Platform independent solutions for: copy&paste, notify user and open weblink

Hi,

For our project (OpenLieroX), we needed some platform independent
solutions for these three things (copy&paste, notify user and open
weblinks), whereby it should at least work on major versions of Windows,
Linux and MacOSX. Another requirement was to be independent from any big
framework like GTK or Qt (because we don’t want to include such a
framework only for these small functions).

It was not easy because these three systems handle such things very
different. And it was also not easy because it was hard to find other
projects with implementations of these things.

But finally we managed to collect code from different sources and
implemented the rest ourselves to achieve this, meaning all of the three
features working fine on all systems tested so far.

If somebody is interested, here is the source (licensed under LGPL):

Copy&Paste:
http://openlierox.svn.sourceforge.net/viewvc/openlierox/include/Clipboard.h?view=markup
http://openlierox.svn.sourceforge.net/viewvc/openlierox/src/client/Clipboard.cpp?view=markup

Notify user:
http://openlierox.svn.sourceforge.net/viewvc/openlierox/include/NotifyUser.h?view=markup
http://openlierox.svn.sourceforge.net/viewvc/openlierox/src/client/NotifyUser.cpp?view=markup

Open weblink:
http://openlierox.svn.sourceforge.net/viewvc/openlierox/src/client/OpenExternBrowser.cpp?view=markup

I write because I am still not happy with all solutions (although they
are working really fine right now).

One thing is the ongoing discussion about the MacOSX Carbon framework.
All MacOSX implementations of these three things depend on Carbon and I
was thus not able to compile it for 64bit under MacOSX. And I am
concerned about future versions of MacOSX. Is it true that all
Carbon-dependent applications will not run anymore on OSX 10.6+? Anyway,
does perhaps somebody have a (L)GPL licensed implementation of these
things in Cocoa?

Then, I am not happy about the OpenExternBrowser implementation for
Unix/Linux systems. Currently, it just checks for the environment
variable BROWSER and a number of standard webbrowsers and starts the
first available one. I have seen similar implementations at various
places. But I am not sure myself if there is any default way to do this
at all. It seems that Gnome and KDE doesn’t share a common configuration
about the default browser, so the default browser of KDE could be
different from the one in Gnome. I think Gnome stores this somewhere in
GConf. I don’t know about KDE. And probably other desktop environments
again have different settings. If Gnome is available, on some systems a
binary called ‘gnome-open’ seem to open the link always in the default
browser, therefore this binary is on very top in the list. Then, on
Ubuntu systems I have seen a small wrapper-binary called
‘sensible-browser’ which should also open the link in the default
browser. Therefore, this is the second entry in the list. Following are
Firefox, Konqueror, Mozilla and so on. I really don’t like this solution
that much but I wonder if there is any better way to do this at all.

Another reason for writing is that I wonder if such functions could
perhaps make it into the SDL library itself. I think that are very
useful and general functions everybody could use/need once here and
there.

Many greetings,
Albert

Den Sun, 09 Nov 2008 23:49:22 +0100
skrev Albert Zeyer <albert.zeyer at rwth-aachen.de>:

Then, I am not happy about the OpenExternBrowser implementation for
Unix/Linux systems. Currently, it just checks for the environment
variable BROWSER and a number of standard webbrowsers and starts the
(…)

For Linux you should use xdg-open, from the xdg utils:

http://portland.freedesktop.org/wiki/XdgUtils

Modern distros come with their own version of xdg-open that does the
right thing, and you can provide a default fallback script for the rest.
(See the “using xdg-utils” section there). You could append the dir
of your xdg-open to PATH in a wrapper script, or just manipulate the
environment in the executable itself if you don’t want a wrapper. Then
you can call xdg-open with execlp or execvp (or, system("… &") can
be convenient if you’re feeling quick and dirty… =])

  • Gerry

Den Sun, 09 Nov 2008 23:49:22 +0100
skrev Albert Zeyer <@Albert_Zeyer>:

Then, I am not happy about the OpenExternBrowser implementation for
Unix/Linux systems. Currently, it just checks for the environment
variable BROWSER and a number of standard webbrowsers and starts the
(…)

For Linux you should use xdg-open, from the xdg utils:

http://portland.freedesktop.org/wiki/XdgUtils

Modern distros come with their own version of xdg-open that does the
right thing, and you can provide a default fallback script for the
rest.
(See the “using xdg-utils” section there). You could append the dir
of your xdg-open to PATH in a wrapper script, or just manipulate the
environment in the executable itself if you don’t want a wrapper. Then
you can call xdg-open with execlp or execvp (or, system("… &") can
be convenient if you’re feeling quick and dirty… =])

  • Gerry

Thanks a lot. I just added xdg-open also to the (top of) list of
browsers. :slight_smile:

  • AlbertAm 10.11.2008 um 19:03 schrieb Gerry JJ: