annotate audacious/widgets/playlist_list.c @ 1614:9b4678a2efc9 trunk

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