Skip to content
Permalink
Browse files

avoid 'gtk_file_chooser_dialog_new' with stock ids

  • Loading branch information...
sc0w authored and raveit65 committed Mar 23, 2018
1 parent 4fb3590 commit 7c9b80c6fd4096f9bee465e60a28f7a8d7bf87f1
@@ -211,6 +211,63 @@ eel_dialog_add_button (GtkDialog *dialog,
return button;
}

static GtkWidget *
eel_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)
eel_dialog_add_button (GTK_DIALOG (result), _("_Cancel"), button_text, response_id);
else if (g_strcmp0 (button_text, "document-open") == 0)
eel_dialog_add_button (GTK_DIALOG (result), _("_Open"), button_text, response_id);
else if (g_strcmp0 (button_text, "document-revert") == 0)
eel_dialog_add_button (GTK_DIALOG (result), _("_Revert"), 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;
}

GtkWidget *
eel_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 = eel_file_chooser_dialog_new_valist (title, parent, action,
first_button_text,
varargs);
va_end (varargs);

return result;
}

static gboolean
timed_wait_callback (gpointer callback_data)
{
@@ -53,6 +53,11 @@ GtkWidget* eel_dialog_add_button (GtkDialog *dialog,
const gchar *button_text,
const gchar *icon_name,
gint response_id);
GtkWidget* eel_file_chooser_dialog_new (const gchar *title,
GtkWindow *parent,
GtkFileChooserAction action,
const gchar *first_button_text,
...);

/* Variations on mate stock dialogs; these do line wrapping, we don't
* bother with non-parented versions, we allow setting the title,
@@ -447,12 +447,12 @@ browse_clicked_cb (GtkWidget *button,

dialog = CAJA_OPEN_WITH_DIALOG (user_data);

chooser = gtk_file_chooser_dialog_new (_("Select an Application"),
chooser = eel_file_chooser_dialog_new (_("Select an Application"),
GTK_WINDOW (dialog),
GTK_FILE_CHOOSER_ACTION_OPEN,
"gtk-cancel",
"process-stop",
GTK_RESPONSE_CANCEL,
"gtk-open",
"document-open",
GTK_RESPONSE_OK,
NULL);
gtk_window_set_destroy_with_parent (GTK_WINDOW (chooser), TRUE);
@@ -1062,11 +1062,11 @@ icon_button_clicked_cb (GtkButton *b,
GtkWidget *preview;
int res;

dialog = gtk_file_chooser_dialog_new (_("Select an Image File for the New Emblem"),
dialog = eel_file_chooser_dialog_new (_("Select an Image File for the New Emblem"),
GTK_WINDOW (browser),
GTK_FILE_CHOOSER_ACTION_OPEN,
"gtk-cancel", GTK_RESPONSE_CANCEL,
"gtk-open", GTK_RESPONSE_ACCEPT,
"process-stop", GTK_RESPONSE_CANCEL,
"document-open", GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog),
DATADIR "/pixmaps");
@@ -1319,11 +1319,11 @@ add_new_pattern (CajaPropertyBrowser *property_browser)
else
{
property_browser->details->patterns_dialog = dialog =
gtk_file_chooser_dialog_new (_("Select an Image File to Add as a Pattern"),
eel_file_chooser_dialog_new (_("Select an Image File to Add as a Pattern"),
GTK_WINDOW (property_browser),
GTK_FILE_CHOOSER_ACTION_OPEN,
"gtk-cancel", GTK_RESPONSE_CANCEL,
"gtk-open", GTK_RESPONSE_ACCEPT,
"process-stop", GTK_RESPONSE_CANCEL,
"document-open", GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog),
DATADIR "/caja/patterns/");
@@ -5673,11 +5673,11 @@ select_image_button_callback (GtkWidget *widget,
dialog = window->details->icon_chooser;

if (dialog == NULL) {
dialog = gtk_file_chooser_dialog_new (_("Select Custom Icon"), GTK_WINDOW (window),
dialog = eel_file_chooser_dialog_new (_("Select Custom Icon"), GTK_WINDOW (window),
GTK_FILE_CHOOSER_ACTION_OPEN,
"gtk-revert-to-saved", GTK_RESPONSE_NO,
"gtk-cancel", GTK_RESPONSE_CANCEL,
"gtk-open", GTK_RESPONSE_OK,
"document-revert", GTK_RESPONSE_NO,
"process-stop", GTK_RESPONSE_CANCEL,
"document-open", GTK_RESPONSE_OK,
NULL);
gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog), "/usr/share/icons", NULL);
gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog), "/usr/share/pixmaps", NULL);

0 comments on commit 7c9b80c

Please sign in to comment.
You can’t perform that action at this time.