Skip to content

Commit ac1a336

Browse files
committed
avoid 'gtk_file_chooser_dialog_new' with stock id
1 parent 766c5b5 commit ac1a336

File tree

1 file changed

+58
-5
lines changed

1 file changed

+58
-5
lines changed

‎pluma/dialogs/pluma-preferences-dialog.c‎

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,59 @@ add_scheme_chooser_response_cb (GtkDialog *chooser,
793793

794794
set_buttons_sensisitivity_according_to_scheme (dlg, scheme_id);
795795
}
796+
797+
static GtkWidget *
798+
scheme_file_chooser_dialog_new_valist (const gchar *title,
799+
GtkWindow *parent,
800+
GtkFileChooserAction action,
801+
const gchar *first_button_text,
802+
va_list varargs)
803+
{
804+
GtkWidget *result;
805+
const char *button_text = first_button_text;
806+
gint response_id;
807+
808+
result = g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG,
809+
"title", title,
810+
"action", action,
811+
NULL);
812+
813+
if (parent)
814+
gtk_window_set_transient_for (GTK_WINDOW (result), parent);
815+
816+
while (button_text)
817+
{
818+
response_id = va_arg (varargs, gint);
819+
820+
if (g_strcmp0 (button_text, "process-stop") == 0)
821+
pluma_dialog_add_button (GTK_DIALOG (result), _("_Cancel"), button_text, response_id);
822+
else
823+
gtk_dialog_add_button (GTK_DIALOG (result), button_text, response_id);
824+
825+
button_text = va_arg (varargs, const gchar *);
826+
}
827+
828+
return result;
829+
}
830+
831+
static GtkWidget *
832+
scheme_file_chooser_dialog_new (const gchar *title,
833+
GtkWindow *parent,
834+
GtkFileChooserAction action,
835+
const gchar *first_button_text,
836+
...)
837+
{
838+
GtkWidget *result;
839+
va_list varargs;
840+
841+
va_start (varargs, first_button_text);
842+
result = scheme_file_chooser_dialog_new_valist (title, parent, action,
843+
first_button_text,
844+
varargs);
845+
va_end (varargs);
846+
847+
return result;
848+
}
796849

797850
static void
798851
install_scheme_clicked (GtkButton *button,
@@ -807,11 +860,11 @@ install_scheme_clicked (GtkButton *button,
807860
return;
808861
}
809862

810-
chooser = gtk_file_chooser_dialog_new (_("Add Scheme"),
811-
GTK_WINDOW (dlg),
812-
GTK_FILE_CHOOSER_ACTION_OPEN,
813-
"gtk-cancel", GTK_RESPONSE_CANCEL,
814-
NULL);
863+
chooser = scheme_file_chooser_dialog_new (_("Add Scheme"),
864+
GTK_WINDOW (dlg),
865+
GTK_FILE_CHOOSER_ACTION_OPEN,
866+
"process-stop", GTK_RESPONSE_CANCEL,
867+
NULL);
815868

816869
pluma_dialog_add_button (GTK_DIALOG (chooser),
817870
_("A_dd Scheme"),

0 commit comments

Comments
 (0)