Mercurial > audlegacy
annotate src/audacious/ui_playlist.c @ 2499:15a1f5ee4d1c trunk
[svn] - playlist_manager -> ui_playlist_manager, since it's a UI component.
author | nenolod |
---|---|
date | Sat, 10 Feb 2007 20:21:42 -0800 |
parents | 6fb56e6bc6ec |
children | e07c141dd326 |
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" | |
2499
15a1f5ee4d1c
[svn] - playlist_manager -> ui_playlist_manager, since it's a UI component.
nenolod
parents:
2495
diff
changeset
|
47 #include "ui_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 |
2494
59661bd074b4
[svn] Try to put some skinned window code in a common place.
nenolod
parents:
2492
diff
changeset
|
56 #include "ui_skinned_window.h" |
59661bd074b4
[svn] Try to put some skinned window code in a common place.
nenolod
parents:
2492
diff
changeset
|
57 |
2313 | 58 #include "icons-stock.h" |
59 #include "images/audacious_playlist.xpm" | |
60 | |
61 GtkWidget *playlistwin; | |
62 | |
63 PlayList_List *playlistwin_list = NULL; | |
64 PButton *playlistwin_shade, *playlistwin_close; | |
65 | |
66 static GdkPixmap *playlistwin_bg; | |
67 static GdkBitmap *playlistwin_mask = NULL; | |
68 static GdkGC *playlistwin_gc; | |
69 | |
70 static gboolean playlistwin_hint_flag = FALSE; | |
71 | |
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
72 static GtkWidget *playlistwin_infopopup = NULL; |
2351
911743d27aba
[svn] - simplify and optimize the metadata tooltip trigger function
giacomo
parents:
2348
diff
changeset
|
73 static guint playlistwin_infopopup_sid = 0; |
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
74 |
2313 | 75 static PlaylistSlider *playlistwin_slider = NULL; |
76 static TextBox *playlistwin_time_min, *playlistwin_time_sec; | |
77 static TextBox *playlistwin_info, *playlistwin_sinfo; | |
78 static SButton *playlistwin_srew, *playlistwin_splay; | |
79 static SButton *playlistwin_spause, *playlistwin_sstop; | |
80 static SButton *playlistwin_sfwd, *playlistwin_seject; | |
81 static SButton *playlistwin_sscroll_up, *playlistwin_sscroll_down; | |
82 | |
83 static GList *playlistwin_wlist = NULL; | |
84 | |
85 void playlistwin_select_search_cbt_cb( GtkWidget *called_cbt , | |
86 gpointer other_cbt ); | |
87 static gboolean playlistwin_select_search_kp_cb( GtkWidget *entry , GdkEventKey *event , | |
88 gpointer searchdlg_win ); | |
89 | |
90 static void playlistwin_draw_frame(void); | |
91 | |
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
92 static gboolean playlistwin_fileinfopopup_probe(gpointer * filepopup_win); |
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
93 |
2491
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
94 static gboolean playlistwin_resizing = FALSE; |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
95 static gint playlistwin_resize_x, playlistwin_resize_y; |
2313 | 96 |
97 gboolean | |
98 playlistwin_is_shaded(void) | |
99 { | |
100 return cfg.playlist_shaded; | |
101 } | |
102 | |
103 gint | |
104 playlistwin_get_width(void) | |
105 { | |
106 cfg.playlist_width /= PLAYLISTWIN_WIDTH_SNAP; | |
107 cfg.playlist_width *= PLAYLISTWIN_WIDTH_SNAP; | |
108 return cfg.playlist_width; | |
109 } | |
110 | |
111 gint | |
112 playlistwin_get_height_unshaded(void) | |
113 { | |
114 gint height; | |
115 cfg.playlist_height /= PLAYLISTWIN_HEIGHT_SNAP; | |
116 cfg.playlist_height *= PLAYLISTWIN_HEIGHT_SNAP; | |
117 height = cfg.playlist_height; | |
118 return height; | |
119 } | |
120 | |
121 gint | |
122 playlistwin_get_height_shaded(void) | |
123 { | |
124 return PLAYLISTWIN_SHADED_HEIGHT; | |
125 } | |
126 | |
127 gint | |
128 playlistwin_get_height(void) | |
129 { | |
130 if (playlistwin_is_shaded()) | |
131 return playlistwin_get_height_shaded(); | |
132 else | |
133 return playlistwin_get_height_unshaded(); | |
134 } | |
135 | |
136 void | |
137 playlistwin_get_size(gint * width, gint * height) | |
138 { | |
139 if (width) | |
140 *width = playlistwin_get_width(); | |
141 | |
142 if (height) | |
143 *height = playlistwin_get_height(); | |
144 } | |
145 | |
146 static void | |
147 playlistwin_update_info(Playlist *playlist) | |
148 { | |
149 gchar *text, *sel_text, *tot_text; | |
150 gulong selection, total; | |
151 gboolean selection_more, total_more; | |
152 | |
153 playlist_get_total_time(playlist, &total, &selection, &total_more, &selection_more); | |
154 | |
155 if (selection > 0 || (selection == 0 && !selection_more)) { | |
156 if (selection > 3600) | |
157 sel_text = | |
158 g_strdup_printf("%lu:%-2.2lu:%-2.2lu%s", selection / 3600, | |
159 (selection / 60) % 60, selection % 60, | |
160 (selection_more ? "+" : "")); | |
161 else | |
162 sel_text = | |
163 g_strdup_printf("%lu:%-2.2lu%s", selection / 60, | |
164 selection % 60, (selection_more ? "+" : "")); | |
165 } | |
166 else | |
167 sel_text = g_strdup("?"); | |
168 if (total > 0 || (total == 0 && !total_more)) { | |
169 if (total > 3600) | |
170 tot_text = | |
171 g_strdup_printf("%lu:%-2.2lu:%-2.2lu%s", total / 3600, | |
172 (total / 60) % 60, total % 60, | |
173 total_more ? "+" : ""); | |
174 else | |
175 tot_text = | |
176 g_strdup_printf("%lu:%-2.2lu%s", total / 60, total % 60, | |
177 total_more ? "+" : ""); | |
178 } | |
179 else | |
180 tot_text = g_strdup("?"); | |
181 text = g_strconcat(sel_text, "/", tot_text, NULL); | |
182 textbox_set_text(playlistwin_info, text ? text : ""); | |
183 g_free(text); | |
184 g_free(tot_text); | |
185 g_free(sel_text); | |
186 } | |
187 | |
188 static void | |
189 playlistwin_update_sinfo(Playlist *playlist) | |
190 { | |
191 gchar *posstr, *timestr, *title, *info; | |
192 gint pos, time; | |
193 | |
194 pos = playlist_get_position(playlist); | |
195 title = playlist_get_songtitle(playlist, pos); | |
196 | |
197 if (!title) { | |
198 textbox_set_text(playlistwin_sinfo, ""); | |
199 return; | |
200 } | |
201 | |
202 convert_title_text(title); | |
203 | |
204 time = playlist_get_songtime(playlist, pos); | |
205 | |
206 if (cfg.show_numbers_in_pl) | |
207 posstr = g_strdup_printf("%d. ", pos + 1); | |
208 else | |
209 posstr = g_strdup(""); | |
210 | |
211 if (time != -1) { | |
212 timestr = g_strdup_printf(" (%d:%-2.2d)", time / 60000, | |
213 (time / 1000) % 60); | |
214 } | |
215 else | |
216 timestr = g_strdup(""); | |
217 | |
218 info = g_strdup_printf("%s%s%s", posstr, title, timestr); | |
219 | |
220 g_free(posstr); | |
221 g_free(title); | |
222 g_free(timestr); | |
223 | |
224 textbox_set_text(playlistwin_sinfo, info ? info : ""); | |
225 g_free(info); | |
226 } | |
227 | |
228 gboolean | |
229 playlistwin_item_visible(gint index) | |
230 { | |
231 if (index >= playlistwin_list->pl_first | |
232 && index < | |
233 (playlistwin_list->pl_first + playlistwin_list->pl_num_visible)) | |
234 return TRUE; | |
235 return FALSE; | |
236 } | |
237 | |
238 gint | |
239 playlistwin_get_toprow(void) | |
240 { | |
241 if (playlistwin_list) | |
242 return (playlistwin_list->pl_first); | |
243 return (-1); | |
244 } | |
245 | |
246 void | |
247 playlistwin_set_toprow(gint toprow) | |
248 { | |
249 if (playlistwin_list) | |
250 playlistwin_list->pl_first = toprow; | |
251 playlistwin_update_list(playlist_get_active()); | |
252 } | |
253 | |
254 void | |
255 playlistwin_update_list(Playlist *playlist) | |
256 { | |
257 /* this can happen early on. just bail gracefully. */ | |
2363 | 258 g_return_if_fail(playlistwin_list); |
2313 | 259 |
260 widget_draw(WIDGET(playlistwin_list)); | |
261 widget_draw(WIDGET(playlistwin_slider)); | |
262 playlistwin_update_info(playlist); | |
263 playlistwin_update_sinfo(playlist); | |
264 } | |
265 | |
266 static void | |
267 playlistwin_set_mask(void) | |
268 { | |
269 GdkGC *gc; | |
270 GdkColor pattern; | |
271 | |
272 if (playlistwin_mask) | |
273 g_object_unref(playlistwin_mask); | |
274 | |
275 playlistwin_mask = | |
276 gdk_pixmap_new(playlistwin->window, playlistwin_get_width(), | |
277 playlistwin_get_height(), 1); | |
278 gc = gdk_gc_new(playlistwin_mask); | |
279 pattern.pixel = 1; | |
280 gdk_gc_set_foreground(gc, &pattern); | |
281 gdk_draw_rectangle(playlistwin_mask, gc, TRUE, 0, 0, | |
282 playlistwin_get_width(), playlistwin_get_height()); | |
283 g_object_unref(gc); | |
284 | |
285 gtk_widget_shape_combine_mask(playlistwin, playlistwin_mask, 0, 0); | |
286 } | |
287 | |
288 static void | |
289 playlistwin_set_geometry_hints(gboolean shaded) | |
290 { | |
291 GdkGeometry geometry; | |
292 GdkWindowHints mask; | |
293 | |
294 geometry.min_width = PLAYLISTWIN_MIN_WIDTH; | |
295 geometry.max_width = G_MAXUINT16; | |
296 | |
297 geometry.width_inc = PLAYLISTWIN_WIDTH_SNAP; | |
298 geometry.height_inc = PLAYLISTWIN_HEIGHT_SNAP; | |
299 | |
300 if (shaded) { | |
301 geometry.min_height = PLAYLISTWIN_SHADED_HEIGHT; | |
302 geometry.max_height = PLAYLISTWIN_SHADED_HEIGHT; | |
303 geometry.base_height = PLAYLISTWIN_SHADED_HEIGHT; | |
304 } | |
305 else { | |
306 geometry.min_height = PLAYLISTWIN_MIN_HEIGHT; | |
307 geometry.max_height = G_MAXUINT16; | |
308 } | |
309 | |
310 mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_RESIZE_INC; | |
311 | |
312 gtk_window_set_geometry_hints(GTK_WINDOW(playlistwin), | |
313 playlistwin, &geometry, mask); | |
314 } | |
315 | |
316 void | |
317 playlistwin_set_sinfo_font(gchar *font) | |
318 { | |
319 gchar *tmp = NULL, *tmp2 = NULL; | |
320 | |
2363 | 321 g_return_if_fail(font); |
2313 | 322 |
323 tmp = g_strdup(font); | |
2363 | 324 g_return_if_fail(tmp); |
2313 | 325 |
326 *strrchr(tmp, ' ') = '\0'; | |
327 tmp2 = g_strdup_printf("%s 8", tmp); | |
2363 | 328 g_return_if_fail(tmp2); |
329 | |
2313 | 330 textbox_set_xfont(playlistwin_sinfo, cfg.mainwin_use_xfont, tmp2); |
331 | |
2363 | 332 g_free(tmp); |
333 g_free(tmp2); | |
2313 | 334 } |
335 | |
336 void | |
337 playlistwin_set_sinfo_scroll(gboolean scroll) | |
338 { | |
339 if(playlistwin_is_shaded()) | |
340 textbox_set_scroll(playlistwin_sinfo, cfg.autoscroll); | |
341 else | |
342 textbox_set_scroll(playlistwin_sinfo, FALSE); | |
343 } | |
344 | |
345 void | |
346 playlistwin_set_shade(gboolean shaded) | |
347 { | |
348 cfg.playlist_shaded = shaded; | |
349 | |
350 if (shaded) { | |
351 playlistwin_set_sinfo_font(cfg.playlist_font); | |
352 playlistwin_set_sinfo_scroll(cfg.autoscroll); | |
353 widget_show(WIDGET(playlistwin_sinfo)); | |
354 playlistwin_shade->pb_nx = 128; | |
355 playlistwin_shade->pb_ny = 45; | |
356 playlistwin_shade->pb_px = 150; | |
357 playlistwin_shade->pb_py = 42; | |
358 playlistwin_close->pb_nx = 138; | |
359 playlistwin_close->pb_ny = 45; | |
360 } | |
361 else { | |
362 widget_hide(WIDGET(playlistwin_sinfo)); | |
363 playlistwin_set_sinfo_scroll(FALSE); | |
364 playlistwin_shade->pb_nx = 157; | |
365 playlistwin_shade->pb_ny = 3; | |
366 playlistwin_shade->pb_px = 62; | |
367 playlistwin_shade->pb_py = 42; | |
368 playlistwin_close->pb_nx = 167; | |
369 playlistwin_close->pb_ny = 3; | |
370 } | |
371 | |
372 dock_shade(dock_window_list, GTK_WINDOW(playlistwin), | |
373 playlistwin_get_height()); | |
374 | |
375 playlistwin_set_geometry_hints(cfg.playlist_shaded); | |
376 | |
377 gtk_window_resize(GTK_WINDOW(playlistwin), | |
378 playlistwin_get_width(), | |
379 playlistwin_get_height()); | |
380 | |
381 playlistwin_set_mask(); | |
382 | |
383 widget_draw(WIDGET(playlistwin_list)); | |
384 widget_draw(WIDGET(playlistwin_slider)); | |
385 | |
386 draw_playlist_window(TRUE); | |
387 } | |
388 | |
389 static void | |
390 playlistwin_set_shade_menu(gboolean shaded) | |
391 { | |
392 GtkAction *action = gtk_action_group_get_action( | |
393 toggleaction_group_others , "roll up playlist editor" ); | |
394 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , shaded ); | |
395 | |
396 playlistwin_set_shade(shaded); | |
397 playlistwin_update_list(playlist_get_active()); | |
398 } | |
399 | |
400 void | |
401 playlistwin_shade_toggle(void) | |
402 { | |
403 playlistwin_set_shade_menu(!cfg.playlist_shaded); | |
404 } | |
405 | |
406 static void | |
407 playlistwin_release(GtkWidget * widget, | |
408 GdkEventButton * event, | |
409 gpointer callback_data) | |
410 { | |
411 if (event->button == 3) | |
412 return; | |
413 | |
414 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
415 playlistwin_resizing = FALSE; | |
416 gdk_flush(); | |
417 | |
418 if (dock_is_moving(GTK_WINDOW(playlistwin))) | |
419 dock_move_release(GTK_WINDOW(playlistwin)); | |
420 else | |
421 { | |
422 handle_release_cb(playlistwin_wlist, widget, event); | |
423 draw_playlist_window(FALSE); | |
424 } | |
425 } | |
426 | |
427 void | |
428 playlistwin_scroll(gint num) | |
429 { | |
430 playlistwin_list->pl_first += num; | |
431 playlistwin_update_list(playlist_get_active()); | |
432 } | |
433 | |
434 void | |
435 playlistwin_scroll_up_pushed(void) | |
436 { | |
437 playlistwin_scroll(-3); | |
438 } | |
439 | |
440 void | |
441 playlistwin_scroll_down_pushed(void) | |
442 { | |
443 playlistwin_scroll(3); | |
444 } | |
445 | |
446 static void | |
447 playlistwin_select_all(void) | |
448 { | |
449 Playlist *playlist = playlist_get_active(); | |
450 | |
451 playlist_select_all(playlist, TRUE); | |
452 playlistwin_list->pl_prev_selected = 0; | |
453 playlistwin_list->pl_prev_min = 0; | |
454 playlistwin_list->pl_prev_max = playlist_get_length(playlist) - 1; | |
455 playlistwin_update_list(playlist); | |
456 } | |
457 | |
458 static void | |
459 playlistwin_select_none(void) | |
460 { | |
461 playlist_select_all(playlist_get_active(), FALSE); | |
462 playlistwin_list->pl_prev_selected = -1; | |
463 playlistwin_list->pl_prev_min = -1; | |
464 playlistwin_update_list(playlist_get_active()); | |
465 } | |
466 | |
467 static void | |
468 playlistwin_select_search(void) | |
469 { | |
470 Playlist *playlist = playlist_get_active(); | |
471 GtkWidget *searchdlg_win, *searchdlg_table; | |
472 GtkWidget *searchdlg_hbox, *searchdlg_logo, *searchdlg_helptext; | |
473 GtkWidget *searchdlg_entry_track_name, *searchdlg_label_track_name; | |
474 GtkWidget *searchdlg_entry_album_name, *searchdlg_label_album_name; | |
475 GtkWidget *searchdlg_entry_file_name, *searchdlg_label_file_name; | |
476 GtkWidget *searchdlg_entry_performer, *searchdlg_label_performer; | |
477 GtkWidget *searchdlg_checkbt_clearprevsel; | |
478 GtkWidget *searchdlg_checkbt_newplaylist; | |
479 GtkWidget *searchdlg_checkbt_autoenqueue; | |
480 gint result; | |
481 | |
482 /* create dialog */ | |
483 searchdlg_win = gtk_dialog_new_with_buttons( | |
484 _("Search entries in active playlist") , GTK_WINDOW(mainwin) , | |
485 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT , | |
486 GTK_STOCK_CANCEL , GTK_RESPONSE_REJECT , GTK_STOCK_OK , GTK_RESPONSE_ACCEPT , NULL ); | |
487 /* help text and logo */ | |
488 searchdlg_hbox = gtk_hbox_new( FALSE , 4 ); | |
489 searchdlg_logo = gtk_image_new_from_stock( GTK_STOCK_FIND , GTK_ICON_SIZE_DIALOG ); | |
490 searchdlg_helptext = gtk_label_new( _("Select entries in playlist by filling one or more " | |
491 "fields. Fields use regular expressions syntax, case-insensitive. If you don't know how " | |
492 "regular expressions work, simply insert a literal portion of what you're searching for.") ); | |
493 gtk_label_set_line_wrap( GTK_LABEL(searchdlg_helptext) , TRUE ); | |
494 gtk_box_pack_start( GTK_BOX(searchdlg_hbox) , searchdlg_logo , FALSE , FALSE , 0 ); | |
495 gtk_box_pack_start( GTK_BOX(searchdlg_hbox) , searchdlg_helptext , FALSE , FALSE , 0 ); | |
496 /* track name */ | |
497 searchdlg_label_track_name = gtk_label_new( _("Track name: ") ); | |
498 searchdlg_entry_track_name = gtk_entry_new(); | |
499 gtk_misc_set_alignment( GTK_MISC(searchdlg_label_track_name) , 0 , 0.5 ); | |
500 g_signal_connect( G_OBJECT(searchdlg_entry_track_name) , "key-press-event" , | |
501 G_CALLBACK(playlistwin_select_search_kp_cb) , searchdlg_win ); | |
502 /* album name */ | |
503 searchdlg_label_album_name = gtk_label_new( _("Album name: ") ); | |
504 searchdlg_entry_album_name = gtk_entry_new(); | |
505 gtk_misc_set_alignment( GTK_MISC(searchdlg_label_album_name) , 0 , 0.5 ); | |
506 g_signal_connect( G_OBJECT(searchdlg_entry_album_name) , "key-press-event" , | |
507 G_CALLBACK(playlistwin_select_search_kp_cb) , searchdlg_win ); | |
508 /* artist */ | |
509 searchdlg_label_performer = gtk_label_new( _("Artist: ") ); | |
510 searchdlg_entry_performer = gtk_entry_new(); | |
511 gtk_misc_set_alignment( GTK_MISC(searchdlg_label_performer) , 0 , 0.5 ); | |
512 g_signal_connect( G_OBJECT(searchdlg_entry_performer) , "key-press-event" , | |
513 G_CALLBACK(playlistwin_select_search_kp_cb) , searchdlg_win ); | |
514 /* file name */ | |
515 searchdlg_label_file_name = gtk_label_new( _("Filename: ") ); | |
516 searchdlg_entry_file_name = gtk_entry_new(); | |
517 gtk_misc_set_alignment( GTK_MISC(searchdlg_label_file_name) , 0 , 0.5 ); | |
518 g_signal_connect( G_OBJECT(searchdlg_entry_file_name) , "key-press-event" , | |
519 G_CALLBACK(playlistwin_select_search_kp_cb) , searchdlg_win ); | |
520 /* some options that control behaviour */ | |
521 searchdlg_checkbt_clearprevsel = gtk_check_button_new_with_label( | |
522 _("Clear previous selection before searching") ); | |
523 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(searchdlg_checkbt_clearprevsel) , TRUE ); | |
524 searchdlg_checkbt_autoenqueue = gtk_check_button_new_with_label( | |
525 _("Automatically toggle queue for matching entries") ); | |
526 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(searchdlg_checkbt_autoenqueue) , FALSE ); | |
527 searchdlg_checkbt_newplaylist = gtk_check_button_new_with_label( | |
528 _("Create a new playlist with matching entries") ); | |
529 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(searchdlg_checkbt_newplaylist) , FALSE ); | |
530 g_signal_connect( G_OBJECT(searchdlg_checkbt_autoenqueue) , "clicked" , | |
531 G_CALLBACK(playlistwin_select_search_cbt_cb) , searchdlg_checkbt_newplaylist ); | |
532 g_signal_connect( G_OBJECT(searchdlg_checkbt_newplaylist) , "clicked" , | |
533 G_CALLBACK(playlistwin_select_search_cbt_cb) , searchdlg_checkbt_autoenqueue ); | |
534 /* place fields in searchdlg_table */ | |
535 searchdlg_table = gtk_table_new( 8 , 2 , FALSE ); | |
536 gtk_table_set_row_spacing( GTK_TABLE(searchdlg_table) , 0 , 8 ); | |
537 gtk_table_set_row_spacing( GTK_TABLE(searchdlg_table) , 4 , 8 ); | |
538 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_hbox , | |
539 0 , 2 , 0 , 1 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
540 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_label_track_name , | |
541 0 , 1 , 1 , 2 , GTK_FILL , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
542 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_entry_track_name , | |
543 1 , 2 , 1 , 2 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
544 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_label_album_name , | |
545 0 , 1 , 2 , 3 , GTK_FILL , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
546 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_entry_album_name , | |
547 1 , 2 , 2 , 3 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
548 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_label_performer , | |
549 0 , 1 , 3 , 4 , GTK_FILL , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
550 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_entry_performer , | |
551 1 , 2 , 3 , 4 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
552 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_label_file_name , | |
553 0 , 1 , 4 , 5 , GTK_FILL , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
554 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_entry_file_name , | |
555 1 , 2 , 4 , 5 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
556 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_checkbt_clearprevsel , | |
557 0 , 2 , 5 , 6 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 1 ); | |
558 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_checkbt_autoenqueue , | |
559 0 , 2 , 6 , 7 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 1 ); | |
560 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_checkbt_newplaylist , | |
561 0 , 2 , 7 , 8 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 1 ); | |
562 | |
563 gtk_container_set_border_width( GTK_CONTAINER(searchdlg_table) , 5 ); | |
564 gtk_container_add( GTK_CONTAINER(GTK_DIALOG(searchdlg_win)->vbox) , searchdlg_table ); | |
565 gtk_widget_show_all( searchdlg_win ); | |
566 result = gtk_dialog_run( GTK_DIALOG(searchdlg_win) ); | |
567 switch(result) | |
568 { | |
569 case GTK_RESPONSE_ACCEPT: | |
570 { | |
571 gint matched_entries_num = 0; | |
572 /* create a TitleInput tuple with user search data */ | |
573 TitleInput *tuple = g_malloc(sizeof(TitleInput)); | |
574 gchar *searchdata = NULL; | |
575 searchdata = (gchar*)gtk_entry_get_text( GTK_ENTRY(searchdlg_entry_track_name) ); | |
576 tuple->track_name = ( strcmp(searchdata,"") ) ? g_strdup(searchdata) : NULL; | |
577 searchdata = (gchar*)gtk_entry_get_text( GTK_ENTRY(searchdlg_entry_album_name) ); | |
578 tuple->album_name = ( strcmp(searchdata,"") ) ? g_strdup(searchdata) : NULL; | |
579 searchdata = (gchar*)gtk_entry_get_text( GTK_ENTRY(searchdlg_entry_performer) ); | |
580 tuple->performer = ( strcmp(searchdata,"") ) ? g_strdup(searchdata) : NULL; | |
581 searchdata = (gchar*)gtk_entry_get_text( GTK_ENTRY(searchdlg_entry_file_name) ); | |
582 tuple->file_name = ( strcmp(searchdata,"") ) ? g_strdup(searchdata) : NULL; | |
583 /* check if previous selection should be cleared before searching */ | |
584 if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(searchdlg_checkbt_clearprevsel)) == TRUE ) | |
585 playlistwin_select_none(); | |
586 /* now send this tuple to the real search function */ | |
587 matched_entries_num = playlist_select_search( playlist , tuple , 0 ); | |
588 /* we do not need the tuple and its data anymore */ | |
589 if ( tuple->track_name != NULL ) g_free( tuple->track_name ); | |
590 if ( tuple->album_name != NULL ) g_free( tuple->album_name ); | |
591 if ( tuple->performer != NULL ) g_free( tuple->performer ); | |
592 if ( tuple->file_name != NULL ) g_free( tuple->file_name ); | |
593 g_free( tuple ); | |
594 playlistwin_update_list(playlist_get_active()); | |
595 /* check if a new playlist should be created after searching */ | |
596 if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(searchdlg_checkbt_newplaylist)) == TRUE ) | |
597 playlist_new_from_selected(); | |
598 /* check if matched entries should be queued */ | |
599 else if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(searchdlg_checkbt_autoenqueue)) == TRUE ) | |
600 playlist_queue(playlist_get_active()); | |
601 break; | |
602 } | |
603 default: | |
604 break; | |
605 } | |
606 /* done here :) */ | |
607 gtk_widget_destroy( searchdlg_win ); | |
608 } | |
609 | |
610 static void | |
611 playlistwin_inverse_selection(void) | |
612 { | |
613 playlist_select_invert_all(playlist_get_active()); | |
614 playlistwin_list->pl_prev_selected = -1; | |
615 playlistwin_list->pl_prev_min = -1; | |
616 playlistwin_update_list(playlist_get_active()); | |
617 } | |
618 | |
619 static void | |
620 playlistwin_resize(gint width, gint height) | |
621 { | |
2491
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
622 gint tx, ty; |
2313 | 623 gboolean redraw; |
624 | |
625 g_return_if_fail(width > 0 && height > 0); | |
626 | |
2491
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
627 tx = (width - PLAYLISTWIN_MIN_WIDTH) / PLAYLISTWIN_WIDTH_SNAP; |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
628 tx = (tx * PLAYLISTWIN_WIDTH_SNAP) + PLAYLISTWIN_MIN_WIDTH; |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
629 if (tx < PLAYLISTWIN_MIN_WIDTH) |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
630 tx = PLAYLISTWIN_MIN_WIDTH; |
2313 | 631 |
632 if (!cfg.playlist_shaded) | |
2491
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
633 { |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
634 ty = (height - PLAYLISTWIN_MIN_HEIGHT) / PLAYLISTWIN_HEIGHT_SNAP; |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
635 ty = (ty * PLAYLISTWIN_HEIGHT_SNAP) + PLAYLISTWIN_MIN_HEIGHT; |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
636 if (ty < PLAYLISTWIN_MIN_HEIGHT) |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
637 ty = PLAYLISTWIN_MIN_HEIGHT; |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
638 } |
2313 | 639 else |
2491
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
640 ty = cfg.playlist_height; |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
641 |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
642 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
|
643 return; |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
644 |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
645 cfg.playlist_width = width = tx; |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
646 cfg.playlist_height = height = ty; |
2313 | 647 |
648 /* FIXME: why the fsck are we doing this manually? */ | |
649 /* adjust widget positions and sizes */ | |
650 | |
651 widget_resize(WIDGET(playlistwin_list), width - 31, height - 58); | |
652 | |
653 widget_move(WIDGET(playlistwin_slider), width - 15, 20); | |
654 widget_resize(WIDGET(playlistwin_slider), 8, height - 58); | |
655 | |
656 widget_resize(WIDGET(playlistwin_sinfo), width - 35, 14); | |
657 playlistwin_update_sinfo(playlist_get_active()); | |
658 | |
659 widget_move(WIDGET(playlistwin_shade), width - 21, 3); | |
660 widget_move(WIDGET(playlistwin_close), width - 11, 3); | |
661 widget_move(WIDGET(playlistwin_time_min), width - 82, height - 15); | |
662 widget_move(WIDGET(playlistwin_time_sec), width - 64, height - 15); | |
663 widget_move(WIDGET(playlistwin_info), width - 143, height - 28); | |
664 widget_move(WIDGET(playlistwin_srew), width - 144, height - 16); | |
665 widget_move(WIDGET(playlistwin_splay), width - 138, height - 16); | |
666 widget_move(WIDGET(playlistwin_spause), width - 128, height - 16); | |
667 widget_move(WIDGET(playlistwin_sstop), width - 118, height - 16); | |
668 widget_move(WIDGET(playlistwin_sfwd), width - 109, height - 16); | |
669 widget_move(WIDGET(playlistwin_seject), width - 100, height - 16); | |
670 widget_move(WIDGET(playlistwin_sscroll_up), width - 14, height - 35); | |
671 widget_move(WIDGET(playlistwin_sscroll_down), width - 14, height - 30); | |
672 | |
673 g_object_unref(playlistwin_bg); | |
674 playlistwin_bg = gdk_pixmap_new(playlistwin->window, width, height, -1); | |
675 playlistwin_set_mask(); | |
676 | |
677 widget_list_lock(playlistwin_wlist); | |
678 | |
679 widget_list_change_pixmap(playlistwin_wlist, playlistwin_bg); | |
680 playlistwin_draw_frame(); | |
681 widget_list_draw(playlistwin_wlist, &redraw, TRUE); | |
682 widget_list_clear_redraw(playlistwin_wlist); | |
683 | |
684 widget_list_unlock(playlistwin_wlist); | |
685 | |
686 gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0); | |
687 gdk_window_clear(playlistwin->window); | |
688 } | |
689 | |
2492
ea80fe9c3ba4
[svn] - use ConfigureNotify to set playlist location, a proper use of ICCCM.
nenolod
parents:
2491
diff
changeset
|
690 static gboolean |
ea80fe9c3ba4
[svn] - use ConfigureNotify to set playlist location, a proper use of ICCCM.
nenolod
parents:
2491
diff
changeset
|
691 playlistwin_configure(GtkWidget * window, |
ea80fe9c3ba4
[svn] - use ConfigureNotify to set playlist location, a proper use of ICCCM.
nenolod
parents:
2491
diff
changeset
|
692 GdkEventConfigure * event, gpointer data) |
ea80fe9c3ba4
[svn] - use ConfigureNotify to set playlist location, a proper use of ICCCM.
nenolod
parents:
2491
diff
changeset
|
693 { |
ea80fe9c3ba4
[svn] - use ConfigureNotify to set playlist location, a proper use of ICCCM.
nenolod
parents:
2491
diff
changeset
|
694 if (!GTK_WIDGET_VISIBLE(window)) |
ea80fe9c3ba4
[svn] - use ConfigureNotify to set playlist location, a proper use of ICCCM.
nenolod
parents:
2491
diff
changeset
|
695 return FALSE; |
2313 | 696 |
2492
ea80fe9c3ba4
[svn] - use ConfigureNotify to set playlist location, a proper use of ICCCM.
nenolod
parents:
2491
diff
changeset
|
697 cfg.playlist_x = event->x; |
ea80fe9c3ba4
[svn] - use ConfigureNotify to set playlist location, a proper use of ICCCM.
nenolod
parents:
2491
diff
changeset
|
698 cfg.playlist_y = event->y; |
ea80fe9c3ba4
[svn] - use ConfigureNotify to set playlist location, a proper use of ICCCM.
nenolod
parents:
2491
diff
changeset
|
699 |
ea80fe9c3ba4
[svn] - use ConfigureNotify to set playlist location, a proper use of ICCCM.
nenolod
parents:
2491
diff
changeset
|
700 return TRUE; |
ea80fe9c3ba4
[svn] - use ConfigureNotify to set playlist location, a proper use of ICCCM.
nenolod
parents:
2491
diff
changeset
|
701 } |
2313 | 702 |
703 static void | |
704 playlistwin_motion(GtkWidget * widget, | |
705 GdkEventMotion * event, | |
706 gpointer callback_data) | |
707 { | |
708 GdkEvent *gevent; | |
709 | |
2491
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
710 /* |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
711 * 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
|
712 * to do all of this stuff by hand. |
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 (playlistwin_resizing == TRUE) |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
715 { |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
716 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
|
717 event->y + playlistwin_resize_y != playlistwin_get_height()) |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
718 { |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
719 playlistwin_resize(event->x + playlistwin_resize_x, |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
720 event->y + playlistwin_resize_y); |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
721 } |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
722 gdk_window_resize(playlistwin->window, |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
723 cfg.playlist_width, cfg.playlist_height); |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
724 } |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
725 else if (dock_is_moving(GTK_WINDOW(playlistwin))) |
2313 | 726 dock_move_motion(GTK_WINDOW(playlistwin), event); |
2491
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
727 else |
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
728 { |
2313 | 729 handle_motion_cb(playlistwin_wlist, widget, event); |
730 draw_playlist_window(FALSE); | |
731 } | |
732 gdk_flush(); | |
733 | |
734 while ((gevent = gdk_event_get()) != NULL) gdk_event_free(gevent); | |
735 } | |
736 | |
737 static void | |
738 playlistwin_enter(GtkWidget * widget, | |
739 GdkEventMotion * event, | |
740 gpointer callback_data) | |
741 { | |
742 playlistwin_list->pl_tooltips = TRUE; | |
743 } | |
744 | |
745 static void | |
746 playlistwin_leave(GtkWidget * widget, | |
747 GdkEventMotion * event, | |
748 gpointer callback_data) | |
749 { | |
750 playlistwin_list->pl_tooltips = FALSE; | |
751 } | |
752 | |
753 static void | |
754 playlistwin_show_filebrowser(void) | |
755 { | |
2416
0fd7f4f969ad
[svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
2373
diff
changeset
|
756 run_filebrowser(NO_PLAY_BUTTON); |
2313 | 757 } |
758 | |
759 static void | |
760 playlistwin_fileinfo(void) | |
761 { | |
762 Playlist *playlist = playlist_get_active(); | |
763 | |
764 /* Show the first selected file, or the current file if nothing is | |
765 * selected */ | |
766 GList *list = playlist_get_selected(playlist); | |
767 if (list) { | |
768 playlist_fileinfo(playlist, GPOINTER_TO_INT(list->data)); | |
769 g_list_free(list); | |
770 } | |
771 else | |
772 playlist_fileinfo_current(playlist); | |
773 } | |
774 | |
775 static void | |
2363 | 776 show_playlist_save_error(GtkWindow *parent, |
777 const gchar *filename) | |
2313 | 778 { |
779 GtkWidget *dialog; | |
780 | |
781 g_return_if_fail(GTK_IS_WINDOW(parent)); | |
2363 | 782 g_return_if_fail(filename); |
2313 | 783 |
784 dialog = gtk_message_dialog_new(GTK_WINDOW(parent), | |
785 GTK_DIALOG_DESTROY_WITH_PARENT, | |
786 GTK_MESSAGE_ERROR, | |
787 GTK_BUTTONS_OK, | |
788 _("Error writing playlist \"%s\": %s"), | |
789 filename, strerror(errno)); | |
790 | |
791 gtk_dialog_run(GTK_DIALOG(dialog)); | |
792 gtk_widget_destroy(dialog); | |
793 } | |
794 | |
795 static gboolean | |
796 show_playlist_overwrite_prompt(GtkWindow * parent, | |
797 const gchar * filename) | |
798 { | |
799 GtkWidget *dialog; | |
800 gint result; | |
801 | |
802 g_return_val_if_fail(GTK_IS_WINDOW(parent), FALSE); | |
803 g_return_val_if_fail(filename != NULL, FALSE); | |
804 | |
805 dialog = gtk_message_dialog_new(GTK_WINDOW(parent), | |
806 GTK_DIALOG_DESTROY_WITH_PARENT, | |
807 GTK_MESSAGE_QUESTION, | |
808 GTK_BUTTONS_YES_NO, | |
809 _("%s already exist. Continue?"), | |
810 filename); | |
811 | |
812 result = gtk_dialog_run(GTK_DIALOG(dialog)); | |
813 gtk_widget_destroy(dialog); | |
814 | |
815 return (result == GTK_RESPONSE_YES); | |
816 } | |
817 | |
818 static void | |
819 show_playlist_save_format_error(GtkWindow * parent, | |
820 const gchar * filename) | |
821 { | |
822 const gchar *markup = | |
823 N_("<b><big>Unable to save playlist.</big></b>\n\n" | |
824 "Unknown file type for '%s'.\n"); | |
825 | |
826 GtkWidget *dialog; | |
827 | |
828 g_return_if_fail(GTK_IS_WINDOW(parent)); | |
829 g_return_if_fail(filename != NULL); | |
830 | |
831 dialog = | |
832 gtk_message_dialog_new_with_markup(GTK_WINDOW(parent), | |
833 GTK_DIALOG_DESTROY_WITH_PARENT, | |
834 GTK_MESSAGE_ERROR, | |
835 GTK_BUTTONS_OK, | |
836 _(markup), | |
837 filename); | |
838 gtk_dialog_run(GTK_DIALOG(dialog)); | |
839 gtk_widget_destroy(dialog); | |
840 } | |
841 | |
842 static void | |
843 playlistwin_save_playlist(const gchar * filename) | |
844 { | |
845 PlaylistContainer *plc; | |
846 gchar *ext = strrchr(filename, '.') + 1; | |
847 | |
848 plc = playlist_container_find(ext); | |
849 if (plc == NULL) { | |
850 show_playlist_save_format_error(GTK_WINDOW(playlistwin), filename); | |
851 return; | |
852 } | |
853 | |
854 str_replace_in(&cfg.playlist_path, g_path_get_dirname(filename)); | |
855 | |
856 if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) | |
857 if (!show_playlist_overwrite_prompt(GTK_WINDOW(playlistwin), filename)) | |
858 return; | |
859 | |
860 if (!playlist_save(playlist_get_active(), filename)) | |
861 show_playlist_save_error(GTK_WINDOW(playlistwin), filename); | |
862 } | |
863 | |
864 static void | |
865 playlistwin_load_playlist(const gchar * filename) | |
866 { | |
867 Playlist *playlist = playlist_get_active(); | |
868 | |
869 g_return_if_fail(filename != NULL); | |
870 | |
871 str_replace_in(&cfg.playlist_path, g_strdup(filename)); | |
872 | |
873 playlist_clear(playlist); | |
874 mainwin_clear_song_info(); | |
875 mainwin_set_info_text(); | |
876 | |
877 playlist_load(playlist, filename); | |
878 playlist_set_current_name(playlist, filename); | |
879 } | |
880 | |
881 static gchar * | |
882 playlist_file_selection_load(const gchar * title, | |
883 const gchar * default_filename) | |
884 { | |
885 static GtkWidget *dialog = NULL; | |
886 GtkWidget *button; | |
887 gchar *filename; | |
888 | |
889 g_return_val_if_fail(title != NULL, NULL); | |
890 | |
891 if(!dialog) { | |
892 dialog = gtk_file_chooser_dialog_new(title, GTK_WINDOW(mainwin), | |
893 GTK_FILE_CHOOSER_ACTION_OPEN, NULL, NULL); | |
894 | |
895 if (default_filename) | |
896 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), | |
897 default_filename); | |
898 | |
899 button = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, | |
900 GTK_RESPONSE_REJECT); | |
901 gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); | |
902 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); | |
903 | |
904 button = gtk_dialog_add_button(GTK_DIALOG(dialog), | |
905 GTK_STOCK_OPEN, | |
906 GTK_RESPONSE_ACCEPT); | |
907 gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); | |
908 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); | |
909 } | |
910 | |
911 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) | |
912 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); | |
913 else | |
914 filename = NULL; | |
915 | |
916 gtk_widget_hide(dialog); | |
917 return filename; | |
918 } | |
919 | |
920 static gchar * | |
921 playlist_file_selection_save(const gchar * title, | |
922 const gchar * default_filename) | |
923 { | |
924 static GtkWidget *dialog = NULL; | |
925 GtkWidget *button; | |
926 gchar *filename; | |
927 | |
928 g_return_val_if_fail(title != NULL, NULL); | |
929 | |
930 if(!dialog) { | |
931 dialog = gtk_file_chooser_dialog_new(title, GTK_WINDOW(mainwin), | |
932 GTK_FILE_CHOOSER_ACTION_SAVE, NULL, NULL); | |
933 | |
934 if (default_filename) | |
935 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), | |
936 default_filename); | |
937 | |
938 button = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, | |
939 GTK_RESPONSE_REJECT); | |
940 gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); | |
941 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); | |
942 | |
943 button = gtk_dialog_add_button(GTK_DIALOG(dialog), | |
944 GTK_STOCK_SAVE, | |
945 GTK_RESPONSE_ACCEPT); | |
946 gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); | |
947 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); | |
948 } | |
949 | |
950 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) | |
951 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); | |
952 else | |
953 filename = NULL; | |
954 | |
955 gtk_widget_hide(dialog); | |
956 return filename; | |
957 } | |
958 | |
959 void | |
960 playlistwin_select_playlist_to_load(const gchar * default_filename) | |
961 { | |
962 gchar *filename = | |
963 playlist_file_selection_load(_("Load Playlist"), default_filename); | |
964 | |
965 if (filename) { | |
966 playlistwin_load_playlist(filename); | |
967 g_free(filename); | |
968 } | |
969 } | |
970 | |
971 static void | |
972 playlistwin_select_playlist_to_save(const gchar * default_filename) | |
973 { | |
974 gchar *dot = NULL, *basename = NULL; | |
975 gchar *filename = | |
976 playlist_file_selection_save(_("Save Playlist"), default_filename); | |
977 | |
978 if (filename) { | |
979 /* Default to xspf if no filename has extension */ | |
980 basename = g_path_get_basename(filename); | |
981 dot = strrchr(basename, '.'); | |
982 if( dot == NULL || dot == basename) { | |
983 gchar *oldname = filename; | |
984 filename = g_strconcat(oldname, ".xspf", NULL); | |
985 g_free(oldname); | |
986 } | |
987 g_free(basename); | |
988 | |
989 playlistwin_save_playlist(filename); | |
990 g_free(filename); | |
991 } | |
992 } | |
993 | |
994 static gboolean | |
995 inside_sensitive_widgets(gint x, gint y) | |
996 { | |
997 return (widget_contains(WIDGET(playlistwin_list), x, y) || | |
998 widget_contains(WIDGET(playlistwin_slider), x, y) || | |
999 widget_contains(WIDGET(playlistwin_close), x, y) || | |
1000 widget_contains(WIDGET(playlistwin_shade), x, y) || | |
1001 widget_contains(WIDGET(playlistwin_time_min), x, y) || | |
1002 widget_contains(WIDGET(playlistwin_time_sec), x, y) || | |
1003 widget_contains(WIDGET(playlistwin_info), x, y) || | |
1004 widget_contains(WIDGET(playlistwin_srew), x, y) || | |
1005 widget_contains(WIDGET(playlistwin_splay), x, y) || | |
1006 widget_contains(WIDGET(playlistwin_spause), x, y) || | |
1007 widget_contains(WIDGET(playlistwin_sstop), x, y) || | |
1008 widget_contains(WIDGET(playlistwin_sfwd), x, y) || | |
1009 widget_contains(WIDGET(playlistwin_seject), x, y) || | |
1010 widget_contains(WIDGET(playlistwin_sscroll_up), x, y) || | |
1011 widget_contains(WIDGET(playlistwin_sscroll_down), x, y)); | |
1012 } | |
1013 | |
1014 #define REGION_L(x1,x2,y1,y2) \ | |
1015 (event->x >= (x1) && event->x < (x2) && \ | |
1016 event->y >= cfg.playlist_height - (y1) && \ | |
1017 event->y < cfg.playlist_height - (y2)) | |
1018 | |
1019 #define REGION_R(x1,x2,y1,y2) \ | |
1020 (event->x >= playlistwin_get_width() - (x1) && \ | |
1021 event->x < playlistwin_get_width() - (x2) && \ | |
1022 event->y >= cfg.playlist_height - (y1) && \ | |
1023 event->y < cfg.playlist_height - (y2)) | |
1024 | |
1025 static void | |
1026 playlistwin_scrolled(GtkWidget * widget, | |
1027 GdkEventScroll * event, | |
1028 gpointer callback_data) | |
1029 { | |
1030 | |
1031 if (event->direction == GDK_SCROLL_DOWN) | |
1032 playlistwin_scroll(cfg.scroll_pl_by); | |
1033 | |
1034 if (event->direction == GDK_SCROLL_UP) | |
1035 playlistwin_scroll(-cfg.scroll_pl_by); | |
1036 | |
1037 g_cond_signal(cond_scan); | |
1038 | |
1039 } | |
1040 | |
1041 static gboolean | |
1042 playlistwin_press(GtkWidget * widget, | |
1043 GdkEventButton * event, | |
1044 gpointer callback_data) | |
1045 { | |
1046 gboolean grab = TRUE; | |
1047 gint xpos, ypos; | |
1048 GtkRequisition req; | |
1049 | |
1050 gtk_window_get_position(GTK_WINDOW(playlistwin), &xpos, &ypos); | |
1051 | |
1052 if (event->button == 1 && !cfg.show_wm_decorations && | |
1053 ((!cfg.playlist_shaded && | |
1054 event->x > playlistwin_get_width() - 20 && | |
1055 event->y > cfg.playlist_height - 20) || | |
1056 (cfg.playlist_shaded && | |
1057 event->x >= playlistwin_get_width() - 31 && | |
1058 event->x < playlistwin_get_width() - 22))) { | |
1059 | |
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 | |
2494
59661bd074b4
[svn] Try to put some skinned window code in a common place.
nenolod
parents:
2492
diff
changeset
|
1671 playlistwin = ui_skinned_window_new(GTK_WINDOW_TOPLEVEL); |
2313 | 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 | |
1681 gtk_window_set_transient_for(GTK_WINDOW(playlistwin), | |
1682 GTK_WINDOW(mainwin)); | |
1683 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(playlistwin), TRUE); | |
1684 | |
1685 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) bmp_playlist_icon); | |
1686 gtk_window_set_icon(GTK_WINDOW(playlistwin), icon); | |
1687 g_object_unref(icon); | |
1688 | |
1689 gtk_widget_set_app_paintable(playlistwin, TRUE); | |
1690 | |
1691 if (cfg.playlist_x != -1 && cfg.save_window_position) | |
1692 gtk_window_move(GTK_WINDOW(playlistwin), | |
1693 cfg.playlist_x, cfg.playlist_y); | |
1694 | |
1695 gtk_widget_add_events(playlistwin, GDK_POINTER_MOTION_MASK | | |
1696 GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_MOTION_MASK | | |
1697 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | |
1698 GDK_SCROLL_MASK | GDK_VISIBILITY_NOTIFY_MASK); | |
1699 gtk_widget_realize(playlistwin); | |
1700 | |
1701 g_signal_connect(playlistwin, "delete_event", | |
1702 G_CALLBACK(playlistwin_delete), NULL); | |
1703 g_signal_connect(playlistwin, "button_press_event", | |
1704 G_CALLBACK(playlistwin_press), NULL); | |
1705 g_signal_connect(playlistwin, "button_release_event", | |
1706 G_CALLBACK(playlistwin_release), NULL); | |
1707 g_signal_connect(playlistwin, "scroll_event", | |
1708 G_CALLBACK(playlistwin_scrolled), NULL); | |
1709 g_signal_connect(playlistwin, "motion_notify_event", | |
1710 G_CALLBACK(playlistwin_motion), NULL); | |
1711 g_signal_connect(playlistwin, "enter_notify_event", | |
1712 G_CALLBACK(playlistwin_enter), NULL); | |
1713 g_signal_connect(playlistwin, "leave_notify_event", | |
1714 G_CALLBACK(playlistwin_leave), NULL); | |
1715 g_signal_connect_after(playlistwin, "focus_in_event", | |
1716 G_CALLBACK(playlistwin_focus_in), NULL); | |
1717 g_signal_connect_after(playlistwin, "focus_out_event", | |
1718 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
|
1719 g_signal_connect(playlistwin, "configure_event", |
ea80fe9c3ba4
[svn] - use ConfigureNotify to set playlist location, a proper use of ICCCM.
nenolod
parents:
2491
diff
changeset
|
1720 G_CALLBACK(playlistwin_configure), NULL); |
2313 | 1721 g_signal_connect(playlistwin, "style_set", |
1722 G_CALLBACK(playlistwin_set_back_pixmap), NULL); | |
1723 | |
1724 bmp_drag_dest_set(playlistwin); | |
1725 | |
1726 /* DnD stuff */ | |
1727 g_signal_connect(playlistwin, "drag-leave", | |
1728 G_CALLBACK(playlistwin_drag_end), NULL); | |
1729 g_signal_connect(playlistwin, "drag-data-delete", | |
1730 G_CALLBACK(playlistwin_drag_end), NULL); | |
1731 g_signal_connect(playlistwin, "drag-end", | |
1732 G_CALLBACK(playlistwin_drag_end), NULL); | |
1733 g_signal_connect(playlistwin, "drag-drop", | |
1734 G_CALLBACK(playlistwin_drag_end), NULL); | |
1735 g_signal_connect(playlistwin, "drag-data-received", | |
1736 G_CALLBACK(playlistwin_drag_data_received), NULL); | |
1737 g_signal_connect(playlistwin, "drag-motion", | |
1738 G_CALLBACK(playlistwin_drag_motion), NULL); | |
1739 | |
1740 g_signal_connect(playlistwin, "key_press_event", | |
1741 G_CALLBACK(playlistwin_keypress), NULL); | |
1742 g_signal_connect(playlistwin, "selection_received", | |
1743 G_CALLBACK(selection_received), NULL); | |
1744 | |
1745 playlistwin_set_mask(); | |
1746 } | |
1747 | |
1748 void | |
1749 playlistwin_create(void) | |
1750 { | |
1751 playlistwin_create_window(); | |
1752 | |
1753 /* create GC and back pixmap for custom widget to draw on */ | |
1754 playlistwin_gc = gdk_gc_new(playlistwin->window); | |
1755 playlistwin_bg = gdk_pixmap_new(playlistwin->window, | |
1756 playlistwin_get_width(), | |
1757 playlistwin_get_height_unshaded(), -1); | |
1758 gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0); | |
1759 | |
1760 playlistwin_create_widgets(); | |
1761 playlistwin_update_info(playlist_get_active()); | |
1762 | |
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
|
1763 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
|
1764 |
2313 | 1765 gtk_window_add_accel_group(GTK_WINDOW(playlistwin), ui_manager_get_accel_group()); |
1766 } | |
1767 | |
1768 | |
1769 void | |
1770 playlistwin_show(void) | |
1771 { | |
1772 GtkAction *action = gtk_action_group_get_action( | |
1773 toggleaction_group_others , "show playlist editor" ); | |
1774 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , TRUE ); | |
1775 | |
1776 tbutton_set_toggled(mainwin_pl, TRUE); | |
1777 cfg.playlist_visible = TRUE; | |
1778 | |
1779 playlistwin_set_toprow(0); | |
1780 playlist_check_pos_current(playlist_get_active()); | |
1781 | |
2351
911743d27aba
[svn] - simplify and optimize the metadata tooltip trigger function
giacomo
parents:
2348
diff
changeset
|
1782 if ( playlistwin_infopopup_sid == 0 ) |
911743d27aba
[svn] - simplify and optimize the metadata tooltip trigger function
giacomo
parents:
2348
diff
changeset
|
1783 playlistwin_infopopup_sid = g_timeout_add( |
911743d27aba
[svn] - simplify and optimize the metadata tooltip trigger function
giacomo
parents:
2348
diff
changeset
|
1784 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
|
1785 |
2313 | 1786 gtk_widget_show(playlistwin); |
1787 } | |
1788 | |
1789 void | |
1790 playlistwin_hide(void) | |
1791 { | |
1792 GtkAction *action = gtk_action_group_get_action( | |
1793 toggleaction_group_others , "show playlist editor" ); | |
1794 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , FALSE ); | |
1795 | |
1796 gtk_widget_hide(playlistwin); | |
1797 tbutton_set_toggled(mainwin_pl, FALSE); | |
1798 cfg.playlist_visible = FALSE; | |
1799 | |
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
|
1800 /* 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
|
1801 if ( playlistwin_infopopup_sid != 0 ) |
2351
911743d27aba
[svn] - simplify and optimize the metadata tooltip trigger function
giacomo
parents:
2348
diff
changeset
|
1802 { |
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
|
1803 g_source_remove( playlistwin_infopopup_sid ); |
2351
911743d27aba
[svn] - simplify and optimize the metadata tooltip trigger function
giacomo
parents:
2348
diff
changeset
|
1804 playlistwin_infopopup_sid = 0; |
911743d27aba
[svn] - simplify and optimize the metadata tooltip trigger function
giacomo
parents:
2348
diff
changeset
|
1805 } |
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
|
1806 |
2338
d0a04f1ee732
[svn] - in playlistwin_hide(), pass focus to the player main window only if it's visible
giacomo
parents:
2328
diff
changeset
|
1807 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
|
1808 { |
d0a04f1ee732
[svn] - in playlistwin_hide(), pass focus to the player main window only if it's visible
giacomo
parents:
2328
diff
changeset
|
1809 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
|
1810 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
|
1811 } |
2313 | 1812 } |
1813 | |
1814 void action_playlist_track_info(void) | |
1815 { | |
1816 playlistwin_fileinfo(); | |
1817 } | |
1818 | |
1819 void action_queue_toggle(void) | |
1820 { | |
1821 playlist_queue(playlist_get_active()); | |
1822 } | |
1823 | |
1824 void action_playlist_sort_by_playlist_entry(void) | |
1825 { | |
1826 Playlist *playlist = playlist_get_active(); | |
1827 | |
1828 playlist_sort(playlist, PLAYLIST_SORT_PLAYLIST); | |
1829 playlistwin_update_list(playlist); | |
1830 } | |
1831 | |
1832 void action_playlist_sort_by_track_number(void) | |
1833 { | |
1834 Playlist *playlist = playlist_get_active(); | |
1835 | |
1836 playlist_sort(playlist, PLAYLIST_SORT_TRACK); | |
1837 playlistwin_update_list(playlist); | |
1838 } | |
1839 | |
1840 void action_playlist_sort_by_title(void) | |
1841 { | |
1842 Playlist *playlist = playlist_get_active(); | |
1843 | |
1844 playlist_sort(playlist, PLAYLIST_SORT_TITLE); | |
1845 playlistwin_update_list(playlist); | |
1846 } | |
1847 | |
1848 void action_playlist_sort_by_artist(void) | |
1849 { | |
1850 Playlist *playlist = playlist_get_active(); | |
1851 | |
1852 playlist_sort(playlist, PLAYLIST_SORT_ARTIST); | |
1853 playlistwin_update_list(playlist); | |
1854 } | |
1855 | |
1856 void action_playlist_sort_by_full_path(void) | |
1857 { | |
1858 Playlist *playlist = playlist_get_active(); | |
1859 | |
1860 playlist_sort(playlist, PLAYLIST_SORT_PATH); | |
1861 playlistwin_update_list(playlist); | |
1862 } | |
1863 | |
1864 void action_playlist_sort_by_date(void) | |
1865 { | |
1866 Playlist *playlist = playlist_get_active(); | |
1867 | |
1868 playlist_sort(playlist, PLAYLIST_SORT_DATE); | |
1869 playlistwin_update_list(playlist); | |
1870 } | |
1871 | |
1872 void action_playlist_sort_by_filename(void) | |
1873 { | |
1874 Playlist *playlist = playlist_get_active(); | |
1875 | |
1876 playlist_sort(playlist, PLAYLIST_SORT_FILENAME); | |
1877 playlistwin_update_list(playlist); | |
1878 } | |
1879 | |
1880 void action_playlist_sort_selected_by_playlist_entry(void) | |
1881 { | |
1882 Playlist *playlist = playlist_get_active(); | |
1883 | |
1884 playlist_sort_selected(playlist, PLAYLIST_SORT_PLAYLIST); | |
1885 playlistwin_update_list(playlist); | |
1886 } | |
1887 | |
1888 void action_playlist_sort_selected_by_track_number(void) | |
1889 { | |
1890 Playlist *playlist = playlist_get_active(); | |
1891 | |
1892 playlist_sort_selected(playlist, PLAYLIST_SORT_TRACK); | |
1893 playlistwin_update_list(playlist); | |
1894 } | |
1895 | |
1896 void action_playlist_sort_selected_by_title(void) | |
1897 { | |
1898 Playlist *playlist = playlist_get_active(); | |
1899 | |
1900 playlist_sort_selected(playlist, PLAYLIST_SORT_TITLE); | |
1901 playlistwin_update_list(playlist); | |
1902 } | |
1903 | |
1904 void action_playlist_sort_selected_by_artist(void) | |
1905 { | |
1906 Playlist *playlist = playlist_get_active(); | |
1907 | |
1908 playlist_sort_selected(playlist, PLAYLIST_SORT_ARTIST); | |
1909 playlistwin_update_list(playlist); | |
1910 } | |
1911 | |
1912 void action_playlist_sort_selected_by_full_path(void) | |
1913 { | |
1914 Playlist *playlist = playlist_get_active(); | |
1915 | |
1916 playlist_sort_selected(playlist, PLAYLIST_SORT_PATH); | |
1917 playlistwin_update_list(playlist); | |
1918 } | |
1919 | |
1920 void action_playlist_sort_selected_by_date(void) | |
1921 { | |
1922 Playlist *playlist = playlist_get_active(); | |
1923 | |
1924 playlist_sort_selected(playlist, PLAYLIST_SORT_DATE); | |
1925 playlistwin_update_list(playlist); | |
1926 } | |
1927 | |
1928 void action_playlist_sort_selected_by_filename(void) | |
1929 { | |
1930 Playlist *playlist = playlist_get_active(); | |
1931 | |
1932 playlist_sort_selected(playlist, PLAYLIST_SORT_FILENAME); | |
1933 playlistwin_update_list(playlist); | |
1934 } | |
1935 | |
1936 void action_playlist_randomize_list(void) | |
1937 { | |
1938 Playlist *playlist = playlist_get_active(); | |
1939 | |
1940 playlist_random(playlist); | |
1941 playlistwin_update_list(playlist); | |
1942 } | |
1943 | |
1944 void action_playlist_reverse_list(void) | |
1945 { | |
1946 Playlist *playlist = playlist_get_active(); | |
1947 | |
1948 playlist_reverse(playlist); | |
1949 playlistwin_update_list(playlist); | |
1950 } | |
1951 | |
1952 void | |
1953 action_playlist_clear_queue(void) | |
1954 { | |
1955 playlist_clear_queue(playlist_get_active()); | |
1956 } | |
1957 | |
1958 void | |
1959 action_playlist_remove_unavailable(void) | |
1960 { | |
1961 playlist_remove_dead_files(playlist_get_active()); | |
1962 } | |
1963 | |
1964 void | |
1965 action_playlist_remove_dupes_by_title(void) | |
1966 { | |
1967 playlist_remove_duplicates(playlist_get_active(), PLAYLIST_DUPS_TITLE); | |
1968 } | |
1969 | |
1970 void | |
1971 action_playlist_remove_dupes_by_filename(void) | |
1972 { | |
1973 playlist_remove_duplicates(playlist_get_active(), PLAYLIST_DUPS_FILENAME); | |
1974 } | |
1975 | |
1976 void | |
1977 action_playlist_remove_dupes_by_full_path(void) | |
1978 { | |
1979 playlist_remove_duplicates(playlist_get_active(), PLAYLIST_DUPS_PATH); | |
1980 } | |
1981 | |
1982 void | |
1983 action_playlist_remove_all(void) | |
1984 { | |
1985 playlist_clear(playlist_get_active()); | |
1986 | |
1987 /* XXX -- should this really be coupled here? -nenolod */ | |
1988 mainwin_clear_song_info(); | |
1989 mainwin_set_info_text(); | |
1990 } | |
1991 | |
1992 void | |
1993 action_playlist_remove_selected(void) | |
1994 { | |
1995 playlist_delete(playlist_get_active(), FALSE); | |
1996 } | |
1997 | |
1998 void | |
1999 action_playlist_remove_unselected(void) | |
2000 { | |
2001 playlist_delete(playlist_get_active(), TRUE); | |
2002 } | |
2003 | |
2004 void | |
2005 action_playlist_add_files(void) | |
2006 { | |
2416
0fd7f4f969ad
[svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
2373
diff
changeset
|
2007 run_filebrowser(NO_PLAY_BUTTON); |
2313 | 2008 } |
2009 | |
2010 void add_medium(void); /* XXX */ | |
2011 | |
2012 void | |
2013 action_playlist_add_cd(void) | |
2014 { | |
2015 add_medium(); | |
2016 } | |
2017 | |
2018 void | |
2019 action_playlist_add_url(void) | |
2020 { | |
2021 mainwin_show_add_url_window(); | |
2022 } | |
2023 | |
2024 void | |
2025 action_playlist_new( void ) | |
2026 { | |
2027 Playlist *new_pl = playlist_new(); | |
2028 playlist_add_playlist(new_pl); | |
2029 playlist_select_playlist(new_pl); | |
2030 } | |
2031 | |
2032 void | |
2033 action_playlist_prev( void ) | |
2034 { | |
2035 playlist_select_prev(); | |
2036 } | |
2037 | |
2038 void | |
2039 action_playlist_next( void ) | |
2040 { | |
2041 playlist_select_next(); | |
2042 } | |
2043 | |
2044 void | |
2045 action_playlist_delete( void ) | |
2046 { | |
2047 playlist_remove_playlist( playlist_get_active() ); | |
2048 } | |
2049 | |
2050 void | |
2051 action_playlist_save_list(void) | |
2052 { | |
2053 Playlist *playlist = playlist_get_active(); | |
2054 | |
2055 playlistwin_select_playlist_to_save(playlist_get_current_name(playlist)); | |
2056 } | |
2057 | |
2058 void | |
2059 action_playlist_save_default_list(void) | |
2060 { | |
2061 Playlist *playlist = playlist_get_active(); | |
2062 | |
2063 playlist_save(playlist, bmp_paths[BMP_PATH_PLAYLIST_FILE]); | |
2064 } | |
2065 | |
2066 void | |
2067 action_playlist_load_list(void) | |
2068 { | |
2069 Playlist *playlist = playlist_get_active(); | |
2070 | |
2071 playlistwin_select_playlist_to_load(playlist_get_current_name(playlist)); | |
2072 } | |
2073 | |
2074 void | |
2075 action_playlist_refresh_list(void) | |
2076 { | |
2077 Playlist *playlist = playlist_get_active(); | |
2078 | |
2079 playlist_read_info_selection(playlist); | |
2080 playlistwin_update_list(playlist); | |
2081 } | |
2082 | |
2083 void | |
2084 action_open_list_manager(void) | |
2085 { | |
2086 playlist_manager_ui_show(); | |
2087 } | |
2088 | |
2089 void | |
2090 action_playlist_search_and_select(void) | |
2091 { | |
2092 playlistwin_select_search(); | |
2093 } | |
2094 | |
2095 void | |
2096 action_playlist_invert_selection(void) | |
2097 { | |
2098 playlistwin_inverse_selection(); | |
2099 } | |
2100 | |
2101 void | |
2102 action_playlist_select_none(void) | |
2103 { | |
2104 playlistwin_select_none(); | |
2105 } | |
2106 | |
2107 void | |
2108 action_playlist_select_all(void) | |
2109 { | |
2110 playlistwin_select_all(); | |
2111 } | |
2112 | |
2113 | |
2114 | |
2115 /* playlistwin_select_search callback functions | |
2116 placed here to avoid making the code messier :) */ | |
2117 void | |
2363 | 2118 playlistwin_select_search_cbt_cb(GtkWidget *called_cbt, gpointer other_cbt) |
2313 | 2119 { |
2363 | 2120 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(called_cbt)) == TRUE) |
2121 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(other_cbt), FALSE); | |
2313 | 2122 return; |
2123 } | |
2124 | |
2125 static gboolean | |
2363 | 2126 playlistwin_select_search_kp_cb(GtkWidget *entry, GdkEventKey *event, |
2127 gpointer searchdlg_win) | |
2313 | 2128 { |
2129 switch (event->keyval) | |
2130 { | |
2131 case GDK_Return: | |
2363 | 2132 gtk_dialog_response(GTK_DIALOG(searchdlg_win), GTK_RESPONSE_ACCEPT); |
2313 | 2133 return TRUE; |
2134 default: | |
2135 return FALSE; | |
2136 } | |
2137 } | |
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
|
2138 |
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
|
2139 |
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
|
2140 /* 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
|
2141 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
|
2142 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
|
2143 { |
2363 | 2144 gint x, y, pos; |
2145 TitleInput *tuple; | |
2146 static gint prev_x = 0, prev_y = 0, ctr = 0, prev_pos = -1; | |
2147 static gint shaded_pos = -1, shaded_prev_pos = -1; | |
2148 gboolean skip = FALSE; | |
2149 GdkWindow *win; | |
2150 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
|
2151 |
2363 | 2152 win = gdk_window_at_pointer(NULL, NULL); |
2153 gdk_window_get_pointer(GDK_WINDOW(playlistwin->window), &x, &y, NULL); | |
2154 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
|
2155 |
2363 | 2156 if (win == NULL |
2157 || cfg.show_filepopup_for_tuple == FALSE | |
2158 || playlistwin_list->pl_tooltips == FALSE | |
2159 || pos != prev_pos | |
2160 || win != GDK_WINDOW(playlistwin->window)) | |
2161 { | |
2162 prev_pos = pos; | |
2163 ctr = 0; | |
2164 audacious_fileinfopopup_hide(GTK_WIDGET(filepopup_win), NULL); | |
2165 return TRUE; | |
2166 } | |
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
|
2167 |
2363 | 2168 if (prev_x == x && prev_y == y) |
2169 ctr++; | |
2170 else | |
2171 { | |
2172 ctr = 0; | |
2173 prev_x = x; | |
2174 prev_y = y; | |
2175 audacious_fileinfopopup_hide(GTK_WIDGET(filepopup_win), NULL); | |
2176 return TRUE; | |
2177 } | |
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
|
2178 |
2363 | 2179 if (playlistwin_is_shaded()) |
2180 { | |
2181 shaded_pos = playlist_get_position(playlist); | |
2182 if (shaded_prev_pos != shaded_pos) | |
2183 skip = TRUE; | |
2184 } | |
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
|
2185 |
2351
911743d27aba
[svn] - simplify and optimize the metadata tooltip trigger function
giacomo
parents:
2348
diff
changeset
|
2186 if (ctr >= cfg.filepopup_delay && (skip == TRUE || GTK_WIDGET_VISIBLE(GTK_WIDGET(filepopup_win)) != TRUE)) { |
2363 | 2187 if (pos == -1 && !playlistwin_is_shaded()) |
2188 { | |
2189 audacious_fileinfopopup_hide(GTK_WIDGET(filepopup_win), NULL); | |
2190 return TRUE; | |
2191 } | |
2192 /* shaded mode */ | |
2193 else | |
2194 { | |
2195 tuple = playlist_get_tuple(playlist, shaded_pos); | |
2196 audacious_fileinfopopup_hide(GTK_WIDGET(filepopup_win), NULL); | |
2197 audacious_fileinfopopup_show_from_tuple(GTK_WIDGET(filepopup_win), tuple); | |
2198 shaded_prev_pos = shaded_pos; | |
2199 } | |
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
|
2200 |
2363 | 2201 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
|
2202 |
2363 | 2203 tuple = playlist_get_tuple(playlist, pos); |
2204 audacious_fileinfopopup_show_from_tuple(GTK_WIDGET(filepopup_win), tuple); | |
2205 } | |
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
|
2206 |
2363 | 2207 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
|
2208 } |