summaryrefslogtreecommitdiff
path: root/control-center
diff options
context:
space:
mode:
authorRichard Hestilow <hestilow@ximian.com>2002-01-21 22:44:12 +0000
committerRachel Hestilow <hestgray@src.gnome.org>2002-01-21 22:44:12 +0000
commit836434f1f05c201d413f0fcf94e8ba0b23641920 (patch)
treeea6cf3304b70e983c1047b327f8bfad7a3b564c0 /control-center
parent6b980e6eaa3ff3a51a612aa8c26a43fe75b1ff15 (diff)
downloadgnome-control-center-836434f1f05c201d413f0fcf94e8ba0b23641920.tar.gz
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.
Diffstat (limited to 'control-center')
-rw-r--r--control-center/ChangeLog4
-rw-r--r--control-center/main.c72
2 files changed, 74 insertions, 2 deletions
diff --git a/control-center/ChangeLog b/control-center/ChangeLog
index a2331711f..b4f30ac77 100644
--- a/control-center/ChangeLog
+++ b/control-center/ChangeLog
@@ -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
diff --git a/control-center/main.c b/control-center/main.c
index 140ce3ef6..83a9515e6 100644
--- a/control-center/main.c
+++ b/control-center/main.c
@@ -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,8 +115,9 @@ 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 ();
if (dir == NULL)