summaryrefslogtreecommitdiff
path: root/eel
diff options
context:
space:
mode:
authorPablo Barciela <[email protected]>2018-03-23 02:06:16 +0100
committerraveit65 <[email protected]>2018-03-23 08:59:49 +0100
commit7c9b80c6fd4096f9bee465e60a28f7a8d7bf87f1 (patch)
tree192a6493676c9a0861d5f556e6f6d73392821bf1 /eel
parent4fb359018441a9a80984a7a94be1a939efc51bde (diff)
downloadcaja-7c9b80c6fd4096f9bee465e60a28f7a8d7bf87f1.tar.bz2
caja-7c9b80c6fd4096f9bee465e60a28f7a8d7bf87f1.tar.xz
avoid 'gtk_file_chooser_dialog_new' with stock ids
Diffstat (limited to 'eel')
-rw-r--r--eel/eel-stock-dialogs.c57
-rw-r--r--eel/eel-stock-dialogs.h5
2 files changed, 62 insertions, 0 deletions
diff --git a/eel/eel-stock-dialogs.c b/eel/eel-stock-dialogs.c
index b893642c..33ba13c4 100644
--- a/eel/eel-stock-dialogs.c
+++ b/eel/eel-stock-dialogs.c
@@ -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)
{
diff --git a/eel/eel-stock-dialogs.h b/eel/eel-stock-dialogs.h
index b5f69715..74f61396 100644
--- a/eel/eel-stock-dialogs.h
+++ b/eel/eel-stock-dialogs.h
@@ -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,