annotate audacious/widgets/playlist_list.c @ 2093:b05046902327 trunk

[svn] Oops. controlsocket.c is *much* happier now that the arguments are in the right order. >.>
author kiyoshi
date Mon, 11 Dec 2006 04:53:17 -0800
parents c547fe73f290
children fcd1f54efdb9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
1 /* Audacious - Cross-platform multimedia player
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
2 * Copyright (C) 2005-2006 Audacious development team.
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
3 *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
4 * BMP - Cross-platform multimedia player
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
5 * Copyright (C) 2003-2004 BMP development team.
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
6 *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
7 * Based on XMMS:
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
8 * Copyright (C) 1998-2003 XMMS development team.
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
9 *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
13 * (at your option) any later version.
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
14 *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
18 * GNU General Public License for more details.
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
19 *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
23 */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
24
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
25 /*
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
26 * A note about Pango and some funky spacey fonts: Weirdly baselined
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
27 * fonts, or fonts with weird ascents or descents _will_ display a
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
28 * little bit weird in the playlist widget, but the display engine
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
29 * won't make it look too bad, just a little deranged. I honestly
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
30 * don't think it's worth fixing (around...), it doesn't have to be
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
31 * perfectly fitting, just the general look has to be ok, which it
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
32 * IMHO is.
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
33 *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
34 * A second note: The numbers aren't perfectly aligned, but in the
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
35 * end it looks better when using a single Pango layout for each
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
36 * number.
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
37 */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
38
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
39 #include "widgetcore.h"
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
40
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
41 #include <stdlib.h>
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
42 #include <string.h>
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
43
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
44 #include "main.h"
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
45 #include "input.h"
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
46 #include "playback.h"
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
47 #include "playlist.h"
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
48 #include "ui_playlist.h"
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
49 #include "util.h"
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
50
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
51 #include "debug.h"
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
52
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
53 static PangoFontDescription *playlist_list_font = NULL;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
54 static gint ascent, descent, width_delta_digit_one;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
55 static gboolean has_slant;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
56 static guint padding;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
57
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
58 /* FIXME: the following globals should not be needed. */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
59 static gint width_approx_letters;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
60 static gint width_colon, width_colon_third;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
61 static gint width_approx_digits, width_approx_digits_half;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
62
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
63 GdkPixmap *rootpix;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
64
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
65 void playlist_list_draw(Widget * w);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
66
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
67 /* Sort of stolen from XChat, but not really, as theres uses Xlib */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
68 static void
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
69 shade_gdkimage_generic (GdkVisual *visual, GdkImage *ximg, int bpl, int w, int h, int rm, int gm, int bm, int bg)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
70 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
71 int x, y;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
72 int bgr = (256 - rm) * (bg & visual->red_mask);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
73 int bgg = (256 - gm) * (bg & visual->green_mask);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
74 int bgb = (256 - bm) * (bg & visual->blue_mask);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
75
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
76 for (x = 0; x < w; x++)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
77 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
78 for (y = 0; y < h; y++)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
79 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
80 unsigned long pixel = gdk_image_get_pixel (ximg, x, y);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
81 int r, g, b;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
82
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
83 r = rm * (pixel & visual->red_mask) + bgr;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
84 g = gm * (pixel & visual->green_mask) + bgg;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
85 b = bm * (pixel & visual->blue_mask) + bgb;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
86
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
87 gdk_image_put_pixel (ximg, x, y,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
88 ((r >> 8) & visual->red_mask) |
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
89 ((g >> 8) & visual->green_mask) |
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
90 ((b >> 8) & visual->blue_mask));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
91 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
92 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
93 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
94
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
95 /* and this is definately mine... -nenolod */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
96 GdkPixmap *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
97 shade_pixmap(GdkPixmap *in, gint x, gint y, gint x_offset, gint y_offset, gint w, gint h, GdkColor *shade_color)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
98 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
99 GdkImage *ximg;
1770
80955c196e11 [svn] - fix a potential crash when running audacious remotely
nenolod
parents: 1653
diff changeset
100 GdkPixmap *p;
80955c196e11 [svn] - fix a potential crash when running audacious remotely
nenolod
parents: 1653
diff changeset
101 GdkGC *gc;
80955c196e11 [svn] - fix a potential crash when running audacious remotely
nenolod
parents: 1653
diff changeset
102
1887
94795106c541 [svn] - icc warning fixes (pass 1)
nenolod
parents: 1771
diff changeset
103 g_return_val_if_fail(in != NULL, NULL);
1770
80955c196e11 [svn] - fix a potential crash when running audacious remotely
nenolod
parents: 1653
diff changeset
104
1771
630cdcaad7de [svn] - that should be a lowercase p, not an uppercase one.
nenolod
parents: 1770
diff changeset
105 p = gdk_pixmap_new(in, w, h, -1);
1770
80955c196e11 [svn] - fix a potential crash when running audacious remotely
nenolod
parents: 1653
diff changeset
106 gc = gdk_gc_new(p);
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
107
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
108 gdk_draw_pixmap(p, gc, in, x, y, 0, 0, w, h);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
109
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
110 gdk_error_trap_push();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
111
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
112 ximg = gdk_drawable_copy_to_image(in, NULL, x, y, 0, 0, w, h); /* copy */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
113
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
114 gdk_error_trap_pop();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
115
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
116 if (GDK_IS_IMAGE(ximg))
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
117 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
118 shade_gdkimage_generic(gdk_drawable_get_visual(GDK_WINDOW(playlistwin->window)),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
119 ximg, ximg->bpl, w, h, 60, 60, 60, shade_color->pixel);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
120
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
121 gdk_draw_image(p, gc, ximg, 0, 0, x, y, w, h);
1902
e549a118c972 [svn] - fix memory leak once and for bloody all
nenolod
parents: 1899
diff changeset
122
e549a118c972 [svn] - fix memory leak once and for bloody all
nenolod
parents: 1899
diff changeset
123 g_object_unref(ximg);
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
124 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
125 else {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
126 cfg.playlist_transparent = FALSE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
127 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
128
1898
22051a0efcef [svn] - fix leak when changing background
nenolod
parents: 1887
diff changeset
129 g_object_unref(in);
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
130 g_object_unref(gc);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
131
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
132 return p;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
133 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
134
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
135 #ifdef GDK_WINDOWING_X11
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
136
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
137 #include <gdk/gdkx.h>
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
138 #include <X11/Xlib.h>
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
139 #include <X11/Xatom.h>
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
140
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
141 GdkDrawable *get_transparency_pixmap(void)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
142 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
143 GdkDrawable *root;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
144 XID *pixmaps;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
145 GdkAtom prop_type;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
146 gint prop_size;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
147 GdkPixmap *pixmap;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
148 gboolean ret;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
149
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
150 root = gdk_get_default_root_window();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
151
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
152 pixmap = NULL;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
153 pixmaps = NULL;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
154
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
155 gdk_error_trap_push();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
156
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
157 ret = gdk_property_get(root, gdk_atom_intern("_XROOTPMAP_ID", TRUE),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
158 0, 0, INT_MAX - 3,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
159 FALSE,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
160 &prop_type, NULL, &prop_size,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
161 (guchar **) &pixmaps);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
162
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
163 gdk_error_trap_pop();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
164
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
165 if ((ret == TRUE) && (prop_type == GDK_TARGET_PIXMAP) && (prop_size >= sizeof(XID)) && (pixmaps != NULL))
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
166 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
167 pixmap = gdk_pixmap_foreign_new_for_display(gdk_drawable_get_display(root),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
168 pixmaps[0]);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
169
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
170 if (pixmaps != NULL)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
171 g_free(pixmaps);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
172 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
173
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
174 return GDK_DRAWABLE(pixmap);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
175 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
176
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
177 static GdkFilterReturn
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
178 root_event_cb (GdkXEvent *xev, GdkEventProperty *event, gpointer data)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
179 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
180 XEvent *xevent = (XEvent *)xev;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
181
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
182 if (xevent->type == PropertyNotify)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
183 {
1902
e549a118c972 [svn] - fix memory leak once and for bloody all
nenolod
parents: 1899
diff changeset
184 Atom at = XInternAtom (xevent->xproperty.display, "_XROOTPMAP_ID", True);
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
185
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
186 if (at == xevent->xproperty.atom)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
187 {
1899
e08527b44c20 [svn] - make sure rootpix is freed when a new pixmap is generated
nenolod
parents: 1898
diff changeset
188 if (rootpix != NULL)
e08527b44c20 [svn] - make sure rootpix is freed when a new pixmap is generated
nenolod
parents: 1898
diff changeset
189 g_object_unref(rootpix);
e08527b44c20 [svn] - make sure rootpix is freed when a new pixmap is generated
nenolod
parents: 1898
diff changeset
190
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
191 rootpix = shade_pixmap(get_transparency_pixmap(), 0, 0, 0, 0, gdk_screen_width(), gdk_screen_height(),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
192 skin_get_color(bmp_active_skin, SKIN_PLEDIT_NORMALBG));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
193
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
194 if (cfg.playlist_transparent)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
195 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
196 playlistwin_update_list();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
197 draw_playlist_window(TRUE);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
198 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
199 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
200 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
201
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
202 return GDK_FILTER_CONTINUE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
203 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
204
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
205 #else
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
206
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
207 GdkPixmap *get_transparency_pixmap(void)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
208 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
209 return NULL;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
210 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
211
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
212 #endif
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
213
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
214 static gboolean
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
215 playlist_list_auto_drag_down_func(gpointer data)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
216 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
217 PlayList_List *pl = data;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
218
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
219 if (pl->pl_auto_drag_down) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
220 playlist_list_move_down(pl);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
221 pl->pl_first++;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
222 playlistwin_update_list();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
223 return TRUE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
224 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
225 return FALSE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
226 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
227
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
228 static gboolean
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
229 playlist_list_auto_drag_up_func(gpointer data)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
230 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
231 PlayList_List *pl = data;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
232
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
233 if (pl->pl_auto_drag_up) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
234 playlist_list_move_up(pl);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
235 pl->pl_first--;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
236 playlistwin_update_list();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
237 return TRUE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
238
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
239 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
240 return FALSE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
241 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
242
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
243 void
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
244 playlist_list_move_up(PlayList_List * pl)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
245 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
246 GList *list;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
247
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
248 PLAYLIST_LOCK();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
249 if ((list = playlist_get()) == NULL) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
250 PLAYLIST_UNLOCK();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
251 return;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
252 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
253 if (PLAYLIST_ENTRY(list->data)->selected) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
254 /* We are at the top */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
255 PLAYLIST_UNLOCK();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
256 return;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
257 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
258 while (list) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
259 if (PLAYLIST_ENTRY(list->data)->selected)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
260 glist_moveup(list);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
261 list = g_list_next(list);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
262 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
263 PLAYLIST_UNLOCK();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
264 if (pl->pl_prev_selected != -1)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
265 pl->pl_prev_selected--;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
266 if (pl->pl_prev_min != -1)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
267 pl->pl_prev_min--;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
268 if (pl->pl_prev_max != -1)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
269 pl->pl_prev_max--;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
270 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
271
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
272 void
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
273 playlist_list_move_down(PlayList_List * pl)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
274 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
275 GList *list;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
276
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
277 PLAYLIST_LOCK();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
278
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
279 if (!(list = g_list_last(playlist_get()))) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
280 PLAYLIST_UNLOCK();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
281 return;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
282 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
283
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
284 if (PLAYLIST_ENTRY(list->data)->selected) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
285 /* We are at the bottom */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
286 PLAYLIST_UNLOCK();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
287 return;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
288 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
289
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
290 while (list) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
291 if (PLAYLIST_ENTRY(list->data)->selected)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
292 glist_movedown(list);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
293 list = g_list_previous(list);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
294 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
295
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
296 PLAYLIST_UNLOCK();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
297
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
298 if (pl->pl_prev_selected != -1)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
299 pl->pl_prev_selected++;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
300 if (pl->pl_prev_min != -1)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
301 pl->pl_prev_min++;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
302 if (pl->pl_prev_max != -1)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
303 pl->pl_prev_max++;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
304 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
305
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
306 static void
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
307 playlist_list_button_press_cb(GtkWidget * widget,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
308 GdkEventButton * event,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
309 PlayList_List * pl)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
310 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
311 gint nr, y;
2086
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
312 Playlist *playlist = playlist_get_active();
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
313
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
314 if (event->button == 1 && pl->pl_fheight &&
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
315 widget_contains(&pl->pl_widget, event->x, event->y)) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
316
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
317 y = event->y - pl->pl_widget.y;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
318 nr = (y / pl->pl_fheight) + pl->pl_first;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
319
2086
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
320 if (nr >= playlist_get_length(playlist))
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
321 nr = playlist_get_length(playlist) - 1;
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
322
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
323 if (!(event->state & GDK_CONTROL_MASK))
2086
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
324 playlist_select_all(playlist, FALSE);
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
325
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
326 if (event->state & GDK_SHIFT_MASK && pl->pl_prev_selected != -1) {
2086
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
327 playlist_select_range(playlist, pl->pl_prev_selected, nr, TRUE);
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
328 pl->pl_prev_min = pl->pl_prev_selected;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
329 pl->pl_prev_max = nr;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
330 pl->pl_drag_pos = nr - pl->pl_first;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
331 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
332 else {
2086
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
333 if (playlist_select_invert(playlist, nr)) {
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
334 if (event->state & GDK_CONTROL_MASK) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
335 if (pl->pl_prev_min == -1) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
336 pl->pl_prev_min = pl->pl_prev_selected;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
337 pl->pl_prev_max = pl->pl_prev_selected;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
338 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
339 if (nr < pl->pl_prev_min)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
340 pl->pl_prev_min = nr;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
341 else if (nr > pl->pl_prev_max)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
342 pl->pl_prev_max = nr;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
343 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
344 else
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
345 pl->pl_prev_min = -1;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
346 pl->pl_prev_selected = nr;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
347 pl->pl_drag_pos = nr - pl->pl_first;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
348 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
349 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
350 if (event->type == GDK_2BUTTON_PRESS) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
351 /*
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
352 * Ungrab the pointer to prevent us from
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
353 * hanging on to it during the sometimes slow
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
354 * bmp_playback_initiate().
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
355 */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
356 gdk_pointer_ungrab(GDK_CURRENT_TIME);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
357 gdk_flush();
2086
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
358 playlist_set_position(playlist, nr);
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
359 if (!bmp_playback_get_playing())
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
360 bmp_playback_initiate();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
361 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
362
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
363 pl->pl_dragging = TRUE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
364 playlistwin_update_list();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
365 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
366 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
367
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
368 gint
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
369 playlist_list_get_playlist_position(PlayList_List * pl,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
370 gint x,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
371 gint y)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
372 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
373 gint iy, length;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
374 gint ret;
2086
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
375 Playlist *playlist = playlist_get_active();
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
376
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
377 if (!widget_contains(WIDGET(pl), x, y) || !pl->pl_fheight)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
378 return -1;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
379
2086
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
380 if ((length = playlist_get_length(playlist)) == 0)
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
381 return -1;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
382 iy = y - pl->pl_widget.y;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
383
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
384 ret = (iy / pl->pl_fheight) + pl->pl_first;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
385
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
386 if(ret > length-1)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
387 ret = -1;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
388
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
389 return ret;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
390 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
391
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
392 static void
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
393 playlist_list_motion_cb(GtkWidget * widget,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
394 GdkEventMotion * event,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
395 PlayList_List * pl)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
396 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
397 gint nr, y, off, i;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
398
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
399 if (pl->pl_dragging) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
400 y = event->y - pl->pl_widget.y;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
401 nr = (y / pl->pl_fheight);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
402 if (nr < 0) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
403 nr = 0;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
404 if (!pl->pl_auto_drag_up) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
405 pl->pl_auto_drag_up = TRUE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
406 pl->pl_auto_drag_up_tag =
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
407 gtk_timeout_add(100, playlist_list_auto_drag_up_func, pl);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
408 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
409 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
410 else if (pl->pl_auto_drag_up)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
411 pl->pl_auto_drag_up = FALSE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
412
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
413 if (nr >= pl->pl_num_visible) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
414 nr = pl->pl_num_visible - 1;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
415 if (!pl->pl_auto_drag_down) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
416 pl->pl_auto_drag_down = TRUE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
417 pl->pl_auto_drag_down_tag =
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
418 gtk_timeout_add(100, playlist_list_auto_drag_down_func,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
419 pl);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
420 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
421 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
422 else if (pl->pl_auto_drag_down)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
423 pl->pl_auto_drag_down = FALSE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
424
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
425 off = nr - pl->pl_drag_pos;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
426 if (off) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
427 for (i = 0; i < abs(off); i++) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
428 if (off < 0)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
429 playlist_list_move_up(pl);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
430 else
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
431 playlist_list_move_down(pl);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
432
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
433 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
434 playlistwin_update_list();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
435 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
436 pl->pl_drag_pos = nr;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
437 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
438 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
439
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
440 static void
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
441 playlist_list_button_release_cb(GtkWidget * widget,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
442 GdkEventButton * event,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
443 PlayList_List * pl)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
444 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
445 pl->pl_dragging = FALSE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
446 pl->pl_auto_drag_down = FALSE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
447 pl->pl_auto_drag_up = FALSE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
448 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
449
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
450 static void
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
451 playlist_list_draw_string(PlayList_List * pl,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
452 PangoFontDescription * font,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
453 gint line,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
454 gint width,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
455 const gchar * text,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
456 guint ppos)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
457 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
458 guint plist_length_int;
2086
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
459 Playlist *playlist = playlist_get_active();
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
460
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
461 PangoLayout *layout;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
462
2086
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
463 REQUIRE_STATIC_LOCK(playlists);
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
464
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
465 if (cfg.show_numbers_in_pl) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
466 gchar *pos_string = g_strdup_printf(cfg.show_separator_in_pl == TRUE ? "%d" : "%d.", ppos);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
467 plist_length_int =
2086
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
468 gint_count_digits(playlist_get_length_nolock(playlist)) + !cfg.show_separator_in_pl + 1; /* cf.show_separator_in_pl will be 0 if false */
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
469
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
470 padding = plist_length_int;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
471 padding = ((padding + 1) * width_approx_digits);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
472
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
473 layout = gtk_widget_create_pango_layout(playlistwin, pos_string);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
474 pango_layout_set_font_description(layout, playlist_list_font);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
475 pango_layout_set_width(layout, plist_length_int * 100);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
476
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
477 pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
478 gdk_draw_layout(pl->pl_widget.parent, pl->pl_widget.gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
479 pl->pl_widget.x +
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
480 (width_approx_digits *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
481 (-1 + plist_length_int - strlen(pos_string))) +
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
482 (width_approx_digits / 4),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
483 pl->pl_widget.y + (line - 1) * pl->pl_fheight +
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
484 ascent + abs(descent), layout);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
485 g_free(pos_string);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
486 g_object_unref(layout);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
487
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
488 if (!cfg.show_separator_in_pl)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
489 padding -= (width_approx_digits * 1.5);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
490 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
491 else {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
492 padding = 3;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
493 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
494
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
495 width -= padding;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
496
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
497 layout = gtk_widget_create_pango_layout(playlistwin, text);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
498
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
499 pango_layout_set_font_description(layout, playlist_list_font);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
500 pango_layout_set_width(layout, width * PANGO_SCALE);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
501 pango_layout_set_single_paragraph_mode(layout, TRUE);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
502 pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
503 gdk_draw_layout(pl->pl_widget.parent, pl->pl_widget.gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
504 pl->pl_widget.x + padding + (width_approx_letters / 4),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
505 pl->pl_widget.y + (line - 1) * pl->pl_fheight +
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
506 ascent + abs(descent), layout);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
507
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
508 g_object_unref(layout);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
509 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
510
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
511 void
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
512 playlist_list_draw(Widget * w)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
513 {
2086
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
514 Playlist *playlist = playlist_get_active();
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
515 PlayList_List *pl = PLAYLIST_LIST(w);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
516 GList *list;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
517 GdkGC *gc;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
518 GdkPixmap *obj;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
519 PangoLayout *layout;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
520 gchar *title;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
521 gint width, height;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
522 gint i, max_first;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
523 guint padding, padding_dwidth, padding_plength;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
524 guint max_time_len = 0;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
525 gfloat queue_tailpadding = 0;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
526 gint tpadding;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
527 gsize tpadding_dwidth = 0;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
528 gint x, y;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
529 guint tail_width;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
530 guint tail_len;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
531
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
532 gchar tail[100];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
533 gchar queuepos[255];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
534 gchar length[40];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
535
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
536 gchar **frags;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
537 gchar *frag0;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
538
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
539 gint plw_w, plw_h;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
540
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
541 GdkRectangle *playlist_rect;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
542
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
543 gc = pl->pl_widget.gc;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
544
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
545 width = pl->pl_widget.width;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
546 height = pl->pl_widget.height;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
547
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
548 obj = pl->pl_widget.parent;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
549
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
550 gtk_window_get_size(GTK_WINDOW(playlistwin), &plw_w, &plw_h);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
551
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
552 playlist_rect = g_new0(GdkRectangle, 1);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
553
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
554 playlist_rect->x = 0;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
555 playlist_rect->y = 0;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
556 playlist_rect->width = plw_w - 17;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
557 playlist_rect->height = plw_h - 36;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
558
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
559 gdk_gc_set_clip_origin(gc, 31, 58);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
560 gdk_gc_set_clip_rectangle(gc, playlist_rect);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
561
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
562 if (cfg.playlist_transparent == FALSE)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
563 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
564 gdk_gc_set_foreground(gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
565 skin_get_color(bmp_active_skin,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
566 SKIN_PLEDIT_NORMALBG));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
567 gdk_draw_rectangle(obj, gc, TRUE, pl->pl_widget.x, pl->pl_widget.y,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
568 width, height);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
569 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
570 else
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
571 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
572 if (!rootpix)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
573 rootpix = shade_pixmap(get_transparency_pixmap(), 0, 0, 0, 0, gdk_screen_width(), gdk_screen_height(),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
574 skin_get_color(bmp_active_skin, SKIN_PLEDIT_NORMALBG));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
575 gdk_draw_pixmap(obj, gc, rootpix, cfg.playlist_x + pl->pl_widget.x,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
576 cfg.playlist_y + pl->pl_widget.y, pl->pl_widget.x, pl->pl_widget.y,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
577 width, height);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
578 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
579
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
580 if (!playlist_list_font) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
581 g_critical("Couldn't open playlist font");
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
582 return;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
583 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
584
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
585 pl->pl_fheight = (ascent + abs(descent));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
586 pl->pl_num_visible = height / pl->pl_fheight;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
587
2086
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
588 max_first = playlist_get_length(playlist) - pl->pl_num_visible;
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
589 max_first = MAX(max_first, 0);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
590
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
591 pl->pl_first = CLAMP(pl->pl_first, 0, max_first);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
592
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
593 PLAYLIST_LOCK();
2086
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
594 list = playlist->entries;
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
595 list = g_list_nth(list, pl->pl_first);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
596
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
597 /* It sucks having to run the iteration twice but this is the only
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
598 way you can reliably get the maximum width so we can get our
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
599 playlist nice and aligned... -- plasmaroo */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
600
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
601 for (i = pl->pl_first;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
602 list && i < pl->pl_first + pl->pl_num_visible;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
603 list = g_list_next(list), i++) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
604 PlaylistEntry *entry = list->data;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
605
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
606 if (entry->length != -1)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
607 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
608 g_snprintf(length, sizeof(length), "%d:%-2.2d",
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
609 entry->length / 60000, (entry->length / 1000) % 60);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
610 tpadding_dwidth = MAX(tpadding_dwidth, strlen(length));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
611 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
612 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
613
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
614 /* Reset */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
615 list = playlist_get();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
616 list = g_list_nth(list, pl->pl_first);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
617
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
618 for (i = pl->pl_first;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
619 list && i < pl->pl_first + pl->pl_num_visible;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
620 list = g_list_next(list), i++) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
621 gint pos;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
622 PlaylistEntry *entry = list->data;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
623
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
624 if (entry->selected) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
625 gdk_gc_set_foreground(gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
626 skin_get_color(bmp_active_skin,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
627 SKIN_PLEDIT_SELECTEDBG));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
628 gdk_draw_rectangle(obj, gc, TRUE, pl->pl_widget.x,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
629 pl->pl_widget.y +
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
630 ((i - pl->pl_first) * pl->pl_fheight),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
631 width, pl->pl_fheight);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
632 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
633
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
634 /* FIXME: entry->title should NEVER be NULL, and there should
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
635 NEVER be a need to do a UTF-8 conversion. Playlist title
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
636 strings should be kept properly. */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
637
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
638 if (!entry->title) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
639 gchar *basename = g_path_get_basename(entry->filename);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
640 title = filename_to_utf8(basename);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
641 g_free(basename);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
642 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
643 else
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
644 title = str_to_utf8(entry->title);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
645
1996
1abdcfc557d8 [svn] - fix the %20 in playlist issue. Patch by external contributor Ralf
nenolod
parents: 1902
diff changeset
646 title = convert_title_text(title);
1abdcfc557d8 [svn] - fix the %20 in playlist issue. Patch by external contributor Ralf
nenolod
parents: 1902
diff changeset
647
2086
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
648 pos = playlist_get_queue_position(playlist, entry);
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
649
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
650 tail[0] = 0;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
651 queuepos[0] = 0;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
652 length[0] = 0;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
654 if (pos != -1)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
655 g_snprintf(queuepos, sizeof(queuepos), "%d", pos + 1);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
656
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
657 if (entry->length != -1)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
658 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
659 g_snprintf(length, sizeof(length), "%d:%-2.2d",
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
660 entry->length / 60000, (entry->length / 1000) % 60);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
661 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
662
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
663 strncat(tail, length, sizeof(tail));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
664 tail_len = strlen(tail);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
665
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
666 max_time_len = MAX(max_time_len, tail_len);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
667
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
668 if (pos != -1 && tpadding_dwidth <= 0)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
669 tail_width = width - (width_approx_digits * (strlen(queuepos) + 2.25));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
670 else if (pos != -1)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
671 tail_width = width - (width_approx_digits * (tpadding_dwidth + strlen(queuepos) + 4));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
672 else if (tpadding_dwidth > 0)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
673 tail_width = width - (width_approx_digits * (tpadding_dwidth + 2.5));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
674 else
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
675 tail_width = width;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
676
2086
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
677 if (i == playlist_get_position_nolock(playlist))
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
678 gdk_gc_set_foreground(gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
679 skin_get_color(bmp_active_skin,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
680 SKIN_PLEDIT_CURRENT));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
681 else
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
682 gdk_gc_set_foreground(gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
683 skin_get_color(bmp_active_skin,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
684 SKIN_PLEDIT_NORMAL));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
685 playlist_list_draw_string(pl, playlist_list_font,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
686 i - pl->pl_first, tail_width, title,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
687 i + 1);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
688
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
689 x = pl->pl_widget.x + width - width_approx_digits * 2;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
690 y = pl->pl_widget.y + ((i - pl->pl_first) -
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
691 1) * pl->pl_fheight + ascent;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
692
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
693 frags = NULL;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
694 frag0 = NULL;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
695
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
696 if ((strlen(tail) > 0) && (tail != NULL)) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
697 frags = g_strsplit(tail, ":", 0);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
698 frag0 = g_strconcat(frags[0], ":", NULL);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
699
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
700 layout = gtk_widget_create_pango_layout(playlistwin, frags[1]);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
701 pango_layout_set_font_description(layout, playlist_list_font);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
702 pango_layout_set_width(layout, tail_len * 100);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
703 pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
704 gdk_draw_layout(obj, gc, x - (0.5 * width_approx_digits),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
705 y + abs(descent), layout);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
706 g_object_unref(layout);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
707
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
708 layout = gtk_widget_create_pango_layout(playlistwin, frag0);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
709 pango_layout_set_font_description(layout, playlist_list_font);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
710 pango_layout_set_width(layout, tail_len * 100);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
711 pango_layout_set_alignment(layout, PANGO_ALIGN_RIGHT);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
712 gdk_draw_layout(obj, gc, x - (0.75 * width_approx_digits),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
713 y + abs(descent), layout);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
714 g_object_unref(layout);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
715
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
716 g_free(frag0);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
717 g_strfreev(frags);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
718 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
719
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
720 if (pos != -1) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
721
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
722 /* DON'T remove the commented code yet please -- Milosz */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
723
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
724 if (tpadding_dwidth > 0)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
725 queue_tailpadding = tpadding_dwidth + 1;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
726 else
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
727 queue_tailpadding = -0.75;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
728
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
729 gdk_draw_rectangle(obj, gc, FALSE,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
730 x -
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
731 (((queue_tailpadding +
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
732 strlen(queuepos)) *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
733 width_approx_digits) +
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
734 (width_approx_digits / 4)),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
735 y + abs(descent),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
736 (strlen(queuepos)) *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
737 width_approx_digits +
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
738 (width_approx_digits / 2),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
739 pl->pl_fheight - 2);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
740
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
741 layout =
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
742 gtk_widget_create_pango_layout(playlistwin, queuepos);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
743 pango_layout_set_font_description(layout, playlist_list_font);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
744 pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
745
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
746 gdk_draw_layout(obj, gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
747 x -
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
748 ((queue_tailpadding +
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
749 strlen(queuepos)) * width_approx_digits) +
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
750 (width_approx_digits / 4),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
751 y + abs(descent), layout);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
752 g_object_unref(layout);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
753 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
754
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
755 g_free(title);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
756 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
757
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
758
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
759 /*
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
760 * Drop target hovering over the playlist, so draw some hint where the
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
761 * drop will occur.
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
762 *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
763 * This is (currently? unfixably?) broken when dragging files from Qt/KDE apps,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
764 * probably due to DnD signaling problems (actually i have no clue).
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
765 *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
766 */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
767
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
768 if (pl->pl_drag_motion) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
769 guint pos, plength, lpadding;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
770 gint x, y, plx, ply;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
771
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
772 if (cfg.show_numbers_in_pl) {
2086
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
773 lpadding = gint_count_digits(playlist_get_length_nolock(playlist)) + 1;
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
774 lpadding = ((lpadding + 1) * width_approx_digits);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
775 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
776 else {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
777 lpadding = 3;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
778 };
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
779
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
780 /* We already hold the mutex and have the playlist locked, so call
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
781 the non-locking function. */
2086
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
782 plength = playlist_get_length_nolock(playlist);
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
783
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
784 x = pl->drag_motion_x;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
785 y = pl->drag_motion_y;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
786
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
787 plx = pl->pl_widget.x;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
788 ply = pl->pl_widget.y;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
789
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
790 if ((x > pl->pl_widget.x) && !(x > pl->pl_widget.width)) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
791
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
792 if ((y > pl->pl_widget.y)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
793 && !(y > (pl->pl_widget.height + ply))) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
794
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
795 pos = ((y - ((Widget *) pl)->y) / pl->pl_fheight) +
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
796 pl->pl_first;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
797
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
798 if (pos > (plength)) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
799 pos = plength;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
800 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
801
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
802 gdk_gc_set_foreground(gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
803 skin_get_color(bmp_active_skin,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
804 SKIN_PLEDIT_CURRENT));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
805
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
806 gdk_draw_line(obj, gc, pl->pl_widget.x,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
807 pl->pl_widget.y + ((pos - pl->pl_first) * pl->pl_fheight),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
808 pl->pl_widget.width + pl->pl_widget.x - 1,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
809 pl->pl_widget.y +
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
810 ((pos - pl->pl_first) * pl->pl_fheight));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
811 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
812
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
813 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
814
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
815 /* When dropping on the borders of the playlist, outside the text area,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
816 * files get appended at the end of the list. Show that too.
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
817 */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
818
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
819 if ((y < ply) || (y > pl->pl_widget.height + ply)) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
820 if ((y >= 0) || (y <= (pl->pl_widget.height + ply))) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
821 pos = plength;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
822 gdk_gc_set_foreground(gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
823 skin_get_color(bmp_active_skin,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
824 SKIN_PLEDIT_CURRENT));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
825
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
826 gdk_draw_line(obj, gc, pl->pl_widget.x,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
827 pl->pl_widget.y +
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
828 ((pos - pl->pl_first) * pl->pl_fheight),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
829 pl->pl_widget.width + pl->pl_widget.x - 1,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
830 pl->pl_widget.y +
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
831 ((pos - pl->pl_first) * pl->pl_fheight));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
832
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
833 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
834 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
835 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
836
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
837 gdk_gc_set_foreground(gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
838 skin_get_color(bmp_active_skin,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
839 SKIN_PLEDIT_NORMAL));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
840
2086
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
841 if (cfg.show_numbers_in_pl)
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
842 {
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
843 padding_plength = playlist_get_length_nolock(playlist);
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
844
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
845 if (padding_plength == 0) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
846 padding_dwidth = 0;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
847 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
848 else {
2086
c547fe73f290 [svn] - update widgetcore to new API
nenolod
parents: 1996
diff changeset
849 padding_dwidth = gint_count_digits(playlist_get_length_nolock(playlist));
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
850 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
851
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
852 padding =
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
853 (padding_dwidth *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
854 width_approx_digits) + width_approx_digits;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
855
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
856
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
857 /* For italic or oblique fonts we add another half of the
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
858 * approximate width */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
859 if (has_slant)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
860 padding += width_approx_digits_half;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
861
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
862 if (cfg.show_separator_in_pl) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
863 gdk_draw_line(obj, gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
864 pl->pl_widget.x + padding,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
865 pl->pl_widget.y,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
866 pl->pl_widget.x + padding,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
867 pl->pl_widget.y + pl->pl_widget.height - 1);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
868 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
869 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
870
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
871 if (tpadding_dwidth != 0)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
872 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
873 tpadding = (tpadding_dwidth * width_approx_digits) + (width_approx_digits * 1.5);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
874
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
875 if (has_slant)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
876 tpadding += width_approx_digits_half;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
877
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
878 if (cfg.show_separator_in_pl) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
879 gdk_draw_line(obj, gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
880 pl->pl_widget.x + pl->pl_widget.width - tpadding,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
881 pl->pl_widget.y,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
882 pl->pl_widget.x + pl->pl_widget.width - tpadding,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
883 pl->pl_widget.y + pl->pl_widget.height - 1);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
884 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
885 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
886
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
887 gdk_gc_set_clip_origin(gc, 0, 0);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
888 gdk_gc_set_clip_rectangle(gc, NULL);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
889
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
890 PLAYLIST_UNLOCK();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
891
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
892 gdk_flush();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
893
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
894 g_free(playlist_rect);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
895 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
896
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
897
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
898 PlayList_List *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
899 create_playlist_list(GList ** wlist,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
900 GdkPixmap * parent,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
901 GdkGC * gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
902 gint x, gint y,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
903 gint w, gint h)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
904 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
905 PlayList_List *pl;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
906
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
907 pl = g_new0(PlayList_List, 1);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
908 widget_init(&pl->pl_widget, parent, gc, x, y, w, h, TRUE);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
909
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
910 pl->pl_widget.button_press_cb =
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
911 (WidgetButtonPressFunc) playlist_list_button_press_cb;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
912 pl->pl_widget.button_release_cb =
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
913 (WidgetButtonReleaseFunc) playlist_list_button_release_cb;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
914 pl->pl_widget.motion_cb = (WidgetMotionFunc) playlist_list_motion_cb;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
915 pl->pl_widget.draw = playlist_list_draw;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
916
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
917 pl->pl_prev_selected = -1;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
918 pl->pl_prev_min = -1;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
919 pl->pl_prev_max = -1;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
920
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
921 widget_list_add(wlist, WIDGET(pl));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
922
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
923 #ifdef GDK_WINDOWING_X11
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
924 gdk_window_set_events (gdk_get_default_root_window(), GDK_PROPERTY_CHANGE_MASK);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
925 gdk_window_add_filter (gdk_get_default_root_window(), (GdkFilterFunc)root_event_cb, pl);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
926 #endif
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
927
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
928 return pl;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
929 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
930
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
931 void
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
932 playlist_list_set_font(const gchar * font)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
933 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
934
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
935 /* Welcome to bad hack central 2k3 */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
936
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
937 gchar *font_lower;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
938 gint width_temp;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
939 gint width_temp_0;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
940
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
941 playlist_list_font = pango_font_description_from_string(font);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
942
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
943 text_get_extents(font,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
944 "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz ",
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
945 &width_approx_letters, NULL, &ascent, &descent);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
946
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
947 width_approx_letters = (width_approx_letters / 53);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
948
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
949 /* Experimental: We don't weigh the 1 into total because it's width is almost always
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
950 * very different from the rest
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
951 */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
952 text_get_extents(font, "023456789", &width_approx_digits, NULL, NULL,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
953 NULL);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
954 width_approx_digits = (width_approx_digits / 9);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
955
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
956 /* Precache some often used calculations */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
957 width_approx_digits_half = width_approx_digits / 2;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
958
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
959 /* FIXME: We assume that any other number is broader than the "1" */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
960 text_get_extents(font, "1", &width_temp, NULL, NULL, NULL);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
961 text_get_extents(font, "2", &width_temp_0, NULL, NULL, NULL);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
962
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
963 if (abs(width_temp_0 - width_temp) < 2) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
964 width_delta_digit_one = 0;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
965 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
966 else {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
967 width_delta_digit_one = ((width_temp_0 - width_temp) / 2) + 2;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
968 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
969
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
970 text_get_extents(font, ":", &width_colon, NULL, NULL, NULL);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
971 width_colon_third = width_colon / 4;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
972
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
973 font_lower = g_utf8_strdown(font, strlen(font));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
974 /* This doesn't take any i18n into account, but i think there is none with TTF fonts
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
975 * FIXME: This can probably be retrieved trough Pango too
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
976 */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
977 has_slant = g_strstr_len(font_lower, strlen(font_lower), "oblique")
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
978 || g_strstr_len(font_lower, strlen(font_lower), "italic");
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
979
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
980 g_free(font_lower);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
981 }