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



hi;

on Linux you can use the `xdg-open` command[1] (it should be available
on any reasonably modern distribution as part of the cross-desktop
utilities[0]). you can use xdg-open to open any file or URI you pass
to it with the correct application for the file's MIME type; if that
path is a directory, then the default action is to open a file manager
window.

if you have access to a recent enough version of GLib, you should use
GSubprocess; alternatively, use the g_spawn_* family of functions.

ciao,
 Emmanuele.

[0] http://portland.freedesktop.org/xdg-utils-1.0/
[1] http://portland.freedesktop.org/xdg-utils-1.0/xdg-open.html

On 7 February 2014 22:39,  <christian bluepanel org> wrote:
Hello there,

I'm trying to implement an "open in file manager" button in Gtk2
(a specific path given).
After checking many different sites without finding an answer or any
reference to this issue, how to do this "the Gtk way", I'm asking you
guys.

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).


Thanks in advance!


Regards,
Christian

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



-- 
W: http://www.emmanuelebassi.name
B: http://blogs.gnome.org/ebassi/


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