Mercurial > audlegacy
annotate src/audacious/ui_jumptotrack.c @ 2547:8ac0dcad22e3 trunk
[svn] - changes in r4102 break jtf. disabled for now.
author | yaz |
---|---|
date | Sun, 18 Feb 2007 20:40:14 -0800 |
parents | 9fe930a34683 |
children | 904f52140910 |
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 | |
12 * the Free Software Foundation; under version 2 of the License. | |
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 | |
20 * along with this program; if not, write to the Free Software | |
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 # include "config.h" | |
26 #endif | |
27 | |
28 | |
29 #include <glib.h> | |
30 #include <glib/gi18n.h> | |
31 #include <glib/gprintf.h> | |
32 #include <gtk/gtk.h> | |
33 #include <gtk/gtkmessagedialog.h> | |
34 | |
35 /* GDK including */ | |
36 #include "platform/smartinclude.h" | |
37 | |
38 #include <math.h> | |
39 #include <stdlib.h> | |
40 #include <string.h> | |
41 | |
42 #include <X11/Xlib.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 "widgets/widgetcore.h" | |
55 #include "ui_main.h" | |
56 #include "icons-stock.h" | |
57 | |
58 #include "actions-mainwin.h" | |
59 | |
60 #include "main.h" | |
61 | |
62 #include "controlsocket.h" | |
63 #include "dnd.h" | |
64 #include "dock.h" | |
65 #include "genevent.h" | |
66 #include "hints.h" | |
67 #include "input.h" | |
68 #include "libaudacious/configdb.h" | |
69 #include "urldecode.h" | |
70 #include "playback.h" | |
71 #include "playlist.h" | |
72 #include "pluginenum.h" | |
73 #include "ui_credits.h" | |
74 #include "ui_equalizer.h" | |
75 #include "ui_fileopener.h" | |
76 #include "ui_manager.h" | |
77 #include "ui_playlist.h" | |
78 #include "ui_preferences.h" | |
79 #include "ui_skinselector.h" | |
80 #include "ui_urlopener.h" | |
81 #include "strings.h" | |
82 #include "util.h" | |
83 #include "visualization.h" | |
84 | |
85 #include "ui_skinned_window.h" | |
86 | |
87 static GtkWidget *jump_to_track_win = NULL; | |
88 | |
89 static void | |
90 change_song(guint pos) | |
91 { | |
92 if (playback_get_playing()) | |
93 playback_stop(); | |
94 | |
95 playlist_set_position(playlist_get_active(), pos); | |
96 playback_initiate(); | |
97 } | |
98 | |
99 static void | |
100 ui_jump_to_track_jump(GtkTreeView * treeview) | |
101 { | |
102 GtkTreeModel *model; | |
103 GtkTreeSelection *selection; | |
104 GtkTreeIter iter; | |
105 guint pos; | |
106 | |
107 model = gtk_tree_view_get_model(treeview); | |
108 selection = gtk_tree_view_get_selection(treeview); | |
109 | |
110 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
111 return; | |
112 | |
113 gtk_tree_model_get(model, &iter, 0, &pos, -1); | |
114 | |
115 change_song(pos - 1); | |
116 | |
117 /* FIXME: should only hide window */ | |
118 gtk_widget_destroy(jump_to_track_win); | |
119 jump_to_track_win = NULL; | |
120 } | |
121 | |
122 static void | |
123 ui_jump_to_track_jump_cb(GtkTreeView * treeview, | |
124 gpointer data) | |
125 { | |
126 ui_jump_to_track_jump(treeview); | |
127 } | |
128 | |
129 static void | |
130 ui_jump_to_track_set_queue_button_label(GtkButton * button, | |
131 guint pos) | |
132 { | |
133 if (playlist_is_position_queued(playlist_get_active(), pos)) | |
134 gtk_button_set_label(button, _("Un_queue")); | |
135 else | |
136 gtk_button_set_label(button, _("_Queue")); | |
137 } | |
138 | |
139 static void | |
140 ui_jump_to_track_queue_cb(GtkButton * button, | |
141 gpointer data) | |
142 { | |
143 GtkTreeView *treeview; | |
144 GtkTreeModel *model; | |
145 GtkTreeSelection *selection; | |
146 GtkTreeIter iter; | |
147 guint pos; | |
148 | |
149 treeview = GTK_TREE_VIEW(data); | |
150 model = gtk_tree_view_get_model(treeview); | |
151 selection = gtk_tree_view_get_selection(treeview); | |
152 | |
153 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
154 return; | |
155 | |
156 gtk_tree_model_get(model, &iter, 0, &pos, -1); | |
157 | |
158 playlist_queue_position(playlist_get_active(), (pos - 1)); | |
159 | |
160 ui_jump_to_track_set_queue_button_label(button, (pos - 1)); | |
161 } | |
162 | |
163 static void | |
164 ui_jump_to_track_selection_changed_cb(GtkTreeSelection *treesel, | |
165 gpointer data) | |
166 { | |
167 GtkTreeView *treeview; | |
168 GtkTreeModel *model; | |
169 GtkTreeSelection *selection; | |
170 GtkTreeIter iter; | |
171 guint pos; | |
172 | |
173 treeview = gtk_tree_selection_get_tree_view(treesel); | |
174 model = gtk_tree_view_get_model(treeview); | |
175 selection = gtk_tree_view_get_selection(treeview); | |
176 | |
177 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
178 return; | |
179 | |
180 gtk_tree_model_get(model, &iter, 0, &pos, -1); | |
181 | |
182 ui_jump_to_track_set_queue_button_label(GTK_BUTTON(data), (pos - 1)); | |
183 } | |
184 | |
185 static gboolean | |
186 ui_jump_to_track_edit_keypress_cb(GtkWidget * object, | |
187 GdkEventKey * event, | |
188 gpointer data) | |
189 { | |
190 switch (event->keyval) { | |
191 case GDK_Return: | |
192 if (gtk_im_context_filter_keypress (GTK_ENTRY (object)->im_context, event)) { | |
193 GTK_ENTRY (object)->need_im_reset = TRUE; | |
194 return TRUE; | |
195 } else { | |
196 ui_jump_to_track_jump(GTK_TREE_VIEW(data)); | |
197 return TRUE; | |
198 } | |
199 default: | |
200 return FALSE; | |
201 } | |
202 } | |
203 | |
204 static gboolean | |
205 ui_jump_to_track_keypress_cb(GtkWidget * object, | |
206 GdkEventKey * event, | |
207 gpointer data) | |
208 { | |
209 switch (event->keyval) { | |
210 case GDK_Escape: | |
211 /* FIXME: show only hide window */ | |
212 gtk_widget_destroy(jump_to_track_win); | |
213 jump_to_track_win = NULL; | |
214 return TRUE; | |
215 case GDK_KP_Enter: | |
216 ui_jump_to_track_queue_cb(NULL, data); | |
217 return TRUE; | |
218 default: | |
219 return FALSE; | |
220 }; | |
221 | |
222 return FALSE; | |
223 } | |
224 | |
225 static gboolean | |
226 ui_jump_to_track_match(const gchar * song, GSList *regex_list) | |
227 { | |
228 gboolean rv = TRUE; | |
229 | |
230 if ( song == NULL ) | |
231 return FALSE; | |
232 | |
233 for ( ; regex_list ; regex_list = g_slist_next(regex_list) ) | |
234 { | |
235 regex_t *regex = regex_list->data; | |
236 if ( regexec( regex , song , 0 , NULL , 0 ) != 0 ) | |
237 { | |
238 rv = FALSE; | |
239 break; | |
240 } | |
241 } | |
242 | |
243 return rv; | |
244 } | |
245 | |
246 /* FIXME: Clear the entry when the list gets updated */ | |
247 void | |
248 ui_jump_to_track_update(GtkWidget * widget, gpointer user_data) | |
249 { | |
250 /* FIXME: Is not in sync with playlist due to delayed extinfo | |
251 * reading */ | |
252 guint row; | |
253 GList *playlist_glist; | |
254 gchar *desc_buf = NULL; | |
255 GtkTreeIter iter; | |
256 GtkTreeSelection *selection; | |
257 Playlist *playlist; | |
258 | |
259 GtkTreeModel *store; | |
260 | |
261 if (!jump_to_track_win) | |
262 return; | |
263 | |
264 store = gtk_tree_view_get_model(GTK_TREE_VIEW(user_data)); | |
265 gtk_list_store_clear(GTK_LIST_STORE(store)); | |
266 | |
267 row = 1; | |
268 playlist = playlist_get_active(); | |
269 for (playlist_glist = playlist->entries; playlist_glist; | |
270 playlist_glist = g_list_next(playlist_glist)) { | |
271 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist_glist->data); | |
272 | |
273 if (entry->title) | |
274 desc_buf = g_strdup(entry->title); | |
275 else if (strchr(entry->filename, '/')) | |
276 desc_buf = str_to_utf8(strrchr(entry->filename, '/') + 1); | |
277 else | |
278 desc_buf = str_to_utf8(entry->filename); | |
279 | |
280 gtk_list_store_append(GTK_LIST_STORE(store), &iter); | |
281 gtk_list_store_set(GTK_LIST_STORE(store), &iter, | |
282 0, row, 1, desc_buf, -1); | |
283 row++; | |
284 | |
285 if(desc_buf) { | |
286 g_free(desc_buf); | |
287 desc_buf = NULL; | |
288 } | |
289 } | |
290 | |
291 gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); | |
292 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(user_data)); | |
293 gtk_tree_selection_select_iter(selection, &iter); | |
294 } | |
295 | |
296 static void | |
297 ui_jump_to_track_edit_cb(GtkEntry * entry, gpointer user_data) | |
298 { | |
299 GtkTreeView *treeview = GTK_TREE_VIEW(user_data); | |
300 GtkTreeSelection *selection; | |
301 GtkTreeIter iter; | |
302 | |
303 GtkListStore *store; | |
304 | |
305 guint song_index = 0; | |
306 gchar **words; | |
307 GList *playlist_glist; | |
308 Playlist *playlist; | |
309 | |
310 gboolean match = FALSE; | |
311 | |
312 GSList *regex_list = NULL, *regex_list_tmp = NULL; | |
313 gint i = -1; | |
314 | |
315 /* Chop the key string into ' '-separated key regex-pattern strings */ | |
316 words = g_strsplit(gtk_entry_get_text(entry), " ", 0); | |
317 | |
318 /* create a list of regex using the regex-pattern strings */ | |
319 while ( words[++i] != NULL ) | |
320 { | |
321 regex_t *regex = g_malloc(sizeof(regex_t)); | |
322 #if defined(USE_REGEX_PCRE) | |
323 if ( regcomp( regex , words[i] , REG_NOSUB | REG_ICASE | REG_UTF8 ) == 0 ) | |
324 #else | |
325 if ( regcomp( regex , words[i] , REG_NOSUB | REG_ICASE ) == 0 ) | |
326 #endif | |
327 regex_list = g_slist_append( regex_list , regex ); | |
328 } | |
329 | |
330 /* FIXME: Remove the connected signals before clearing | |
331 * (row-selected will still eventually arrive once) */ | |
332 store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview)); | |
333 /* detach model from treeview */ | |
334 g_object_ref( store ); | |
335 gtk_tree_view_set_model( GTK_TREE_VIEW(treeview) , NULL ); | |
336 | |
337 gtk_list_store_clear(store); | |
338 | |
339 playlist = playlist_get_active(); | |
340 | |
341 PLAYLIST_LOCK(playlist->mutex); | |
342 | |
343 for (playlist_glist = playlist->entries; playlist_glist; | |
2546
9fe930a34683
[svn] - run gtk events while iterating through the playlist
nenolod
parents:
2500
diff
changeset
|
344 playlist_glist = g_list_next(playlist_glist)) |
9fe930a34683
[svn] - run gtk events while iterating through the playlist
nenolod
parents:
2500
diff
changeset
|
345 { |
2500 | 346 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist_glist->data); |
347 const gchar *title; | |
348 gchar *filename = NULL; | |
349 | |
2547 | 350 // g_main_context_iteration(g_main_context_default(), FALSE); |
2546
9fe930a34683
[svn] - run gtk events while iterating through the playlist
nenolod
parents:
2500
diff
changeset
|
351 |
2500 | 352 title = entry->title; |
353 if (!title) { | |
354 filename = str_to_utf8(entry->filename); | |
355 | |
356 if (strchr(filename, '/')) | |
357 title = strrchr(filename, '/') + 1; | |
358 else | |
359 title = filename; | |
360 } | |
361 | |
362 /* Compare the reg.expressions to the string - if all the | |
363 regexp in regex_list match, add to the ListStore */ | |
364 | |
365 /* | |
366 * FIXME: The search string should be adapted to the | |
367 * current display setting, e.g. if the user has set it to | |
368 * "%p - %t" then build the match string like that too, or | |
369 * even better, search for each of the tags seperatly. | |
370 * | |
371 * In any case the string to match should _never_ contain | |
372 * something the user can't actually see in the playlist. | |
373 */ | |
374 if (regex_list != NULL) | |
375 match = ui_jump_to_track_match(title, regex_list); | |
376 else | |
377 match = TRUE; | |
378 | |
379 if (match) { | |
380 gtk_list_store_append(store, &iter); | |
381 gtk_list_store_set(store, &iter, 0, song_index + 1 , 1, title, -1); | |
382 } | |
383 | |
384 song_index++; | |
385 | |
386 if (filename) { | |
387 g_free(filename); | |
388 filename = NULL; | |
389 } | |
390 } | |
391 | |
392 PLAYLIST_UNLOCK(playlist->mutex); | |
393 | |
394 /* attach the model again to the treeview */ | |
395 gtk_tree_view_set_model( GTK_TREE_VIEW(treeview) , GTK_TREE_MODEL(store) ); | |
396 g_object_unref( store ); | |
397 | |
398 if ( regex_list != NULL ) | |
399 { | |
400 regex_list_tmp = regex_list; | |
401 while ( regex_list != NULL ) | |
402 { | |
403 regex_t *regex = regex_list->data; | |
404 regfree( regex ); | |
405 regex_list = g_slist_next(regex_list); | |
406 } | |
407 g_slist_free( regex_list_tmp ); | |
408 } | |
409 g_strfreev(words); | |
410 | |
411 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter)) { | |
412 selection = gtk_tree_view_get_selection(treeview); | |
413 gtk_tree_selection_select_iter(selection, &iter); | |
414 } | |
415 } | |
416 | |
417 void | |
418 ui_jump_to_track(void) | |
419 { | |
420 GtkWidget *scrollwin; | |
421 GtkWidget *vbox, *bbox, *sep; | |
422 GtkWidget *jump, *queue, *cancel; | |
423 GtkWidget *rescan, *edit; | |
424 GtkWidget *search_label, *hbox; | |
425 GList *playlist_glist; | |
426 Playlist *playlist; | |
427 gchar *desc_buf = NULL; | |
428 guint row; | |
429 | |
430 GtkWidget *treeview; | |
431 GtkListStore *jtf_store; | |
432 | |
433 GtkTreeIter iter; | |
434 GtkCellRenderer *renderer; | |
435 GtkTreeViewColumn *column; | |
436 | |
437 if (jump_to_track_win) { | |
438 gtk_window_present(GTK_WINDOW(jump_to_track_win)); | |
439 return; | |
440 } | |
441 | |
442 #if defined(USE_REGEX_ONIGURUMA) | |
443 /* set encoding for Oniguruma regex to UTF-8 */ | |
444 reg_set_encoding( REG_POSIX_ENCODING_UTF8 ); | |
445 onig_set_default_syntax( ONIG_SYNTAX_POSIX_BASIC ); | |
446 #endif | |
447 | |
448 jump_to_track_win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
449 gtk_window_set_type_hint(GTK_WINDOW(jump_to_track_win), | |
450 GDK_WINDOW_TYPE_HINT_DIALOG); | |
451 | |
452 gtk_window_set_title(GTK_WINDOW(jump_to_track_win), _("Jump to Track")); | |
453 | |
454 gtk_window_set_position(GTK_WINDOW(jump_to_track_win), GTK_WIN_POS_CENTER); | |
455 g_signal_connect(jump_to_track_win, "destroy", | |
456 G_CALLBACK(gtk_widget_destroyed), &jump_to_track_win); | |
457 | |
458 gtk_container_border_width(GTK_CONTAINER(jump_to_track_win), 10); | |
459 gtk_window_set_default_size(GTK_WINDOW(jump_to_track_win), 550, 350); | |
460 | |
461 vbox = gtk_vbox_new(FALSE, 5); | |
462 gtk_container_add(GTK_CONTAINER(jump_to_track_win), vbox); | |
463 | |
464 jtf_store = gtk_list_store_new(2, G_TYPE_UINT, G_TYPE_STRING); | |
465 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(jtf_store)); | |
466 g_object_unref(jtf_store); | |
467 | |
468 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); | |
469 | |
470 column = gtk_tree_view_column_new(); | |
471 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); | |
472 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); | |
473 | |
474 renderer = gtk_cell_renderer_text_new(); | |
475 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
476 gtk_tree_view_column_set_attributes(column, renderer, "text", 0, NULL); | |
477 gtk_tree_view_column_set_spacing(column, 4); | |
478 | |
479 renderer = gtk_cell_renderer_text_new(); | |
480 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
481 gtk_tree_view_column_set_attributes(column, renderer, "text", 1, NULL); | |
482 gtk_tree_view_column_set_spacing(column, 4); | |
483 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); | |
484 | |
485 gtk_tree_view_set_search_column(GTK_TREE_VIEW(treeview), 1); | |
486 | |
487 g_signal_connect(treeview, "row-activated", | |
488 G_CALLBACK(ui_jump_to_track_jump), NULL); | |
489 | |
490 hbox = gtk_hbox_new(FALSE, 3); | |
491 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3); | |
492 | |
493 search_label = gtk_label_new(_("Filter: ")); | |
494 gtk_label_set_markup_with_mnemonic(GTK_LABEL(search_label), _("_Filter:")); | |
495 gtk_box_pack_start(GTK_BOX(hbox), search_label, FALSE, FALSE, 0); | |
496 | |
497 edit = gtk_entry_new(); | |
498 gtk_entry_set_editable(GTK_ENTRY(edit), TRUE); | |
499 gtk_label_set_mnemonic_widget(GTK_LABEL(search_label), edit); | |
500 g_signal_connect(edit, "changed", | |
501 G_CALLBACK(ui_jump_to_track_edit_cb), treeview); | |
502 | |
503 g_signal_connect(edit, "key_press_event", | |
504 G_CALLBACK(ui_jump_to_track_edit_keypress_cb), treeview); | |
505 | |
506 g_signal_connect(jump_to_track_win, "key_press_event", | |
507 G_CALLBACK(ui_jump_to_track_keypress_cb), treeview); | |
508 | |
509 gtk_box_pack_start(GTK_BOX(hbox), edit, TRUE, TRUE, 3); | |
510 | |
511 scrollwin = gtk_scrolled_window_new(NULL, NULL); | |
512 gtk_container_add(GTK_CONTAINER(scrollwin), treeview); | |
513 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), | |
514 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
515 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwin), | |
516 GTK_SHADOW_IN); | |
517 gtk_box_pack_start(GTK_BOX(vbox), scrollwin, TRUE, TRUE, 0); | |
518 | |
519 sep = gtk_hseparator_new(); | |
520 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
521 | |
522 bbox = gtk_hbutton_box_new(); | |
523 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
524 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
525 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
526 | |
527 queue = gtk_button_new_with_mnemonic(_("_Queue")); | |
528 gtk_box_pack_start(GTK_BOX(bbox), queue, FALSE, FALSE, 0); | |
529 GTK_WIDGET_SET_FLAGS(queue, GTK_CAN_DEFAULT); | |
530 g_signal_connect(queue, "clicked", | |
531 G_CALLBACK(ui_jump_to_track_queue_cb), | |
532 treeview); | |
533 g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)), "changed", | |
534 G_CALLBACK(ui_jump_to_track_selection_changed_cb), | |
535 queue); | |
536 | |
537 rescan = gtk_button_new_from_stock(GTK_STOCK_REFRESH); | |
538 gtk_box_pack_start(GTK_BOX(bbox), rescan, FALSE, FALSE, 0); | |
539 g_signal_connect(rescan, "clicked", | |
540 G_CALLBACK(ui_jump_to_track_update), treeview); | |
541 GTK_WIDGET_SET_FLAGS(rescan, GTK_CAN_DEFAULT); | |
542 gtk_widget_grab_default(rescan); | |
543 | |
544 jump = gtk_button_new_from_stock(GTK_STOCK_JUMP_TO); | |
545 gtk_box_pack_start(GTK_BOX(bbox), jump, FALSE, FALSE, 0); | |
546 | |
547 g_signal_connect_swapped(jump, "clicked", | |
548 G_CALLBACK(ui_jump_to_track_jump_cb), | |
549 treeview); | |
550 | |
551 GTK_WIDGET_SET_FLAGS(jump, GTK_CAN_DEFAULT); | |
552 gtk_widget_grab_default(jump); | |
553 | |
554 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
555 gtk_box_pack_start(GTK_BOX(bbox), cancel, FALSE, FALSE, 0); | |
556 g_signal_connect_swapped(cancel, "clicked", | |
557 G_CALLBACK(gtk_widget_destroy), | |
558 jump_to_track_win); | |
559 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
560 | |
561 gtk_list_store_clear(jtf_store); | |
562 | |
563 row = 1; | |
564 | |
565 playlist = playlist_get_active(); | |
566 | |
567 PLAYLIST_LOCK(playlist->mutex); | |
568 | |
569 for (playlist_glist = playlist->entries; playlist_glist; | |
570 playlist_glist = g_list_next(playlist_glist)) { | |
571 | |
572 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist_glist->data); | |
573 | |
574 if (entry->title) | |
575 desc_buf = g_strdup(entry->title); | |
576 else if (strchr(entry->filename, '/')) | |
577 desc_buf = str_to_utf8(strrchr(entry->filename, '/') + 1); | |
578 else | |
579 desc_buf = str_to_utf8(entry->filename); | |
580 | |
581 gtk_list_store_append(GTK_LIST_STORE(jtf_store), &iter); | |
582 gtk_list_store_set(GTK_LIST_STORE(jtf_store), &iter, | |
583 0, row, 1, desc_buf, -1); | |
584 row++; | |
585 | |
586 if (desc_buf) { | |
587 g_free(desc_buf); | |
588 desc_buf = NULL; | |
589 } | |
590 } | |
591 | |
592 PLAYLIST_UNLOCK(playlist->mutex); | |
593 | |
594 gtk_widget_show_all(jump_to_track_win); | |
595 } | |
596 |