gnome-terminal/gnome-terminal-session.patch
2009-04-08 17:57:25 +00:00

197 lines
6.0 KiB
Diff

Index: src/terminal-app.h
===================================================================
--- src/terminal-app.h (revision 3380)
+++ src/terminal-app.h (working copy)
@@ -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,
Index: src/terminal-options.c
===================================================================
--- src/terminal-options.c (revision 3380)
+++ src/terminal-options.c (working copy)
@@ -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,7 +890,25 @@
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)
{
g_list_foreach (options->initial_windows, (GFunc) initial_window_free, NULL);
Index: src/terminal-options.h
===================================================================
--- src/terminal-options.h (revision 3380)
+++ src/terminal-options.h (working copy)
@@ -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
Index: src/terminal.c
===================================================================
--- src/terminal.c (revision 3380)
+++ src/terminal.c (working copy)
@@ -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 $HOME 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;
}
Index: src/terminal-app.c
===================================================================
--- src/terminal-app.c (revision 3380)
+++ src/terminal-app.c (working copy)
@@ -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;