Skip to content

Commit 49a3b4a

Browse files
sc0wlukefromdc
authored andcommitted
avoid 'gtk_file_chooser_dialog_new' with stock ids
1 parent 8248680 commit 49a3b4a

File tree

6 files changed

+88
-21
lines changed

6 files changed

+88
-21
lines changed

mate-panel/libpanel-util/panel-gtk.c

+58
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424

2525
#include <gtk/gtk.h>
26+
#include <glib/gi18n.h>
2627

2728
#include "panel-gtk.h"
2829

@@ -101,3 +102,60 @@ panel_dialog_add_button (GtkDialog *dialog,
101102

102103
return button;
103104
}
105+
106+
static GtkWidget *
107+
panel_file_chooser_dialog_new_valist (const gchar *title,
108+
GtkWindow *parent,
109+
GtkFileChooserAction action,
110+
const gchar *first_button_text,
111+
va_list varargs)
112+
{
113+
GtkWidget *result;
114+
const char *button_text = first_button_text;
115+
gint response_id;
116+
117+
result = g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG,
118+
"title", title,
119+
"action", action,
120+
NULL);
121+
122+
if (parent)
123+
gtk_window_set_transient_for (GTK_WINDOW (result), parent);
124+
125+
while (button_text)
126+
{
127+
response_id = va_arg (varargs, gint);
128+
129+
if (g_strcmp0 (button_text, "process-stop") == 0)
130+
panel_dialog_add_button (GTK_DIALOG (result), _("_Cancel"), button_text, response_id);
131+
else if (g_strcmp0 (button_text, "document-open") == 0)
132+
panel_dialog_add_button (GTK_DIALOG (result), _("_Open"), button_text, response_id);
133+
else if (g_strcmp0 (button_text, "gtk-ok") == 0)
134+
panel_dialog_add_button (GTK_DIALOG (result), _("_OK"), button_text, response_id);
135+
else
136+
gtk_dialog_add_button (GTK_DIALOG (result), button_text, response_id);
137+
138+
button_text = va_arg (varargs, const gchar *);
139+
}
140+
141+
return result;
142+
}
143+
144+
GtkWidget *
145+
panel_file_chooser_dialog_new (const gchar *title,
146+
GtkWindow *parent,
147+
GtkFileChooserAction action,
148+
const gchar *first_button_text,
149+
...)
150+
{
151+
GtkWidget *result;
152+
va_list varargs;
153+
154+
va_start (varargs, first_button_text);
155+
result = panel_file_chooser_dialog_new_valist (title, parent, action,
156+
first_button_text,
157+
varargs);
158+
va_end (varargs);
159+
160+
return result;
161+
}

mate-panel/libpanel-util/panel-gtk.h

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ GtkWidget* panel_dialog_add_button (GtkDialog *dialog,
4040
const gchar *icon_name,
4141
gint response_id);
4242

43+
GtkWidget* panel_file_chooser_dialog_new (const gchar *title,
44+
GtkWindow *parent,
45+
GtkFileChooserAction action,
46+
const gchar *first_button_text,
47+
...);
48+
4349
#ifdef __cplusplus
4450
}
4551
#endif

mate-panel/libpanel-util/panel-icon-chooser.c

+9-8
Original file line numberDiff line numberDiff line change
@@ -378,14 +378,15 @@ _panel_icon_chooser_clicked (GtkButton *button)
378378
else
379379
parent = NULL;
380380

381-
filechooser = gtk_file_chooser_dialog_new (_("Choose an icon"),
382-
parent,
383-
GTK_FILE_CHOOSER_ACTION_OPEN,
384-
"gtk-cancel",
385-
GTK_RESPONSE_CANCEL,
386-
"gtk-open",
387-
GTK_RESPONSE_ACCEPT,
388-
NULL);
381+
filechooser = panel_file_chooser_dialog_new (_("Choose an icon"),
382+
parent,
383+
GTK_FILE_CHOOSER_ACTION_OPEN,
384+
"process-stop",
385+
GTK_RESPONSE_CANCEL,
386+
"document-open",
387+
GTK_RESPONSE_ACCEPT,
388+
NULL);
389+
389390
panel_gtk_file_chooser_add_image_preview (GTK_FILE_CHOOSER (filechooser));
390391

391392
path = g_build_filename (DATADIR, "icons", NULL);

mate-panel/panel-ditem-editor.c

+8-7
Original file line numberDiff line numberDiff line change
@@ -1009,13 +1009,14 @@ command_browse_button_clicked (PanelDItemEditor *dialog)
10091009
return;
10101010
}
10111011

1012-
chooser = gtk_file_chooser_dialog_new ("", GTK_WINDOW (dialog),
1013-
GTK_FILE_CHOOSER_ACTION_OPEN,
1014-
"gtk-cancel",
1015-
GTK_RESPONSE_CANCEL,
1016-
"gtk-open",
1017-
GTK_RESPONSE_ACCEPT,
1018-
NULL);
1012+
chooser = panel_file_chooser_dialog_new ("", GTK_WINDOW (dialog),
1013+
GTK_FILE_CHOOSER_ACTION_OPEN,
1014+
"process-stop",
1015+
GTK_RESPONSE_CANCEL,
1016+
"document-open",
1017+
GTK_RESPONSE_ACCEPT,
1018+
NULL);
1019+
10191020
gtk_window_set_destroy_with_parent (GTK_WINDOW (chooser), TRUE);
10201021

10211022
g_signal_connect (chooser, "response",

mate-panel/panel-run-dialog.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -1232,12 +1232,12 @@ file_button_clicked (GtkButton *button,
12321232
{
12331233
GtkWidget *chooser;
12341234

1235-
chooser = gtk_file_chooser_dialog_new (_("Choose a file to append to the command..."),
1236-
GTK_WINDOW (dialog->run_dialog),
1237-
GTK_FILE_CHOOSER_ACTION_OPEN,
1238-
"gtk-cancel", GTK_RESPONSE_CANCEL,
1239-
"gtk-ok", GTK_RESPONSE_OK,
1240-
NULL);
1235+
chooser = panel_file_chooser_dialog_new (_("Choose a file to append to the command..."),
1236+
GTK_WINDOW (dialog->run_dialog),
1237+
GTK_FILE_CHOOSER_ACTION_OPEN,
1238+
"process-stop", GTK_RESPONSE_CANCEL,
1239+
"gtk-ok", GTK_RESPONSE_OK,
1240+
NULL);
12411241

12421242
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser),
12431243
g_get_home_dir ());

po/POTFILES.in

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ applets/wncklet/workspace-switcher.c
3131
[type: gettext/gsettings]data/org.mate.panel.toplevel.gschema.xml.in
3232
mate-panel/libegg/eggdesktopfile.c
3333
mate-panel/libegg/eggsmclient.c
34+
mate-panel/libpanel-util/panel-gtk.c
3435
mate-panel/libpanel-util/panel-error.c
3536
mate-panel/libpanel-util/panel-icon-chooser.c
3637
mate-panel/libpanel-util/panel-launch.c

0 commit comments

Comments
 (0)