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