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