Mercurial > audlegacy
annotate src/audacious/ui_jumptotrack.c @ 4042:e8066e91388a
Automated merge with ssh://hg.atheme.org//hg/audacious
author | Eugene Zagidullin <e.asphyx@gmail.com> |
---|---|
date | Sat, 01 Dec 2007 01:57:03 +0300 |
parents | c2b2828186ba |
children | 008708425c83 |
rev | line source |
---|---|
2500 | 1 /* Audacious - Cross-platform multimedia player |
2 * Copyright (C) 2005-2006 Audacious development team. | |
3 * | |
4 * BMP - Cross-platform multimedia player | |
5 * Copyright (C) 2003-2004 BMP development team. | |
6 * | |
7 * Based on XMMS: | |
8 * Copyright (C) 1998-2003 XMMS development team. | |
9 * | |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3096
diff
changeset
|
12 * the Free Software Foundation; under version 3 of the License. |
2500 | 13 * |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3096
diff
changeset
|
20 * 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
|
21 * |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
22 * 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
|
23 * Audacious or using our public API to be a derived work. |
2500 | 24 */ |
25 | |
26 #ifdef HAVE_CONFIG_H | |
27 # include "config.h" | |
28 #endif | |
29 | |
30 | |
31 #include <glib.h> | |
32 #include <glib/gi18n.h> | |
33 #include <glib/gprintf.h> | |
34 #include <gtk/gtk.h> | |
35 #include <gtk/gtkmessagedialog.h> | |
36 | |
37 /* GDK including */ | |
38 #include "platform/smartinclude.h" | |
39 | |
40 #include <math.h> | |
41 #include <stdlib.h> | |
42 #include <string.h> | |
43 | |
44 #include <sys/types.h> | |
45 | |
46 #if defined(USE_REGEX_ONIGURUMA) | |
47 #include <onigposix.h> | |
48 #elif defined(USE_REGEX_PCRE) | |
49 #include <pcreposix.h> | |
50 #else | |
51 #include <regex.h> | |
52 #endif | |
53 | |
54 #include "ui_main.h" | |
55 #include "icons-stock.h" | |
56 | |
57 #include "actions-mainwin.h" | |
58 | |
59 #include "main.h" | |
60 | |
61 #include "dnd.h" | |
62 #include "dock.h" | |
63 #include "hints.h" | |
64 #include "input.h" | |
65 #include "playback.h" | |
66 #include "playlist.h" | |
67 #include "pluginenum.h" | |
68 #include "ui_credits.h" | |
69 #include "ui_equalizer.h" | |
70 #include "ui_fileopener.h" | |
71 #include "ui_manager.h" | |
72 #include "ui_playlist.h" | |
73 #include "ui_preferences.h" | |
74 #include "ui_skinselector.h" | |
75 #include "ui_urlopener.h" | |
76 #include "strings.h" | |
77 #include "util.h" | |
78 #include "visualization.h" | |
79 | |
80 #include "ui_skinned_window.h" | |
81 | |
82 static GtkWidget *jump_to_track_win = NULL; | |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
83 static gulong serial = 0; |
2500 | 84 |
85 static void | |
86 change_song(guint pos) | |
87 { | |
88 if (playback_get_playing()) | |
89 playback_stop(); | |
90 | |
91 playlist_set_position(playlist_get_active(), pos); | |
92 playback_initiate(); | |
93 } | |
94 | |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
95 void |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
96 ui_jump_to_track_hide(void) |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
97 { |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
98 g_return_if_fail(jump_to_track_win); |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
99 gtk_widget_hide(jump_to_track_win); |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
100 } |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
101 |
2500 | 102 static void |
103 ui_jump_to_track_jump(GtkTreeView * treeview) | |
104 { | |
105 GtkTreeModel *model; | |
106 GtkTreeSelection *selection; | |
107 GtkTreeIter iter; | |
108 guint pos; | |
109 | |
110 model = gtk_tree_view_get_model(treeview); | |
111 selection = gtk_tree_view_get_selection(treeview); | |
112 | |
113 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
114 return; | |
115 | |
116 gtk_tree_model_get(model, &iter, 0, &pos, -1); | |
117 | |
118 change_song(pos - 1); | |
119 | |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
120 if(cfg.close_jtf_dialog) |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
121 ui_jump_to_track_hide(); |
3917 | 122 } |
123 | |
2805
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
124 static void |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
125 ui_jump_to_track_toggle_cb(GtkWidget * toggle) |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
126 { |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
127 cfg.close_jtf_dialog = |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
128 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle)); |
2500 | 129 } |
130 | |
131 static void | |
132 ui_jump_to_track_jump_cb(GtkTreeView * treeview, | |
133 gpointer data) | |
134 { | |
135 ui_jump_to_track_jump(treeview); | |
136 } | |
137 | |
138 static void | |
139 ui_jump_to_track_set_queue_button_label(GtkButton * button, | |
140 guint pos) | |
141 { | |
142 if (playlist_is_position_queued(playlist_get_active(), pos)) | |
143 gtk_button_set_label(button, _("Un_queue")); | |
144 else | |
145 gtk_button_set_label(button, _("_Queue")); | |
146 } | |
147 | |
148 static void | |
149 ui_jump_to_track_queue_cb(GtkButton * button, | |
150 gpointer data) | |
151 { | |
152 GtkTreeView *treeview; | |
153 GtkTreeModel *model; | |
154 GtkTreeSelection *selection; | |
155 GtkTreeIter iter; | |
156 guint pos; | |
157 | |
158 treeview = GTK_TREE_VIEW(data); | |
159 model = gtk_tree_view_get_model(treeview); | |
160 selection = gtk_tree_view_get_selection(treeview); | |
161 | |
162 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
163 return; | |
164 | |
165 gtk_tree_model_get(model, &iter, 0, &pos, -1); | |
166 | |
167 playlist_queue_position(playlist_get_active(), (pos - 1)); | |
168 | |
169 ui_jump_to_track_set_queue_button_label(button, (pos - 1)); | |
170 } | |
171 | |
172 static void | |
173 ui_jump_to_track_selection_changed_cb(GtkTreeSelection *treesel, | |
174 gpointer data) | |
175 { | |
176 GtkTreeView *treeview; | |
177 GtkTreeModel *model; | |
178 GtkTreeSelection *selection; | |
179 GtkTreeIter iter; | |
180 guint pos; | |
181 | |
182 treeview = gtk_tree_selection_get_tree_view(treesel); | |
183 model = gtk_tree_view_get_model(treeview); | |
184 selection = gtk_tree_view_get_selection(treeview); | |
185 | |
186 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
187 return; | |
188 | |
189 gtk_tree_model_get(model, &iter, 0, &pos, -1); | |
190 | |
191 ui_jump_to_track_set_queue_button_label(GTK_BUTTON(data), (pos - 1)); | |
192 } | |
193 | |
194 static gboolean | |
195 ui_jump_to_track_edit_keypress_cb(GtkWidget * object, | |
196 GdkEventKey * event, | |
197 gpointer data) | |
198 { | |
199 switch (event->keyval) { | |
200 case GDK_Return: | |
201 if (gtk_im_context_filter_keypress (GTK_ENTRY (object)->im_context, event)) { | |
202 GTK_ENTRY (object)->need_im_reset = TRUE; | |
203 return TRUE; | |
204 } else { | |
205 ui_jump_to_track_jump(GTK_TREE_VIEW(data)); | |
206 return TRUE; | |
207 } | |
208 default: | |
209 return FALSE; | |
210 } | |
211 } | |
212 | |
213 static gboolean | |
214 ui_jump_to_track_keypress_cb(GtkWidget * object, | |
215 GdkEventKey * event, | |
216 gpointer data) | |
217 { | |
218 switch (event->keyval) { | |
219 case GDK_Escape: | |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
220 ui_jump_to_track_hide(); |
2500 | 221 return TRUE; |
222 case GDK_KP_Enter: | |
223 ui_jump_to_track_queue_cb(NULL, data); | |
224 return TRUE; | |
225 default: | |
226 return FALSE; | |
227 }; | |
228 | |
229 return FALSE; | |
230 } | |
231 | |
232 static gboolean | |
233 ui_jump_to_track_match(const gchar * song, GSList *regex_list) | |
234 { | |
235 gboolean rv = TRUE; | |
236 | |
237 if ( song == NULL ) | |
238 return FALSE; | |
239 | |
240 for ( ; regex_list ; regex_list = g_slist_next(regex_list) ) | |
241 { | |
242 regex_t *regex = regex_list->data; | |
243 if ( regexec( regex , song , 0 , NULL , 0 ) != 0 ) | |
244 { | |
245 rv = FALSE; | |
246 break; | |
247 } | |
248 } | |
249 | |
250 return rv; | |
251 } | |
252 | |
253 void | |
254 ui_jump_to_track_update(GtkWidget * widget, gpointer user_data) | |
255 { | |
256 guint row; | |
257 GList *playlist_glist; | |
258 gchar *desc_buf = NULL; | |
259 GtkTreeIter iter; | |
260 GtkTreeSelection *selection; | |
261 Playlist *playlist; | |
262 | |
263 GtkTreeModel *store; | |
264 | |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
265 GtkTreeView *tree = GTK_TREE_VIEW(g_object_get_data(user_data, "treeview")); |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
266 GtkEntry *edit = g_object_get_data(user_data, "edit"); |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
267 |
2500 | 268 if (!jump_to_track_win) |
269 return; | |
270 | |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
271 /* clear edit widget */ |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
272 if(edit){ |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
273 gtk_entry_set_text(edit, "\0"); |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
274 } |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
275 |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
276 store = gtk_tree_view_get_model(tree); |
2500 | 277 gtk_list_store_clear(GTK_LIST_STORE(store)); |
278 | |
279 row = 1; | |
280 playlist = playlist_get_active(); | |
281 for (playlist_glist = playlist->entries; playlist_glist; | |
282 playlist_glist = g_list_next(playlist_glist)) { | |
283 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist_glist->data); | |
284 | |
285 if (entry->title) | |
3096
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
286 desc_buf = g_strdup(entry->title); |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
287 else { |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
288 gchar *realfn = NULL; |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
289 realfn = g_filename_from_uri(entry->filename, NULL, NULL); |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
290 if (strchr(realfn ? realfn : entry->filename, '/')) |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
291 desc_buf = str_to_utf8(strrchr(realfn ? realfn : entry->filename, '/') + 1); |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
292 else |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
293 desc_buf = str_to_utf8(realfn ? realfn : entry->filename); |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
294 g_free(realfn); realfn = NULL; |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
295 } |
2500 | 296 |
297 gtk_list_store_append(GTK_LIST_STORE(store), &iter); | |
298 gtk_list_store_set(GTK_LIST_STORE(store), &iter, | |
299 0, row, 1, desc_buf, -1); | |
300 row++; | |
301 | |
3096
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
302 g_free(desc_buf); |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
303 desc_buf = NULL; |
2500 | 304 } |
305 | |
306 gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); | |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
307 selection = gtk_tree_view_get_selection(tree); |
2500 | 308 gtk_tree_selection_select_iter(selection, &iter); |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
309 serial = playlist->serial; // important. --yaz |
2500 | 310 } |
311 | |
312 static void | |
313 ui_jump_to_track_edit_cb(GtkEntry * entry, gpointer user_data) | |
314 { | |
315 GtkTreeView *treeview = GTK_TREE_VIEW(user_data); | |
316 GtkTreeSelection *selection; | |
317 GtkTreeIter iter; | |
318 | |
319 GtkListStore *store; | |
320 | |
321 guint song_index = 0; | |
322 gchar **words; | |
323 GList *playlist_glist; | |
324 Playlist *playlist; | |
325 | |
326 gboolean match = FALSE; | |
327 | |
328 GSList *regex_list = NULL, *regex_list_tmp = NULL; | |
329 gint i = -1; | |
330 | |
331 /* Chop the key string into ' '-separated key regex-pattern strings */ | |
332 words = g_strsplit(gtk_entry_get_text(entry), " ", 0); | |
333 | |
334 /* create a list of regex using the regex-pattern strings */ | |
335 while ( words[++i] != NULL ) | |
336 { | |
337 regex_t *regex = g_malloc(sizeof(regex_t)); | |
338 #if defined(USE_REGEX_PCRE) | |
339 if ( regcomp( regex , words[i] , REG_NOSUB | REG_ICASE | REG_UTF8 ) == 0 ) | |
340 #else | |
341 if ( regcomp( regex , words[i] , REG_NOSUB | REG_ICASE ) == 0 ) | |
342 #endif | |
343 regex_list = g_slist_append( regex_list , regex ); | |
344 } | |
345 | |
346 /* FIXME: Remove the connected signals before clearing | |
347 * (row-selected will still eventually arrive once) */ | |
348 store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview)); | |
349 /* detach model from treeview */ | |
350 g_object_ref( store ); | |
351 gtk_tree_view_set_model( GTK_TREE_VIEW(treeview) , NULL ); | |
352 | |
353 gtk_list_store_clear(store); | |
354 | |
355 playlist = playlist_get_active(); | |
356 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3251
diff
changeset
|
357 PLAYLIST_LOCK(playlist); |
2500 | 358 |
359 for (playlist_glist = playlist->entries; playlist_glist; | |
2546
9fe930a34683
[svn] - run gtk events while iterating through the playlist
nenolod
parents:
2500
diff
changeset
|
360 playlist_glist = g_list_next(playlist_glist)) |
9fe930a34683
[svn] - run gtk events while iterating through the playlist
nenolod
parents:
2500
diff
changeset
|
361 { |
2500 | 362 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist_glist->data); |
3096
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
363 gchar *title = NULL; |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
364 |
2819
75b12d24b7dc
[svn] match the whole filename when tag isn't available, but i couldnt figure out how to do this all the time because it kept crashing...
majeru
parents:
2805
diff
changeset
|
365 if (entry->title) |
3096
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
366 title = g_strdup(entry->title); |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
367 else { |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
368 gchar *realfn = NULL; |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
369 realfn = g_filename_from_uri(entry->filename, NULL, NULL); |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
370 title = str_to_utf8(realfn ? realfn : entry->filename); |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
371 g_free(realfn); realfn = NULL; |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
372 } |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
373 |
2819
75b12d24b7dc
[svn] match the whole filename when tag isn't available, but i couldnt figure out how to do this all the time because it kept crashing...
majeru
parents:
2805
diff
changeset
|
374 /*we are matching all the path not just the filename or title*/ |
2500 | 375 |
376 /* Compare the reg.expressions to the string - if all the | |
377 regexp in regex_list match, add to the ListStore */ | |
378 | |
379 /* | |
380 * FIXME: The search string should be adapted to the | |
381 * current display setting, e.g. if the user has set it to | |
382 * "%p - %t" then build the match string like that too, or | |
383 * even better, search for each of the tags seperatly. | |
384 * | |
385 * In any case the string to match should _never_ contain | |
386 * something the user can't actually see in the playlist. | |
387 */ | |
2819
75b12d24b7dc
[svn] match the whole filename when tag isn't available, but i couldnt figure out how to do this all the time because it kept crashing...
majeru
parents:
2805
diff
changeset
|
388 //g_print ("it passed\n"); |
2500 | 389 if (regex_list != NULL) |
2819
75b12d24b7dc
[svn] match the whole filename when tag isn't available, but i couldnt figure out how to do this all the time because it kept crashing...
majeru
parents:
2805
diff
changeset
|
390 match = ui_jump_to_track_match(title, regex_list); |
2500 | 391 else |
2819
75b12d24b7dc
[svn] match the whole filename when tag isn't available, but i couldnt figure out how to do this all the time because it kept crashing...
majeru
parents:
2805
diff
changeset
|
392 match = TRUE; |
2500 | 393 |
394 if (match) { | |
2819
75b12d24b7dc
[svn] match the whole filename when tag isn't available, but i couldnt figure out how to do this all the time because it kept crashing...
majeru
parents:
2805
diff
changeset
|
395 if (entry->title) |
3096
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
396 title = g_strdup(entry->title); |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
397 else { |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
398 gchar *realfn = NULL; |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
399 realfn = g_filename_from_uri(entry->filename, NULL, NULL); |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
400 if (strchr(realfn ? realfn : entry->filename, '/')) |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
401 title = str_to_utf8(strrchr(realfn ? realfn : entry->filename, '/') + 1); |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
402 else |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
403 title = str_to_utf8(realfn ? realfn : entry->filename); |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
404 g_free(realfn); realfn = NULL; |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
405 } |
2819
75b12d24b7dc
[svn] match the whole filename when tag isn't available, but i couldnt figure out how to do this all the time because it kept crashing...
majeru
parents:
2805
diff
changeset
|
406 gtk_list_store_append(store, &iter); |
75b12d24b7dc
[svn] match the whole filename when tag isn't available, but i couldnt figure out how to do this all the time because it kept crashing...
majeru
parents:
2805
diff
changeset
|
407 gtk_list_store_set(store, &iter, 0, song_index + 1 , 1, title, -1); |
2500 | 408 } |
409 song_index++; | |
3096
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
410 g_free(title); title = NULL; |
2500 | 411 } |
412 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3251
diff
changeset
|
413 PLAYLIST_UNLOCK(playlist); |
2500 | 414 |
415 /* attach the model again to the treeview */ | |
416 gtk_tree_view_set_model( GTK_TREE_VIEW(treeview) , GTK_TREE_MODEL(store) ); | |
417 g_object_unref( store ); | |
418 | |
419 if ( regex_list != NULL ) | |
420 { | |
421 regex_list_tmp = regex_list; | |
422 while ( regex_list != NULL ) | |
423 { | |
424 regex_t *regex = regex_list->data; | |
425 regfree( regex ); | |
426 regex_list = g_slist_next(regex_list); | |
427 } | |
428 g_slist_free( regex_list_tmp ); | |
429 } | |
430 g_strfreev(words); | |
431 | |
432 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter)) { | |
433 selection = gtk_tree_view_get_selection(treeview); | |
434 gtk_tree_selection_select_iter(selection, &iter); | |
435 } | |
436 } | |
437 | |
2639
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
438 static gboolean |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
439 ui_jump_to_track_fill(gpointer treeview) |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
440 { |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
441 GList *playlist_glist; |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
442 Playlist *playlist; |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
443 gchar *desc_buf = NULL; |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
444 guint row; |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
445 GtkTreeIter iter; |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
446 GtkListStore *jtf_store = (GtkListStore*)gtk_tree_view_get_model( GTK_TREE_VIEW(treeview) ); |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
447 |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
448 /* detach model from treeview before fill */ |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
449 g_object_ref(jtf_store); |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
450 gtk_tree_view_set_model( GTK_TREE_VIEW(treeview), NULL ); |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
451 |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
452 gtk_list_store_clear(jtf_store); |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
453 |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
454 row = 1; |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
455 playlist = playlist_get_active(); |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
456 |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3251
diff
changeset
|
457 PLAYLIST_LOCK(playlist); |
2639
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
458 for (playlist_glist = playlist->entries; playlist_glist; |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
459 playlist_glist = g_list_next(playlist_glist)) { |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
460 |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
461 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist_glist->data); |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
462 |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
463 if (entry->title) |
3096
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
464 desc_buf = g_strdup(entry->title); |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
465 else { |
3081
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2976
diff
changeset
|
466 gchar *realfn = NULL; |
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2976
diff
changeset
|
467 realfn = g_filename_from_uri(entry->filename, NULL, NULL); |
3096
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
468 if (strchr(realfn ? realfn : entry->filename, '/')) |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
469 desc_buf = str_to_utf8(strrchr(realfn ? realfn : entry->filename, '/') + 1); |
3081
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2976
diff
changeset
|
470 else |
3096
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
471 desc_buf = str_to_utf8(realfn ? realfn : entry->filename); |
3081
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2976
diff
changeset
|
472 g_free(realfn); realfn = NULL; |
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2976
diff
changeset
|
473 } |
2639
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
474 |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
475 gtk_list_store_append(GTK_LIST_STORE(jtf_store), &iter); |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
476 gtk_list_store_set(GTK_LIST_STORE(jtf_store), &iter, |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
477 0, row, 1, desc_buf, -1); |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
478 row++; |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
479 |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
480 g_free(desc_buf); |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
481 desc_buf = NULL; |
2639
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
482 } |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3251
diff
changeset
|
483 PLAYLIST_UNLOCK(playlist); |
2639
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
484 |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
485 /* attach liststore to treeview */ |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
486 gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(jtf_store)); |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
487 g_object_unref(jtf_store); |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
488 serial = playlist->serial; |
2639
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
489 return FALSE; |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
490 } |
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
491 |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
492 static gboolean |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
493 watchdog(gpointer storage) |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
494 { |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
495 GtkWidget *widget; |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
496 Playlist *playlist = playlist_get_active(); |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
497 |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
498 if(serial == playlist->serial) |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
499 return TRUE; |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
500 |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
501 widget = g_object_get_data(storage, "widget"); |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
502 ui_jump_to_track_update(widget, storage); |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
503 return TRUE; |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
504 } |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
505 |
2500 | 506 void |
507 ui_jump_to_track(void) | |
508 { | |
509 GtkWidget *scrollwin; | |
510 GtkWidget *vbox, *bbox, *sep; | |
2805
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
511 GtkWidget *toggle; |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
512 GtkWidget *jump, *queue, *close; |
2500 | 513 GtkWidget *rescan, *edit; |
514 GtkWidget *search_label, *hbox; | |
515 | |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
516 GtkWidget *treeview = NULL; |
2500 | 517 GtkListStore *jtf_store; |
518 | |
519 GtkCellRenderer *renderer; | |
520 GtkTreeViewColumn *column; | |
521 | |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
522 gpointer storage; |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
523 |
2500 | 524 if (jump_to_track_win) { |
525 gtk_window_present(GTK_WINDOW(jump_to_track_win)); | |
526 return; | |
527 } | |
528 | |
529 #if defined(USE_REGEX_ONIGURUMA) | |
530 /* set encoding for Oniguruma regex to UTF-8 */ | |
531 reg_set_encoding( REG_POSIX_ENCODING_UTF8 ); | |
532 onig_set_default_syntax( ONIG_SYNTAX_POSIX_BASIC ); | |
533 #endif | |
534 | |
535 jump_to_track_win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
536 gtk_window_set_type_hint(GTK_WINDOW(jump_to_track_win), | |
537 GDK_WINDOW_TYPE_HINT_DIALOG); | |
538 | |
539 gtk_window_set_title(GTK_WINDOW(jump_to_track_win), _("Jump to Track")); | |
540 | |
541 gtk_window_set_position(GTK_WINDOW(jump_to_track_win), GTK_WIN_POS_CENTER); | |
542 g_signal_connect(jump_to_track_win, "destroy", | |
543 G_CALLBACK(gtk_widget_destroyed), &jump_to_track_win); | |
544 | |
545 gtk_container_border_width(GTK_CONTAINER(jump_to_track_win), 10); | |
546 gtk_window_set_default_size(GTK_WINDOW(jump_to_track_win), 550, 350); | |
547 | |
548 vbox = gtk_vbox_new(FALSE, 5); | |
549 gtk_container_add(GTK_CONTAINER(jump_to_track_win), vbox); | |
550 | |
551 jtf_store = gtk_list_store_new(2, G_TYPE_UINT, G_TYPE_STRING); | |
552 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(jtf_store)); | |
553 g_object_unref(jtf_store); | |
554 | |
555 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); | |
556 | |
557 column = gtk_tree_view_column_new(); | |
558 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); | |
559 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); | |
560 | |
561 renderer = gtk_cell_renderer_text_new(); | |
562 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
563 gtk_tree_view_column_set_attributes(column, renderer, "text", 0, NULL); | |
564 gtk_tree_view_column_set_spacing(column, 4); | |
565 | |
566 renderer = gtk_cell_renderer_text_new(); | |
567 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
568 gtk_tree_view_column_set_attributes(column, renderer, "text", 1, NULL); | |
569 gtk_tree_view_column_set_spacing(column, 4); | |
570 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); | |
571 | |
572 gtk_tree_view_set_search_column(GTK_TREE_VIEW(treeview), 1); | |
573 | |
574 g_signal_connect(treeview, "row-activated", | |
575 G_CALLBACK(ui_jump_to_track_jump), NULL); | |
576 | |
577 hbox = gtk_hbox_new(FALSE, 3); | |
578 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3); | |
579 | |
580 search_label = gtk_label_new(_("Filter: ")); | |
581 gtk_label_set_markup_with_mnemonic(GTK_LABEL(search_label), _("_Filter:")); | |
582 gtk_box_pack_start(GTK_BOX(hbox), search_label, FALSE, FALSE, 0); | |
583 | |
584 edit = gtk_entry_new(); | |
585 gtk_entry_set_editable(GTK_ENTRY(edit), TRUE); | |
586 gtk_label_set_mnemonic_widget(GTK_LABEL(search_label), edit); | |
587 g_signal_connect(edit, "changed", | |
588 G_CALLBACK(ui_jump_to_track_edit_cb), treeview); | |
589 | |
590 g_signal_connect(edit, "key_press_event", | |
591 G_CALLBACK(ui_jump_to_track_edit_keypress_cb), treeview); | |
592 | |
593 g_signal_connect(jump_to_track_win, "key_press_event", | |
594 G_CALLBACK(ui_jump_to_track_keypress_cb), treeview); | |
595 | |
596 gtk_box_pack_start(GTK_BOX(hbox), edit, TRUE, TRUE, 3); | |
597 | |
598 scrollwin = gtk_scrolled_window_new(NULL, NULL); | |
599 gtk_container_add(GTK_CONTAINER(scrollwin), treeview); | |
600 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), | |
601 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
602 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwin), | |
603 GTK_SHADOW_IN); | |
604 gtk_box_pack_start(GTK_BOX(vbox), scrollwin, TRUE, TRUE, 0); | |
605 | |
606 sep = gtk_hseparator_new(); | |
607 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
608 | |
609 bbox = gtk_hbutton_box_new(); | |
610 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
611 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
612 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
613 | |
2805
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
614 /* close dialog toggle */ |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
615 toggle = gtk_check_button_new_with_label(_("Close on Jump")); |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
616 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
617 cfg.close_jtf_dialog ? TRUE : FALSE); |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
618 gtk_box_pack_start(GTK_BOX(bbox), toggle, FALSE, FALSE, 0); |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
619 g_signal_connect(toggle, "clicked", |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
620 G_CALLBACK(ui_jump_to_track_toggle_cb), |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
621 toggle); |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
622 |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
623 |
2500 | 624 queue = gtk_button_new_with_mnemonic(_("_Queue")); |
625 gtk_box_pack_start(GTK_BOX(bbox), queue, FALSE, FALSE, 0); | |
626 GTK_WIDGET_SET_FLAGS(queue, GTK_CAN_DEFAULT); | |
627 g_signal_connect(queue, "clicked", | |
628 G_CALLBACK(ui_jump_to_track_queue_cb), | |
629 treeview); | |
630 g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)), "changed", | |
631 G_CALLBACK(ui_jump_to_track_selection_changed_cb), | |
632 queue); | |
633 | |
634 rescan = gtk_button_new_from_stock(GTK_STOCK_REFRESH); | |
635 gtk_box_pack_start(GTK_BOX(bbox), rescan, FALSE, FALSE, 0); | |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
636 |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
637 /* pack to container */ |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
638 storage = g_object_new(G_TYPE_OBJECT, NULL); |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
639 g_object_set_data(storage, "widget", rescan); |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
640 g_object_set_data(storage, "treeview", treeview); |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
641 g_object_set_data(storage, "edit", edit); |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
642 |
2500 | 643 g_signal_connect(rescan, "clicked", |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
644 G_CALLBACK(ui_jump_to_track_update), storage); |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
645 |
2500 | 646 GTK_WIDGET_SET_FLAGS(rescan, GTK_CAN_DEFAULT); |
647 gtk_widget_grab_default(rescan); | |
648 | |
649 jump = gtk_button_new_from_stock(GTK_STOCK_JUMP_TO); | |
650 gtk_box_pack_start(GTK_BOX(bbox), jump, FALSE, FALSE, 0); | |
651 | |
652 g_signal_connect_swapped(jump, "clicked", | |
653 G_CALLBACK(ui_jump_to_track_jump_cb), | |
654 treeview); | |
655 | |
656 GTK_WIDGET_SET_FLAGS(jump, GTK_CAN_DEFAULT); | |
657 gtk_widget_grab_default(jump); | |
658 | |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
659 close = gtk_button_new_from_stock(GTK_STOCK_CLOSE); |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
660 gtk_box_pack_start(GTK_BOX(bbox), close, FALSE, FALSE, 0); |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
661 /* g_signal_connect_swapped(close, "clicked", */ |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
662 /* G_CALLBACK(gtk_widget_destroy), */ |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
663 /* jump_to_track_win); */ |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
664 g_signal_connect_swapped(close, "clicked", |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
665 G_CALLBACK(gtk_widget_hide), |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
666 jump_to_track_win); // just hide --yaz |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
667 GTK_WIDGET_SET_FLAGS(close, GTK_CAN_DEFAULT); |
2500 | 668 |
2639
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
669 g_timeout_add(100, (GSourceFunc)ui_jump_to_track_fill, treeview); |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3917
diff
changeset
|
670 g_timeout_add(500, (GSourceFunc)watchdog, storage); |
2500 | 671 |
672 gtk_widget_show_all(jump_to_track_win); | |
2639
ed67025aeea5
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
giacomo
parents:
2627
diff
changeset
|
673 gtk_widget_grab_focus(edit); |
2500 | 674 } |
675 |