This is an automated email from the git hooks/post-receive script. f 2 4 0 4 p u s h e d a c o m m i t t o b r a n c h m a s t e r in repository apps/xfce4-terminal.
commit 27fe3923510f081962c39d048976d54167f3e6b9 Author: Igor <f2...@yandex.ru> Date: Mon Apr 16 13:50:20 2018 -0400 Add --preferences command line option It opens a standalone Preferences dialog. Fixes bug #13249 --- terminal/main.c | 35 +++++++++++++++++++++------------- terminal/terminal-options.c | 21 ++++++++++---------- terminal/terminal-options.h | 14 ++++++++++---- terminal/terminal-preferences-dialog.c | 27 +++++++++++++------------- terminal/terminal-preferences-dialog.h | 3 ++- terminal/terminal-window.c | 2 +- 6 files changed, 59 insertions(+), 43 deletions(-) diff --git a/terminal/main.c b/terminal/main.c index ce28c00..ec544a3 100644 --- a/terminal/main.c +++ b/terminal/main.c @@ -33,8 +33,8 @@ #include <terminal/terminal-app.h> #include <terminal/terminal-private.h> - #include <terminal/terminal-gdbus.h> +#include <terminal/terminal-preferences-dialog.h> @@ -104,7 +104,7 @@ usage (void) _("Usage:"), PACKAGE_NAME, _("OPTION")); g_print ("%s:\n" - " -h, --help; -V, --version; --disable-server; --color-table;\n" + " -h, --help; -V, --version; --disable-server; --color-table; --preferences;\n" " --default-display=%s; --default-working-directory=%s\n\n", _("General Options"), /* parameter of --default-display */ @@ -166,10 +166,7 @@ usage (void) int main (int argc, char **argv) { - gboolean show_help = FALSE; - gboolean show_version = FALSE; - gboolean show_colors = FALSE; - gboolean disable_server = FALSE; + TerminalOptions options; TerminalApp *app; const gchar *startup_id; const gchar *display; @@ -179,6 +176,10 @@ main (int argc, char **argv) gint n; const gchar *msg; + /* initialize options */ + options.disable_server = options.show_version = options.show_colors = options.show_help = + options.show_preferences = FALSE; + /* install required signal handlers */ signal (SIGPIPE, SIG_IGN); @@ -198,9 +199,9 @@ main (int argc, char **argv) #endif /* parse some options we need in main, not the windows attrs */ - terminal_options_parse (argc, argv, &show_help, &show_version, &show_colors, &disable_server); + terminal_options_parse (argc, argv, &options); - if (G_UNLIKELY (show_version)) + if (G_UNLIKELY (options.show_version)) { g_print ("%s %s (Xfce %s)\n\n", PACKAGE_NAME, PACKAGE_VERSION, xfce_version_string ()); g_print ("%s\n", "Copyright (c) 2003-2018"); @@ -213,16 +214,24 @@ main (int argc, char **argv) return EXIT_SUCCESS; } - else if (G_UNLIKELY (show_colors)) + else if (G_UNLIKELY (options.show_colors)) { colortable (); return EXIT_SUCCESS; } - else if (G_UNLIKELY (show_help)) + else if (G_UNLIKELY (options.show_help)) { usage (); return EXIT_SUCCESS; } + else if (G_UNLIKELY (options.show_preferences)) + { + GtkWidget *dialog; + gtk_init (&argc, &argv); + dialog = terminal_preferences_dialog_new (TRUE, FALSE); + gtk_dialog_run (GTK_DIALOG (dialog)); + return EXIT_SUCCESS; + } /* create a copy of the standard arguments with our additional stuff */ nargv = g_new (gchar*, argc + 5); nargc = 0; @@ -255,7 +264,7 @@ main (int argc, char **argv) g_type_init (); #endif - if (!disable_server) + if (!options.disable_server) { /* try to connect to an existing Terminal service */ if (terminal_gdbus_invoke_launch (nargc, nargv, &error)) @@ -268,7 +277,7 @@ main (int argc, char **argv) || g_error_matches (error, TERMINAL_ERROR, TERMINAL_ERROR_DISPLAY_MISMATCH)) { /* don't try to establish another service here */ - disable_server = TRUE; + options.disable_server = TRUE; #ifdef G_ENABLE_DEBUG g_debug ("%s mismatch when invoking remote terminal: %s", @@ -311,7 +320,7 @@ main (int argc, char **argv) app = g_object_new (TERMINAL_TYPE_APP, NULL); - if (!disable_server) + if (!options.disable_server) { if (!terminal_gdbus_register_service (app, &error)) { diff --git a/terminal/terminal-options.c b/terminal/terminal-options.c index 4d9adf7..081dfd6 100644 --- a/terminal/terminal-options.c +++ b/terminal/terminal-options.c @@ -145,14 +145,11 @@ terminal_tab_attr_free (TerminalTabAttr *attr) void -terminal_options_parse (gint argc, - gchar **argv, - gboolean *show_help, - gboolean *show_version, - gboolean *show_colors, - gboolean *disable_server) +terminal_options_parse (gint argc, + gchar **argv, + TerminalOptions *options) { - gint n; + gint n; for (n = 1; n < argc; ++n) { @@ -165,13 +162,15 @@ terminal_options_parse (gint argc, break; if (terminal_option_cmp ("help", 'h', argc, argv, &n, NULL)) - *show_help = TRUE; + options->show_help = TRUE; else if (terminal_option_cmp ("version", 'V', argc, argv, &n, NULL)) - *show_version = TRUE; + options->show_version = TRUE; else if (terminal_option_cmp ("disable-server", 0, argc, argv, &n, NULL)) - *disable_server = TRUE; + options->disable_server = TRUE; else if (terminal_option_cmp ("color-table", 0, argc, argv, &n, NULL)) - *show_colors = TRUE; + options->show_colors = TRUE; + else if (terminal_option_cmp ("preferences", 0, argc, argv, &n, NULL)) + options->show_preferences = TRUE; } } diff --git a/terminal/terminal-options.h b/terminal/terminal-options.h index 2358382..a27068b 100644 --- a/terminal/terminal-options.h +++ b/terminal/terminal-options.h @@ -87,12 +87,18 @@ typedef struct TerminalZoomLevel zoom; } TerminalWindowAttr; +typedef struct +{ + gboolean show_help; + gboolean show_version; + gboolean show_colors; + gboolean show_preferences; + gboolean disable_server; +} TerminalOptions; + void terminal_options_parse (gint argc, gchar **argv, - gboolean *show_help, - gboolean *show_version, - gboolean *show_colors, - gboolean *disable_server); + TerminalOptions *options); GSList *terminal_window_attr_parse (gint argc, gchar **argv, diff --git a/terminal/terminal-preferences-dialog.c b/terminal/terminal-preferences-dialog.c index 1dfe31a..7807563 100644 --- a/terminal/terminal-preferences-dialog.c +++ b/terminal/terminal-preferences-dialog.c @@ -1099,7 +1099,8 @@ terminal_preferences_dialog_encoding_changed (GtkComboBox *combobo * Return value : **/ GtkWidget* -terminal_preferences_dialog_new (gboolean show_drop_down) +terminal_preferences_dialog_new (gboolean show_drop_down, + gboolean drop_down_mode) { static GtkBuilder *builder = NULL; @@ -1117,24 +1118,24 @@ terminal_preferences_dialog_new (gboolean show_drop_down) terminal_return_val_if_fail (GTK_IS_WIDGET (object), NULL); gtk_widget_set_visible (GTK_WIDGET (object), show_drop_down); - if (show_drop_down) + /* focus the drop-down tab if in drop-down mode */ + if (show_drop_down && drop_down_mode) { - /* focus the drop-down tab if enabled */ notebook = gtk_builder_get_object (builder, "notebook"); terminal_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL); gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), gtk_notebook_page_num (GTK_NOTEBOOK (notebook), GTK_WIDGET (object))); + } - /* show warning and disable control if WM does not support compositing */ - if (!gdk_screen_is_composited (gtk_widget_get_screen (GTK_WIDGET (object)))) - { - object = gtk_builder_get_object (builder, "dropdown-opacity-not-available"); - terminal_return_val_if_fail (G_IS_OBJECT (object), NULL); - gtk_widget_set_visible (GTK_WIDGET (object), TRUE); - object = gtk_builder_get_object (builder, "scale-opacity"); - terminal_return_val_if_fail (G_IS_OBJECT (object), NULL); - gtk_widget_set_sensitive (GTK_WIDGET (object), FALSE); - } + /* show warning and disable control if WM does not support compositing */ + if (show_drop_down && !gdk_screen_is_composited (gtk_widget_get_screen (GTK_WIDGET (object)))) + { + object = gtk_builder_get_object (builder, "dropdown-opacity-not-available"); + terminal_return_val_if_fail (G_IS_OBJECT (object), NULL); + gtk_widget_set_visible (GTK_WIDGET (object), TRUE); + object = gtk_builder_get_object (builder, "scale-opacity"); + terminal_return_val_if_fail (G_IS_OBJECT (object), NULL); + gtk_widget_set_sensitive (GTK_WIDGET (object), FALSE); } dialog = gtk_builder_get_object (builder, "dialog"); diff --git a/terminal/terminal-preferences-dialog.h b/terminal/terminal-preferences-dialog.h index 98c3e43..2543245 100644 --- a/terminal/terminal-preferences-dialog.h +++ b/terminal/terminal-preferences-dialog.h @@ -36,7 +36,8 @@ typedef struct _TerminalPreferencesDialog TerminalPreferencesDialog; GType terminal_preferences_dialog_get_type (void) G_GNUC_CONST; -GtkWidget *terminal_preferences_dialog_new (gboolean show_drop_down); +GtkWidget *terminal_preferences_dialog_new (gboolean show_drop_down, + gboolean drop_down_mode); G_END_DECLS diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c index f556669..ec1bfc1 100644 --- a/terminal/terminal-window.c +++ b/terminal/terminal-window.c @@ -1880,7 +1880,7 @@ terminal_window_action_prefs (GtkAction *action, { if (window->priv->preferences_dialog == NULL) { - window->priv->preferences_dialog = terminal_preferences_dialog_new (window->drop_down); + window->priv->preferences_dialog = terminal_preferences_dialog_new (window->drop_down, window->drop_down); if (G_LIKELY (window->priv->preferences_dialog != NULL)) { window->priv->n_child_windows++; -- To stop receiving notification emails like this one, please contact the administrator of this repository. _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits