Mercurial > audlegacy-plugins
annotate src/skins/ui_skinned_playlist.c @ 3103:b562bc52a93e
ported OSS
author | Michal Lipski <tallica@o2.pl> |
---|---|
date | Thu, 30 Apr 2009 18:06:46 +0200 |
parents | 6baa6eaf8290 |
children | 5744479b31f4 |
rev | line source |
---|---|
2620 | 1 /* |
2 * Audacious - a cross-platform multimedia player | |
3 * Copyright (c) 2007 Tomasz Moń | |
4 * Copyright (c) 2008 William Pitcock | |
5 * | |
6 * Based on: | |
7 * BMP - Cross-platform multimedia player | |
8 * Copyright (C) 2003-2004 BMP development team. | |
9 * | |
10 * XMMS: | |
11 * Copyright (C) 1998-2003 XMMS development team. | |
12 * | |
13 * This program is free software; you can redistribute it and/or modify | |
14 * it under the terms of the GNU General Public License as published by | |
15 * the Free Software Foundation; under version 3 of the License. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, | |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 * GNU General Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with this program. If not, see <http://www.gnu.org/licenses>. | |
24 * | |
25 * The Audacious team does not consider modular code linking to | |
26 * Audacious or using our public API to be a derived work. | |
27 */ | |
28 | |
29 /* | |
30 * A note about Pango and some funky spacey fonts: Weirdly baselined | |
31 * fonts, or fonts with weird ascents or descents _will_ display a | |
32 * little bit weird in the playlist widget, but the display engine | |
33 * won't make it look too bad, just a little deranged. I honestly | |
34 * don't think it's worth fixing (around...), it doesn't have to be | |
35 * perfectly fitting, just the general look has to be ok, which it | |
36 * IMHO is. | |
37 * | |
38 * A second note: The numbers aren't perfectly aligned, but in the | |
39 * end it looks better when using a single Pango layout for each | |
40 * number. | |
41 */ | |
42 | |
43 #include "ui_skinned_playlist.h" | |
44 | |
45 #include "debug.h" | |
46 #include "ui_playlist.h" | |
47 #include "ui_manager.h" | |
48 #include "ui_skin.h" | |
49 #include "util.h" | |
50 #include "skins_cfg.h" | |
2971
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2698
diff
changeset
|
51 #include <audlegacy/plugin.h> |
2620 | 52 |
53 static PangoFontDescription *playlist_list_font = NULL; | |
54 static gint ascent, descent, width_delta_digit_one; | |
55 static gboolean has_slant; | |
56 static guint padding; | |
57 | |
58 /* FIXME: the following globals should not be needed. */ | |
59 static gint width_approx_letters; | |
60 static gint width_colon, width_colon_third; | |
61 static gint width_approx_digits, width_approx_digits_half; | |
62 | |
63 #define UI_SKINNED_PLAYLIST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ui_skinned_playlist_get_type(), UiSkinnedPlaylistPrivate)) | |
64 typedef struct _UiSkinnedPlaylistPrivate UiSkinnedPlaylistPrivate; | |
65 | |
66 struct _UiSkinnedPlaylistPrivate { | |
67 SkinPixmapId skin_index; | |
68 gint width, height; | |
69 gint resize_width, resize_height; | |
70 gint drag_pos; | |
71 gboolean dragging, auto_drag_down, auto_drag_up; | |
72 gint auto_drag_up_tag, auto_drag_down_tag; | |
73 }; | |
74 | |
75 static void ui_skinned_playlist_class_init (UiSkinnedPlaylistClass *klass); | |
76 static void ui_skinned_playlist_init (UiSkinnedPlaylist *playlist); | |
77 static void ui_skinned_playlist_destroy (GtkObject *object); | |
78 static void ui_skinned_playlist_realize (GtkWidget *widget); | |
79 static void ui_skinned_playlist_size_request (GtkWidget *widget, GtkRequisition *requisition); | |
80 static void ui_skinned_playlist_size_allocate (GtkWidget *widget, GtkAllocation *allocation); | |
81 static gboolean ui_skinned_playlist_expose (GtkWidget *widget, GdkEventExpose *event); | |
82 static gboolean ui_skinned_playlist_button_press (GtkWidget *widget, GdkEventButton *event); | |
83 static gboolean ui_skinned_playlist_button_release (GtkWidget *widget, GdkEventButton *event); | |
84 static gboolean ui_skinned_playlist_motion_notify (GtkWidget *widget, GdkEventMotion *event); | |
85 static gboolean ui_skinned_playlist_leave_notify (GtkWidget *widget, GdkEventCrossing *event); | |
86 static gboolean ui_skinned_playlist_popup_show (gpointer data); | |
87 static void ui_skinned_playlist_popup_hide (GtkWidget *widget); | |
88 static void ui_skinned_playlist_popup_timer_start (GtkWidget *widget); | |
89 static void ui_skinned_playlist_popup_timer_stop (GtkWidget *widget); | |
90 | |
91 static GtkWidgetClass *parent_class = NULL; | |
92 | |
93 GType ui_skinned_playlist_get_type() { | |
94 static GType playlist_type = 0; | |
95 if (!playlist_type) { | |
96 static const GTypeInfo playlist_info = { | |
97 sizeof (UiSkinnedPlaylistClass), | |
98 NULL, | |
99 NULL, | |
100 (GClassInitFunc) ui_skinned_playlist_class_init, | |
101 NULL, | |
102 NULL, | |
103 sizeof (UiSkinnedPlaylist), | |
104 0, | |
105 (GInstanceInitFunc) ui_skinned_playlist_init, | |
106 }; | |
107 playlist_type = g_type_register_static (GTK_TYPE_WIDGET, "UiSkinnedPlaylist", &playlist_info, 0); | |
108 } | |
109 | |
110 return playlist_type; | |
111 } | |
112 | |
113 static void ui_skinned_playlist_class_init(UiSkinnedPlaylistClass *klass) { | |
114 GObjectClass *gobject_class; | |
115 GtkObjectClass *object_class; | |
116 GtkWidgetClass *widget_class; | |
117 | |
118 gobject_class = G_OBJECT_CLASS(klass); | |
119 object_class = (GtkObjectClass*) klass; | |
120 widget_class = (GtkWidgetClass*) klass; | |
3032
6baa6eaf8290
Don't use deprecated gtk_type_class()
Tomasz Mon <desowin@gmail.com>
parents:
3031
diff
changeset
|
121 parent_class = g_type_class_peek_parent(klass); |
2620 | 122 |
123 object_class->destroy = ui_skinned_playlist_destroy; | |
124 | |
125 widget_class->realize = ui_skinned_playlist_realize; | |
126 widget_class->expose_event = ui_skinned_playlist_expose; | |
127 widget_class->size_request = ui_skinned_playlist_size_request; | |
128 widget_class->size_allocate = ui_skinned_playlist_size_allocate; | |
129 widget_class->button_press_event = ui_skinned_playlist_button_press; | |
130 widget_class->button_release_event = ui_skinned_playlist_button_release; | |
131 widget_class->motion_notify_event = ui_skinned_playlist_motion_notify; | |
132 widget_class->leave_notify_event = ui_skinned_playlist_leave_notify; | |
133 | |
134 g_type_class_add_private (gobject_class, sizeof (UiSkinnedPlaylistPrivate)); | |
135 } | |
136 | |
137 static void ui_skinned_playlist_init(UiSkinnedPlaylist *playlist) { | |
138 UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(playlist); | |
139 playlist->pressed = FALSE; | |
140 priv->resize_width = 0; | |
141 priv->resize_height = 0; | |
142 playlist->prev_selected = -1; | |
143 playlist->prev_min = -1; | |
144 playlist->prev_max = -1; | |
145 | |
146 g_object_set_data(G_OBJECT(playlist), "timer_id", GINT_TO_POINTER(0)); | |
147 g_object_set_data(G_OBJECT(playlist), "timer_active", GINT_TO_POINTER(0)); | |
2638 | 148 |
149 GtkWidget *popup = audacious_fileinfopopup_create(); | |
2620 | 150 g_object_set_data(G_OBJECT(playlist), "popup", popup); |
151 g_object_set_data(G_OBJECT(playlist), "popup_active", GINT_TO_POINTER(0)); | |
152 g_object_set_data(G_OBJECT(playlist), "popup_position", GINT_TO_POINTER(-1)); | |
153 } | |
154 | |
155 GtkWidget* ui_skinned_playlist_new(GtkWidget *fixed, gint x, gint y, gint w, gint h) { | |
156 | |
157 UiSkinnedPlaylist *hs = g_object_new (ui_skinned_playlist_get_type (), NULL); | |
158 UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(hs); | |
159 | |
160 hs->x = x; | |
161 hs->y = y; | |
162 priv->width = w; | |
163 priv->height = h; | |
164 priv->skin_index = SKIN_PLEDIT; | |
165 | |
166 gtk_fixed_put(GTK_FIXED(fixed), GTK_WIDGET(hs), hs->x, hs->y); | |
167 gtk_widget_set_double_buffered(GTK_WIDGET(hs), TRUE); | |
168 | |
169 return GTK_WIDGET(hs); | |
170 } | |
171 | |
172 static void ui_skinned_playlist_destroy(GtkObject *object) { | |
173 UiSkinnedPlaylist *playlist; | |
174 | |
175 g_return_if_fail (object != NULL); | |
176 g_return_if_fail (UI_SKINNED_IS_PLAYLIST (object)); | |
177 | |
178 playlist = UI_SKINNED_PLAYLIST (object); | |
179 | |
180 if (GTK_OBJECT_CLASS (parent_class)->destroy) | |
181 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); | |
182 } | |
183 | |
184 static void ui_skinned_playlist_realize(GtkWidget *widget) { | |
185 UiSkinnedPlaylist *playlist; | |
186 GdkWindowAttr attributes; | |
187 gint attributes_mask; | |
188 | |
189 g_return_if_fail (widget != NULL); | |
190 g_return_if_fail (UI_SKINNED_IS_PLAYLIST(widget)); | |
191 | |
192 GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); | |
193 playlist = UI_SKINNED_PLAYLIST(widget); | |
194 | |
195 attributes.x = widget->allocation.x; | |
196 attributes.y = widget->allocation.y; | |
197 attributes.width = widget->allocation.width; | |
198 attributes.height = widget->allocation.height; | |
199 attributes.wclass = GDK_INPUT_OUTPUT; | |
200 attributes.window_type = GDK_WINDOW_CHILD; | |
201 attributes.event_mask = gtk_widget_get_events(widget); | |
202 attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | | |
203 GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK; | |
204 attributes.visual = gtk_widget_get_visual(widget); | |
205 attributes.colormap = gtk_widget_get_colormap(widget); | |
206 | |
207 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; | |
208 widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask); | |
209 | |
210 widget->style = gtk_style_attach(widget->style, widget->window); | |
211 gdk_window_set_user_data(widget->window, widget); | |
212 } | |
213 | |
214 static void ui_skinned_playlist_size_request(GtkWidget *widget, GtkRequisition *requisition) { | |
215 UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(widget); | |
216 | |
217 requisition->width = priv->width; | |
218 requisition->height = priv->height; | |
219 } | |
220 | |
221 static void ui_skinned_playlist_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { | |
222 UiSkinnedPlaylist *playlist = UI_SKINNED_PLAYLIST (widget); | |
223 UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(playlist); | |
224 | |
225 widget->allocation = *allocation; | |
226 if (GTK_WIDGET_REALIZED (widget)) | |
227 gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height); | |
228 | |
229 playlist->x = widget->allocation.x; | |
230 playlist->y = widget->allocation.y; | |
231 | |
232 if (priv->height != widget->allocation.height || priv->width != widget->allocation.width) { | |
233 priv->width = priv->width + priv->resize_width; | |
234 priv->height = priv->height + priv->resize_height; | |
235 priv->resize_width = 0; | |
236 priv->resize_height = 0; | |
237 gtk_widget_queue_draw(widget); | |
238 } | |
239 } | |
240 | |
241 static gboolean ui_skinned_playlist_auto_drag_down_func(gpointer data) { | |
242 UiSkinnedPlaylist *pl = UI_SKINNED_PLAYLIST(data); | |
243 UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(data); | |
244 | |
245 if (priv->auto_drag_down) { | |
246 ui_skinned_playlist_move_down(pl); | |
247 pl->first++; | |
248 playlistwin_update_list(aud_playlist_get_active()); | |
249 return TRUE; | |
250 } | |
251 return FALSE; | |
252 } | |
253 | |
254 static gboolean ui_skinned_playlist_auto_drag_up_func(gpointer data) { | |
255 UiSkinnedPlaylist *pl = UI_SKINNED_PLAYLIST(data); | |
256 UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(data); | |
257 | |
258 if (priv->auto_drag_up) { | |
259 ui_skinned_playlist_move_up(pl); | |
260 pl->first--; | |
261 playlistwin_update_list(aud_playlist_get_active()); | |
262 return TRUE; | |
263 | |
264 } | |
265 return FALSE; | |
266 } | |
267 | |
268 void ui_skinned_playlist_move_up(UiSkinnedPlaylist * pl) { | |
269 GList *list; | |
270 Playlist *playlist = aud_playlist_get_active(); | |
271 | |
272 if (!playlist) | |
273 return; | |
274 | |
275 PLAYLIST_LOCK(playlist); | |
276 if ((list = playlist->entries) == NULL) { | |
277 PLAYLIST_UNLOCK(playlist); | |
278 return; | |
279 } | |
280 if (PLAYLIST_ENTRY(list->data)->selected) { | |
281 /* We are at the top */ | |
282 PLAYLIST_UNLOCK(playlist); | |
283 return; | |
284 } | |
285 while (list) { | |
286 if (PLAYLIST_ENTRY(list->data)->selected) | |
287 glist_moveup(list); | |
288 list = g_list_next(list); | |
289 } | |
290 PLAYLIST_INCR_SERIAL(playlist); | |
291 PLAYLIST_UNLOCK(playlist); | |
292 if (pl->prev_selected != -1) | |
293 pl->prev_selected--; | |
294 if (pl->prev_min != -1) | |
295 pl->prev_min--; | |
296 if (pl->prev_max != -1) | |
297 pl->prev_max--; | |
298 } | |
299 | |
300 void ui_skinned_playlist_move_down(UiSkinnedPlaylist * pl) { | |
301 GList *list; | |
302 Playlist *playlist = aud_playlist_get_active(); | |
303 | |
304 if (!playlist) | |
305 return; | |
306 | |
307 PLAYLIST_LOCK(playlist); | |
308 | |
309 if (!(list = g_list_last(playlist->entries))) { | |
310 PLAYLIST_UNLOCK(playlist); | |
311 return; | |
312 } | |
313 | |
314 if (PLAYLIST_ENTRY(list->data)->selected) { | |
315 /* We are at the bottom */ | |
316 PLAYLIST_UNLOCK(playlist); | |
317 return; | |
318 } | |
319 | |
320 while (list) { | |
321 if (PLAYLIST_ENTRY(list->data)->selected) | |
322 glist_movedown(list); | |
323 list = g_list_previous(list); | |
324 } | |
325 | |
326 PLAYLIST_INCR_SERIAL(playlist); | |
327 PLAYLIST_UNLOCK(playlist); | |
328 | |
329 if (pl->prev_selected != -1) | |
330 pl->prev_selected++; | |
331 if (pl->prev_min != -1) | |
332 pl->prev_min++; | |
333 if (pl->prev_max != -1) | |
334 pl->prev_max++; | |
335 } | |
336 | |
337 static void | |
338 playlist_list_draw_string(cairo_t *cr, UiSkinnedPlaylist *pl, | |
339 PangoFontDescription * font, | |
340 gint line, | |
341 gint width, | |
342 const gchar * text, | |
343 guint ppos) | |
344 { | |
345 guint plist_length_int; | |
346 Playlist *playlist = aud_playlist_get_active(); | |
347 PangoLayout *layout; | |
348 | |
349 REQUIRE_LOCK(playlist->mutex); | |
350 | |
351 cairo_new_path(cr); | |
352 | |
353 if (config.show_numbers_in_pl) { | |
354 gchar *pos_string = g_strdup_printf(config.show_separator_in_pl == TRUE ? "%d" : "%d.", ppos); | |
355 plist_length_int = | |
356 gint_count_digits(aud_playlist_get_length(playlist)) + !config.show_separator_in_pl + 1; /* cf.show_separator_in_pl will be 0 if false */ | |
357 | |
358 padding = plist_length_int; | |
359 padding = ((padding + 1) * width_approx_digits); | |
360 | |
361 layout = gtk_widget_create_pango_layout(playlistwin, pos_string); | |
362 pango_layout_set_font_description(layout, playlist_list_font); | |
363 pango_layout_set_width(layout, plist_length_int * 100); | |
364 | |
365 pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT); | |
366 | |
367 cairo_move_to(cr, (width_approx_digits * | |
368 (-1 + plist_length_int - strlen(pos_string))) + | |
369 (width_approx_digits / 4), (line - 1) * pl->fheight + | |
370 ascent + abs(descent)); | |
371 pango_cairo_show_layout(cr, layout); | |
372 | |
373 g_free(pos_string); | |
374 g_object_unref(layout); | |
375 | |
376 if (!config.show_separator_in_pl) | |
377 padding -= (width_approx_digits * 1.5); | |
378 } else { | |
379 padding = 3; | |
380 } | |
381 | |
382 width -= padding; | |
383 | |
384 layout = gtk_widget_create_pango_layout(playlistwin, text); | |
385 | |
386 pango_layout_set_font_description(layout, playlist_list_font); | |
387 pango_layout_set_width(layout, width * PANGO_SCALE); | |
388 pango_layout_set_single_paragraph_mode(layout, TRUE); | |
389 pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END); | |
390 | |
391 cairo_move_to(cr, padding + (width_approx_letters / 4), | |
392 (line - 1) * pl->fheight + | |
393 ascent + abs(descent)); | |
394 pango_cairo_show_layout(cr, layout); | |
395 | |
396 g_object_unref(layout); | |
397 } | |
398 | |
399 static gboolean ui_skinned_playlist_expose(GtkWidget *widget, GdkEventExpose *event) { | |
400 UiSkinnedPlaylist *pl = UI_SKINNED_PLAYLIST (widget); | |
401 UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(pl); | |
402 g_return_val_if_fail (priv->width > 0 && priv->height > 0, FALSE); | |
403 | |
404 Playlist *playlist = aud_playlist_get_active(); | |
405 PlaylistEntry *entry; | |
406 GList *list; | |
407 PangoLayout *layout; | |
408 gchar *title; | |
409 gint width, height; | |
410 gint i, max_first; | |
411 guint padding, padding_dwidth, padding_plength; | |
412 guint max_time_len = 0; | |
413 gfloat queue_tailpadding = 0; | |
414 gint tpadding; | |
415 gsize tpadding_dwidth = 0; | |
416 gint x, y; | |
417 guint tail_width; | |
418 guint tail_len; | |
419 gboolean in_selection = FALSE; | |
420 | |
421 gchar tail[100]; | |
422 gchar queuepos[255]; | |
423 gchar length[40]; | |
424 | |
425 gchar **frags; | |
426 gchar *frag0; | |
427 | |
428 gint plw_w, plw_h; | |
429 | |
430 cairo_t *cr; | |
431 gint yc; | |
432 gint pos; | |
433 gdouble rounding_offset; | |
434 | |
435 g_return_val_if_fail (widget != NULL, FALSE); | |
436 g_return_val_if_fail (UI_SKINNED_IS_PLAYLIST (widget), FALSE); | |
437 g_return_val_if_fail (event != NULL, FALSE); | |
438 | |
439 cr = gdk_cairo_create(widget->window); | |
440 | |
441 width = priv->width; | |
442 height = priv->height; | |
443 | |
444 plw_w = playlistwin_get_width(); | |
445 plw_h = playlistwin_get_height(); | |
446 | |
447 gdk_cairo_set_source_color(cr, skin_get_color(aud_active_skin, SKIN_PLEDIT_NORMALBG)); | |
448 | |
449 cairo_rectangle(cr, 0, 0, width, height); | |
450 cairo_paint(cr); | |
451 | |
452 if (!playlist_list_font) { | |
453 g_critical("Couldn't open playlist font"); | |
454 return FALSE; | |
455 } | |
456 | |
457 pl->fheight = (ascent + abs(descent)); | |
458 pl->num_visible = height / pl->fheight; | |
459 | |
460 rounding_offset = pl->fheight / 3; | |
461 | |
462 max_first = aud_playlist_get_length(playlist) - pl->num_visible; | |
463 max_first = MAX(max_first, 0); | |
464 | |
465 pl->first = CLAMP(pl->first, 0, max_first); | |
466 | |
467 PLAYLIST_LOCK(playlist); | |
468 list = playlist->entries; | |
469 list = g_list_nth(list, pl->first); | |
470 | |
471 /* It sucks having to run the iteration twice but this is the only | |
472 way you can reliably get the maximum width so we can get our | |
473 playlist nice and aligned... -- plasmaroo */ | |
474 | |
475 for (i = pl->first; | |
476 list && i < pl->first + pl->num_visible; | |
477 list = g_list_next(list), i++) { | |
478 entry = list->data; | |
479 | |
480 if (entry->length != -1) | |
481 { | |
482 g_snprintf(length, sizeof(length), "%d:%-2.2d", | |
483 entry->length / 60000, (entry->length / 1000) % 60); | |
484 tpadding_dwidth = MAX(tpadding_dwidth, strlen(length)); | |
485 } | |
486 } | |
487 | |
488 /* Reset */ | |
489 list = playlist->entries; | |
490 list = g_list_nth(list, pl->first); | |
491 | |
492 for (i = pl->first; | |
493 list && i < pl->first + pl->num_visible; | |
494 list = g_list_next(list), i++) { | |
495 entry = list->data; | |
496 | |
497 if (entry->selected && !in_selection) { | |
498 yc = ((i - pl->first) * pl->fheight); | |
499 | |
500 cairo_new_path(cr); | |
501 | |
502 cairo_move_to(cr, 0, yc + (rounding_offset * 2)); | |
503 cairo_curve_to(cr, 0, yc + rounding_offset, 0, yc + 0.5, 0 + rounding_offset, yc + 0.5); | |
504 | |
505 cairo_line_to(cr, 0 + width - (rounding_offset * 2), yc + 0.5); | |
506 cairo_curve_to(cr, 0 + width - rounding_offset, yc + 0.5, | |
507 0 + width, yc + 0.5, 0 + width, yc + rounding_offset); | |
508 | |
509 in_selection = TRUE; | |
510 } | |
511 | |
512 if ((!entry->selected || | |
513 (i == pl->first + pl->num_visible - 1) || !g_list_next(list)) | |
514 && in_selection) { | |
515 | |
516 if (!entry->selected) | |
517 yc = (((i - 1) - pl->first) * pl->fheight); | |
518 else /* last visible item */ | |
519 yc = ((i - pl->first) * pl->fheight); | |
520 | |
521 cairo_line_to(cr, 0 + width, yc + pl->fheight - (rounding_offset * 2)); | |
522 cairo_curve_to (cr, 0 + width, yc + pl->fheight - rounding_offset, | |
523 0 + width, yc + pl->fheight - 0.5, | |
524 0 + width-rounding_offset, yc + pl->fheight - 0.5); | |
525 | |
526 cairo_line_to (cr, 0 + (rounding_offset * 2), yc + pl->fheight - 0.5); | |
527 cairo_curve_to (cr, 0 + rounding_offset, yc + pl->fheight - 0.5, | |
528 0, yc + pl->fheight - 0.5, | |
529 0, yc + pl->fheight - rounding_offset); | |
530 | |
531 cairo_close_path (cr); | |
532 | |
533 gdk_cairo_set_source_color(cr, skin_get_color(aud_active_skin, SKIN_PLEDIT_SELECTEDBG)); | |
534 | |
535 cairo_fill(cr); | |
536 | |
537 in_selection = FALSE; | |
538 } | |
539 } | |
540 | |
541 list = playlist->entries; | |
542 list = g_list_nth(list, pl->first); | |
543 | |
544 /* now draw the text */ | |
545 for (i = pl->first; | |
546 list && i < pl->first + pl->num_visible; | |
547 list = g_list_next(list), i++) { | |
548 entry = list->data; | |
549 | |
550 /* FIXME: entry->title should NEVER be NULL, and there should | |
551 NEVER be a need to do a UTF-8 conversion. Playlist title | |
552 strings should be kept properly. */ | |
553 | |
554 if (!entry->title) { | |
555 gchar *realfn = g_filename_from_uri(entry->filename, NULL, NULL); | |
556 gchar *basename = g_path_get_basename(realfn ? realfn : entry->filename); | |
557 title = aud_filename_to_utf8(basename); | |
558 g_free(basename); g_free(realfn); | |
559 } | |
560 else | |
561 title = aud_str_to_utf8(entry->title); | |
562 | |
563 title = aud_convert_title_text(title); | |
564 | |
565 pos = aud_playlist_get_queue_position(playlist, entry); | |
566 | |
567 tail[0] = 0; | |
568 queuepos[0] = 0; | |
569 length[0] = 0; | |
570 | |
571 if (pos != -1) | |
572 g_snprintf(queuepos, sizeof(queuepos), "%d", pos + 1); | |
573 | |
574 if (entry->length != -1) | |
575 { | |
576 g_snprintf(length, sizeof(length), "%d:%-2.2d", | |
577 entry->length / 60000, (entry->length / 1000) % 60); | |
578 } | |
579 | |
580 strncat(tail, length, sizeof(tail) - 1); | |
581 tail_len = strlen(tail); | |
582 | |
583 max_time_len = MAX(max_time_len, tail_len); | |
584 | |
585 if (pos != -1 && tpadding_dwidth <= 0) | |
586 tail_width = width - (width_approx_digits * (strlen(queuepos) + 2.25)); | |
587 else if (pos != -1) | |
588 tail_width = width - (width_approx_digits * (tpadding_dwidth + strlen(queuepos) + 4)); | |
589 else if (tpadding_dwidth > 0) | |
590 tail_width = width - (width_approx_digits * (tpadding_dwidth + 2.5)); | |
591 else | |
592 tail_width = width; | |
593 | |
594 if (i == aud_playlist_get_position_nolock(playlist)) | |
595 gdk_cairo_set_source_color(cr, skin_get_color(aud_active_skin, SKIN_PLEDIT_CURRENT)); | |
596 else | |
597 gdk_cairo_set_source_color(cr, skin_get_color(aud_active_skin, SKIN_PLEDIT_NORMAL)); | |
598 | |
599 playlist_list_draw_string(cr, pl, playlist_list_font, | |
600 i - pl->first, tail_width, title, | |
601 i + 1); | |
602 | |
603 x = width - width_approx_digits * 2; | |
604 y = ((i - pl->first) - 1) * pl->fheight + ascent; | |
605 | |
606 frags = NULL; | |
607 frag0 = NULL; | |
608 | |
609 if ((strlen(tail) > 0) && (tail != NULL)) { | |
610 frags = g_strsplit(tail, ":", 0); | |
611 frag0 = g_strconcat(frags[0], ":", NULL); | |
612 | |
613 layout = gtk_widget_create_pango_layout(playlistwin, frags[1]); | |
614 pango_layout_set_font_description(layout, playlist_list_font); | |
615 pango_layout_set_width(layout, tail_len * 100); | |
616 pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT); | |
617 | |
618 cairo_new_path(cr); | |
619 cairo_move_to(cr, x - (0.5 * width_approx_digits), y + abs(descent)); | |
620 pango_cairo_show_layout(cr, layout); | |
621 g_object_unref(layout); | |
622 | |
623 layout = gtk_widget_create_pango_layout(playlistwin, frag0); | |
624 pango_layout_set_font_description(layout, playlist_list_font); | |
625 pango_layout_set_width(layout, tail_len * 100); | |
626 pango_layout_set_alignment(layout, PANGO_ALIGN_RIGHT); | |
627 | |
628 cairo_move_to(cr, x - (0.75 * width_approx_digits), y + abs(descent)); | |
629 pango_cairo_show_layout(cr, layout); | |
630 g_object_unref(layout); | |
631 | |
632 g_free(frag0); | |
633 g_strfreev(frags); | |
634 } | |
635 | |
636 if (pos != -1) { | |
637 if (tpadding_dwidth > 0) | |
638 queue_tailpadding = tpadding_dwidth + 1; | |
639 else | |
640 queue_tailpadding = -0.75; | |
641 | |
642 cairo_rectangle(cr, | |
643 x - | |
644 (((queue_tailpadding + | |
645 strlen(queuepos)) * | |
646 width_approx_digits) + | |
647 (width_approx_digits / 4)), | |
648 y + abs(descent), | |
649 (strlen(queuepos)) * | |
650 width_approx_digits + | |
651 (width_approx_digits / 2), | |
652 pl->fheight - 2); | |
653 | |
654 layout = | |
655 gtk_widget_create_pango_layout(playlistwin, queuepos); | |
656 pango_layout_set_font_description(layout, playlist_list_font); | |
657 pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); | |
658 | |
659 cairo_move_to(cr, | |
660 x - | |
661 ((queue_tailpadding + | |
662 strlen(queuepos)) * width_approx_digits) + | |
663 (width_approx_digits / 4), | |
664 y + abs(descent)); | |
665 pango_cairo_show_layout(cr, layout); | |
666 | |
667 g_object_unref(layout); | |
668 } | |
669 | |
670 cairo_stroke(cr); | |
671 | |
672 g_free(title); | |
673 } | |
674 | |
675 | |
676 /* | |
677 * Drop target hovering over the playlist, so draw some hint where the | |
678 * drop will occur. | |
679 * | |
680 * This is (currently? unfixably?) broken when dragging files from Qt/KDE apps, | |
681 * probably due to DnD signaling problems (actually i have no clue). | |
682 * | |
683 */ | |
684 | |
685 if (pl->drag_motion) { | |
686 guint pos, plength, lpadding; | |
687 | |
688 if (config.show_numbers_in_pl) { | |
689 lpadding = gint_count_digits(aud_playlist_get_length(playlist)) + 1; | |
690 lpadding = ((lpadding + 1) * width_approx_digits); | |
691 } | |
692 else { | |
693 lpadding = 3; | |
694 }; | |
695 | |
696 /* We already hold the mutex and have the playlist locked, so call | |
697 the non-locking function. */ | |
698 plength = aud_playlist_get_length(playlist); | |
699 | |
700 x = pl->drag_motion_x; | |
701 y = pl->drag_motion_y; | |
702 | |
703 if ((x > pl->x) && !(x > priv->width)) { | |
704 | |
705 if ((y > pl->y) | |
706 && !(y > (priv->height + pl->y))) { | |
707 | |
708 pos = (y / pl->fheight) + | |
709 pl->first; | |
710 | |
711 if (pos > (plength)) { | |
712 pos = plength; | |
713 } | |
714 | |
715 gdk_cairo_set_source_color(cr, skin_get_color(aud_active_skin, SKIN_PLEDIT_CURRENT)); | |
716 | |
717 cairo_new_path(cr); | |
718 | |
719 cairo_move_to(cr, 0, ((pos - pl->first) * pl->fheight)); | |
720 cairo_rel_line_to(cr, priv->width - 1, 0); | |
721 | |
722 cairo_set_line_width(cr, 1); | |
723 cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE); | |
724 cairo_stroke(cr); | |
725 } | |
726 | |
727 } | |
728 | |
729 /* When dropping on the borders of the playlist, outside the text area, | |
730 * files get appended at the end of the list. Show that too. | |
731 */ | |
732 | |
733 if ((y < pl->y) || (y > priv->height + pl->y)) { | |
734 if ((y >= 0) || (y <= (priv->height + pl->y))) { | |
735 pos = plength; | |
736 | |
737 gdk_cairo_set_source_color(cr, skin_get_color(aud_active_skin, SKIN_PLEDIT_CURRENT)); | |
738 | |
739 cairo_new_path(cr); | |
740 | |
741 cairo_move_to(cr, 0, ((pos - pl->first) * pl->fheight)); | |
742 cairo_rel_line_to(cr, priv->width - 1, 0); | |
743 | |
744 cairo_set_line_width(cr, 1); | |
745 cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE); | |
746 cairo_stroke(cr); | |
747 } | |
748 } | |
749 } | |
750 | |
751 gdk_cairo_set_source_color(cr, skin_get_color(aud_active_skin, SKIN_PLEDIT_NORMAL)); | |
752 cairo_set_line_width(cr, 1); | |
753 cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE); | |
754 | |
755 if (config.show_numbers_in_pl) | |
756 { | |
757 padding_plength = aud_playlist_get_length(playlist); | |
758 | |
759 if (padding_plength == 0) { | |
760 padding_dwidth = 0; | |
761 } | |
762 else { | |
763 padding_dwidth = gint_count_digits(aud_playlist_get_length(playlist)); | |
764 } | |
765 | |
766 padding = | |
767 (padding_dwidth * | |
768 width_approx_digits) + width_approx_digits; | |
769 | |
770 | |
771 /* For italic or oblique fonts we add another half of the | |
772 * approximate width */ | |
773 if (has_slant) | |
774 padding += width_approx_digits_half; | |
775 | |
776 if (config.show_separator_in_pl) { | |
777 cairo_new_path(cr); | |
778 | |
779 cairo_move_to(cr, padding, 0); | |
780 cairo_rel_line_to(cr, 0, priv->height - 1); | |
781 | |
782 cairo_stroke(cr); | |
783 } | |
784 } | |
785 | |
786 if (tpadding_dwidth != 0) | |
787 { | |
788 tpadding = (tpadding_dwidth * width_approx_digits) + (width_approx_digits * 1.5); | |
789 | |
790 if (has_slant) | |
791 tpadding += width_approx_digits_half; | |
792 | |
793 if (config.show_separator_in_pl) { | |
794 cairo_new_path(cr); | |
795 | |
796 cairo_move_to(cr, priv->width - tpadding, 0); | |
797 cairo_rel_line_to(cr, 0, priv->height - 1); | |
798 | |
799 cairo_stroke(cr); | |
800 } | |
801 } | |
802 | |
803 PLAYLIST_UNLOCK(playlist); | |
804 | |
805 cairo_destroy(cr); | |
806 | |
807 return FALSE; | |
808 } | |
809 | |
810 gint ui_skinned_playlist_get_position(GtkWidget *widget, gint x, gint y) { | |
811 gint iy, length; | |
812 gint ret; | |
813 Playlist *playlist = aud_playlist_get_active(); | |
814 UiSkinnedPlaylist *pl = UI_SKINNED_PLAYLIST (widget); | |
815 | |
816 if (!pl->fheight) | |
817 return -1; | |
818 | |
819 if ((length = aud_playlist_get_length(playlist)) == 0) | |
820 return -1; | |
821 iy = y; | |
822 | |
823 ret = (iy / pl->fheight) + pl->first; | |
824 | |
825 if (ret > length - 1) | |
826 ret = -1; | |
827 | |
828 return ret; | |
829 } | |
830 | |
831 static gboolean ui_skinned_playlist_button_press(GtkWidget *widget, GdkEventButton *event) { | |
832 UiSkinnedPlaylist *pl = UI_SKINNED_PLAYLIST (widget); | |
833 UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(widget); | |
834 | |
835 gint nr; | |
836 Playlist *playlist = aud_playlist_get_active(); | |
837 | |
838 nr = ui_skinned_playlist_get_position(widget, event->x, event->y); | |
839 if (nr == -1) | |
2657 | 840 return TRUE; |
2620 | 841 |
842 if (event->button == 3) { | |
843 ui_manager_popup_menu_show(GTK_MENU(playlistwin_popup_menu), | |
844 event->x_root, event->y_root + 5, | |
845 event->button, event->time); | |
846 GList* selection = aud_playlist_get_selected(playlist); | |
847 if (g_list_find(selection, GINT_TO_POINTER(nr)) == NULL) { | |
848 aud_playlist_select_all(playlist, FALSE); | |
849 aud_playlist_select_range(playlist, nr, nr, TRUE); | |
850 } | |
851 } else if (event->button == 1) { | |
852 if (!(event->state & GDK_CONTROL_MASK)) | |
853 aud_playlist_select_all(playlist, FALSE); | |
854 | |
855 if ((event->state & GDK_MOD1_MASK)) | |
856 aud_playlist_queue_position(playlist, nr); | |
857 | |
858 if (event->state & GDK_SHIFT_MASK && pl->prev_selected != -1) { | |
859 aud_playlist_select_range(playlist, pl->prev_selected, nr, TRUE); | |
860 pl->prev_min = pl->prev_selected; | |
861 pl->prev_max = nr; | |
862 priv->drag_pos = nr - pl->first; | |
863 } | |
864 else { | |
865 if (aud_playlist_select_invert(playlist, nr)) { | |
866 if (event->state & GDK_CONTROL_MASK) { | |
867 if (pl->prev_min == -1) { | |
868 pl->prev_min = pl->prev_selected; | |
869 pl->prev_max = pl->prev_selected; | |
870 } | |
871 if (nr < pl->prev_min) | |
872 pl->prev_min = nr; | |
873 else if (nr > pl->prev_max) | |
874 pl->prev_max = nr; | |
875 } | |
876 else | |
877 pl->prev_min = -1; | |
878 pl->prev_selected = nr; | |
879 priv->drag_pos = nr - pl->first; | |
880 } | |
881 } | |
882 if (event->type == GDK_2BUTTON_PRESS) { | |
883 /* | |
884 * Ungrab the pointer to prevent us from | |
885 * hanging on to it during the sometimes slow | |
886 * audacious_drct_initiate(). | |
887 */ | |
888 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
889 aud_playlist_set_position(playlist, nr); | |
890 if (!audacious_drct_get_playing()) | |
891 audacious_drct_initiate(); | |
892 } | |
893 | |
894 priv->dragging = TRUE; | |
895 } | |
896 playlistwin_update_list(playlist); | |
897 ui_skinned_playlist_popup_hide(widget); | |
898 ui_skinned_playlist_popup_timer_stop(widget); | |
899 | |
900 return TRUE; | |
901 } | |
902 | |
903 static gboolean ui_skinned_playlist_button_release(GtkWidget *widget, GdkEventButton *event) { | |
904 UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(widget); | |
905 | |
906 priv->dragging = FALSE; | |
907 priv->auto_drag_down = FALSE; | |
908 priv->auto_drag_up = FALSE; | |
909 gtk_widget_queue_draw(widget); | |
910 | |
911 ui_skinned_playlist_popup_hide(widget); | |
912 ui_skinned_playlist_popup_timer_stop(widget); | |
913 return TRUE; | |
914 } | |
915 | |
916 static gboolean ui_skinned_playlist_motion_notify(GtkWidget *widget, GdkEventMotion *event) { | |
917 UiSkinnedPlaylist *pl = UI_SKINNED_PLAYLIST(widget); | |
918 UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(widget); | |
919 | |
920 gint nr, y, off, i; | |
921 if (priv->dragging) { | |
922 y = event->y; | |
923 nr = (y / pl->fheight); | |
924 if (nr < 0) { | |
925 nr = 0; | |
926 if (!priv->auto_drag_up) { | |
927 priv->auto_drag_up = TRUE; | |
928 priv->auto_drag_up_tag = | |
929 g_timeout_add(100, ui_skinned_playlist_auto_drag_up_func, pl); | |
930 } | |
931 } | |
932 else if (priv->auto_drag_up) | |
933 priv->auto_drag_up = FALSE; | |
934 | |
935 if (nr >= pl->num_visible) { | |
936 nr = pl->num_visible - 1; | |
937 if (!priv->auto_drag_down) { | |
938 priv->auto_drag_down = TRUE; | |
939 priv->auto_drag_down_tag = | |
940 g_timeout_add(100, ui_skinned_playlist_auto_drag_down_func, pl); | |
941 } | |
942 } | |
943 else if (priv->auto_drag_down) | |
944 priv->auto_drag_down = FALSE; | |
945 | |
946 off = nr - priv->drag_pos; | |
947 if (off) { | |
948 for (i = 0; i < abs(off); i++) { | |
949 if (off < 0) | |
950 ui_skinned_playlist_move_up(pl); | |
951 else | |
952 ui_skinned_playlist_move_down(pl); | |
953 | |
954 } | |
955 playlistwin_update_list(aud_playlist_get_active()); | |
956 } | |
957 priv->drag_pos = nr; | |
2642 | 958 } else if (config.show_filepopup_for_tuple) { |
2620 | 959 gint pos = ui_skinned_playlist_get_position(widget, event->x, event->y); |
3030
c442f8407dcb
Show playlist popup information reliably (Debian bug #460802)
John Lindgren <john.lindgren@tds.net>
parents:
2971
diff
changeset
|
960 if (pos == -1) { |
c442f8407dcb
Show playlist popup information reliably (Debian bug #460802)
John Lindgren <john.lindgren@tds.net>
parents:
2971
diff
changeset
|
961 ui_skinned_playlist_popup_hide (widget); |
c442f8407dcb
Show playlist popup information reliably (Debian bug #460802)
John Lindgren <john.lindgren@tds.net>
parents:
2971
diff
changeset
|
962 ui_skinned_playlist_popup_timer_stop (widget); |
3031 | 963 } else if (GPOINTER_TO_INT(g_object_get_data (G_OBJECT(widget), "popup_active") == 0) || |
964 pos != GPOINTER_TO_INT(g_object_get_data (G_OBJECT(widget), "popup_position"))) { | |
3030
c442f8407dcb
Show playlist popup information reliably (Debian bug #460802)
John Lindgren <john.lindgren@tds.net>
parents:
2971
diff
changeset
|
965 ui_skinned_playlist_popup_hide (widget); |
c442f8407dcb
Show playlist popup information reliably (Debian bug #460802)
John Lindgren <john.lindgren@tds.net>
parents:
2971
diff
changeset
|
966 ui_skinned_playlist_popup_timer_stop (widget); |
3031 | 967 g_object_set_data (G_OBJECT(widget), "popup_position", GINT_TO_POINTER(pos)); |
3030
c442f8407dcb
Show playlist popup information reliably (Debian bug #460802)
John Lindgren <john.lindgren@tds.net>
parents:
2971
diff
changeset
|
968 ui_skinned_playlist_popup_timer_start (widget); |
2620 | 969 } |
970 } | |
971 | |
972 return TRUE; | |
973 } | |
974 | |
975 static gboolean ui_skinned_playlist_leave_notify(GtkWidget *widget, GdkEventCrossing *event) { | |
976 ui_skinned_playlist_popup_hide(widget); | |
977 ui_skinned_playlist_popup_timer_stop(widget); | |
978 | |
979 return FALSE; | |
980 } | |
981 | |
982 void ui_skinned_playlist_set_font(const gchar * font) { | |
983 /* Welcome to bad hack central 2k3 */ | |
984 gchar *font_lower; | |
985 gint width_temp; | |
986 gint width_temp_0; | |
987 | |
988 playlist_list_font = pango_font_description_from_string(font); | |
989 | |
990 text_get_extents(font, | |
991 "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz ", | |
992 &width_approx_letters, NULL, &ascent, &descent); | |
993 | |
994 width_approx_letters = (width_approx_letters / 53); | |
995 | |
996 /* Experimental: We don't weigh the 1 into total because it's width is almost always | |
997 * very different from the rest | |
998 */ | |
999 text_get_extents(font, "023456789", &width_approx_digits, NULL, NULL, | |
1000 NULL); | |
1001 width_approx_digits = (width_approx_digits / 9); | |
1002 | |
1003 /* Precache some often used calculations */ | |
1004 width_approx_digits_half = width_approx_digits / 2; | |
1005 | |
1006 /* FIXME: We assume that any other number is broader than the "1" */ | |
1007 text_get_extents(font, "1", &width_temp, NULL, NULL, NULL); | |
1008 text_get_extents(font, "2", &width_temp_0, NULL, NULL, NULL); | |
1009 | |
1010 if (abs(width_temp_0 - width_temp) < 2) { | |
1011 width_delta_digit_one = 0; | |
1012 } | |
1013 else { | |
1014 width_delta_digit_one = ((width_temp_0 - width_temp) / 2) + 2; | |
1015 } | |
1016 | |
1017 text_get_extents(font, ":", &width_colon, NULL, NULL, NULL); | |
1018 width_colon_third = width_colon / 4; | |
1019 | |
1020 font_lower = g_utf8_strdown(font, strlen(font)); | |
1021 /* This doesn't take any i18n into account, but i think there is none with TTF fonts | |
1022 * FIXME: This can probably be retrieved trough Pango too | |
1023 */ | |
1024 has_slant = g_strstr_len(font_lower, strlen(font_lower), "oblique") | |
1025 || g_strstr_len(font_lower, strlen(font_lower), "italic"); | |
1026 | |
1027 g_free(font_lower); | |
1028 } | |
1029 | |
1030 void ui_skinned_playlist_resize_relative(GtkWidget *widget, gint w, gint h) { | |
1031 UiSkinnedPlaylistPrivate *priv = UI_SKINNED_PLAYLIST_GET_PRIVATE(widget); | |
1032 priv->resize_width += w; | |
1033 priv->resize_height += h; | |
2698
32e99af83a3e
I don't think redraw signal is needed anymore
Tomasz Mon <desowin@gmail.com>
parents:
2657
diff
changeset
|
1034 gtk_widget_set_size_request(widget, priv->width+priv->resize_width, priv->height+priv->resize_height); |
2620 | 1035 } |
1036 | |
1037 static gboolean ui_skinned_playlist_popup_show(gpointer data) { | |
1038 GtkWidget *widget = data; | |
1039 gint pos = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "popup_position")); | |
1040 | |
1041 if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "timer_active")) == 1 && pos != -1) { | |
1042 Tuple *tuple; | |
1043 Playlist *pl_active = aud_playlist_get_active(); | |
1044 GtkWidget *popup = g_object_get_data(G_OBJECT(widget), "popup"); | |
1045 | |
2638 | 1046 tuple = aud_playlist_get_tuple(pl_active, pos); |
1047 if ((tuple == NULL) || (aud_tuple_get_int(tuple, FIELD_LENGTH, NULL) < 1)) { | |
2629
2ce9e17525dc
make dnd working in playlistwin
Tomasz Mon <desowin@gmail.com>
parents:
2620
diff
changeset
|
1048 gchar *title = aud_playlist_get_songtitle(pl_active, pos); |
2638 | 1049 audacious_fileinfopopup_show_from_title(popup, title); |
2620 | 1050 g_free(title); |
1051 } else { | |
2638 | 1052 audacious_fileinfopopup_show_from_tuple(popup , tuple); |
2620 | 1053 } |
1054 g_object_set_data(G_OBJECT(widget), "popup_active" , GINT_TO_POINTER(1)); | |
1055 } | |
1056 | |
1057 ui_skinned_playlist_popup_timer_stop(widget); | |
1058 return FALSE; | |
1059 } | |
1060 | |
1061 static void ui_skinned_playlist_popup_hide(GtkWidget *widget) { | |
1062 if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "popup_active")) == 1) { | |
1063 GtkWidget *popup = g_object_get_data(G_OBJECT(widget), "popup"); | |
1064 g_object_set_data(G_OBJECT(widget), "popup_active", GINT_TO_POINTER(0)); | |
2638 | 1065 audacious_fileinfopopup_hide(popup, NULL); |
2620 | 1066 } |
1067 } | |
1068 | |
1069 static void ui_skinned_playlist_popup_timer_start(GtkWidget *widget) { | |
2642 | 1070 gint timer_id = g_timeout_add(config.filepopup_delay*100, ui_skinned_playlist_popup_show, widget); |
2620 | 1071 g_object_set_data(G_OBJECT(widget), "timer_id", GINT_TO_POINTER(timer_id)); |
1072 g_object_set_data(G_OBJECT(widget), "timer_active", GINT_TO_POINTER(1)); | |
1073 } | |
1074 | |
1075 static void ui_skinned_playlist_popup_timer_stop(GtkWidget *widget) { | |
1076 if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "timer_active")) == 1) | |
1077 g_source_remove(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "timer_id"))); | |
1078 | |
1079 g_object_set_data(G_OBJECT(widget), "timer_id", GINT_TO_POINTER(0)); | |
1080 g_object_set_data(G_OBJECT(widget), "timer_active", GINT_TO_POINTER(0)); | |
1081 } |