Mercurial > audlegacy
annotate src/audacious/ui_fileopener.c @ 3687:12e11b15b549
Export ConfigDB API via vtable, adding public aliases: bmp_cfg_db_*, aud_cfg_db_*.
The bmp_cfg_db_* aliases will be removed later once people have done sed on
the plugins.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Tue, 02 Oct 2007 21:41:06 -0500 |
parents | fa19626d85fc |
children | b5ee3a4a8e3b |
rev | line source |
---|---|
2417 | 1 /* Audacious - Cross-platform multimedia player |
2 * Copyright (C) 2005-2007 Audacious development team | |
3 * | |
4 * This program is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2986
diff
changeset
|
6 * the Free Software Foundation; under version 3 of the License. |
2417 | 7 * |
8 * This program is distributed in the hope that it will be useful, | |
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 * GNU General Public License for more details. | |
12 * | |
13 * You should have received a copy of the GNU General Public License | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2986
diff
changeset
|
14 * along with this program. If not, see <http://www.gnu.org/licenses>. |
3123
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
15 * |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
16 * The Audacious team does not consider modular code linking to |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
17 * Audacious or using our public API to be a derived work. |
2417 | 18 */ |
19 | |
20 #include "ui_fileopener.h" | |
21 | |
22 #include <glib/gi18n.h> | |
23 #include <string.h> | |
2432
4a1d1c324685
[svn] - restore shortcut key (esc) to close gtk2 fileopener.
yaz
parents:
2422
diff
changeset
|
24 #include <gdk/gdkkeysyms.h> |
2417 | 25 |
26 #include "input.h" | |
27 #include "main.h" | |
28 #include "playback.h" | |
29 #include "strings.h" | |
30 #include "ui_playlist.h" | |
31 | |
32 static void | |
33 filebrowser_add_files(GtkFileChooser * browser, | |
34 GSList * files) | |
35 { | |
36 GSList *cur; | |
37 gchar *ptr; | |
38 Playlist *playlist = playlist_get_active(); | |
39 | |
40 for (cur = files; cur; cur = g_slist_next(cur)) { | |
3235
c48ce3f67130
gtk_file_chooser_get_uris() results in unpredictable behaviour when GNOME is not installed. Build URIs ourselves.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
41 gchar *filename = g_filename_to_uri((const gchar *) cur->data, NULL, NULL); |
2417 | 42 |
2984
df71b1cef70a
Use vfs_file_test() instead of g_file_test() where appropriate.
William Pitcock <nenolod@atheme-project.org>
parents:
2658
diff
changeset
|
43 if (vfs_file_test(cur->data, G_FILE_TEST_IS_DIR)) { |
3235
c48ce3f67130
gtk_file_chooser_get_uris() results in unpredictable behaviour when GNOME is not installed. Build URIs ourselves.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
44 playlist_add_dir(playlist, filename ? filename : (const gchar *) cur->data); |
2417 | 45 } else { |
3235
c48ce3f67130
gtk_file_chooser_get_uris() results in unpredictable behaviour when GNOME is not installed. Build URIs ourselves.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
46 playlist_add(playlist, filename ? filename : (const gchar *) cur->data); |
2417 | 47 } |
48 | |
3235
c48ce3f67130
gtk_file_chooser_get_uris() results in unpredictable behaviour when GNOME is not installed. Build URIs ourselves.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
49 g_free(filename); |
2417 | 50 } |
51 | |
52 playlistwin_update_list(playlist); | |
53 | |
54 ptr = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(browser)); | |
55 | |
56 g_free(cfg.filesel_path); | |
57 cfg.filesel_path = ptr; | |
58 } | |
59 | |
60 static void | |
61 action_button_cb(GtkWidget *widget, gpointer data) | |
62 { | |
63 GtkWidget *window = g_object_get_data(data, "window"); | |
64 GtkWidget *chooser = g_object_get_data(data, "chooser"); | |
65 GtkWidget *toggle = g_object_get_data(data, "toggle-button"); | |
2658
4b8db8c0521d
[svn] - fixed c++ish declaration in a c file (part 5)
giacomo
parents:
2500
diff
changeset
|
66 gboolean play_button; |
4b8db8c0521d
[svn] - fixed c++ish declaration in a c file (part 5)
giacomo
parents:
2500
diff
changeset
|
67 GSList *files; |
2417 | 68 cfg.close_dialog_open = |
69 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle)); | |
70 | |
2658
4b8db8c0521d
[svn] - fixed c++ish declaration in a c file (part 5)
giacomo
parents:
2500
diff
changeset
|
71 play_button = |
2417 | 72 GPOINTER_TO_INT(g_object_get_data(data, "play-button")); |
73 | |
3235
c48ce3f67130
gtk_file_chooser_get_uris() results in unpredictable behaviour when GNOME is not installed. Build URIs ourselves.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
74 files = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(chooser)); |
2417 | 75 if (!files) return; |
76 | |
77 if (play_button) | |
78 playlist_clear(playlist_get_active()); | |
79 | |
80 filebrowser_add_files(GTK_FILE_CHOOSER(chooser), files); | |
81 g_slist_foreach(files, (GFunc) g_free, NULL); | |
82 g_slist_free(files); | |
83 | |
84 if (play_button) | |
85 playback_initiate(); | |
86 | |
87 if (cfg.close_dialog_open) | |
88 gtk_widget_destroy(window); | |
89 } | |
90 | |
91 | |
92 static void | |
93 close_button_cb(GtkWidget *widget, gpointer data) | |
94 { | |
95 gtk_widget_destroy(GTK_WIDGET(data)); | |
96 } | |
97 | |
2432
4a1d1c324685
[svn] - restore shortcut key (esc) to close gtk2 fileopener.
yaz
parents:
2422
diff
changeset
|
98 static gboolean |
4a1d1c324685
[svn] - restore shortcut key (esc) to close gtk2 fileopener.
yaz
parents:
2422
diff
changeset
|
99 filebrowser_on_keypress(GtkWidget * browser, |
4a1d1c324685
[svn] - restore shortcut key (esc) to close gtk2 fileopener.
yaz
parents:
2422
diff
changeset
|
100 GdkEventKey * event, |
4a1d1c324685
[svn] - restore shortcut key (esc) to close gtk2 fileopener.
yaz
parents:
2422
diff
changeset
|
101 gpointer data) |
4a1d1c324685
[svn] - restore shortcut key (esc) to close gtk2 fileopener.
yaz
parents:
2422
diff
changeset
|
102 { |
4a1d1c324685
[svn] - restore shortcut key (esc) to close gtk2 fileopener.
yaz
parents:
2422
diff
changeset
|
103 if (event->keyval == GDK_Escape) { |
2449 | 104 gtk_widget_destroy(browser); |
2432
4a1d1c324685
[svn] - restore shortcut key (esc) to close gtk2 fileopener.
yaz
parents:
2422
diff
changeset
|
105 return TRUE; |
4a1d1c324685
[svn] - restore shortcut key (esc) to close gtk2 fileopener.
yaz
parents:
2422
diff
changeset
|
106 } |
4a1d1c324685
[svn] - restore shortcut key (esc) to close gtk2 fileopener.
yaz
parents:
2422
diff
changeset
|
107 |
4a1d1c324685
[svn] - restore shortcut key (esc) to close gtk2 fileopener.
yaz
parents:
2422
diff
changeset
|
108 return FALSE; |
4a1d1c324685
[svn] - restore shortcut key (esc) to close gtk2 fileopener.
yaz
parents:
2422
diff
changeset
|
109 } |
4a1d1c324685
[svn] - restore shortcut key (esc) to close gtk2 fileopener.
yaz
parents:
2422
diff
changeset
|
110 |
2417 | 111 void |
112 util_run_filebrowser_gtk2style(gboolean play_button) | |
113 { | |
2449 | 114 static GtkWidget *window = NULL; |
2417 | 115 GtkWidget *vbox, *hbox, *bbox; |
116 GtkWidget *chooser; | |
117 GtkWidget *action_button, *close_button; | |
118 GtkWidget *toggle; | |
2658
4b8db8c0521d
[svn] - fixed c++ish declaration in a c file (part 5)
giacomo
parents:
2500
diff
changeset
|
119 gchar *window_title, *toggle_text; |
4b8db8c0521d
[svn] - fixed c++ish declaration in a c file (part 5)
giacomo
parents:
2500
diff
changeset
|
120 gpointer action_stock, storage; |
2417 | 121 |
2490
49e27e4d8426
[svn] - trying to open filebrowser when it is already open will raise the filebrowser.
yaz
parents:
2449
diff
changeset
|
122 if(window) { |
49e27e4d8426
[svn] - trying to open filebrowser when it is already open will raise the filebrowser.
yaz
parents:
2449
diff
changeset
|
123 gtk_window_present(GTK_WINDOW(window)); /* raise filebrowser */ |
2449 | 124 return; |
2490
49e27e4d8426
[svn] - trying to open filebrowser when it is already open will raise the filebrowser.
yaz
parents:
2449
diff
changeset
|
125 } |
2449 | 126 |
2658
4b8db8c0521d
[svn] - fixed c++ish declaration in a c file (part 5)
giacomo
parents:
2500
diff
changeset
|
127 window_title = play_button ? _("Open Files") : _("Add Files"); |
4b8db8c0521d
[svn] - fixed c++ish declaration in a c file (part 5)
giacomo
parents:
2500
diff
changeset
|
128 toggle_text = play_button ? |
2417 | 129 _("Close dialog on Open") : _("Close dialog on Add"); |
2658
4b8db8c0521d
[svn] - fixed c++ish declaration in a c file (part 5)
giacomo
parents:
2500
diff
changeset
|
130 action_stock = play_button ? GTK_STOCK_OPEN : GTK_STOCK_ADD; |
2417 | 131 |
132 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
133 gtk_window_set_title(GTK_WINDOW(window), window_title); | |
134 gtk_window_set_default_size(GTK_WINDOW(window), 700, 450); | |
2440
7f0318090690
[svn] - set the gtk2 fileopener position to the center of the screen
giacomo
parents:
2432
diff
changeset
|
135 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); |
2417 | 136 gtk_container_set_border_width(GTK_CONTAINER(window), 10); |
137 | |
138 vbox = gtk_vbox_new(FALSE, 0); | |
139 gtk_container_add(GTK_CONTAINER(window), vbox); | |
140 | |
141 chooser = gtk_file_chooser_widget_new(GTK_FILE_CHOOSER_ACTION_OPEN); | |
142 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(chooser), TRUE); | |
143 if (cfg.filesel_path) | |
144 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(chooser), | |
145 cfg.filesel_path); | |
2422 | 146 gtk_box_pack_start(GTK_BOX(vbox), chooser, TRUE, TRUE, 3); |
2417 | 147 |
148 hbox = gtk_hbox_new(TRUE, 0); | |
2422 | 149 gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 3); |
2417 | 150 |
151 toggle = gtk_check_button_new_with_label(toggle_text); | |
152 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
153 cfg.close_dialog_open ? TRUE : FALSE); | |
2422 | 154 gtk_box_pack_start(GTK_BOX(hbox), toggle, TRUE, TRUE, 3); |
2417 | 155 |
156 bbox = gtk_hbutton_box_new(); | |
157 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
2422 | 158 gtk_box_set_spacing(GTK_BOX(bbox), 6); |
159 gtk_box_pack_end(GTK_BOX(hbox), bbox, TRUE, TRUE, 3); | |
2417 | 160 |
161 close_button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | |
162 action_button = gtk_button_new_from_stock(action_stock); | |
163 gtk_container_add(GTK_CONTAINER(bbox), close_button); | |
164 gtk_container_add(GTK_CONTAINER(bbox), action_button); | |
165 | |
2420 | 166 /* this storage object holds several other objects which are used in the |
167 * callback functions | |
168 */ | |
2658
4b8db8c0521d
[svn] - fixed c++ish declaration in a c file (part 5)
giacomo
parents:
2500
diff
changeset
|
169 storage = g_object_new(G_TYPE_OBJECT, NULL); |
2417 | 170 g_object_set_data(storage, "window", window); |
171 g_object_set_data(storage, "chooser", chooser); | |
172 g_object_set_data(storage, "toggle-button", toggle); | |
173 g_object_set_data(storage, "play-button", GINT_TO_POINTER(play_button)); | |
174 | |
175 g_signal_connect(chooser, "file-activated", | |
176 G_CALLBACK(action_button_cb), storage); | |
177 g_signal_connect(action_button, "clicked", | |
178 G_CALLBACK(action_button_cb), storage); | |
179 g_signal_connect(close_button, "clicked", | |
180 G_CALLBACK(close_button_cb), window); | |
181 g_signal_connect(window, "destroy", | |
182 G_CALLBACK(gtk_widget_destroyed), &window); | |
183 | |
2432
4a1d1c324685
[svn] - restore shortcut key (esc) to close gtk2 fileopener.
yaz
parents:
2422
diff
changeset
|
184 g_signal_connect(window, "key_press_event", |
4a1d1c324685
[svn] - restore shortcut key (esc) to close gtk2 fileopener.
yaz
parents:
2422
diff
changeset
|
185 G_CALLBACK(filebrowser_on_keypress), |
4a1d1c324685
[svn] - restore shortcut key (esc) to close gtk2 fileopener.
yaz
parents:
2422
diff
changeset
|
186 NULL); |
4a1d1c324685
[svn] - restore shortcut key (esc) to close gtk2 fileopener.
yaz
parents:
2422
diff
changeset
|
187 |
2417 | 188 gtk_widget_show_all(window); |
189 } | |
190 | |
191 /* | |
192 * Derived from Beep Media Player 0.9.6.1. | |
193 * Which is (C) 2003 - 2006 Milosz Derezynski &c | |
194 * | |
195 * Although I changed it quite a bit. -nenolod | |
196 */ | |
197 static void filebrowser_changed_classic(GtkFileSelection * filesel) | |
198 { | |
199 GList *list; | |
200 GList *node; | |
201 char *filename = (char *) | |
202 gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel)); | |
203 GtkListStore *store; | |
204 GtkTreeIter iter; | |
205 | |
206 if ((list = input_scan_dir(filename)) != NULL) | |
207 { | |
208 /* | |
209 * We enter a directory that has been "hijacked" by an | |
210 * input-plugin. This is used by the CDDA plugin | |
211 */ | |
212 store = | |
213 GTK_LIST_STORE(gtk_tree_view_get_model | |
214 (GTK_TREE_VIEW(filesel->file_list))); | |
215 gtk_list_store_clear(store); | |
216 | |
217 node = list; | |
218 while (node) { | |
219 gtk_list_store_append(store, &iter); | |
220 gtk_list_store_set(store, &iter, 0, node->data, -1); | |
221 g_free(node->data); | |
222 node = g_list_next(node); | |
223 } | |
224 | |
225 g_list_free(list); | |
226 } | |
227 } | |
228 | |
229 static void filebrowser_entry_changed_classic(GtkEditable * entry, gpointer data) | |
230 { | |
231 filebrowser_changed_classic(GTK_FILE_SELECTION(data)); | |
232 } | |
233 | |
234 | |
235 static gboolean | |
236 util_filebrowser_is_dir_classic(GtkFileSelection * filesel) | |
237 { | |
238 char *text; | |
239 struct stat buf; | |
240 gboolean retv = FALSE; | |
241 | |
242 text = g_strdup(gtk_file_selection_get_filename(filesel)); | |
243 | |
244 if (stat(text, &buf) == 0 && S_ISDIR(buf.st_mode)) { | |
245 /* Selected directory */ | |
246 int len = strlen(text); | |
247 if (len > 3 && !strcmp(text + len - 4, "/../")) { | |
248 if (len == 4) | |
249 /* At the root already */ | |
250 *(text + len - 3) = '\0'; | |
251 else { | |
252 char *ptr; | |
253 *(text + len - 4) = '\0'; | |
254 ptr = strrchr(text, '/'); | |
255 *(ptr + 1) = '\0'; | |
256 } | |
257 } else if (len > 2 && !strcmp(text + len - 3, "/./")) | |
258 *(text + len - 2) = '\0'; | |
259 gtk_file_selection_set_filename(filesel, text); | |
260 retv = TRUE; | |
261 } | |
262 g_free(text); | |
263 return retv; | |
264 } | |
265 | |
266 static void filebrowser_add_files_classic(gchar ** files, | |
267 GtkFileSelection * filesel) | |
268 { | |
269 int ctr = 0; | |
270 char *ptr; | |
271 Playlist *playlist = playlist_get_active(); | |
272 | |
273 | |
274 while (files[ctr] != NULL) { | |
3236
74a999f3f4d2
Unbreak XMMS/GTK1 file selector.
William Pitcock <nenolod@atheme-project.org>
parents:
3235
diff
changeset
|
275 gchar *filename = g_filename_to_uri((const gchar *) files[ctr++], NULL, NULL); |
74a999f3f4d2
Unbreak XMMS/GTK1 file selector.
William Pitcock <nenolod@atheme-project.org>
parents:
3235
diff
changeset
|
276 playlist_add(playlist, filename); |
74a999f3f4d2
Unbreak XMMS/GTK1 file selector.
William Pitcock <nenolod@atheme-project.org>
parents:
3235
diff
changeset
|
277 g_free(filename); |
2417 | 278 } |
279 playlistwin_update_list(playlist); | |
280 | |
281 gtk_label_get(GTK_LABEL(GTK_BIN(filesel->history_pulldown)->child), | |
282 &ptr); | |
283 | |
284 /* This will give an extra slash if the current dir is the root. */ | |
285 cfg.filesel_path = g_strconcat(ptr, "/", NULL); | |
286 } | |
287 | |
288 static void filebrowser_ok_classic(GtkWidget * w, GtkWidget * filesel) | |
289 { | |
290 gchar **files; | |
291 | |
292 if (util_filebrowser_is_dir_classic(GTK_FILE_SELECTION(filesel))) | |
293 return; | |
294 files = gtk_file_selection_get_selections(GTK_FILE_SELECTION(filesel)); | |
295 filebrowser_add_files_classic(files, GTK_FILE_SELECTION(filesel)); | |
296 gtk_widget_destroy(filesel); | |
297 } | |
298 | |
299 static void filebrowser_play_classic(GtkWidget * w, GtkWidget * filesel) | |
300 { | |
301 gchar **files; | |
302 | |
303 if (util_filebrowser_is_dir_classic | |
304 (GTK_FILE_SELECTION(GTK_FILE_SELECTION(filesel)))) | |
305 return; | |
306 playlist_clear(playlist_get_active()); | |
307 files = gtk_file_selection_get_selections(GTK_FILE_SELECTION(filesel)); | |
308 filebrowser_add_files_classic(files, GTK_FILE_SELECTION(filesel)); | |
309 gtk_widget_destroy(filesel); | |
310 playback_initiate(); | |
311 } | |
312 | |
313 static void filebrowser_add_selected_files_classic(GtkWidget * w, gpointer data) | |
314 { | |
315 gchar **files; | |
316 | |
317 GtkFileSelection *filesel = GTK_FILE_SELECTION(data); | |
318 files = gtk_file_selection_get_selections(filesel); | |
319 | |
320 filebrowser_add_files_classic(files, filesel); | |
321 gtk_tree_selection_unselect_all(gtk_tree_view_get_selection | |
322 (GTK_TREE_VIEW(filesel->file_list))); | |
323 | |
324 gtk_entry_set_text(GTK_ENTRY(filesel->selection_entry), ""); | |
325 } | |
326 | |
327 static void filebrowser_add_all_files_classic(GtkWidget * w, gpointer data) | |
328 { | |
329 gchar **files; | |
330 GtkFileSelection *filesel; | |
331 | |
332 filesel = data; | |
333 gtk_tree_selection_select_all(gtk_tree_view_get_selection | |
334 (GTK_TREE_VIEW(filesel->file_list))); | |
335 files = gtk_file_selection_get_selections(filesel); | |
336 filebrowser_add_files_classic(files, filesel); | |
337 gtk_tree_selection_unselect_all(gtk_tree_view_get_selection | |
338 (GTK_TREE_VIEW(filesel->file_list))); | |
339 gtk_entry_set_text(GTK_ENTRY(filesel->selection_entry), ""); | |
340 } | |
341 | |
342 void | |
343 util_run_filebrowser_classic(gboolean play_button) | |
344 { | |
345 static GtkWidget *dialog; | |
346 GtkWidget *button_add_selected, *button_add_all, *button_close, | |
347 *button_add; | |
348 char *title; | |
349 | |
350 if (dialog != NULL) { | |
351 gtk_window_present(GTK_WINDOW(dialog)); | |
352 return; | |
353 } | |
354 | |
355 if (play_button) | |
356 title = _("Play files"); | |
357 else | |
358 title = _("Load files"); | |
359 | |
360 dialog = gtk_file_selection_new(title); | |
361 | |
362 gtk_file_selection_set_select_multiple | |
363 (GTK_FILE_SELECTION(dialog), TRUE); | |
364 | |
365 if (cfg.filesel_path) | |
366 gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog), | |
367 cfg.filesel_path); | |
368 | |
369 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(dialog)); | |
370 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); | |
371 | |
372 gtk_widget_hide(GTK_FILE_SELECTION(dialog)->ok_button); | |
373 gtk_widget_destroy(GTK_FILE_SELECTION(dialog)->cancel_button); | |
374 | |
375 /* | |
376 * The mnemonics are quite unorthodox, but that should guarantee they're unique in any locale | |
377 * plus kinda easy to use | |
378 */ | |
379 button_add_selected = | |
380 gtk_dialog_add_button(GTK_DIALOG(dialog), "Add selected", | |
381 GTK_RESPONSE_NONE); | |
382 gtk_button_set_use_underline(GTK_BUTTON(button_add_selected), TRUE); | |
383 g_signal_connect(G_OBJECT(button_add_selected), "clicked", | |
384 G_CALLBACK(filebrowser_add_selected_files_classic), dialog); | |
385 | |
386 button_add_all = | |
387 gtk_dialog_add_button(GTK_DIALOG(dialog), "Add all", | |
388 GTK_RESPONSE_NONE); | |
389 gtk_button_set_use_underline(GTK_BUTTON(button_add_all), TRUE); | |
390 g_signal_connect(G_OBJECT(button_add_all), "clicked", | |
391 G_CALLBACK(filebrowser_add_all_files_classic), dialog); | |
392 | |
393 if (play_button) { | |
394 button_add = | |
395 gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_MEDIA_PLAY, | |
396 GTK_RESPONSE_NONE); | |
397 gtk_button_set_use_stock(GTK_BUTTON(button_add), TRUE); | |
398 g_signal_connect(G_OBJECT(button_add), "clicked", | |
399 G_CALLBACK(filebrowser_play_classic), dialog); | |
400 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(dialog)->ok_button), | |
401 "clicked", G_CALLBACK(filebrowser_play_classic), dialog); | |
402 } else { | |
403 button_add = | |
404 gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_ADD, | |
405 GTK_RESPONSE_NONE); | |
406 gtk_button_set_use_stock(GTK_BUTTON(button_add), TRUE); | |
407 g_signal_connect(G_OBJECT(button_add), "clicked", | |
408 G_CALLBACK(filebrowser_ok_classic), dialog); | |
409 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(dialog)->ok_button), | |
410 "clicked", G_CALLBACK(filebrowser_ok_classic), dialog); | |
411 } | |
412 | |
413 button_close = | |
414 gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE, | |
415 GTK_RESPONSE_NONE); | |
416 gtk_button_set_use_stock(GTK_BUTTON(button_close), TRUE); | |
417 g_signal_connect_swapped(G_OBJECT(button_close), "clicked", | |
418 G_CALLBACK(gtk_widget_destroy), | |
419 G_OBJECT(dialog)); | |
420 | |
421 gtk_widget_set_size_request(dialog, 600, 450); | |
422 gtk_widget_realize(dialog); | |
423 | |
424 g_signal_connect(G_OBJECT | |
425 (GTK_FILE_SELECTION(dialog)->history_pulldown), | |
426 "changed", G_CALLBACK(filebrowser_entry_changed_classic), | |
427 dialog); | |
428 | |
429 g_signal_connect(G_OBJECT(dialog), "destroy", | |
430 G_CALLBACK(gtk_widget_destroyed), &dialog); | |
431 | |
432 filebrowser_changed_classic(GTK_FILE_SELECTION(dialog)); | |
433 | |
434 gtk_widget_show(dialog); | |
435 } | |
436 | |
437 /* | |
438 * util_run_filebrowser(gboolean play_button) | |
439 * | |
440 * Inputs: | |
441 * - whether or not a play button should be used | |
442 * | |
443 * Outputs: | |
444 * - none | |
445 * | |
446 * Side Effects: | |
447 * - either a GTK1 or a GTK2 fileselector is launched | |
448 */ | |
449 void | |
450 run_filebrowser(gboolean play_button) | |
451 { | |
452 if (!cfg.use_xmms_style_fileselector) | |
453 util_run_filebrowser_gtk2style(play_button); | |
454 else | |
455 util_run_filebrowser_classic(play_button); | |
456 } |