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