Re: nautilus vs. gnome-settings-daemon "race"



On Fri, 2002-07-12 at 14:54, jacob berkman wrote:
> gnome-settings-daemon currently checks to see if nautilus is running,
> and if so won't draw the background image.
> 
> gnome-session starts gnome-settings-daemon before nautilus, so nautilus
> isn't running when gnome-settings-daemon goes to draw the background. 
> this causes the background to get drawn twice, which slows down login a
> bit.

here's a different approach - since gsm spawns gsd, we can just tell it
directly via monikers whether it should draw the background or not.

this is just a proof-of-concept, i don't know if it works yet.  but i
think i like the other method a little better...

 - jacob
Index: gnome-control-center/gnome-settings-daemon/gnome-settings-daemon.c
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/gnome-settings-daemon.c,v
retrieving revision 1.25
diff -u -r1.25 gnome-settings-daemon.c
--- gnome-control-center/gnome-settings-daemon/gnome-settings-daemon.c	30 May 2002 00:25:29 -0000	1.25
+++ gnome-control-center/gnome-settings-daemon/gnome-settings-daemon.c	15 Jul 2002 17:56:40 -0000
@@ -30,6 +30,7 @@
 #include <gconf/gconf.h>
 #include <libgnome/gnome-init.h>
 #include <libgnomeui/gnome-ui-init.h>
+#include <bonobo/bonobo-item-handler.h>
 #include <config.h>
 #include "xsettings-manager.h"
 #include "gnome-settings-daemon.h"
@@ -197,6 +198,39 @@
 BONOBO_TYPE_FUNC_FULL(GnomeSettingsDaemon, GNOME_SettingsDaemon,
 		      BONOBO_TYPE_OBJECT, gnome_settings_daemon)
 
+static Bonobo_Unknown
+background_get_object_cb (BonoboItemHandler *itemh,
+			  const char *item_name,
+			  gboolean only_if_exists,
+			  gpointer data,
+			  CORBA_Environment *env)
+{
+  BonoboItemOption *option;
+  GSList *options, *li;
+  gboolean draw_background = FALSE;
+
+  options = bonobo_item_option_parse (item_name);
+  for (li = options; li; li=li->next)
+    {
+      option = li->data;
+
+      if (!strcmp (option->key, "DrawBackground"))
+	{
+	  draw_background = 
+	    g_ascii_tolower (*option->value) == 't' ||
+	    g_ascii_tolower (*option->value) == 'y' ||
+	    atoi (option->value)
+	    ? TRUE
+	    : FALSE;
+	}
+    }
+
+  if (draw_background)
+    gnome_settings_background_load (gconf_client_get_default ());
+
+  return bonobo_object_dup_ref (bonobo_object_corba_objref (BONOBO_OBJECT (itemh)), env);
+}
+
 GObject *
 gnome_settings_daemon_new (void)
 {
@@ -204,6 +238,7 @@
   GConfClient *client;
   GSList *list;
   GnomeSettingsDaemon *daemon;
+  BonoboItemHandler *item_handler;
 
   daemon = g_object_new (gnome_settings_daemon_get_type (), NULL);
 
@@ -279,8 +314,11 @@
   gnome_settings_accessibility_keyboard_load (client);
   gnome_settings_screensaver_load (client);
   gnome_settings_default_editor_load (client);
-  gnome_settings_background_load (client);
-  gnome_settings_keybindings_load (client);
+  gnome_settings_keybindings_load (client);  
+
+  item_handler = bonobo_item_handler_new (NULL, background_get_object_cb, daemon);
+  bonobo_object_add_interface (BONOBO_OBJECT (daemon),
+			       BONOBO_OBJECT (item_handler));
 
   return G_OBJECT (daemon);
 }
Index: gnome-session/gnome-session/main.c
===================================================================
RCS file: /cvs/gnome/gnome-session/gnome-session/main.c,v
retrieving revision 1.47
diff -u -r1.47 main.c
--- gnome-session/gnome-session/main.c	15 Jul 2002 14:25:09 -0000	1.47
+++ gnome-session/gnome-session/main.c	15 Jul 2002 17:56:40 -0000
@@ -222,7 +222,7 @@
 	  
 	  gtk_window_set_position (GTK_WINDOW (tmp_msgbox), GTK_WIN_POS_CENTER);
 	}
-
+      
       gtk_dialog_set_default_response (GTK_DIALOG (tmp_msgbox), RESPONSE_TRY_AGAIN);
 
       if (RESPONSE_TRY_AGAIN != gtk_dialog_run (GTK_DIALOG (tmp_msgbox)))
@@ -353,7 +353,7 @@
 
   gsm_sound_login ();
 
-  gsm_gsd_start ();
+  gsm_gsd_start (the_session);
 
   if (splashing)
     start_splash (49.0);
Index: gnome-session/gnome-session/gsm-gsd.c
===================================================================
RCS file: /cvs/gnome/gnome-session/gnome-session/gsm-gsd.c,v
retrieving revision 1.2
diff -u -r1.2 gsm-gsd.c
--- gnome-session/gnome-session/gsm-gsd.c	20 Jun 2002 16:45:25 -0000	1.2
+++ gnome-session/gnome-session/gsm-gsd.c	15 Jul 2002 17:56:40 -0000
@@ -121,12 +121,46 @@
   ORBit_small_listen_for_broken (object, G_CALLBACK (broken_cb), gsd);
 }
 
+/* 
+ * check that we are starting nautilus and that it draws the
+ * background.
+ */
+static gboolean
+nautilus_draws_background (Session *session)
+{
+  GSList *li;
+  SmProp *prop;
+  char *program;
+
+  g_return_if_fail (session != NULL);
+
+  for (li = session->client_list; li; li = li->next)
+    {
+      prop = find_property_by_name ((Client *)li->data, SmRestartCommand);
+      if (!prop)
+	continue;
+
+      program = strrchr (prop->vals[0].value, G_DIR_SEPARATOR);
+      program = program ? program+1 : prop->vals[0].value;
+
+      if (!strcmp (program, "nautilus"))
+	{
+	  return gconf_client_get_bool (gconf_client_get_default (),
+					"/apps/nautilus/preferences/show_desktop",
+					NULL);
+	}
+    }
+
+  return FALSE;
+}
+
 void
-gsm_gsd_start (void)
+gsm_gsd_start (Session *session)
 {
   static GnomeSettingsData gsd = { CORBA_OBJECT_NIL };
   CORBA_Environment ev;
   time_t now;
+  char *moniker;
 
   gsm_verbose ("gsm_gsd_start(): starting");
 
@@ -160,13 +194,19 @@
 
   gsd.activating = TRUE;
 
+  moniker = g_strdup_printf ("OAFIID:GNOME_SettingsDaemon!DrawBackground=%s",
+			     nautilus_draws_background (the_session)
+			     ? "False" : "True");
+
   CORBA_exception_init (&ev);
 
-  bonobo_get_object_async ("OAFIID:GNOME_SettingsDaemon",
+  bonobo_get_object_async (moniker,
 			   "IDL:Bonobo/Unknown:1.0",
 			   &ev,
 			   activate_cb,
 			   &gsd);
+
+  g_free (moniker);
 
   if (BONOBO_EX (&ev))
     {


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