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