summaryrefslogtreecommitdiff
path: root/mate-panel/libpanel-util/panel-gtk.c
diff options
context:
space:
mode:
Diffstat (limited to 'mate-panel/libpanel-util/panel-gtk.c')
-rw-r--r--mate-panel/libpanel-util/panel-gtk.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/mate-panel/libpanel-util/panel-gtk.c b/mate-panel/libpanel-util/panel-gtk.c
index aed2ce9c..11a7a952 100644
--- a/mate-panel/libpanel-util/panel-gtk.c
+++ b/mate-panel/libpanel-util/panel-gtk.c
@@ -23,6 +23,7 @@
*/
#include <gtk/gtk.h>
+#include <glib/gi18n.h>
#include "panel-gtk.h"
@@ -101,3 +102,60 @@ panel_dialog_add_button (GtkDialog *dialog,
return button;
}
+
+static GtkWidget *
+panel_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)
+ panel_dialog_add_button (GTK_DIALOG (result), _("_Cancel"), button_text, response_id);
+ else if (g_strcmp0 (button_text, "document-open") == 0)
+ panel_dialog_add_button (GTK_DIALOG (result), _("_Open"), button_text, response_id);
+ else if (g_strcmp0 (button_text, "gtk-ok") == 0)
+ panel_dialog_add_button (GTK_DIALOG (result), _("_OK"), 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 *
+panel_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 = panel_file_chooser_dialog_new_valist (title, parent, action,
+ first_button_text,
+ varargs);
+ va_end (varargs);
+
+ return result;
+}