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