Re: How to start a filemanager in Gtk2 "the proper way"



On Sat, Feb 8, 2014 at 9:39 AM,  <christian bluepanel org> wrote:
Is there any "proper way" to do this or do I have use #ifdef syntax to
check for the system?

#ifdef __unix__
    //my start code
#elif __WIN32__
    // start windows code here
#else
    // fallback code..?
#endif


If there is no conventional way, I'd use the #ifdef-elif-else macros to
find out the operating system and call explorer.exe on Windows, xdg-open
on Linux/Unix and finder on Mac (although I have no way to test it on
Mac).

If there is a single proper way, I want to hear about it too. What you
have there is very similar to my code for attempting to open a URL in
the default browser:

https://github.com/Rosuav/Gypsum/blob/master/globals.pike#L469

I'd love to simplify that and make it more reliable. There are four
separate commands *that I know of* for different Linux window
managers, and none of them is guaranteed to exist. And be careful.
Windows uses "start" and Mac OS uses "open", and all three platforms
could well have commands with either of those names. So you _will_
need the #if checks if you do it that way.

ChrisA


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]