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