Skip to content

Commit 7c9b80c

Browse files
sc0wraveit65
authored andcommitted
avoid 'gtk_file_chooser_dialog_new' with stock ids
1 parent 4fb3590 commit 7c9b80c

File tree

5 files changed

+75
-13
lines changed

5 files changed

+75
-13
lines changed

‎eel/eel-stock-dialogs.c‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,63 @@ eel_dialog_add_button (GtkDialog *dialog,
211211
return button;
212212
}
213213

214+
static GtkWidget *
215+
eel_file_chooser_dialog_new_valist (const gchar *title,
216+
GtkWindow *parent,
217+
GtkFileChooserAction action,
218+
const gchar *first_button_text,
219+
va_list varargs)
220+
{
221+
GtkWidget *result;
222+
const char *button_text = first_button_text;
223+
gint response_id;
224+
225+
result = g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG,
226+
"title", title,
227+
"action", action,
228+
NULL);
229+
230+
if (parent)
231+
gtk_window_set_transient_for (GTK_WINDOW (result), parent);
232+
233+
while (button_text)
234+
{
235+
response_id = va_arg (varargs, gint);
236+
237+
if (g_strcmp0 (button_text, "process-stop") == 0)
238+
eel_dialog_add_button (GTK_DIALOG (result), _("_Cancel"), button_text, response_id);
239+
else if (g_strcmp0 (button_text, "document-open") == 0)
240+
eel_dialog_add_button (GTK_DIALOG (result), _("_Open"), button_text, response_id);
241+
else if (g_strcmp0 (button_text, "document-revert") == 0)
242+
eel_dialog_add_button (GTK_DIALOG (result), _("_Revert"), button_text, response_id);
243+
else
244+
gtk_dialog_add_button (GTK_DIALOG (result), button_text, response_id);
245+
246+
button_text = va_arg (varargs, const gchar *);
247+
}
248+
249+
return result;
250+
}
251+
252+
GtkWidget *
253+
eel_file_chooser_dialog_new (const gchar *title,
254+
GtkWindow *parent,
255+
GtkFileChooserAction action,
256+
const gchar *first_button_text,
257+
...)
258+
{
259+
GtkWidget *result;
260+
va_list varargs;
261+
262+
va_start (varargs, first_button_text);
263+
result = eel_file_chooser_dialog_new_valist (title, parent, action,
264+
first_button_text,
265+
varargs);
266+
va_end (varargs);
267+
268+
return result;
269+
}
270+
214271
static gboolean
215272
timed_wait_callback (gpointer callback_data)
216273
{

‎eel/eel-stock-dialogs.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ GtkWidget* eel_dialog_add_button (GtkDialog *dialog,
5353
const gchar *button_text,
5454
const gchar *icon_name,
5555
gint response_id);
56+
GtkWidget* eel_file_chooser_dialog_new (const gchar *title,
57+
GtkWindow *parent,
58+
GtkFileChooserAction action,
59+
const gchar *first_button_text,
60+
...);
5661

5762
/* Variations on mate stock dialogs; these do line wrapping, we don't
5863
* bother with non-parented versions, we allow setting the title,

‎libcaja-private/caja-open-with-dialog.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,12 +447,12 @@ browse_clicked_cb (GtkWidget *button,
447447

448448
dialog = CAJA_OPEN_WITH_DIALOG (user_data);
449449

450-
chooser = gtk_file_chooser_dialog_new (_("Select an Application"),
450+
chooser = eel_file_chooser_dialog_new (_("Select an Application"),
451451
GTK_WINDOW (dialog),
452452
GTK_FILE_CHOOSER_ACTION_OPEN,
453-
"gtk-cancel",
453+
"process-stop",
454454
GTK_RESPONSE_CANCEL,
455-
"gtk-open",
455+
"document-open",
456456
GTK_RESPONSE_OK,
457457
NULL);
458458
gtk_window_set_destroy_with_parent (GTK_WINDOW (chooser), TRUE);

‎src/caja-property-browser.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,11 +1062,11 @@ icon_button_clicked_cb (GtkButton *b,
10621062
GtkWidget *preview;
10631063
int res;
10641064

1065-
dialog = gtk_file_chooser_dialog_new (_("Select an Image File for the New Emblem"),
1065+
dialog = eel_file_chooser_dialog_new (_("Select an Image File for the New Emblem"),
10661066
GTK_WINDOW (browser),
10671067
GTK_FILE_CHOOSER_ACTION_OPEN,
1068-
"gtk-cancel", GTK_RESPONSE_CANCEL,
1069-
"gtk-open", GTK_RESPONSE_ACCEPT,
1068+
"process-stop", GTK_RESPONSE_CANCEL,
1069+
"document-open", GTK_RESPONSE_ACCEPT,
10701070
NULL);
10711071
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog),
10721072
DATADIR "/pixmaps");
@@ -1319,11 +1319,11 @@ add_new_pattern (CajaPropertyBrowser *property_browser)
13191319
else
13201320
{
13211321
property_browser->details->patterns_dialog = dialog =
1322-
gtk_file_chooser_dialog_new (_("Select an Image File to Add as a Pattern"),
1322+
eel_file_chooser_dialog_new (_("Select an Image File to Add as a Pattern"),
13231323
GTK_WINDOW (property_browser),
13241324
GTK_FILE_CHOOSER_ACTION_OPEN,
1325-
"gtk-cancel", GTK_RESPONSE_CANCEL,
1326-
"gtk-open", GTK_RESPONSE_ACCEPT,
1325+
"process-stop", GTK_RESPONSE_CANCEL,
1326+
"document-open", GTK_RESPONSE_ACCEPT,
13271327
NULL);
13281328
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog),
13291329
DATADIR "/caja/patterns/");

‎src/file-manager/fm-properties-window.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5673,11 +5673,11 @@ select_image_button_callback (GtkWidget *widget,
56735673
dialog = window->details->icon_chooser;
56745674

56755675
if (dialog == NULL) {
5676-
dialog = gtk_file_chooser_dialog_new (_("Select Custom Icon"), GTK_WINDOW (window),
5676+
dialog = eel_file_chooser_dialog_new (_("Select Custom Icon"), GTK_WINDOW (window),
56775677
GTK_FILE_CHOOSER_ACTION_OPEN,
5678-
"gtk-revert-to-saved", GTK_RESPONSE_NO,
5679-
"gtk-cancel", GTK_RESPONSE_CANCEL,
5680-
"gtk-open", GTK_RESPONSE_OK,
5678+
"document-revert", GTK_RESPONSE_NO,
5679+
"process-stop", GTK_RESPONSE_CANCEL,
5680+
"document-open", GTK_RESPONSE_OK,
56815681
NULL);
56825682
gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog), "/usr/share/icons", NULL);
56835683
gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog), "/usr/share/pixmaps", NULL);

0 commit comments

Comments
 (0)