gnome-terminal r3088 - trunk/src



Author: chpe
Date: Wed Sep 24 20:11:50 2008
New Revision: 3088
URL: http://svn.gnome.org/viewvc/gnome-terminal?rev=3088&view=rev

Log:
Update from libegg.

Modified:
   trunk/src/eggdesktopfile.c
   trunk/src/eggsmclient-xsmp.c
   trunk/src/eggsmclient.c
   trunk/src/eggsmclient.h

Modified: trunk/src/eggdesktopfile.c
==============================================================================
--- trunk/src/eggdesktopfile.c	(original)
+++ trunk/src/eggdesktopfile.c	Wed Sep 24 20:11:50 2008
@@ -25,9 +25,6 @@
 #include "config.h"
 #endif
 
-#undef HAVE_GDK_X11_DISPLAY_BROADCAST_STARTUP_MESSAGE
-#define HAVE_GDK_X11_DISPLAY_BROADCAST_STARTUP_MESSAGE 1
-
 #include "eggdesktopfile.h"
 
 #include <string.h>
@@ -826,7 +823,7 @@
   return TRUE;
 }
 
-#ifdef HAVE_GDK_X11_DISPLAY_BROADCAST_STARTUP_MESSAGE
+#if GTK_CHECK_VERSION (2, 12, 0)
 static char *
 start_startup_notification (GdkDisplay     *display,
 			    EggDesktopFile *desktop_file,
@@ -937,9 +934,7 @@
   g_timeout_add (EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH,
 		 startup_notification_timeout, sn_data);
 }
-#endif /* HAVE_GDK_X11_DISPLAY_BROADCAST_STARTUP_MESSAGE */
-
-extern char **environ;
+#endif /* GTK 2.12 */
 
 static GPtrArray *
 array_putenv (GPtrArray *env, char *variable)
@@ -948,10 +943,20 @@
 
   if (!env)
     {
+      char **envp;
+
       env = g_ptr_array_new ();
 
-      for (i = 0; environ[i]; i++)
-	g_ptr_array_add (env, g_strdup (environ[i]));
+      envp = g_listenv ();
+      for (i = 0; envp[i]; i++)
+        {
+          const char *value;
+
+          value = g_getenv (envp[i]);
+          g_ptr_array_add (env, g_strdup_printf ("%s=%s", envp[i],
+                                                 value ? value : ""));
+        }
+      g_strfreev (envp);
     }
 
   keylen = strcspn (variable, "=");
@@ -1116,7 +1121,7 @@
 	}
       g_free (command);
 
-#ifdef HAVE_GDK_X11_DISPLAY_BROADCAST_STARTUP_MESSAGE
+#if GTK_CHECK_VERSION (2, 12, 0)
       startup_id = start_startup_notification (display, desktop_file,
 					       argv[0], screen_num,
 					       workspace, launch_time);
@@ -1129,7 +1134,7 @@
 	}
 #else
       startup_id = NULL;
-#endif /* HAVE_GDK_X11_DISPLAY_BROADCAST_STARTUP_MESSAGE */
+#endif /* GTK 2.12 */
 
       current_success =
 	g_spawn_async_with_pipes (directory,
@@ -1144,7 +1149,7 @@
 
       if (startup_id)
 	{
-#ifdef HAVE_GDK_X11_DISPLAY_BROADCAST_STARTUP_MESSAGE
+#if GTK_CHECK_VERSION (2, 12, 0)
 	  if (current_success)
 	    {
 	      set_startup_notification_timeout (display, startup_id);
@@ -1155,7 +1160,7 @@
 		g_free (startup_id);
 	    }
 	  else
-#endif /* HAVE_GDK_X11_DISPLAY_BROADCAST_STARTUP_MESSAGE */
+#endif /* GTK 2.12 */
 	    g_free (startup_id);
 	}
       else if (ret_startup_id)

Modified: trunk/src/eggsmclient-xsmp.c
==============================================================================
--- trunk/src/eggsmclient-xsmp.c	(original)
+++ trunk/src/eggsmclient-xsmp.c	Wed Sep 24 20:11:50 2008
@@ -89,6 +89,8 @@
   char **restart_command;
   gboolean set_restart_command;
   int restart_style;
+  char **discard_command;
+  gboolean set_discard_command;
 
   guint idle;
 
@@ -118,6 +120,9 @@
 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,
@@ -151,7 +156,7 @@
 static void set_properties         (EggSMClientXSMP *xsmp, ...);
 static void delete_properties      (EggSMClientXSMP *xsmp, ...);
 
-static GPtrArray *generate_command (char       **restart_command,
+static GPtrArray *generate_command (char       **argv,
 				    const char  *client_id,
 				    const char  *state_file);
 
@@ -186,6 +191,7 @@
 
   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;
 }
@@ -410,6 +416,26 @@
 }
 
 static void
+sm_client_xsmp_set_discard_command (EggSMClient  *client,
+				    int           argc,
+				    const char  **argv)
+{
+  EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
+  int i;
+
+  g_return_if_fail (xsmp->set_restart_command);
+
+  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)
 {
@@ -801,7 +827,7 @@
   GKeyFile *state_file;
   char *state_file_path, *data;
   EggDesktopFile *desktop_file;
-  GPtrArray *restart;
+  GPtrArray *restart, *discard;
   int offset, fd;
 
   /* We set xsmp->state before emitting save_state, but our caller is
@@ -817,7 +843,18 @@
 		      ptrarray_prop (SmRestartCommand, restart),
 		      NULL);
       g_ptr_array_free (restart, TRUE);
-      delete_properties (xsmp, SmDiscardCommand, NULL);
+
+      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);
+
       return;
     }
 
@@ -1040,14 +1077,14 @@
  * then free the array, but not its contents.
  */
 static GPtrArray *
-generate_command (char **restart_command, const char *client_id,
+generate_command (char **argv, const char *client_id,
 		  const char *state_file)
 {
   GPtrArray *cmd;
   int i;
 
   cmd = g_ptr_array_new ();
-  g_ptr_array_add (cmd, restart_command[0]);
+  g_ptr_array_add (cmd, argv[0]);
 
   if (client_id)
     {
@@ -1061,8 +1098,8 @@
       g_ptr_array_add (cmd, (char *)state_file);
     }
 
-  for (i = 1; restart_command[i]; i++)
-    g_ptr_array_add (cmd, restart_command[i]);
+  for (i = 1; argv[i]; i++)
+    g_ptr_array_add (cmd, argv[i]);
 
   return cmd;
 }

Modified: trunk/src/eggsmclient.c
==============================================================================
--- trunk/src/eggsmclient.c	(original)
+++ trunk/src/eggsmclient.c	Wed Sep 24 20:11:50 2008
@@ -214,9 +214,12 @@
     { "sm-client-id", 0, 0,
       G_OPTION_ARG_STRING, &sm_client_id,
       N_("Specify session management ID"), N_("ID") },
+    /* Compatibility options */
+    { "sm-disable", 0, G_OPTION_FLAG_HIDDEN,
+      G_OPTION_ARG_NONE, &sm_client_disable,
+      NULL, NULL },
     { NULL }
   };
-
   GOptionGroup *group;
 
   /* Use our own debug handler for the "EggSMClient" domain. */
@@ -224,10 +227,9 @@
 		     egg_sm_client_debug_handler, NULL);
 
   group = g_option_group_new ("sm-client",
-			      N_("Session Management Options:"),
-			      N_("Show session management options"),
+			      _("Session management options:"),
+			      _("Show session management options"),
 			      NULL, NULL);
-  g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);
   g_option_group_add_entries (group, entries);
   g_option_group_set_parse_hooks (group, NULL, sm_client_post_parse_func);
 
@@ -421,6 +423,27 @@
 }
 
 /**
+ * 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

Modified: trunk/src/eggsmclient.h
==============================================================================
--- trunk/src/eggsmclient.h	(original)
+++ trunk/src/eggsmclient.h	Wed Sep 24 20:11:50 2008
@@ -72,6 +72,9 @@
   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,
@@ -102,6 +105,9 @@
 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]