[gnome-terminal] Simplify legacy client session handling code
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-terminal] Simplify legacy client session handling code
- Date: Thu, 3 May 2012 19:03:50 +0000 (UTC)
commit fb97643ac039f2d5d9dcfc3d469bf1d75db338b8
Author: Christian Persch <chpe gnome org>
Date: Fri Nov 25 19:41:12 2011 +0100
Simplify legacy client session handling code
Remove eggsmclient code from here, and simplify the args parsing.
src/Makefile.am | 26 -----------------------
src/terminal-options.c | 53 ++++++++++++++++++++++-------------------------
src/terminal-options.h | 11 +++++----
src/terminal.c | 49 +++++++++++--------------------------------
4 files changed, 44 insertions(+), 95 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 5fd5aee..ce07dab 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -229,32 +229,6 @@ gnome_terminal_LDFLAGS = \
gnome_terminal_LDADD = \
$(TERM_LIBS)
-
-if WITH_SMCLIENT
-gnome_terminal_SOURCES += \
- eggsmclient.c \
- eggsmclient.h \
- eggsmclient-private.h \
- $(NULL)
-gnome_terminal_CFLAGS += $(SMCLIENT_CFLAGS)
-gnome_terminal_LDADD += $(SMCLIENT_LIBS)
-
-if WITH_SMCLIENT_XSMP
-gnome_terminal_SOURCES += \
- eggdesktopfile.c \
- eggdesktopfile.h \
- eggsmclient-xsmp.c \
- $(NULL)
-gnome_terminal_CPPFLAGS += -DEGG_SM_CLIENT_BACKEND_XSMP
-endif
-if WITH_SMCLIENT_WIN32
-gnome_terminal_SOURCES += eggsmclient-win32.c
-endif
-if WITH_SMCLIENT_QUARTZ
-gnome_terminal_SOURCES += eggsmclient-osx.c
-endif
-endif
-
# Nautilus extension
libterminal_nautilus_la_SOURCES = \
diff --git a/src/terminal-options.c b/src/terminal-options.c
index 20ab08f..3eb3d5b 100644
--- a/src/terminal-options.c
+++ b/src/terminal-options.c
@@ -710,16 +710,11 @@ digest_options_callback (GOptionContext *context,
/**
* terminal_options_parse:
* @working_directory: the default working directory
- * @display_name: the default X display name
* @startup_id: the startup notification ID
- * @remote_arguments: whether the caller is the factory process or not
- * @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
*
@@ -728,26 +723,20 @@ digest_options_callback (GOptionContext *context,
*/
TerminalOptions *
terminal_options_parse (const char *working_directory,
- const char *display_name,
const char *startup_id,
- gboolean remote_arguments,
- gboolean ignore_unknown_options,
int *argcp,
char ***argvp,
- GError **error,
- ...)
+ GError **error)
{
TerminalOptions *options;
GOptionContext *context;
- GOptionGroup *extra_group;
- va_list va_args;
gboolean retval;
int i;
char **argv = *argvp;
options = g_slice_new0 (TerminalOptions);
- options->remote_arguments = remote_arguments;
+ options->remote_arguments = FALSE;
options->default_window_menubar_forced = FALSE;
options->default_window_menubar_state = TRUE;
options->default_fullscreen = FALSE;
@@ -756,7 +745,7 @@ terminal_options_parse (const char *working_directory,
options->use_factory = TRUE;
options->startup_id = g_strdup (startup_id && startup_id[0] ? startup_id : NULL);
- options->display_name = g_strdup (display_name);
+ options->display_name = NULL;
options->initial_windows = NULL;
options->default_role = NULL;
options->default_geometry = NULL;
@@ -801,18 +790,6 @@ terminal_options_parse (const char *working_directory,
}
context = get_goption_context (options);
-
- g_option_context_set_ignore_unknown_options (context, ignore_unknown_options);
-
- va_start (va_args, error);
- extra_group = va_arg (va_args, GOptionGroup*);
- while (extra_group != NULL)
- {
- g_option_context_add_group (context, extra_group);
- extra_group = va_arg (va_args, GOptionGroup*);
- }
- va_end (va_args);
-
retval = g_option_context_parse (context, argcp, argvp, error);
g_option_context_free (context);
@@ -977,6 +954,10 @@ terminal_options_free (TerminalOptions *options)
g_free (options->display_name);
g_free (options->startup_id);
+ g_free (options->sm_client_state_file);
+ g_free (options->sm_client_id);
+ g_free (options->sm_config_prefix);
+
g_slice_free (TerminalOptions, options);
}
@@ -1395,12 +1376,24 @@ get_goption_context (TerminalOptions *options)
{ NULL, 0, 0, 0, NULL, NULL, NULL }
};
+ const GOptionEntry smclient_goptions[] = {
+ { "sm-client-disable", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &options->sm_client_disable, NULL, NULL },
+ { "sm-client-state-file", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME, &options->sm_client_state_file, NULL, NULL },
+ { "sm-client-id", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &options->sm_client_id, NULL, NULL },
+ { "sm-disable", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &options->sm_client_disable, NULL, NULL },
+ { "sm-config-prefix", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &options->sm_config_prefix, NULL, NULL },
+ { NULL }
+ };
+
GOptionContext *context;
GOptionGroup *group;
context = g_option_context_new (NULL);
g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
g_option_context_set_description (context, N_("GNOME Terminal Emulator"));
+ g_option_context_set_ignore_unknown_options (context, FALSE);
+
+ g_option_context_add_group (context, gtk_get_option_group (TRUE));
group = g_option_group_new ("gnome-terminal",
N_("GNOME Terminal Emulator"),
@@ -1430,7 +1423,7 @@ get_goption_context (TerminalOptions *options)
g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);
g_option_group_add_entries (group, window_goptions);
g_option_context_add_group (context, group);
-
+
group = g_option_group_new ("terminal-options",
N_("Terminal options; if used before the first --window or --tab argument, sets the default for all terminals:"),
N_("Show per-terminal options"),
@@ -1439,6 +1432,10 @@ get_goption_context (TerminalOptions *options)
g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);
g_option_group_add_entries (group, terminal_goptions);
g_option_context_add_group (context, group);
-
+
+ group = g_option_group_new ("sm-client", "", "", NULL, NULL);
+ g_option_group_add_entries (group, smclient_goptions);
+ g_option_context_add_group (context, group);
+
return context;
}
diff --git a/src/terminal-options.h b/src/terminal-options.h
index c5aff62..eee9afd 100644
--- a/src/terminal-options.h
+++ b/src/terminal-options.h
@@ -77,6 +77,11 @@ typedef struct
gboolean load_config;
gboolean save_config;
+ gboolean sm_client_disable;
+ char *sm_client_state_file;
+ char *sm_client_id;
+ char *sm_config_prefix;
+
guint zoom_set : 1;
} TerminalOptions;
@@ -120,14 +125,10 @@ typedef enum {
} TerminalOptionError;
TerminalOptions *terminal_options_parse (const char *working_directory,
- const char *display_name,
const char *startup_id,
- gboolean remote_arguments,
- gboolean ignore_unknown_options,
int *argcp,
char ***argvp,
- GError **error,
- ...) G_GNUC_NULL_TERMINATED;
+ GError **error);
gboolean terminal_options_merge_config (TerminalOptions *options,
GKeyFile *key_file,
diff --git a/src/terminal.c b/src/terminal.c
index a1a6a37..c6e9f0a 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -34,10 +34,6 @@
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
-#ifdef WITH_SMCLIENT
-#include "eggsmclient.h"
-#endif
-
#include "terminal-debug.h"
#include "terminal-intl.h"
#include "terminal-options.h"
@@ -68,7 +64,6 @@ enum
static gboolean
handle_options (TerminalFactory *factory,
TerminalOptions *options,
- gboolean allow_resume,
GError **error)
{
GList *lw;
@@ -110,23 +105,21 @@ handle_options (TerminalFactory *factory,
/* 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))
+ if (options->sm_client_state_file && !options->sm_client_disable)
{
GKeyFile *key_file;
+ gboolean result;
+
+ key_file = g_key_file_new ();
+ result = g_key_file_load_from_file (key_file, options->sm_client_state_file, 0, error) &&
+ terminal_options_merge_config (options, key_file, SOURCE_SESSION, error);
+ g_key_file_free (key_file);
- key_file = egg_sm_client_get_state_file (sm_client);
- if (key_file != NULL &&
- !terminal_options_merge_config (options, key_file, SOURCE_SESSION, error))
+ if (!result)
return FALSE;
+
+ /* fall-through on success */
}
-}
-#endif
/* Make sure we open at least one window */
terminal_options_ensure_window (options);
@@ -317,18 +310,9 @@ main (int argc, char **argv)
working_directory = g_get_current_dir ();
options = terminal_options_parse (working_directory,
- NULL,
startup_id,
- FALSE,
- FALSE,
&argc, &argv,
- &error,
- gtk_get_option_group (TRUE),
-#ifdef WITH_SMCLIENT
- egg_sm_client_get_option_group (),
-#endif
- NULL);
-
+ &error);
if (options == NULL) {
g_printerr (_("Failed to parse arguments: %s\n"), error->message);
g_error_free (error);
@@ -339,14 +323,7 @@ main (int argc, char **argv)
g_set_application_name (_("Terminal"));
- /* Unset the these env variables, so they doesn't end up
- * in the factory's env and thus in the terminals' envs.
- */
- g_unsetenv ("DESKTOP_STARTUP_ID");
- g_unsetenv ("GIO_LAUNCHED_DESKTOP_FILE_PID");
- g_unsetenv ("GIO_LAUNCHED_DESKTOP_FILE");
-
- /* Do this here so that gdk_display is initialized */
+ /* Do this here so that gdk_display is initialized */
if (options->startup_id == NULL)
{
/* Create a fake one containing a timestamp that we can use */
@@ -376,7 +353,7 @@ main (int argc, char **argv)
goto out;
}
- if (!handle_options (factory, options, TRUE /* allow resume */, &error)) {
+ if (!handle_options (factory, options, &error)) {
g_printerr ("Failed to handle arguments: %s\n", error->message);
} else {
exit_code = EXIT_SUCCESS;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]