gnome-terminal r3381 - trunk/src



Author: chpe
Date: Thu Mar 19 13:49:02 2009
New Revision: 3381
URL: http://svn.gnome.org/viewvc/gnome-terminal?rev=3381&view=rev

Log:
Bug 575308 â Make gnome-terminal session loading work
Based on the patch by Hiroyuki Ikezoe.

Modified:
   trunk/src/terminal-app.c
   trunk/src/terminal-app.h
   trunk/src/terminal-options.c
   trunk/src/terminal-options.h
   trunk/src/terminal.c

Modified: trunk/src/terminal-app.c
==============================================================================
--- trunk/src/terminal-app.c	(original)
+++ trunk/src/terminal-app.c	Thu Mar 19 13:49:02 2009
@@ -1643,9 +1643,24 @@
   return global_app;
 }
 
+/**
+ * terminal_app_handle_options:
+ * @app:
+ * @options: a #TerminalOptions
+ * @allow_resume: whether to merge the terminal configuration from the
+ *   saved session on resume
+ * @error: a #GError to fill in
+ *
+ * Processes @options. It loads or saves the terminal configuration, or
+ * opens the specified windows and tabs.
+ *
+ * Returns: %TRUE if @options could be successfully handled, or %FALSE on
+ *   error
+ */
 gboolean
 terminal_app_handle_options (TerminalApp *app,
                              TerminalOptions *options,
+                             gboolean allow_resume,
                              GError **error)
 {
   GList *lw;
@@ -1673,6 +1688,27 @@
       /* fall-through on success */
     }
 
+#ifdef WITH_SMCLIENT
+{
+  EggSMClient *sm_client;
+
+  sm_client = egg_sm_client_get ();
+
+  if (allow_resume && egg_sm_client_is_resumed (sm_client))
+    {
+      GKeyFile *key_file;
+
+      key_file = egg_sm_client_get_state_file (sm_client);
+      if (key_file != NULL &&
+          !terminal_options_merge_config (options, key_file, error))
+        return FALSE;
+    }
+}
+#endif
+
+  /* Make sure we option at least one window */
+  terminal_options_ensure_window (options);
+
   for (lw = options->initial_windows;  lw != NULL; lw = lw->next)
     {
       InitialWindow *iw = lw->data;

Modified: trunk/src/terminal-app.h
==============================================================================
--- trunk/src/terminal-app.h	(original)
+++ trunk/src/terminal-app.h	Thu Mar 19 13:49:02 2009
@@ -93,6 +93,7 @@
 
 gboolean terminal_app_handle_options (TerminalApp *app,
                                       TerminalOptions *options,
+                                      gboolean allow_resume,
                                       GError **error);
 
 void terminal_app_edit_profile (TerminalApp     *app,

Modified: trunk/src/terminal-options.c
==============================================================================
--- trunk/src/terminal-options.c	(original)
+++ trunk/src/terminal-options.c	Thu Mar 19 13:49:02 2009
@@ -636,10 +636,6 @@
   TerminalOptions *options = data;
   InitialTab    *it;
 
-  /* make sure we have some window in case no options were given */
-  if (options->initial_windows == NULL)
-    it = ensure_top_tab (options);
-
   if (options->execute)
     {
       if (options->exec_argv == NULL)
@@ -662,6 +658,25 @@
   return TRUE;
 }
 
+/**
+ * terminal_options_parse:
+ * @working_directory: the default working directory
+ * @display_name: the default X display name
+ * @startup_id: the startup notification ID
+ * @env: the environment as variable=value pairs
+ * @ignore_unknown_options: whether to ignore unknown options when parsing
+ *   the arguments
+ * @argcp: (inout) address of the argument count. Changed if any arguments were handled
+ * @argvp: (inout) address of the argument vector. Any parameters understood by
+ *   the terminal #GOptionContext are removed
+ * @error: a #GError to fill in
+ * @...: a %NULL terminated list of extra #GOptionGroup<!-- -->s
+ *
+ * Parses the argument vector * argvp 
+ *
+ * Returns: a new #TerminalOptions containing the windows and tabs to open,
+ *   or %NULL on error.
+ */
 TerminalOptions *
 terminal_options_parse (const char *working_directory,
                         const char *display_name,
@@ -758,6 +773,17 @@
   return NULL;
 }
 
+/**
+ * terminal_options_merge_config:
+ * @options:
+ * @key_file: a #GKeyFile containing to merge the options from
+ * @error: a #GError to fill in
+ *
+ * Merges the saved options from @key_file into @options.
+ *
+ * Returns: %TRUE if @key_file was a valid key file containing a stored
+ *   terminal configuration, or %FALSE on error
+ */
 gboolean
 terminal_options_merge_config (TerminalOptions *options,
                                GKeyFile *key_file,
@@ -864,6 +890,24 @@
   return TRUE;
 }
 
+/**
+ * terminal_options_ensure_window:
+ * @options:
+ *
+ * Ensure that @options will contain at least one window to open.
+ */
+void
+terminal_options_ensure_window (TerminalOptions *options)
+{
+  ensure_top_window (options);
+}
+
+/**
+ * terminal_options_free:
+ * @options:
+ *
+ * Frees @options.
+ */
 void
 terminal_options_free (TerminalOptions *options)
 {

Modified: trunk/src/terminal-options.h
==============================================================================
--- trunk/src/terminal-options.h	(original)
+++ trunk/src/terminal-options.h	Thu Mar 19 13:49:02 2009
@@ -97,12 +97,14 @@
                                          int *argcp,
                                          char ***argvp,
                                          GError **error,
-                                         ...);
+                                         ...) G_GNUC_NULL_TERMINATED;
 
 gboolean terminal_options_merge_config (TerminalOptions *options,
                                         GKeyFile *key_file,
                                         GError **error);
 
+void terminal_options_ensure_window (TerminalOptions *options);
+
 void terminal_options_free (TerminalOptions *options);
 
 G_END_DECLS

Modified: trunk/src/terminal.c
==============================================================================
--- trunk/src/terminal.c	(original)
+++ trunk/src/terminal.c	Thu Mar 19 13:49:02 2009
@@ -475,7 +475,7 @@
   terminal_app_initialize (options->use_factory);
   g_signal_connect (terminal_app_get (), "quit", G_CALLBACK (gtk_main_quit), NULL);
 
-  terminal_app_handle_options (terminal_app_get (), options, NULL);
+  terminal_app_handle_options (terminal_app_get (), options, TRUE /* allow resume */, NULL);
   terminal_options_free (options);
 
   /* Now change directory to / so we don't prevent unmounting, e.g. if the
@@ -499,7 +499,7 @@
 static gboolean
 handle_new_terminal_event (TerminalOptions *options)
 {
-  terminal_app_handle_options (terminal_app_get (), options, NULL);
+  terminal_app_handle_options (terminal_app_get (), options, FALSE /* no resume */, NULL);
 
   return FALSE;
 }



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