0
|
1 /* BMP - Cross-platform multimedia player
|
|
2 * Copyright (C) 2003-2004 BMP development team.
|
|
3 *
|
|
4 * Based on XMMS:
|
|
5 * Copyright (C) 1998-2003 XMMS development team.
|
|
6 *
|
|
7 * This program is free software; you can redistribute it and/or modify
|
|
8 * it under the terms of the GNU General Public License as published by
|
|
9 * the Free Software Foundation; either version 2 of the License, or
|
|
10 * (at your option) any later version.
|
|
11 *
|
|
12 * This program is distributed in the hope that it will be useful,
|
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 * GNU General Public License for more details.
|
|
16 *
|
|
17 * You should have received a copy of the GNU General Public License
|
|
18 * along with this program; if not, write to the Free Software
|
|
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
20 */
|
|
21
|
|
22 #include "playlistwin.h"
|
|
23
|
|
24 #include <glib.h>
|
|
25 #include <glib/gi18n.h>
|
|
26 #include <gdk/gdk.h>
|
|
27 #include <gdk/gdkkeysyms.h>
|
|
28 #include <gtk/gtk.h>
|
|
29 #include <string.h>
|
|
30
|
|
31 #include <gdk/gdkx.h>
|
|
32
|
|
33 #include <X11/Xlib.h>
|
|
34 #include <unistd.h>
|
|
35 #include <errno.h>
|
|
36
|
|
37 #include "libaudacious/util.h"
|
|
38
|
|
39 #include "dnd.h"
|
|
40 #include "dock.h"
|
|
41 #include "equalizer.h"
|
|
42 #include "hints.h"
|
|
43 #include "input.h"
|
|
44 #include "main.h"
|
|
45 #include "mainwin.h"
|
|
46 #include "playback.h"
|
|
47 #include "playlist.h"
|
|
48 #include "playlist_list.h"
|
|
49 #include "playlist_slider.h"
|
|
50 #include "playlist_popup.h"
|
|
51 #include "pbutton.h"
|
|
52 #include "sbutton.h"
|
|
53 #include "skin.h"
|
|
54 #include "textbox.h"
|
|
55 #include "util.h"
|
|
56
|
|
57 #include "pixmaps.h"
|
|
58 #include "images/bmp_playlist.xpm"
|
|
59
|
|
60
|
|
61 #define ITEM_SEPARATOR {"/-", NULL, NULL, 0, "<Separator>"}
|
|
62
|
|
63
|
|
64 enum {
|
|
65 ADD_URL, ADD_DIR, ADD_FILES,
|
|
66 SUB_MISC, SUB_ALL, SUB_CROP, SUB_SELECTED,
|
|
67 SEL_INV, SEL_ZERO, SEL_ALL,
|
|
68 MISC_SORT, MISC_FILEINFO, MISC_MISCOPTS,
|
|
69 PLIST_NEW, PLIST_SAVE_AS, PLIST_LOAD,
|
|
70 SEL_LOOKUP, CLOSE_PL_WINDOW, MOVE_UP, PLIST_SAVE,
|
|
71 MISC_QUEUE, PLIST_CQUEUE, PLIST_JTF, PLIST_JTT,
|
|
72 PLAYLISTWIN_REMOVE_DEAD_FILES,
|
|
73 PLAYLISTWIN_REFRESH
|
|
74 };
|
|
75
|
|
76 enum {
|
|
77 PLAYLISTWIN_SORT_BYTITLE, PLAYLISTWIN_SORT_BYFILENAME,
|
|
78 PLAYLISTWIN_SORT_BYPATH, PLAYLISTWIN_SORT_BYDATE,
|
|
79 PLAYLISTWIN_SORT_SEL_BYTITLE, PLAYLISTWIN_SORT_SEL_BYFILENAME,
|
|
80 PLAYLISTWIN_SORT_SEL_BYPATH, PLAYLISTWIN_SORT_SEL_BYDATE,
|
|
81 PLAYLISTWIN_SORT_RANDOMIZE, PLAYLISTWIN_SORT_REVERSE
|
|
82 };
|
|
83
|
|
84 GtkWidget *playlistwin;
|
|
85
|
|
86 PlayList_List *playlistwin_list = NULL;
|
|
87 PButton *playlistwin_shade, *playlistwin_close;
|
|
88 Vis *playlistwin_vis;
|
|
89
|
|
90 static gboolean playlistwin_resizing = FALSE;
|
|
91
|
|
92 static GtkItemFactory *playlistwin_popup_menu;
|
|
93 static GtkItemFactory *pladd_menu, *pldel_menu;
|
|
94 static GtkItemFactory *plsel_menu, *plsort_menu;
|
|
95 static GtkItemFactory *pllist_menu;
|
|
96
|
|
97 static GdkPixmap *playlistwin_bg;
|
|
98 static GdkBitmap *playlistwin_mask = NULL;
|
|
99 static GdkGC *playlistwin_gc;
|
|
100
|
|
101 static GtkAccelGroup *playlistwin_accel;
|
|
102
|
|
103 static gboolean playlistwin_hint_flag = FALSE;
|
|
104
|
|
105 static PlaylistSlider *playlistwin_slider = NULL;
|
|
106 static TextBox *playlistwin_time_min, *playlistwin_time_sec;
|
|
107 static TextBox *playlistwin_info, *playlistwin_sinfo;
|
|
108 static SButton *playlistwin_srew, *playlistwin_splay;
|
|
109 static SButton *playlistwin_spause, *playlistwin_sstop;
|
|
110 static SButton *playlistwin_sfwd, *playlistwin_seject;
|
|
111 static SButton *playlistwin_sscroll_up, *playlistwin_sscroll_down;
|
|
112
|
|
113 static GList *playlistwin_wlist = NULL;
|
|
114 static gboolean playlistwin_vis_enabled = FALSE;
|
|
115
|
|
116
|
|
117 static void plsort_menu_callback(gpointer cb_data, guint action,
|
|
118 GtkWidget * w);
|
|
119 static void playlistwin_sub_menu_callback(gpointer cb_data, guint action,
|
|
120 GtkWidget * w);
|
|
121 static void playlistwin_popup_menu_callback(gpointer cb_data, guint action,
|
|
122 GtkWidget * w);
|
|
123
|
|
124 static GtkItemFactoryEntry playlistwin_popup_menu_entries[] = {
|
|
125 {N_("/View Track Details"), NULL,
|
|
126 playlistwin_popup_menu_callback,
|
|
127 MISC_FILEINFO, "<ImageItem>", my_pixbuf},
|
|
128
|
|
129 ITEM_SEPARATOR,
|
|
130
|
|
131 {N_("/Remove Selected"), "Delete",
|
|
132 playlistwin_sub_menu_callback,
|
|
133 SUB_SELECTED, "<Item>", GTK_STOCK_DELETE},
|
|
134
|
|
135 {N_("/Remove Unselected"), NULL,
|
|
136 playlistwin_sub_menu_callback,
|
|
137 SUB_CROP, "<Item>", GTK_STOCK_CUT},
|
|
138
|
|
139 {N_("/Remove All"), NULL,
|
|
140 playlistwin_sub_menu_callback,
|
|
141 SUB_ALL, "<Item>", GTK_STOCK_DELETE},
|
|
142
|
|
143 ITEM_SEPARATOR,
|
|
144
|
|
145 {N_("/Queue Toggle"), "q",
|
|
146 playlistwin_popup_menu_callback,
|
|
147 MISC_QUEUE, "<Item>", NULL},
|
|
148 };
|
|
149
|
|
150 static GtkItemFactoryEntry pladd_menu_entries[] = {
|
|
151 {N_("/Add CD..."), "<shift>c",
|
|
152 mainwin_general_menu_callback,
|
|
153 MAINWIN_GENERAL_ADDCD, "<StockItem>", GTK_STOCK_CDROM},
|
|
154
|
|
155 {N_("/Add Internet Address..."), "<control>h",
|
|
156 mainwin_general_menu_callback,
|
|
157 MAINWIN_GENERAL_PLAYLOCATION, "<StockItem>", GTK_STOCK_NETWORK},
|
|
158
|
|
159 /* GtkFileChooser in SELECT_FOLDER mode is currently BROKEN! */
|
|
160 #if 0
|
|
161 {N_("/Add Folders..."), "d",
|
|
162 mainwin_general_menu_callback,
|
|
163 MAINWIN_GENERAL_PLAYDIRECTORY, "<StockItem>", GTK_STOCK_OPEN},
|
|
164 #endif
|
|
165
|
|
166 {N_("/Add Files..."), "f",
|
|
167 mainwin_general_menu_callback,
|
|
168 MAINWIN_GENERAL_PLAYFILE, "<StockItem>", GTK_STOCK_OPEN},
|
|
169 };
|
|
170
|
|
171 static GtkItemFactoryEntry pldel_menu_entries[] = {
|
|
172 {N_("/Clear Queue"), "<shift>Q",
|
|
173 playlistwin_popup_menu_callback,
|
|
174 PLIST_CQUEUE, "<Item>"},
|
|
175
|
|
176 ITEM_SEPARATOR,
|
|
177
|
|
178 {N_("/Remove Unavailable Files"), NULL,
|
|
179 playlistwin_sub_menu_callback,
|
|
180 PLAYLISTWIN_REMOVE_DEAD_FILES, "<Item>", GTK_STOCK_DELETE},
|
|
181
|
|
182 ITEM_SEPARATOR,
|
|
183
|
|
184 {N_("/Remove All"), NULL,
|
|
185 playlistwin_sub_menu_callback,
|
|
186 SUB_ALL, "<Item>", GTK_STOCK_DELETE},
|
|
187
|
|
188 {N_("/Remove Unselected"), NULL,
|
|
189 playlistwin_sub_menu_callback,
|
|
190 SUB_CROP, "<Item>", GTK_STOCK_DELETE},
|
|
191
|
|
192 {N_("/Remove Selected"), "Delete",
|
|
193 playlistwin_sub_menu_callback,
|
|
194 SUB_SELECTED, "<Item>", GTK_STOCK_DELETE}
|
|
195 };
|
|
196
|
|
197 static GtkItemFactoryEntry pllist_menu_entries[] = {
|
|
198 {N_("/New List"), NULL,
|
|
199 playlistwin_sub_menu_callback,
|
|
200 PLIST_NEW, "<StockItem>", GTK_STOCK_NEW},
|
|
201
|
|
202 ITEM_SEPARATOR,
|
|
203
|
|
204 {N_("/Load List"), "o",
|
|
205 playlistwin_sub_menu_callback,
|
|
206 PLIST_LOAD, "<StockItem>", GTK_STOCK_OPEN},
|
|
207
|
|
208 {N_("/Save List"), "s",
|
|
209 playlistwin_sub_menu_callback,
|
|
210 PLIST_SAVE, "<StockItem>", GTK_STOCK_SAVE},
|
|
211
|
|
212 ITEM_SEPARATOR,
|
|
213
|
|
214 {N_("/Update View"), "F5",
|
|
215 playlistwin_sub_menu_callback,
|
|
216 PLAYLISTWIN_REFRESH, "<StockItem>", GTK_STOCK_REFRESH}
|
|
217 };
|
|
218
|
|
219 static GtkItemFactoryEntry plsel_menu_entries[] = {
|
|
220 {N_("/Invert Selection"), NULL,
|
|
221 playlistwin_sub_menu_callback,
|
|
222 SEL_INV, "<Item>", GTK_STOCK_NETWORK},
|
|
223
|
|
224 ITEM_SEPARATOR,
|
|
225
|
|
226 {N_("/Select None"),"<Ctrl><Shift>A",
|
|
227 playlistwin_sub_menu_callback,
|
|
228 SEL_ZERO, "<Item>", GTK_STOCK_OPEN},
|
|
229
|
|
230 {N_("/Select All"), "<Ctrl>A",
|
|
231 playlistwin_sub_menu_callback,
|
|
232 SEL_ALL, "<Item>", GTK_STOCK_OPEN},
|
|
233 };
|
|
234
|
|
235 static GtkItemFactoryEntry plsort_menu_entries[] = {
|
|
236 {N_("/Randomize List"), NULL, plsort_menu_callback,
|
|
237 PLAYLISTWIN_SORT_RANDOMIZE, "<Item>"},
|
|
238 {N_("/Reverse List"), NULL, plsort_menu_callback,
|
|
239 PLAYLISTWIN_SORT_REVERSE, "<Item>"},
|
|
240 ITEM_SEPARATOR,
|
|
241 {N_("/Sort List"), NULL, NULL, 0, "<Branch>"},
|
|
242 {N_("/Sort List/By Title"), NULL, plsort_menu_callback,
|
|
243 PLAYLISTWIN_SORT_BYTITLE, "<Item>"},
|
|
244 {N_("/Sort List/By Filename"), NULL, plsort_menu_callback,
|
|
245 PLAYLISTWIN_SORT_BYFILENAME, "<Item>"},
|
|
246 {N_("/Sort List/By Path + Filename"), NULL, plsort_menu_callback,
|
|
247 PLAYLISTWIN_SORT_BYPATH, "<Item>"},
|
|
248 {N_("/Sort List/By Date"), NULL, plsort_menu_callback,
|
|
249 PLAYLISTWIN_SORT_BYDATE, "<Item>"},
|
|
250 {N_("/Sort Selection"), NULL, NULL, 0, "<Branch>"},
|
|
251 {N_("/Sort Selection/By Title"), NULL, plsort_menu_callback,
|
|
252 PLAYLISTWIN_SORT_SEL_BYTITLE, "<Item>"},
|
|
253 {N_("/Sort Selection/By Filename"), NULL, plsort_menu_callback,
|
|
254 PLAYLISTWIN_SORT_SEL_BYFILENAME, "<Item>"},
|
|
255 {N_("/Sort Selection/By Path + Filename"), NULL, plsort_menu_callback,
|
|
256 PLAYLISTWIN_SORT_SEL_BYPATH, "<Item>"},
|
|
257 {N_("/Sort Selection/By Date"), NULL, plsort_menu_callback,
|
|
258 PLAYLISTWIN_SORT_SEL_BYDATE, "<Item>"}
|
|
259 };
|
|
260
|
|
261
|
|
262 static void playlistwin_draw_frame(void);
|
|
263
|
|
264
|
|
265 gboolean
|
|
266 playlistwin_is_shaded(void)
|
|
267 {
|
|
268 return cfg.playlist_shaded;
|
|
269 }
|
|
270
|
|
271 gint
|
|
272 playlistwin_get_width(void)
|
|
273 {
|
|
274 return cfg.playlist_width;
|
|
275 }
|
|
276
|
|
277 gint
|
|
278 playlistwin_get_height_unshaded(void)
|
|
279 {
|
|
280 gint height = cfg.playlist_height;
|
|
281 return height;
|
|
282 }
|
|
283
|
|
284 gint
|
|
285 playlistwin_get_height_shaded(void)
|
|
286 {
|
|
287 return PLAYLISTWIN_SHADED_HEIGHT;
|
|
288 }
|
|
289
|
|
290 gint
|
|
291 playlistwin_get_height(void)
|
|
292 {
|
|
293 if (playlistwin_is_shaded())
|
|
294 return playlistwin_get_height_shaded();
|
|
295 else
|
|
296 return playlistwin_get_height_unshaded();
|
|
297 }
|
|
298
|
|
299 void
|
|
300 playlistwin_get_size(gint * width, gint * height)
|
|
301 {
|
|
302 if (width)
|
|
303 *width = playlistwin_get_width();
|
|
304
|
|
305 if (height)
|
|
306 *height = playlistwin_get_height();
|
|
307 }
|
|
308
|
|
309 static void
|
|
310 playlistwin_update_info(void)
|
|
311 {
|
|
312 gchar *text, *sel_text, *tot_text;
|
|
313 gulong selection, total;
|
|
314 gboolean selection_more, total_more;
|
|
315
|
|
316 playlist_get_total_time(&total, &selection, &total_more, &selection_more);
|
|
317
|
|
318 if (selection > 0 || (selection == 0 && !selection_more)) {
|
|
319 if (selection > 3600)
|
|
320 sel_text =
|
|
321 g_strdup_printf("%lu:%-2.2lu:%-2.2lu%s", selection / 3600,
|
|
322 (selection / 60) % 60, selection % 60,
|
|
323 (selection_more ? "+" : ""));
|
|
324 else
|
|
325 sel_text =
|
|
326 g_strdup_printf("%lu:%-2.2lu%s", selection / 60,
|
|
327 selection % 60, (selection_more ? "+" : ""));
|
|
328 }
|
|
329 else
|
|
330 sel_text = g_strdup("?");
|
|
331 if (total > 0 || (total == 0 && !total_more)) {
|
|
332 if (total > 3600)
|
|
333 tot_text =
|
|
334 g_strdup_printf("%lu:%-2.2lu:%-2.2lu%s", total / 3600,
|
|
335 (total / 60) % 60, total % 60,
|
|
336 total_more ? "+" : "");
|
|
337 else
|
|
338 tot_text =
|
|
339 g_strdup_printf("%lu:%-2.2lu%s", total / 60, total % 60,
|
|
340 total_more ? "+" : "");
|
|
341 }
|
|
342 else
|
|
343 tot_text = g_strdup("?");
|
|
344 text = g_strconcat(sel_text, "/", tot_text, NULL);
|
|
345 textbox_set_text(playlistwin_info, text);
|
|
346 g_free(text);
|
|
347 g_free(tot_text);
|
|
348 g_free(sel_text);
|
|
349 }
|
|
350
|
|
351 static void
|
|
352 playlistwin_update_sinfo(void)
|
|
353 {
|
|
354 gchar *posstr, *timestr, *title, *info, *dots;
|
|
355 gint pos, time, max_len;
|
|
356
|
|
357 pos = playlist_get_position();
|
|
358 title = playlist_get_songtitle(pos);
|
|
359 time = playlist_get_songtime(pos);
|
|
360
|
|
361 if (!title) {
|
|
362 textbox_set_text(playlistwin_sinfo, "");
|
|
363 return;
|
|
364 }
|
|
365
|
|
366 if (cfg.show_numbers_in_pl)
|
|
367 posstr = g_strdup_printf("%d. ", pos + 1);
|
|
368 else
|
|
369 posstr = g_strdup("");
|
|
370
|
|
371 max_len = (playlistwin_get_width() - 35) / 5 - strlen(posstr);
|
|
372
|
|
373 if (time != -1) {
|
|
374 timestr = g_strdup_printf(" %d:%-2.2d", time / 60000,
|
|
375 (time / 1000) % 60);
|
|
376 max_len -= strlen(timestr);
|
|
377 }
|
|
378 else
|
|
379 timestr = g_strdup("");
|
|
380
|
|
381 convert_title_text(title);
|
|
382
|
|
383 if (strlen(title) > max_len) {
|
|
384 max_len -= 3;
|
|
385 dots = "...";
|
|
386 }
|
|
387 else
|
|
388 dots = "";
|
|
389
|
|
390 info = g_strdup_printf("%s%-*.*s%s%s", posstr, max_len, max_len,
|
|
391 title, dots, timestr);
|
|
392 g_free(posstr);
|
|
393 g_free(title);
|
|
394 g_free(timestr);
|
|
395
|
|
396 textbox_set_text(playlistwin_sinfo, info);
|
|
397 g_free(info);
|
|
398 }
|
|
399
|
|
400 gboolean
|
|
401 playlistwin_item_visible(gint index)
|
|
402 {
|
|
403 if (index >= playlistwin_list->pl_first
|
|
404 && index <
|
|
405 (playlistwin_list->pl_first + playlistwin_list->pl_num_visible))
|
|
406 return TRUE;
|
|
407 return FALSE;
|
|
408 }
|
|
409
|
|
410 gint
|
|
411 playlistwin_get_toprow(void)
|
|
412 {
|
|
413 if (playlistwin_list)
|
|
414 return (playlistwin_list->pl_first);
|
|
415 return (-1);
|
|
416 }
|
|
417
|
|
418 void
|
|
419 playlistwin_set_toprow(gint toprow)
|
|
420 {
|
|
421 if (playlistwin_list)
|
|
422 playlistwin_list->pl_first = toprow;
|
|
423 playlistwin_update_list();
|
|
424 }
|
|
425
|
|
426 void
|
|
427 playlistwin_update_list(void)
|
|
428 {
|
|
429 g_return_if_fail(playlistwin_list != NULL);
|
|
430
|
|
431 widget_draw(WIDGET(playlistwin_list));
|
|
432 widget_draw(WIDGET(playlistwin_slider));
|
|
433 playlistwin_update_info();
|
|
434 playlistwin_update_sinfo();
|
|
435 /* mainwin_update_jtf(); */
|
|
436 }
|
|
437
|
|
438 #if 0
|
|
439 static void
|
|
440 playlistwin_redraw_list(void)
|
|
441 {
|
|
442 g_return_if_fail(playlistwin_list != NULL);
|
|
443
|
|
444 draw_widget(playlistwin_list);
|
|
445 draw_widget(playlistwin_slider);
|
|
446 }
|
|
447 #endif
|
|
448
|
|
449 static void
|
|
450 playlistwin_set_mask(void)
|
|
451 {
|
|
452 GdkGC *gc;
|
|
453 GdkColor pattern;
|
|
454
|
|
455 if (playlistwin_mask)
|
|
456 g_object_unref(playlistwin_mask);
|
|
457
|
|
458 playlistwin_mask =
|
|
459 gdk_pixmap_new(playlistwin->window, playlistwin_get_width(),
|
|
460 playlistwin_get_height(), 1);
|
|
461 gc = gdk_gc_new(playlistwin_mask);
|
|
462 pattern.pixel = 1;
|
|
463 gdk_gc_set_foreground(gc, &pattern);
|
|
464 gdk_draw_rectangle(playlistwin_mask, gc, TRUE, 0, 0,
|
|
465 playlistwin_get_width(), playlistwin_get_height());
|
|
466 gdk_gc_destroy(gc);
|
|
467
|
|
468 gtk_widget_shape_combine_mask(playlistwin, playlistwin_mask, 0, 0);
|
|
469 }
|
|
470
|
|
471 static void
|
|
472 playlistwin_set_geometry_hints(gboolean shaded)
|
|
473 {
|
|
474 GdkGeometry geometry;
|
|
475 GdkWindowHints mask;
|
|
476
|
|
477 geometry.min_width = PLAYLISTWIN_MIN_WIDTH;
|
|
478 geometry.max_width = G_MAXUINT16;
|
|
479 geometry.base_width = cfg.playlist_width;
|
|
480
|
|
481 geometry.width_inc = PLAYLISTWIN_WIDTH_SNAP;
|
|
482 geometry.height_inc = PLAYLISTWIN_HEIGHT_SNAP;
|
|
483
|
|
484 if (shaded) {
|
|
485 geometry.min_height = PLAYLISTWIN_SHADED_HEIGHT;
|
|
486 geometry.max_height = PLAYLISTWIN_SHADED_HEIGHT;
|
|
487 geometry.base_height = PLAYLISTWIN_SHADED_HEIGHT;
|
|
488 }
|
|
489 else {
|
|
490 geometry.min_height = PLAYLISTWIN_MIN_HEIGHT;
|
|
491 geometry.max_height = G_MAXUINT16;
|
|
492 geometry.base_height = cfg.playlist_height;
|
|
493 }
|
|
494
|
|
495 mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_RESIZE_INC |
|
|
496 GDK_HINT_BASE_SIZE;
|
|
497
|
|
498 gtk_window_set_geometry_hints(GTK_WINDOW(playlistwin),
|
|
499 playlistwin, &geometry, mask);
|
|
500 }
|
|
501
|
|
502 void
|
|
503 playlistwin_set_shade(gboolean shaded)
|
|
504 {
|
|
505 if (cfg.playlist_shaded == shaded)
|
|
506 return;
|
|
507
|
|
508 cfg.playlist_shaded = shaded;
|
|
509
|
|
510 if (shaded) {
|
|
511 widget_show(WIDGET(playlistwin_sinfo));
|
|
512 playlistwin_shade->pb_nx = 128;
|
|
513 playlistwin_shade->pb_ny = 45;
|
|
514 playlistwin_shade->pb_px = 150;
|
|
515 playlistwin_shade->pb_py = 42;
|
|
516 playlistwin_close->pb_nx = 138;
|
|
517 playlistwin_close->pb_ny = 45;
|
|
518 }
|
|
519 else {
|
|
520 widget_hide(WIDGET(playlistwin_sinfo));
|
|
521 playlistwin_shade->pb_nx = 157;
|
|
522 playlistwin_shade->pb_ny = 3;
|
|
523 playlistwin_shade->pb_px = 62;
|
|
524 playlistwin_shade->pb_py = 42;
|
|
525 playlistwin_close->pb_nx = 167;
|
|
526 playlistwin_close->pb_ny = 3;
|
|
527 }
|
|
528
|
|
529 dock_shade(dock_window_list, GTK_WINDOW(playlistwin),
|
|
530 playlistwin_get_height());
|
|
531
|
|
532 playlistwin_set_geometry_hints(cfg.playlist_shaded);
|
|
533
|
|
534 gtk_window_resize(GTK_WINDOW(playlistwin),
|
|
535 cfg.playlist_width,
|
|
536 playlistwin_get_height());
|
|
537
|
|
538 draw_playlist_window(TRUE);
|
|
539 }
|
|
540
|
|
541 static void
|
|
542 playlistwin_set_shade_menu(gboolean shaded)
|
|
543 {
|
|
544 GtkWidget *item;
|
|
545
|
|
546 item = gtk_item_factory_get_widget(mainwin_view_menu,
|
|
547 "/Roll up Playlist Editor");
|
|
548 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), shaded);
|
|
549
|
|
550 playlistwin_set_shade(shaded);
|
|
551 }
|
|
552
|
|
553 void
|
|
554 playlistwin_shade_toggle(void)
|
|
555 {
|
|
556 playlistwin_set_shade_menu(!cfg.playlist_shaded);
|
|
557 }
|
|
558
|
|
559 static void
|
|
560 playlistwin_release(GtkWidget * widget,
|
|
561 GdkEventButton * event,
|
|
562 gpointer callback_data)
|
|
563 {
|
|
564 if (event->button == 3)
|
|
565 return;
|
|
566
|
|
567 gdk_pointer_ungrab(GDK_CURRENT_TIME);
|
|
568 playlistwin_resizing = FALSE;
|
|
569 gdk_flush();
|
|
570
|
|
571 if (dock_is_moving(GTK_WINDOW(playlistwin))) {
|
|
572 dock_move_release(GTK_WINDOW(playlistwin));
|
|
573 #if 0
|
|
574 if (cfg.playlist_transparent)
|
|
575 playlistwin_update_list();
|
|
576 #endif
|
|
577 }
|
|
578 else {
|
|
579 handle_release_cb(playlistwin_wlist, widget, event);
|
|
580 playlist_popup_destroy();
|
|
581 draw_playlist_window(FALSE);
|
|
582 }
|
|
583 }
|
|
584
|
|
585 void
|
|
586 playlistwin_scroll(gint num)
|
|
587 {
|
|
588 playlistwin_list->pl_first += num;
|
|
589 playlistwin_update_list();
|
|
590 }
|
|
591
|
|
592 void
|
|
593 playlistwin_scroll_up_pushed(void)
|
|
594 {
|
|
595 playlistwin_list->pl_first -= 3;
|
|
596 playlistwin_update_list();
|
|
597 }
|
|
598
|
|
599 void
|
|
600 playlistwin_scroll_down_pushed(void)
|
|
601 {
|
|
602 playlistwin_list->pl_first += 3;
|
|
603 playlistwin_update_list();
|
|
604 }
|
|
605
|
|
606 static void
|
|
607 playlistwin_select_all(void)
|
|
608 {
|
|
609 playlist_select_all(TRUE);
|
|
610 playlistwin_list->pl_prev_selected = 0;
|
|
611 playlistwin_list->pl_prev_min = 0;
|
|
612 playlistwin_list->pl_prev_max = playlist_get_length() - 1;
|
|
613 playlistwin_update_list();
|
|
614 }
|
|
615
|
|
616 static void
|
|
617 playlistwin_select_none(void)
|
|
618 {
|
|
619 playlist_select_all(FALSE);
|
|
620 playlistwin_list->pl_prev_selected = -1;
|
|
621 playlistwin_list->pl_prev_min = -1;
|
|
622 playlistwin_update_list();
|
|
623 }
|
|
624
|
|
625 static void
|
|
626 playlistwin_inverse_selection(void)
|
|
627 {
|
|
628 playlist_select_invert_all();
|
|
629 playlistwin_list->pl_prev_selected = -1;
|
|
630 playlistwin_list->pl_prev_min = -1;
|
|
631 playlistwin_update_list();
|
|
632 }
|
|
633
|
|
634 static void
|
|
635 playlistwin_resize(gint width, gint height)
|
|
636 {
|
|
637 gboolean redraw;
|
|
638
|
|
639 g_return_if_fail(width > 0 && height > 0);
|
|
640
|
|
641 cfg.playlist_width = width;
|
|
642
|
|
643 if (!cfg.playlist_shaded)
|
|
644 cfg.playlist_height = height;
|
|
645 else
|
|
646 height = cfg.playlist_height;
|
|
647
|
|
648 /* FIXME: why the fsck are we doing this manually? */
|
|
649 /* adjust widget positions and sizes */
|
|
650
|
|
651 widget_resize(WIDGET(playlistwin_list), width - 31, height - 58);
|
|
652
|
|
653 widget_move(WIDGET(playlistwin_slider), width - 15, 20);
|
|
654 widget_resize(WIDGET(playlistwin_slider), 8, height - 58);
|
|
655
|
|
656 widget_resize(WIDGET(playlistwin_sinfo), width - 35, 14);
|
|
657 playlistwin_update_sinfo();
|
|
658
|
|
659 widget_move(WIDGET(playlistwin_shade), width - 21, 3);
|
|
660 widget_move(WIDGET(playlistwin_close), width - 11, 3);
|
|
661 widget_move(WIDGET(playlistwin_time_min), width - 82, height - 15);
|
|
662 widget_move(WIDGET(playlistwin_time_sec), width - 64, height - 15);
|
|
663 widget_move(WIDGET(playlistwin_info), width - 143, height - 28);
|
|
664 widget_move(WIDGET(playlistwin_srew), width - 144, height - 16);
|
|
665 widget_move(WIDGET(playlistwin_splay), width - 138, height - 16);
|
|
666 widget_move(WIDGET(playlistwin_spause), width - 128, height - 16);
|
|
667 widget_move(WIDGET(playlistwin_sstop), width - 118, height - 16);
|
|
668 widget_move(WIDGET(playlistwin_sfwd), width - 109, height - 16);
|
|
669 widget_move(WIDGET(playlistwin_seject), width - 100, height - 16);
|
|
670 widget_move(WIDGET(playlistwin_sscroll_up), width - 14, height - 35);
|
|
671 widget_move(WIDGET(playlistwin_sscroll_down), width - 14, height - 30);
|
|
672
|
|
673 /* decide if we should show the mini visualizer */
|
|
674 if (playlistwin_get_width() >= 350) {
|
|
675 widget_move(WIDGET(playlistwin_vis), width - 223, height - 26);
|
|
676
|
|
677 if (playlistwin_vis_enabled)
|
|
678 widget_show(WIDGET(playlistwin_vis));
|
|
679 }
|
|
680 else
|
|
681 widget_hide(WIDGET(playlistwin_vis));
|
|
682
|
|
683 g_object_unref(playlistwin_bg);
|
|
684 playlistwin_bg = gdk_pixmap_new(playlistwin->window, width, height, -1);
|
|
685 playlistwin_set_mask();
|
|
686
|
|
687 widget_list_lock(playlistwin_wlist);
|
|
688
|
|
689 widget_list_change_pixmap(playlistwin_wlist, playlistwin_bg);
|
|
690 playlistwin_draw_frame();
|
|
691 widget_list_draw(playlistwin_wlist, &redraw, TRUE);
|
|
692 widget_list_clear_redraw(playlistwin_wlist);
|
|
693
|
|
694 widget_list_unlock(playlistwin_wlist);
|
|
695
|
|
696 gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0);
|
|
697 gdk_window_clear(playlistwin->window);
|
|
698 }
|
|
699
|
|
700
|
|
701
|
|
702 static void
|
|
703 playlistwin_motion(GtkWidget * widget,
|
|
704 GdkEventMotion * event,
|
|
705 gpointer callback_data)
|
|
706 {
|
|
707 XEvent ev;
|
|
708
|
|
709 if (dock_is_moving(GTK_WINDOW(playlistwin))) {
|
|
710 dock_move_motion(GTK_WINDOW(playlistwin), event);
|
|
711 }
|
|
712 else {
|
|
713 handle_motion_cb(playlistwin_wlist, widget, event);
|
|
714 draw_playlist_window(FALSE);
|
|
715 }
|
|
716 gdk_flush();
|
|
717 while (XCheckMaskEvent(GDK_DISPLAY(), ButtonMotionMask, &ev));
|
|
718 }
|
|
719
|
|
720 static void
|
|
721 playlistwin_show_filebrowser(void)
|
|
722 {
|
|
723 util_run_filebrowser(NO_PLAY_BUTTON);
|
|
724 }
|
|
725
|
|
726 #if 0
|
|
727 static void
|
|
728 playlistwin_add_dir_handler(const gchar * dir)
|
|
729 {
|
|
730 g_free(cfg.filesel_path);
|
|
731 cfg.filesel_path = g_strdup(dir);
|
|
732 playlist_add_dir(dir);
|
|
733 }
|
|
734 #endif
|
|
735
|
|
736 static void
|
|
737 playlistwin_fileinfo(void)
|
|
738 {
|
|
739 /* Show the first selected file, or the current file if nothing is
|
|
740 * selected */
|
|
741 GList *list = playlist_get_selected();
|
|
742 if (list) {
|
|
743 playlist_fileinfo(GPOINTER_TO_INT(list->data));
|
|
744 g_list_free(list);
|
|
745 }
|
|
746 else
|
|
747 playlist_fileinfo_current();
|
|
748 }
|
|
749
|
|
750 static void
|
|
751 menu_set_item_sensitive(GtkItemFactory * item_factory,
|
|
752 const gchar * path,
|
|
753 gboolean sensitive)
|
|
754 {
|
|
755 GtkWidget *item = gtk_item_factory_get_widget(item_factory, path);
|
|
756 gtk_widget_set_sensitive(item, sensitive);
|
|
757 }
|
|
758
|
|
759 /* FIXME: broken */
|
|
760 static void
|
|
761 playlistwin_set_sensitive_sortmenu(void)
|
|
762 {
|
|
763 gboolean set = playlist_get_num_selected() > 1;
|
|
764 menu_set_item_sensitive(plsort_menu, "/Sort Selection/By Title", set);
|
|
765 menu_set_item_sensitive(plsort_menu, "/Sort Selection/By Filename", set);
|
|
766 menu_set_item_sensitive(plsort_menu, "/Sort Selection/By Path + Filename", set);
|
|
767 menu_set_item_sensitive(plsort_menu, "/Sort Selection/By Date", set);
|
|
768 }
|
|
769
|
|
770 static void
|
|
771 show_playlist_save_error(GtkWindow * parent,
|
|
772 const gchar * filename)
|
|
773 {
|
|
774 GtkWidget *dialog;
|
|
775
|
|
776 g_return_if_fail(GTK_IS_WINDOW(parent));
|
|
777 g_return_if_fail(filename != NULL);
|
|
778
|
|
779 dialog = gtk_message_dialog_new(GTK_WINDOW(parent),
|
|
780 GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
781 GTK_MESSAGE_ERROR,
|
|
782 GTK_BUTTONS_OK,
|
|
783 _("Error writing playlist \"%s\": %s"),
|
|
784 filename, strerror(errno));
|
|
785
|
|
786 gtk_dialog_run(GTK_DIALOG(dialog));
|
|
787 gtk_widget_destroy(dialog);
|
|
788 }
|
|
789
|
|
790 static gboolean
|
|
791 show_playlist_overwrite_prompt(GtkWindow * parent,
|
|
792 const gchar * filename)
|
|
793 {
|
|
794 GtkWidget *dialog;
|
|
795 gint result;
|
|
796
|
|
797 g_return_val_if_fail(GTK_IS_WINDOW(parent), FALSE);
|
|
798 g_return_val_if_fail(filename != NULL, FALSE);
|
|
799
|
|
800 dialog = gtk_message_dialog_new(GTK_WINDOW(parent),
|
|
801 GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
802 GTK_MESSAGE_QUESTION,
|
|
803 GTK_BUTTONS_YES_NO,
|
|
804 _("%s already exist. Continue?"),
|
|
805 filename);
|
|
806
|
|
807 result = gtk_dialog_run(GTK_DIALOG(dialog));
|
|
808 gtk_widget_destroy(dialog);
|
|
809
|
|
810 return (result == GTK_RESPONSE_YES);
|
|
811 }
|
|
812
|
|
813 static void
|
|
814 show_playlist_save_format_error(GtkWindow * parent,
|
|
815 const gchar * filename)
|
|
816 {
|
|
817 const gchar *markup =
|
|
818 N_("<b><big>Unable to save playlist.</big></b>\n\n"
|
|
819 "Unknown file type for '%s'.\n");
|
|
820
|
|
821 GtkWidget *dialog;
|
|
822
|
|
823 g_return_if_fail(GTK_IS_WINDOW(parent));
|
|
824 g_return_if_fail(filename != NULL);
|
|
825
|
|
826 dialog =
|
|
827 gtk_message_dialog_new_with_markup(GTK_WINDOW(parent),
|
|
828 GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
829 GTK_MESSAGE_ERROR,
|
|
830 GTK_BUTTONS_OK,
|
|
831 _(markup),
|
|
832 filename);
|
|
833 gtk_dialog_run(GTK_DIALOG(dialog));
|
|
834 gtk_widget_destroy(dialog);
|
|
835 }
|
|
836
|
|
837 static void
|
|
838 playlistwin_save_playlist(const gchar * filename)
|
|
839 {
|
|
840 PlaylistFormat format;
|
|
841
|
|
842 format = playlist_format_get_from_name(filename);
|
|
843 if (format == PLAYLIST_FORMAT_UNKNOWN) {
|
|
844 show_playlist_save_format_error(GTK_WINDOW(playlistwin), filename);
|
|
845 return;
|
|
846 }
|
|
847
|
|
848 str_replace_in(&cfg.playlist_path, g_path_get_dirname(filename));
|
|
849
|
|
850 if (g_file_test(filename, G_FILE_TEST_IS_REGULAR))
|
|
851 if (!show_playlist_overwrite_prompt(GTK_WINDOW(playlistwin), filename))
|
|
852 return;
|
|
853
|
|
854 if (!playlist_save(filename, format))
|
|
855 show_playlist_save_error(GTK_WINDOW(playlistwin), filename);
|
|
856 }
|
|
857
|
|
858 #if 0
|
|
859 static void
|
|
860 playlistwin_save_current(void)
|
|
861 {
|
|
862 const gchar *filename;
|
|
863
|
|
864 if (!(filename = playlist_get_current_name()))
|
|
865 return;
|
|
866
|
|
867 playlistwin_save_playlist(filename);
|
|
868 }
|
|
869 #endif
|
|
870
|
|
871 static void
|
|
872 playlistwin_load_playlist(const gchar * filename)
|
|
873 {
|
|
874 g_return_if_fail(filename != NULL);
|
|
875
|
|
876 str_replace_in(&cfg.playlist_path, g_strdup(filename));
|
|
877
|
|
878 playlist_clear();
|
|
879 mainwin_clear_song_info();
|
|
880 mainwin_set_info_text();
|
|
881
|
|
882 playlist_load(filename);
|
|
883 playlist_set_current_name(filename);
|
|
884 }
|
|
885
|
|
886 static gchar *
|
|
887 playlist_file_selection(const gchar * title,
|
|
888 gboolean save,
|
|
889 const gchar * default_filename)
|
|
890 {
|
|
891 GtkWidget *dialog, *button;
|
|
892 gchar *filename;
|
|
893
|
|
894 g_return_val_if_fail(title != NULL, NULL);
|
|
895
|
|
896 dialog = gtk_file_chooser_dialog_new(title, GTK_WINDOW(mainwin),
|
|
897 save ? GTK_FILE_CHOOSER_ACTION_SAVE :
|
|
898 GTK_FILE_CHOOSER_ACTION_OPEN, NULL);
|
|
899 if (default_filename)
|
|
900 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),
|
|
901 default_filename);
|
|
902
|
|
903 button = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL,
|
|
904 GTK_RESPONSE_REJECT);
|
|
905 gtk_button_set_use_stock(GTK_BUTTON(button), TRUE);
|
|
906 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
|
|
907
|
|
908 button = gtk_dialog_add_button(GTK_DIALOG(dialog),
|
|
909 save ? GTK_STOCK_SAVE : GTK_STOCK_OPEN,
|
|
910 GTK_RESPONSE_ACCEPT);
|
|
911 gtk_button_set_use_stock(GTK_BUTTON(button), TRUE);
|
|
912 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
|
|
913
|
|
914 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
|
|
915 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
|
|
916 else
|
|
917 filename = NULL;
|
|
918
|
|
919 gtk_widget_destroy(dialog);
|
|
920
|
|
921 return filename;
|
|
922 }
|
|
923
|
|
924 void
|
|
925 playlistwin_select_playlist_to_load(const gchar * default_filename)
|
|
926 {
|
|
927 gchar *filename =
|
|
928 playlist_file_selection(_("Load Playlist"), FALSE, default_filename);
|
|
929
|
|
930 if (filename) {
|
|
931 playlistwin_load_playlist(filename);
|
|
932 g_free(filename);
|
|
933 }
|
|
934 }
|
|
935
|
|
936 static void
|
|
937 playlistwin_select_playlist_to_save(const gchar * default_filename)
|
|
938 {
|
|
939 gchar *filename =
|
|
940 playlist_file_selection(_("Save Playlist"), TRUE, default_filename);
|
|
941
|
|
942 if (filename) {
|
|
943 /* Default to M3U if no filename has extension */
|
|
944
|
|
945 /* NOTE: This doesn't work correctly for hidden files
|
|
946 - descender */
|
|
947 if (!strchr(filename, '.')) {
|
|
948 gchar *tmpstr = filename;
|
|
949 filename = g_strconcat(filename, ".m3u", NULL);
|
|
950 g_free(tmpstr);
|
|
951 }
|
|
952
|
|
953 playlistwin_save_playlist(filename);
|
|
954 g_free(filename);
|
|
955 }
|
|
956 }
|
|
957
|
|
958 static void
|
|
959 playlistwin_run_dirbrowser(void)
|
|
960 {
|
|
961 mainwin_run_dirbrowser();
|
|
962 }
|
|
963
|
|
964 static gboolean
|
|
965 inside_sensitive_widgets(gint x, gint y)
|
|
966 {
|
|
967 return (widget_contains(WIDGET(playlistwin_list), x, y) ||
|
|
968 widget_contains(WIDGET(playlistwin_slider), x, y) ||
|
|
969 widget_contains(WIDGET(playlistwin_close), x, y) ||
|
|
970 widget_contains(WIDGET(playlistwin_shade), x, y) ||
|
|
971 widget_contains(WIDGET(playlistwin_time_min), x, y) ||
|
|
972 widget_contains(WIDGET(playlistwin_time_sec), x, y) ||
|
|
973 widget_contains(WIDGET(playlistwin_info), x, y) ||
|
|
974 widget_contains(WIDGET(playlistwin_vis), x, y) ||
|
|
975 widget_contains(WIDGET(playlistwin_srew), x, y) ||
|
|
976 widget_contains(WIDGET(playlistwin_splay), x, y) ||
|
|
977 widget_contains(WIDGET(playlistwin_spause), x, y) ||
|
|
978 widget_contains(WIDGET(playlistwin_sstop), x, y) ||
|
|
979 widget_contains(WIDGET(playlistwin_sfwd), x, y) ||
|
|
980 widget_contains(WIDGET(playlistwin_seject), x, y) ||
|
|
981 widget_contains(WIDGET(playlistwin_sscroll_up), x, y) ||
|
|
982 widget_contains(WIDGET(playlistwin_sscroll_down), x, y));
|
|
983 }
|
|
984
|
|
985 #define REGION_L(x1,x2,y1,y2) \
|
|
986 (event->x >= (x1) && event->x < (x2) && \
|
|
987 event->y >= cfg.playlist_height - (y1) && \
|
|
988 event->y < cfg.playlist_height - (y2))
|
|
989
|
|
990 #define REGION_R(x1,x2,y1,y2) \
|
|
991 (event->x >= playlistwin_get_width() - (x1) && \
|
|
992 event->x < playlistwin_get_width() - (x2) && \
|
|
993 event->y >= cfg.playlist_height - (y1) && \
|
|
994 event->y < cfg.playlist_height - (y2))
|
|
995
|
|
996 static void
|
|
997 playlistwin_scrolled(GtkWidget * widget,
|
|
998 GdkEventScroll * event,
|
|
999 gpointer callback_data)
|
|
1000 {
|
|
1001
|
|
1002 if (event->direction == GDK_SCROLL_DOWN)
|
|
1003 playlistwin_scroll(cfg.scroll_pl_by);
|
|
1004
|
|
1005 if (event->direction == GDK_SCROLL_UP)
|
|
1006 playlistwin_scroll(-cfg.scroll_pl_by);
|
|
1007
|
|
1008 }
|
|
1009
|
|
1010
|
|
1011
|
|
1012
|
|
1013 static gboolean
|
|
1014 playlistwin_press(GtkWidget * widget,
|
|
1015 GdkEventButton * event,
|
|
1016 gpointer callback_data)
|
|
1017 {
|
|
1018 gboolean grab = TRUE;
|
|
1019 gint xpos, ypos;
|
|
1020 GtkWidget *_menu;
|
|
1021 GtkRequisition req;
|
|
1022
|
|
1023 gtk_window_get_position(GTK_WINDOW(playlistwin), &xpos, &ypos);
|
|
1024
|
|
1025 if (event->button == 1 && !cfg.show_wm_decorations &&
|
|
1026 ((!cfg.playlist_shaded &&
|
|
1027 event->x > playlistwin_get_width() - 20 &&
|
|
1028 event->y > cfg.playlist_height - 20) ||
|
|
1029 (cfg.playlist_shaded &&
|
|
1030 event->x >= playlistwin_get_width() - 31 &&
|
|
1031 event->x < playlistwin_get_width() - 22))) {
|
|
1032
|
|
1033 /* NOTE: Workaround for bug #214 */
|
|
1034 if (event->type != GDK_2BUTTON_PRESS &&
|
|
1035 event->type != GDK_3BUTTON_PRESS) {
|
|
1036 /* resize area */
|
|
1037 playlistwin_resizing = TRUE;
|
|
1038 gtk_window_begin_resize_drag(GTK_WINDOW(widget),
|
|
1039 GDK_WINDOW_EDGE_SOUTH_EAST,
|
|
1040 event->button,
|
|
1041 event->x + xpos, event->y + ypos,
|
|
1042 event->time);
|
|
1043 }
|
|
1044 grab = FALSE;
|
|
1045 }
|
|
1046 else if (event->button == 1 && REGION_L(12, 37, 29, 11)) {
|
|
1047 /* ADD button menu */
|
|
1048
|
|
1049 _menu = GTK_WIDGET(pladd_menu->widget);
|
|
1050 if (!GTK_WIDGET_REALIZED(_menu)) gtk_widget_realize(_menu);
|
|
1051 gtk_widget_size_request(_menu, &req);
|
|
1052 gtk_item_factory_popup_with_data(pladd_menu,
|
|
1053 NULL, NULL,
|
|
1054 xpos+12,
|
|
1055 (ypos + playlistwin_get_height()) - 8 - req.height, 1, event->time);
|
|
1056 grab = FALSE;
|
|
1057 }
|
|
1058 else if (event->button == 1 && REGION_L(41, 66, 29, 11)) {
|
|
1059 /* SUB button menu */
|
|
1060 _menu = GTK_WIDGET(pldel_menu->widget);
|
|
1061 if (!GTK_WIDGET_REALIZED(_menu)) gtk_widget_realize(_menu);
|
|
1062 gtk_widget_size_request(_menu, &req);
|
|
1063 gtk_item_factory_popup_with_data(pldel_menu,
|
|
1064 NULL, NULL,
|
|
1065 xpos+40,
|
|
1066 (ypos + playlistwin_get_height()) - 8 - req.height, 1, event->time);
|
|
1067 grab = FALSE;
|
|
1068 }
|
|
1069 else if (event->button == 1 && REGION_L(70, 95, 29, 11)) {
|
|
1070 /* SEL button menu */
|
|
1071 _menu = GTK_WIDGET(plsel_menu->widget);
|
|
1072 if (!GTK_WIDGET_REALIZED(_menu)) gtk_widget_realize(_menu);
|
|
1073 gtk_widget_size_request(_menu, &req);
|
|
1074 gtk_item_factory_popup_with_data(plsel_menu,
|
|
1075 NULL, NULL,
|
|
1076 xpos+68,
|
|
1077 (ypos + playlistwin_get_height()) - 8 - req.height, 1, event->time);
|
|
1078
|
|
1079 grab = FALSE;
|
|
1080 }
|
|
1081 else if (event->button == 1 && REGION_L(99, 124, 29, 11)) {
|
|
1082 /* MISC button menu */
|
|
1083 _menu = GTK_WIDGET(plsort_menu->widget);
|
|
1084 if (!GTK_WIDGET_REALIZED(_menu)) gtk_widget_realize(_menu);
|
|
1085 gtk_widget_size_request(_menu, &req);
|
|
1086 gtk_item_factory_popup_with_data(plsort_menu,
|
|
1087 NULL, NULL,
|
|
1088 xpos+100,
|
|
1089 (ypos + playlistwin_get_height()) - 8 - req.height, 1, event->time);
|
|
1090 grab = FALSE;
|
|
1091 }
|
|
1092 else if (event->button == 1 && REGION_R(46, 23, 29, 11)) {
|
|
1093 /* LIST button menu */
|
|
1094 _menu = GTK_WIDGET(pllist_menu->widget);
|
|
1095 if (!GTK_WIDGET_REALIZED(_menu)) gtk_widget_realize(_menu);
|
|
1096 gtk_widget_size_request(_menu, &req);
|
|
1097 gtk_item_factory_popup_with_data(pllist_menu,
|
|
1098 NULL, NULL,
|
|
1099 xpos + playlistwin_get_width() - req.width - 12,
|
|
1100 (ypos + playlistwin_get_height()) - 8 - req.height, 1, event->time);
|
|
1101 grab = FALSE;
|
|
1102 }
|
|
1103 else if (event->button == 1 && REGION_R(82, 54, 15, 9)) {
|
|
1104 if (cfg.timer_mode == TIMER_ELAPSED)
|
|
1105 cfg.timer_mode = TIMER_REMAINING;
|
|
1106 else
|
|
1107 cfg.timer_mode = TIMER_ELAPSED;
|
|
1108 }
|
|
1109 else if (event->button == 2 && (event->type == GDK_BUTTON_PRESS) &&
|
|
1110 widget_contains(WIDGET(playlistwin_list), event->x, event->y)) {
|
|
1111 gtk_selection_convert(widget, GDK_SELECTION_PRIMARY,
|
|
1112 GDK_TARGET_STRING, event->time);
|
|
1113 }
|
|
1114 else if (playlistwin_get_width() >= 350 && REGION_R(223, 151, 26, 10)) {
|
|
1115 if (event->button == 1) {
|
|
1116 cfg.vis_type++;
|
|
1117 if (cfg.vis_type > VIS_OFF)
|
|
1118 cfg.vis_type = VIS_ANALYZER;
|
|
1119 mainwin_vis_set_type(cfg.vis_type);
|
|
1120 }
|
|
1121 else if (event->button == 3) {
|
|
1122 gint mx, my;
|
|
1123 GdkModifierType modmask;
|
|
1124
|
|
1125 gdk_window_get_pointer(NULL, &mx, &my, &modmask);
|
|
1126 util_item_factory_popup(mainwin_vis_menu, mx, my, 3, event->time);
|
|
1127 grab = FALSE;
|
|
1128 }
|
|
1129 }
|
|
1130 else if (event->button == 1 && event->type == GDK_BUTTON_PRESS &&
|
|
1131 !inside_sensitive_widgets(event->x, event->y) && event->y < 14) {
|
|
1132 gdk_window_raise(playlistwin->window);
|
|
1133 dock_move_press(dock_window_list, GTK_WINDOW(playlistwin), event,
|
|
1134 FALSE);
|
|
1135 }
|
|
1136 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS &&
|
|
1137 !inside_sensitive_widgets(event->x, event->y)
|
|
1138 && event->y < 14) {
|
|
1139 /* double click on title bar */
|
|
1140 playlistwin_shade_toggle();
|
|
1141 if (dock_is_moving(GTK_WINDOW(playlistwin)))
|
|
1142 dock_move_release(GTK_WINDOW(playlistwin));
|
|
1143 return TRUE;
|
|
1144 }
|
|
1145 else if (event->button == 3 &&
|
|
1146 !(widget_contains(WIDGET(playlistwin_list), event->x, event->y) ||
|
|
1147 (event->y >= cfg.playlist_height - 29 &&
|
|
1148 event->y < cfg.playlist_height - 11 &&
|
|
1149 ((event->x >= 12 && event->x < 37) ||
|
|
1150 (event->x >= 41 && event->x < 66) ||
|
|
1151 (event->x >= 70 && event->x < 95) ||
|
|
1152 (event->x >= 99 && event->x < 124) ||
|
|
1153 (event->x >= playlistwin_get_width() - 46 &&
|
|
1154 event->x < playlistwin_get_width() - 23))))) {
|
|
1155 /*
|
|
1156 * Pop up the main menu a few pixels down to avoid
|
|
1157 * anything to be selected initially.
|
|
1158 */
|
|
1159 util_item_factory_popup(mainwin_general_menu, event->x_root,
|
|
1160 event->y_root + 2, 3, event->time);
|
|
1161 grab = FALSE;
|
|
1162 }
|
|
1163 else if (event->button == 3 &&
|
|
1164 widget_contains(WIDGET(playlistwin_list), event->x, event->y)) {
|
|
1165 /* popup menu */
|
|
1166 playlistwin_set_sensitive_sortmenu();
|
|
1167 gtk_item_factory_popup(playlistwin_popup_menu,
|
|
1168 event->x_root, event->y_root + 5,
|
|
1169 3, event->time);
|
|
1170 grab = FALSE;
|
|
1171 }
|
|
1172 else {
|
|
1173 handle_press_cb(playlistwin_wlist, widget, event);
|
|
1174 draw_playlist_window(FALSE);
|
|
1175 }
|
|
1176
|
|
1177 if (grab)
|
|
1178 gdk_pointer_grab(playlistwin->window, FALSE,
|
|
1179 GDK_BUTTON_MOTION_MASK | GDK_BUTTON_RELEASE_MASK |
|
|
1180 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
|
|
1181 GDK_BUTTON1_MOTION_MASK, NULL, NULL,
|
|
1182 GDK_CURRENT_TIME);
|
|
1183
|
|
1184 return FALSE;
|
|
1185 }
|
|
1186
|
|
1187 static gboolean
|
|
1188 playlistwin_focus_in(GtkWidget * widget, GdkEvent * event, gpointer data)
|
|
1189 {
|
|
1190 playlistwin_close->pb_allow_draw = TRUE;
|
|
1191 playlistwin_shade->pb_allow_draw = TRUE;
|
|
1192 draw_playlist_window(TRUE);
|
|
1193 return FALSE;
|
|
1194 }
|
|
1195
|
|
1196 static gboolean
|
|
1197 playlistwin_focus_out(GtkWidget * widget,
|
|
1198 GdkEventButton * event, gpointer data)
|
|
1199 {
|
|
1200 playlistwin_close->pb_allow_draw = FALSE;
|
|
1201 playlistwin_shade->pb_allow_draw = FALSE;
|
|
1202 draw_playlist_window(TRUE);
|
|
1203 return FALSE;
|
|
1204 }
|
|
1205
|
|
1206 static gboolean
|
|
1207 playlistwin_configure(GtkWidget * window,
|
|
1208 GdkEventConfigure * event, gpointer data)
|
|
1209 {
|
|
1210 if (!GTK_WIDGET_VISIBLE(window))
|
|
1211 return FALSE;
|
|
1212
|
|
1213 cfg.playlist_x = event->x;
|
|
1214 cfg.playlist_y = event->y;
|
|
1215
|
|
1216 if (playlistwin_resizing) {
|
|
1217 if (event->width != playlistwin_get_width() ||
|
|
1218 event->height != playlistwin_get_height())
|
|
1219 playlistwin_resize(event->width, event->height);
|
|
1220 }
|
|
1221 return TRUE;
|
|
1222 }
|
|
1223
|
|
1224 void
|
|
1225 playlistwin_set_back_pixmap(void)
|
|
1226 {
|
|
1227 gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0);
|
|
1228 gdk_window_clear(playlistwin->window);
|
|
1229 }
|
|
1230
|
|
1231 static gboolean
|
|
1232 playlistwin_delete(GtkWidget * w, gpointer data)
|
|
1233 {
|
|
1234 playlistwin_hide();
|
|
1235 return TRUE;
|
|
1236 }
|
|
1237
|
|
1238 static void
|
|
1239 playlistwin_keypress_up_down_handler(PlayList_List * pl,
|
|
1240 gboolean up, guint state)
|
|
1241 {
|
|
1242 if ((state & GDK_MOD1_MASK) && (state & GDK_SHIFT_MASK))
|
|
1243 return;
|
|
1244 if (!(state & GDK_MOD1_MASK))
|
|
1245 playlist_select_all(FALSE);
|
|
1246
|
|
1247 if (pl->pl_prev_selected == -1 ||
|
|
1248 (!playlistwin_item_visible(pl->pl_prev_selected) &&
|
|
1249 !(state & GDK_SHIFT_MASK && pl->pl_prev_min != -1))) {
|
|
1250 pl->pl_prev_selected = pl->pl_first;
|
|
1251 }
|
|
1252 else if (state & GDK_SHIFT_MASK) {
|
|
1253 if (pl->pl_prev_min == -1) {
|
|
1254 pl->pl_prev_max = pl->pl_prev_selected;
|
|
1255 pl->pl_prev_min = pl->pl_prev_selected;
|
|
1256 }
|
|
1257 pl->pl_prev_max += (up ? -1 : 1);
|
|
1258 pl->pl_prev_max =
|
|
1259 CLAMP(pl->pl_prev_max, 0, playlist_get_length() - 1);
|
|
1260
|
|
1261 pl->pl_first = MIN(pl->pl_first, pl->pl_prev_max);
|
|
1262 pl->pl_first = MAX(pl->pl_first, pl->pl_prev_max -
|
|
1263 pl->pl_num_visible + 1);
|
|
1264 playlist_select_range(pl->pl_prev_min, pl->pl_prev_max, TRUE);
|
|
1265 return;
|
|
1266 }
|
|
1267 else if (state & GDK_MOD1_MASK) {
|
|
1268 if (up)
|
|
1269 playlist_list_move_up(pl);
|
|
1270 else
|
|
1271 playlist_list_move_down(pl);
|
|
1272 if (pl->pl_prev_min < pl->pl_first)
|
|
1273 pl->pl_first = pl->pl_prev_min;
|
|
1274 else if (pl->pl_prev_max >= (pl->pl_first + pl->pl_num_visible))
|
|
1275 pl->pl_first = pl->pl_prev_max - pl->pl_num_visible + 1;
|
|
1276 return;
|
|
1277 }
|
|
1278 else if (up)
|
|
1279 pl->pl_prev_selected--;
|
|
1280 else
|
|
1281 pl->pl_prev_selected++;
|
|
1282
|
|
1283 pl->pl_prev_selected =
|
|
1284 CLAMP(pl->pl_prev_selected, 0, playlist_get_length() - 1);
|
|
1285
|
|
1286 if (pl->pl_prev_selected < pl->pl_first)
|
|
1287 pl->pl_first--;
|
|
1288 else if (pl->pl_prev_selected >= (pl->pl_first + pl->pl_num_visible))
|
|
1289 pl->pl_first++;
|
|
1290
|
|
1291 playlist_select_range(pl->pl_prev_selected, pl->pl_prev_selected, TRUE);
|
|
1292 pl->pl_prev_min = -1;
|
|
1293
|
|
1294 }
|
|
1295
|
|
1296 /* FIXME: Handle the keys through menu */
|
|
1297
|
|
1298 static gboolean
|
|
1299 playlistwin_keypress(GtkWidget * w, GdkEventKey * event, gpointer data)
|
|
1300 {
|
|
1301 guint keyval;
|
|
1302 gboolean refresh = FALSE;
|
|
1303
|
|
1304 if (cfg.playlist_shaded)
|
|
1305 return FALSE;
|
|
1306
|
|
1307 switch (keyval = event->keyval) {
|
|
1308 case GDK_KP_Up:
|
|
1309 case GDK_KP_Down:
|
|
1310 case GDK_Up:
|
|
1311 case GDK_Down:
|
|
1312 playlistwin_keypress_up_down_handler(playlistwin_list,
|
|
1313 keyval == GDK_Up
|
|
1314 || keyval == GDK_KP_Up,
|
|
1315 event->state);
|
|
1316 refresh = TRUE;
|
|
1317 break;
|
|
1318 case GDK_Page_Up:
|
|
1319 playlistwin_scroll(-playlistwin_list->pl_num_visible);
|
|
1320 refresh = TRUE;
|
|
1321 break;
|
|
1322 case GDK_Page_Down:
|
|
1323 playlistwin_scroll(playlistwin_list->pl_num_visible);
|
|
1324 refresh = TRUE;
|
|
1325 break;
|
|
1326 case GDK_Home:
|
|
1327 playlistwin_list->pl_first = 0;
|
|
1328 refresh = TRUE;
|
|
1329 break;
|
|
1330 case GDK_End:
|
|
1331 playlistwin_list->pl_first =
|
|
1332 playlist_get_length() - playlistwin_list->pl_num_visible;
|
|
1333 refresh = TRUE;
|
|
1334 break;
|
|
1335 case GDK_Return:
|
|
1336 if (playlistwin_list->pl_prev_selected > -1
|
|
1337 && playlistwin_item_visible(playlistwin_list->pl_prev_selected)) {
|
|
1338 playlist_set_position(playlistwin_list->pl_prev_selected);
|
|
1339 if (!bmp_playback_get_playing())
|
|
1340 bmp_playback_initiate();
|
|
1341 }
|
|
1342 break;
|
|
1343 case GDK_3:
|
|
1344 if (event->state & GDK_CONTROL_MASK)
|
|
1345 playlistwin_fileinfo();
|
|
1346 break;
|
|
1347 case GDK_Delete:
|
|
1348 if (event->state & GDK_CONTROL_MASK)
|
|
1349 playlist_delete(TRUE);
|
|
1350 else
|
|
1351 playlist_delete(FALSE);
|
|
1352 break;
|
|
1353 case GDK_Insert:
|
|
1354 if (event->state & GDK_SHIFT_MASK)
|
|
1355 playlistwin_run_dirbrowser();
|
|
1356 else if (event->state & GDK_MOD1_MASK)
|
|
1357 mainwin_show_add_url_window();
|
|
1358 else
|
|
1359 playlistwin_show_filebrowser();
|
|
1360 break;
|
|
1361 case GDK_Escape:
|
|
1362 mainwin_minimize_cb();
|
|
1363 break;
|
|
1364 default:
|
|
1365 return FALSE;
|
|
1366 }
|
|
1367
|
|
1368 if (refresh)
|
|
1369 playlistwin_update_list();
|
|
1370
|
|
1371 return TRUE;
|
|
1372 }
|
|
1373
|
|
1374 static void
|
|
1375 playlistwin_draw_frame(void)
|
|
1376 {
|
|
1377 gboolean focus =
|
|
1378 gtk_window_has_toplevel_focus(GTK_WINDOW(playlistwin)) ||
|
|
1379 !cfg.dim_titlebar;
|
|
1380
|
|
1381 if (cfg.playlist_shaded) {
|
|
1382 skin_draw_playlistwin_shaded(bmp_active_skin,
|
|
1383 playlistwin_bg, playlistwin_gc,
|
|
1384 playlistwin_get_width(), focus);
|
|
1385 }
|
|
1386 else {
|
|
1387 skin_draw_playlistwin_frame(bmp_active_skin,
|
|
1388 playlistwin_bg, playlistwin_gc,
|
|
1389 playlistwin_get_width(),
|
|
1390 cfg.playlist_height, focus);
|
|
1391 }
|
|
1392 }
|
|
1393
|
|
1394 void
|
|
1395 draw_playlist_window(gboolean force)
|
|
1396 {
|
|
1397 gboolean redraw;
|
|
1398 GList *wl;
|
|
1399 Widget *w;
|
|
1400
|
|
1401 if (force)
|
|
1402 playlistwin_draw_frame();
|
|
1403
|
|
1404 widget_list_lock(playlistwin_wlist);
|
|
1405 widget_list_draw(playlistwin_wlist, &redraw, force);
|
|
1406
|
|
1407 if (redraw || force) {
|
|
1408 if (force) {
|
|
1409 gdk_window_clear(playlistwin->window);
|
|
1410 }
|
|
1411 else {
|
|
1412 for (wl = playlistwin_wlist; wl; wl = g_list_next(wl)) {
|
|
1413 w = WIDGET(wl->data);
|
|
1414 if (w->redraw && w->visible) {
|
|
1415 gdk_window_clear_area(playlistwin->window, w->x, w->y,
|
|
1416 w->width, w->height);
|
|
1417 w->redraw = FALSE;
|
|
1418 }
|
|
1419 }
|
|
1420 }
|
|
1421
|
|
1422 gdk_flush();
|
|
1423 }
|
|
1424
|
|
1425 widget_list_unlock(playlistwin_wlist);
|
|
1426 }
|
|
1427
|
|
1428
|
|
1429 void
|
|
1430 playlistwin_hide_timer(void)
|
|
1431 {
|
|
1432 textbox_set_text(playlistwin_time_min, " ");
|
|
1433 textbox_set_text(playlistwin_time_sec, " ");
|
|
1434 }
|
|
1435
|
|
1436 void
|
|
1437 playlistwin_vis_enable(void)
|
|
1438 {
|
|
1439 playlistwin_vis_enabled = TRUE;
|
|
1440
|
|
1441 if (playlistwin_get_width() >= 350)
|
|
1442 widget_show(WIDGET(playlistwin_vis));
|
|
1443 }
|
|
1444
|
|
1445 void
|
|
1446 playlistwin_vis_disable(void)
|
|
1447 {
|
|
1448 playlistwin_vis_enabled = FALSE;
|
|
1449 widget_hide(WIDGET(playlistwin_vis));
|
|
1450 draw_playlist_window(TRUE);
|
|
1451 }
|
|
1452
|
|
1453 void
|
|
1454 playlistwin_set_time(gint time, gint length, TimerMode mode)
|
|
1455 {
|
|
1456 gchar *text, sign;
|
|
1457
|
|
1458 if (mode == TIMER_REMAINING && length != -1) {
|
|
1459 time = length - time;
|
|
1460 sign = '-';
|
|
1461 }
|
|
1462 else
|
|
1463 sign = ' ';
|
|
1464
|
|
1465 time /= 1000;
|
|
1466
|
|
1467 if (time < 0)
|
|
1468 time = 0;
|
|
1469 if (time > 99 * 60)
|
|
1470 time /= 60;
|
|
1471
|
|
1472 text = g_strdup_printf("%c%-2.2d", sign, time / 60);
|
|
1473 textbox_set_text(playlistwin_time_min, text);
|
|
1474 g_free(text);
|
|
1475
|
|
1476 text = g_strdup_printf("%-2.2d", time % 60);
|
|
1477 textbox_set_text(playlistwin_time_sec, text);
|
|
1478 g_free(text);
|
|
1479 }
|
|
1480
|
|
1481 static void
|
|
1482 playlistwin_drag_motion(GtkWidget * widget,
|
|
1483 GdkDragContext * context,
|
|
1484 gint x, gint y,
|
|
1485 GtkSelectionData * selection_data,
|
|
1486 guint info, guint time, gpointer user_data)
|
|
1487 {
|
|
1488 playlistwin_list->pl_drag_motion = TRUE;
|
|
1489 playlistwin_list->drag_motion_x = x;
|
|
1490 playlistwin_list->drag_motion_y = y;
|
|
1491 playlistwin_update_list();
|
|
1492 playlistwin_hint_flag = TRUE;
|
|
1493 }
|
|
1494
|
|
1495 static void
|
|
1496 playlistwin_drag_end(GtkWidget * widget,
|
|
1497 GdkDragContext * context, gpointer user_data)
|
|
1498 {
|
|
1499 playlistwin_list->pl_drag_motion = FALSE;
|
|
1500 playlistwin_hint_flag = FALSE;
|
|
1501 playlistwin_update_list();
|
|
1502 }
|
|
1503
|
|
1504 static void
|
|
1505 playlistwin_drag_data_received(GtkWidget * widget,
|
|
1506 GdkDragContext * context,
|
|
1507 gint x, gint y,
|
|
1508 GtkSelectionData *
|
|
1509 selection_data, guint info,
|
|
1510 guint time, gpointer user_data)
|
|
1511 {
|
|
1512 guint pos;
|
|
1513
|
|
1514 g_return_if_fail(selection_data != NULL);
|
|
1515
|
|
1516 if (!selection_data->data) {
|
|
1517 g_message("Received no DND data!");
|
|
1518 return;
|
|
1519 }
|
|
1520
|
|
1521 if (widget_contains(WIDGET(playlistwin_list), x, y)) {
|
|
1522 pos = (y - WIDGET(playlistwin_list)->y) /
|
|
1523 playlistwin_list->pl_fheight + playlistwin_list->pl_first;
|
|
1524
|
|
1525 pos = MIN(pos, playlist_get_length());
|
|
1526 playlist_ins_url((gchar *) selection_data->data, pos);
|
|
1527 }
|
|
1528 else
|
|
1529 playlist_add_url((gchar *) selection_data->data);
|
|
1530 }
|
|
1531
|
|
1532 static void
|
|
1533 playlistwin_create_widgets(void)
|
|
1534 {
|
|
1535 /* This function creates the custom widgets used by the playlist editor */
|
|
1536
|
|
1537 /* text box for displaying song title in shaded mode */
|
|
1538 playlistwin_sinfo =
|
|
1539 create_textbox(&playlistwin_wlist, playlistwin_bg, playlistwin_gc,
|
|
1540 4, 4, playlistwin_get_width() - 35, FALSE, SKIN_TEXT);
|
|
1541
|
|
1542 if (!cfg.playlist_shaded)
|
|
1543 widget_hide(WIDGET(playlistwin_sinfo));
|
|
1544
|
|
1545 /* shade/unshade window push button */
|
|
1546 if (cfg.playlist_shaded)
|
|
1547 playlistwin_shade =
|
|
1548 create_pbutton(&playlistwin_wlist, playlistwin_bg,
|
|
1549 playlistwin_gc, playlistwin_get_width() - 21, 3,
|
|
1550 9, 9, 128, 45, 150, 42,
|
|
1551 playlistwin_shade_toggle, SKIN_PLEDIT);
|
|
1552 else
|
|
1553 playlistwin_shade =
|
|
1554 create_pbutton(&playlistwin_wlist, playlistwin_bg,
|
|
1555 playlistwin_gc, playlistwin_get_width() - 21, 3,
|
|
1556 9, 9, 157, 3, 62, 42, playlistwin_shade_toggle,
|
|
1557 SKIN_PLEDIT);
|
|
1558
|
|
1559 playlistwin_shade->pb_allow_draw = FALSE;
|
|
1560
|
|
1561 /* close window push button */
|
|
1562 playlistwin_close =
|
|
1563 create_pbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc,
|
|
1564 playlistwin_get_width() - 11, 3, 9, 9,
|
|
1565 cfg.playlist_shaded ? 138 : 167,
|
|
1566 cfg.playlist_shaded ? 45 : 3, 52, 42,
|
|
1567 playlistwin_hide, SKIN_PLEDIT);
|
|
1568 playlistwin_close->pb_allow_draw = FALSE;
|
|
1569
|
|
1570 /* playlist list box */
|
|
1571 playlistwin_list =
|
|
1572 create_playlist_list(&playlistwin_wlist, playlistwin_bg,
|
|
1573 playlistwin_gc, 12, 20,
|
|
1574 playlistwin_get_width() - 31,
|
|
1575 cfg.playlist_height - 58);
|
|
1576 playlist_list_set_font(cfg.playlist_font);
|
|
1577
|
|
1578 /* playlist list box slider */
|
|
1579 playlistwin_slider =
|
|
1580 create_playlistslider(&playlistwin_wlist, playlistwin_bg,
|
|
1581 playlistwin_gc, playlistwin_get_width() - 15,
|
|
1582 20, cfg.playlist_height - 58, playlistwin_list);
|
|
1583 /* track time (minute) */
|
|
1584 playlistwin_time_min =
|
|
1585 create_textbox(&playlistwin_wlist, playlistwin_bg, playlistwin_gc,
|
|
1586 playlistwin_get_width() - 82,
|
|
1587 cfg.playlist_height - 15, 15, FALSE, SKIN_TEXT);
|
|
1588
|
|
1589 /* track time (second) */
|
|
1590 playlistwin_time_sec =
|
|
1591 create_textbox(&playlistwin_wlist, playlistwin_bg, playlistwin_gc,
|
|
1592 playlistwin_get_width() - 64,
|
|
1593 cfg.playlist_height - 15, 10, FALSE, SKIN_TEXT);
|
|
1594
|
|
1595 /* playlist information (current track length / total track length) */
|
|
1596 playlistwin_info =
|
|
1597 create_textbox(&playlistwin_wlist, playlistwin_bg, playlistwin_gc,
|
|
1598 playlistwin_get_width() - 143,
|
|
1599 cfg.playlist_height - 28, 85, FALSE, SKIN_TEXT);
|
|
1600
|
|
1601 /* mini visualizer */
|
|
1602 playlistwin_vis =
|
|
1603 create_vis(&playlistwin_wlist, playlistwin_bg, playlistwin->window,
|
|
1604 playlistwin_gc, playlistwin_get_width() - 223,
|
|
1605 cfg.playlist_height - 26, 72);
|
|
1606 widget_hide(WIDGET(playlistwin_vis));
|
|
1607
|
|
1608 /* mini play control buttons at right bottom corner */
|
|
1609
|
|
1610 /* rewind button */
|
|
1611 playlistwin_srew =
|
|
1612 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc,
|
|
1613 playlistwin_get_width() - 144,
|
|
1614 cfg.playlist_height - 16, 8, 7, playlist_prev);
|
|
1615
|
|
1616 /* play button */
|
|
1617 playlistwin_splay =
|
|
1618 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc,
|
|
1619 playlistwin_get_width() - 138,
|
|
1620 cfg.playlist_height - 16, 10, 7, mainwin_play_pushed);
|
|
1621
|
|
1622 /* pause button */
|
|
1623 playlistwin_spause =
|
|
1624 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc,
|
|
1625 playlistwin_get_width() - 128,
|
|
1626 cfg.playlist_height - 16, 10, 7, bmp_playback_pause);
|
|
1627
|
|
1628 /* stop button */
|
|
1629 playlistwin_sstop =
|
|
1630 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc,
|
|
1631 playlistwin_get_width() - 118,
|
|
1632 cfg.playlist_height - 16, 9, 7, mainwin_stop_pushed);
|
|
1633
|
|
1634 /* forward button */
|
|
1635 playlistwin_sfwd =
|
|
1636 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc,
|
|
1637 playlistwin_get_width() - 109,
|
|
1638 cfg.playlist_height - 16, 8, 7, playlist_next);
|
|
1639
|
|
1640 /* eject button */
|
|
1641 playlistwin_seject =
|
|
1642 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc,
|
|
1643 playlistwin_get_width() - 100,
|
|
1644 cfg.playlist_height - 16, 9, 7, mainwin_eject_pushed);
|
|
1645
|
|
1646
|
|
1647 playlistwin_sscroll_up =
|
|
1648 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc,
|
|
1649 playlistwin_get_width() - 14,
|
|
1650 cfg.playlist_height - 35, 8, 5,
|
|
1651 playlistwin_scroll_up_pushed);
|
|
1652 playlistwin_sscroll_down =
|
|
1653 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc,
|
|
1654 playlistwin_get_width() - 14,
|
|
1655 cfg.playlist_height - 30, 8, 5,
|
|
1656 playlistwin_scroll_down_pushed);
|
|
1657
|
|
1658 }
|
|
1659
|
|
1660 static void
|
|
1661 selection_received(GtkWidget * widget,
|
|
1662 GtkSelectionData * selection_data, gpointer data)
|
|
1663 {
|
|
1664 if (selection_data->type == GDK_SELECTION_TYPE_STRING &&
|
|
1665 selection_data->length > 0)
|
|
1666 playlist_add_url((gchar *) selection_data->data);
|
|
1667 }
|
|
1668
|
|
1669 static void
|
|
1670 playlistwin_create_window(void)
|
|
1671 {
|
|
1672 GdkPixbuf *icon;
|
|
1673
|
|
1674 playlistwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
1675 gtk_window_set_title(GTK_WINDOW(playlistwin), _("BMP Playlist Editor"));
|
|
1676 gtk_window_set_role(GTK_WINDOW(playlistwin), "playlist");
|
|
1677 gtk_window_set_default_size(GTK_WINDOW(playlistwin),
|
|
1678 playlistwin_get_width(),
|
|
1679 playlistwin_get_height());
|
|
1680 gtk_window_set_resizable(GTK_WINDOW(playlistwin), TRUE);
|
|
1681 playlistwin_set_geometry_hints(cfg.playlist_shaded);
|
|
1682 dock_window_list = dock_window_set_decorated(dock_window_list,
|
|
1683 GTK_WINDOW(playlistwin),
|
|
1684 cfg.show_wm_decorations);
|
|
1685
|
|
1686 gtk_window_set_transient_for(GTK_WINDOW(playlistwin),
|
|
1687 GTK_WINDOW(mainwin));
|
|
1688 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(playlistwin), TRUE);
|
|
1689
|
|
1690 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) bmp_playlist_icon);
|
|
1691 gtk_window_set_icon(GTK_WINDOW(playlistwin), icon);
|
|
1692 g_object_unref(icon);
|
|
1693
|
|
1694 gtk_widget_set_app_paintable(playlistwin, TRUE);
|
|
1695
|
|
1696 if (cfg.playlist_x != -1 && cfg.save_window_position)
|
|
1697 gtk_window_move(GTK_WINDOW(playlistwin),
|
|
1698 cfg.playlist_x, cfg.playlist_y);
|
|
1699
|
|
1700 gtk_widget_add_events(playlistwin,
|
|
1701 GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_MOTION_MASK |
|
|
1702 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
|
|
1703 GDK_SCROLL_MASK | GDK_VISIBILITY_NOTIFY_MASK);
|
|
1704 gtk_widget_realize(playlistwin);
|
|
1705
|
|
1706 util_set_cursor(playlistwin);
|
|
1707
|
|
1708 g_signal_connect(playlistwin, "delete_event",
|
|
1709 G_CALLBACK(playlistwin_delete), NULL);
|
|
1710 g_signal_connect(playlistwin, "button_press_event",
|
|
1711 G_CALLBACK(playlistwin_press), NULL);
|
|
1712 g_signal_connect(playlistwin, "button_release_event",
|
|
1713 G_CALLBACK(playlistwin_release), NULL);
|
|
1714 g_signal_connect(playlistwin, "scroll_event",
|
|
1715 G_CALLBACK(playlistwin_scrolled), NULL);
|
|
1716 g_signal_connect(playlistwin, "motion_notify_event",
|
|
1717 G_CALLBACK(playlistwin_motion), NULL);
|
|
1718 g_signal_connect_after(playlistwin, "focus_in_event",
|
|
1719 G_CALLBACK(playlistwin_focus_in), NULL);
|
|
1720 g_signal_connect_after(playlistwin, "focus_out_event",
|
|
1721 G_CALLBACK(playlistwin_focus_out), NULL);
|
|
1722 g_signal_connect(playlistwin, "configure_event",
|
|
1723 G_CALLBACK(playlistwin_configure), NULL);
|
|
1724 g_signal_connect(playlistwin, "style_set",
|
|
1725 G_CALLBACK(playlistwin_set_back_pixmap), NULL);
|
|
1726
|
|
1727 bmp_drag_dest_set(playlistwin);
|
|
1728
|
|
1729 /* DnD stuff */
|
|
1730 g_signal_connect(playlistwin, "drag-leave",
|
|
1731 G_CALLBACK(playlistwin_drag_end), NULL);
|
|
1732 g_signal_connect(playlistwin, "drag-data-delete",
|
|
1733 G_CALLBACK(playlistwin_drag_end), NULL);
|
|
1734 g_signal_connect(playlistwin, "drag-end",
|
|
1735 G_CALLBACK(playlistwin_drag_end), NULL);
|
|
1736 g_signal_connect(playlistwin, "drag-drop",
|
|
1737 G_CALLBACK(playlistwin_drag_end), NULL);
|
|
1738 g_signal_connect(playlistwin, "drag-data-received",
|
|
1739 G_CALLBACK(playlistwin_drag_data_received), NULL);
|
|
1740 g_signal_connect(playlistwin, "drag-motion",
|
|
1741 G_CALLBACK(playlistwin_drag_motion), NULL);
|
|
1742
|
|
1743 g_signal_connect(playlistwin, "key_press_event",
|
|
1744 G_CALLBACK(playlistwin_keypress), NULL);
|
|
1745 g_signal_connect(playlistwin, "selection_received",
|
|
1746 G_CALLBACK(selection_received), NULL);
|
|
1747
|
|
1748 playlistwin_set_mask();
|
|
1749 }
|
|
1750
|
|
1751 void
|
|
1752 playlistwin_create_popup_menus(void)
|
|
1753 {
|
|
1754 playlistwin_accel = gtk_accel_group_new();
|
|
1755
|
|
1756 /* playlist window popup menu */
|
|
1757 playlistwin_popup_menu = create_menu(playlistwin_popup_menu_entries,
|
|
1758 G_N_ELEMENTS(playlistwin_popup_menu_entries),
|
|
1759 playlistwin_accel);
|
|
1760
|
|
1761 pladd_menu = create_menu(pladd_menu_entries, G_N_ELEMENTS(pladd_menu_entries),
|
|
1762 playlistwin_accel);
|
|
1763 pldel_menu = create_menu(pldel_menu_entries, G_N_ELEMENTS(pldel_menu_entries),
|
|
1764 playlistwin_accel);
|
|
1765 plsel_menu = create_menu(plsel_menu_entries, G_N_ELEMENTS(plsel_menu_entries),
|
|
1766 playlistwin_accel);
|
|
1767 plsort_menu = create_menu(plsort_menu_entries,
|
|
1768 G_N_ELEMENTS(plsort_menu_entries),
|
|
1769 playlistwin_accel);
|
|
1770 pllist_menu = create_menu(pllist_menu_entries, G_N_ELEMENTS(pllist_menu_entries),
|
|
1771 playlistwin_accel);
|
|
1772
|
|
1773 #if 0
|
|
1774 make_submenu(playlistwin_popup_menu, "/Playlist",
|
|
1775 playlistwin_playlist_menu);
|
|
1776 make_submenu(playlistwin_popup_menu, "/Playback",
|
|
1777 playlistwin_playback_menu);
|
|
1778 make_submenu(playlistwin_popup_menu, "/Add",
|
|
1779 pladd_menu);
|
|
1780 #endif
|
|
1781 }
|
|
1782
|
|
1783 void
|
|
1784 playlistwin_create(void)
|
|
1785 {
|
|
1786 playlistwin_create_window();
|
|
1787 playlistwin_create_popup_menus();
|
|
1788
|
|
1789 /* create GC and back pixmap for custom widget to draw on */
|
|
1790 playlistwin_gc = gdk_gc_new(playlistwin->window);
|
|
1791 playlistwin_bg = gdk_pixmap_new(playlistwin->window,
|
|
1792 playlistwin_get_width(),
|
|
1793 playlistwin_get_height_unshaded(), -1);
|
|
1794 gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0);
|
|
1795
|
|
1796 playlistwin_create_widgets();
|
|
1797 playlistwin_update_info();
|
|
1798
|
|
1799 gtk_window_add_accel_group(GTK_WINDOW(playlistwin), playlistwin_accel);
|
|
1800 gtk_window_add_accel_group(GTK_WINDOW(playlistwin), mainwin_accel);
|
|
1801 }
|
|
1802
|
|
1803
|
|
1804 void
|
|
1805 playlistwin_show(void)
|
|
1806 {
|
|
1807 GtkWidget *item;
|
|
1808
|
|
1809 item = gtk_item_factory_get_widget(mainwin_view_menu,
|
|
1810 "/Show Playlist Editor");
|
|
1811 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
|
|
1812
|
|
1813 tbutton_set_toggled(mainwin_pl, TRUE);
|
|
1814 cfg.playlist_visible = TRUE;
|
|
1815
|
|
1816 playlistwin_set_toprow(0);
|
|
1817 playlist_check_pos_current();
|
|
1818
|
|
1819 gtk_widget_show(playlistwin);
|
|
1820 }
|
|
1821
|
|
1822 void
|
|
1823 playlistwin_hide(void)
|
|
1824 {
|
|
1825 GtkWidget *item;
|
|
1826
|
|
1827 item = gtk_item_factory_get_widget(mainwin_view_menu,
|
|
1828 "/Show Playlist Editor");
|
|
1829 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), FALSE);
|
|
1830
|
|
1831 gtk_widget_hide(playlistwin);
|
|
1832 tbutton_set_toggled(mainwin_pl, FALSE);
|
|
1833 cfg.playlist_visible = FALSE;
|
|
1834
|
|
1835 gtk_window_present(GTK_WINDOW(mainwin));
|
|
1836 gtk_widget_grab_focus(mainwin);
|
|
1837 }
|
|
1838
|
|
1839
|
|
1840 static void
|
|
1841 plsort_menu_callback(gpointer data,
|
|
1842 guint action,
|
|
1843 GtkWidget * widget)
|
|
1844 {
|
|
1845 switch (action) {
|
|
1846 case PLAYLISTWIN_SORT_BYTITLE:
|
|
1847 playlist_sort(PLAYLIST_SORT_TITLE);
|
|
1848 playlistwin_update_list();
|
|
1849 break;
|
|
1850 case PLAYLISTWIN_SORT_BYPATH:
|
|
1851 playlist_sort(PLAYLIST_SORT_PATH);
|
|
1852 playlistwin_update_list();
|
|
1853 break;
|
|
1854 case PLAYLISTWIN_SORT_BYDATE:
|
|
1855 playlist_sort(PLAYLIST_SORT_DATE);
|
|
1856 playlistwin_update_list();
|
|
1857 break;
|
|
1858 case PLAYLISTWIN_SORT_BYFILENAME:
|
|
1859 playlist_sort(PLAYLIST_SORT_FILENAME);
|
|
1860 playlistwin_update_list();
|
|
1861 break;
|
|
1862 case PLAYLISTWIN_SORT_SEL_BYTITLE:
|
|
1863 playlist_sort_selected(PLAYLIST_SORT_TITLE);
|
|
1864 playlistwin_update_list();
|
|
1865 break;
|
|
1866 case PLAYLISTWIN_SORT_SEL_BYFILENAME:
|
|
1867 playlist_sort_selected(PLAYLIST_SORT_FILENAME);
|
|
1868 playlistwin_update_list();
|
|
1869 break;
|
|
1870 case PLAYLISTWIN_SORT_SEL_BYPATH:
|
|
1871 playlist_sort_selected(PLAYLIST_SORT_PATH);
|
|
1872 playlistwin_update_list();
|
|
1873 break;
|
|
1874 case PLAYLISTWIN_SORT_SEL_BYDATE:
|
|
1875 playlist_sort_selected(PLAYLIST_SORT_DATE);
|
|
1876 playlistwin_update_list();
|
|
1877 break;
|
|
1878 case PLAYLISTWIN_SORT_REVERSE:
|
|
1879 playlist_reverse();
|
|
1880 playlistwin_update_list();
|
|
1881 break;
|
|
1882 case PLAYLISTWIN_SORT_RANDOMIZE:
|
|
1883 playlist_random();
|
|
1884 playlistwin_update_list();
|
|
1885 break;
|
|
1886 }
|
|
1887 }
|
|
1888
|
|
1889 static void
|
|
1890 playlistwin_sub_menu_callback(gpointer data,
|
|
1891 guint action,
|
|
1892 GtkWidget * widget)
|
|
1893 {
|
|
1894 switch (action) {
|
|
1895 case PLIST_NEW:
|
|
1896 playlist_set_current_name(NULL);
|
|
1897 playlist_clear();
|
|
1898 mainwin_clear_song_info();
|
|
1899 mainwin_set_info_text();
|
|
1900 break;
|
|
1901 case PLIST_SAVE:
|
|
1902 playlistwin_select_playlist_to_save(playlist_get_current_name());
|
|
1903 break;
|
|
1904 case PLIST_SAVE_AS:
|
|
1905 playlistwin_select_playlist_to_save(playlist_get_current_name());
|
|
1906 break;
|
|
1907 case PLIST_LOAD:
|
|
1908 playlistwin_select_playlist_to_load(playlist_get_current_name());
|
|
1909 break;
|
|
1910 case SEL_INV:
|
|
1911 playlistwin_inverse_selection();
|
|
1912 break;
|
|
1913 case SEL_ZERO:
|
|
1914 playlistwin_select_none();
|
|
1915 break;
|
|
1916 case SEL_ALL:
|
|
1917 playlistwin_select_all();
|
|
1918 break;
|
|
1919 case SUB_ALL:
|
|
1920 playlist_clear();
|
|
1921 mainwin_clear_song_info();
|
|
1922 mainwin_set_info_text();
|
|
1923 break;
|
|
1924 case SUB_CROP:
|
|
1925 playlist_delete(TRUE);
|
|
1926 break;
|
|
1927 case SUB_SELECTED:
|
|
1928 playlist_delete(FALSE);
|
|
1929 break;
|
|
1930 case PLAYLISTWIN_REMOVE_DEAD_FILES:
|
|
1931 playlist_remove_dead_files();
|
|
1932 break;
|
|
1933 case PLAYLISTWIN_REFRESH:
|
|
1934 playlist_read_info_selection();
|
|
1935 playlistwin_update_list();
|
|
1936 textbox_set_xfont(mainwin_info, TRUE, cfg.mainwin_font);
|
|
1937 break;
|
|
1938 }
|
|
1939 }
|
|
1940
|
|
1941 static void
|
|
1942 playlistwin_popup_menu_callback(gpointer data,
|
|
1943 guint action,
|
|
1944 GtkWidget * widget)
|
|
1945 {
|
|
1946 switch (action) {
|
|
1947 case ADD_FILES:
|
|
1948 playlistwin_show_filebrowser();
|
|
1949 break;
|
|
1950 case ADD_DIR:
|
|
1951 playlistwin_run_dirbrowser();
|
|
1952 break;
|
|
1953 case CLOSE_PL_WINDOW:
|
|
1954 playlistwin_hide();
|
|
1955 break;
|
|
1956 case MISC_FILEINFO:
|
|
1957 playlistwin_fileinfo();
|
|
1958 break;
|
|
1959 case SEL_LOOKUP:
|
|
1960 playlist_read_info_selection();
|
|
1961 break;
|
|
1962 case MISC_QUEUE:
|
|
1963 playlist_queue();
|
|
1964 break;
|
|
1965 case PLIST_CQUEUE:
|
|
1966 playlist_clear_queue();
|
|
1967 break;
|
|
1968 case PLIST_JTT:
|
|
1969 mainwin_jump_to_time();
|
|
1970 break;
|
|
1971 case PLIST_JTF:
|
|
1972 mainwin_jump_to_file();
|
|
1973 break;
|
|
1974 }
|
|
1975 }
|