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