|
23 | 23 | */
|
24 | 24 |
|
25 | 25 | #include <gtk/gtk.h>
|
| 26 | +#include <glib/gi18n.h> |
26 | 27 |
|
27 | 28 | #include "panel-gtk.h"
|
28 | 29 |
|
@@ -101,3 +102,60 @@ panel_dialog_add_button (GtkDialog *dialog,
|
101 | 102 |
|
102 | 103 | return button;
|
103 | 104 | }
|
| 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 | +} |
0 commit comments