Mercurial > audlegacy
annotate audacious/playlist_list.c @ 1047:91f6db060a8b trunk
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
author | nenolod |
---|---|
date | Sun, 14 May 2006 13:35:06 -0700 |
parents | ff0cc786ebeb |
children | b10e09537428 |
rev | line source |
---|---|
0 | 1 /* BMP - Cross-platform multimedia player |
2 * Copyright (C) 2003-2004 BMP development team. | |
3 * | |
4 * Based on XMMS: | |
5 * Copyright (C) 1998-2003 XMMS development team. | |
6 * | |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
20 */ | |
21 | |
22 /* | |
23 * A note about Pango and some funky spacey fonts: Weirdly baselined | |
24 * fonts, or fonts with weird ascents or descents _will_ display a | |
25 * little bit weird in the playlist widget, but the display engine | |
26 * won't make it look too bad, just a little deranged. I honestly | |
27 * don't think it's worth fixing (around...), it doesn't have to be | |
28 * perfectly fitting, just the general look has to be ok, which it | |
29 * IMHO is. | |
30 * | |
31 * A second note: The numbers aren't perfectly aligned, but in the | |
32 * end it looks better when using a single Pango layout for each | |
33 * number. | |
34 */ | |
35 | |
36 #include "playlist_list.h" | |
37 | |
38 #include <stdlib.h> | |
39 #include <string.h> | |
40 | |
41 #include "main.h" | |
42 #include "input.h" | |
538
e4e897d20791
[svn] remove libaudcore, we never did anything with it
nenolod
parents:
512
diff
changeset
|
43 #include "playback.h" |
0 | 44 #include "playlist.h" |
383 | 45 #include "ui_playlist.h" |
0 | 46 #include "util.h" |
47 | |
48 #include "debug.h" | |
49 | |
50 static PangoFontDescription *playlist_list_font = NULL; | |
51 static gint ascent, descent, width_delta_digit_one; | |
52 static gboolean has_slant; | |
53 static guint padding; | |
54 | |
55 /* FIXME: the following globals should not be needed. */ | |
56 static gint width_approx_letters; | |
57 static gint width_colon, width_colon_third; | |
58 static gint width_approx_digits, width_approx_digits_half; | |
59 | |
1047
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
60 #ifdef GDK_WINDOWING_X11 |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
61 |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
62 #include <gdk/gdkx.h> |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
63 #include <X11/Xlib.h> |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
64 #include <X11/Xatom.h> |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
65 |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
66 static GdkPixmap *get_transparency_pixmap(void) |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
67 { |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
68 Atom prop, type; |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
69 int format; |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
70 unsigned long length, after; |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
71 unsigned char *data; |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
72 static GdkPixmap *retval = NULL; |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
73 |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
74 if(retval) |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
75 return retval; |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
76 |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
77 prop = XInternAtom(GDK_DISPLAY(), "_XROOTPMAP_ID", True); |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
78 |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
79 if(prop == None) |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
80 return NULL; |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
81 |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
82 XGetWindowProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(), prop, 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data); |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
83 |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
84 if(type == XA_PIXMAP) |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
85 retval = gdk_pixmap_foreign_new(*((Pixmap *)data)); |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
86 |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
87 return retval; |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
88 } |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
89 |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
90 #else |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
91 |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
92 static GdkPixmap *get_transparency_pixmap(void) |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
93 { |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
94 return NULL; |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
95 } |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
96 |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
97 #endif |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
98 |
0 | 99 static gboolean |
100 playlist_list_auto_drag_down_func(gpointer data) | |
101 { | |
102 PlayList_List *pl = data; | |
103 | |
104 if (pl->pl_auto_drag_down) { | |
105 playlist_list_move_down(pl); | |
106 pl->pl_first++; | |
107 playlistwin_update_list(); | |
108 return TRUE; | |
109 } | |
110 return FALSE; | |
111 } | |
112 | |
113 static gboolean | |
114 playlist_list_auto_drag_up_func(gpointer data) | |
115 { | |
116 PlayList_List *pl = data; | |
117 | |
118 if (pl->pl_auto_drag_up) { | |
119 playlist_list_move_up(pl); | |
120 pl->pl_first--; | |
121 playlistwin_update_list(); | |
122 return TRUE; | |
123 | |
124 } | |
125 return FALSE; | |
126 } | |
127 | |
128 void | |
129 playlist_list_move_up(PlayList_List * pl) | |
130 { | |
131 GList *list; | |
132 | |
133 PLAYLIST_LOCK(); | |
134 if ((list = playlist_get()) == NULL) { | |
135 PLAYLIST_UNLOCK(); | |
136 return; | |
137 } | |
138 if (PLAYLIST_ENTRY(list->data)->selected) { | |
139 /* We are at the top */ | |
140 PLAYLIST_UNLOCK(); | |
141 return; | |
142 } | |
143 while (list) { | |
144 if (PLAYLIST_ENTRY(list->data)->selected) | |
145 glist_moveup(list); | |
146 list = g_list_next(list); | |
147 } | |
148 PLAYLIST_UNLOCK(); | |
149 if (pl->pl_prev_selected != -1) | |
150 pl->pl_prev_selected--; | |
151 if (pl->pl_prev_min != -1) | |
152 pl->pl_prev_min--; | |
153 if (pl->pl_prev_max != -1) | |
154 pl->pl_prev_max--; | |
155 } | |
156 | |
157 void | |
158 playlist_list_move_down(PlayList_List * pl) | |
159 { | |
160 GList *list; | |
161 | |
162 PLAYLIST_LOCK(); | |
163 | |
164 if (!(list = g_list_last(playlist_get()))) { | |
165 PLAYLIST_UNLOCK(); | |
166 return; | |
167 } | |
168 | |
169 if (PLAYLIST_ENTRY(list->data)->selected) { | |
170 /* We are at the bottom */ | |
171 PLAYLIST_UNLOCK(); | |
172 return; | |
173 } | |
174 | |
175 while (list) { | |
176 if (PLAYLIST_ENTRY(list->data)->selected) | |
177 glist_movedown(list); | |
178 list = g_list_previous(list); | |
179 } | |
180 | |
181 PLAYLIST_UNLOCK(); | |
182 | |
183 if (pl->pl_prev_selected != -1) | |
184 pl->pl_prev_selected++; | |
185 if (pl->pl_prev_min != -1) | |
186 pl->pl_prev_min++; | |
187 if (pl->pl_prev_max != -1) | |
188 pl->pl_prev_max++; | |
189 } | |
190 | |
191 static void | |
192 playlist_list_button_press_cb(GtkWidget * widget, | |
193 GdkEventButton * event, | |
194 PlayList_List * pl) | |
195 { | |
196 gint nr, y; | |
197 | |
198 if (event->button == 1 && pl->pl_fheight && | |
199 widget_contains(&pl->pl_widget, event->x, event->y)) { | |
200 | |
201 y = event->y - pl->pl_widget.y; | |
202 nr = (y / pl->pl_fheight) + pl->pl_first; | |
203 | |
204 if (nr >= playlist_get_length()) | |
205 nr = playlist_get_length() - 1; | |
206 | |
207 if (!(event->state & GDK_CONTROL_MASK)) | |
208 playlist_select_all(FALSE); | |
209 | |
210 if (event->state & GDK_SHIFT_MASK && pl->pl_prev_selected != -1) { | |
211 playlist_select_range(pl->pl_prev_selected, nr, TRUE); | |
212 pl->pl_prev_min = pl->pl_prev_selected; | |
213 pl->pl_prev_max = nr; | |
214 pl->pl_drag_pos = nr - pl->pl_first; | |
215 } | |
216 else { | |
217 if (playlist_select_invert(nr)) { | |
218 if (event->state & GDK_CONTROL_MASK) { | |
219 if (pl->pl_prev_min == -1) { | |
220 pl->pl_prev_min = pl->pl_prev_selected; | |
221 pl->pl_prev_max = pl->pl_prev_selected; | |
222 } | |
223 if (nr < pl->pl_prev_min) | |
224 pl->pl_prev_min = nr; | |
225 else if (nr > pl->pl_prev_max) | |
226 pl->pl_prev_max = nr; | |
227 } | |
228 else | |
229 pl->pl_prev_min = -1; | |
230 pl->pl_prev_selected = nr; | |
231 pl->pl_drag_pos = nr - pl->pl_first; | |
232 } | |
233 } | |
234 if (event->type == GDK_2BUTTON_PRESS) { | |
235 /* | |
236 * Ungrab the pointer to prevent us from | |
237 * hanging on to it during the sometimes slow | |
238 * bmp_playback_initiate(). | |
239 */ | |
240 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
241 gdk_flush(); | |
242 playlist_set_position(nr); | |
243 if (!bmp_playback_get_playing()) | |
244 bmp_playback_initiate(); | |
245 } | |
246 | |
247 pl->pl_dragging = TRUE; | |
248 playlistwin_update_list(); | |
249 } | |
250 } | |
251 | |
252 gint | |
253 playlist_list_get_playlist_position(PlayList_List * pl, | |
254 gint x, | |
255 gint y) | |
256 { | |
257 gint iy, length; | |
258 | |
259 if (!widget_contains(WIDGET(pl), x, y) || !pl->pl_fheight) | |
260 return -1; | |
261 | |
262 if ((length = playlist_get_length()) == 0) | |
263 return -1; | |
264 iy = y - pl->pl_widget.y; | |
265 | |
266 return (MIN((iy / pl->pl_fheight) + pl->pl_first, length - 1)); | |
267 } | |
268 | |
269 static void | |
270 playlist_list_motion_cb(GtkWidget * widget, | |
271 GdkEventMotion * event, | |
272 PlayList_List * pl) | |
273 { | |
274 gint nr, y, off, i; | |
275 | |
276 if (pl->pl_dragging) { | |
277 y = event->y - pl->pl_widget.y; | |
278 nr = (y / pl->pl_fheight); | |
279 if (nr < 0) { | |
280 nr = 0; | |
281 if (!pl->pl_auto_drag_up) { | |
282 pl->pl_auto_drag_up = TRUE; | |
283 pl->pl_auto_drag_up_tag = | |
284 gtk_timeout_add(100, playlist_list_auto_drag_up_func, pl); | |
285 } | |
286 } | |
287 else if (pl->pl_auto_drag_up) | |
288 pl->pl_auto_drag_up = FALSE; | |
289 | |
290 if (nr >= pl->pl_num_visible) { | |
291 nr = pl->pl_num_visible - 1; | |
292 if (!pl->pl_auto_drag_down) { | |
293 pl->pl_auto_drag_down = TRUE; | |
294 pl->pl_auto_drag_down_tag = | |
295 gtk_timeout_add(100, playlist_list_auto_drag_down_func, | |
296 pl); | |
297 } | |
298 } | |
299 else if (pl->pl_auto_drag_down) | |
300 pl->pl_auto_drag_down = FALSE; | |
301 | |
302 off = nr - pl->pl_drag_pos; | |
303 if (off) { | |
304 for (i = 0; i < abs(off); i++) { | |
305 if (off < 0) | |
306 playlist_list_move_up(pl); | |
307 else | |
308 playlist_list_move_down(pl); | |
309 | |
310 } | |
311 playlistwin_update_list(); | |
312 } | |
313 pl->pl_drag_pos = nr; | |
314 } | |
315 } | |
316 | |
317 static void | |
318 playlist_list_button_release_cb(GtkWidget * widget, | |
319 GdkEventButton * event, | |
320 PlayList_List * pl) | |
321 { | |
322 pl->pl_dragging = FALSE; | |
323 pl->pl_auto_drag_down = FALSE; | |
324 pl->pl_auto_drag_up = FALSE; | |
325 } | |
326 | |
327 static void | |
328 playlist_list_draw_string(PlayList_List * pl, | |
329 PangoFontDescription * font, | |
330 gint line, | |
331 gint width, | |
332 const gchar * text, | |
333 guint ppos) | |
334 { | |
324
fbafca56b6a8
[svn] playlist window truncation fixes provided by external contributor: Tim Yamin <plasmaroo -at- gentoo.org>.
nenolod
parents:
284
diff
changeset
|
335 guint plist_length_int; |
0 | 336 |
337 PangoLayout *layout; | |
338 | |
339 REQUIRE_STATIC_LOCK(playlist); | |
340 | |
341 if (cfg.show_numbers_in_pl) { | |
342 gchar *pos_string = g_strdup_printf("%d", ppos); | |
343 plist_length_int = | |
344 gint_count_digits(playlist_get_length_nolock()) + 1; | |
345 | |
346 padding = plist_length_int; | |
347 padding = ((padding + 1) * width_approx_digits); | |
348 | |
349 layout = gtk_widget_create_pango_layout(playlistwin, pos_string); | |
350 pango_layout_set_font_description(layout, playlist_list_font); | |
351 pango_layout_set_width(layout, plist_length_int * 100); | |
352 | |
353 pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT); | |
354 gdk_draw_layout(pl->pl_widget.parent, pl->pl_widget.gc, | |
355 pl->pl_widget.x + | |
356 (width_approx_digits * | |
357 (-1 + plist_length_int - strlen(pos_string))) + | |
358 (width_approx_digits / 4), | |
359 pl->pl_widget.y + (line - 1) * pl->pl_fheight + | |
360 ascent + abs(descent), layout); | |
361 g_free(pos_string); | |
362 g_object_unref(layout); | |
363 } | |
364 else { | |
365 padding = 3; | |
366 } | |
367 | |
324
fbafca56b6a8
[svn] playlist window truncation fixes provided by external contributor: Tim Yamin <plasmaroo -at- gentoo.org>.
nenolod
parents:
284
diff
changeset
|
368 width -= padding; |
fbafca56b6a8
[svn] playlist window truncation fixes provided by external contributor: Tim Yamin <plasmaroo -at- gentoo.org>.
nenolod
parents:
284
diff
changeset
|
369 |
326 | 370 layout = gtk_widget_create_pango_layout(playlistwin, text); |
0 | 371 |
372 pango_layout_set_font_description(layout, playlist_list_font); | |
326 | 373 pango_layout_set_width(layout, width * PANGO_SCALE); |
374 pango_layout_set_single_paragraph_mode(layout, TRUE); | |
375 pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END); | |
0 | 376 gdk_draw_layout(pl->pl_widget.parent, pl->pl_widget.gc, |
377 pl->pl_widget.x + padding + (width_approx_letters / 4), | |
378 pl->pl_widget.y + (line - 1) * pl->pl_fheight + | |
379 ascent + abs(descent), layout); | |
380 | |
381 g_object_unref(layout); | |
382 } | |
383 | |
384 void | |
385 playlist_list_draw(Widget * w) | |
386 { | |
387 PlayList_List *pl = PLAYLIST_LIST(w); | |
388 GList *list; | |
389 GdkGC *gc; | |
390 GdkPixmap *obj; | |
391 PangoLayout *layout; | |
392 gchar *title; | |
393 gint width, height; | |
394 gint i, max_first; | |
395 guint padding, padding_dwidth, padding_plength; | |
396 guint max_time_len = 0; | |
958 | 397 gfloat queue_tailpadding = 0; |
701
d539e5c5f730
[svn] Fixes of the remaining GCC 4.1 warnings from external contributor Diego "Flameeyes" Petteno (Gentoo).
chainsaw
parents:
625
diff
changeset
|
398 gint tpadding; |
d539e5c5f730
[svn] Fixes of the remaining GCC 4.1 warnings from external contributor Diego "Flameeyes" Petteno (Gentoo).
chainsaw
parents:
625
diff
changeset
|
399 gsize tpadding_dwidth = 0; |
828
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
400 gint x, y; |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
401 guint tail_width; |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
402 guint tail_len; |
0 | 403 |
404 gchar tail[100]; | |
782
4c7ee8f64d9b
[svn] untag a critical fixme as it was actually deadchip smoking some craq
nenolod
parents:
736
diff
changeset
|
405 gchar queuepos[255]; |
0 | 406 gchar length[40]; |
407 | |
408 gchar **frags; | |
409 gchar *frag0; | |
410 | |
411 gint plw_w, plw_h; | |
412 | |
413 GdkRectangle *playlist_rect; | |
414 | |
415 gc = pl->pl_widget.gc; | |
416 | |
417 width = pl->pl_widget.width; | |
418 height = pl->pl_widget.height; | |
419 | |
420 obj = pl->pl_widget.parent; | |
421 | |
422 gtk_window_get_size(GTK_WINDOW(playlistwin), &plw_w, &plw_h); | |
423 | |
424 playlist_rect = g_new0(GdkRectangle, 1); | |
425 | |
426 playlist_rect->x = 0; | |
427 playlist_rect->y = 0; | |
428 playlist_rect->width = plw_w - 17; | |
429 playlist_rect->height = plw_h - 36; | |
430 | |
431 gdk_gc_set_clip_origin(gc, 31, 58); | |
432 gdk_gc_set_clip_rectangle(gc, playlist_rect); | |
1047
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
433 |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
434 if (cfg.playlist_transparent == FALSE) |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
435 { |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
436 gdk_gc_set_foreground(gc, |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
437 skin_get_color(bmp_active_skin, |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
438 SKIN_PLEDIT_NORMALBG)); |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
439 gdk_draw_rectangle(obj, gc, TRUE, pl->pl_widget.x, pl->pl_widget.y, |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
440 width, height); |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
441 } |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
442 else |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
443 { |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
444 GdkPixmap *rootpix = get_transparency_pixmap(); |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
445 gdk_draw_pixmap(obj, gc, rootpix, cfg.playlist_x + pl->pl_widget.x, |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
446 cfg.playlist_y + pl->pl_widget.y, pl->pl_widget.x, pl->pl_widget.y, |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
447 width, height); |
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
958
diff
changeset
|
448 } |
0 | 449 |
450 if (!playlist_list_font) { | |
451 g_critical("Couldn't open playlist font"); | |
452 return; | |
453 } | |
454 | |
455 pl->pl_fheight = (ascent + abs(descent)); | |
456 pl->pl_num_visible = height / pl->pl_fheight; | |
457 | |
458 max_first = playlist_get_length() - pl->pl_num_visible; | |
459 max_first = MAX(max_first, 0); | |
460 | |
461 pl->pl_first = CLAMP(pl->pl_first, 0, max_first); | |
462 | |
463 PLAYLIST_LOCK(); | |
464 list = playlist_get(); | |
610
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
465 list = g_list_nth(list, pl->pl_first); |
0 | 466 |
610
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
467 /* It sucks having to run the iteration twice but this is the only |
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
468 way you can reliably get the maximum width so we can get our |
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
469 playlist nice and aligned... -- plasmaroo */ |
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
470 |
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
471 for (i = pl->pl_first; |
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
472 list && i < pl->pl_first + pl->pl_num_visible; |
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
473 list = g_list_next(list), i++) { |
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
474 PlaylistEntry *entry = list->data; |
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
475 |
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
476 if (entry->length != -1) |
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
477 { |
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
478 g_snprintf(length, sizeof(length), "%d:%-2.2d", |
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
479 entry->length / 60000, (entry->length / 1000) % 60); |
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
480 tpadding_dwidth = MAX(tpadding_dwidth, strlen(length)); |
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
481 } |
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
482 } |
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
483 |
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
484 /* Reset */ |
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
485 list = playlist_get(); |
d056380ea0b3
[svn] playlist_list widget improvements via plasmaroo
nenolod
parents:
538
diff
changeset
|
486 list = g_list_nth(list, pl->pl_first); |
0 | 487 |
488 for (i = pl->pl_first; | |
489 list && i < pl->pl_first + pl->pl_num_visible; | |
490 list = g_list_next(list), i++) { | |
491 gint pos; | |
492 PlaylistEntry *entry = list->data; | |
493 | |
494 if (entry->selected) { | |
495 gdk_gc_set_foreground(gc, | |
496 skin_get_color(bmp_active_skin, | |
497 SKIN_PLEDIT_SELECTEDBG)); | |
498 gdk_draw_rectangle(obj, gc, TRUE, pl->pl_widget.x, | |
499 pl->pl_widget.y + | |
500 ((i - pl->pl_first) * pl->pl_fheight), | |
501 width, pl->pl_fheight); | |
502 } | |
503 | |
504 /* FIXME: entry->title should NEVER be NULL, and there should | |
505 NEVER be a need to do a UTF-8 conversion. Playlist title | |
506 strings should be kept properly. */ | |
507 | |
508 if (!entry->title) { | |
509 gchar *basename = g_path_get_basename(entry->filename); | |
510 title = filename_to_utf8(basename); | |
511 g_free(basename); | |
512 } | |
513 else | |
514 title = str_to_utf8(entry->title); | |
515 | |
516 pos = playlist_get_queue_position(entry); | |
517 | |
518 tail[0] = 0; | |
519 queuepos[0] = 0; | |
520 length[0] = 0; | |
521 | |
522 if (pos != -1) | |
523 g_snprintf(queuepos, sizeof(queuepos), "%d", pos + 1); | |
524 | |
525 if (entry->length != -1) | |
506
4d3b74821345
[svn] Add a line between the time and the track name.
nenolod
parents:
460
diff
changeset
|
526 { |
0 | 527 g_snprintf(length, sizeof(length), "%d:%-2.2d", |
528 entry->length / 60000, (entry->length / 1000) % 60); | |
506
4d3b74821345
[svn] Add a line between the time and the track name.
nenolod
parents:
460
diff
changeset
|
529 } |
0 | 530 |
828
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
531 strncat(tail, length, sizeof(tail)); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
532 tail_len = strlen(tail); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
533 |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
534 max_time_len = MAX(max_time_len, tail_len); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
535 |
958 | 536 if (pos != -1 && tpadding_dwidth <= 0) |
537 tail_width = width - (width_approx_digits * (strlen(queuepos) + 2.25)); | |
538 else if (pos != -1) | |
828
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
539 tail_width = width - (width_approx_digits * (tpadding_dwidth + strlen(queuepos) + 4)); |
958 | 540 else if (tpadding_dwidth > 0) |
541 tail_width = width - (width_approx_digits * (tpadding_dwidth + 2.5)); | |
828
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
542 else |
958 | 543 tail_width = width; |
0 | 544 |
828
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
545 if (i == playlist_get_position_nolock()) |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
546 gdk_gc_set_foreground(gc, |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
547 skin_get_color(bmp_active_skin, |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
548 SKIN_PLEDIT_CURRENT)); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
549 else |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
550 gdk_gc_set_foreground(gc, |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
551 skin_get_color(bmp_active_skin, |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
552 SKIN_PLEDIT_NORMAL)); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
553 playlist_list_draw_string(pl, playlist_list_font, |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
554 i - pl->pl_first, tail_width, title, |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
555 i + 1); |
0 | 556 |
828
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
557 x = pl->pl_widget.x + width - width_approx_digits * 2; |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
558 y = pl->pl_widget.y + ((i - pl->pl_first) - |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
559 1) * pl->pl_fheight + ascent; |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
560 |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
561 frags = NULL; |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
562 frag0 = NULL; |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
563 |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
564 if ((strlen(tail) > 0) && (tail != NULL)) { |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
565 frags = g_strsplit(tail, ":", 0); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
566 frag0 = g_strconcat(frags[0], ":", NULL); |
0 | 567 |
828
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
568 layout = gtk_widget_create_pango_layout(playlistwin, frags[1]); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
569 pango_layout_set_font_description(layout, playlist_list_font); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
570 pango_layout_set_width(layout, tail_len * 100); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
571 pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
572 gdk_draw_layout(obj, gc, x - (0.5 * width_approx_digits), |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
573 y + abs(descent), layout); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
574 g_object_unref(layout); |
0 | 575 |
828
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
576 layout = gtk_widget_create_pango_layout(playlistwin, frag0); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
577 pango_layout_set_font_description(layout, playlist_list_font); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
578 pango_layout_set_width(layout, tail_len * 100); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
579 pango_layout_set_alignment(layout, PANGO_ALIGN_RIGHT); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
580 gdk_draw_layout(obj, gc, x - (0.75 * width_approx_digits), |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
581 y + abs(descent), layout); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
582 g_object_unref(layout); |
0 | 583 |
828
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
584 g_free(frag0); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
585 g_strfreev(frags); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
586 } |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
587 |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
588 if (pos != -1) { |
0 | 589 |
828
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
590 /* DON'T remove the commented code yet please -- Milosz */ |
0 | 591 |
958 | 592 if (tpadding_dwidth > 0) |
593 queue_tailpadding = tpadding_dwidth + 1; | |
594 else | |
595 queue_tailpadding = -0.75; | |
0 | 596 |
828
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
597 gdk_draw_rectangle(obj, gc, FALSE, |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
598 x - |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
599 (((queue_tailpadding + |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
600 strlen(queuepos)) * |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
601 width_approx_digits) + |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
602 (width_approx_digits / 4)), |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
603 y + abs(descent), |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
604 (strlen(queuepos)) * |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
605 width_approx_digits + |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
606 (width_approx_digits / 2), |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
607 pl->pl_fheight - 2); |
0 | 608 |
828
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
609 layout = |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
610 gtk_widget_create_pango_layout(playlistwin, queuepos); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
611 pango_layout_set_font_description(layout, playlist_list_font); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
612 pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); |
0 | 613 |
828
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
614 gdk_draw_layout(obj, gc, |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
615 x - |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
616 ((queue_tailpadding + |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
617 strlen(queuepos)) * width_approx_digits) + |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
618 (width_approx_digits / 4), |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
619 y + abs(descent), layout); |
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
620 g_object_unref(layout); |
0 | 621 } |
622 | |
623 g_free(title); | |
624 } | |
625 | |
626 | |
627 /* | |
628 * Drop target hovering over the playlist, so draw some hint where the | |
629 * drop will occur. | |
630 * | |
631 * This is (currently? unfixably?) broken when dragging files from Qt/KDE apps, | |
632 * probably due to DnD signaling problems (actually i have no clue). | |
633 * | |
634 */ | |
635 | |
636 if (pl->pl_drag_motion) { | |
625
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
610
diff
changeset
|
637 guint pos, plength, lpadding; |
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
610
diff
changeset
|
638 gint x, y, plx, ply; |
0 | 639 |
640 if (cfg.show_numbers_in_pl) { | |
641 lpadding = gint_count_digits(playlist_get_length_nolock()) + 1; | |
642 lpadding = ((lpadding + 1) * width_approx_digits); | |
643 } | |
644 else { | |
645 lpadding = 3; | |
646 }; | |
647 | |
648 /* We already hold the mutex and have the playlist locked, so call | |
649 the non-locking function. */ | |
650 plength = playlist_get_length_nolock(); | |
651 | |
652 x = pl->drag_motion_x; | |
653 y = pl->drag_motion_y; | |
654 | |
655 plx = pl->pl_widget.x; | |
656 ply = pl->pl_widget.y; | |
657 | |
658 if ((x > pl->pl_widget.x) && !(x > pl->pl_widget.width)) { | |
659 | |
660 if ((y > pl->pl_widget.y) | |
661 && !(y > (pl->pl_widget.height + ply))) { | |
662 | |
663 pos = ((y - ((Widget *) pl)->y) / pl->pl_fheight) + | |
664 pl->pl_first; | |
665 | |
666 if (pos > (plength)) { | |
667 pos = plength; | |
668 } | |
669 | |
670 gdk_gc_set_foreground(gc, | |
671 skin_get_color(bmp_active_skin, | |
672 SKIN_PLEDIT_CURRENT)); | |
673 | |
674 gdk_draw_line(obj, gc, pl->pl_widget.x, | |
735 | 675 pl->pl_widget.y + ((pos - pl->pl_first) * pl->pl_fheight), |
0 | 676 pl->pl_widget.width + pl->pl_widget.x - 1, |
677 pl->pl_widget.y + | |
678 ((pos - pl->pl_first) * pl->pl_fheight)); | |
679 } | |
680 | |
681 } | |
682 | |
683 /* When dropping on the borders of the playlist, outside the text area, | |
684 * files get appended at the end of the list. Show that too. | |
685 */ | |
686 | |
687 if ((y < ply) || (y > pl->pl_widget.height + ply)) { | |
688 if ((y >= 0) || (y <= (pl->pl_widget.height + ply))) { | |
689 pos = plength; | |
690 gdk_gc_set_foreground(gc, | |
691 skin_get_color(bmp_active_skin, | |
692 SKIN_PLEDIT_CURRENT)); | |
693 | |
694 gdk_draw_line(obj, gc, pl->pl_widget.x, | |
736 | 695 pl->pl_widget.y + |
696 ((pos - pl->pl_first) * pl->pl_fheight), | |
0 | 697 pl->pl_widget.width + pl->pl_widget.x - 1, |
698 pl->pl_widget.y + | |
699 ((pos - pl->pl_first) * pl->pl_fheight)); | |
700 | |
701 } | |
702 } | |
703 } | |
704 | |
705 gdk_gc_set_foreground(gc, | |
706 skin_get_color(bmp_active_skin, | |
707 SKIN_PLEDIT_NORMAL)); | |
708 | |
709 if (cfg.show_numbers_in_pl) { | |
710 | |
711 padding_plength = playlist_get_length_nolock(); | |
712 | |
713 if (padding_plength == 0) { | |
714 padding_dwidth = 0; | |
715 } | |
716 else { | |
717 padding_dwidth = gint_count_digits(playlist_get_length_nolock()); | |
718 } | |
719 | |
720 padding = | |
721 (padding_dwidth * | |
722 width_approx_digits) + width_approx_digits; | |
723 | |
724 | |
725 /* For italic or oblique fonts we add another half of the | |
726 * approximate width */ | |
727 if (has_slant) | |
728 padding += width_approx_digits_half; | |
729 | |
730 gdk_draw_line(obj, gc, | |
731 pl->pl_widget.x + padding, | |
732 pl->pl_widget.y, | |
733 pl->pl_widget.x + padding, | |
958 | 734 pl->pl_widget.y + pl->pl_widget.height - 1); |
0 | 735 } |
736 | |
506
4d3b74821345
[svn] Add a line between the time and the track name.
nenolod
parents:
460
diff
changeset
|
737 if (tpadding_dwidth != 0) |
4d3b74821345
[svn] Add a line between the time and the track name.
nenolod
parents:
460
diff
changeset
|
738 { |
828
45ec63505a4e
[svn] - improvements to the playlist list control, via nhjm
nenolod
parents:
813
diff
changeset
|
739 tpadding = (tpadding_dwidth * width_approx_digits) + (width_approx_digits * 1.5); |
506
4d3b74821345
[svn] Add a line between the time and the track name.
nenolod
parents:
460
diff
changeset
|
740 |
4d3b74821345
[svn] Add a line between the time and the track name.
nenolod
parents:
460
diff
changeset
|
741 if (has_slant) |
4d3b74821345
[svn] Add a line between the time and the track name.
nenolod
parents:
460
diff
changeset
|
742 tpadding += width_approx_digits_half; |
4d3b74821345
[svn] Add a line between the time and the track name.
nenolod
parents:
460
diff
changeset
|
743 |
4d3b74821345
[svn] Add a line between the time and the track name.
nenolod
parents:
460
diff
changeset
|
744 gdk_draw_line(obj, gc, |
4d3b74821345
[svn] Add a line between the time and the track name.
nenolod
parents:
460
diff
changeset
|
745 pl->pl_widget.x + pl->pl_widget.width - tpadding, |
4d3b74821345
[svn] Add a line between the time and the track name.
nenolod
parents:
460
diff
changeset
|
746 pl->pl_widget.y, |
4d3b74821345
[svn] Add a line between the time and the track name.
nenolod
parents:
460
diff
changeset
|
747 pl->pl_widget.x + pl->pl_widget.width - tpadding, |
958 | 748 pl->pl_widget.y + pl->pl_widget.height - 1); |
506
4d3b74821345
[svn] Add a line between the time and the track name.
nenolod
parents:
460
diff
changeset
|
749 |
4d3b74821345
[svn] Add a line between the time and the track name.
nenolod
parents:
460
diff
changeset
|
750 } |
4d3b74821345
[svn] Add a line between the time and the track name.
nenolod
parents:
460
diff
changeset
|
751 |
0 | 752 gdk_gc_set_clip_origin(gc, 0, 0); |
753 gdk_gc_set_clip_rectangle(gc, NULL); | |
754 | |
755 PLAYLIST_UNLOCK(); | |
958 | 756 |
813
c8cf439179b8
[svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents:
797
diff
changeset
|
757 g_free(playlist_rect); |
0 | 758 } |
759 | |
760 | |
761 PlayList_List * | |
762 create_playlist_list(GList ** wlist, | |
763 GdkPixmap * parent, | |
764 GdkGC * gc, | |
765 gint x, gint y, | |
766 gint w, gint h) | |
767 { | |
768 PlayList_List *pl; | |
769 | |
770 pl = g_new0(PlayList_List, 1); | |
771 widget_init(&pl->pl_widget, parent, gc, x, y, w, h, TRUE); | |
772 | |
773 pl->pl_widget.button_press_cb = | |
774 (WidgetButtonPressFunc) playlist_list_button_press_cb; | |
775 pl->pl_widget.button_release_cb = | |
776 (WidgetButtonReleaseFunc) playlist_list_button_release_cb; | |
777 pl->pl_widget.motion_cb = (WidgetMotionFunc) playlist_list_motion_cb; | |
778 pl->pl_widget.draw = playlist_list_draw; | |
779 | |
780 pl->pl_prev_selected = -1; | |
781 pl->pl_prev_min = -1; | |
782 pl->pl_prev_max = -1; | |
783 | |
784 widget_list_add(wlist, WIDGET(pl)); | |
785 | |
786 return pl; | |
787 } | |
788 | |
789 void | |
790 playlist_list_set_font(const gchar * font) | |
791 { | |
792 | |
793 /* Welcome to bad hack central 2k3 */ | |
794 | |
795 gchar *font_lower; | |
796 gint width_temp; | |
797 gint width_temp_0; | |
798 | |
799 playlist_list_font = pango_font_description_from_string(font); | |
800 | |
801 text_get_extents(font, | |
802 "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz ", | |
803 &width_approx_letters, NULL, &ascent, &descent); | |
804 | |
805 width_approx_letters = (width_approx_letters / 53); | |
806 | |
807 /* Experimental: We don't weigh the 1 into total because it's width is almost always | |
808 * very different from the rest | |
809 */ | |
810 text_get_extents(font, "023456789", &width_approx_digits, NULL, NULL, | |
811 NULL); | |
812 width_approx_digits = (width_approx_digits / 9); | |
813 | |
814 /* Precache some often used calculations */ | |
815 width_approx_digits_half = width_approx_digits / 2; | |
816 | |
817 /* FIXME: We assume that any other number is broader than the "1" */ | |
818 text_get_extents(font, "1", &width_temp, NULL, NULL, NULL); | |
819 text_get_extents(font, "2", &width_temp_0, NULL, NULL, NULL); | |
820 | |
821 if (abs(width_temp_0 - width_temp) < 2) { | |
822 width_delta_digit_one = 0; | |
823 } | |
824 else { | |
825 width_delta_digit_one = ((width_temp_0 - width_temp) / 2) + 2; | |
826 } | |
827 | |
828 text_get_extents(font, ":", &width_colon, NULL, NULL, NULL); | |
829 width_colon_third = width_colon / 4; | |
830 | |
831 font_lower = g_utf8_strdown(font, strlen(font)); | |
832 /* This doesn't take any i18n into account, but i think there is none with TTF fonts | |
833 * FIXME: This can probably be retrieved trough Pango too | |
834 */ | |
835 has_slant = g_strstr_len(font_lower, strlen(font_lower), "oblique") | |
836 || g_strstr_len(font_lower, strlen(font_lower), "italic"); | |
837 | |
838 g_free(font_lower); | |
839 } |