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