Mercurial > audlegacy
annotate audacious/ui_playlist.c @ 2144:b76039eeb6f0 trunk
[svn] - added auto-enqueue option for search-in-playlist
author | giacomo |
---|---|
date | Sat, 16 Dec 2006 10:44:25 -0800 |
parents | 299651a8f107 |
children | e2c6696c1d9a |
rev | line source |
---|---|
1653 | 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 | |
2105
f18a5b617c34
[svn] - move to GPLv2-only. Based on my interpretation of the license, we are
nenolod
parents:
2095
diff
changeset
|
12 * the Free Software Foundation; under version 2 of the License. |
1653 | 13 * |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program; if not, write to the Free Software | |
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
22 */ | |
23 | |
24 #include "ui_playlist.h" | |
25 | |
26 #include <glib.h> | |
27 #include <glib/gi18n.h> | |
28 #include <gdk/gdk.h> | |
29 #include <gdk/gdkkeysyms.h> | |
30 #include <gtk/gtk.h> | |
31 #include <string.h> | |
32 | |
33 #include "platform/smartinclude.h" | |
34 | |
35 #include <unistd.h> | |
36 #include <errno.h> | |
37 | |
38 #include "libaudacious/util.h" | |
39 | |
40 #include "dnd.h" | |
41 #include "dock.h" | |
42 #include "equalizer.h" | |
43 #include "hints.h" | |
44 #include "input.h" | |
45 #include "main.h" | |
46 #include "mainwin.h" | |
47 #include "playback.h" | |
48 #include "playlist.h" | |
49 #include "playlist_container.h" | |
50 #include "util.h" | |
51 | |
52 #include "pixmaps.h" | |
53 #include "images/audacious_playlist.xpm" | |
54 | |
55 | |
56 #define ITEM_SEPARATOR {"/-", NULL, NULL, 0, "<Separator>", NULL} | |
57 | |
58 | |
59 enum { | |
60 ADD_URL, ADD_DIR, ADD_FILES, | |
61 SUB_MISC, SUB_ALL, SUB_CROP, SUB_SELECTED, | |
62 SUB_DUPLICATE_BYTITLE, SUB_DUPLICATE_BYFILENAME, SUB_DUPLICATE_BYPATH, | |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
63 SEL_SEARCH, SEL_INV, SEL_ZERO, SEL_ALL, |
1653 | 64 MISC_SORT, MISC_FILEINFO, MISC_MISCOPTS, |
65 PLIST_NEW, PLIST_SAVE_AS, PLIST_LOAD, | |
66 SEL_LOOKUP, CLOSE_PL_WINDOW, MOVE_UP, PLIST_SAVE, | |
67 MISC_QUEUE, PLIST_CQUEUE, PLIST_JTF, PLIST_JTT, | |
68 PLAYLISTWIN_REMOVE_DEAD_FILES, | |
69 PLAYLISTWIN_REFRESH, PLIST_DEFAULTSAVE, MISC_FILEPOPUP | |
70 }; | |
71 | |
72 enum { | |
73 PLAYLISTWIN_SORT_BYTITLE, PLAYLISTWIN_SORT_BYFILENAME, | |
74 PLAYLISTWIN_SORT_BYPATH, PLAYLISTWIN_SORT_BYDATE, | |
75 PLAYLISTWIN_SORT_BYARTIST, PLAYLISTWIN_SORT_SEL_BYARTIST, | |
76 PLAYLISTWIN_SORT_SEL_BYTITLE, PLAYLISTWIN_SORT_SEL_BYFILENAME, | |
77 PLAYLISTWIN_SORT_SEL_BYPATH, PLAYLISTWIN_SORT_SEL_BYDATE, | |
78 PLAYLISTWIN_SORT_RANDOMIZE, PLAYLISTWIN_SORT_REVERSE, | |
79 PLAYLISTWIN_SORT_BYTRACK, PLAYLISTWIN_SORT_SEL_BYTRACK, | |
80 PLAYLISTWIN_SORT_BYPLAYLIST, PLAYLISTWIN_SORT_SEL_BYPLAYLIST | |
81 }; | |
82 | |
83 GtkWidget *playlistwin; | |
84 | |
85 PlayList_List *playlistwin_list = NULL; | |
86 PButton *playlistwin_shade, *playlistwin_close; | |
87 | |
88 static gboolean playlistwin_resizing = FALSE; | |
89 | |
90 static GtkItemFactory *playlistwin_popup_menu; | |
91 static GtkItemFactory *pladd_menu, *pldel_menu; | |
92 static GtkItemFactory *plsel_menu, *plsort_menu; | |
93 static GtkItemFactory *pllist_menu; | |
94 | |
95 static GdkPixmap *playlistwin_bg; | |
96 static GdkBitmap *playlistwin_mask = NULL; | |
97 static GdkGC *playlistwin_gc; | |
98 | |
99 static GtkAccelGroup *playlistwin_accel; | |
100 | |
101 static gboolean playlistwin_hint_flag = FALSE; | |
102 | |
103 static PlaylistSlider *playlistwin_slider = NULL; | |
104 static TextBox *playlistwin_time_min, *playlistwin_time_sec; | |
105 static TextBox *playlistwin_info, *playlistwin_sinfo; | |
106 static SButton *playlistwin_srew, *playlistwin_splay; | |
107 static SButton *playlistwin_spause, *playlistwin_sstop; | |
108 static SButton *playlistwin_sfwd, *playlistwin_seject; | |
109 static SButton *playlistwin_sscroll_up, *playlistwin_sscroll_down; | |
110 | |
111 static GList *playlistwin_wlist = NULL; | |
112 | |
113 static void plsort_menu_callback(gpointer cb_data, guint action, | |
114 GtkWidget * w); | |
115 static void playlistwin_sub_menu_callback(gpointer cb_data, guint action, | |
116 GtkWidget * w); | |
117 static void playlistwin_popup_menu_callback(gpointer cb_data, guint action, | |
118 GtkWidget * w); | |
119 | |
2144
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
120 static void playlistwin_select_search_cbt_cb( GtkWidget *called_cbt , |
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
121 gpointer other_cbt ); |
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
122 |
1653 | 123 static GtkItemFactoryEntry playlistwin_popup_menu_entries[] = { |
124 {N_("/View Track Details"), NULL, | |
125 playlistwin_popup_menu_callback, | |
126 MISC_FILEINFO, "<ImageItem>", my_pixbuf}, | |
127 | |
128 {N_("/Show Popup Info"), NULL, | |
129 playlistwin_popup_menu_callback, | |
130 MISC_FILEPOPUP, "<ToggleItem>", NULL}, | |
131 | |
132 ITEM_SEPARATOR, | |
133 | |
134 {N_("/Remove Selected"), "Delete", | |
135 playlistwin_sub_menu_callback, | |
136 SUB_SELECTED, "<StockItem>", GTK_STOCK_REMOVE}, | |
137 | |
138 {N_("/Remove Unselected"), NULL, | |
139 playlistwin_sub_menu_callback, | |
140 SUB_CROP, "<StockItem>", GTK_STOCK_REMOVE}, | |
141 | |
142 {N_("/Remove All"), NULL, | |
143 playlistwin_sub_menu_callback, | |
144 SUB_ALL, "<StockItem>", GTK_STOCK_CLEAR}, | |
145 | |
146 ITEM_SEPARATOR, | |
147 | |
148 {N_("/Queue Toggle"), "q", | |
149 playlistwin_popup_menu_callback, | |
150 MISC_QUEUE, "<ImageItem>", queuetoggle_pixbuf}, | |
151 }; | |
152 | |
153 static GtkItemFactoryEntry pladd_menu_entries[] = { | |
154 {N_("/Add CD..."), "<shift>c", | |
155 mainwin_general_menu_callback, | |
156 MAINWIN_GENERAL_ADDCD, "<StockItem>", GTK_STOCK_CDROM}, | |
157 | |
158 {N_("/Add Internet Address..."), "<control>h", | |
159 mainwin_general_menu_callback, | |
160 MAINWIN_GENERAL_PLAYLOCATION, "<StockItem>", GTK_STOCK_NETWORK}, | |
161 | |
162 {N_("/Add Files..."), "f", | |
163 mainwin_general_menu_callback, | |
164 MAINWIN_GENERAL_PLAYFILE, "<StockItem>", GTK_STOCK_ADD}, | |
165 }; | |
166 | |
167 static GtkItemFactoryEntry pldel_menu_entries[] = { | |
168 {N_("/Clear Queue"), "<shift>Q", | |
169 playlistwin_popup_menu_callback, | |
170 PLIST_CQUEUE, "<StockItem>", GTK_STOCK_CANCEL}, | |
171 | |
172 ITEM_SEPARATOR, | |
173 | |
174 {N_("/Remove Unavailable Files"), NULL, | |
175 playlistwin_sub_menu_callback, | |
176 PLAYLISTWIN_REMOVE_DEAD_FILES, "<ImageItem>", removeunavail_pixbuf}, | |
177 | |
178 {N_("/Remove Duplicates"), NULL, NULL, 0, "<Branch>", NULL}, | |
179 {N_("/Remove Duplicates/By Title"), NULL, | |
180 playlistwin_sub_menu_callback, | |
181 SUB_DUPLICATE_BYTITLE, "<ImageItem>", removedups_pixbuf}, | |
182 {N_("/Remove Duplicates/By Filename"), NULL, | |
183 playlistwin_sub_menu_callback, | |
184 SUB_DUPLICATE_BYFILENAME, "<ImageItem>", removedups_pixbuf}, | |
185 {N_("/Remove Duplicates/By Path + Filename"), NULL, | |
186 playlistwin_sub_menu_callback, | |
187 SUB_DUPLICATE_BYPATH, "<ImageItem>", removedups_pixbuf}, | |
188 | |
189 ITEM_SEPARATOR, | |
190 | |
191 {N_("/Remove All"), NULL, | |
192 playlistwin_sub_menu_callback, | |
193 SUB_ALL, "<StockItem>", GTK_STOCK_CLEAR}, | |
194 | |
195 {N_("/Remove Unselected"), NULL, | |
196 playlistwin_sub_menu_callback, | |
197 SUB_CROP, "<StockItem>", GTK_STOCK_REMOVE}, | |
198 | |
199 {N_("/Remove Selected"), "Delete", | |
200 playlistwin_sub_menu_callback, | |
201 SUB_SELECTED, "<StockItem>", GTK_STOCK_REMOVE} | |
202 }; | |
203 | |
204 static GtkItemFactoryEntry pllist_menu_entries[] = { | |
205 {N_("/New List"), "<shift>N", | |
206 playlistwin_sub_menu_callback, | |
207 PLIST_NEW, "<StockItem>", GTK_STOCK_NEW}, | |
208 | |
209 ITEM_SEPARATOR, | |
210 | |
211 {N_("/Load List"), "o", | |
212 playlistwin_sub_menu_callback, | |
213 PLIST_LOAD, "<StockItem>", GTK_STOCK_OPEN}, | |
214 | |
215 {N_("/Save List"), "<shift>S", | |
216 playlistwin_sub_menu_callback, | |
217 PLIST_SAVE, "<StockItem>", GTK_STOCK_SAVE}, | |
218 | |
219 {N_("/Save Default List"), "<alt>S", | |
220 playlistwin_sub_menu_callback, | |
221 PLIST_DEFAULTSAVE, "<StockItem>", GTK_STOCK_SAVE}, | |
222 | |
223 ITEM_SEPARATOR, | |
224 | |
225 {N_("/Update View"), "F5", | |
226 playlistwin_sub_menu_callback, | |
227 PLAYLISTWIN_REFRESH, "<StockItem>", GTK_STOCK_REFRESH} | |
228 }; | |
229 | |
230 static GtkItemFactoryEntry plsel_menu_entries[] = { | |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
231 {N_("/Search and Select"), NULL, |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
232 playlistwin_sub_menu_callback, |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
233 SEL_SEARCH, "<StockItem>", GTK_STOCK_FIND}, |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
234 |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
235 ITEM_SEPARATOR, |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
236 |
1653 | 237 {N_("/Invert Selection"), NULL, |
238 playlistwin_sub_menu_callback, | |
239 SEL_INV, "<ImageItem>", selectinvert_pixbuf}, | |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
240 |
1653 | 241 ITEM_SEPARATOR, |
242 | |
243 {N_("/Select None"),"<Ctrl><Shift>A", | |
244 playlistwin_sub_menu_callback, | |
245 SEL_ZERO, "<ImageItem>", selectnone_pixbuf}, | |
246 | |
247 {N_("/Select All"), "<Ctrl>A", | |
248 playlistwin_sub_menu_callback, | |
249 SEL_ALL, "<ImageItem>", selectall_pixbuf}, | |
250 }; | |
251 | |
252 static GtkItemFactoryEntry plsort_menu_entries[] = { | |
1934
886b479afe63
[svn] - assign Control+Shift+R keybinding. to Randomize Playlist. Closes #529
nenolod
parents:
1825
diff
changeset
|
253 {N_("/Randomize List"), "<Ctrl><Shift>R", plsort_menu_callback, |
1653 | 254 PLAYLISTWIN_SORT_RANDOMIZE, "<ImageItem>", randomizepl_pixbuf}, |
255 {N_("/Reverse List"), NULL, plsort_menu_callback, | |
256 PLAYLISTWIN_SORT_REVERSE, "<ImageItem>", invertpl_pixbuf}, | |
257 ITEM_SEPARATOR, | |
258 {N_("/Sort List"), NULL, NULL, 0, "<Branch>", NULL}, | |
259 {N_("/Sort List/By Title"), NULL, plsort_menu_callback, | |
260 PLAYLISTWIN_SORT_BYTITLE, "<ImageItem>", sortbytitle_pixbuf}, | |
261 {N_("/Sort List/By Artist"), NULL, plsort_menu_callback, | |
262 PLAYLISTWIN_SORT_BYARTIST, "<ImageItem>", sortbytitle_pixbuf}, | |
263 {N_("/Sort List/By Filename"), NULL, plsort_menu_callback, | |
264 PLAYLISTWIN_SORT_BYFILENAME, "<ImageItem>", sortbyfilename_pixbuf}, | |
265 {N_("/Sort List/By Path + Filename"), NULL, plsort_menu_callback, | |
266 PLAYLISTWIN_SORT_BYPATH, "<ImageItem>", sortbypathfile_pixbuf}, | |
267 {N_("/Sort List/By Date"), NULL, plsort_menu_callback, | |
268 PLAYLISTWIN_SORT_BYDATE, "<ImageItem>", sortbydate_pixbuf}, | |
269 {N_("/Sort List/By Track Number"), NULL, plsort_menu_callback, | |
270 PLAYLISTWIN_SORT_BYTRACK, "<ImageItem>", sortbytitle_pixbuf}, | |
271 {N_("/Sort List/By Playlist Entry"), NULL, plsort_menu_callback, | |
272 PLAYLISTWIN_SORT_BYPLAYLIST, "<ImageItem>", sortbytitle_pixbuf}, | |
273 {N_("/Sort Selection"), NULL, NULL, 0, "<Branch>", NULL}, | |
274 {N_("/Sort Selection/By Title"), NULL, plsort_menu_callback, | |
275 PLAYLISTWIN_SORT_SEL_BYTITLE, "<ImageItem>", sortbytitle_pixbuf}, | |
276 {N_("/Sort Selection/By Artist"), NULL, plsort_menu_callback, | |
277 PLAYLISTWIN_SORT_SEL_BYARTIST, "<ImageItem>", sortbytitle_pixbuf}, | |
278 {N_("/Sort Selection/By Filename"), NULL, plsort_menu_callback, | |
279 PLAYLISTWIN_SORT_SEL_BYFILENAME, "<ImageItem>", sortbyfilename_pixbuf}, | |
280 {N_("/Sort Selection/By Path + Filename"), NULL, plsort_menu_callback, | |
281 PLAYLISTWIN_SORT_SEL_BYPATH, "<ImageItem>", sortbypathfile_pixbuf}, | |
282 {N_("/Sort Selection/By Date"), NULL, plsort_menu_callback, | |
283 PLAYLISTWIN_SORT_SEL_BYDATE, "<ImageItem>", sortbydate_pixbuf}, | |
284 {N_("/Sort Selection/By Track Number"), NULL, plsort_menu_callback, | |
285 PLAYLISTWIN_SORT_SEL_BYTRACK, "<ImageItem>", sortbytitle_pixbuf}, | |
286 {N_("/Sort Selection/By Playlist Entry"), NULL, plsort_menu_callback, | |
287 PLAYLISTWIN_SORT_SEL_BYPLAYLIST, "<ImageItem>", sortbytitle_pixbuf} | |
288 }; | |
289 | |
290 | |
291 static void playlistwin_draw_frame(void); | |
292 | |
293 | |
294 gboolean | |
295 playlistwin_is_shaded(void) | |
296 { | |
297 return cfg.playlist_shaded; | |
298 } | |
299 | |
300 gint | |
301 playlistwin_get_width(void) | |
302 { | |
303 cfg.playlist_width /= PLAYLISTWIN_WIDTH_SNAP; | |
304 cfg.playlist_width *= PLAYLISTWIN_WIDTH_SNAP; | |
305 return cfg.playlist_width; | |
306 } | |
307 | |
308 gint | |
309 playlistwin_get_height_unshaded(void) | |
310 { | |
2055 | 311 gint height; |
1653 | 312 cfg.playlist_height /= PLAYLISTWIN_HEIGHT_SNAP; |
313 cfg.playlist_height *= PLAYLISTWIN_HEIGHT_SNAP; | |
2055 | 314 height = cfg.playlist_height; |
1653 | 315 return height; |
316 } | |
317 | |
318 gint | |
319 playlistwin_get_height_shaded(void) | |
320 { | |
321 return PLAYLISTWIN_SHADED_HEIGHT; | |
322 } | |
323 | |
324 gint | |
325 playlistwin_get_height(void) | |
326 { | |
327 if (playlistwin_is_shaded()) | |
328 return playlistwin_get_height_shaded(); | |
329 else | |
330 return playlistwin_get_height_unshaded(); | |
331 } | |
332 | |
333 void | |
334 playlistwin_get_size(gint * width, gint * height) | |
335 { | |
336 if (width) | |
337 *width = playlistwin_get_width(); | |
338 | |
339 if (height) | |
340 *height = playlistwin_get_height(); | |
341 } | |
342 | |
343 static void | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
344 playlistwin_update_info(Playlist *playlist) |
1653 | 345 { |
346 gchar *text, *sel_text, *tot_text; | |
347 gulong selection, total; | |
348 gboolean selection_more, total_more; | |
349 | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
350 playlist_get_total_time(playlist, &total, &selection, &total_more, &selection_more); |
1653 | 351 |
352 if (selection > 0 || (selection == 0 && !selection_more)) { | |
353 if (selection > 3600) | |
354 sel_text = | |
355 g_strdup_printf("%lu:%-2.2lu:%-2.2lu%s", selection / 3600, | |
356 (selection / 60) % 60, selection % 60, | |
357 (selection_more ? "+" : "")); | |
358 else | |
359 sel_text = | |
360 g_strdup_printf("%lu:%-2.2lu%s", selection / 60, | |
361 selection % 60, (selection_more ? "+" : "")); | |
362 } | |
363 else | |
364 sel_text = g_strdup("?"); | |
365 if (total > 0 || (total == 0 && !total_more)) { | |
366 if (total > 3600) | |
367 tot_text = | |
368 g_strdup_printf("%lu:%-2.2lu:%-2.2lu%s", total / 3600, | |
369 (total / 60) % 60, total % 60, | |
370 total_more ? "+" : ""); | |
371 else | |
372 tot_text = | |
373 g_strdup_printf("%lu:%-2.2lu%s", total / 60, total % 60, | |
374 total_more ? "+" : ""); | |
375 } | |
376 else | |
377 tot_text = g_strdup("?"); | |
378 text = g_strconcat(sel_text, "/", tot_text, NULL); | |
1775 | 379 textbox_set_text(playlistwin_info, text ? text : ""); |
1653 | 380 g_free(text); |
381 g_free(tot_text); | |
382 g_free(sel_text); | |
383 } | |
384 | |
385 static void | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
386 playlistwin_update_sinfo(Playlist *playlist) |
1653 | 387 { |
1775 | 388 gchar *posstr, *timestr, *title, *info; |
1653 | 389 gint pos, time; |
390 | |
2095 | 391 pos = playlist_get_position(playlist); |
392 title = playlist_get_songtitle(playlist, pos); | |
1653 | 393 |
394 if (!title) { | |
395 textbox_set_text(playlistwin_sinfo, ""); | |
396 return; | |
397 } | |
398 | |
1775 | 399 convert_title_text(title); |
400 | |
2095 | 401 time = playlist_get_songtime(playlist, pos); |
1775 | 402 |
1653 | 403 if (cfg.show_numbers_in_pl) |
404 posstr = g_strdup_printf("%d. ", pos + 1); | |
405 else | |
406 posstr = g_strdup(""); | |
407 | |
408 if (time != -1) { | |
1800
61f531908dd0
[svn] - Put ()'s around the time in the shaded playlist text.
nhjm449
parents:
1775
diff
changeset
|
409 timestr = g_strdup_printf(" (%d:%-2.2d)", time / 60000, |
1775 | 410 (time / 1000) % 60); |
1653 | 411 } |
412 else | |
413 timestr = g_strdup(""); | |
414 | |
1775 | 415 info = g_strdup_printf("%s%s%s", posstr, title, timestr); |
1653 | 416 |
417 g_free(posstr); | |
418 g_free(title); | |
419 g_free(timestr); | |
420 | |
1775 | 421 textbox_set_text(playlistwin_sinfo, info ? info : ""); |
1653 | 422 g_free(info); |
423 } | |
424 | |
425 gboolean | |
426 playlistwin_item_visible(gint index) | |
427 { | |
428 if (index >= playlistwin_list->pl_first | |
429 && index < | |
430 (playlistwin_list->pl_first + playlistwin_list->pl_num_visible)) | |
431 return TRUE; | |
432 return FALSE; | |
433 } | |
434 | |
435 gint | |
436 playlistwin_get_toprow(void) | |
437 { | |
438 if (playlistwin_list) | |
439 return (playlistwin_list->pl_first); | |
440 return (-1); | |
441 } | |
442 | |
443 void | |
444 playlistwin_set_toprow(gint toprow) | |
445 { | |
446 if (playlistwin_list) | |
447 playlistwin_list->pl_first = toprow; | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
448 playlistwin_update_list(playlist_get_active()); |
1653 | 449 } |
450 | |
451 void | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
452 playlistwin_update_list(Playlist *playlist) |
1653 | 453 { |
454 g_return_if_fail(playlistwin_list != NULL); | |
455 | |
456 widget_draw(WIDGET(playlistwin_list)); | |
457 widget_draw(WIDGET(playlistwin_slider)); | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
458 playlistwin_update_info(playlist); |
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
459 playlistwin_update_sinfo(playlist); |
1653 | 460 /* mainwin_update_jtf(); */ |
461 } | |
462 | |
463 #if 0 | |
464 static void | |
465 playlistwin_redraw_list(void) | |
466 { | |
467 g_return_if_fail(playlistwin_list != NULL); | |
468 | |
469 draw_widget(playlistwin_list); | |
470 draw_widget(playlistwin_slider); | |
471 } | |
472 #endif | |
473 | |
474 static void | |
475 playlistwin_set_mask(void) | |
476 { | |
477 GdkGC *gc; | |
478 GdkColor pattern; | |
479 | |
480 if (playlistwin_mask) | |
481 g_object_unref(playlistwin_mask); | |
482 | |
483 playlistwin_mask = | |
484 gdk_pixmap_new(playlistwin->window, playlistwin_get_width(), | |
485 playlistwin_get_height(), 1); | |
486 gc = gdk_gc_new(playlistwin_mask); | |
487 pattern.pixel = 1; | |
488 gdk_gc_set_foreground(gc, &pattern); | |
489 gdk_draw_rectangle(playlistwin_mask, gc, TRUE, 0, 0, | |
490 playlistwin_get_width(), playlistwin_get_height()); | |
491 gdk_gc_destroy(gc); | |
492 | |
493 gtk_widget_shape_combine_mask(playlistwin, playlistwin_mask, 0, 0); | |
494 } | |
495 | |
496 static void | |
497 playlistwin_set_geometry_hints(gboolean shaded) | |
498 { | |
499 GdkGeometry geometry; | |
500 GdkWindowHints mask; | |
501 | |
502 geometry.min_width = PLAYLISTWIN_MIN_WIDTH; | |
503 geometry.max_width = G_MAXUINT16; | |
504 | |
505 geometry.width_inc = PLAYLISTWIN_WIDTH_SNAP; | |
506 geometry.height_inc = PLAYLISTWIN_HEIGHT_SNAP; | |
507 | |
508 if (shaded) { | |
509 geometry.min_height = PLAYLISTWIN_SHADED_HEIGHT; | |
510 geometry.max_height = PLAYLISTWIN_SHADED_HEIGHT; | |
511 geometry.base_height = PLAYLISTWIN_SHADED_HEIGHT; | |
512 } | |
513 else { | |
514 geometry.min_height = PLAYLISTWIN_MIN_HEIGHT; | |
515 geometry.max_height = G_MAXUINT16; | |
516 } | |
517 | |
518 mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_RESIZE_INC; | |
519 | |
520 gtk_window_set_geometry_hints(GTK_WINDOW(playlistwin), | |
521 playlistwin, &geometry, mask); | |
522 } | |
523 | |
524 void | |
1775 | 525 playlistwin_set_sinfo_font(gchar *font) |
526 { | |
527 gchar *tmp = NULL, *tmp2 = NULL; | |
528 | |
529 if(!font) | |
530 return; | |
531 | |
532 tmp = g_strdup(font); | |
533 if(!tmp) | |
534 return; | |
535 | |
536 *strrchr(tmp, ' ') = '\0'; | |
537 tmp2 = g_strdup_printf("%s 8", tmp); | |
538 if(!tmp2) | |
539 return; | |
540 textbox_set_xfont(playlistwin_sinfo, cfg.mainwin_use_xfont, tmp2); | |
541 | |
542 g_free(tmp); g_free(tmp2); | |
543 } | |
544 | |
545 void | |
546 playlistwin_set_sinfo_scroll(gboolean scroll) | |
547 { | |
548 GtkWidget *item; | |
549 | |
550 if(playlistwin_is_shaded()) | |
551 textbox_set_scroll(playlistwin_sinfo, cfg.autoscroll); | |
552 else | |
553 textbox_set_scroll(playlistwin_sinfo, FALSE); | |
554 } | |
555 | |
556 void | |
1653 | 557 playlistwin_set_shade(gboolean shaded) |
558 { | |
559 cfg.playlist_shaded = shaded; | |
560 | |
561 if (shaded) { | |
1775 | 562 playlistwin_set_sinfo_font(cfg.playlist_font); |
563 playlistwin_set_sinfo_scroll(cfg.autoscroll); | |
1653 | 564 widget_show(WIDGET(playlistwin_sinfo)); |
565 playlistwin_shade->pb_nx = 128; | |
566 playlistwin_shade->pb_ny = 45; | |
567 playlistwin_shade->pb_px = 150; | |
568 playlistwin_shade->pb_py = 42; | |
569 playlistwin_close->pb_nx = 138; | |
570 playlistwin_close->pb_ny = 45; | |
571 } | |
572 else { | |
573 widget_hide(WIDGET(playlistwin_sinfo)); | |
1775 | 574 playlistwin_set_sinfo_scroll(FALSE); |
1653 | 575 playlistwin_shade->pb_nx = 157; |
576 playlistwin_shade->pb_ny = 3; | |
577 playlistwin_shade->pb_px = 62; | |
578 playlistwin_shade->pb_py = 42; | |
579 playlistwin_close->pb_nx = 167; | |
580 playlistwin_close->pb_ny = 3; | |
581 } | |
582 | |
583 dock_shade(dock_window_list, GTK_WINDOW(playlistwin), | |
584 playlistwin_get_height()); | |
585 | |
586 playlistwin_set_geometry_hints(cfg.playlist_shaded); | |
587 | |
588 gtk_window_resize(GTK_WINDOW(playlistwin), | |
589 playlistwin_get_width(), | |
590 playlistwin_get_height()); | |
591 | |
592 playlistwin_set_mask(); | |
593 | |
594 widget_draw(WIDGET(playlistwin_list)); | |
595 widget_draw(WIDGET(playlistwin_slider)); | |
596 | |
597 draw_playlist_window(TRUE); | |
598 } | |
599 | |
600 static void | |
601 playlistwin_set_shade_menu(gboolean shaded) | |
602 { | |
603 GtkWidget *item; | |
604 | |
605 item = gtk_item_factory_get_widget(mainwin_view_menu, | |
606 "/Roll up Playlist Editor"); | |
607 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), shaded); | |
608 | |
609 playlistwin_set_shade(shaded); | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
610 playlistwin_update_list(playlist_get_active()); |
1653 | 611 } |
612 | |
613 void | |
614 playlistwin_shade_toggle(void) | |
615 { | |
616 playlistwin_set_shade_menu(!cfg.playlist_shaded); | |
617 } | |
618 | |
619 static void | |
620 playlistwin_release(GtkWidget * widget, | |
621 GdkEventButton * event, | |
622 gpointer callback_data) | |
623 { | |
624 if (event->button == 3) | |
625 return; | |
626 | |
627 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
628 playlistwin_resizing = FALSE; | |
629 gdk_flush(); | |
630 | |
631 if (dock_is_moving(GTK_WINDOW(playlistwin))) | |
632 { | |
633 dock_move_release(GTK_WINDOW(playlistwin)); | |
634 | |
635 if (cfg.playlist_transparent) | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
636 playlistwin_update_list(playlist_get_active()); |
1653 | 637 } |
638 else | |
639 { | |
640 handle_release_cb(playlistwin_wlist, widget, event); | |
641 draw_playlist_window(FALSE); | |
642 } | |
643 } | |
644 | |
645 void | |
646 playlistwin_scroll(gint num) | |
647 { | |
648 playlistwin_list->pl_first += num; | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
649 playlistwin_update_list(playlist_get_active()); |
1653 | 650 } |
651 | |
652 void | |
653 playlistwin_scroll_up_pushed(void) | |
654 { | |
2026 | 655 playlistwin_scroll(-3); |
1653 | 656 } |
657 | |
658 void | |
659 playlistwin_scroll_down_pushed(void) | |
660 { | |
2026 | 661 playlistwin_scroll(3); |
1653 | 662 } |
663 | |
664 static void | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
665 playlistwin_select_all(void) |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
666 { |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
667 Playlist *playlist = playlist_get_active(); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
668 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
669 playlist_select_all(playlist, TRUE); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
670 playlistwin_list->pl_prev_selected = 0; |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
671 playlistwin_list->pl_prev_min = 0; |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
672 playlistwin_list->pl_prev_max = playlist_get_length(playlist) - 1; |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
673 playlistwin_update_list(playlist); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
674 } |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
675 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
676 static void |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
677 playlistwin_select_none(void) |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
678 { |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
679 playlist_select_all(playlist_get_active(), FALSE); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
680 playlistwin_list->pl_prev_selected = -1; |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
681 playlistwin_list->pl_prev_min = -1; |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
682 playlistwin_update_list(playlist_get_active()); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
683 } |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
684 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
685 static void |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
686 playlistwin_select_search(void) |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
687 { |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
688 Playlist *playlist = playlist_get_active(); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
689 GtkWidget *searchdlg_win, *searchdlg_table; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
690 GtkWidget *searchdlg_hbox, *searchdlg_logo, *searchdlg_helptext; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
691 GtkWidget *searchdlg_entry_track_name, *searchdlg_label_track_name; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
692 GtkWidget *searchdlg_entry_album_name, *searchdlg_label_album_name; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
693 GtkWidget *searchdlg_entry_file_name, *searchdlg_label_file_name; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
694 GtkWidget *searchdlg_entry_performer, *searchdlg_label_performer; |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
695 GtkWidget *searchdlg_checkbt_clearprevsel; |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
696 GtkWidget *searchdlg_checkbt_newplaylist; |
2144
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
697 GtkWidget *searchdlg_checkbt_autoenqueue; |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
698 gint result; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
699 |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
700 /* create dialog */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
701 searchdlg_win = gtk_dialog_new_with_buttons( |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
702 "Search entries in active playlist" , GTK_WINDOW(mainwin) , |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
703 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT , |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
704 GTK_STOCK_CANCEL , GTK_RESPONSE_REJECT , GTK_STOCK_OK , GTK_RESPONSE_ACCEPT , NULL ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
705 /* help text and logo */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
706 searchdlg_hbox = gtk_hbox_new( FALSE , 4 ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
707 searchdlg_logo = gtk_image_new_from_stock( GTK_STOCK_FIND , GTK_ICON_SIZE_DIALOG ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
708 searchdlg_helptext = gtk_label_new( _("Select entries in playlist by filling one or more " |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
709 "fields. Fields use regular expressions syntax, case-insensitive. If you don't know how " |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
710 "regular expressions work, simply insert a literal portion of what you're searching for.") ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
711 gtk_label_set_line_wrap( GTK_LABEL(searchdlg_helptext) , TRUE ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
712 gtk_box_pack_start( GTK_BOX(searchdlg_hbox) , searchdlg_logo , FALSE , FALSE , 0 ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
713 gtk_box_pack_start( GTK_BOX(searchdlg_hbox) , searchdlg_helptext , FALSE , FALSE , 0 ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
714 /* track name */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
715 searchdlg_label_track_name = gtk_label_new( _("Track name: ") ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
716 searchdlg_entry_track_name = gtk_entry_new(); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
717 gtk_misc_set_alignment( GTK_MISC(searchdlg_label_track_name) , 0 , 0.5 ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
718 /* album name */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
719 searchdlg_label_album_name = gtk_label_new( _("Album name: ") ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
720 searchdlg_entry_album_name = gtk_entry_new(); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
721 gtk_misc_set_alignment( GTK_MISC(searchdlg_label_album_name) , 0 , 0.5 ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
722 /* artist */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
723 searchdlg_label_performer = gtk_label_new( _("Artist: ") ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
724 searchdlg_entry_performer = gtk_entry_new(); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
725 gtk_misc_set_alignment( GTK_MISC(searchdlg_label_performer) , 0 , 0.5 ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
726 /* file name */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
727 searchdlg_label_file_name = gtk_label_new( _("Filename: ") ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
728 searchdlg_entry_file_name = gtk_entry_new(); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
729 gtk_misc_set_alignment( GTK_MISC(searchdlg_label_file_name) , 0 , 0.5 ); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
730 /* some options that control behaviour */ |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
731 searchdlg_checkbt_clearprevsel = gtk_check_button_new_with_label( |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
732 _("Clear previous selection before searching") ); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
733 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(searchdlg_checkbt_clearprevsel) , TRUE ); |
2144
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
734 searchdlg_checkbt_autoenqueue = gtk_check_button_new_with_label( |
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
735 _("Automatically toggle queue for matching entries") ); |
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
736 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(searchdlg_checkbt_autoenqueue) , FALSE ); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
737 searchdlg_checkbt_newplaylist = gtk_check_button_new_with_label( |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
738 _("Create a new playlist with matching entries") ); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
739 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(searchdlg_checkbt_newplaylist) , FALSE ); |
2144
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
740 g_signal_connect( G_OBJECT(searchdlg_checkbt_autoenqueue) , "clicked" , |
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
741 G_CALLBACK(playlistwin_select_search_cbt_cb) , searchdlg_checkbt_newplaylist ); |
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
742 g_signal_connect( G_OBJECT(searchdlg_checkbt_newplaylist) , "clicked" , |
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
743 G_CALLBACK(playlistwin_select_search_cbt_cb) , searchdlg_checkbt_autoenqueue ); |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
744 /* place fields in searchdlg_table */ |
2144
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
745 searchdlg_table = gtk_table_new( 8 , 2 , FALSE ); |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
746 gtk_table_set_row_spacing( GTK_TABLE(searchdlg_table) , 0 , 8 ); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
747 gtk_table_set_row_spacing( GTK_TABLE(searchdlg_table) , 4 , 8 ); |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
748 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_hbox , |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
749 0 , 2 , 0 , 1 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
750 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_label_track_name , |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
751 0 , 1 , 1 , 2 , GTK_FILL , GTK_FILL | GTK_EXPAND , 0 , 2 ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
752 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_entry_track_name , |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
753 1 , 2 , 1 , 2 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
754 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_label_album_name , |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
755 0 , 1 , 2 , 3 , GTK_FILL , GTK_FILL | GTK_EXPAND , 0 , 2 ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
756 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_entry_album_name , |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
757 1 , 2 , 2 , 3 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
758 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_label_performer , |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
759 0 , 1 , 3 , 4 , GTK_FILL , GTK_FILL | GTK_EXPAND , 0 , 2 ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
760 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_entry_performer , |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
761 1 , 2 , 3 , 4 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
762 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_label_file_name , |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
763 0 , 1 , 4 , 5 , GTK_FILL , GTK_FILL | GTK_EXPAND , 0 , 2 ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
764 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_entry_file_name , |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
765 1 , 2 , 4 , 5 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 ); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
766 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_checkbt_clearprevsel , |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
767 0 , 2 , 5 , 6 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 1 ); |
2144
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
768 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_checkbt_autoenqueue , |
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
769 0 , 2 , 6 , 7 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 1 ); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
770 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_checkbt_newplaylist , |
2144
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
771 0 , 2 , 7 , 8 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 1 ); |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
772 |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
773 gtk_container_set_border_width( GTK_CONTAINER(searchdlg_table) , 5 ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
774 gtk_container_add( GTK_CONTAINER(GTK_DIALOG(searchdlg_win)->vbox) , searchdlg_table ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
775 gtk_widget_show_all( searchdlg_win ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
776 result = gtk_dialog_run( GTK_DIALOG(searchdlg_win) ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
777 switch(result) |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
778 { |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
779 case GTK_RESPONSE_ACCEPT: |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
780 { |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
781 gint matched_entries_num = 0; |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
782 /* create a TitleInput tuple with user search data */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
783 TitleInput *tuple = g_malloc(sizeof(TitleInput)); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
784 gchar *searchdata = NULL; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
785 searchdata = (gchar*)gtk_entry_get_text( GTK_ENTRY(searchdlg_entry_track_name) ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
786 tuple->track_name = ( strcmp(searchdata,"") ) ? g_strdup(searchdata) : NULL; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
787 searchdata = (gchar*)gtk_entry_get_text( GTK_ENTRY(searchdlg_entry_album_name) ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
788 tuple->album_name = ( strcmp(searchdata,"") ) ? g_strdup(searchdata) : NULL; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
789 searchdata = (gchar*)gtk_entry_get_text( GTK_ENTRY(searchdlg_entry_performer) ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
790 tuple->performer = ( strcmp(searchdata,"") ) ? g_strdup(searchdata) : NULL; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
791 searchdata = (gchar*)gtk_entry_get_text( GTK_ENTRY(searchdlg_entry_file_name) ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
792 tuple->file_name = ( strcmp(searchdata,"") ) ? g_strdup(searchdata) : NULL; |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
793 /* check if previous selection should be cleared before searching */ |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
794 if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(searchdlg_checkbt_clearprevsel)) == TRUE ) |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
795 playlistwin_select_none(); |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
796 /* now send this tuple to the real search function */ |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
797 matched_entries_num = playlist_select_search( playlist , tuple , 0 ); |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
798 /* we do not need the tuple and its data anymore */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
799 if ( tuple->track_name != NULL ) g_free( tuple->track_name ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
800 if ( tuple->album_name != NULL ) g_free( tuple->album_name ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
801 if ( tuple->performer != NULL ) g_free( tuple->performer ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
802 if ( tuple->file_name != NULL ) g_free( tuple->file_name ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
803 g_free( tuple ); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
804 playlistwin_update_list(playlist_get_active()); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
805 /* check if a new playlist should be created after searching */ |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
806 if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(searchdlg_checkbt_newplaylist)) == TRUE ) |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2129
diff
changeset
|
807 playlist_new_from_selected(); |
2144
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
808 /* check if matched entries should be queued */ |
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
809 else if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(searchdlg_checkbt_autoenqueue)) == TRUE ) |
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
810 playlist_queue(playlist_get_active()); |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
811 break; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
812 } |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
813 default: |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
814 break; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
815 } |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
816 /* done here :) */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
817 gtk_widget_destroy( searchdlg_win ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
818 } |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
819 |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
820 static void |
1653 | 821 playlistwin_inverse_selection(void) |
822 { | |
2095 | 823 playlist_select_invert_all(playlist_get_active()); |
1653 | 824 playlistwin_list->pl_prev_selected = -1; |
825 playlistwin_list->pl_prev_min = -1; | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
826 playlistwin_update_list(playlist_get_active()); |
1653 | 827 } |
828 | |
829 static void | |
830 playlistwin_resize(gint width, gint height) | |
831 { | |
832 gboolean redraw; | |
833 | |
834 g_return_if_fail(width > 0 && height > 0); | |
835 | |
836 cfg.playlist_width = width; | |
837 | |
838 if (!cfg.playlist_shaded) | |
839 cfg.playlist_height = height; | |
840 else | |
841 height = cfg.playlist_height; | |
842 | |
843 /* FIXME: why the fsck are we doing this manually? */ | |
844 /* adjust widget positions and sizes */ | |
845 | |
846 widget_resize(WIDGET(playlistwin_list), width - 31, height - 58); | |
847 | |
848 widget_move(WIDGET(playlistwin_slider), width - 15, 20); | |
849 widget_resize(WIDGET(playlistwin_slider), 8, height - 58); | |
850 | |
851 widget_resize(WIDGET(playlistwin_sinfo), width - 35, 14); | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
852 playlistwin_update_sinfo(playlist_get_active()); |
1653 | 853 |
854 widget_move(WIDGET(playlistwin_shade), width - 21, 3); | |
855 widget_move(WIDGET(playlistwin_close), width - 11, 3); | |
856 widget_move(WIDGET(playlistwin_time_min), width - 82, height - 15); | |
857 widget_move(WIDGET(playlistwin_time_sec), width - 64, height - 15); | |
858 widget_move(WIDGET(playlistwin_info), width - 143, height - 28); | |
859 widget_move(WIDGET(playlistwin_srew), width - 144, height - 16); | |
860 widget_move(WIDGET(playlistwin_splay), width - 138, height - 16); | |
861 widget_move(WIDGET(playlistwin_spause), width - 128, height - 16); | |
862 widget_move(WIDGET(playlistwin_sstop), width - 118, height - 16); | |
863 widget_move(WIDGET(playlistwin_sfwd), width - 109, height - 16); | |
864 widget_move(WIDGET(playlistwin_seject), width - 100, height - 16); | |
865 widget_move(WIDGET(playlistwin_sscroll_up), width - 14, height - 35); | |
866 widget_move(WIDGET(playlistwin_sscroll_down), width - 14, height - 30); | |
867 | |
868 g_object_unref(playlistwin_bg); | |
869 playlistwin_bg = gdk_pixmap_new(playlistwin->window, width, height, -1); | |
870 playlistwin_set_mask(); | |
871 | |
872 widget_list_lock(playlistwin_wlist); | |
873 | |
874 widget_list_change_pixmap(playlistwin_wlist, playlistwin_bg); | |
875 playlistwin_draw_frame(); | |
876 widget_list_draw(playlistwin_wlist, &redraw, TRUE); | |
877 widget_list_clear_redraw(playlistwin_wlist); | |
878 | |
879 widget_list_unlock(playlistwin_wlist); | |
880 | |
881 gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0); | |
882 gdk_window_clear(playlistwin->window); | |
883 } | |
884 | |
885 | |
886 | |
887 static void | |
888 playlistwin_motion(GtkWidget * widget, | |
889 GdkEventMotion * event, | |
890 gpointer callback_data) | |
891 { | |
892 GdkEvent *gevent; | |
893 | |
894 if (dock_is_moving(GTK_WINDOW(playlistwin))) { | |
895 dock_move_motion(GTK_WINDOW(playlistwin), event); | |
896 } | |
897 else { | |
898 handle_motion_cb(playlistwin_wlist, widget, event); | |
899 draw_playlist_window(FALSE); | |
900 } | |
901 gdk_flush(); | |
902 | |
903 while ((gevent = gdk_event_get()) != NULL) gdk_event_free(gevent); | |
904 } | |
905 | |
906 static void | |
907 playlistwin_enter(GtkWidget * widget, | |
908 GdkEventMotion * event, | |
909 gpointer callback_data) | |
910 { | |
911 playlistwin_list->pl_tooltips = TRUE; | |
912 } | |
913 | |
914 static void | |
915 playlistwin_leave(GtkWidget * widget, | |
916 GdkEventMotion * event, | |
917 gpointer callback_data) | |
918 { | |
919 playlistwin_list->pl_tooltips = FALSE; | |
920 } | |
921 | |
922 static void | |
923 playlistwin_show_filebrowser(void) | |
924 { | |
925 util_run_filebrowser(NO_PLAY_BUTTON); | |
926 } | |
927 | |
928 #if 0 | |
929 static void | |
930 playlistwin_add_dir_handler(const gchar * dir) | |
931 { | |
932 g_free(cfg.filesel_path); | |
933 cfg.filesel_path = g_strdup(dir); | |
934 playlist_add_dir(dir); | |
935 } | |
936 #endif | |
937 | |
938 static void | |
939 playlistwin_fileinfo(void) | |
940 { | |
2095 | 941 Playlist *playlist = playlist_get_active(); |
942 | |
1653 | 943 /* Show the first selected file, or the current file if nothing is |
944 * selected */ | |
2095 | 945 GList *list = playlist_get_selected(playlist); |
1653 | 946 if (list) { |
2095 | 947 playlist_fileinfo(playlist, GPOINTER_TO_INT(list->data)); |
1653 | 948 g_list_free(list); |
949 } | |
950 else | |
2095 | 951 playlist_fileinfo_current(playlist); |
1653 | 952 } |
953 | |
954 static void | |
955 menu_set_item_sensitive(GtkItemFactory * item_factory, | |
956 const gchar * path, | |
957 gboolean sensitive) | |
958 { | |
959 GtkWidget *item = gtk_item_factory_get_widget(item_factory, path); | |
960 gtk_widget_set_sensitive(item, sensitive); | |
961 } | |
962 | |
963 /* FIXME: broken */ | |
964 static void | |
965 playlistwin_set_sensitive_sortmenu(void) | |
966 { | |
2095 | 967 gboolean set = playlist_get_num_selected(playlist_get_active()) > 1; |
1653 | 968 menu_set_item_sensitive(plsort_menu, "/Sort Selection/By Title", set); |
969 menu_set_item_sensitive(plsort_menu, "/Sort Selection/By Filename", set); | |
970 menu_set_item_sensitive(plsort_menu, "/Sort Selection/By Path + Filename", set); | |
971 menu_set_item_sensitive(plsort_menu, "/Sort Selection/By Date", set); | |
972 } | |
973 | |
974 static void | |
975 show_playlist_save_error(GtkWindow * parent, | |
976 const gchar * filename) | |
977 { | |
978 GtkWidget *dialog; | |
979 | |
980 g_return_if_fail(GTK_IS_WINDOW(parent)); | |
981 g_return_if_fail(filename != NULL); | |
982 | |
983 dialog = gtk_message_dialog_new(GTK_WINDOW(parent), | |
984 GTK_DIALOG_DESTROY_WITH_PARENT, | |
985 GTK_MESSAGE_ERROR, | |
986 GTK_BUTTONS_OK, | |
987 _("Error writing playlist \"%s\": %s"), | |
988 filename, strerror(errno)); | |
989 | |
990 gtk_dialog_run(GTK_DIALOG(dialog)); | |
991 gtk_widget_destroy(dialog); | |
992 } | |
993 | |
994 static gboolean | |
995 show_playlist_overwrite_prompt(GtkWindow * parent, | |
996 const gchar * filename) | |
997 { | |
998 GtkWidget *dialog; | |
999 gint result; | |
1000 | |
1001 g_return_val_if_fail(GTK_IS_WINDOW(parent), FALSE); | |
1002 g_return_val_if_fail(filename != NULL, FALSE); | |
1003 | |
1004 dialog = gtk_message_dialog_new(GTK_WINDOW(parent), | |
1005 GTK_DIALOG_DESTROY_WITH_PARENT, | |
1006 GTK_MESSAGE_QUESTION, | |
1007 GTK_BUTTONS_YES_NO, | |
1008 _("%s already exist. Continue?"), | |
1009 filename); | |
1010 | |
1011 result = gtk_dialog_run(GTK_DIALOG(dialog)); | |
1012 gtk_widget_destroy(dialog); | |
1013 | |
1014 return (result == GTK_RESPONSE_YES); | |
1015 } | |
1016 | |
1017 static void | |
1018 show_playlist_save_format_error(GtkWindow * parent, | |
1019 const gchar * filename) | |
1020 { | |
1021 const gchar *markup = | |
1022 N_("<b><big>Unable to save playlist.</big></b>\n\n" | |
1023 "Unknown file type for '%s'.\n"); | |
1024 | |
1025 GtkWidget *dialog; | |
1026 | |
1027 g_return_if_fail(GTK_IS_WINDOW(parent)); | |
1028 g_return_if_fail(filename != NULL); | |
1029 | |
1030 dialog = | |
1031 gtk_message_dialog_new_with_markup(GTK_WINDOW(parent), | |
1032 GTK_DIALOG_DESTROY_WITH_PARENT, | |
1033 GTK_MESSAGE_ERROR, | |
1034 GTK_BUTTONS_OK, | |
1035 _(markup), | |
1036 filename); | |
1037 gtk_dialog_run(GTK_DIALOG(dialog)); | |
1038 gtk_widget_destroy(dialog); | |
1039 } | |
1040 | |
1041 static void | |
1042 playlistwin_save_playlist(const gchar * filename) | |
1043 { | |
1044 PlaylistContainer *plc; | |
1045 gchar *ext = strrchr(filename, '.') + 1; | |
1046 | |
1047 plc = playlist_container_find(ext); | |
1048 if (plc == NULL) { | |
1049 show_playlist_save_format_error(GTK_WINDOW(playlistwin), filename); | |
1050 return; | |
1051 } | |
1052 | |
1053 str_replace_in(&cfg.playlist_path, g_path_get_dirname(filename)); | |
1054 | |
1055 if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) | |
1056 if (!show_playlist_overwrite_prompt(GTK_WINDOW(playlistwin), filename)) | |
1057 return; | |
1058 | |
2095 | 1059 if (!playlist_save(playlist_get_active(), filename)) |
1653 | 1060 show_playlist_save_error(GTK_WINDOW(playlistwin), filename); |
1061 } | |
1062 | |
1063 #if 0 | |
1064 static void | |
1065 playlistwin_save_current(void) | |
1066 { | |
1067 const gchar *filename; | |
1068 | |
1069 if (!(filename = playlist_get_current_name())) | |
1070 return; | |
1071 | |
1072 playlistwin_save_playlist(filename); | |
1073 } | |
1074 #endif | |
1075 | |
1076 static void | |
1077 playlistwin_load_playlist(const gchar * filename) | |
1078 { | |
2095 | 1079 Playlist *playlist = playlist_get_active(); |
1080 | |
1653 | 1081 g_return_if_fail(filename != NULL); |
1082 | |
1083 str_replace_in(&cfg.playlist_path, g_strdup(filename)); | |
1084 | |
2095 | 1085 playlist_clear(playlist); |
1653 | 1086 mainwin_clear_song_info(); |
1087 mainwin_set_info_text(); | |
1088 | |
2095 | 1089 playlist_load(playlist, filename); |
1090 playlist_set_current_name(playlist, filename); | |
1653 | 1091 } |
1092 | |
1093 static gchar * | |
1762
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1094 playlist_file_selection_load(const gchar * title, |
1653 | 1095 const gchar * default_filename) |
1096 { | |
1762
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1097 static GtkWidget *dialog = NULL; |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1098 GtkWidget *button; |
1653 | 1099 gchar *filename; |
1100 | |
1101 g_return_val_if_fail(title != NULL, NULL); | |
1102 | |
1762
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1103 if(!dialog) { |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1104 dialog = gtk_file_chooser_dialog_new(title, GTK_WINDOW(mainwin), |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1105 GTK_FILE_CHOOSER_ACTION_OPEN, NULL, NULL); |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1106 |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1107 if (default_filename) |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1108 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1109 default_filename); |
1653 | 1110 |
1762
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1111 button = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1112 GTK_RESPONSE_REJECT); |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1113 gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1114 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); |
1653 | 1115 |
1762
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1116 button = gtk_dialog_add_button(GTK_DIALOG(dialog), |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1117 GTK_STOCK_OPEN, |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1118 GTK_RESPONSE_ACCEPT); |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1119 gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1120 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1121 } |
1653 | 1122 |
1123 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) | |
1124 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); | |
1125 else | |
1126 filename = NULL; | |
1127 | |
1762
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1128 gtk_widget_hide(dialog); |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1129 return filename; |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1130 } |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1131 |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1132 static gchar * |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1133 playlist_file_selection_save(const gchar * title, |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1134 const gchar * default_filename) |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1135 { |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1136 static GtkWidget *dialog = NULL; |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1137 GtkWidget *button; |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1138 gchar *filename; |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1139 |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1140 g_return_val_if_fail(title != NULL, NULL); |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1141 |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1142 if(!dialog) { |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1143 dialog = gtk_file_chooser_dialog_new(title, GTK_WINDOW(mainwin), |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1144 GTK_FILE_CHOOSER_ACTION_SAVE, NULL, NULL); |
1653 | 1145 |
1762
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1146 if (default_filename) |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1147 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1148 default_filename); |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1149 |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1150 button = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1151 GTK_RESPONSE_REJECT); |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1152 gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1153 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1154 |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1155 button = gtk_dialog_add_button(GTK_DIALOG(dialog), |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1156 GTK_STOCK_SAVE, |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1157 GTK_RESPONSE_ACCEPT); |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1158 gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1159 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1160 } |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1161 |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1162 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1163 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1164 else |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1165 filename = NULL; |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1166 |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1167 gtk_widget_hide(dialog); |
1653 | 1168 return filename; |
1169 } | |
1170 | |
1171 void | |
1172 playlistwin_select_playlist_to_load(const gchar * default_filename) | |
1173 { | |
1174 gchar *filename = | |
1762
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1175 playlist_file_selection_load(_("Load Playlist"), default_filename); |
1653 | 1176 |
1177 if (filename) { | |
1178 playlistwin_load_playlist(filename); | |
1179 g_free(filename); | |
1180 } | |
1181 } | |
1182 | |
1183 static void | |
1184 playlistwin_select_playlist_to_save(const gchar * default_filename) | |
1185 { | |
1762
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1186 gchar *dot = NULL, *basename = NULL; |
1653 | 1187 gchar *filename = |
1762
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1188 playlist_file_selection_save(_("Save Playlist"), default_filename); |
1653 | 1189 |
1190 if (filename) { | |
1762
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1191 /* Default to xspf if no filename has extension */ |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1192 basename = g_path_get_basename(filename); |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1193 dot = strrchr(basename, '.'); |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1194 if( dot == NULL || dot == basename) { |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1195 gchar *oldname = filename; |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1196 filename = g_strconcat(oldname, ".xspf", NULL); |
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1197 g_free(oldname); |
1653 | 1198 } |
1762
5170463d8cc9
[svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog.
yaz
parents:
1653
diff
changeset
|
1199 g_free(basename); |
1653 | 1200 |
1201 playlistwin_save_playlist(filename); | |
1202 g_free(filename); | |
1203 } | |
1204 } | |
1205 | |
1206 static gboolean | |
1207 inside_sensitive_widgets(gint x, gint y) | |
1208 { | |
1209 return (widget_contains(WIDGET(playlistwin_list), x, y) || | |
1210 widget_contains(WIDGET(playlistwin_slider), x, y) || | |
1211 widget_contains(WIDGET(playlistwin_close), x, y) || | |
1212 widget_contains(WIDGET(playlistwin_shade), x, y) || | |
1213 widget_contains(WIDGET(playlistwin_time_min), x, y) || | |
1214 widget_contains(WIDGET(playlistwin_time_sec), x, y) || | |
1215 widget_contains(WIDGET(playlistwin_info), x, y) || | |
1216 widget_contains(WIDGET(playlistwin_srew), x, y) || | |
1217 widget_contains(WIDGET(playlistwin_splay), x, y) || | |
1218 widget_contains(WIDGET(playlistwin_spause), x, y) || | |
1219 widget_contains(WIDGET(playlistwin_sstop), x, y) || | |
1220 widget_contains(WIDGET(playlistwin_sfwd), x, y) || | |
1221 widget_contains(WIDGET(playlistwin_seject), x, y) || | |
1222 widget_contains(WIDGET(playlistwin_sscroll_up), x, y) || | |
1223 widget_contains(WIDGET(playlistwin_sscroll_down), x, y)); | |
1224 } | |
1225 | |
1226 #define REGION_L(x1,x2,y1,y2) \ | |
1227 (event->x >= (x1) && event->x < (x2) && \ | |
1228 event->y >= cfg.playlist_height - (y1) && \ | |
1229 event->y < cfg.playlist_height - (y2)) | |
1230 | |
1231 #define REGION_R(x1,x2,y1,y2) \ | |
1232 (event->x >= playlistwin_get_width() - (x1) && \ | |
1233 event->x < playlistwin_get_width() - (x2) && \ | |
1234 event->y >= cfg.playlist_height - (y1) && \ | |
1235 event->y < cfg.playlist_height - (y2)) | |
1236 | |
1237 static void | |
1238 playlistwin_scrolled(GtkWidget * widget, | |
1239 GdkEventScroll * event, | |
1240 gpointer callback_data) | |
1241 { | |
1242 | |
1243 if (event->direction == GDK_SCROLL_DOWN) | |
1244 playlistwin_scroll(cfg.scroll_pl_by); | |
1245 | |
1246 if (event->direction == GDK_SCROLL_UP) | |
1247 playlistwin_scroll(-cfg.scroll_pl_by); | |
1248 | |
2028 | 1249 g_cond_signal(cond_scan); |
1250 | |
1653 | 1251 } |
1252 | |
1253 | |
1254 | |
1255 | |
1256 static gboolean | |
1257 playlistwin_press(GtkWidget * widget, | |
1258 GdkEventButton * event, | |
1259 gpointer callback_data) | |
1260 { | |
1261 gboolean grab = TRUE; | |
1262 gint xpos, ypos; | |
1263 GtkWidget *_menu; | |
1264 GtkRequisition req; | |
1265 | |
1266 gtk_window_get_position(GTK_WINDOW(playlistwin), &xpos, &ypos); | |
1267 | |
1268 if (event->button == 1 && !cfg.show_wm_decorations && | |
1269 ((!cfg.playlist_shaded && | |
1270 event->x > playlistwin_get_width() - 20 && | |
1271 event->y > cfg.playlist_height - 20) || | |
1272 (cfg.playlist_shaded && | |
1273 event->x >= playlistwin_get_width() - 31 && | |
1274 event->x < playlistwin_get_width() - 22))) { | |
1275 | |
1276 /* NOTE: Workaround for bug #214 */ | |
1277 if (event->type != GDK_2BUTTON_PRESS && | |
1278 event->type != GDK_3BUTTON_PRESS) { | |
1279 /* resize area */ | |
1280 playlistwin_resizing = TRUE; | |
1281 gtk_window_begin_resize_drag(GTK_WINDOW(widget), | |
1282 GDK_WINDOW_EDGE_SOUTH_EAST, | |
1283 event->button, | |
1284 event->x + xpos, event->y + ypos, | |
1285 event->time); | |
1286 } | |
1287 grab = FALSE; | |
1288 } | |
1289 else if (event->button == 1 && REGION_L(12, 37, 29, 11)) { | |
1290 /* ADD button menu */ | |
1291 | |
1292 _menu = GTK_WIDGET(pladd_menu->widget); | |
1293 if (!GTK_WIDGET_REALIZED(_menu)) gtk_widget_realize(_menu); | |
1294 gtk_widget_size_request(_menu, &req); | |
1295 gtk_item_factory_popup_with_data(pladd_menu, | |
1296 NULL, NULL, | |
1297 xpos+12, | |
1298 (ypos + playlistwin_get_height()) - 8 - req.height, 1, event->time); | |
1299 grab = FALSE; | |
1300 } | |
1301 else if (event->button == 1 && REGION_L(41, 66, 29, 11)) { | |
1302 /* SUB button menu */ | |
1303 _menu = GTK_WIDGET(pldel_menu->widget); | |
1304 if (!GTK_WIDGET_REALIZED(_menu)) gtk_widget_realize(_menu); | |
1305 gtk_widget_size_request(_menu, &req); | |
1306 gtk_item_factory_popup_with_data(pldel_menu, | |
1307 NULL, NULL, | |
1308 xpos+40, | |
1309 (ypos + playlistwin_get_height()) - 8 - req.height, 1, event->time); | |
1310 grab = FALSE; | |
1311 } | |
1312 else if (event->button == 1 && REGION_L(70, 95, 29, 11)) { | |
1313 /* SEL button menu */ | |
1314 _menu = GTK_WIDGET(plsel_menu->widget); | |
1315 if (!GTK_WIDGET_REALIZED(_menu)) gtk_widget_realize(_menu); | |
1316 gtk_widget_size_request(_menu, &req); | |
1317 gtk_item_factory_popup_with_data(plsel_menu, | |
1318 NULL, NULL, | |
1319 xpos+68, | |
1320 (ypos + playlistwin_get_height()) - 8 - req.height, 1, event->time); | |
1321 | |
1322 grab = FALSE; | |
1323 } | |
1324 else if (event->button == 1 && REGION_L(99, 124, 29, 11)) { | |
1325 /* MISC button menu */ | |
1326 _menu = GTK_WIDGET(plsort_menu->widget); | |
1327 if (!GTK_WIDGET_REALIZED(_menu)) gtk_widget_realize(_menu); | |
1328 gtk_widget_size_request(_menu, &req); | |
1329 gtk_item_factory_popup_with_data(plsort_menu, | |
1330 NULL, NULL, | |
1331 xpos+100, | |
1332 (ypos + playlistwin_get_height()) - 8 - req.height, 1, event->time); | |
1333 grab = FALSE; | |
1334 } | |
1335 else if (event->button == 1 && REGION_R(46, 23, 29, 11)) { | |
1336 /* LIST button menu */ | |
1337 _menu = GTK_WIDGET(pllist_menu->widget); | |
1338 if (!GTK_WIDGET_REALIZED(_menu)) gtk_widget_realize(_menu); | |
1339 gtk_widget_size_request(_menu, &req); | |
1340 gtk_item_factory_popup_with_data(pllist_menu, | |
1341 NULL, NULL, | |
1342 xpos + playlistwin_get_width() - req.width - 12, | |
1343 (ypos + playlistwin_get_height()) - 8 - req.height, 1, event->time); | |
1344 grab = FALSE; | |
1345 } | |
1346 else if (event->button == 1 && REGION_R(82, 54, 15, 9)) { | |
1347 if (cfg.timer_mode == TIMER_ELAPSED) | |
1348 cfg.timer_mode = TIMER_REMAINING; | |
1349 else | |
1350 cfg.timer_mode = TIMER_ELAPSED; | |
1351 } | |
1352 else if (event->button == 2 && (event->type == GDK_BUTTON_PRESS) && | |
1353 widget_contains(WIDGET(playlistwin_list), event->x, event->y)) { | |
1354 gtk_selection_convert(widget, GDK_SELECTION_PRIMARY, | |
1355 GDK_TARGET_STRING, event->time); | |
1356 } | |
1357 else if (event->button == 1 && event->type == GDK_BUTTON_PRESS && | |
1938 | 1358 !inside_sensitive_widgets(event->x, event->y) && (cfg.easy_move || event->y < 14)) |
1653 | 1359 { |
1360 dock_move_press(dock_window_list, GTK_WINDOW(playlistwin), event, | |
1361 FALSE); | |
1362 gtk_window_present(GTK_WINDOW(playlistwin)); | |
1363 } | |
1364 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && | |
1365 !inside_sensitive_widgets(event->x, event->y) | |
1366 && event->y < 14) { | |
1367 /* double click on title bar */ | |
1368 playlistwin_shade_toggle(); | |
1369 if (dock_is_moving(GTK_WINDOW(playlistwin))) | |
1370 dock_move_release(GTK_WINDOW(playlistwin)); | |
1371 return TRUE; | |
1372 } | |
1373 else if (event->button == 3 && | |
1374 !(widget_contains(WIDGET(playlistwin_list), event->x, event->y) || | |
1375 (event->y >= cfg.playlist_height - 29 && | |
1376 event->y < cfg.playlist_height - 11 && | |
1377 ((event->x >= 12 && event->x < 37) || | |
1378 (event->x >= 41 && event->x < 66) || | |
1379 (event->x >= 70 && event->x < 95) || | |
1380 (event->x >= 99 && event->x < 124) || | |
1381 (event->x >= playlistwin_get_width() - 46 && | |
1382 event->x < playlistwin_get_width() - 23))))) { | |
1383 /* | |
1384 * Pop up the main menu a few pixels down to avoid | |
1385 * anything to be selected initially. | |
1386 */ | |
1387 util_item_factory_popup(mainwin_general_menu, event->x_root, | |
1388 event->y_root + 2, 3, event->time); | |
1389 grab = FALSE; | |
1390 } | |
1391 else if (event->button == 3 && | |
1392 widget_contains(WIDGET(playlistwin_list), event->x, event->y)) { | |
1393 /* popup menu */ | |
1394 playlistwin_set_sensitive_sortmenu(); | |
1395 { | |
1396 GtkWidget *item = gtk_item_factory_get_widget(playlistwin_popup_menu, "/Show Popup Info"); | |
1397 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), cfg.show_filepopup_for_tuple); | |
1398 } | |
1399 gtk_item_factory_popup(playlistwin_popup_menu, | |
1400 event->x_root, event->y_root + 5, | |
1401 3, event->time); | |
1402 grab = FALSE; | |
1403 } | |
1404 else { | |
1405 handle_press_cb(playlistwin_wlist, widget, event); | |
1406 draw_playlist_window(FALSE); | |
1407 } | |
1408 | |
1409 if (grab) | |
1410 gdk_pointer_grab(playlistwin->window, FALSE, | |
1411 GDK_BUTTON_MOTION_MASK | GDK_BUTTON_RELEASE_MASK | | |
1412 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | |
1413 GDK_BUTTON1_MOTION_MASK, NULL, NULL, | |
1414 GDK_CURRENT_TIME); | |
1415 | |
1416 return FALSE; | |
1417 } | |
1418 | |
1419 static gboolean | |
1420 playlistwin_focus_in(GtkWidget * widget, GdkEvent * event, gpointer data) | |
1421 { | |
1422 playlistwin_close->pb_allow_draw = TRUE; | |
1423 playlistwin_shade->pb_allow_draw = TRUE; | |
1424 draw_playlist_window(TRUE); | |
1425 return FALSE; | |
1426 } | |
1427 | |
1428 static gboolean | |
1429 playlistwin_focus_out(GtkWidget * widget, | |
1430 GdkEventButton * event, gpointer data) | |
1431 { | |
1432 playlistwin_close->pb_allow_draw = FALSE; | |
1433 playlistwin_shade->pb_allow_draw = FALSE; | |
1434 draw_playlist_window(TRUE); | |
1435 return FALSE; | |
1436 } | |
1437 | |
1438 static gboolean | |
1439 playlistwin_configure(GtkWidget * window, | |
1440 GdkEventConfigure * event, gpointer data) | |
1441 { | |
1442 if (!GTK_WIDGET_VISIBLE(window)) | |
1443 return FALSE; | |
1444 | |
1445 cfg.playlist_x = event->x; | |
1446 cfg.playlist_y = event->y; | |
1447 | |
1448 if (playlistwin_resizing) { | |
1449 if (event->width != playlistwin_get_width() || | |
1450 event->height != playlistwin_get_height()) | |
1451 playlistwin_resize(event->width, event->height); | |
1452 } | |
1453 return TRUE; | |
1454 } | |
1455 | |
1456 void | |
1457 playlistwin_set_back_pixmap(void) | |
1458 { | |
1459 gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0); | |
1460 gdk_window_clear(playlistwin->window); | |
1461 } | |
1462 | |
1463 static gboolean | |
1464 playlistwin_delete(GtkWidget * w, gpointer data) | |
1465 { | |
1466 playlistwin_hide(); | |
1467 return TRUE; | |
1468 } | |
1469 | |
1470 static void | |
1471 playlistwin_keypress_up_down_handler(PlayList_List * pl, | |
1472 gboolean up, guint state) | |
1473 { | |
2095 | 1474 Playlist *playlist = playlist_get_active(); |
1475 | |
1653 | 1476 if ((state & GDK_MOD1_MASK) && (state & GDK_SHIFT_MASK)) |
1477 return; | |
1478 if (!(state & GDK_MOD1_MASK)) | |
2095 | 1479 playlist_select_all(playlist, FALSE); |
1653 | 1480 |
1481 if (pl->pl_prev_selected == -1 || | |
1482 (!playlistwin_item_visible(pl->pl_prev_selected) && | |
1483 !(state & GDK_SHIFT_MASK && pl->pl_prev_min != -1))) { | |
1484 pl->pl_prev_selected = pl->pl_first; | |
1485 } | |
1486 else if (state & GDK_SHIFT_MASK) { | |
1487 if (pl->pl_prev_min == -1) { | |
1488 pl->pl_prev_max = pl->pl_prev_selected; | |
1489 pl->pl_prev_min = pl->pl_prev_selected; | |
1490 } | |
1491 pl->pl_prev_max += (up ? -1 : 1); | |
1492 pl->pl_prev_max = | |
2095 | 1493 CLAMP(pl->pl_prev_max, 0, playlist_get_length(playlist) - 1); |
1653 | 1494 |
1495 pl->pl_first = MIN(pl->pl_first, pl->pl_prev_max); | |
1496 pl->pl_first = MAX(pl->pl_first, pl->pl_prev_max - | |
1497 pl->pl_num_visible + 1); | |
2095 | 1498 playlist_select_range(playlist, pl->pl_prev_min, pl->pl_prev_max, TRUE); |
1653 | 1499 return; |
1500 } | |
1501 else if (state & GDK_MOD1_MASK) { | |
1502 if (up) | |
1503 playlist_list_move_up(pl); | |
1504 else | |
1505 playlist_list_move_down(pl); | |
1506 if (pl->pl_prev_min < pl->pl_first) | |
1507 pl->pl_first = pl->pl_prev_min; | |
1508 else if (pl->pl_prev_max >= (pl->pl_first + pl->pl_num_visible)) | |
1509 pl->pl_first = pl->pl_prev_max - pl->pl_num_visible + 1; | |
1510 return; | |
1511 } | |
1512 else if (up) | |
1513 pl->pl_prev_selected--; | |
1514 else | |
1515 pl->pl_prev_selected++; | |
1516 | |
1517 pl->pl_prev_selected = | |
2095 | 1518 CLAMP(pl->pl_prev_selected, 0, playlist_get_length(playlist) - 1); |
1653 | 1519 |
1520 if (pl->pl_prev_selected < pl->pl_first) | |
1521 pl->pl_first--; | |
1522 else if (pl->pl_prev_selected >= (pl->pl_first + pl->pl_num_visible)) | |
1523 pl->pl_first++; | |
1524 | |
2095 | 1525 playlist_select_range(playlist, pl->pl_prev_selected, pl->pl_prev_selected, TRUE); |
1653 | 1526 pl->pl_prev_min = -1; |
1527 } | |
1528 | |
1529 /* FIXME: Handle the keys through menu */ | |
1530 | |
1531 static gboolean | |
1532 playlistwin_keypress(GtkWidget * w, GdkEventKey * event, gpointer data) | |
1533 { | |
2095 | 1534 Playlist *playlist = playlist_get_active(); |
1535 | |
1653 | 1536 guint keyval; |
1537 gboolean refresh = FALSE; | |
1538 | |
1539 if (cfg.playlist_shaded) | |
1540 return FALSE; | |
1541 | |
1542 switch (keyval = event->keyval) { | |
1543 case GDK_KP_Up: | |
1544 case GDK_KP_Down: | |
1545 case GDK_Up: | |
1546 case GDK_Down: | |
1547 playlistwin_keypress_up_down_handler(playlistwin_list, | |
1548 keyval == GDK_Up | |
1549 || keyval == GDK_KP_Up, | |
1550 event->state); | |
1551 refresh = TRUE; | |
1552 break; | |
1553 case GDK_Page_Up: | |
1554 playlistwin_scroll(-playlistwin_list->pl_num_visible); | |
1555 refresh = TRUE; | |
1556 break; | |
1557 case GDK_Page_Down: | |
1558 playlistwin_scroll(playlistwin_list->pl_num_visible); | |
1559 refresh = TRUE; | |
1560 break; | |
1561 case GDK_Home: | |
1562 playlistwin_list->pl_first = 0; | |
1563 refresh = TRUE; | |
1564 break; | |
1565 case GDK_End: | |
1566 playlistwin_list->pl_first = | |
2095 | 1567 playlist_get_length(playlist) - playlistwin_list->pl_num_visible; |
1653 | 1568 refresh = TRUE; |
1569 break; | |
1570 case GDK_Return: | |
1571 if (playlistwin_list->pl_prev_selected > -1 | |
1572 && playlistwin_item_visible(playlistwin_list->pl_prev_selected)) { | |
2095 | 1573 playlist_set_position(playlist, playlistwin_list->pl_prev_selected); |
1653 | 1574 if (!bmp_playback_get_playing()) |
1575 bmp_playback_initiate(); | |
1576 } | |
1577 break; | |
1578 case GDK_3: | |
1579 if (event->state & GDK_CONTROL_MASK) | |
1580 playlistwin_fileinfo(); | |
1581 break; | |
1582 case GDK_Delete: | |
1583 if (event->state & GDK_CONTROL_MASK) | |
2095 | 1584 playlist_delete(playlist, TRUE); |
1653 | 1585 else |
2095 | 1586 playlist_delete(playlist, FALSE); |
1653 | 1587 break; |
1588 case GDK_Insert: | |
1589 if (event->state & GDK_MOD1_MASK) | |
1590 mainwin_show_add_url_window(); | |
1591 else | |
1592 playlistwin_show_filebrowser(); | |
1593 break; | |
1594 case GDK_Left: | |
1595 case GDK_KP_Left: | |
1596 case GDK_KP_7: | |
2095 | 1597 if (playlist_get_current_length(playlist) != -1) |
1653 | 1598 bmp_playback_seek(CLAMP |
2043
e211d52a3626
[svn] Seek controls (left and right) now seek 5 seconds like the main window
nazca
parents:
2028
diff
changeset
|
1599 (bmp_playback_get_time() - 5000, 0, |
2095 | 1600 playlist_get_current_length(playlist)) / 1000); |
1653 | 1601 break; |
1602 case GDK_Right: | |
1603 case GDK_KP_Right: | |
1604 case GDK_KP_9: | |
2095 | 1605 if (playlist_get_current_length(playlist) != -1) |
1653 | 1606 bmp_playback_seek(CLAMP |
2043
e211d52a3626
[svn] Seek controls (left and right) now seek 5 seconds like the main window
nazca
parents:
2028
diff
changeset
|
1607 (bmp_playback_get_time() + 5000, 0, |
2095 | 1608 playlist_get_current_length(playlist)) / 1000); |
1653 | 1609 break; |
2048
7bc2489db782
[svn] Numpad 4 and 6 liked to prev and next respectively to be more consistant with the main window
nazca
parents:
2043
diff
changeset
|
1610 case GDK_KP_4: |
2095 | 1611 playlist_prev(playlist); |
2048
7bc2489db782
[svn] Numpad 4 and 6 liked to prev and next respectively to be more consistant with the main window
nazca
parents:
2043
diff
changeset
|
1612 break; |
7bc2489db782
[svn] Numpad 4 and 6 liked to prev and next respectively to be more consistant with the main window
nazca
parents:
2043
diff
changeset
|
1613 case GDK_KP_6: |
2095 | 1614 playlist_next(playlist); |
2048
7bc2489db782
[svn] Numpad 4 and 6 liked to prev and next respectively to be more consistant with the main window
nazca
parents:
2043
diff
changeset
|
1615 break; |
1653 | 1616 |
1617 case GDK_Escape: | |
1618 mainwin_minimize_cb(); | |
1619 break; | |
1620 default: | |
1621 return FALSE; | |
1622 } | |
1623 | |
2026 | 1624 if (refresh) { |
1625 g_cond_signal(cond_scan); | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1626 playlistwin_update_list(playlist_get_active()); |
2026 | 1627 } |
1653 | 1628 |
1629 return TRUE; | |
1630 } | |
1631 | |
1632 static void | |
1633 playlistwin_draw_frame(void) | |
1634 { | |
1635 gboolean focus = | |
1636 gtk_window_has_toplevel_focus(GTK_WINDOW(playlistwin)) || | |
1637 !cfg.dim_titlebar; | |
1638 | |
1639 if (cfg.playlist_shaded) { | |
1640 skin_draw_playlistwin_shaded(bmp_active_skin, | |
1641 playlistwin_bg, playlistwin_gc, | |
1642 playlistwin_get_width(), focus); | |
1643 } | |
1644 else { | |
1645 skin_draw_playlistwin_frame(bmp_active_skin, | |
1646 playlistwin_bg, playlistwin_gc, | |
1647 playlistwin_get_width(), | |
1648 cfg.playlist_height, focus); | |
1649 } | |
1650 } | |
1651 | |
1652 void | |
1653 draw_playlist_window(gboolean force) | |
1654 { | |
1655 gboolean redraw; | |
1656 GList *wl; | |
1657 Widget *w; | |
1658 | |
1659 if (force) | |
1660 playlistwin_draw_frame(); | |
1661 | |
1662 widget_list_lock(playlistwin_wlist); | |
1663 widget_list_draw(playlistwin_wlist, &redraw, force); | |
1664 | |
1665 if (redraw || force) { | |
1666 if (force) { | |
1667 gdk_window_clear(playlistwin->window); | |
1668 } | |
1669 else { | |
1670 for (wl = playlistwin_wlist; wl; wl = g_list_next(wl)) { | |
1671 w = WIDGET(wl->data); | |
1672 if (w->redraw && w->visible) { | |
1673 gdk_window_clear_area(playlistwin->window, w->x, w->y, | |
1674 w->width, w->height); | |
1675 w->redraw = FALSE; | |
1676 } | |
1677 } | |
1678 } | |
1679 | |
1680 gdk_flush(); | |
1681 } | |
1682 | |
1683 widget_list_unlock(playlistwin_wlist); | |
1684 } | |
1685 | |
1686 | |
1687 void | |
1688 playlistwin_hide_timer(void) | |
1689 { | |
1690 textbox_set_text(playlistwin_time_min, " "); | |
1691 textbox_set_text(playlistwin_time_sec, " "); | |
1692 } | |
1693 | |
1694 void | |
1695 playlistwin_set_time(gint time, gint length, TimerMode mode) | |
1696 { | |
1697 gchar *text, sign; | |
1698 | |
1699 if (mode == TIMER_REMAINING && length != -1) { | |
1700 time = length - time; | |
1701 sign = '-'; | |
1702 } | |
1703 else | |
1704 sign = ' '; | |
1705 | |
1706 time /= 1000; | |
1707 | |
1708 if (time < 0) | |
1709 time = 0; | |
1710 if (time > 99 * 60) | |
1711 time /= 60; | |
1712 | |
1713 text = g_strdup_printf("%c%-2.2d", sign, time / 60); | |
1714 textbox_set_text(playlistwin_time_min, text); | |
1715 g_free(text); | |
1716 | |
1717 text = g_strdup_printf("%-2.2d", time % 60); | |
1718 textbox_set_text(playlistwin_time_sec, text); | |
1719 g_free(text); | |
1720 } | |
1721 | |
1722 static void | |
1723 playlistwin_drag_motion(GtkWidget * widget, | |
1724 GdkDragContext * context, | |
1725 gint x, gint y, | |
1726 GtkSelectionData * selection_data, | |
1727 guint info, guint time, gpointer user_data) | |
1728 { | |
1729 playlistwin_list->pl_drag_motion = TRUE; | |
1730 playlistwin_list->drag_motion_x = x; | |
1731 playlistwin_list->drag_motion_y = y; | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1732 playlistwin_update_list(playlist_get_active()); |
1653 | 1733 playlistwin_hint_flag = TRUE; |
1734 } | |
1735 | |
1736 static void | |
1737 playlistwin_drag_end(GtkWidget * widget, | |
1738 GdkDragContext * context, gpointer user_data) | |
1739 { | |
1740 playlistwin_list->pl_drag_motion = FALSE; | |
1741 playlistwin_hint_flag = FALSE; | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1742 playlistwin_update_list(playlist_get_active()); |
1653 | 1743 } |
1744 | |
1745 static void | |
1746 playlistwin_drag_data_received(GtkWidget * widget, | |
1747 GdkDragContext * context, | |
1748 gint x, gint y, | |
1749 GtkSelectionData * | |
1750 selection_data, guint info, | |
1751 guint time, gpointer user_data) | |
1752 { | |
1753 gint pos; | |
2095 | 1754 Playlist *playlist = playlist_get_active(); |
1653 | 1755 |
1756 g_return_if_fail(selection_data != NULL); | |
1757 | |
1758 if (!selection_data->data) { | |
1759 g_message("Received no DND data!"); | |
1760 return; | |
1761 } | |
1762 | |
1763 if (widget_contains(WIDGET(playlistwin_list), x, y)) { | |
1764 pos = (y - WIDGET(playlistwin_list)->y) / | |
1765 playlistwin_list->pl_fheight + playlistwin_list->pl_first; | |
1766 | |
2095 | 1767 pos = MIN(pos, playlist_get_length(playlist)); |
1768 playlist_ins_url(playlist, (gchar *) selection_data->data, pos); | |
1653 | 1769 } |
1770 else | |
2095 | 1771 playlist_add_url(playlist, (gchar *) selection_data->data); |
1772 } | |
1773 | |
1774 static void | |
1775 local_playlist_prev(void) | |
1776 { | |
1777 playlist_prev(playlist_get_active()); | |
1778 } | |
1779 | |
1780 static void | |
1781 local_playlist_next(void) | |
1782 { | |
1783 playlist_next(playlist_get_active()); | |
1653 | 1784 } |
1785 | |
1786 static void | |
1787 playlistwin_create_widgets(void) | |
1788 { | |
1775 | 1789 gchar *font = NULL, *tmp = NULL; |
1653 | 1790 /* This function creates the custom widgets used by the playlist editor */ |
1791 | |
1792 /* text box for displaying song title in shaded mode */ | |
1793 playlistwin_sinfo = | |
1794 create_textbox(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1775 | 1795 4, 4, playlistwin_get_width() - 35, TRUE, SKIN_TEXT); |
1796 | |
1797 playlistwin_set_sinfo_font(cfg.playlist_font); | |
1653 | 1798 |
1799 if (!cfg.playlist_shaded) | |
1800 widget_hide(WIDGET(playlistwin_sinfo)); | |
1801 | |
1802 /* shade/unshade window push button */ | |
1803 if (cfg.playlist_shaded) | |
1804 playlistwin_shade = | |
1805 create_pbutton(&playlistwin_wlist, playlistwin_bg, | |
1806 playlistwin_gc, playlistwin_get_width() - 21, 3, | |
1807 9, 9, 128, 45, 150, 42, | |
1808 playlistwin_shade_toggle, SKIN_PLEDIT); | |
1809 else | |
1810 playlistwin_shade = | |
1811 create_pbutton(&playlistwin_wlist, playlistwin_bg, | |
1812 playlistwin_gc, playlistwin_get_width() - 21, 3, | |
1813 9, 9, 157, 3, 62, 42, playlistwin_shade_toggle, | |
1814 SKIN_PLEDIT); | |
1815 | |
1816 playlistwin_shade->pb_allow_draw = FALSE; | |
1817 | |
1818 /* close window push button */ | |
1819 playlistwin_close = | |
1820 create_pbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1821 playlistwin_get_width() - 11, 3, 9, 9, | |
1822 cfg.playlist_shaded ? 138 : 167, | |
1823 cfg.playlist_shaded ? 45 : 3, 52, 42, | |
1824 playlistwin_hide, SKIN_PLEDIT); | |
1825 playlistwin_close->pb_allow_draw = FALSE; | |
1826 | |
1827 /* playlist list box */ | |
1828 playlistwin_list = | |
1829 create_playlist_list(&playlistwin_wlist, playlistwin_bg, | |
1830 playlistwin_gc, 12, 20, | |
1831 playlistwin_get_width() - 31, | |
1832 cfg.playlist_height - 58); | |
1833 playlist_list_set_font(cfg.playlist_font); | |
1834 | |
1835 /* playlist list box slider */ | |
1836 playlistwin_slider = | |
1837 create_playlistslider(&playlistwin_wlist, playlistwin_bg, | |
1838 playlistwin_gc, playlistwin_get_width() - 15, | |
1839 20, cfg.playlist_height - 58, playlistwin_list); | |
1840 /* track time (minute) */ | |
1841 playlistwin_time_min = | |
1842 create_textbox(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1843 playlistwin_get_width() - 82, | |
1844 cfg.playlist_height - 15, 15, FALSE, SKIN_TEXT); | |
1845 | |
1846 /* track time (second) */ | |
1847 playlistwin_time_sec = | |
1848 create_textbox(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1849 playlistwin_get_width() - 64, | |
1850 cfg.playlist_height - 15, 10, FALSE, SKIN_TEXT); | |
1851 | |
1852 /* playlist information (current track length / total track length) */ | |
1853 playlistwin_info = | |
1854 create_textbox(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1855 playlistwin_get_width() - 143, | |
1856 cfg.playlist_height - 28, 90, FALSE, SKIN_TEXT); | |
1857 | |
1858 /* mini play control buttons at right bottom corner */ | |
1859 | |
1860 /* rewind button */ | |
1861 playlistwin_srew = | |
1862 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1863 playlistwin_get_width() - 144, | |
2095 | 1864 cfg.playlist_height - 16, 8, 7, local_playlist_prev); |
1653 | 1865 |
1866 /* play button */ | |
1867 playlistwin_splay = | |
1868 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1869 playlistwin_get_width() - 138, | |
1870 cfg.playlist_height - 16, 10, 7, mainwin_play_pushed); | |
1871 | |
1872 /* pause button */ | |
1873 playlistwin_spause = | |
1874 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1875 playlistwin_get_width() - 128, | |
1876 cfg.playlist_height - 16, 10, 7, bmp_playback_pause); | |
1877 | |
1878 /* stop button */ | |
1879 playlistwin_sstop = | |
1880 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1881 playlistwin_get_width() - 118, | |
1882 cfg.playlist_height - 16, 9, 7, mainwin_stop_pushed); | |
1883 | |
1884 /* forward button */ | |
1885 playlistwin_sfwd = | |
1886 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1887 playlistwin_get_width() - 109, | |
2095 | 1888 cfg.playlist_height - 16, 8, 7, local_playlist_next); |
1653 | 1889 |
1890 /* eject button */ | |
1891 playlistwin_seject = | |
1892 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1893 playlistwin_get_width() - 100, | |
1894 cfg.playlist_height - 16, 9, 7, mainwin_eject_pushed); | |
1895 | |
1896 | |
1897 playlistwin_sscroll_up = | |
1898 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1899 playlistwin_get_width() - 14, | |
1900 cfg.playlist_height - 35, 8, 5, | |
1901 playlistwin_scroll_up_pushed); | |
1902 playlistwin_sscroll_down = | |
1903 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1904 playlistwin_get_width() - 14, | |
1905 cfg.playlist_height - 30, 8, 5, | |
1906 playlistwin_scroll_down_pushed); | |
1907 | |
1908 } | |
1909 | |
1910 static void | |
1911 selection_received(GtkWidget * widget, | |
1912 GtkSelectionData * selection_data, gpointer data) | |
1913 { | |
1914 if (selection_data->type == GDK_SELECTION_TYPE_STRING && | |
1915 selection_data->length > 0) | |
2095 | 1916 playlist_add_url(playlist_get_active(), (gchar *) selection_data->data); |
1653 | 1917 } |
1918 | |
1919 static void | |
1920 playlistwin_create_window(void) | |
1921 { | |
1922 GdkPixbuf *icon; | |
1923 | |
1924 playlistwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1925 gtk_window_set_title(GTK_WINDOW(playlistwin), _("Audacious Playlist Editor")); | |
1926 gtk_window_set_wmclass(GTK_WINDOW(playlistwin), "playlist", "Audacious"); | |
1927 gtk_window_set_role(GTK_WINDOW(playlistwin), "playlist"); | |
1928 gtk_window_set_default_size(GTK_WINDOW(playlistwin), | |
1929 playlistwin_get_width(), | |
1930 playlistwin_get_height()); | |
1931 gtk_window_set_resizable(GTK_WINDOW(playlistwin), TRUE); | |
1932 playlistwin_set_geometry_hints(cfg.playlist_shaded); | |
1933 dock_window_list = dock_window_set_decorated(dock_window_list, | |
1934 GTK_WINDOW(playlistwin), | |
1935 cfg.show_wm_decorations); | |
1936 | |
1937 gtk_window_set_transient_for(GTK_WINDOW(playlistwin), | |
1938 GTK_WINDOW(mainwin)); | |
1939 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(playlistwin), TRUE); | |
1940 | |
1941 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) bmp_playlist_icon); | |
1942 gtk_window_set_icon(GTK_WINDOW(playlistwin), icon); | |
1943 g_object_unref(icon); | |
1944 | |
1945 gtk_widget_set_app_paintable(playlistwin, TRUE); | |
1946 | |
1947 if (cfg.playlist_x != -1 && cfg.save_window_position) | |
1948 gtk_window_move(GTK_WINDOW(playlistwin), | |
1949 cfg.playlist_x, cfg.playlist_y); | |
1950 | |
1951 gtk_widget_add_events(playlistwin, GDK_POINTER_MOTION_MASK | | |
1952 GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_MOTION_MASK | | |
1953 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | |
1954 GDK_SCROLL_MASK | GDK_VISIBILITY_NOTIFY_MASK); | |
1955 gtk_widget_realize(playlistwin); | |
1956 | |
1957 util_set_cursor(playlistwin); | |
1958 | |
1959 g_signal_connect(playlistwin, "delete_event", | |
1960 G_CALLBACK(playlistwin_delete), NULL); | |
1961 g_signal_connect(playlistwin, "button_press_event", | |
1962 G_CALLBACK(playlistwin_press), NULL); | |
1963 g_signal_connect(playlistwin, "button_release_event", | |
1964 G_CALLBACK(playlistwin_release), NULL); | |
1965 g_signal_connect(playlistwin, "scroll_event", | |
1966 G_CALLBACK(playlistwin_scrolled), NULL); | |
1967 g_signal_connect(playlistwin, "motion_notify_event", | |
1968 G_CALLBACK(playlistwin_motion), NULL); | |
1969 g_signal_connect(playlistwin, "enter_notify_event", | |
1970 G_CALLBACK(playlistwin_enter), NULL); | |
1971 g_signal_connect(playlistwin, "leave_notify_event", | |
1972 G_CALLBACK(playlistwin_leave), NULL); | |
1973 g_signal_connect_after(playlistwin, "focus_in_event", | |
1974 G_CALLBACK(playlistwin_focus_in), NULL); | |
1975 g_signal_connect_after(playlistwin, "focus_out_event", | |
1976 G_CALLBACK(playlistwin_focus_out), NULL); | |
1977 g_signal_connect(playlistwin, "configure_event", | |
1978 G_CALLBACK(playlistwin_configure), NULL); | |
1979 g_signal_connect(playlistwin, "style_set", | |
1980 G_CALLBACK(playlistwin_set_back_pixmap), NULL); | |
1981 | |
1982 bmp_drag_dest_set(playlistwin); | |
1983 | |
1984 /* DnD stuff */ | |
1985 g_signal_connect(playlistwin, "drag-leave", | |
1986 G_CALLBACK(playlistwin_drag_end), NULL); | |
1987 g_signal_connect(playlistwin, "drag-data-delete", | |
1988 G_CALLBACK(playlistwin_drag_end), NULL); | |
1989 g_signal_connect(playlistwin, "drag-end", | |
1990 G_CALLBACK(playlistwin_drag_end), NULL); | |
1991 g_signal_connect(playlistwin, "drag-drop", | |
1992 G_CALLBACK(playlistwin_drag_end), NULL); | |
1993 g_signal_connect(playlistwin, "drag-data-received", | |
1994 G_CALLBACK(playlistwin_drag_data_received), NULL); | |
1995 g_signal_connect(playlistwin, "drag-motion", | |
1996 G_CALLBACK(playlistwin_drag_motion), NULL); | |
1997 | |
1998 g_signal_connect(playlistwin, "key_press_event", | |
1999 G_CALLBACK(playlistwin_keypress), NULL); | |
2000 g_signal_connect(playlistwin, "selection_received", | |
2001 G_CALLBACK(selection_received), NULL); | |
2002 | |
2003 playlistwin_set_mask(); | |
2004 } | |
2005 | |
2006 void | |
2007 playlistwin_create_popup_menus(void) | |
2008 { | |
2009 playlistwin_accel = gtk_accel_group_new(); | |
2010 | |
2011 /* playlist window popup menu */ | |
2012 playlistwin_popup_menu = create_menu(playlistwin_popup_menu_entries, | |
2013 G_N_ELEMENTS(playlistwin_popup_menu_entries), | |
2014 playlistwin_accel); | |
2015 | |
2016 pladd_menu = create_menu(pladd_menu_entries, G_N_ELEMENTS(pladd_menu_entries), | |
2017 playlistwin_accel); | |
2018 pldel_menu = create_menu(pldel_menu_entries, G_N_ELEMENTS(pldel_menu_entries), | |
2019 playlistwin_accel); | |
2020 plsel_menu = create_menu(plsel_menu_entries, G_N_ELEMENTS(plsel_menu_entries), | |
2021 playlistwin_accel); | |
2022 plsort_menu = create_menu(plsort_menu_entries, | |
2023 G_N_ELEMENTS(plsort_menu_entries), | |
2024 playlistwin_accel); | |
2025 pllist_menu = create_menu(pllist_menu_entries, G_N_ELEMENTS(pllist_menu_entries), | |
2026 playlistwin_accel); | |
2027 | |
2028 #if 0 | |
2029 make_submenu(playlistwin_popup_menu, "/Playlist", | |
2030 playlistwin_playlist_menu); | |
2031 make_submenu(playlistwin_popup_menu, "/Playback", | |
2032 playlistwin_playback_menu); | |
2033 make_submenu(playlistwin_popup_menu, "/Add", | |
2034 pladd_menu); | |
2035 #endif | |
2036 } | |
2037 | |
2038 void | |
2039 playlistwin_create(void) | |
2040 { | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2041 Playlist *playlist; |
1653 | 2042 playlistwin_create_window(); |
2043 playlistwin_create_popup_menus(); | |
2044 | |
2045 /* create GC and back pixmap for custom widget to draw on */ | |
2046 playlistwin_gc = gdk_gc_new(playlistwin->window); | |
2047 playlistwin_bg = gdk_pixmap_new(playlistwin->window, | |
2048 playlistwin_get_width(), | |
2049 playlistwin_get_height_unshaded(), -1); | |
2050 gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0); | |
2051 | |
2052 playlistwin_create_widgets(); | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2053 playlistwin_update_info(playlist_get_active()); |
1653 | 2054 |
2055 gtk_window_add_accel_group(GTK_WINDOW(playlistwin), playlistwin_accel); | |
2056 gtk_window_add_accel_group(GTK_WINDOW(playlistwin), mainwin_accel); | |
2057 } | |
2058 | |
2059 | |
2060 void | |
2061 playlistwin_show(void) | |
2062 { | |
2063 GtkWidget *item; | |
2064 | |
2065 item = gtk_item_factory_get_widget(mainwin_view_menu, | |
2066 "/Show Playlist Editor"); | |
2067 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); | |
2068 | |
2069 tbutton_set_toggled(mainwin_pl, TRUE); | |
2070 cfg.playlist_visible = TRUE; | |
2071 | |
2072 playlistwin_set_toprow(0); | |
2095 | 2073 playlist_check_pos_current(playlist_get_active()); |
1653 | 2074 |
2075 gtk_widget_show(playlistwin); | |
2076 } | |
2077 | |
2078 void | |
2079 playlistwin_hide(void) | |
2080 { | |
2081 GtkWidget *item; | |
2082 | |
2083 item = gtk_item_factory_get_widget(mainwin_view_menu, | |
2084 "/Show Playlist Editor"); | |
2085 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), FALSE); | |
2086 | |
2087 gtk_widget_hide(playlistwin); | |
2088 tbutton_set_toggled(mainwin_pl, FALSE); | |
2089 cfg.playlist_visible = FALSE; | |
2090 | |
2091 gtk_window_present(GTK_WINDOW(mainwin)); | |
2092 gtk_widget_grab_focus(mainwin); | |
2093 } | |
2094 | |
2095 | |
2096 static void | |
2097 plsort_menu_callback(gpointer data, | |
2098 guint action, | |
2099 GtkWidget * widget) | |
2100 { | |
2095 | 2101 Playlist *playlist = playlist_get_active(); |
2102 | |
1653 | 2103 switch (action) { |
2104 case PLAYLISTWIN_SORT_BYPLAYLIST: | |
2095 | 2105 playlist_sort(playlist, PLAYLIST_SORT_PLAYLIST); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2106 playlistwin_update_list(playlist_get_active()); |
1653 | 2107 break; |
2108 case PLAYLISTWIN_SORT_BYTRACK: | |
2095 | 2109 playlist_sort(playlist, PLAYLIST_SORT_TRACK); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2110 playlistwin_update_list(playlist_get_active()); |
1653 | 2111 break; |
2112 case PLAYLISTWIN_SORT_BYTITLE: | |
2095 | 2113 playlist_sort(playlist, PLAYLIST_SORT_TITLE); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2114 playlistwin_update_list(playlist_get_active()); |
1653 | 2115 break; |
2116 case PLAYLISTWIN_SORT_BYARTIST: | |
2095 | 2117 playlist_sort(playlist, PLAYLIST_SORT_ARTIST); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2118 playlistwin_update_list(playlist_get_active()); |
1653 | 2119 break; |
2120 case PLAYLISTWIN_SORT_BYPATH: | |
2095 | 2121 playlist_sort(playlist, PLAYLIST_SORT_PATH); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2122 playlistwin_update_list(playlist_get_active()); |
1653 | 2123 break; |
2124 case PLAYLISTWIN_SORT_BYDATE: | |
2095 | 2125 playlist_sort(playlist, PLAYLIST_SORT_DATE); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2126 playlistwin_update_list(playlist_get_active()); |
1653 | 2127 break; |
2128 case PLAYLISTWIN_SORT_BYFILENAME: | |
2095 | 2129 playlist_sort(playlist, PLAYLIST_SORT_FILENAME); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2130 playlistwin_update_list(playlist_get_active()); |
1653 | 2131 break; |
2132 case PLAYLISTWIN_SORT_SEL_BYPLAYLIST: | |
2095 | 2133 playlist_sort_selected(playlist, PLAYLIST_SORT_PLAYLIST); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2134 playlistwin_update_list(playlist_get_active()); |
1653 | 2135 break; |
2136 case PLAYLISTWIN_SORT_SEL_BYTRACK: | |
2095 | 2137 playlist_sort_selected(playlist, PLAYLIST_SORT_TRACK); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2138 playlistwin_update_list(playlist_get_active()); |
1653 | 2139 break; |
2140 case PLAYLISTWIN_SORT_SEL_BYTITLE: | |
2095 | 2141 playlist_sort_selected(playlist, PLAYLIST_SORT_TITLE); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2142 playlistwin_update_list(playlist_get_active()); |
1653 | 2143 break; |
2144 case PLAYLISTWIN_SORT_SEL_BYARTIST: | |
2095 | 2145 playlist_sort_selected(playlist, PLAYLIST_SORT_ARTIST); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2146 playlistwin_update_list(playlist_get_active()); |
1653 | 2147 break; |
2148 case PLAYLISTWIN_SORT_SEL_BYFILENAME: | |
2095 | 2149 playlist_sort_selected(playlist, PLAYLIST_SORT_FILENAME); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2150 playlistwin_update_list(playlist_get_active()); |
1653 | 2151 break; |
2152 case PLAYLISTWIN_SORT_SEL_BYPATH: | |
2095 | 2153 playlist_sort_selected(playlist, PLAYLIST_SORT_PATH); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2154 playlistwin_update_list(playlist_get_active()); |
1653 | 2155 break; |
2156 case PLAYLISTWIN_SORT_SEL_BYDATE: | |
2095 | 2157 playlist_sort_selected(playlist, PLAYLIST_SORT_DATE); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2158 playlistwin_update_list(playlist_get_active()); |
1653 | 2159 break; |
2160 case PLAYLISTWIN_SORT_REVERSE: | |
2095 | 2161 playlist_reverse(playlist); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2162 playlistwin_update_list(playlist_get_active()); |
1653 | 2163 break; |
2164 case PLAYLISTWIN_SORT_RANDOMIZE: | |
2095 | 2165 playlist_random(playlist); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2166 playlistwin_update_list(playlist_get_active()); |
1653 | 2167 break; |
2168 } | |
2169 } | |
2170 | |
2171 static void | |
2172 playlistwin_sub_menu_callback(gpointer data, | |
2173 guint action, | |
2174 GtkWidget * widget) | |
2175 { | |
2095 | 2176 Playlist *playlist = playlist_get_active(); |
2177 | |
1653 | 2178 switch (action) { |
2179 case PLIST_NEW: | |
2095 | 2180 playlist_set_current_name(playlist, NULL); |
2181 playlist_clear(playlist); | |
1653 | 2182 mainwin_clear_song_info(); |
2183 mainwin_set_info_text(); | |
2184 break; | |
2185 case PLIST_SAVE: | |
2095 | 2186 playlistwin_select_playlist_to_save(playlist_get_current_name(playlist)); |
1653 | 2187 break; |
2188 case PLIST_DEFAULTSAVE: | |
2095 | 2189 playlist_save(playlist, bmp_paths[BMP_PATH_PLAYLIST_FILE]); |
1653 | 2190 break; |
2191 case PLIST_SAVE_AS: | |
2095 | 2192 playlistwin_select_playlist_to_save(playlist_get_current_name(playlist)); |
1653 | 2193 break; |
2194 case PLIST_LOAD: | |
2095 | 2195 playlistwin_select_playlist_to_load(playlist_get_current_name(playlist)); |
1653 | 2196 break; |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
2197 case SEL_SEARCH: |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
2198 playlistwin_select_search(); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2105
diff
changeset
|
2199 break; |
1653 | 2200 case SEL_INV: |
2201 playlistwin_inverse_selection(); | |
2202 break; | |
2203 case SEL_ZERO: | |
2204 playlistwin_select_none(); | |
2205 break; | |
2206 case SEL_ALL: | |
2207 playlistwin_select_all(); | |
2208 break; | |
2209 case SUB_ALL: | |
2095 | 2210 playlist_clear(playlist); |
1653 | 2211 mainwin_clear_song_info(); |
2212 mainwin_set_info_text(); | |
2213 break; | |
2214 case SUB_CROP: | |
2095 | 2215 playlist_delete(playlist, TRUE); |
1653 | 2216 break; |
2217 case SUB_SELECTED: | |
2095 | 2218 playlist_delete(playlist, FALSE); |
1653 | 2219 break; |
2220 case SUB_DUPLICATE_BYTITLE: | |
2095 | 2221 playlist_remove_duplicates(playlist, PLAYLIST_DUPS_TITLE); |
1653 | 2222 break; |
2223 case SUB_DUPLICATE_BYFILENAME: | |
2095 | 2224 playlist_remove_duplicates(playlist, PLAYLIST_DUPS_FILENAME); |
1653 | 2225 break; |
2226 case SUB_DUPLICATE_BYPATH: | |
2095 | 2227 playlist_remove_duplicates(playlist, PLAYLIST_DUPS_PATH); |
1653 | 2228 break; |
2229 case PLAYLISTWIN_REMOVE_DEAD_FILES: | |
2095 | 2230 playlist_remove_dead_files(playlist); |
1653 | 2231 break; |
2232 case PLAYLISTWIN_REFRESH: | |
2095 | 2233 playlist_read_info_selection(playlist); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2234 playlistwin_update_list(playlist_get_active()); |
1653 | 2235 break; |
2236 } | |
2237 } | |
2238 | |
2239 static void | |
2240 playlistwin_popup_menu_callback(gpointer data, | |
2241 guint action, | |
2242 GtkWidget * widget) | |
2243 { | |
2244 extern GtkWidget *filepopupbutton; | |
2095 | 2245 Playlist *playlist = playlist_get_active(); |
1653 | 2246 |
2247 switch (action) { | |
2248 case ADD_FILES: | |
2249 playlistwin_show_filebrowser(); | |
2250 break; | |
2251 case CLOSE_PL_WINDOW: | |
2252 playlistwin_hide(); | |
2253 break; | |
2254 case MISC_FILEINFO: | |
2255 playlistwin_fileinfo(); | |
2256 break; | |
2257 case SEL_LOOKUP: | |
2095 | 2258 playlist_read_info_selection(playlist); |
1653 | 2259 break; |
2260 case MISC_QUEUE: | |
2095 | 2261 playlist_queue(playlist); |
1653 | 2262 break; |
2263 case PLIST_CQUEUE: | |
2095 | 2264 playlist_clear_queue(playlist); |
1653 | 2265 break; |
2266 case PLIST_JTT: | |
2267 mainwin_jump_to_time(); | |
2268 break; | |
2269 case PLIST_JTF: | |
2270 mainwin_jump_to_file(); | |
2271 break; | |
2272 case MISC_FILEPOPUP: | |
2273 cfg.show_filepopup_for_tuple = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
2274 if(filepopupbutton != NULL){ | |
2275 gtk_signal_emit_by_name(GTK_OBJECT(filepopupbutton), "realize"); | |
2276 } | |
2277 break; | |
2278 | |
2279 } | |
2280 } | |
2144
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
2281 |
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
2282 |
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
2283 /* playlistwin_select_search callback functions |
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
2284 placed here to avoid making the code messier :) */ |
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
2285 static void |
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
2286 playlistwin_select_search_cbt_cb( GtkWidget *called_cbt , gpointer other_cbt ) |
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
2287 { |
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
2288 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(called_cbt) ) == TRUE ) |
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
2289 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(other_cbt) , FALSE ); |
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
2290 return; |
b76039eeb6f0
[svn] - added auto-enqueue option for search-in-playlist
giacomo
parents:
2140
diff
changeset
|
2291 } |