[nautilus] smclient: backport and tweak a patch for late SMClient initialization



commit d09b45c72bb1c3573b8f1c0bc83f1d8448ba5309
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sat Oct 30 17:17:29 2010 +0200

    smclient: backport and tweak a patch for late SMClient initialization
    
    This is a tweak of a patch bt Vincent Untz, see libegg commit
    dc8db697dfaf8e57fbc9fe5251675a27e8c54f44

 cut-n-paste-code/libegg/eggsmclient.c |   38 +++++++++++++++++++++++++-------
 1 files changed, 29 insertions(+), 9 deletions(-)
---
diff --git a/cut-n-paste-code/libegg/eggsmclient.c b/cut-n-paste-code/libegg/eggsmclient.c
index efa901d..acb3d93 100644
--- a/cut-n-paste-code/libegg/eggsmclient.c
+++ b/cut-n-paste-code/libegg/eggsmclient.c
@@ -186,7 +186,7 @@ sm_client_post_parse_func (GOptionContext  *context,
 			   gpointer         data,
 			   GError         **error)
 {
-  EggSMClient *client = egg_sm_client_get ();
+  EggSMClient *client;
 
   if (sm_client_id == NULL)
     {
@@ -202,8 +202,14 @@ sm_client_post_parse_func (GOptionContext  *context,
    * use the same client id. */
   g_unsetenv ("DESKTOP_AUTOSTART_ID");
 
-  if (EGG_SM_CLIENT_GET_CLASS (client)->startup)
-    EGG_SM_CLIENT_GET_CLASS (client)->startup (client, sm_client_id);
+  if (global_client_mode != EGG_SM_CLIENT_MODE_DISABLED)
+    {
+      client = egg_sm_client_get ();
+
+      if (EGG_SM_CLIENT_GET_CLASS (client)->startup)
+	EGG_SM_CLIENT_GET_CLASS (client)->startup (client, sm_client_id);
+    }
+
   return TRUE;
 }
 
@@ -265,9 +271,9 @@ egg_sm_client_get_option_group (void)
  * Sets the "mode" of #EggSMClient as follows:
  *
  *    %EGG_SM_CLIENT_MODE_DISABLED: Session management is completely
- *    disabled. The application will not even connect to the session
- *    manager. (egg_sm_client_get() will still return an #EggSMClient,
- *    but it will just be a dummy object.)
+ *    disabled, until the mode is changed again. The application will
+ *    not even connect to the session manager. (egg_sm_client_get()
+ *    will still return an #EggSMClient object.)
  *
  *    %EGG_SM_CLIENT_MODE_NO_RESTART: The application will connect to
  *    the session manager (and thus will receive notification when the
@@ -277,12 +283,27 @@ egg_sm_client_get_option_group (void)
  *    %EGG_SM_CLIENT_MODE_NORMAL: The default. #EggSMCLient will
  *    function normally.
  *
- * This must be called before the application's main loop begins.
+ * This must be called before the application's main loop begins and
+ * before any call to egg_sm_client_get(), unless the mode was set
+ * earlier to %EGG_SM_CLIENT_MODE_DISABLED and this call enables
+ * session management. Note that option parsing will call
+ * egg_sm_client_get().
  **/
 void
 egg_sm_client_set_mode (EggSMClientMode mode)
 {
+  EggSMClientMode old_mode = global_client_mode;
+
+  g_return_if_fail (global_client == NULL || global_client_mode == EGG_SM_CLIENT_MODE_DISABLED);
+  g_return_if_fail (!(global_client != NULL && mode == EGG_SM_CLIENT_MODE_DISABLED));
+
   global_client_mode = mode;
+
+  if (global_client != NULL && old_mode == EGG_SM_CLIENT_MODE_DISABLED)
+    {
+      if (EGG_SM_CLIENT_GET_CLASS (global_client)->startup)
+        EGG_SM_CLIENT_GET_CLASS (global_client)->startup (global_client, sm_client_id);
+    }
 }
 
 /**
@@ -317,8 +338,7 @@ egg_sm_client_get (void)
 {
   if (!global_client)
     {
-      if (global_client_mode != EGG_SM_CLIENT_MODE_DISABLED &&
-	  !sm_client_disable)
+      if (!sm_client_disable)
 	{
 #if defined (GDK_WINDOWING_WIN32)
 	  global_client = egg_sm_client_win32_new ();



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