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