annotate audacious/playlist_list.c @ 1379:5767c05ce900 trunk

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