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