Mercurial > audlegacy
annotate src/audacious/ui_jumptotrack.c @ 2967:53ebe56cb0ac trunk
fix scrolling when double-sized
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Mon, 02 Jul 2007 12:50:26 +0200 |
parents | 75b12d24b7dc |
children | 6131bf51ee63 |
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 */ | |
2805
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
116 if(cfg.close_jtf_dialog){ |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
117 gtk_widget_destroy(jump_to_track_win); |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
118 jump_to_track_win = NULL; |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
119 } |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
120 } |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
121 |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
122 static void |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
123 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
|
124 { |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
125 cfg.close_jtf_dialog = |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
126 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle)); |
2500 | 127 } |
128 | |
129 static void | |
130 ui_jump_to_track_jump_cb(GtkTreeView * treeview, | |
131 gpointer data) | |
132 { | |
133 ui_jump_to_track_jump(treeview); | |
134 } | |
135 | |
136 static void | |
137 ui_jump_to_track_set_queue_button_label(GtkButton * button, | |
138 guint pos) | |
139 { | |
140 if (playlist_is_position_queued(playlist_get_active(), pos)) | |
141 gtk_button_set_label(button, _("Un_queue")); | |
142 else | |
143 gtk_button_set_label(button, _("_Queue")); | |
144 } | |
145 | |
146 static void | |
147 ui_jump_to_track_queue_cb(GtkButton * button, | |
148 gpointer data) | |
149 { | |
150 GtkTreeView *treeview; | |
151 GtkTreeModel *model; | |
152 GtkTreeSelection *selection; | |
153 GtkTreeIter iter; | |
154 guint pos; | |
155 | |
156 treeview = GTK_TREE_VIEW(data); | |
157 model = gtk_tree_view_get_model(treeview); | |
158 selection = gtk_tree_view_get_selection(treeview); | |
159 | |
160 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
161 return; | |
162 | |
163 gtk_tree_model_get(model, &iter, 0, &pos, -1); | |
164 | |
165 playlist_queue_position(playlist_get_active(), (pos - 1)); | |
166 | |
167 ui_jump_to_track_set_queue_button_label(button, (pos - 1)); | |
168 } | |
169 | |
170 static void | |
171 ui_jump_to_track_selection_changed_cb(GtkTreeSelection *treesel, | |
172 gpointer data) | |
173 { | |
174 GtkTreeView *treeview; | |
175 GtkTreeModel *model; | |
176 GtkTreeSelection *selection; | |
177 GtkTreeIter iter; | |
178 guint pos; | |
179 | |
180 treeview = gtk_tree_selection_get_tree_view(treesel); | |
181 model = gtk_tree_view_get_model(treeview); | |
182 selection = gtk_tree_view_get_selection(treeview); | |
183 | |
184 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
185 return; | |
186 | |
187 gtk_tree_model_get(model, &iter, 0, &pos, -1); | |
188 | |
189 ui_jump_to_track_set_queue_button_label(GTK_BUTTON(data), (pos - 1)); | |
190 } | |
191 | |
192 static gboolean | |
193 ui_jump_to_track_edit_keypress_cb(GtkWidget * object, | |
194 GdkEventKey * event, | |
195 gpointer data) | |
196 { | |
197 switch (event->keyval) { | |
198 case GDK_Return: | |
199 if (gtk_im_context_filter_keypress (GTK_ENTRY (object)->im_context, event)) { | |
200 GTK_ENTRY (object)->need_im_reset = TRUE; | |
201 return TRUE; | |
202 } else { | |
203 ui_jump_to_track_jump(GTK_TREE_VIEW(data)); | |
204 return TRUE; | |
205 } | |
206 default: | |
207 return FALSE; | |
208 } | |
209 } | |
210 | |
211 static gboolean | |
212 ui_jump_to_track_keypress_cb(GtkWidget * object, | |
213 GdkEventKey * event, | |
214 gpointer data) | |
215 { | |
216 switch (event->keyval) { | |
217 case GDK_Escape: | |
218 /* FIXME: show only hide window */ | |
219 gtk_widget_destroy(jump_to_track_win); | |
220 jump_to_track_win = NULL; | |
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 /* FIXME: Clear the entry when the list gets updated */ | |
254 void | |
255 ui_jump_to_track_update(GtkWidget * widget, gpointer user_data) | |
256 { | |
257 /* FIXME: Is not in sync with playlist due to delayed extinfo | |
258 * reading */ | |
259 guint row; | |
260 GList *playlist_glist; | |
261 gchar *desc_buf = NULL; | |
262 GtkTreeIter iter; | |
263 GtkTreeSelection *selection; | |
264 Playlist *playlist; | |
265 | |
266 GtkTreeModel *store; | |
267 | |
268 if (!jump_to_track_win) | |
269 return; | |
270 | |
271 store = gtk_tree_view_get_model(GTK_TREE_VIEW(user_data)); | |
272 gtk_list_store_clear(GTK_LIST_STORE(store)); | |
273 | |
274 row = 1; | |
275 playlist = playlist_get_active(); | |
276 for (playlist_glist = playlist->entries; playlist_glist; | |
277 playlist_glist = g_list_next(playlist_glist)) { | |
278 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist_glist->data); | |
279 | |
280 if (entry->title) | |
281 desc_buf = g_strdup(entry->title); | |
282 else if (strchr(entry->filename, '/')) | |
283 desc_buf = str_to_utf8(strrchr(entry->filename, '/') + 1); | |
284 else | |
285 desc_buf = str_to_utf8(entry->filename); | |
286 | |
287 gtk_list_store_append(GTK_LIST_STORE(store), &iter); | |
288 gtk_list_store_set(GTK_LIST_STORE(store), &iter, | |
289 0, row, 1, desc_buf, -1); | |
290 row++; | |
291 | |
292 if(desc_buf) { | |
293 g_free(desc_buf); | |
294 desc_buf = NULL; | |
295 } | |
296 } | |
297 | |
298 gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); | |
299 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(user_data)); | |
300 gtk_tree_selection_select_iter(selection, &iter); | |
301 } | |
302 | |
303 static void | |
304 ui_jump_to_track_edit_cb(GtkEntry * entry, gpointer user_data) | |
305 { | |
306 GtkTreeView *treeview = GTK_TREE_VIEW(user_data); | |
307 GtkTreeSelection *selection; | |
308 GtkTreeIter iter; | |
309 | |
310 GtkListStore *store; | |
311 | |
312 guint song_index = 0; | |
313 gchar **words; | |
314 GList *playlist_glist; | |
315 Playlist *playlist; | |
316 | |
317 gboolean match = FALSE; | |
318 | |
319 GSList *regex_list = NULL, *regex_list_tmp = NULL; | |
320 gint i = -1; | |
321 | |
322 /* Chop the key string into ' '-separated key regex-pattern strings */ | |
323 words = g_strsplit(gtk_entry_get_text(entry), " ", 0); | |
324 | |
325 /* create a list of regex using the regex-pattern strings */ | |
326 while ( words[++i] != NULL ) | |
327 { | |
328 regex_t *regex = g_malloc(sizeof(regex_t)); | |
329 #if defined(USE_REGEX_PCRE) | |
330 if ( regcomp( regex , words[i] , REG_NOSUB | REG_ICASE | REG_UTF8 ) == 0 ) | |
331 #else | |
332 if ( regcomp( regex , words[i] , REG_NOSUB | REG_ICASE ) == 0 ) | |
333 #endif | |
334 regex_list = g_slist_append( regex_list , regex ); | |
335 } | |
336 | |
337 /* FIXME: Remove the connected signals before clearing | |
338 * (row-selected will still eventually arrive once) */ | |
339 store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview)); | |
340 /* detach model from treeview */ | |
341 g_object_ref( store ); | |
342 gtk_tree_view_set_model( GTK_TREE_VIEW(treeview) , NULL ); | |
343 | |
344 gtk_list_store_clear(store); | |
345 | |
346 playlist = playlist_get_active(); | |
347 | |
348 PLAYLIST_LOCK(playlist->mutex); | |
349 | |
350 for (playlist_glist = playlist->entries; playlist_glist; | |
2546
9fe930a34683
[svn] - run gtk events while iterating through the playlist
nenolod
parents:
2500
diff
changeset
|
351 playlist_glist = g_list_next(playlist_glist)) |
9fe930a34683
[svn] - run gtk events while iterating through the playlist
nenolod
parents:
2500
diff
changeset
|
352 { |
2500 | 353 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist_glist->data); |
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
|
354 const gchar *title=NULL; |
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
|
355 gchar *filename = NULL; |
2500 | 356 filename = str_to_utf8(entry->filename); |
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
|
357 if (entry->title) |
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
|
358 title = entry->title; |
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
|
359 else |
2500 | 360 title = filename; |
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
|
361 /*we are matching all the path not just the filename or title*/ |
2500 | 362 |
363 /* Compare the reg.expressions to the string - if all the | |
364 regexp in regex_list match, add to the ListStore */ | |
365 | |
366 /* | |
367 * FIXME: The search string should be adapted to the | |
368 * current display setting, e.g. if the user has set it to | |
369 * "%p - %t" then build the match string like that too, or | |
370 * even better, search for each of the tags seperatly. | |
371 * | |
372 * In any case the string to match should _never_ contain | |
373 * something the user can't actually see in the playlist. | |
374 */ | |
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
|
375 //g_print ("it passed\n"); |
2500 | 376 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
|
377 match = ui_jump_to_track_match(title, regex_list); |
2500 | 378 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
|
379 match = TRUE; |
2500 | 380 |
381 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
|
382 if (entry->title) |
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
|
383 title = g_strdup(entry->title); |
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
|
384 else if (strchr(entry->filename, '/')) |
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
|
385 title = str_to_utf8(strrchr(entry->filename, '/') + 1); |
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
|
386 else |
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
|
387 title = str_to_utf8(entry->filename); |
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 |
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
|
389 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
|
390 gtk_list_store_set(store, &iter, 0, song_index + 1 , 1, title, -1); |
2500 | 391 } |
392 song_index++; | |
393 | |
394 if (filename) { | |
395 g_free(filename); | |
396 filename = NULL; | |
397 } | |
398 } | |
399 | |
400 PLAYLIST_UNLOCK(playlist->mutex); | |
401 | |
402 /* attach the model again to the treeview */ | |
403 gtk_tree_view_set_model( GTK_TREE_VIEW(treeview) , GTK_TREE_MODEL(store) ); | |
404 g_object_unref( store ); | |
405 | |
406 if ( regex_list != NULL ) | |
407 { | |
408 regex_list_tmp = regex_list; | |
409 while ( regex_list != NULL ) | |
410 { | |
411 regex_t *regex = regex_list->data; | |
412 regfree( regex ); | |
413 regex_list = g_slist_next(regex_list); | |
414 } | |
415 g_slist_free( regex_list_tmp ); | |
416 } | |
417 g_strfreev(words); | |
418 | |
419 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter)) { | |
420 selection = gtk_tree_view_get_selection(treeview); | |
421 gtk_tree_selection_select_iter(selection, &iter); | |
422 } | |
423 } | |
424 | |
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
|
425 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
|
426 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
|
427 { |
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 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
|
429 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
|
430 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
|
431 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
|
432 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
|
433 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
|
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 /* 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
|
436 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
|
437 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
|
438 |
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 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
|
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 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
|
442 |
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 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
|
444 |
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 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
|
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 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
|
448 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
|
449 |
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 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
|
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 (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
|
453 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
|
454 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
|
455 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
|
456 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
|
457 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
|
458 |
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 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
|
460 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
|
461 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
|
462 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
|
463 |
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 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
|
465 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
|
466 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
|
467 } |
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
|
468 } |
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
|
469 |
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
|
470 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
|
471 |
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
|
472 /* 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
|
473 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
|
474 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
|
475 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
|
476 } |
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 |
2500 | 478 void |
479 ui_jump_to_track(void) | |
480 { | |
481 GtkWidget *scrollwin; | |
482 GtkWidget *vbox, *bbox, *sep; | |
2805
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
483 GtkWidget *toggle; |
2500 | 484 GtkWidget *jump, *queue, *cancel; |
485 GtkWidget *rescan, *edit; | |
486 GtkWidget *search_label, *hbox; | |
487 | |
488 GtkWidget *treeview; | |
489 GtkListStore *jtf_store; | |
490 | |
491 GtkCellRenderer *renderer; | |
492 GtkTreeViewColumn *column; | |
493 | |
494 if (jump_to_track_win) { | |
495 gtk_window_present(GTK_WINDOW(jump_to_track_win)); | |
496 return; | |
497 } | |
498 | |
499 #if defined(USE_REGEX_ONIGURUMA) | |
500 /* set encoding for Oniguruma regex to UTF-8 */ | |
501 reg_set_encoding( REG_POSIX_ENCODING_UTF8 ); | |
502 onig_set_default_syntax( ONIG_SYNTAX_POSIX_BASIC ); | |
503 #endif | |
504 | |
505 jump_to_track_win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
506 gtk_window_set_type_hint(GTK_WINDOW(jump_to_track_win), | |
507 GDK_WINDOW_TYPE_HINT_DIALOG); | |
508 | |
509 gtk_window_set_title(GTK_WINDOW(jump_to_track_win), _("Jump to Track")); | |
510 | |
511 gtk_window_set_position(GTK_WINDOW(jump_to_track_win), GTK_WIN_POS_CENTER); | |
512 g_signal_connect(jump_to_track_win, "destroy", | |
513 G_CALLBACK(gtk_widget_destroyed), &jump_to_track_win); | |
514 | |
515 gtk_container_border_width(GTK_CONTAINER(jump_to_track_win), 10); | |
516 gtk_window_set_default_size(GTK_WINDOW(jump_to_track_win), 550, 350); | |
517 | |
518 vbox = gtk_vbox_new(FALSE, 5); | |
519 gtk_container_add(GTK_CONTAINER(jump_to_track_win), vbox); | |
520 | |
521 jtf_store = gtk_list_store_new(2, G_TYPE_UINT, G_TYPE_STRING); | |
522 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(jtf_store)); | |
523 g_object_unref(jtf_store); | |
524 | |
525 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); | |
526 | |
527 column = gtk_tree_view_column_new(); | |
528 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); | |
529 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); | |
530 | |
531 renderer = gtk_cell_renderer_text_new(); | |
532 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
533 gtk_tree_view_column_set_attributes(column, renderer, "text", 0, NULL); | |
534 gtk_tree_view_column_set_spacing(column, 4); | |
535 | |
536 renderer = gtk_cell_renderer_text_new(); | |
537 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
538 gtk_tree_view_column_set_attributes(column, renderer, "text", 1, NULL); | |
539 gtk_tree_view_column_set_spacing(column, 4); | |
540 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); | |
541 | |
542 gtk_tree_view_set_search_column(GTK_TREE_VIEW(treeview), 1); | |
543 | |
544 g_signal_connect(treeview, "row-activated", | |
545 G_CALLBACK(ui_jump_to_track_jump), NULL); | |
546 | |
547 hbox = gtk_hbox_new(FALSE, 3); | |
548 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3); | |
549 | |
550 search_label = gtk_label_new(_("Filter: ")); | |
551 gtk_label_set_markup_with_mnemonic(GTK_LABEL(search_label), _("_Filter:")); | |
552 gtk_box_pack_start(GTK_BOX(hbox), search_label, FALSE, FALSE, 0); | |
553 | |
554 edit = gtk_entry_new(); | |
555 gtk_entry_set_editable(GTK_ENTRY(edit), TRUE); | |
556 gtk_label_set_mnemonic_widget(GTK_LABEL(search_label), edit); | |
557 g_signal_connect(edit, "changed", | |
558 G_CALLBACK(ui_jump_to_track_edit_cb), treeview); | |
559 | |
560 g_signal_connect(edit, "key_press_event", | |
561 G_CALLBACK(ui_jump_to_track_edit_keypress_cb), treeview); | |
562 | |
563 g_signal_connect(jump_to_track_win, "key_press_event", | |
564 G_CALLBACK(ui_jump_to_track_keypress_cb), treeview); | |
565 | |
566 gtk_box_pack_start(GTK_BOX(hbox), edit, TRUE, TRUE, 3); | |
567 | |
568 scrollwin = gtk_scrolled_window_new(NULL, NULL); | |
569 gtk_container_add(GTK_CONTAINER(scrollwin), treeview); | |
570 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), | |
571 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
572 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwin), | |
573 GTK_SHADOW_IN); | |
574 gtk_box_pack_start(GTK_BOX(vbox), scrollwin, TRUE, TRUE, 0); | |
575 | |
576 sep = gtk_hseparator_new(); | |
577 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
578 | |
579 bbox = gtk_hbutton_box_new(); | |
580 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
581 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
582 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
583 | |
2805
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
584 /* close dialog toggle */ |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
585 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
|
586 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
|
587 cfg.close_jtf_dialog ? TRUE : FALSE); |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
588 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
|
589 g_signal_connect(toggle, "clicked", |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
590 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
|
591 toggle); |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
592 |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
593 |
2500 | 594 queue = gtk_button_new_with_mnemonic(_("_Queue")); |
595 gtk_box_pack_start(GTK_BOX(bbox), queue, FALSE, FALSE, 0); | |
596 GTK_WIDGET_SET_FLAGS(queue, GTK_CAN_DEFAULT); | |
597 g_signal_connect(queue, "clicked", | |
598 G_CALLBACK(ui_jump_to_track_queue_cb), | |
599 treeview); | |
600 g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)), "changed", | |
601 G_CALLBACK(ui_jump_to_track_selection_changed_cb), | |
602 queue); | |
603 | |
604 rescan = gtk_button_new_from_stock(GTK_STOCK_REFRESH); | |
605 gtk_box_pack_start(GTK_BOX(bbox), rescan, FALSE, FALSE, 0); | |
606 g_signal_connect(rescan, "clicked", | |
607 G_CALLBACK(ui_jump_to_track_update), treeview); | |
608 GTK_WIDGET_SET_FLAGS(rescan, GTK_CAN_DEFAULT); | |
609 gtk_widget_grab_default(rescan); | |
610 | |
611 jump = gtk_button_new_from_stock(GTK_STOCK_JUMP_TO); | |
612 gtk_box_pack_start(GTK_BOX(bbox), jump, FALSE, FALSE, 0); | |
613 | |
614 g_signal_connect_swapped(jump, "clicked", | |
615 G_CALLBACK(ui_jump_to_track_jump_cb), | |
616 treeview); | |
617 | |
618 GTK_WIDGET_SET_FLAGS(jump, GTK_CAN_DEFAULT); | |
619 gtk_widget_grab_default(jump); | |
620 | |
621 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
622 gtk_box_pack_start(GTK_BOX(bbox), cancel, FALSE, FALSE, 0); | |
623 g_signal_connect_swapped(cancel, "clicked", | |
624 G_CALLBACK(gtk_widget_destroy), | |
625 jump_to_track_win); | |
626 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
627 | |
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
|
628 g_timeout_add(100, (GSourceFunc)ui_jump_to_track_fill, treeview); |
2500 | 629 |
630 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
|
631 gtk_widget_grab_focus(edit); |
2500 | 632 } |
633 |