annotate audacious/widgets/playlist_list.c @ 2140:299651a8f107 trunk

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