annotate src/skins/ui_playlist.c @ 2795:4c9db0b2194f

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