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