annotate src/audacious/ui_fileopener.c @ 2422:b31111934cd3 trunk

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