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