annotate src/audacious/ui_jumptotrack.c @ 3147:f8a449aa8a6f trunk

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