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