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