annotate audacious/playlist_list.c @ 796:a5e9c8d67e00 trunk

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