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