diff options
author | Pablo Barciela <[email protected]> | 2018-04-08 02:56:49 +0200 |
---|---|---|
committer | Pablo Barciela <[email protected]> | 2018-04-08 03:48:43 +0200 |
commit | ac1a33614fd26f77285ed327491e58d34376dd2d (patch) | |
tree | 06d2348a8e7027f9385feb1c732d6836adf878ba | |
parent | 766c5b5b3299b8c86014b2109d1cd7dc937a8be8 (diff) | |
download | pluma-ac1a33614fd26f77285ed327491e58d34376dd2d.tar.bz2 pluma-ac1a33614fd26f77285ed327491e58d34376dd2d.tar.xz |
avoid 'gtk_file_chooser_dialog_new' with stock id
-rw-r--r-- | pluma/dialogs/pluma-preferences-dialog.c | 63 |
1 files changed, 58 insertions, 5 deletions
diff --git a/pluma/dialogs/pluma-preferences-dialog.c b/pluma/dialogs/pluma-preferences-dialog.c index 30e8dc8d..23b94ba4 100644 --- a/pluma/dialogs/pluma-preferences-dialog.c +++ b/pluma/dialogs/pluma-preferences-dialog.c @@ -793,6 +793,59 @@ add_scheme_chooser_response_cb (GtkDialog *chooser, set_buttons_sensisitivity_according_to_scheme (dlg, scheme_id); } + +static GtkWidget * +scheme_file_chooser_dialog_new_valist (const gchar *title, + GtkWindow *parent, + GtkFileChooserAction action, + const gchar *first_button_text, + va_list varargs) +{ + GtkWidget *result; + const char *button_text = first_button_text; + gint response_id; + + result = g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG, + "title", title, + "action", action, + NULL); + + if (parent) + gtk_window_set_transient_for (GTK_WINDOW (result), parent); + + while (button_text) + { + response_id = va_arg (varargs, gint); + + if (g_strcmp0 (button_text, "process-stop") == 0) + pluma_dialog_add_button (GTK_DIALOG (result), _("_Cancel"), button_text, response_id); + else + gtk_dialog_add_button (GTK_DIALOG (result), button_text, response_id); + + button_text = va_arg (varargs, const gchar *); + } + + return result; +} + +static GtkWidget * +scheme_file_chooser_dialog_new (const gchar *title, + GtkWindow *parent, + GtkFileChooserAction action, + const gchar *first_button_text, + ...) +{ + GtkWidget *result; + va_list varargs; + + va_start (varargs, first_button_text); + result = scheme_file_chooser_dialog_new_valist (title, parent, action, + first_button_text, + varargs); + va_end (varargs); + + return result; +} static void install_scheme_clicked (GtkButton *button, @@ -807,11 +860,11 @@ install_scheme_clicked (GtkButton *button, return; } - chooser = gtk_file_chooser_dialog_new (_("Add Scheme"), - GTK_WINDOW (dlg), - GTK_FILE_CHOOSER_ACTION_OPEN, - "gtk-cancel", GTK_RESPONSE_CANCEL, - NULL); + chooser = scheme_file_chooser_dialog_new (_("Add Scheme"), + GTK_WINDOW (dlg), + GTK_FILE_CHOOSER_ACTION_OPEN, + "process-stop", GTK_RESPONSE_CANCEL, + NULL); pluma_dialog_add_button (GTK_DIALOG (chooser), _("A_dd Scheme"), |