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