Mercurial > audlegacy
annotate src/audacious/ui_jumptotrack.c @ 4621:fb56923e8206
Updated pkg.m4.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 05 Jun 2008 16:04:18 +0300 |
parents | 23a9ded30c70 |
children | b87f8c707b7f |
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 "input.h" | |
63 #include "playback.h" | |
64 #include "playlist.h" | |
65 #include "pluginenum.h" | |
66 #include "ui_credits.h" | |
4546 | 67 #include "ui_dock.h" |
2500 | 68 #include "ui_equalizer.h" |
69 #include "ui_fileopener.h" | |
70 #include "ui_manager.h" | |
71 #include "ui_playlist.h" | |
72 #include "ui_preferences.h" | |
73 #include "ui_skinselector.h" | |
74 #include "ui_urlopener.h" | |
75 #include "strings.h" | |
76 #include "util.h" | |
77 #include "visualization.h" | |
78 | |
79 #include "ui_skinned_window.h" | |
80 | |
4291
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
81 #include "ui_jumptotrack_cache.h" |
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
82 |
2500 | 83 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
|
84 static gulong serial = 0; |
2500 | 85 |
4291
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
86 static JumpToTrackCache* cache = NULL; |
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
87 |
2500 | 88 static void |
89 change_song(guint pos) | |
90 { | |
91 if (playback_get_playing()) | |
92 playback_stop(); | |
93 | |
94 playlist_set_position(playlist_get_active(), pos); | |
95 playback_initiate(); | |
96 } | |
97 | |
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
|
98 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
|
99 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
|
100 { |
4115
e99284bb7936
Reset the text entry box to nothing when the jump to track window is requested.
William Pitcock <nenolod@atheme.org>
parents:
4085
diff
changeset
|
101 g_return_if_fail(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
|
102 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
|
103 } |
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
|
104 |
2500 | 105 static void |
106 ui_jump_to_track_jump(GtkTreeView * treeview) | |
107 { | |
108 GtkTreeModel *model; | |
109 GtkTreeSelection *selection; | |
110 GtkTreeIter iter; | |
111 guint pos; | |
112 | |
113 model = gtk_tree_view_get_model(treeview); | |
114 selection = gtk_tree_view_get_selection(treeview); | |
115 | |
116 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
117 return; | |
118 | |
119 gtk_tree_model_get(model, &iter, 0, &pos, -1); | |
120 | |
121 change_song(pos - 1); | |
122 | |
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
|
123 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
|
124 ui_jump_to_track_hide(); |
3917 | 125 } |
126 | |
2805
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
127 static void |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
128 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
|
129 { |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
130 cfg.close_jtf_dialog = |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
131 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle)); |
2500 | 132 } |
133 | |
134 static void | |
4116
5853d43e539a
remember filter entry in jtf dialog is extremely useful when jtf deals with large playlist. now this feature is configurable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4115
diff
changeset
|
135 ui_jump_to_track_toggle2_cb(GtkWidget * toggle) |
5853d43e539a
remember filter entry in jtf dialog is extremely useful when jtf deals with large playlist. now this feature is configurable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4115
diff
changeset
|
136 { |
5853d43e539a
remember filter entry in jtf dialog is extremely useful when jtf deals with large playlist. now this feature is configurable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4115
diff
changeset
|
137 cfg.remember_jtf_entry = |
5853d43e539a
remember filter entry in jtf dialog is extremely useful when jtf deals with large playlist. now this feature is configurable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4115
diff
changeset
|
138 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle)); |
5853d43e539a
remember filter entry in jtf dialog is extremely useful when jtf deals with large playlist. now this feature is configurable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4115
diff
changeset
|
139 } |
5853d43e539a
remember filter entry in jtf dialog is extremely useful when jtf deals with large playlist. now this feature is configurable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4115
diff
changeset
|
140 |
5853d43e539a
remember filter entry in jtf dialog is extremely useful when jtf deals with large playlist. now this feature is configurable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4115
diff
changeset
|
141 static void |
2500 | 142 ui_jump_to_track_jump_cb(GtkTreeView * treeview, |
143 gpointer data) | |
144 { | |
145 ui_jump_to_track_jump(treeview); | |
146 } | |
147 | |
148 static void | |
149 ui_jump_to_track_set_queue_button_label(GtkButton * button, | |
150 guint pos) | |
151 { | |
152 if (playlist_is_position_queued(playlist_get_active(), pos)) | |
153 gtk_button_set_label(button, _("Un_queue")); | |
154 else | |
155 gtk_button_set_label(button, _("_Queue")); | |
156 } | |
157 | |
158 static void | |
159 ui_jump_to_track_queue_cb(GtkButton * button, | |
160 gpointer data) | |
161 { | |
162 GtkTreeView *treeview; | |
163 GtkTreeModel *model; | |
164 GtkTreeSelection *selection; | |
165 GtkTreeIter iter; | |
166 guint pos; | |
167 | |
168 treeview = GTK_TREE_VIEW(data); | |
169 model = gtk_tree_view_get_model(treeview); | |
170 selection = gtk_tree_view_get_selection(treeview); | |
171 | |
172 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
173 return; | |
174 | |
175 gtk_tree_model_get(model, &iter, 0, &pos, -1); | |
176 | |
177 playlist_queue_position(playlist_get_active(), (pos - 1)); | |
178 | |
179 ui_jump_to_track_set_queue_button_label(button, (pos - 1)); | |
180 } | |
181 | |
182 static void | |
183 ui_jump_to_track_selection_changed_cb(GtkTreeSelection *treesel, | |
184 gpointer data) | |
185 { | |
186 GtkTreeView *treeview; | |
187 GtkTreeModel *model; | |
188 GtkTreeSelection *selection; | |
189 GtkTreeIter iter; | |
190 guint pos; | |
191 | |
192 treeview = gtk_tree_selection_get_tree_view(treesel); | |
193 model = gtk_tree_view_get_model(treeview); | |
194 selection = gtk_tree_view_get_selection(treeview); | |
195 | |
196 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
197 return; | |
198 | |
199 gtk_tree_model_get(model, &iter, 0, &pos, -1); | |
200 | |
201 ui_jump_to_track_set_queue_button_label(GTK_BUTTON(data), (pos - 1)); | |
202 } | |
203 | |
204 static gboolean | |
205 ui_jump_to_track_edit_keypress_cb(GtkWidget * object, | |
206 GdkEventKey * event, | |
207 gpointer data) | |
208 { | |
209 switch (event->keyval) { | |
210 case GDK_Return: | |
211 if (gtk_im_context_filter_keypress (GTK_ENTRY (object)->im_context, event)) { | |
212 GTK_ENTRY (object)->need_im_reset = TRUE; | |
213 return TRUE; | |
214 } else { | |
215 ui_jump_to_track_jump(GTK_TREE_VIEW(data)); | |
216 return TRUE; | |
217 } | |
218 default: | |
219 return FALSE; | |
220 } | |
221 } | |
222 | |
223 static gboolean | |
224 ui_jump_to_track_keypress_cb(GtkWidget * object, | |
225 GdkEventKey * event, | |
226 gpointer data) | |
227 { | |
228 switch (event->keyval) { | |
229 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
|
230 ui_jump_to_track_hide(); |
2500 | 231 return TRUE; |
232 case GDK_KP_Enter: | |
233 ui_jump_to_track_queue_cb(NULL, data); | |
234 return TRUE; | |
235 default: | |
236 return FALSE; | |
237 }; | |
238 | |
239 return FALSE; | |
240 } | |
241 | |
242 void | |
243 ui_jump_to_track_update(GtkWidget * widget, gpointer user_data) | |
244 { | |
245 guint row; | |
246 GList *playlist_glist; | |
247 gchar *desc_buf = NULL; | |
248 GtkTreeIter iter; | |
249 GtkTreeSelection *selection; | |
250 Playlist *playlist; | |
251 | |
252 GtkTreeModel *store; | |
253 | |
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
|
254 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
|
255 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
|
256 |
2500 | 257 if (!jump_to_track_win) |
258 return; | |
259 | |
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
|
260 /* 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
|
261 if(edit){ |
4116
5853d43e539a
remember filter entry in jtf dialog is extremely useful when jtf deals with large playlist. now this feature is configurable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4115
diff
changeset
|
262 gtk_entry_set_text(edit, ""); |
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
|
263 } |
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
|
264 |
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 store = gtk_tree_view_get_model(tree); |
2500 | 266 gtk_list_store_clear(GTK_LIST_STORE(store)); |
267 | |
268 row = 1; | |
269 playlist = playlist_get_active(); | |
270 for (playlist_glist = playlist->entries; playlist_glist; | |
271 playlist_glist = g_list_next(playlist_glist)) { | |
272 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist_glist->data); | |
273 | |
274 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
|
275 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
|
276 else { |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
277 gchar *realfn = NULL; |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
278 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
|
279 if (strchr(realfn ? realfn : entry->filename, '/')) |
4608
23a9ded30c70
Use str_assert_utf8() where it makes sense in the core.
Matti Hamalainen <ccr@tnsp.org>
parents:
4546
diff
changeset
|
280 desc_buf = str_assert_utf8(strrchr(realfn ? realfn : entry->filename, '/') + 1); |
3096
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
281 else |
4608
23a9ded30c70
Use str_assert_utf8() where it makes sense in the core.
Matti Hamalainen <ccr@tnsp.org>
parents:
4546
diff
changeset
|
282 desc_buf = str_assert_utf8(realfn ? realfn : entry->filename); |
3096
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
283 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
|
284 } |
2500 | 285 |
286 gtk_list_store_append(GTK_LIST_STORE(store), &iter); | |
287 gtk_list_store_set(GTK_LIST_STORE(store), &iter, | |
288 0, row, 1, desc_buf, -1); | |
289 row++; | |
290 | |
3096
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
291 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
|
292 desc_buf = NULL; |
2500 | 293 } |
294 | |
295 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
|
296 selection = gtk_tree_view_get_selection(tree); |
2500 | 297 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
|
298 serial = playlist->serial; // important. --yaz |
2500 | 299 } |
300 | |
301 static void | |
302 ui_jump_to_track_edit_cb(GtkEntry * entry, gpointer user_data) | |
303 { | |
304 GtkTreeView *treeview = GTK_TREE_VIEW(user_data); | |
305 GtkTreeSelection *selection; | |
306 GtkTreeIter iter; | |
307 | |
308 GtkListStore *store; | |
309 | |
4291
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
310 const GArray *search_matches; |
2500 | 311 Playlist *playlist; |
4291
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
312 int i; |
2500 | 313 |
4291
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
314 if (cache == NULL) { |
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
315 cache = ui_jump_to_track_cache_new(); |
2500 | 316 } |
317 | |
318 /* FIXME: Remove the connected signals before clearing | |
319 * (row-selected will still eventually arrive once) */ | |
320 store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview)); | |
321 /* detach model from treeview */ | |
322 g_object_ref( store ); | |
323 gtk_tree_view_set_model( GTK_TREE_VIEW(treeview) , NULL ); | |
324 | |
325 gtk_list_store_clear(store); | |
326 | |
327 playlist = playlist_get_active(); | |
328 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3251
diff
changeset
|
329 PLAYLIST_LOCK(playlist); |
2500 | 330 |
4291
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
331 search_matches = ui_jump_to_track_cache_search(cache, |
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
332 playlist, |
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
333 gtk_entry_get_text(entry)); |
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
334 |
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
335 for (i = 0; i < search_matches->len; i++) |
2546
9fe930a34683
[svn] - run gtk events while iterating through the playlist
nenolod
parents:
2500
diff
changeset
|
336 { |
4291
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
337 JumpToTrackEntry *jttentry = g_array_index(search_matches, JumpToTrackEntry*, i); |
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
338 PlaylistEntry* entry = jttentry->entry; |
3096
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
339 gchar *title = NULL; |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
340 |
4291
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
341 if (entry->title) |
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
342 title = g_strdup(entry->title); |
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
343 else { |
3096
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
344 gchar *realfn = NULL; |
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
345 realfn = g_filename_from_uri(entry->filename, NULL, NULL); |
4291
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
346 if (strchr(realfn ? realfn : entry->filename, '/')) |
4608
23a9ded30c70
Use str_assert_utf8() where it makes sense in the core.
Matti Hamalainen <ccr@tnsp.org>
parents:
4546
diff
changeset
|
347 title = str_assert_utf8(strrchr(realfn ? realfn : entry->filename, '/') + 1); |
4291
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
348 else |
4608
23a9ded30c70
Use str_assert_utf8() where it makes sense in the core.
Matti Hamalainen <ccr@tnsp.org>
parents:
4546
diff
changeset
|
349 title = str_assert_utf8(realfn ? realfn : entry->filename); |
3096
8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3092
diff
changeset
|
350 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
|
351 } |
4291
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
352 gtk_list_store_append(store, &iter); |
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
353 gtk_list_store_set(store, &iter, 0, jttentry->playlist_position + 1 , 1, title, -1); |
ca077e01ed3a
Add caching to Jump to Track feature to speed up searches. (Bugzilla #180)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4179
diff
changeset
|
354 g_free(title); |
2500 | 355 } |
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_UNLOCK(playlist); |
2500 | 358 |
359 /* attach the model again to the treeview */ | |
360 gtk_tree_view_set_model( GTK_TREE_VIEW(treeview) , GTK_TREE_MODEL(store) ); | |
361 g_object_unref( store ); | |
362 | |
363 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter)) { | |
364 selection = gtk_tree_view_get_selection(treeview); | |
365 gtk_tree_selection_select_iter(selection, &iter); | |
366 } | |
367 } | |
368 | |
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
|
369 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
|
370 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
|
371 { |
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
|
372 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
|
373 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
|
374 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
|
375 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
|
376 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
|
377 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
|
378 |
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
|
379 /* 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
|
380 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
|
381 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
|
382 |
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
|
383 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
|
384 |
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
|
385 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
|
386 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
|
387 |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3251
diff
changeset
|
388 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
|
389 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
|
390 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
|
391 |
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
|
392 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
|
393 |
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
|
394 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
|
395 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
|
396 else { |
3081
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2976
diff
changeset
|
397 gchar *realfn = NULL; |
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2976
diff
changeset
|
398 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
|
399 if (strchr(realfn ? realfn : entry->filename, '/')) |
4608
23a9ded30c70
Use str_assert_utf8() where it makes sense in the core.
Matti Hamalainen <ccr@tnsp.org>
parents:
4546
diff
changeset
|
400 desc_buf = str_assert_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
|
401 else |
4608
23a9ded30c70
Use str_assert_utf8() where it makes sense in the core.
Matti Hamalainen <ccr@tnsp.org>
parents:
4546
diff
changeset
|
402 desc_buf = str_assert_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
|
403 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
|
404 } |
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
|
405 |
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
|
406 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
|
407 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
|
408 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
|
409 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
|
410 |
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
|
411 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
|
412 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
|
413 } |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3251
diff
changeset
|
414 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
|
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 /* 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
|
417 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
|
418 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
|
419 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
|
420 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
|
421 } |
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 |
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
|
423 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
|
424 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
|
425 { |
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
|
426 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
|
427 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
|
428 |
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
|
429 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
|
430 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
|
431 |
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
|
432 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
|
433 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
|
434 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
|
435 } |
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
|
436 |
2500 | 437 void |
438 ui_jump_to_track(void) | |
439 { | |
440 GtkWidget *scrollwin; | |
441 GtkWidget *vbox, *bbox, *sep; | |
4116
5853d43e539a
remember filter entry in jtf dialog is extremely useful when jtf deals with large playlist. now this feature is configurable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4115
diff
changeset
|
442 GtkWidget *toggle, *toggle2; |
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
|
443 GtkWidget *jump, *queue, *close; |
4085
008708425c83
make filter field in jtf dialog always grab focus on appearance.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3920
diff
changeset
|
444 GtkWidget *rescan; |
4115
e99284bb7936
Reset the text entry box to nothing when the jump to track window is requested.
William Pitcock <nenolod@atheme.org>
parents:
4085
diff
changeset
|
445 GtkWidget *search_label, *hbox; |
4085
008708425c83
make filter field in jtf dialog always grab focus on appearance.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3920
diff
changeset
|
446 static GtkWidget *edit; |
2500 | 447 |
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
|
448 GtkWidget *treeview = NULL; |
2500 | 449 GtkListStore *jtf_store; |
450 | |
451 GtkCellRenderer *renderer; | |
452 GtkTreeViewColumn *column; | |
453 | |
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
|
454 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
|
455 |
2500 | 456 if (jump_to_track_win) { |
457 gtk_window_present(GTK_WINDOW(jump_to_track_win)); | |
4116
5853d43e539a
remember filter entry in jtf dialog is extremely useful when jtf deals with large playlist. now this feature is configurable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4115
diff
changeset
|
458 |
5853d43e539a
remember filter entry in jtf dialog is extremely useful when jtf deals with large playlist. now this feature is configurable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4115
diff
changeset
|
459 if(!cfg.remember_jtf_entry) |
5853d43e539a
remember filter entry in jtf dialog is extremely useful when jtf deals with large playlist. now this feature is configurable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4115
diff
changeset
|
460 gtk_entry_set_text(GTK_ENTRY(edit), ""); |
5853d43e539a
remember filter entry in jtf dialog is extremely useful when jtf deals with large playlist. now this feature is configurable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4115
diff
changeset
|
461 |
4085
008708425c83
make filter field in jtf dialog always grab focus on appearance.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3920
diff
changeset
|
462 gtk_widget_grab_focus(edit); |
4116
5853d43e539a
remember filter entry in jtf dialog is extremely useful when jtf deals with large playlist. now this feature is configurable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4115
diff
changeset
|
463 gtk_editable_select_region(GTK_EDITABLE(edit), 0, -1); |
2500 | 464 return; |
465 } | |
466 | |
467 #if defined(USE_REGEX_ONIGURUMA) | |
468 /* set encoding for Oniguruma regex to UTF-8 */ | |
469 reg_set_encoding( REG_POSIX_ENCODING_UTF8 ); | |
470 onig_set_default_syntax( ONIG_SYNTAX_POSIX_BASIC ); | |
471 #endif | |
472 | |
473 jump_to_track_win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
474 gtk_window_set_type_hint(GTK_WINDOW(jump_to_track_win), | |
475 GDK_WINDOW_TYPE_HINT_DIALOG); | |
476 | |
477 gtk_window_set_title(GTK_WINDOW(jump_to_track_win), _("Jump to Track")); | |
478 | |
479 gtk_window_set_position(GTK_WINDOW(jump_to_track_win), GTK_WIN_POS_CENTER); | |
480 g_signal_connect(jump_to_track_win, "destroy", | |
481 G_CALLBACK(gtk_widget_destroyed), &jump_to_track_win); | |
482 | |
483 gtk_container_border_width(GTK_CONTAINER(jump_to_track_win), 10); | |
4177
948d373a513c
just a little bigger
Cristi Magherusan <majeru@atheme-project.org>
parents:
4176
diff
changeset
|
484 gtk_window_set_default_size(GTK_WINDOW(jump_to_track_win), 600, 500); |
2500 | 485 |
486 vbox = gtk_vbox_new(FALSE, 5); | |
487 gtk_container_add(GTK_CONTAINER(jump_to_track_win), vbox); | |
488 | |
489 jtf_store = gtk_list_store_new(2, G_TYPE_UINT, G_TYPE_STRING); | |
490 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(jtf_store)); | |
491 g_object_unref(jtf_store); | |
492 | |
493 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); | |
494 | |
495 column = gtk_tree_view_column_new(); | |
496 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); | |
497 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); | |
498 | |
499 renderer = gtk_cell_renderer_text_new(); | |
500 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
501 gtk_tree_view_column_set_attributes(column, renderer, "text", 0, NULL); | |
502 gtk_tree_view_column_set_spacing(column, 4); | |
503 | |
504 renderer = gtk_cell_renderer_text_new(); | |
505 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
506 gtk_tree_view_column_set_attributes(column, renderer, "text", 1, NULL); | |
507 gtk_tree_view_column_set_spacing(column, 4); | |
508 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); | |
509 | |
510 gtk_tree_view_set_search_column(GTK_TREE_VIEW(treeview), 1); | |
511 | |
512 g_signal_connect(treeview, "row-activated", | |
513 G_CALLBACK(ui_jump_to_track_jump), NULL); | |
514 | |
515 hbox = gtk_hbox_new(FALSE, 3); | |
516 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3); | |
517 | |
4178
cb0952a41f7b
- removed genres that appeared twice in the file info dialog
mf0102 <0102@gmx.at>
parents:
4177
diff
changeset
|
518 |
cb0952a41f7b
- removed genres that appeared twice in the file info dialog
mf0102 <0102@gmx.at>
parents:
4177
diff
changeset
|
519 /* filter box */ |
2500 | 520 search_label = gtk_label_new(_("Filter: ")); |
521 gtk_label_set_markup_with_mnemonic(GTK_LABEL(search_label), _("_Filter:")); | |
522 gtk_box_pack_start(GTK_BOX(hbox), search_label, FALSE, FALSE, 0); | |
523 | |
524 edit = gtk_entry_new(); | |
525 gtk_entry_set_editable(GTK_ENTRY(edit), TRUE); | |
526 gtk_label_set_mnemonic_widget(GTK_LABEL(search_label), edit); | |
527 g_signal_connect(edit, "changed", | |
528 G_CALLBACK(ui_jump_to_track_edit_cb), treeview); | |
529 | |
530 g_signal_connect(edit, "key_press_event", | |
531 G_CALLBACK(ui_jump_to_track_edit_keypress_cb), treeview); | |
532 | |
533 g_signal_connect(jump_to_track_win, "key_press_event", | |
534 G_CALLBACK(ui_jump_to_track_keypress_cb), treeview); | |
535 | |
536 gtk_box_pack_start(GTK_BOX(hbox), edit, TRUE, TRUE, 3); | |
537 | |
4174
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
538 /* remember text entry */ |
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
539 toggle2 = gtk_check_button_new_with_label(_("Remember")); |
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
540 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle2), |
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
541 cfg.remember_jtf_entry ? TRUE : FALSE); |
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
542 gtk_box_pack_start(GTK_BOX(hbox), toggle2, FALSE, FALSE, 0); |
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
543 g_signal_connect(toggle2, "clicked", |
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
544 G_CALLBACK(ui_jump_to_track_toggle2_cb), |
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
545 toggle2); |
4178
cb0952a41f7b
- removed genres that appeared twice in the file info dialog
mf0102 <0102@gmx.at>
parents:
4177
diff
changeset
|
546 |
cb0952a41f7b
- removed genres that appeared twice in the file info dialog
mf0102 <0102@gmx.at>
parents:
4177
diff
changeset
|
547 /* clear button */ |
4174
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
548 rescan = gtk_button_new_from_stock(GTK_STOCK_CLEAR); |
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
549 gtk_box_pack_start(GTK_BOX(hbox), rescan, FALSE, FALSE, 0); |
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
550 |
4178
cb0952a41f7b
- removed genres that appeared twice in the file info dialog
mf0102 <0102@gmx.at>
parents:
4177
diff
changeset
|
551 |
4174
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
552 /* pack to container */ |
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
553 storage = g_object_new(G_TYPE_OBJECT, NULL); |
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
554 g_object_set_data(storage, "widget", rescan); |
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
555 g_object_set_data(storage, "treeview", treeview); |
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
556 g_object_set_data(storage, "edit", edit); |
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
557 |
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
558 g_signal_connect(rescan, "clicked", |
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
559 G_CALLBACK(ui_jump_to_track_update), storage); |
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
560 |
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
561 GTK_WIDGET_SET_FLAGS(rescan, GTK_CAN_DEFAULT); |
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
562 gtk_widget_grab_default(rescan); |
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
563 |
2500 | 564 scrollwin = gtk_scrolled_window_new(NULL, NULL); |
565 gtk_container_add(GTK_CONTAINER(scrollwin), treeview); | |
566 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), | |
567 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
568 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwin), | |
569 GTK_SHADOW_IN); | |
570 gtk_box_pack_start(GTK_BOX(vbox), scrollwin, TRUE, TRUE, 0); | |
571 | |
572 sep = gtk_hseparator_new(); | |
573 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
574 | |
575 bbox = gtk_hbutton_box_new(); | |
576 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
4174
6425fbe741f1
reorganized the JTF dialog, it's not so wide anymore
Cristi Magherusan <majeru@atheme-project.org>
parents:
4160
diff
changeset
|
577 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 4); |
2500 | 578 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); |
579 | |
2805
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
580 /* close dialog toggle */ |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
581 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
|
582 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
|
583 cfg.close_jtf_dialog ? TRUE : FALSE); |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
584 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
|
585 g_signal_connect(toggle, "clicked", |
6295535fbf49
[svn] - add toggle button to keep jtf dialog opened on jump.
yaz
parents:
2717
diff
changeset
|
586 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
|
587 toggle); |
4176
75188b91097e
added the GTK_STOCK_ADD pixmap to the queue button
Cristi Magherusan <majeru@atheme-project.org>
parents:
4174
diff
changeset
|
588 |
2500 | 589 queue = gtk_button_new_with_mnemonic(_("_Queue")); |
4176
75188b91097e
added the GTK_STOCK_ADD pixmap to the queue button
Cristi Magherusan <majeru@atheme-project.org>
parents:
4174
diff
changeset
|
590 gtk_button_set_image(GTK_BUTTON(queue), |
4178
cb0952a41f7b
- removed genres that appeared twice in the file info dialog
mf0102 <0102@gmx.at>
parents:
4177
diff
changeset
|
591 gtk_image_new_from_stock(AUD_STOCK_QUEUETOGGLE, GTK_ICON_SIZE_BUTTON)); |
2500 | 592 gtk_box_pack_start(GTK_BOX(bbox), queue, FALSE, FALSE, 0); |
593 GTK_WIDGET_SET_FLAGS(queue, GTK_CAN_DEFAULT); | |
594 g_signal_connect(queue, "clicked", | |
595 G_CALLBACK(ui_jump_to_track_queue_cb), | |
596 treeview); | |
597 g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)), "changed", | |
598 G_CALLBACK(ui_jump_to_track_selection_changed_cb), | |
599 queue); | |
600 | |
601 jump = gtk_button_new_from_stock(GTK_STOCK_JUMP_TO); | |
602 gtk_box_pack_start(GTK_BOX(bbox), jump, FALSE, FALSE, 0); | |
603 | |
604 g_signal_connect_swapped(jump, "clicked", | |
605 G_CALLBACK(ui_jump_to_track_jump_cb), | |
606 treeview); | |
607 | |
608 GTK_WIDGET_SET_FLAGS(jump, GTK_CAN_DEFAULT); | |
609 gtk_widget_grab_default(jump); | |
610 | |
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
|
611 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
|
612 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
|
613 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
|
614 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
|
615 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
|
616 GTK_WIDGET_SET_FLAGS(close, GTK_CAN_DEFAULT); |
2500 | 617 |
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
|
618 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
|
619 g_timeout_add(500, (GSourceFunc)watchdog, storage); |
2500 | 620 |
621 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
|
622 gtk_widget_grab_focus(edit); |
2500 | 623 } |