Mercurial > audlegacy-plugins
annotate src/skins/ui_playlist.c @ 2795:4c9db0b2194f
added strcasestr implementation; improved searching and updating
author | Calin Crisan ccrisan@gmail.com |
---|---|
date | Thu, 10 Jul 2008 01:40:57 +0300 |
parents | b34c4e3d9488 |
children | f3e242d1855b |
rev | line source |
---|---|
2620 | 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 3 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, see <http://www.gnu.org/licenses>. | |
21 * | |
22 * The Audacious team does not consider modular code linking to | |
23 * Audacious or using our public API to be a derived work. | |
24 */ | |
25 | |
26 /* #define AUD_DEBUG 1 */ | |
27 | |
28 #include "ui_playlist.h" | |
29 | |
30 #include <glib.h> | |
31 #include <glib/gi18n.h> | |
32 #include <gdk/gdk.h> | |
33 #include <gdk/gdkkeysyms.h> | |
34 #include <gtk/gtk.h> | |
35 #include <string.h> | |
36 | |
37 #include "platform/smartinclude.h" | |
38 | |
39 #include <unistd.h> | |
40 #include <errno.h> | |
41 | |
42 #include "actions-playlist.h" | |
2629
2ce9e17525dc
make dnd working in playlistwin
Tomasz Mon <desowin@gmail.com>
parents:
2621
diff
changeset
|
43 #include "dnd.h" |
2620 | 44 #if 0 |
45 #include "input.h" | |
46 #include "main.h" | |
47 #include "playback.h" | |
48 #include "playlist.h" | |
49 #include "playlist_container.h" | |
50 #include "strings.h" | |
51 #endif | |
52 #include "ui_dock.h" | |
53 #include "ui_equalizer.h" | |
54 #include "ui_main.h" | |
55 #include "ui_manager.h" | |
56 #include "ui_playlist_evlisteners.h" | |
57 #include "ui_playlist_manager.h" | |
58 #include "util.h" | |
59 | |
60 #include "ui_skinned_window.h" | |
61 #include "ui_skinned_button.h" | |
62 #include "ui_skinned_textbox.h" | |
63 #include "ui_skinned_playlist_slider.h" | |
64 #include "ui_skinned_playlist.h" | |
65 | |
66 #include "icons-stock.h" | |
67 #include "images/audacious_playlist.xpm" | |
68 | |
69 GtkWidget *playlistwin; | |
70 | |
71 static GMutex *resize_mutex = NULL; | |
72 | |
73 static GtkWidget *playlistwin_list = NULL; | |
74 static GtkWidget *playlistwin_shade, *playlistwin_close; | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
75 static GtkWidget *playlistwin_shaded_shade, *playlistwin_shaded_close; |
2620 | 76 |
77 static gboolean playlistwin_hint_flag = FALSE; | |
78 | |
79 static GtkWidget *playlistwin_slider; | |
80 static GtkWidget *playlistwin_time_min, *playlistwin_time_sec; | |
81 static GtkWidget *playlistwin_info, *playlistwin_sinfo; | |
82 static GtkWidget *playlistwin_srew, *playlistwin_splay; | |
83 static GtkWidget *playlistwin_spause, *playlistwin_sstop; | |
84 static GtkWidget *playlistwin_sfwd, *playlistwin_seject; | |
85 static GtkWidget *playlistwin_sscroll_up, *playlistwin_sscroll_down; | |
86 | |
87 static void playlistwin_select_search_cbt_cb(GtkWidget *called_cbt, | |
88 gpointer other_cbt); | |
89 static gboolean playlistwin_select_search_kp_cb(GtkWidget *entry, | |
90 GdkEventKey *event, | |
91 gpointer searchdlg_win); | |
92 | |
93 static gboolean playlistwin_resizing = FALSE; | |
94 static gint playlistwin_resize_x, playlistwin_resize_y; | |
95 | |
96 gboolean | |
97 playlistwin_is_shaded(void) | |
98 { | |
99 return config.playlist_shaded; | |
100 } | |
101 | |
102 gint | |
103 playlistwin_get_width(void) | |
104 { | |
105 config.playlist_width /= PLAYLISTWIN_WIDTH_SNAP; | |
106 config.playlist_width *= PLAYLISTWIN_WIDTH_SNAP; | |
107 return config.playlist_width; | |
108 } | |
109 | |
110 gint | |
111 playlistwin_get_height_unshaded(void) | |
112 { | |
113 config.playlist_height /= PLAYLISTWIN_HEIGHT_SNAP; | |
114 config.playlist_height *= PLAYLISTWIN_HEIGHT_SNAP; | |
115 return config.playlist_height; | |
116 } | |
117 | |
118 gint | |
119 playlistwin_get_height_shaded(void) | |
120 { | |
121 return PLAYLISTWIN_SHADED_HEIGHT; | |
122 } | |
123 | |
124 gint | |
125 playlistwin_get_height(void) | |
126 { | |
127 if (playlistwin_is_shaded()) | |
128 return playlistwin_get_height_shaded(); | |
129 else | |
130 return playlistwin_get_height_unshaded(); | |
131 } | |
132 | |
133 static void | |
134 playlistwin_update_info(Playlist *playlist) | |
135 { | |
2634
43a07a0607da
make playlistwin_update_info and playlistwin_update_sinfo working
Tomasz Mon <desowin@gmail.com>
parents:
2629
diff
changeset
|
136 g_return_if_fail(playlist != NULL); |
43a07a0607da
make playlistwin_update_info and playlistwin_update_sinfo working
Tomasz Mon <desowin@gmail.com>
parents:
2629
diff
changeset
|
137 |
2620 | 138 gchar *text, *sel_text, *tot_text; |
139 gulong selection, total; | |
140 gboolean selection_more, total_more; | |
141 | |
142 aud_playlist_get_total_time(playlist, &total, &selection, &total_more, &selection_more); | |
143 | |
144 if (selection > 0 || (selection == 0 && !selection_more)) { | |
145 if (selection > 3600) | |
146 sel_text = | |
147 g_strdup_printf("%lu:%-2.2lu:%-2.2lu%s", selection / 3600, | |
148 (selection / 60) % 60, selection % 60, | |
149 (selection_more ? "+" : "")); | |
150 else | |
151 sel_text = | |
152 g_strdup_printf("%lu:%-2.2lu%s", selection / 60, | |
153 selection % 60, (selection_more ? "+" : "")); | |
154 } | |
155 else | |
156 sel_text = g_strdup("?"); | |
157 if (total > 0 || (total == 0 && !total_more)) { | |
158 if (total > 3600) | |
159 tot_text = | |
160 g_strdup_printf("%lu:%-2.2lu:%-2.2lu%s", total / 3600, | |
161 (total / 60) % 60, total % 60, | |
162 total_more ? "+" : ""); | |
163 else | |
164 tot_text = | |
165 g_strdup_printf("%lu:%-2.2lu%s", total / 60, total % 60, | |
166 total_more ? "+" : ""); | |
167 } | |
168 else | |
169 tot_text = g_strdup("?"); | |
170 text = g_strconcat(sel_text, "/", tot_text, NULL); | |
171 ui_skinned_textbox_set_text(playlistwin_info, text ? text : ""); | |
172 g_free(text); | |
173 g_free(tot_text); | |
174 g_free(sel_text); | |
175 } | |
176 | |
177 static void | |
178 playlistwin_update_sinfo(Playlist *playlist) | |
179 { | |
2634
43a07a0607da
make playlistwin_update_info and playlistwin_update_sinfo working
Tomasz Mon <desowin@gmail.com>
parents:
2629
diff
changeset
|
180 g_return_if_fail(playlist != NULL); |
43a07a0607da
make playlistwin_update_info and playlistwin_update_sinfo working
Tomasz Mon <desowin@gmail.com>
parents:
2629
diff
changeset
|
181 |
2620 | 182 gchar *posstr, *timestr, *title, *info; |
183 gint pos, time; | |
184 | |
185 pos = aud_playlist_get_position(playlist); | |
186 title = aud_playlist_get_songtitle(playlist, pos); | |
187 | |
188 if (!title) { | |
189 ui_skinned_textbox_set_text(playlistwin_sinfo, ""); | |
190 return; | |
191 } | |
192 | |
193 aud_convert_title_text(title); | |
194 | |
195 time = aud_playlist_get_songtime(playlist, pos); | |
196 | |
197 if (config.show_numbers_in_pl) | |
198 posstr = g_strdup_printf("%d. ", pos + 1); | |
199 else | |
200 posstr = g_strdup(""); | |
201 | |
202 if (time != -1) { | |
203 timestr = g_strdup_printf(" (%d:%-2.2d)", time / 60000, | |
204 (time / 1000) % 60); | |
205 } | |
206 else | |
207 timestr = g_strdup(""); | |
208 | |
209 info = g_strdup_printf("%s%s%s", posstr, title, timestr); | |
210 | |
211 g_free(posstr); | |
212 g_free(title); | |
213 g_free(timestr); | |
214 | |
215 ui_skinned_textbox_set_text(playlistwin_sinfo, info ? info : ""); | |
216 g_free(info); | |
217 } | |
218 | |
219 gboolean | |
220 playlistwin_item_visible(gint index) | |
221 { | |
222 g_return_val_if_fail(UI_SKINNED_IS_PLAYLIST(playlistwin_list), FALSE); | |
223 | |
224 if (index >= UI_SKINNED_PLAYLIST(playlistwin_list)->first && | |
225 index < (UI_SKINNED_PLAYLIST(playlistwin_list)->first + UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible) ) { | |
226 return TRUE; | |
227 } | |
228 return FALSE; | |
229 } | |
230 | |
231 gint | |
232 playlistwin_list_get_visible_count(void) | |
233 { | |
234 g_return_val_if_fail(UI_SKINNED_IS_PLAYLIST(playlistwin_list), -1); | |
235 | |
236 return UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible; | |
237 } | |
238 | |
239 gint | |
240 playlistwin_list_get_first(void) | |
241 { | |
242 g_return_val_if_fail(UI_SKINNED_IS_PLAYLIST(playlistwin_list), -1); | |
243 | |
244 return UI_SKINNED_PLAYLIST(playlistwin_list)->first; | |
245 } | |
246 | |
247 gint | |
248 playlistwin_get_toprow(void) | |
249 { | |
250 g_return_val_if_fail(UI_SKINNED_IS_PLAYLIST(playlistwin_list), -1); | |
251 | |
252 return (UI_SKINNED_PLAYLIST(playlistwin_list)->first); | |
253 } | |
254 | |
255 void | |
256 playlistwin_set_toprow(gint toprow) | |
257 { | |
258 if (UI_SKINNED_IS_PLAYLIST(playlistwin_list)) | |
259 UI_SKINNED_PLAYLIST(playlistwin_list)->first = toprow; | |
260 #if 0 | |
261 g_cond_signal(cond_scan); | |
262 #endif | |
263 playlistwin_update_list(aud_playlist_get_active()); | |
264 } | |
265 | |
266 void | |
267 playlistwin_update_list(Playlist *playlist) | |
268 { | |
269 /* this can happen early on. just bail gracefully. */ | |
270 g_return_if_fail(playlistwin_list); | |
271 | |
272 playlistwin_update_info(playlist); | |
273 playlistwin_update_sinfo(playlist); | |
274 gtk_widget_queue_draw(playlistwin_list); | |
275 gtk_widget_queue_draw(playlistwin_slider); | |
276 } | |
277 | |
278 static void | |
279 playlistwin_set_geometry_hints(gboolean shaded) | |
280 { | |
281 GdkGeometry geometry; | |
282 GdkWindowHints mask; | |
283 | |
284 geometry.min_width = PLAYLISTWIN_MIN_WIDTH; | |
285 geometry.max_width = G_MAXUINT16; | |
286 | |
287 geometry.width_inc = PLAYLISTWIN_WIDTH_SNAP; | |
288 geometry.height_inc = PLAYLISTWIN_HEIGHT_SNAP; | |
289 | |
290 if (shaded) { | |
291 geometry.min_height = PLAYLISTWIN_SHADED_HEIGHT; | |
292 geometry.max_height = PLAYLISTWIN_SHADED_HEIGHT; | |
293 geometry.base_height = PLAYLISTWIN_SHADED_HEIGHT; | |
294 } | |
295 else { | |
296 geometry.min_height = PLAYLISTWIN_MIN_HEIGHT; | |
297 geometry.max_height = G_MAXUINT16; | |
298 } | |
299 | |
300 mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_RESIZE_INC; | |
301 | |
302 gtk_window_set_geometry_hints(GTK_WINDOW(playlistwin), | |
303 playlistwin, &geometry, mask); | |
304 } | |
305 | |
306 void | |
307 playlistwin_set_sinfo_font(gchar *font) | |
308 { | |
309 gchar *tmp = NULL, *tmp2 = NULL; | |
310 | |
311 g_return_if_fail(font); | |
312 AUDDBG("Attempt to set font \"%s\"\n", font); | |
313 | |
314 tmp = g_strdup(font); | |
315 g_return_if_fail(tmp); | |
316 | |
317 *strrchr(tmp, ' ') = '\0'; | |
318 tmp2 = g_strdup_printf("%s 8", tmp); | |
319 g_return_if_fail(tmp2); | |
320 | |
321 ui_skinned_textbox_set_xfont(playlistwin_sinfo, !config.mainwin_use_bitmapfont, tmp2); | |
322 | |
323 g_free(tmp); | |
324 g_free(tmp2); | |
325 } | |
326 | |
327 void | |
328 playlistwin_set_sinfo_scroll(gboolean scroll) | |
329 { | |
330 if(playlistwin_is_shaded()) | |
331 ui_skinned_textbox_set_scroll(playlistwin_sinfo, config.autoscroll); | |
332 else | |
333 ui_skinned_textbox_set_scroll(playlistwin_sinfo, FALSE); | |
334 } | |
335 | |
336 void | |
337 playlistwin_set_shade(gboolean shaded) | |
338 { | |
339 config.playlist_shaded = shaded; | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
340 ui_skinned_window_set_shade(playlistwin, shaded); |
2620 | 341 |
342 if (shaded) { | |
2642 | 343 playlistwin_set_sinfo_font(config.playlist_font); |
2620 | 344 playlistwin_set_sinfo_scroll(config.autoscroll); |
345 } | |
346 else { | |
347 playlistwin_set_sinfo_scroll(FALSE); | |
348 } | |
349 | |
350 dock_shade(get_dock_window_list(), GTK_WINDOW(playlistwin), | |
351 playlistwin_get_height()); | |
352 | |
353 playlistwin_set_geometry_hints(config.playlist_shaded); | |
354 | |
355 gtk_window_resize(GTK_WINDOW(playlistwin), | |
356 playlistwin_get_width(), | |
357 playlistwin_get_height()); | |
358 } | |
359 | |
360 static void | |
361 playlistwin_set_shade_menu(gboolean shaded) | |
362 { | |
363 GtkAction *action = gtk_action_group_get_action( | |
364 toggleaction_group_others , "roll up playlist editor" ); | |
365 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , shaded ); | |
366 | |
367 playlistwin_set_shade(shaded); | |
368 playlistwin_update_list(aud_playlist_get_active()); | |
369 } | |
370 | |
371 void | |
372 playlistwin_shade_toggle(void) | |
373 { | |
374 playlistwin_set_shade_menu(!config.playlist_shaded); | |
375 } | |
376 | |
377 static gboolean | |
378 playlistwin_release(GtkWidget * widget, | |
379 GdkEventButton * event, | |
380 gpointer callback_data) | |
381 { | |
382 playlistwin_resizing = FALSE; | |
383 return FALSE; | |
384 } | |
385 | |
386 void | |
387 playlistwin_scroll(gint num) | |
388 { | |
389 if (UI_SKINNED_IS_PLAYLIST(playlistwin_list)) | |
390 UI_SKINNED_PLAYLIST(playlistwin_list)->first += num; | |
391 playlistwin_update_list(aud_playlist_get_active()); | |
392 } | |
393 | |
394 void | |
395 playlistwin_scroll_up_pushed(void) | |
396 { | |
397 playlistwin_scroll(-3); | |
398 } | |
399 | |
400 void | |
401 playlistwin_scroll_down_pushed(void) | |
402 { | |
403 playlistwin_scroll(3); | |
404 } | |
405 | |
406 static void | |
407 playlistwin_select_all(void) | |
408 { | |
409 Playlist *playlist = aud_playlist_get_active(); | |
410 | |
411 aud_playlist_select_all(playlist, TRUE); | |
412 if (UI_SKINNED_IS_PLAYLIST(playlistwin_list)) { | |
413 UI_SKINNED_PLAYLIST(playlistwin_list)->prev_selected = 0; | |
414 UI_SKINNED_PLAYLIST(playlistwin_list)->prev_min = 0; | |
415 UI_SKINNED_PLAYLIST(playlistwin_list)->prev_max = aud_playlist_get_length(playlist) - 1; | |
416 } | |
417 playlistwin_update_list(playlist); | |
418 } | |
419 | |
420 static void | |
421 playlistwin_select_none(void) | |
422 { | |
423 aud_playlist_select_all(aud_playlist_get_active(), FALSE); | |
424 if (UI_SKINNED_IS_PLAYLIST(playlistwin_list)) { | |
425 UI_SKINNED_PLAYLIST(playlistwin_list)->prev_selected = -1; | |
426 UI_SKINNED_PLAYLIST(playlistwin_list)->prev_min = -1; | |
427 } | |
428 playlistwin_update_list(aud_playlist_get_active()); | |
429 } | |
430 | |
431 static void | |
432 playlistwin_select_search(void) | |
433 { | |
434 Playlist *playlist = aud_playlist_get_active(); | |
435 GtkWidget *searchdlg_win, *searchdlg_table; | |
436 GtkWidget *searchdlg_hbox, *searchdlg_logo, *searchdlg_helptext; | |
437 GtkWidget *searchdlg_entry_title, *searchdlg_label_title; | |
438 GtkWidget *searchdlg_entry_album, *searchdlg_label_album; | |
439 GtkWidget *searchdlg_entry_file_name, *searchdlg_label_file_name; | |
440 GtkWidget *searchdlg_entry_performer, *searchdlg_label_performer; | |
441 GtkWidget *searchdlg_checkbt_clearprevsel; | |
442 GtkWidget *searchdlg_checkbt_newplaylist; | |
443 GtkWidget *searchdlg_checkbt_autoenqueue; | |
444 gint result; | |
445 | |
446 /* create dialog */ | |
447 searchdlg_win = gtk_dialog_new_with_buttons( | |
448 _("Search entries in active playlist") , GTK_WINDOW(mainwin) , | |
449 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT , | |
450 GTK_STOCK_CANCEL , GTK_RESPONSE_REJECT , GTK_STOCK_OK , GTK_RESPONSE_ACCEPT , NULL ); | |
451 gtk_window_set_position(GTK_WINDOW(searchdlg_win), GTK_WIN_POS_CENTER); | |
452 | |
453 /* help text and logo */ | |
454 searchdlg_hbox = gtk_hbox_new( FALSE , 4 ); | |
455 searchdlg_logo = gtk_image_new_from_stock( GTK_STOCK_FIND , GTK_ICON_SIZE_DIALOG ); | |
456 searchdlg_helptext = gtk_label_new( _("Select entries in playlist by filling one or more " | |
457 "fields. Fields use regular expressions syntax, case-insensitive. If you don't know how " | |
458 "regular expressions work, simply insert a literal portion of what you're searching for.") ); | |
459 gtk_label_set_line_wrap( GTK_LABEL(searchdlg_helptext) , TRUE ); | |
460 gtk_box_pack_start( GTK_BOX(searchdlg_hbox) , searchdlg_logo , FALSE , FALSE , 0 ); | |
461 gtk_box_pack_start( GTK_BOX(searchdlg_hbox) , searchdlg_helptext , FALSE , FALSE , 0 ); | |
462 | |
463 /* title */ | |
464 searchdlg_label_title = gtk_label_new( _("Title: ") ); | |
465 searchdlg_entry_title = gtk_entry_new(); | |
466 gtk_misc_set_alignment( GTK_MISC(searchdlg_label_title) , 0 , 0.5 ); | |
467 g_signal_connect( G_OBJECT(searchdlg_entry_title) , "key-press-event" , | |
468 G_CALLBACK(playlistwin_select_search_kp_cb) , searchdlg_win ); | |
469 | |
470 /* album */ | |
471 searchdlg_label_album= gtk_label_new( _("Album: ") ); | |
472 searchdlg_entry_album= gtk_entry_new(); | |
473 gtk_misc_set_alignment( GTK_MISC(searchdlg_label_album) , 0 , 0.5 ); | |
474 g_signal_connect( G_OBJECT(searchdlg_entry_album) , "key-press-event" , | |
475 G_CALLBACK(playlistwin_select_search_kp_cb) , searchdlg_win ); | |
476 | |
477 /* artist */ | |
478 searchdlg_label_performer = gtk_label_new( _("Artist: ") ); | |
479 searchdlg_entry_performer = gtk_entry_new(); | |
480 gtk_misc_set_alignment( GTK_MISC(searchdlg_label_performer) , 0 , 0.5 ); | |
481 g_signal_connect( G_OBJECT(searchdlg_entry_performer) , "key-press-event" , | |
482 G_CALLBACK(playlistwin_select_search_kp_cb) , searchdlg_win ); | |
483 | |
484 /* file name */ | |
485 searchdlg_label_file_name = gtk_label_new( _("Filename: ") ); | |
486 searchdlg_entry_file_name = gtk_entry_new(); | |
487 gtk_misc_set_alignment( GTK_MISC(searchdlg_label_file_name) , 0 , 0.5 ); | |
488 g_signal_connect( G_OBJECT(searchdlg_entry_file_name) , "key-press-event" , | |
489 G_CALLBACK(playlistwin_select_search_kp_cb) , searchdlg_win ); | |
490 | |
491 /* some options that control behaviour */ | |
492 searchdlg_checkbt_clearprevsel = gtk_check_button_new_with_label( | |
493 _("Clear previous selection before searching") ); | |
494 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(searchdlg_checkbt_clearprevsel) , TRUE ); | |
495 searchdlg_checkbt_autoenqueue = gtk_check_button_new_with_label( | |
496 _("Automatically toggle queue for matching entries") ); | |
497 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(searchdlg_checkbt_autoenqueue) , FALSE ); | |
498 searchdlg_checkbt_newplaylist = gtk_check_button_new_with_label( | |
499 _("Create a new playlist with matching entries") ); | |
500 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(searchdlg_checkbt_newplaylist) , FALSE ); | |
501 g_signal_connect( G_OBJECT(searchdlg_checkbt_autoenqueue) , "clicked" , | |
502 G_CALLBACK(playlistwin_select_search_cbt_cb) , searchdlg_checkbt_newplaylist ); | |
503 g_signal_connect( G_OBJECT(searchdlg_checkbt_newplaylist) , "clicked" , | |
504 G_CALLBACK(playlistwin_select_search_cbt_cb) , searchdlg_checkbt_autoenqueue ); | |
505 | |
506 /* place fields in searchdlg_table */ | |
507 searchdlg_table = gtk_table_new( 8 , 2 , FALSE ); | |
508 gtk_table_set_row_spacing( GTK_TABLE(searchdlg_table) , 0 , 8 ); | |
509 gtk_table_set_row_spacing( GTK_TABLE(searchdlg_table) , 4 , 8 ); | |
510 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_hbox , | |
511 0 , 2 , 0 , 1 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
512 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_label_title , | |
513 0 , 1 , 1 , 2 , GTK_FILL , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
514 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_entry_title , | |
515 1 , 2 , 1 , 2 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
516 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_label_album, | |
517 0 , 1 , 2 , 3 , GTK_FILL , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
518 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_entry_album, | |
519 1 , 2 , 2 , 3 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
520 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_label_performer , | |
521 0 , 1 , 3 , 4 , GTK_FILL , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
522 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_entry_performer , | |
523 1 , 2 , 3 , 4 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
524 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_label_file_name , | |
525 0 , 1 , 4 , 5 , GTK_FILL , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
526 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_entry_file_name , | |
527 1 , 2 , 4 , 5 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
528 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_checkbt_clearprevsel , | |
529 0 , 2 , 5 , 6 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 1 ); | |
530 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_checkbt_autoenqueue , | |
531 0 , 2 , 6 , 7 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 1 ); | |
532 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_checkbt_newplaylist , | |
533 0 , 2 , 7 , 8 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 1 ); | |
534 | |
535 gtk_container_set_border_width( GTK_CONTAINER(searchdlg_table) , 5 ); | |
536 gtk_container_add( GTK_CONTAINER(GTK_DIALOG(searchdlg_win)->vbox) , searchdlg_table ); | |
537 gtk_widget_show_all( searchdlg_win ); | |
538 result = gtk_dialog_run( GTK_DIALOG(searchdlg_win) ); | |
539 switch(result) | |
540 { | |
541 case GTK_RESPONSE_ACCEPT: | |
542 { | |
543 gint matched_entries_num = 0; | |
544 /* create a TitleInput tuple with user search data */ | |
545 Tuple *tuple = aud_tuple_new(); | |
546 gchar *searchdata = NULL; | |
547 | |
548 searchdata = (gchar*)gtk_entry_get_text( GTK_ENTRY(searchdlg_entry_title) ); | |
549 AUDDBG("title=\"%s\"\n", searchdata); | |
550 aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, searchdata); | |
551 | |
552 searchdata = (gchar*)gtk_entry_get_text( GTK_ENTRY(searchdlg_entry_album) ); | |
553 AUDDBG("album=\"%s\"\n", searchdata); | |
554 aud_tuple_associate_string(tuple, FIELD_ALBUM, NULL, searchdata); | |
555 | |
556 searchdata = (gchar*)gtk_entry_get_text( GTK_ENTRY(searchdlg_entry_performer) ); | |
557 AUDDBG("performer=\"%s\"\n", searchdata); | |
558 aud_tuple_associate_string(tuple, FIELD_ARTIST, NULL, searchdata); | |
559 | |
560 searchdata = (gchar*)gtk_entry_get_text( GTK_ENTRY(searchdlg_entry_file_name) ); | |
561 AUDDBG("filename=\"%s\"\n", searchdata); | |
562 aud_tuple_associate_string(tuple, FIELD_FILE_NAME, NULL, searchdata); | |
563 | |
564 /* check if previous selection should be cleared before searching */ | |
565 if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(searchdlg_checkbt_clearprevsel)) == TRUE ) | |
566 playlistwin_select_none(); | |
567 /* now send this tuple to the real search function */ | |
568 matched_entries_num = aud_playlist_select_search( playlist , tuple , 0 ); | |
569 /* we do not need the tuple and its data anymore */ | |
570 mowgli_object_unref(tuple); | |
571 playlistwin_update_list(aud_playlist_get_active()); | |
572 /* check if a new playlist should be created after searching */ | |
573 if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(searchdlg_checkbt_newplaylist)) == TRUE ) | |
574 aud_playlist_new_from_selected(); | |
575 /* check if matched entries should be queued */ | |
576 else if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(searchdlg_checkbt_autoenqueue)) == TRUE ) | |
577 aud_playlist_queue(aud_playlist_get_active()); | |
578 break; | |
579 } | |
580 default: | |
581 break; | |
582 } | |
583 /* done here :) */ | |
584 gtk_widget_destroy( searchdlg_win ); | |
585 } | |
586 | |
587 static void | |
588 playlistwin_inverse_selection(void) | |
589 { | |
590 aud_playlist_select_invert_all(aud_playlist_get_active()); | |
591 if (UI_SKINNED_IS_PLAYLIST(playlistwin_list)) { | |
592 UI_SKINNED_PLAYLIST(playlistwin_list)->prev_selected = -1; | |
593 UI_SKINNED_PLAYLIST(playlistwin_list)->prev_min = -1; | |
594 } | |
595 playlistwin_update_list(aud_playlist_get_active()); | |
596 } | |
597 | |
598 static void | |
599 playlistwin_resize(gint width, gint height) | |
600 { | |
601 gint tx, ty; | |
602 gint dx, dy; | |
603 | |
604 g_return_if_fail(width > 0 && height > 0); | |
605 | |
606 tx = (width - PLAYLISTWIN_MIN_WIDTH) / PLAYLISTWIN_WIDTH_SNAP; | |
607 tx = (tx * PLAYLISTWIN_WIDTH_SNAP) + PLAYLISTWIN_MIN_WIDTH; | |
608 if (tx < PLAYLISTWIN_MIN_WIDTH) | |
609 tx = PLAYLISTWIN_MIN_WIDTH; | |
610 | |
611 if (!config.playlist_shaded) | |
612 { | |
613 ty = (height - PLAYLISTWIN_MIN_HEIGHT) / PLAYLISTWIN_HEIGHT_SNAP; | |
614 ty = (ty * PLAYLISTWIN_HEIGHT_SNAP) + PLAYLISTWIN_MIN_HEIGHT; | |
615 if (ty < PLAYLISTWIN_MIN_HEIGHT) | |
616 ty = PLAYLISTWIN_MIN_HEIGHT; | |
617 } | |
618 else | |
619 ty = config.playlist_height; | |
620 | |
621 if (tx == config.playlist_width && ty == config.playlist_height) | |
622 return; | |
623 | |
624 /* difference between previous size and new size */ | |
625 dx = tx - config.playlist_width; | |
626 dy = ty - config.playlist_height; | |
627 | |
628 config.playlist_width = width = tx; | |
629 config.playlist_height = height = ty; | |
630 | |
631 g_mutex_lock(resize_mutex); | |
632 ui_skinned_playlist_resize_relative(playlistwin_list, dx, dy); | |
633 | |
634 ui_skinned_playlist_slider_move_relative(playlistwin_slider, dx); | |
635 ui_skinned_playlist_slider_resize_relative(playlistwin_slider, dy); | |
636 | |
637 playlistwin_update_sinfo(aud_playlist_get_active()); | |
638 | |
639 ui_skinned_button_move_relative(playlistwin_shade, dx, 0); | |
640 ui_skinned_button_move_relative(playlistwin_close, dx, 0); | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
641 ui_skinned_button_move_relative(playlistwin_shaded_shade, dx, 0); |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
642 ui_skinned_button_move_relative(playlistwin_shaded_close, dx, 0); |
2620 | 643 ui_skinned_textbox_move_relative(playlistwin_time_min, dx, dy); |
644 ui_skinned_textbox_move_relative(playlistwin_time_sec, dx, dy); | |
645 ui_skinned_textbox_move_relative(playlistwin_info, dx, dy); | |
646 ui_skinned_button_move_relative(playlistwin_srew, dx, dy); | |
647 ui_skinned_button_move_relative(playlistwin_splay, dx, dy); | |
648 ui_skinned_button_move_relative(playlistwin_spause, dx, dy); | |
649 ui_skinned_button_move_relative(playlistwin_sstop, dx, dy); | |
650 ui_skinned_button_move_relative(playlistwin_sfwd, dx, dy); | |
651 ui_skinned_button_move_relative(playlistwin_seject, dx, dy); | |
652 ui_skinned_button_move_relative(playlistwin_sscroll_up, dx, dy); | |
653 ui_skinned_button_move_relative(playlistwin_sscroll_down, dx, dy); | |
654 | |
655 gtk_widget_set_size_request(playlistwin_sinfo, playlistwin_get_width() - 35, | |
656 aud_active_skin->properties.textbox_bitmap_font_height); | |
657 g_mutex_unlock(resize_mutex); | |
658 } | |
659 | |
660 static void | |
661 playlistwin_motion(GtkWidget * widget, | |
662 GdkEventMotion * event, | |
663 gpointer callback_data) | |
664 { | |
665 /* | |
666 * GDK2's resize is broken and doesn't really play nice, so we have | |
667 * to do all of this stuff by hand. | |
668 */ | |
669 if (playlistwin_resizing == TRUE) | |
670 { | |
671 if (event->x + playlistwin_resize_x != playlistwin_get_width() || | |
672 event->y + playlistwin_resize_y != playlistwin_get_height()) | |
673 { | |
674 playlistwin_resize(event->x + playlistwin_resize_x, | |
675 event->y + playlistwin_resize_y); | |
676 gdk_window_resize(playlistwin->window, | |
677 config.playlist_width, playlistwin_get_height()); | |
678 gdk_flush(); | |
679 } | |
680 } | |
681 else if (dock_is_moving(GTK_WINDOW(playlistwin))) | |
682 dock_move_motion(GTK_WINDOW(playlistwin), event); | |
683 } | |
684 | |
685 static void | |
686 playlistwin_show_filebrowser(void) | |
687 { | |
2640 | 688 action_playlist_add_files(); |
2620 | 689 } |
690 | |
691 static void | |
692 playlistwin_fileinfo(void) | |
693 { | |
694 Playlist *playlist = aud_playlist_get_active(); | |
695 | |
696 /* Show the first selected file, or the current file if nothing is | |
697 * selected */ | |
698 GList *list = aud_playlist_get_selected(playlist); | |
699 if (list) { | |
2639 | 700 aud_playlist_fileinfo(playlist, GPOINTER_TO_INT(list->data)); |
2620 | 701 g_list_free(list); |
702 } | |
703 else | |
2639 | 704 aud_playlist_fileinfo_current(playlist); |
2620 | 705 } |
706 | |
707 static void | |
708 show_playlist_save_error(GtkWindow *parent, | |
709 const gchar *filename) | |
710 { | |
711 GtkWidget *dialog; | |
712 | |
713 g_return_if_fail(GTK_IS_WINDOW(parent)); | |
714 g_return_if_fail(filename); | |
715 | |
716 dialog = gtk_message_dialog_new(GTK_WINDOW(parent), | |
717 GTK_DIALOG_DESTROY_WITH_PARENT, | |
718 GTK_MESSAGE_ERROR, | |
719 GTK_BUTTONS_OK, | |
720 _("Error writing playlist \"%s\": %s"), | |
721 filename, strerror(errno)); | |
722 | |
723 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); /* centering */ | |
724 gtk_dialog_run(GTK_DIALOG(dialog)); | |
725 gtk_widget_destroy(dialog); | |
726 } | |
727 | |
728 static gboolean | |
729 show_playlist_overwrite_prompt(GtkWindow * parent, | |
730 const gchar * filename) | |
731 { | |
732 GtkWidget *dialog; | |
733 gint result; | |
734 | |
735 g_return_val_if_fail(GTK_IS_WINDOW(parent), FALSE); | |
736 g_return_val_if_fail(filename != NULL, FALSE); | |
737 | |
738 dialog = gtk_message_dialog_new(GTK_WINDOW(parent), | |
739 GTK_DIALOG_DESTROY_WITH_PARENT, | |
740 GTK_MESSAGE_QUESTION, | |
741 GTK_BUTTONS_YES_NO, | |
742 _("%s already exist. Continue?"), | |
743 filename); | |
744 | |
745 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); /* centering */ | |
746 result = gtk_dialog_run(GTK_DIALOG(dialog)); | |
747 gtk_widget_destroy(dialog); | |
748 | |
749 return (result == GTK_RESPONSE_YES); | |
750 } | |
751 | |
752 static void | |
753 show_playlist_save_format_error(GtkWindow * parent, | |
754 const gchar * filename) | |
755 { | |
756 const gchar *markup = | |
757 N_("<b><big>Unable to save playlist.</big></b>\n\n" | |
758 "Unknown file type for '%s'.\n"); | |
759 | |
760 GtkWidget *dialog; | |
761 | |
762 g_return_if_fail(GTK_IS_WINDOW(parent)); | |
763 g_return_if_fail(filename != NULL); | |
764 | |
765 dialog = | |
766 gtk_message_dialog_new_with_markup(GTK_WINDOW(parent), | |
767 GTK_DIALOG_DESTROY_WITH_PARENT, | |
768 GTK_MESSAGE_ERROR, | |
769 GTK_BUTTONS_OK, | |
770 _(markup), | |
771 filename); | |
772 | |
773 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); /* centering */ | |
774 gtk_dialog_run(GTK_DIALOG(dialog)); | |
775 gtk_widget_destroy(dialog); | |
776 } | |
777 | |
778 static void | |
779 playlistwin_save_playlist(const gchar * filename) | |
780 { | |
781 PlaylistContainer *plc; | |
782 gchar *ext = strrchr(filename, '.') + 1; | |
783 | |
784 plc = aud_playlist_container_find(ext); | |
785 if (plc == NULL) { | |
786 show_playlist_save_format_error(GTK_WINDOW(playlistwin), filename); | |
787 return; | |
788 } | |
789 | |
790 aud_str_replace_in(&aud_cfg->playlist_path, g_path_get_dirname(filename)); | |
791 | |
792 if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) | |
793 if (!show_playlist_overwrite_prompt(GTK_WINDOW(playlistwin), filename)) | |
794 return; | |
795 | |
796 if (!aud_playlist_save(aud_playlist_get_active(), filename)) | |
797 show_playlist_save_error(GTK_WINDOW(playlistwin), filename); | |
798 } | |
799 | |
800 static void | |
801 playlistwin_load_playlist(const gchar * filename) | |
802 { | |
803 const gchar *title; | |
804 Playlist *playlist = aud_playlist_get_active(); | |
805 | |
806 g_return_if_fail(filename != NULL); | |
807 | |
808 aud_str_replace_in(&aud_cfg->playlist_path, g_path_get_dirname(filename)); | |
809 | |
810 aud_playlist_clear(playlist); | |
811 mainwin_clear_song_info(); | |
812 | |
813 aud_playlist_load(playlist, filename); | |
814 title = aud_playlist_get_current_name(playlist); | |
815 if(!title || !title[0]) | |
816 aud_playlist_set_current_name(playlist, filename); | |
817 } | |
818 | |
819 static gchar * | |
820 playlist_file_selection_load(const gchar * title, | |
821 const gchar * default_filename) | |
822 { | |
823 GtkWidget *dialog; | |
824 gchar *filename; | |
825 | |
826 g_return_val_if_fail(title != NULL, NULL); | |
827 | |
828 dialog = make_filebrowser(title, FALSE); | |
829 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), aud_cfg->playlist_path); | |
830 if (default_filename) | |
831 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), default_filename); | |
832 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); /* centering */ | |
833 | |
834 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) | |
835 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); | |
836 else | |
837 filename = NULL; | |
838 | |
839 gtk_widget_destroy(dialog); | |
840 return filename; | |
841 } | |
842 | |
843 static void | |
844 on_static_toggle(GtkToggleButton *button, gpointer data) | |
845 { | |
846 Playlist *playlist = aud_playlist_get_active(); | |
847 | |
848 playlist->attribute = | |
849 gtk_toggle_button_get_active(button) ? | |
850 playlist->attribute | PLAYLIST_STATIC : | |
851 playlist->attribute & ~PLAYLIST_STATIC; | |
852 } | |
853 | |
854 static void | |
855 on_relative_toggle(GtkToggleButton *button, gpointer data) | |
856 { | |
857 Playlist *playlist = aud_playlist_get_active(); | |
858 | |
859 playlist->attribute = | |
860 gtk_toggle_button_get_active(button) ? | |
861 playlist->attribute | PLAYLIST_USE_RELATIVE : | |
862 playlist->attribute & ~PLAYLIST_USE_RELATIVE; | |
863 } | |
864 | |
865 static gchar * | |
866 playlist_file_selection_save(const gchar * title, | |
867 const gchar * default_filename) | |
868 { | |
869 GtkWidget *dialog; | |
870 gchar *filename; | |
871 GtkWidget *hbox; | |
872 GtkWidget *toggle, *toggle2; | |
873 | |
874 g_return_val_if_fail(title != NULL, NULL); | |
875 | |
876 dialog = make_filebrowser(title, TRUE); | |
877 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), aud_cfg->playlist_path); | |
878 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), default_filename); | |
879 | |
880 hbox = gtk_hbox_new(FALSE, 5); | |
881 | |
882 /* static playlist */ | |
883 toggle = gtk_check_button_new_with_label(_("Save as Static Playlist")); | |
884 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
885 (aud_playlist_get_active()->attribute & PLAYLIST_STATIC) ? TRUE : FALSE); | |
886 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(on_static_toggle), dialog); | |
887 gtk_box_pack_start(GTK_BOX(hbox), toggle, FALSE, FALSE, 0); | |
888 | |
889 /* use relative path */ | |
890 toggle2 = gtk_check_button_new_with_label(_("Use Relative Path")); | |
891 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle2), | |
892 (aud_playlist_get_active()->attribute & PLAYLIST_USE_RELATIVE) ? TRUE : FALSE); | |
893 g_signal_connect(G_OBJECT(toggle2), "toggled", G_CALLBACK(on_relative_toggle), dialog); | |
894 gtk_box_pack_start(GTK_BOX(hbox), toggle2, FALSE, FALSE, 0); | |
895 | |
896 gtk_widget_show_all(hbox); | |
897 gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(dialog), hbox); | |
898 | |
899 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) | |
900 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); | |
901 else | |
902 filename = NULL; | |
903 | |
904 gtk_widget_destroy(dialog); | |
905 return filename; | |
906 } | |
907 | |
908 void | |
909 playlistwin_select_playlist_to_load(const gchar * default_filename) | |
910 { | |
911 gchar *filename = | |
912 playlist_file_selection_load(_("Load Playlist"), default_filename); | |
913 | |
914 if (filename) { | |
915 playlistwin_load_playlist(filename); | |
916 g_free(filename); | |
917 } | |
918 } | |
919 | |
920 static void | |
921 playlistwin_select_playlist_to_save(const gchar * default_filename) | |
922 { | |
923 gchar *dot = NULL, *basename = NULL; | |
924 gchar *filename = | |
925 playlist_file_selection_save(_("Save Playlist"), default_filename); | |
926 | |
927 if (filename) { | |
928 /* Default extension */ | |
929 basename = g_path_get_basename(filename); | |
930 dot = strrchr(basename, '.'); | |
931 if( dot == NULL || dot == basename) { | |
932 gchar *oldname = filename; | |
933 #ifdef HAVE_XSPF_PLAYLIST | |
934 filename = g_strconcat(oldname, ".xspf", NULL); | |
935 #else | |
936 filename = g_strconcat(oldname, ".m3u", NULL); | |
937 #endif | |
938 g_free(oldname); | |
939 } | |
940 g_free(basename); | |
941 | |
942 playlistwin_save_playlist(filename); | |
943 g_free(filename); | |
944 } | |
945 } | |
946 | |
947 #define REGION_L(x1,x2,y1,y2) \ | |
948 (event->x >= (x1) && event->x < (x2) && \ | |
949 event->y >= config.playlist_height - (y1) && \ | |
950 event->y < config.playlist_height - (y2)) | |
951 | |
952 #define REGION_R(x1,x2,y1,y2) \ | |
953 (event->x >= playlistwin_get_width() - (x1) && \ | |
954 event->x < playlistwin_get_width() - (x2) && \ | |
955 event->y >= config.playlist_height - (y1) && \ | |
956 event->y < config.playlist_height - (y2)) | |
957 | |
958 static void | |
959 playlistwin_scrolled(GtkWidget * widget, | |
960 GdkEventScroll * event, | |
961 gpointer callback_data) | |
962 { | |
963 if (event->direction == GDK_SCROLL_DOWN) | |
964 playlistwin_scroll(config.scroll_pl_by); | |
965 | |
966 if (event->direction == GDK_SCROLL_UP) | |
967 playlistwin_scroll(-config.scroll_pl_by); | |
968 #if 0 | |
969 g_cond_signal(cond_scan); | |
970 #endif | |
971 } | |
972 | |
973 static gboolean | |
974 playlistwin_press(GtkWidget * widget, | |
975 GdkEventButton * event, | |
976 gpointer callback_data) | |
977 { | |
978 gint xpos, ypos; | |
979 GtkRequisition req; | |
980 | |
981 gtk_window_get_position(GTK_WINDOW(playlistwin), &xpos, &ypos); | |
982 | |
983 if (event->button == 1 && !config.show_wm_decorations && | |
984 ((!config.playlist_shaded && | |
985 event->x > playlistwin_get_width() - 20 && | |
986 event->y > config.playlist_height - 20) || | |
987 (config.playlist_shaded && | |
988 event->x >= playlistwin_get_width() - 31 && | |
989 event->x < playlistwin_get_width() - 22))) { | |
990 | |
991 if (event->type != GDK_2BUTTON_PRESS && | |
992 event->type != GDK_3BUTTON_PRESS) { | |
993 playlistwin_resizing = TRUE; | |
994 playlistwin_resize_x = config.playlist_width - event->x; | |
995 playlistwin_resize_y = config.playlist_height - event->y; | |
996 } | |
997 } | |
998 else if (event->button == 1 && REGION_L(12, 37, 29, 11)) { | |
999 /* ADD button menu */ | |
1000 gtk_widget_size_request(playlistwin_pladd_menu, &req); | |
1001 ui_manager_popup_menu_show(GTK_MENU(playlistwin_pladd_menu), | |
1002 xpos + 12, | |
1003 (ypos + playlistwin_get_height()) - 8 - req.height, | |
1004 event->button, | |
1005 event->time); | |
1006 } | |
1007 else if (event->button == 1 && REGION_L(41, 66, 29, 11)) { | |
1008 /* SUB button menu */ | |
1009 gtk_widget_size_request(playlistwin_pldel_menu, &req); | |
1010 ui_manager_popup_menu_show(GTK_MENU(playlistwin_pldel_menu), | |
1011 xpos + 40, | |
1012 (ypos + playlistwin_get_height()) - 8 - req.height, | |
1013 event->button, | |
1014 event->time); | |
1015 } | |
1016 else if (event->button == 1 && REGION_L(70, 95, 29, 11)) { | |
1017 /* SEL button menu */ | |
1018 gtk_widget_size_request(playlistwin_plsel_menu, &req); | |
1019 ui_manager_popup_menu_show(GTK_MENU(playlistwin_plsel_menu), | |
1020 xpos + 68, | |
1021 (ypos + playlistwin_get_height()) - 8 - req.height, | |
1022 event->button, | |
1023 event->time); | |
1024 } | |
1025 else if (event->button == 1 && REGION_L(99, 124, 29, 11)) { | |
1026 /* MISC button menu */ | |
1027 gtk_widget_size_request(playlistwin_plsort_menu, &req); | |
1028 ui_manager_popup_menu_show(GTK_MENU(playlistwin_plsort_menu), | |
1029 xpos + 100, | |
1030 (ypos + playlistwin_get_height()) - 8 - req.height, | |
1031 event->button, | |
1032 event->time); | |
1033 } | |
1034 else if (event->button == 1 && REGION_R(46, 23, 29, 11)) { | |
1035 /* LIST button menu */ | |
1036 gtk_widget_size_request(playlistwin_pllist_menu, &req); | |
1037 ui_manager_popup_menu_show(GTK_MENU(playlistwin_pllist_menu), | |
1038 xpos + playlistwin_get_width() - req.width - 12, | |
1039 (ypos + playlistwin_get_height()) - 8 - req.height, | |
1040 event->button, | |
1041 event->time); | |
1042 } | |
1043 else if (event->button == 1 && event->type == GDK_BUTTON_PRESS && | |
1044 (config.easy_move || event->y < 14)) | |
1045 { | |
1046 return FALSE; | |
1047 } | |
1048 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS | |
1049 && event->y < 14) { | |
1050 /* double click on title bar */ | |
1051 playlistwin_shade_toggle(); | |
1052 if (dock_is_moving(GTK_WINDOW(playlistwin))) | |
1053 dock_move_release(GTK_WINDOW(playlistwin)); | |
1054 return TRUE; | |
1055 } | |
1056 else if (event->button == 3) { | |
1057 /* | |
1058 * Pop up the main menu a few pixels down to avoid | |
1059 * anything to be selected initially. | |
1060 */ | |
1061 ui_manager_popup_menu_show(GTK_MENU(mainwin_general_menu), event->x_root, | |
1062 event->y_root + 2, 3, event->time); | |
1063 } | |
1064 | |
1065 return TRUE; | |
1066 } | |
1067 | |
1068 static gboolean | |
1069 playlistwin_delete(GtkWidget * w, gpointer data) | |
1070 { | |
1071 playlistwin_hide(); | |
1072 return TRUE; | |
1073 } | |
1074 | |
1075 static gboolean | |
1076 playlistwin_keypress_up_down_handler(UiSkinnedPlaylist * pl, | |
1077 gboolean up, guint state) | |
1078 { | |
1079 Playlist *playlist = aud_playlist_get_active(); | |
1080 if ((!(pl->prev_selected || pl->first) && up) || | |
1081 ((pl->prev_selected >= aud_playlist_get_length(playlist) - 1) && !up)) | |
1082 return FALSE; | |
1083 | |
1084 if ((state & GDK_MOD1_MASK) && (state & GDK_SHIFT_MASK)) | |
1085 return FALSE; | |
1086 if (!(state & GDK_MOD1_MASK)) | |
1087 aud_playlist_select_all(playlist, FALSE); | |
1088 | |
1089 if (pl->prev_selected == -1 || | |
1090 (!playlistwin_item_visible(pl->prev_selected) && | |
1091 !(state & GDK_SHIFT_MASK && pl->prev_min != -1))) { | |
1092 pl->prev_selected = pl->first; | |
1093 } | |
1094 else if (state & GDK_SHIFT_MASK) { | |
1095 if (pl->prev_min == -1) { | |
1096 pl->prev_max = pl->prev_selected; | |
1097 pl->prev_min = pl->prev_selected; | |
1098 } | |
1099 pl->prev_max += (up ? -1 : 1); | |
1100 pl->prev_max = | |
1101 CLAMP(pl->prev_max, 0, aud_playlist_get_length(playlist) - 1); | |
1102 | |
1103 pl->first = MIN(pl->first, pl->prev_max); | |
1104 pl->first = MAX(pl->first, pl->prev_max - | |
1105 pl->num_visible + 1); | |
1106 aud_playlist_select_range(playlist, pl->prev_min, pl->prev_max, TRUE); | |
1107 return TRUE; | |
1108 } | |
1109 else if (state & GDK_MOD1_MASK) { | |
1110 if (up) | |
1111 ui_skinned_playlist_move_up(pl); | |
1112 else | |
1113 ui_skinned_playlist_move_down(pl); | |
1114 if (pl->prev_min < pl->first) | |
1115 pl->first = pl->prev_min; | |
1116 else if (pl->prev_max >= (pl->first + pl->num_visible)) | |
1117 pl->first = pl->prev_max - pl->num_visible + 1; | |
1118 return TRUE; | |
1119 } | |
1120 else if (up) | |
1121 pl->prev_selected--; | |
1122 else | |
1123 pl->prev_selected++; | |
1124 | |
1125 pl->prev_selected = | |
1126 CLAMP(pl->prev_selected, 0, aud_playlist_get_length(playlist) - 1); | |
1127 | |
1128 if (pl->prev_selected < pl->first) | |
1129 pl->first--; | |
1130 else if (pl->prev_selected >= (pl->first + pl->num_visible)) | |
1131 pl->first++; | |
1132 | |
1133 aud_playlist_select_range(playlist, pl->prev_selected, pl->prev_selected, TRUE); | |
1134 pl->prev_min = -1; | |
1135 | |
1136 return TRUE; | |
1137 } | |
1138 | |
1139 /* FIXME: Handle the keys through menu */ | |
1140 | |
1141 static gboolean | |
1142 playlistwin_keypress(GtkWidget * w, GdkEventKey * event, gpointer data) | |
1143 { | |
1144 g_return_val_if_fail(UI_SKINNED_IS_PLAYLIST(playlistwin_list), FALSE); | |
1145 Playlist *playlist = aud_playlist_get_active(); | |
1146 | |
1147 guint keyval; | |
1148 gboolean refresh = FALSE; | |
1149 guint cur_pos; | |
1150 | |
1151 if (config.playlist_shaded) | |
1152 return FALSE; | |
1153 | |
1154 switch (keyval = event->keyval) { | |
1155 case GDK_KP_Up: | |
1156 case GDK_KP_Down: | |
1157 case GDK_Up: | |
1158 case GDK_Down: | |
1159 refresh = playlistwin_keypress_up_down_handler(UI_SKINNED_PLAYLIST(playlistwin_list), | |
1160 keyval == GDK_Up | |
1161 || keyval == GDK_KP_Up, | |
1162 event->state); | |
1163 break; | |
1164 case GDK_Page_Up: | |
1165 playlistwin_scroll(-UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible); | |
1166 refresh = TRUE; | |
1167 break; | |
1168 case GDK_Page_Down: | |
1169 playlistwin_scroll(UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible); | |
1170 refresh = TRUE; | |
1171 break; | |
1172 case GDK_Home: | |
1173 UI_SKINNED_PLAYLIST(playlistwin_list)->first = 0; | |
1174 refresh = TRUE; | |
1175 break; | |
1176 case GDK_End: | |
1177 UI_SKINNED_PLAYLIST(playlistwin_list)->first = | |
1178 aud_playlist_get_length(playlist) - UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible; | |
1179 refresh = TRUE; | |
1180 break; | |
1181 case GDK_Return: | |
1182 if (UI_SKINNED_PLAYLIST(playlistwin_list)->prev_selected > -1 | |
1183 && playlistwin_item_visible(UI_SKINNED_PLAYLIST(playlistwin_list)->prev_selected)) { | |
1184 aud_playlist_set_position(playlist, UI_SKINNED_PLAYLIST(playlistwin_list)->prev_selected); | |
1185 if (!audacious_drct_get_playing()) | |
1186 audacious_drct_initiate(); | |
1187 } | |
1188 refresh = TRUE; | |
1189 break; | |
1190 case GDK_3: | |
1191 if (event->state & GDK_CONTROL_MASK) | |
1192 playlistwin_fileinfo(); | |
1193 break; | |
1194 case GDK_Delete: | |
1195 if (event->state & GDK_CONTROL_MASK) | |
1196 aud_playlist_delete(playlist, TRUE); | |
1197 else | |
1198 aud_playlist_delete(playlist, FALSE); | |
1199 break; | |
1200 case GDK_Insert: | |
1201 if (event->state & GDK_MOD1_MASK) | |
1202 mainwin_show_add_url_window(); | |
1203 else | |
1204 playlistwin_show_filebrowser(); | |
1205 break; | |
1206 case GDK_Left: | |
1207 case GDK_KP_Left: | |
1208 case GDK_KP_7: | |
1209 if (aud_playlist_get_current_length(playlist) != -1) | |
1210 audacious_drct_seek(CLAMP | |
1211 (audacious_drct_get_time() - 5000, 0, | |
1212 aud_playlist_get_current_length(playlist))); | |
1213 break; | |
1214 case GDK_Right: | |
1215 case GDK_KP_Right: | |
1216 case GDK_KP_9: | |
1217 if (aud_playlist_get_current_length(playlist) != -1) | |
1218 audacious_drct_seek(CLAMP | |
1219 (audacious_drct_get_time() + 5000, 0, | |
1220 aud_playlist_get_current_length(playlist))); | |
1221 break; | |
1222 case GDK_KP_4: | |
1223 aud_playlist_prev(playlist); | |
1224 break; | |
1225 case GDK_KP_6: | |
1226 aud_playlist_next(playlist); | |
1227 break; | |
1228 | |
1229 case GDK_Escape: | |
1230 mainwin_minimize_cb(); | |
1231 break; | |
1232 case GDK_Tab: | |
1233 if (event->state & GDK_CONTROL_MASK) { | |
1234 if (config.player_visible) | |
1235 gtk_window_present(GTK_WINDOW(mainwin)); | |
1236 else if (config.equalizer_visible) | |
1237 gtk_window_present(GTK_WINDOW(equalizerwin)); | |
1238 } | |
1239 break; | |
1240 case GDK_space: | |
1241 cur_pos=aud_playlist_get_position(playlist); | |
1242 UI_SKINNED_PLAYLIST(playlistwin_list)->first = | |
1243 cur_pos - (UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible >> 1); | |
1244 refresh = TRUE; | |
1245 break; | |
1246 default: | |
1247 return FALSE; | |
1248 } | |
1249 #if 0 | |
1250 if (refresh) { | |
1251 g_cond_signal(cond_scan); | |
1252 playlistwin_update_list(aud_playlist_get_active()); | |
1253 } | |
1254 #endif | |
1255 return TRUE; | |
1256 } | |
1257 | |
1258 void | |
1259 playlistwin_hide_timer(void) | |
1260 { | |
1261 ui_skinned_textbox_set_text(playlistwin_time_min, " "); | |
1262 ui_skinned_textbox_set_text(playlistwin_time_sec, " "); | |
1263 } | |
1264 | |
1265 void | |
1266 playlistwin_set_time(gint time, gint length, TimerMode mode) | |
1267 { | |
1268 gchar *text, sign; | |
1269 | |
1270 if (mode == TIMER_REMAINING && length != -1) { | |
1271 time = length - time; | |
1272 sign = '-'; | |
1273 } | |
1274 else | |
1275 sign = ' '; | |
1276 | |
1277 time /= 1000; | |
1278 | |
1279 if (time < 0) | |
1280 time = 0; | |
1281 if (time > 99 * 60) | |
1282 time /= 60; | |
1283 | |
1284 text = g_strdup_printf("%c%-2.2d", sign, time / 60); | |
1285 ui_skinned_textbox_set_text(playlistwin_time_min, text); | |
1286 g_free(text); | |
1287 | |
1288 text = g_strdup_printf("%-2.2d", time % 60); | |
1289 ui_skinned_textbox_set_text(playlistwin_time_sec, text); | |
1290 g_free(text); | |
1291 } | |
1292 | |
1293 static void | |
1294 playlistwin_drag_motion(GtkWidget * widget, | |
1295 GdkDragContext * context, | |
1296 gint x, gint y, | |
1297 GtkSelectionData * selection_data, | |
1298 guint info, guint time, gpointer user_data) | |
1299 { | |
1300 if (UI_SKINNED_IS_PLAYLIST(playlistwin_list)) { | |
1301 UI_SKINNED_PLAYLIST(playlistwin_list)->drag_motion = TRUE; | |
1302 UI_SKINNED_PLAYLIST(playlistwin_list)->drag_motion_x = x; | |
1303 UI_SKINNED_PLAYLIST(playlistwin_list)->drag_motion_y = y; | |
1304 } | |
1305 playlistwin_update_list(aud_playlist_get_active()); | |
1306 playlistwin_hint_flag = TRUE; | |
1307 } | |
1308 | |
1309 static void | |
1310 playlistwin_drag_end(GtkWidget * widget, | |
1311 GdkDragContext * context, gpointer user_data) | |
1312 { | |
1313 if (UI_SKINNED_IS_PLAYLIST(playlistwin_list)) | |
1314 UI_SKINNED_PLAYLIST(playlistwin_list)->drag_motion = FALSE; | |
1315 playlistwin_hint_flag = FALSE; | |
1316 playlistwin_update_list(aud_playlist_get_active()); | |
1317 } | |
1318 | |
1319 static void | |
1320 playlistwin_drag_data_received(GtkWidget * widget, | |
1321 GdkDragContext * context, | |
1322 gint x, gint y, | |
1323 GtkSelectionData * | |
1324 selection_data, guint info, | |
1325 guint time, gpointer user_data) | |
1326 { | |
1327 gint pos; | |
1328 Playlist *playlist = aud_playlist_get_active(); | |
1329 | |
1330 g_return_if_fail(selection_data); | |
1331 | |
1332 if (!selection_data->data) { | |
1333 g_message("Received no DND data!"); | |
1334 return; | |
1335 } | |
1336 if (UI_SKINNED_IS_PLAYLIST(playlistwin_list) && | |
1337 (x < playlistwin_get_width() - 20 || y < config.playlist_height - 38)) { | |
1338 pos = y / UI_SKINNED_PLAYLIST(playlistwin_list)->fheight + UI_SKINNED_PLAYLIST(playlistwin_list)->first; | |
1339 | |
1340 pos = MIN(pos, aud_playlist_get_length(playlist)); | |
1341 aud_playlist_ins_url(playlist, (gchar *) selection_data->data, pos); | |
1342 } | |
1343 else | |
1344 aud_playlist_add_url(playlist, (gchar *) selection_data->data); | |
1345 } | |
1346 | |
1347 static void | |
1348 local_playlist_prev(void) | |
1349 { | |
1350 aud_playlist_prev(aud_playlist_get_active()); | |
1351 } | |
1352 | |
1353 static void | |
1354 local_playlist_next(void) | |
1355 { | |
1356 aud_playlist_next(aud_playlist_get_active()); | |
1357 } | |
1358 | |
1359 static void | |
1360 playlistwin_create_widgets(void) | |
1361 { | |
1362 /* This function creates the custom widgets used by the playlist editor */ | |
1363 | |
1364 /* text box for displaying song title in shaded mode */ | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1365 playlistwin_sinfo = ui_skinned_textbox_new(SKINNED_WINDOW(playlistwin)->shaded, |
2620 | 1366 4, 4, playlistwin_get_width() - 35, TRUE, SKIN_TEXT); |
1367 | |
2642 | 1368 playlistwin_set_sinfo_font(config.playlist_font); |
2620 | 1369 |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1370 |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1371 playlistwin_shaded_shade = ui_skinned_button_new(); |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1372 ui_skinned_push_button_setup(playlistwin_shaded_shade, SKINNED_WINDOW(playlistwin)->shaded, |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1373 playlistwin_get_width() - 21, 3, |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1374 9, 9, 128, 45, 150, 42, SKIN_PLEDIT); |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1375 g_signal_connect(playlistwin_shaded_shade, "clicked", playlistwin_shade_toggle, NULL ); |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1376 |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1377 playlistwin_shaded_close = ui_skinned_button_new(); |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1378 ui_skinned_push_button_setup(playlistwin_shaded_close, SKINNED_WINDOW(playlistwin)->shaded, |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1379 playlistwin_get_width() - 11, 3, 9, 9, 138, 45, 52, 42, SKIN_PLEDIT); |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1380 g_signal_connect(playlistwin_shaded_close, "clicked", playlistwin_hide, NULL ); |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1381 |
2620 | 1382 playlistwin_shade = ui_skinned_button_new(); |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1383 ui_skinned_push_button_setup(playlistwin_shade, SKINNED_WINDOW(playlistwin)->normal, |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1384 playlistwin_get_width() - 21, 3, |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1385 9, 9, 157, 3, 62, 42, SKIN_PLEDIT); |
2620 | 1386 g_signal_connect(playlistwin_shade, "clicked", playlistwin_shade_toggle, NULL ); |
1387 | |
1388 playlistwin_close = ui_skinned_button_new(); | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1389 ui_skinned_push_button_setup(playlistwin_close, SKINNED_WINDOW(playlistwin)->normal, |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1390 playlistwin_get_width() - 11, 3, 9, 9, 167, 3, 52, 42, SKIN_PLEDIT); |
2620 | 1391 g_signal_connect(playlistwin_close, "clicked", playlistwin_hide, NULL ); |
1392 | |
1393 /* playlist list box */ | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1394 playlistwin_list = ui_skinned_playlist_new(SKINNED_WINDOW(playlistwin)->normal, 12, 20, |
2620 | 1395 playlistwin_get_width() - 31, |
1396 config.playlist_height - 58); | |
2642 | 1397 ui_skinned_playlist_set_font(config.playlist_font); |
2620 | 1398 |
1399 /* playlist list box slider */ | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1400 playlistwin_slider = ui_skinned_playlist_slider_new(SKINNED_WINDOW(playlistwin)->normal, playlistwin_get_width() - 15, |
2620 | 1401 20, config.playlist_height - 58); |
1402 | |
1403 /* track time (minute) */ | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1404 playlistwin_time_min = ui_skinned_textbox_new(SKINNED_WINDOW(playlistwin)->normal, |
2620 | 1405 playlistwin_get_width() - 82, |
1406 config.playlist_height - 15, 15, FALSE, SKIN_TEXT); | |
1407 g_signal_connect(playlistwin_time_min, "button-press-event", G_CALLBACK(change_timer_mode_cb), NULL); | |
1408 | |
1409 /* track time (second) */ | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1410 playlistwin_time_sec = ui_skinned_textbox_new(SKINNED_WINDOW(playlistwin)->normal, |
2620 | 1411 playlistwin_get_width() - 64, |
1412 config.playlist_height - 15, 10, FALSE, SKIN_TEXT); | |
1413 g_signal_connect(playlistwin_time_sec, "button-press-event", G_CALLBACK(change_timer_mode_cb), NULL); | |
1414 | |
1415 /* playlist information (current track length / total track length) */ | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1416 playlistwin_info = ui_skinned_textbox_new(SKINNED_WINDOW(playlistwin)->normal, |
2620 | 1417 playlistwin_get_width() - 143, |
1418 config.playlist_height - 28, 90, FALSE, SKIN_TEXT); | |
1419 | |
1420 /* mini play control buttons at right bottom corner */ | |
1421 | |
1422 /* rewind button */ | |
1423 playlistwin_srew = ui_skinned_button_new(); | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1424 ui_skinned_small_button_setup(playlistwin_srew, SKINNED_WINDOW(playlistwin)->normal, |
2620 | 1425 playlistwin_get_width() - 144, |
1426 config.playlist_height - 16, 8, 7); | |
1427 g_signal_connect(playlistwin_srew, "clicked", local_playlist_prev, NULL); | |
1428 | |
1429 /* play button */ | |
1430 playlistwin_splay = ui_skinned_button_new(); | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1431 ui_skinned_small_button_setup(playlistwin_splay, SKINNED_WINDOW(playlistwin)->normal, |
2620 | 1432 playlistwin_get_width() - 138, |
1433 config.playlist_height - 16, 10, 7); | |
1434 g_signal_connect(playlistwin_splay, "clicked", mainwin_play_pushed, NULL); | |
1435 | |
1436 /* pause button */ | |
1437 playlistwin_spause = ui_skinned_button_new(); | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1438 ui_skinned_small_button_setup(playlistwin_spause, SKINNED_WINDOW(playlistwin)->normal, |
2620 | 1439 playlistwin_get_width() - 128, |
1440 config.playlist_height - 16, 10, 7); | |
1441 g_signal_connect(playlistwin_spause, "clicked", audacious_drct_pause, NULL); | |
1442 | |
1443 /* stop button */ | |
1444 playlistwin_sstop = ui_skinned_button_new(); | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1445 ui_skinned_small_button_setup(playlistwin_sstop, SKINNED_WINDOW(playlistwin)->normal, |
2620 | 1446 playlistwin_get_width() - 118, |
1447 config.playlist_height - 16, 9, 7); | |
1448 g_signal_connect(playlistwin_sstop, "clicked", mainwin_stop_pushed, NULL); | |
1449 | |
1450 /* forward button */ | |
1451 playlistwin_sfwd = ui_skinned_button_new(); | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1452 ui_skinned_small_button_setup(playlistwin_sfwd, SKINNED_WINDOW(playlistwin)->normal, |
2620 | 1453 playlistwin_get_width() - 109, |
1454 config.playlist_height - 16, 8, 7); | |
1455 g_signal_connect(playlistwin_sfwd, "clicked", local_playlist_next, NULL); | |
1456 | |
1457 /* eject button */ | |
1458 playlistwin_seject = ui_skinned_button_new(); | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1459 ui_skinned_small_button_setup(playlistwin_seject, SKINNED_WINDOW(playlistwin)->normal, |
2620 | 1460 playlistwin_get_width() - 100, |
1461 config.playlist_height - 16, 9, 7); | |
1462 g_signal_connect(playlistwin_seject, "clicked", mainwin_eject_pushed, NULL); | |
1463 | |
1464 playlistwin_sscroll_up = ui_skinned_button_new(); | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1465 ui_skinned_small_button_setup(playlistwin_sscroll_up, SKINNED_WINDOW(playlistwin)->normal, |
2620 | 1466 playlistwin_get_width() - 14, |
1467 config.playlist_height - 35, 8, 5); | |
1468 g_signal_connect(playlistwin_sscroll_up, "clicked", playlistwin_scroll_up_pushed, NULL); | |
1469 | |
1470 playlistwin_sscroll_down = ui_skinned_button_new(); | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2698
diff
changeset
|
1471 ui_skinned_small_button_setup(playlistwin_sscroll_down, SKINNED_WINDOW(playlistwin)->normal, |
2620 | 1472 playlistwin_get_width() - 14, |
1473 config.playlist_height - 30, 8, 5); | |
1474 g_signal_connect(playlistwin_sscroll_down, "clicked", playlistwin_scroll_down_pushed, NULL); | |
1475 | |
1476 ui_playlist_evlistener_init(); | |
1477 } | |
1478 | |
1479 static void | |
1480 selection_received(GtkWidget * widget, | |
1481 GtkSelectionData * selection_data, gpointer data) | |
1482 { | |
1483 if (selection_data->type == GDK_SELECTION_TYPE_STRING && | |
1484 selection_data->length > 0) | |
1485 aud_playlist_add_url(aud_playlist_get_active(), (gchar *) selection_data->data); | |
1486 } | |
1487 | |
1488 static void | |
1489 playlistwin_create_window(void) | |
1490 { | |
1491 GdkPixbuf *icon; | |
1492 | |
1493 playlistwin = ui_skinned_window_new("playlist"); | |
1494 gtk_window_set_title(GTK_WINDOW(playlistwin), _("Audacious Playlist Editor")); | |
1495 gtk_window_set_role(GTK_WINDOW(playlistwin), "playlist"); | |
1496 gtk_window_set_default_size(GTK_WINDOW(playlistwin), | |
1497 playlistwin_get_width(), | |
1498 playlistwin_get_height()); | |
1499 gtk_window_set_resizable(GTK_WINDOW(playlistwin), TRUE); | |
1500 playlistwin_set_geometry_hints(config.playlist_shaded); | |
1501 | |
1502 gtk_window_set_transient_for(GTK_WINDOW(playlistwin), | |
1503 GTK_WINDOW(mainwin)); | |
1504 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(playlistwin), TRUE); | |
1505 | |
1506 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) audacious_playlist_icon); | |
1507 gtk_window_set_icon(GTK_WINDOW(playlistwin), icon); | |
1508 g_object_unref(icon); | |
1509 | |
1510 if (config.playlist_x != -1 && config.save_window_position) | |
1511 gtk_window_move(GTK_WINDOW(playlistwin), | |
1512 config.playlist_x, config.playlist_y); | |
1513 | |
1514 gtk_widget_add_events(playlistwin, GDK_POINTER_MOTION_MASK | | |
1515 GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_MOTION_MASK | | |
1516 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | |
1517 GDK_SCROLL_MASK | GDK_VISIBILITY_NOTIFY_MASK); | |
1518 gtk_widget_realize(playlistwin); | |
1519 | |
1520 g_signal_connect(playlistwin, "delete_event", | |
1521 G_CALLBACK(playlistwin_delete), NULL); | |
1522 g_signal_connect(playlistwin, "button_press_event", | |
1523 G_CALLBACK(playlistwin_press), NULL); | |
1524 g_signal_connect(playlistwin, "button_release_event", | |
1525 G_CALLBACK(playlistwin_release), NULL); | |
1526 g_signal_connect(playlistwin, "scroll_event", | |
1527 G_CALLBACK(playlistwin_scrolled), NULL); | |
1528 g_signal_connect(playlistwin, "motion_notify_event", | |
1529 G_CALLBACK(playlistwin_motion), NULL); | |
2629
2ce9e17525dc
make dnd working in playlistwin
Tomasz Mon <desowin@gmail.com>
parents:
2621
diff
changeset
|
1530 |
2620 | 1531 aud_drag_dest_set(playlistwin); |
2629
2ce9e17525dc
make dnd working in playlistwin
Tomasz Mon <desowin@gmail.com>
parents:
2621
diff
changeset
|
1532 |
2620 | 1533 /* DnD stuff */ |
1534 g_signal_connect(playlistwin, "drag-leave", | |
1535 G_CALLBACK(playlistwin_drag_end), NULL); | |
1536 g_signal_connect(playlistwin, "drag-data-delete", | |
1537 G_CALLBACK(playlistwin_drag_end), NULL); | |
1538 g_signal_connect(playlistwin, "drag-end", | |
1539 G_CALLBACK(playlistwin_drag_end), NULL); | |
1540 g_signal_connect(playlistwin, "drag-drop", | |
1541 G_CALLBACK(playlistwin_drag_end), NULL); | |
1542 g_signal_connect(playlistwin, "drag-data-received", | |
1543 G_CALLBACK(playlistwin_drag_data_received), NULL); | |
1544 g_signal_connect(playlistwin, "drag-motion", | |
1545 G_CALLBACK(playlistwin_drag_motion), NULL); | |
1546 | |
1547 g_signal_connect(playlistwin, "key_press_event", | |
1548 G_CALLBACK(playlistwin_keypress), NULL); | |
1549 g_signal_connect(playlistwin, "selection_received", | |
1550 G_CALLBACK(selection_received), NULL); | |
1551 } | |
1552 | |
1553 void | |
1554 playlistwin_create(void) | |
1555 { | |
1556 resize_mutex = g_mutex_new(); | |
1557 playlistwin_create_window(); | |
1558 | |
1559 playlistwin_create_widgets(); | |
1560 playlistwin_update_info(aud_playlist_get_active()); | |
1561 | |
1562 gtk_window_add_accel_group(GTK_WINDOW(playlistwin), ui_manager_get_accel_group()); | |
1563 } | |
1564 | |
1565 | |
1566 void | |
1567 playlistwin_show(void) | |
1568 { | |
1569 gtk_window_move(GTK_WINDOW(playlistwin), config.playlist_x, config.playlist_y); | |
1570 GtkAction *action = gtk_action_group_get_action( | |
1571 toggleaction_group_others , "show playlist editor" ); | |
1572 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , TRUE ); | |
1573 | |
1574 config.playlist_visible = TRUE; | |
2668
a1431a900f28
introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents:
2658
diff
changeset
|
1575 ui_skinned_button_set_inside(mainwin_pl, TRUE); |
2620 | 1576 |
1577 playlistwin_set_toprow(0); | |
1578 aud_playlist_check_pos_current(aud_playlist_get_active()); | |
1579 | |
1580 gtk_widget_show_all(playlistwin); | |
1581 if (!config.playlist_shaded) | |
1582 gtk_widget_hide(playlistwin_sinfo); | |
1583 gtk_window_present(GTK_WINDOW(playlistwin)); | |
1584 } | |
1585 | |
1586 void | |
1587 playlistwin_hide(void) | |
1588 { | |
1589 GtkAction *action = gtk_action_group_get_action( | |
1590 toggleaction_group_others , "show playlist editor" ); | |
1591 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , FALSE ); | |
1592 | |
1593 gtk_widget_hide(playlistwin); | |
1594 config.playlist_visible = FALSE; | |
2668
a1431a900f28
introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents:
2658
diff
changeset
|
1595 ui_skinned_button_set_inside(mainwin_pl, FALSE); |
2620 | 1596 |
1597 if ( config.player_visible ) | |
1598 { | |
1599 gtk_window_present(GTK_WINDOW(mainwin)); | |
1600 gtk_widget_grab_focus(mainwin); | |
1601 } | |
1602 } | |
1603 | |
1604 void action_playlist_track_info(void) | |
1605 { | |
1606 playlistwin_fileinfo(); | |
1607 } | |
1608 | |
1609 void action_queue_toggle(void) | |
1610 { | |
1611 aud_playlist_queue(aud_playlist_get_active()); | |
1612 } | |
1613 | |
1614 void action_playlist_sort_by_playlist_entry(void) | |
1615 { | |
1616 Playlist *playlist = aud_playlist_get_active(); | |
1617 | |
1618 aud_playlist_sort(playlist, PLAYLIST_SORT_PLAYLIST); | |
1619 playlistwin_update_list(playlist); | |
1620 } | |
1621 | |
1622 void action_playlist_sort_by_track_number(void) | |
1623 { | |
1624 Playlist *playlist = aud_playlist_get_active(); | |
1625 | |
1626 aud_playlist_sort(playlist, PLAYLIST_SORT_TRACK); | |
1627 playlistwin_update_list(playlist); | |
1628 } | |
1629 | |
1630 void action_playlist_sort_by_title(void) | |
1631 { | |
1632 Playlist *playlist = aud_playlist_get_active(); | |
1633 | |
1634 aud_playlist_sort(playlist, PLAYLIST_SORT_TITLE); | |
1635 playlistwin_update_list(playlist); | |
1636 } | |
1637 | |
1638 void action_playlist_sort_by_artist(void) | |
1639 { | |
1640 Playlist *playlist = aud_playlist_get_active(); | |
1641 | |
1642 aud_playlist_sort(playlist, PLAYLIST_SORT_ARTIST); | |
1643 playlistwin_update_list(playlist); | |
1644 } | |
1645 | |
1646 void action_playlist_sort_by_full_path(void) | |
1647 { | |
1648 Playlist *playlist = aud_playlist_get_active(); | |
1649 | |
1650 aud_playlist_sort(playlist, PLAYLIST_SORT_PATH); | |
1651 playlistwin_update_list(playlist); | |
1652 } | |
1653 | |
1654 void action_playlist_sort_by_date(void) | |
1655 { | |
1656 Playlist *playlist = aud_playlist_get_active(); | |
1657 | |
1658 aud_playlist_sort(playlist, PLAYLIST_SORT_DATE); | |
1659 playlistwin_update_list(playlist); | |
1660 } | |
1661 | |
1662 void action_playlist_sort_by_filename(void) | |
1663 { | |
1664 Playlist *playlist = aud_playlist_get_active(); | |
1665 | |
1666 aud_playlist_sort(playlist, PLAYLIST_SORT_FILENAME); | |
1667 playlistwin_update_list(playlist); | |
1668 } | |
1669 | |
1670 void action_playlist_sort_selected_by_playlist_entry(void) | |
1671 { | |
1672 Playlist *playlist = aud_playlist_get_active(); | |
1673 | |
1674 aud_playlist_sort_selected(playlist, PLAYLIST_SORT_PLAYLIST); | |
1675 playlistwin_update_list(playlist); | |
1676 } | |
1677 | |
1678 void action_playlist_sort_selected_by_track_number(void) | |
1679 { | |
1680 Playlist *playlist = aud_playlist_get_active(); | |
1681 | |
1682 aud_playlist_sort_selected(playlist, PLAYLIST_SORT_TRACK); | |
1683 playlistwin_update_list(playlist); | |
1684 } | |
1685 | |
1686 void action_playlist_sort_selected_by_title(void) | |
1687 { | |
1688 Playlist *playlist = aud_playlist_get_active(); | |
1689 | |
1690 aud_playlist_sort_selected(playlist, PLAYLIST_SORT_TITLE); | |
1691 playlistwin_update_list(playlist); | |
1692 } | |
1693 | |
1694 void action_playlist_sort_selected_by_artist(void) | |
1695 { | |
1696 Playlist *playlist = aud_playlist_get_active(); | |
1697 | |
1698 aud_playlist_sort_selected(playlist, PLAYLIST_SORT_ARTIST); | |
1699 playlistwin_update_list(playlist); | |
1700 } | |
1701 | |
1702 void action_playlist_sort_selected_by_full_path(void) | |
1703 { | |
1704 Playlist *playlist = aud_playlist_get_active(); | |
1705 | |
1706 aud_playlist_sort_selected(playlist, PLAYLIST_SORT_PATH); | |
1707 playlistwin_update_list(playlist); | |
1708 } | |
1709 | |
1710 void action_playlist_sort_selected_by_date(void) | |
1711 { | |
1712 Playlist *playlist = aud_playlist_get_active(); | |
1713 | |
1714 aud_playlist_sort_selected(playlist, PLAYLIST_SORT_DATE); | |
1715 playlistwin_update_list(playlist); | |
1716 } | |
1717 | |
1718 void action_playlist_sort_selected_by_filename(void) | |
1719 { | |
1720 Playlist *playlist = aud_playlist_get_active(); | |
1721 | |
1722 aud_playlist_sort_selected(playlist, PLAYLIST_SORT_FILENAME); | |
1723 playlistwin_update_list(playlist); | |
1724 } | |
1725 | |
1726 void action_playlist_randomize_list(void) | |
1727 { | |
1728 Playlist *playlist = aud_playlist_get_active(); | |
1729 | |
1730 aud_playlist_random(playlist); | |
1731 playlistwin_update_list(playlist); | |
1732 } | |
1733 | |
1734 void action_playlist_reverse_list(void) | |
1735 { | |
1736 Playlist *playlist = aud_playlist_get_active(); | |
1737 | |
1738 aud_playlist_reverse(playlist); | |
1739 playlistwin_update_list(playlist); | |
1740 } | |
1741 | |
1742 void | |
1743 action_playlist_clear_queue(void) | |
1744 { | |
1745 aud_playlist_clear_queue(aud_playlist_get_active()); | |
1746 } | |
1747 | |
1748 void | |
1749 action_playlist_remove_unavailable(void) | |
1750 { | |
1751 aud_playlist_remove_dead_files(aud_playlist_get_active()); | |
1752 } | |
1753 | |
1754 void | |
1755 action_playlist_remove_dupes_by_title(void) | |
1756 { | |
1757 aud_playlist_remove_duplicates(aud_playlist_get_active(), PLAYLIST_DUPS_TITLE); | |
1758 } | |
1759 | |
1760 void | |
1761 action_playlist_remove_dupes_by_filename(void) | |
1762 { | |
1763 aud_playlist_remove_duplicates(aud_playlist_get_active(), PLAYLIST_DUPS_FILENAME); | |
1764 } | |
1765 | |
1766 void | |
1767 action_playlist_remove_dupes_by_full_path(void) | |
1768 { | |
1769 aud_playlist_remove_duplicates(aud_playlist_get_active(), PLAYLIST_DUPS_PATH); | |
1770 } | |
1771 | |
1772 void | |
1773 action_playlist_remove_all(void) | |
1774 { | |
1775 aud_playlist_clear(aud_playlist_get_active()); | |
1776 | |
1777 /* XXX -- should this really be coupled here? -nenolod */ | |
1778 mainwin_clear_song_info(); | |
1779 } | |
1780 | |
1781 void | |
1782 action_playlist_remove_selected(void) | |
1783 { | |
1784 aud_playlist_delete(aud_playlist_get_active(), FALSE); | |
1785 } | |
1786 | |
1787 void | |
1788 action_playlist_remove_unselected(void) | |
1789 { | |
1790 aud_playlist_delete(aud_playlist_get_active(), TRUE); | |
1791 } | |
1792 | |
1793 void | |
1794 action_playlist_add_files(void) | |
1795 { | |
2640 | 1796 gboolean button = FALSE; /* FALSE = NO_PLAY_BUTTON */ |
1797 aud_hook_call("filebrowser show", &button); | |
2620 | 1798 } |
1799 | |
1800 void | |
1801 action_playlist_add_url(void) | |
1802 { | |
1803 mainwin_show_add_url_window(); | |
1804 } | |
1805 | |
1806 void | |
1807 action_playlist_new( void ) | |
1808 { | |
1809 Playlist *new_pl = aud_playlist_new(); | |
1810 aud_playlist_add_playlist(new_pl); | |
1811 aud_playlist_select_playlist(new_pl); | |
1812 } | |
1813 | |
1814 void | |
1815 action_playlist_prev( void ) | |
1816 { | |
1817 aud_playlist_select_prev(); | |
1818 } | |
1819 | |
1820 void | |
1821 action_playlist_next( void ) | |
1822 { | |
1823 aud_playlist_select_next(); | |
1824 } | |
1825 | |
1826 void | |
1827 action_playlist_delete( void ) | |
1828 { | |
1829 aud_playlist_remove_playlist( aud_playlist_get_active() ); | |
1830 } | |
1831 | |
1832 void | |
1833 action_playlist_save_list(void) | |
1834 { | |
1835 Playlist *playlist = aud_playlist_get_active(); | |
1836 | |
1837 playlistwin_select_playlist_to_save(aud_playlist_get_current_name(playlist)); | |
1838 } | |
1839 | |
1840 void | |
1841 action_playlist_save_default_list(void) | |
1842 { | |
1843 #if 0 | |
1844 Playlist *playlist = aud_playlist_get_active(); | |
1845 | |
1846 aud_playlist_save(playlist, aud_paths[BMP_PATH_PLAYLIST_FILE]); | |
1847 #endif | |
1848 } | |
1849 | |
1850 void | |
1851 action_playlist_load_list(void) | |
1852 { | |
1853 Playlist *playlist = aud_playlist_get_active(); | |
1854 | |
1855 playlistwin_select_playlist_to_load(aud_playlist_get_current_name(playlist)); | |
1856 } | |
1857 | |
1858 void | |
1859 action_playlist_refresh_list(void) | |
1860 { | |
1861 Playlist *playlist = aud_playlist_get_active(); | |
1862 | |
1863 aud_playlist_read_info_selection(playlist); | |
1864 playlistwin_update_list(playlist); | |
1865 } | |
1866 | |
1867 void | |
1868 action_open_list_manager(void) | |
1869 { | |
1870 playlist_manager_ui_show(); | |
1871 } | |
1872 | |
1873 void | |
1874 action_playlist_search_and_select(void) | |
1875 { | |
1876 playlistwin_select_search(); | |
1877 } | |
1878 | |
1879 void | |
1880 action_playlist_invert_selection(void) | |
1881 { | |
1882 playlistwin_inverse_selection(); | |
1883 } | |
1884 | |
1885 void | |
1886 action_playlist_select_none(void) | |
1887 { | |
1888 playlistwin_select_none(); | |
1889 } | |
1890 | |
1891 void | |
1892 action_playlist_select_all(void) | |
1893 { | |
1894 playlistwin_select_all(); | |
1895 } | |
1896 | |
1897 | |
1898 static void | |
1899 playlistwin_select_search_cbt_cb(GtkWidget *called_cbt, gpointer other_cbt) | |
1900 { | |
1901 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(called_cbt)) == TRUE) | |
1902 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(other_cbt), FALSE); | |
1903 return; | |
1904 } | |
1905 | |
1906 static gboolean | |
1907 playlistwin_select_search_kp_cb(GtkWidget *entry, GdkEventKey *event, | |
1908 gpointer searchdlg_win) | |
1909 { | |
1910 switch (event->keyval) | |
1911 { | |
1912 case GDK_Return: | |
1913 if (gtk_im_context_filter_keypress (GTK_ENTRY (entry)->im_context, event)) { | |
1914 GTK_ENTRY (entry)->need_im_reset = TRUE; | |
1915 return TRUE; | |
1916 } else { | |
1917 gtk_dialog_response(GTK_DIALOG(searchdlg_win), GTK_RESPONSE_ACCEPT); | |
1918 return TRUE; | |
1919 } | |
1920 default: | |
1921 return FALSE; | |
1922 } | |
1923 } |