Use nautilus as the shell if it is already running.
2002-01-21 Richard Hestilow <hestilow@ximian.com> * main.c: Use nautilus as the shell if it is already running.
This commit is contained in:
parent
6b980e6eaa
commit
836434f1f0
2 changed files with 74 additions and 2 deletions
|
@ -1,3 +1,7 @@
|
|||
2002-01-21 Richard Hestilow <hestilow@ximian.com>
|
||||
|
||||
* main.c: Use nautilus as the shell if it is already running.
|
||||
|
||||
2002-01-17 Jakub Steiner <jimmac@ximian.com>
|
||||
|
||||
* control-center.png: fix the antialiasing
|
||||
|
|
|
@ -29,10 +29,77 @@
|
|||
#include <glade/glade.h>
|
||||
#include <bonobo.h>
|
||||
#include <gconf/gconf.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
#include "capplet-dir.h"
|
||||
#include "capplet-dir-view.h"
|
||||
|
||||
static gboolean
|
||||
is_nautilus_running (void)
|
||||
{
|
||||
Atom window_id_atom;
|
||||
Window nautilus_xid;
|
||||
Atom actual_type;
|
||||
int actual_format;
|
||||
unsigned long nitems, bytes_after;
|
||||
unsigned char *data;
|
||||
int retval;
|
||||
Atom wmclass_atom;
|
||||
gboolean running;
|
||||
gint error;
|
||||
|
||||
window_id_atom = XInternAtom (GDK_DISPLAY (),
|
||||
"NAUTILUS_DESKTOP_WINDOW_ID", True);
|
||||
|
||||
if (window_id_atom == None) return FALSE;
|
||||
|
||||
retval = XGetWindowProperty (GDK_DISPLAY (), GDK_ROOT_WINDOW (),
|
||||
window_id_atom, 0, 1, False, XA_WINDOW,
|
||||
&actual_type, &actual_format, &nitems,
|
||||
&bytes_after, &data);
|
||||
|
||||
if (data != NULL) {
|
||||
nautilus_xid = *(Window *) data;
|
||||
XFree (data);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (actual_type != XA_WINDOW) return FALSE;
|
||||
if (actual_format != 32) return FALSE;
|
||||
|
||||
wmclass_atom = XInternAtom (GDK_DISPLAY (), "WM_CLASS", False);
|
||||
|
||||
gdk_error_trap_push ();
|
||||
|
||||
retval = XGetWindowProperty (GDK_DISPLAY (), nautilus_xid,
|
||||
wmclass_atom, 0, 24, False, XA_STRING,
|
||||
&actual_type, &actual_format, &nitems,
|
||||
&bytes_after, &data);
|
||||
|
||||
error = gdk_error_trap_pop ();
|
||||
|
||||
if (error == BadWindow) return FALSE;
|
||||
|
||||
if (actual_type == XA_STRING &&
|
||||
nitems == 24 &&
|
||||
bytes_after == 0 &&
|
||||
actual_format == 8 &&
|
||||
data != NULL &&
|
||||
!strcmp (data, "desktop_window") &&
|
||||
!strcmp (data + strlen (data) + 1, "Nautilus"))
|
||||
running = TRUE;
|
||||
else
|
||||
running = FALSE;
|
||||
|
||||
if (data != NULL)
|
||||
XFree (data);
|
||||
|
||||
return running;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
|
@ -48,7 +115,8 @@ main (int argc, char **argv)
|
|||
GNOME_PARAM_APP_DATADIR, GNOMECC_DATA_DIR,
|
||||
NULL);
|
||||
|
||||
gconf_init (argc, argv, NULL);
|
||||
if (is_nautilus_running ())
|
||||
execlp ("nautilus", "nautilus", "preferences:///", NULL);
|
||||
|
||||
gnomecc_init ();
|
||||
dir = get_root_capplet_dir ();
|
||||
|
|
Loading…
Add table
Reference in a new issue