[gnome-terminal] client: legacy: Add command line option to show the preferences
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-terminal] client: legacy: Add command line option to show the preferences
- Date: Tue, 16 Aug 2016 17:18:07 +0000 (UTC)
commit e0afa0406cda3cb6dcaecc22f00010f5eb40deb8
Author: Christian Persch <chpe gnome org>
Date: Tue Aug 16 19:17:55 2016 +0200
client: legacy: Add command line option to show the preferences
This is useful when you've borked the prefs, for example by
changing the command to something that doesn't exist — causing
the terminal to immediately exit on launch — and want to fix it.
src/terminal-options.c | 1 +
src/terminal-options.h | 1 +
src/terminal.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 51 insertions(+), 2 deletions(-)
---
diff --git a/src/terminal-options.c b/src/terminal-options.c
index 723ecfe..4d33a4d 100644
--- a/src/terminal-options.c
+++ b/src/terminal-options.c
@@ -1077,6 +1077,7 @@ get_goption_context (TerminalOptions *options)
unsupported_option_callback,
NULL, NULL
},
+ { "preferences", 0, 0, G_OPTION_ARG_NONE, &options->show_preferences, N_("Show preferences window"),
NULL },
{ "version", 0, G_OPTION_FLAG_NO_ARG | G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_CALLBACK, option_version_cb,
NULL, NULL },
{ NULL, 0, 0, 0, NULL, NULL, NULL }
};
diff --git a/src/terminal-options.h b/src/terminal-options.h
index a1e645b..bc63452 100644
--- a/src/terminal-options.h
+++ b/src/terminal-options.h
@@ -67,6 +67,7 @@ typedef struct
char *startup_id;
char *display_name;
int screen_number;
+ gboolean show_preferences;
GList *initial_windows;
gboolean default_window_menubar_forced;
gboolean default_window_menubar_state;
diff --git a/src/terminal.c b/src/terminal.c
index da03cdb..5f0363f 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -149,6 +149,49 @@ handle_exec_error (GError *error,
return FALSE; /* don't abort */
}
+static void
+handle_show_preferences (const char *service_name)
+{
+ gs_free_error GError *error = NULL;
+ gs_unref_object GDBusConnection *bus = NULL;
+ gs_free char *object_path = NULL;
+ GVariantBuilder builder;
+
+ bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+ if (bus == NULL) {
+ g_printerr ("Failed to get session bus: %s\n", error->message);
+ return;
+ }
+
+ /* For reasons (!?), the org.gtk.Actions interface's object path
+ * is derived from the service name, i.e. for service name
+ * "foo.bar.baz" the object path is "/foo/bar/baz".
+ */
+ object_path = g_strdelimit (g_strdup_printf (".%s", service_name), ".", '/');
+
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("(sava{sv})"));
+ g_variant_builder_add (&builder, "s", "preferences");
+ g_variant_builder_open (&builder, G_VARIANT_TYPE ("av"));
+ g_variant_builder_close (&builder);
+ g_variant_builder_open (&builder, G_VARIANT_TYPE ("a{sv}"));
+ g_variant_builder_close (&builder);
+
+ if (!g_dbus_connection_call_sync (bus,
+ service_name,
+ object_path,
+ "org.gtk.Actions",
+ "Activate",
+ g_variant_builder_end (&builder),
+ G_VARIANT_TYPE ("()"),
+ G_DBUS_CALL_FLAGS_NO_AUTO_START,
+ 30 * 1000 /* ms timeout */,
+ NULL /* cancelleable */,
+ &error)) {
+ g_printerr ("Activate call failed: %s\n", error->message);
+ return;
+ }
+}
+
/**
* handle_options:
* @app:
@@ -174,8 +217,12 @@ handle_options (TerminalFactory *factory,
/* We need to forward the locale encoding to the server, see bug #732128 */
g_get_charset (&encoding);
- /* Make sure we open at least one window */
- terminal_options_ensure_window (options);
+ if (options->show_preferences) {
+ handle_show_preferences (service_name);
+ } else {
+ /* Make sure we open at least one window */
+ terminal_options_ensure_window (options);
+ }
for (lw = options->initial_windows; lw != NULL; lw = lw->next)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]