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