[gnome-terminal] Update EggSMClient from libegg



commit 4200c2720d2a3ba9dabab788456a9e64ed5c83aa
Author: Vincent Untz <vuntz gnome org>
Date:   Thu Dec 23 14:28:06 2010 +0100

    Update EggSMClient from libegg
    
    This fixes the build with latest GTK+ 3.

 src/eggdesktopfile.c      |   12 +++++++++-
 src/eggdesktopfile.h      |    5 +++-
 src/eggsmclient-osx.c     |    4 +-
 src/eggsmclient-private.h |    8 +++++-
 src/eggsmclient-win32.c   |    2 +-
 src/eggsmclient-xsmp.c    |   56 ++++++++++----------------------------------
 src/eggsmclient.c         |   52 ++++++++++++++++++-----------------------
 src/eggsmclient.h         |    8 +-----
 8 files changed, 62 insertions(+), 85 deletions(-)
---
diff --git a/src/eggdesktopfile.c b/src/eggdesktopfile.c
index a46dc55..9b12af5 100644
--- a/src/eggdesktopfile.c
+++ b/src/eggdesktopfile.c
@@ -7,7 +7,7 @@
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of
+ * as published by the Free Software Foundation; either version 2 of
  * the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful, but
@@ -431,6 +431,16 @@ egg_desktop_file_get_numeric (EggDesktopFile  *desktop_file,
 				error);
 }
 
+int
+egg_desktop_file_get_integer (EggDesktopFile *desktop_file,
+			      const char     *key,
+    			      GError	    **error)
+{
+  return g_key_file_get_integer (desktop_file->key_file,
+				 EGG_DESKTOP_FILE_GROUP, key,
+				 error);
+}
+
 char **
 egg_desktop_file_get_string_list (EggDesktopFile  *desktop_file,
 				  const char      *key,
diff --git a/src/eggdesktopfile.h b/src/eggdesktopfile.h
index 17bd96e..16c5426 100644
--- a/src/eggdesktopfile.h
+++ b/src/eggdesktopfile.h
@@ -3,7 +3,7 @@
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of
+ * as published by the Free Software Foundation; either version 2 of
  * the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful, but
@@ -127,6 +127,9 @@ gboolean  egg_desktop_file_get_boolean            (EggDesktopFile  *desktop_file
 double    egg_desktop_file_get_numeric            (EggDesktopFile  *desktop_file,
 						   const char      *key,
 						   GError         **error);
+int       egg_desktop_file_get_integer            (EggDesktopFile  *desktop_file,
+						   const char      *key,
+						   GError         **error);
 char    **egg_desktop_file_get_string_list        (EggDesktopFile  *desktop_file,
 						   const char      *key,
 						   gsize           *length,
diff --git a/src/eggsmclient-osx.c b/src/eggsmclient-osx.c
index e6fa376..7d3ff4b 100644
--- a/src/eggsmclient-osx.c
+++ b/src/eggsmclient-osx.c
@@ -5,7 +5,7 @@
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
+ * version 2 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -37,7 +37,7 @@
 #include "config.h"
 
 #include "eggsmclient-private.h"
-#include <gdk/gdkquartz.h>
+#include <glib.h>
 #include <Carbon/Carbon.h>
 #include <CoreServices/CoreServices.h>
 
diff --git a/src/eggsmclient-private.h b/src/eggsmclient-private.h
index d1e39cb..0c98eee 100644
--- a/src/eggsmclient-private.h
+++ b/src/eggsmclient-private.h
@@ -4,7 +4,7 @@
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
+ * version 2 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,7 +20,13 @@
 #ifndef __EGG_SM_CLIENT_PRIVATE_H__
 #define __EGG_SM_CLIENT_PRIVATE_H__
 
+#include <gtk/gtk.h>
+
+#if !GTK_CHECK_VERSION(2,91,7) && !GTK_CHECK_VERSION(3,0,0)
+/* GTK+ 3 includes this automatically */
 #include <gdkconfig.h>
+#endif
+
 #include "eggsmclient.h"
 
 G_BEGIN_DECLS
diff --git a/src/eggsmclient-win32.c b/src/eggsmclient-win32.c
index a762c6c..91a2571 100644
--- a/src/eggsmclient-win32.c
+++ b/src/eggsmclient-win32.c
@@ -4,7 +4,7 @@
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
+ * version 2 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/src/eggsmclient-xsmp.c b/src/eggsmclient-xsmp.c
index 801d43e..ec1b594 100644
--- a/src/eggsmclient-xsmp.c
+++ b/src/eggsmclient-xsmp.c
@@ -8,7 +8,7 @@
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
+ * version 2 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -36,6 +36,7 @@
 #include <X11/SM/SMlib.h>
 
 #include <gdk/gdk.h>
+#include <gdk/gdkx.h>
 
 #define EGG_TYPE_SM_CLIENT_XSMP            (egg_sm_client_xsmp_get_type ())
 #define EGG_SM_CLIENT_XSMP(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_SM_CLIENT_XSMP, EggSMClientXSMP))
@@ -88,8 +89,6 @@ struct _EggSMClientXSMP
   char **restart_command;
   gboolean set_restart_command;
   int restart_style;
-  char **discard_command;
-  gboolean set_discard_command;
 
   guint idle;
 
@@ -119,9 +118,6 @@ static void     sm_client_xsmp_startup (EggSMClient *client,
 static void     sm_client_xsmp_set_restart_command (EggSMClient  *client,
 						    int           argc,
 						    const char  **argv);
-static void     sm_client_xsmp_set_discard_command (EggSMClient  *client,
-						    int           argc,
-						    const char  **argv);
 static void     sm_client_xsmp_will_quit (EggSMClient *client,
 					  gboolean     will_quit);
 static gboolean sm_client_xsmp_end_session (EggSMClient         *client,
@@ -155,7 +151,7 @@ static SmProp *card8_prop        (const char    *name,
 static void set_properties         (EggSMClientXSMP *xsmp, ...);
 static void delete_properties      (EggSMClientXSMP *xsmp, ...);
 
-static GPtrArray *generate_command (char       **argv,
+static GPtrArray *generate_command (char       **restart_command,
 				    const char  *client_id,
 				    const char  *state_file);
 
@@ -190,7 +186,6 @@ egg_sm_client_xsmp_class_init (EggSMClientXSMPClass *klass)
 
   sm_client_class->startup             = sm_client_xsmp_startup;
   sm_client_class->set_restart_command = sm_client_xsmp_set_restart_command;
-  sm_client_class->set_discard_command = sm_client_xsmp_set_discard_command;
   sm_client_class->will_quit           = sm_client_xsmp_will_quit;
   sm_client_class->end_session         = sm_client_xsmp_end_session;
 }
@@ -373,7 +368,11 @@ sm_client_xsmp_startup (EggSMClient *client,
       free (ret_client_id);
 
       gdk_threads_enter ();
+#if !GTK_CHECK_VERSION(2,91,7) && !GTK_CHECK_VERSION(3,0,0)
       gdk_set_sm_client_id (xsmp->client_id);
+#else
+      gdk_x11_set_sm_client_id (xsmp->client_id);
+#endif
       gdk_threads_leave ();
 
       g_debug ("Got client ID \"%s\"", xsmp->client_id);
@@ -410,24 +409,6 @@ sm_client_xsmp_set_restart_command (EggSMClient  *client,
 }
 
 static void
-sm_client_xsmp_set_discard_command (EggSMClient  *client,
-				    int           argc,
-				    const char  **argv)
-{
-  EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
-  int i;
-
-  g_strfreev (xsmp->discard_command);
-
-  xsmp->discard_command = g_new (char *, argc + 1);
-  for (i = 0; i < argc; i++)
-    xsmp->discard_command[i] = g_strdup (argv[i]);
-  xsmp->discard_command[i] = NULL;
-
-  xsmp->set_discard_command = TRUE;
-}
-
-static void
 sm_client_xsmp_will_quit (EggSMClient *client,
 			  gboolean     will_quit)
 {
@@ -795,7 +776,7 @@ save_state (EggSMClientXSMP *xsmp)
   GKeyFile *state_file;
   char *state_file_path, *data;
   EggDesktopFile *desktop_file;
-  GPtrArray *restart, *discard;
+  GPtrArray *restart;
   int offset, fd;
 
   /* We set xsmp->state before emitting save_state, but our caller is
@@ -811,18 +792,7 @@ save_state (EggSMClientXSMP *xsmp)
 		      ptrarray_prop (SmRestartCommand, restart),
 		      NULL);
       g_ptr_array_free (restart, TRUE);
-
-      if (xsmp->set_discard_command)
-        {
-          discard = generate_command (xsmp->discard_command, NULL, NULL);
-          set_properties (xsmp,
-                          ptrarray_prop (SmDiscardCommand, discard),
-                          NULL);
-          g_ptr_array_free (discard, TRUE);
-        }
-      else
-        delete_properties (xsmp, SmDiscardCommand, NULL);
-
+      delete_properties (xsmp, SmDiscardCommand, NULL);
       return;
     }
 
@@ -1076,14 +1046,14 @@ xsmp_shutdown_cancelled (SmcConn   smc_conn,
  * then free the array, but not its contents.
  */
 static GPtrArray *
-generate_command (char **argv, const char *client_id,
+generate_command (char **restart_command, const char *client_id,
 		  const char *state_file)
 {
   GPtrArray *cmd;
   int i;
 
   cmd = g_ptr_array_new ();
-  g_ptr_array_add (cmd, argv[0]);
+  g_ptr_array_add (cmd, restart_command[0]);
 
   if (client_id)
     {
@@ -1097,8 +1067,8 @@ generate_command (char **argv, const char *client_id,
       g_ptr_array_add (cmd, (char *)state_file);
     }
 
-  for (i = 1; argv[i]; i++)
-    g_ptr_array_add (cmd, argv[i]);
+  for (i = 1; restart_command[i]; i++)
+    g_ptr_array_add (cmd, restart_command[i]);
 
   return cmd;
 }
diff --git a/src/eggsmclient.c b/src/eggsmclient.c
index a7262ab..92be8a7 100644
--- a/src/eggsmclient.c
+++ b/src/eggsmclient.c
@@ -4,7 +4,7 @@
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
+ * version 2 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -202,7 +202,8 @@ 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)
+  if (global_client_mode != EGG_SM_CLIENT_MODE_DISABLED &&
+      EGG_SM_CLIENT_GET_CLASS (client)->startup)
     EGG_SM_CLIENT_GET_CLASS (client)->startup (client, sm_client_id);
   return TRUE;
 }
@@ -265,9 +266,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 +278,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 +333,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 ();
@@ -445,27 +460,6 @@ egg_sm_client_set_restart_command (EggSMClient  *client,
 }
 
 /**
- * egg_sm_client_set_discard_command:
- * @client: the client
- * @argc: the length of @argv
- * @argv: argument vector
- *
- * Sets the command used to discard a custom state file if using
- * egg_sm_client_set_restart_command(), which must be called before 
- * using this function.
- **/
-void
-egg_sm_client_set_discard_command (EggSMClient  *client,
-				   int           argc,
-				   const char  **argv)
-{
-  g_return_if_fail (EGG_IS_SM_CLIENT (client));
-
-  if (EGG_SM_CLIENT_GET_CLASS (client)->set_discard_command)
-    EGG_SM_CLIENT_GET_CLASS (client)->set_discard_command (client, argc, argv);
-}
-
-/**
  * egg_sm_client_will_quit:
  * @client: the client
  * @will_quit: whether or not the application is willing to quit
diff --git a/src/eggsmclient.h b/src/eggsmclient.h
index 6de47b6..e620b75 100644
--- a/src/eggsmclient.h
+++ b/src/eggsmclient.h
@@ -4,7 +4,7 @@
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
+ * version 2 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -72,9 +72,6 @@ struct _EggSMClientClass
   void	   (*set_restart_command) (EggSMClient          *client,
 				   int                   argc,
 				   const char          **argv);
-  void	   (*set_discard_command) (EggSMClient          *client,
-				   int                   argc,
-				   const char          **argv);
   void	   (*will_quit)           (EggSMClient          *client,
 				   gboolean              will_quit);
   gboolean (*end_session)         (EggSMClient          *client,
@@ -105,9 +102,6 @@ GKeyFile        *egg_sm_client_get_state_file      (EggSMClient *client);
 void             egg_sm_client_set_restart_command (EggSMClient  *client,
 						    int           argc,
 						    const char  **argv);
-void             egg_sm_client_set_discard_command (EggSMClient  *client,
-						    int           argc,
-						    const char  **argv);
 
 /* Handling "quit_requested" signal */
 void             egg_sm_client_will_quit           (EggSMClient *client,



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