annotate audacious/skin.c @ 383:5c457dac866a trunk

[svn] - Rename playlistwin stuff to ui_playlist.*
author nenolod
date Tue, 03 Jan 2006 12:54:18 -0800
parents cb178e5ad177
children 10535124cc8a
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 #ifdef HAVE_CONFIG_H
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
23 # include "config.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
24 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
25
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
26 /* TODO: enforce default sizes! */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28 #include <glib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29 #include <stdio.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
30 #include <stdlib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
31 #include <string.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
32 #include <ctype.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34 #include "equalizer.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35 #include "main.h"
383
5c457dac866a [svn] - Rename playlistwin stuff to ui_playlist.*
nenolod
parents: 0
diff changeset
36 #include "ui_playlist.h"
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37 #include "skin.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
38 #include "skinwin.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
39 #include "util.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
40
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
41 #include "debug.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
42
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
43 #include <gdk/gdkx.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
44 #include <X11/Xlib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
45
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
46
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
47 struct _SkinPixmapIdMapping {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
48 SkinPixmapId id;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
49 const gchar *name;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
50 const gchar *alt_name;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
51 gint width, height;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
52 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
53
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
54 struct _SkinMaskInfo {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
55 gint width, height;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
56 gchar *inistr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
57 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
58
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
59 typedef struct _SkinPixmapIdMapping SkinPixmapIdMapping;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
60 typedef struct _SkinMaskInfo SkinMaskInfo;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
61
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
62
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
63 Skin *bmp_active_skin = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
64
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65 static gint skin_current_num;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67 static SkinMaskInfo skin_mask_info[] = {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68 {275, 116, "Normal"},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 {275, 16, "WindowShade"},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70 {275, 116, "Equalizer"},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 {275, 16, "EqualizerWS"}
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 SkinPixmapIdMapping skin_pixmap_id_map[] = {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75 {SKIN_MAIN, "main", NULL},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76 {SKIN_CBUTTONS, "cbuttons", NULL},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77 {SKIN_SHUFREP, "shufrep", NULL},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 {SKIN_TEXT, "text", NULL},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79 {SKIN_TITLEBAR, "titlebar", NULL},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 {SKIN_VOLUME, "volume", NULL},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81 {SKIN_BALANCE, "balance", "volume"},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82 {SKIN_MONOSTEREO, "monoster", NULL},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83 {SKIN_PLAYPAUSE, "playpaus", NULL},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 {SKIN_NUMBERS, "nums_ex", "numbers"},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 {SKIN_POSBAR, "posbar", NULL},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86 {SKIN_EQMAIN, "eqmain", NULL},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87 {SKIN_PLEDIT, "pledit", NULL},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 {SKIN_EQ_EX, "eq_ex", NULL}
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91 static guint skin_pixmap_id_map_size = G_N_ELEMENTS(skin_pixmap_id_map);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93 static const guchar skin_default_viscolor[24][3] = {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94 {9, 34, 53},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95 {10, 18, 26},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96 {0, 54, 108},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97 {0, 58, 116},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
98 {0, 62, 124},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
99 {0, 66, 132},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
100 {0, 70, 140},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
101 {0, 74, 148},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
102 {0, 78, 156},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
103 {0, 82, 164},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104 {0, 86, 172},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
105 {0, 92, 184},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
106 {0, 98, 196},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107 {0, 104, 208},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
108 {0, 110, 220},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
109 {0, 116, 232},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
110 {0, 122, 244},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
111 {0, 128, 255},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
112 {0, 128, 255},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
113 {0, 104, 208},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
114 {0, 80, 160},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
115 {0, 56, 112},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
116 {0, 32, 64},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
117 {200, 200, 200}
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
119
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
120 static GdkBitmap *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
121 skin_create_transparent_mask(const gchar *,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
122 const gchar *,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
123 const gchar *,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
124 GdkWindow *,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
125 gint, gint);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
126
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
127 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
128 skin_setup_masks(Skin * skin);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
129
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
130 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
131 skin_set_default_vis_color(Skin * skin);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
132
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
133
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
134 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
135 skin_lock(Skin * skin)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
136 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
137 g_mutex_lock(skin->lock);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
138 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
139
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
140 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
141 skin_unlock(Skin * skin)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
142 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
143 g_mutex_unlock(skin->lock);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
144 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
145
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
146 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
147 bmp_active_skin_reload(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
148 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
149 return bmp_active_skin_load(bmp_active_skin->path);
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 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
153 bmp_active_skin_load(const gchar * path)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
154 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
155 g_return_val_if_fail(bmp_active_skin != NULL, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
156
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
157 if (!skin_load(bmp_active_skin, path))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
158 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
159
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
160 skin_setup_masks(bmp_active_skin);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
161 draw_main_window(TRUE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
162 draw_playlist_window(TRUE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
163 draw_equalizer_window(TRUE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
164
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
165 vis_set_window(mainwin_vis, mainwin->window);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
166 playlistwin_update_list();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
167
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
168 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
169 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
170
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
171 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
172 skin_pixmap_free(SkinPixmap * p)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
173 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
174 g_return_if_fail(p != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
175 g_return_if_fail(p->pixmap != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
176
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
177 g_object_unref(p->pixmap);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
178 p->pixmap = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
179 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
180
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
181 Skin *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
182 skin_new(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
183 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
184 Skin *skin;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
185 skin = g_new0(Skin, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
186 skin->lock = g_mutex_new();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
187 return skin;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
188 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
189
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
190 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
191 skin_free(Skin * skin)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
192 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
193 gint i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
194
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
195 g_return_if_fail(skin != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
196
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
197 skin_lock(skin);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
198
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
199 for (i = 0; i < SKIN_PIXMAP_COUNT; i++)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
200 skin_pixmap_free(&skin->pixmaps[i]);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
201
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
202 for (i = 0; i < SKIN_PIXMAP_COUNT; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
203 if (skin->masks[i])
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
204 g_object_unref(skin->masks[i]);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
205
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
206 skin->masks[i] = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
207 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
208
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
209 skin_set_default_vis_color(skin);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
210 skin_unlock(skin);
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 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
214 skin_destroy(Skin * skin)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
215 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
216 g_return_if_fail(skin != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
217 skin_free(skin);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
218 g_mutex_free(skin->lock);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
219 g_free(skin);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
220 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
221
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
222 const SkinPixmapIdMapping *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
223 skin_pixmap_id_lookup(gint id)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
224 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
225 gint i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
226
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
227 for (i = 0; i < skin_pixmap_id_map_size; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
228 if (id == skin_pixmap_id_map[i].id) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
229 return &skin_pixmap_id_map[i];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
230 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
231 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
232
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
233 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
234 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
235
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
236 const gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
237 skin_pixmap_id_to_name(SkinPixmapId id)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
238 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
239 gint i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
240
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
241 for (i = 0; i < skin_pixmap_id_map_size; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
242 if (id == skin_pixmap_id_map[i].id)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
243 return skin_pixmap_id_map[i].name;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
244 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
245 return NULL;
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 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
249 skin_set_default_vis_color(Skin * skin)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
250 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
251 memcpy(skin->vis_color, skin_default_viscolor,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
252 sizeof(skin_default_viscolor));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
253 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
254
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
255 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
256 skin_pixmap_locate(const gchar * dirname, const gchar * basename,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
257 const gchar * alt_basename)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
258 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
259 gchar *filename;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
260
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
261 if (!(filename = find_file_recursively(dirname, basename))) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
262 g_warning(G_STRLOC ": couldn't locate %s in directory %s",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
263 basename, dirname);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
264 g_free(filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
265
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
266 if (alt_basename) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
267 g_message(G_STRLOC ": trying %s instead", alt_basename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
268 return skin_pixmap_locate(dirname, alt_basename, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
269 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
270 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
271
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
272 return filename;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
273 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
274
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
275 /* FIXME: this function is temporary. It will be removed when the skinning system
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
276 uses GdkPixbuf in place of GdkPixmap */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
277
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
278 static GdkPixmap *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
279 pixmap_new_from_file(const gchar * filename)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
280 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
281 GdkPixbuf *pixbuf;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
282 GdkPixmap *pixmap;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
283 gint width, height;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
284
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
285 if (!(pixbuf = gdk_pixbuf_new_from_file(filename, NULL)))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
286 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
287
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
288 width = gdk_pixbuf_get_width(pixbuf);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
289 height = gdk_pixbuf_get_height(pixbuf);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
290
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
291 if (!(pixmap = gdk_pixmap_new(mainwin->window, width, height,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
292 gdk_rgb_get_visual()->depth))) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
293 g_object_unref(pixbuf);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
294 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
295 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
296
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
297 gdk_pixbuf_render_to_drawable(pixbuf, pixmap, mainwin_gc, 0, 0, 0, 0,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
298 width, height, GDK_RGB_DITHER_MAX, 0, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
299 g_object_unref(pixbuf);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
300
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
301 return pixmap;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
302 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
303
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
304 static gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
305 skin_load_pixmap_id(Skin * skin, SkinPixmapId id, const gchar * path_p)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
306 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
307 const gchar *path;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
308 gchar *basename = NULL, *alt_basename = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
309 gchar *filename;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
310 gint width, height;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
311 const SkinPixmapIdMapping *pixmap_id_mapping;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
312 GdkPixmap *gpm;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
313 SkinPixmap *pm = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
314
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
315 g_return_val_if_fail(skin != NULL, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
316 g_return_val_if_fail(id < SKIN_PIXMAP_COUNT, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
317
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
318 pixmap_id_mapping = skin_pixmap_id_lookup(id);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
319 g_return_val_if_fail(pixmap_id_mapping != NULL, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
320
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
321 basename = g_strdup_printf("%s.bmp", pixmap_id_mapping->name);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
322 if (pixmap_id_mapping->alt_name)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
323 alt_basename = g_strdup_printf("%s.bmp", pixmap_id_mapping->alt_name);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
324
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
325 path = path_p ? path_p : skin->path;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
326 filename = skin_pixmap_locate(path, basename, alt_basename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
327 g_free(basename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
328 g_free(alt_basename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
329
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
330 if (!(gpm = pixmap_new_from_file(filename))) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
331 g_warning("loading of %s failed", filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
332 g_free(filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
333 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
334 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
335
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
336 g_free(filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
337
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
338 gdk_window_get_size(gpm, &width, &height);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
339 pm = &skin->pixmaps[id];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
340 pm->pixmap = gpm;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
341 pm->width = width;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
342 pm->height = height;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
343 pm->current_width = width;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
344 pm->current_height = height;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
345
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
346 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
347 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
348
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
349 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
350 skin_mask_create(Skin * skin,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
351 const gchar * path,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
352 gint id,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
353 GdkWindow * window)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
354 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
355 skin->masks[id] =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
356 skin_create_transparent_mask(path, "region.txt",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
357 skin_mask_info[id].inistr, window,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
358 skin_mask_info[id].width,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
359 skin_mask_info[id].height);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
360 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
361
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
362 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
363 skin_setup_masks(Skin * skin)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
364 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
365 GdkBitmap *mask;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
366
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
367 if (cfg.show_wm_decorations)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
368 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
369
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
370 if (cfg.player_visible) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
371 mask = skin_get_mask(skin, SKIN_MASK_MAIN + cfg.player_shaded);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
372 gtk_widget_shape_combine_mask(mainwin, mask, 0, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
373 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
374
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
375 mask = skin_get_mask(skin, SKIN_MASK_EQ + cfg.equalizer_shaded);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
376 gtk_widget_shape_combine_mask(equalizerwin, mask, 0, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
377 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
378
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
379 static GdkBitmap *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
380 create_default_mask(GdkWindow * parent, gint w, gint h)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
381 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
382 GdkBitmap *ret;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
383 GdkGC *gc;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
384 GdkColor pattern;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
385
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
386 ret = gdk_pixmap_new(parent, w, h, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
387 gc = gdk_gc_new(ret);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
388 pattern.pixel = 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
389 gdk_gc_set_foreground(gc, &pattern);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
390 gdk_draw_rectangle(ret, gc, TRUE, 0, 0, w, h);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
391 gdk_gc_destroy(gc);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
392
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
393 return ret;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
394 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
395
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
396 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
397 skin_query_color(GdkColormap * cm, GdkColor * c)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
398 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
399 XColor xc = { 0 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
400
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
401 xc.pixel = c->pixel;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
402 XQueryColor(GDK_COLORMAP_XDISPLAY(cm), GDK_COLORMAP_XCOLORMAP(cm), &xc);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
403 c->red = xc.red;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
404 c->green = xc.green;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
405 c->blue = xc.blue;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
406 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
407
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
408 static glong
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
409 skin_calc_luminance(GdkColor * c)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
410 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
411 return (0.212671 * c->red + 0.715160 * c->green + 0.072169 * c->blue);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
412 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
413
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
414 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
415 skin_get_textcolors(GdkPixmap * text, GdkColor * bgc, GdkColor * fgc)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
416 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
417 /*
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
418 * Try to extract reasonable background and foreground colors
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
419 * from the font pixmap
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
420 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
421
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
422 GdkImage *gi;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
423 GdkColormap *cm;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
424 gint i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
425
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
426 g_return_if_fail(text != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
427
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
428 /* Get the first line of text */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
429 gi = gdk_drawable_get_image(text, 0, 0, 152, 6);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
430 cm = gdk_window_get_colormap(playlistwin->window);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
431 g_return_if_fail(GDK_IS_WINDOW(playlistwin->window));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
432
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
433 for (i = 0; i < 6; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
434 GdkColor c;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
435 gint x;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
436 glong d, max_d;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
437
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
438 /* Get a pixel from the middle of the space character */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
439 bgc[i].pixel = gdk_image_get_pixel(gi, 151, i);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
440 skin_query_color(cm, &bgc[i]);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
441
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
442 max_d = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
443 for (x = 1; x < 150; x++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
444 c.pixel = gdk_image_get_pixel(gi, x, i);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
445 skin_query_color(cm, &c);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
446
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
447 d = labs(skin_calc_luminance(&c) - skin_calc_luminance(&bgc[i]));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
448 if (d > max_d) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
449 memcpy(&fgc[i], &c, sizeof(GdkColor));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
450 max_d = d;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
451 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
452 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
453 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
454 gdk_image_destroy(gi);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
455 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
456
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
457 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
458 init_skins(const gchar * path)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
459 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
460 bmp_active_skin = skin_new();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
461
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
462 if (!bmp_active_skin_load(path)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
463 /* FIXME: Oddly, g_message() causes a crash if path is NULL on
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
464 * Solaris (see bug #165) */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
465 if (path)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
466 g_message("Unable to load skin (%s), trying default...", path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
467
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
468 /* can't load configured skin, retry with default */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
469 if (!bmp_active_skin_load(BMP_DEFAULT_SKIN_PATH)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
470 g_message("Unable to load default skin (%s)! Giving up.",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
471 BMP_DEFAULT_SKIN_PATH);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
472 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
473 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
474 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
475
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
476 if (cfg.random_skin_on_play)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
477 skinlist_update();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
478
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
479 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
480 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
481
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
482 static guint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
483 hex_chars_to_int(gchar hi, gchar lo)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
484 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
485 /*
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
486 * Converts a value in the range 0x00-0xFF
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
487 * to a integer in the range 0-65535
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
488 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
489 gchar str[3];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
490
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
491 str[0] = hi;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
492 str[1] = lo;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
493 str[2] = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
494
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
495 return (CLAMP(strtol(str, NULL, 16), 0, 0xFF) << 8);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
496 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
497
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
498 GdkColor *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
499 skin_load_color(const gchar * path, const gchar * file,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
500 const gchar * section, const gchar * key)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
501 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
502 gchar *filename, *value;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
503 GdkColor *color = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
504
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
505 filename = find_file_recursively(path, file);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
506 if (filename) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
507 value = read_ini_string(filename, section, key);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
508 if (value) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
509 gchar *ptr = value;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
510 gint len;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
511
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
512 color = g_new0(GdkColor, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
513 g_strstrip(value);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
514
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
515 if (value[0] == '#')
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
516 ptr++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
517 len = strlen(ptr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
518
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
519 /*
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
520 * The handling of incomplete values is done this way
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
521 * to maximize winamp compatibility
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
522 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
523 if (len >= 6) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
524 color->red = hex_chars_to_int(*ptr, *(ptr + 1));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
525 ptr += 2;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
526 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
527 if (len >= 4) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
528 color->green = hex_chars_to_int(*ptr, *(ptr + 1));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
529 ptr += 2;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
530 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
531 if (len >= 2)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
532 color->blue = hex_chars_to_int(*ptr, *(ptr + 1));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
533
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
534
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
535 gdk_color_alloc(gdk_window_get_colormap(playlistwin->window),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
536 color);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
537 g_free(value);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
538 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
539 g_free(filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
540 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
541 return color;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
542 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
543
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
544
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
545
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
546 GdkBitmap *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
547 skin_create_transparent_mask(const gchar * path,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
548 const gchar * file,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
549 const gchar * section,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
550 GdkWindow * window,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
551 gint width,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
552 gint height)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
553 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
554 GdkBitmap *mask = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
555 GdkGC *gc = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
556 GdkColor pattern;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
557 GdkPoint *gpoints;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
558
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
559 gchar *filename = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
560 gboolean created_mask = FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
561 GArray *num, *point;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
562 gint i, j, k;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
563
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
564 if (path)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
565 filename = find_file_recursively(path, file);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
566
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
567 /* filename will be null if path wasn't set */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
568 if (!filename) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
569 return create_default_mask(window, width, height);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
570 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
571
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
572 if ((num = read_ini_array(filename, section, "NumPoints")) == NULL) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
573 g_free(filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
574 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
575 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
576
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
577 if ((point = read_ini_array(filename, section, "PointList")) == NULL) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
578 g_array_free(num, TRUE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
579 g_free(filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
580 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
581 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
582
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
583 mask = gdk_pixmap_new(window, width, height, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
584 gc = gdk_gc_new(mask);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
585
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
586 pattern.pixel = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
587 gdk_gc_set_foreground(gc, &pattern);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
588 gdk_draw_rectangle(mask, gc, TRUE, 0, 0, width, height);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
589 pattern.pixel = 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
590 gdk_gc_set_foreground(gc, &pattern);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
591
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
592 j = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
593 for (i = 0; i < num->len; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
594 if ((point->len - j) >= (g_array_index(num, gint, i) * 2)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
595 created_mask = TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
596 gpoints = g_new(GdkPoint, g_array_index(num, gint, i));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
597 for (k = 0; k < g_array_index(num, gint, i); k++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
598 gpoints[k].x = g_array_index(point, gint, j + k * 2);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
599 gpoints[k].y = g_array_index(point, gint, j + k * 2 + 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
600 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
601 j += k * 2;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
602 gdk_draw_polygon(mask, gc, TRUE, gpoints,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
603 g_array_index(num, gint, i));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
604 g_free(gpoints);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
605 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
606 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
607 g_array_free(num, TRUE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
608 g_array_free(point, TRUE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
609 g_free(filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
610
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
611 if (!created_mask)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
612 gdk_draw_rectangle(mask, gc, TRUE, 0, 0, width, height);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
613
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
614 gdk_gc_destroy(gc);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
615
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
616 return mask;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
617 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
618
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
619 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
620 skin_load_viscolor(Skin * skin, const gchar * path, const gchar * basename)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
621 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
622 FILE *file;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
623 gint i, c;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
624 gchar line[256], *filename;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
625 GArray *a;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
626
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
627 g_return_if_fail(skin != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
628 g_return_if_fail(path != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
629 g_return_if_fail(basename != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
630
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
631 skin_set_default_vis_color(skin);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
632
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
633 filename = find_file_recursively(path, basename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
634 if (!filename)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
635 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
636
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
637 if (!(file = fopen(filename, "r"))) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
638 g_free(filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
639 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
640 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
641
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
642 g_free(filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
643
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
644 for (i = 0; i < 24; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
645 if (fgets(line, 255, file)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
646 a = string_to_garray(line);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
647 if (a->len > 2) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
648 for (c = 0; c < 3; c++)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
649 skin->vis_color[i][c] = g_array_index(a, gint, c);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
650 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
651 g_array_free(a, TRUE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
652 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
653 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
654 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
655 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
656
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
657 fclose(file);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
658 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
659
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
660 #if 0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
661 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
662 skin_numbers_generate_dash(Skin * skin)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
663 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
664 GdkGC *gc;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
665 GdkPixmap *pixmap;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
666 SkinPixmap *numbers;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
667
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
668 g_return_if_fail(skin != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
669
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
670 numbers = &skin->pixmaps[SKIN_NUMBERS];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
671 if (!numbers->pixmap || numbers->current_width < 99)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
672 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
673
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
674 gc = gdk_gc_new(numbers->pixmap);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
675 pixmap = gdk_pixmap_new(mainwin->window, 108,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
676 numbers->current_height,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
677 -1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
678
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
679 skin_draw_pixmap(skin, pixmap, gc, SKIN_NUMBERS, 0, 0, 0, 0, 99, 13);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
680 skin_draw_pixmap(skin, pixmap, gc, SKIN_NUMBERS, 90, 0, 99, 0, 9, 13);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
681 skin_draw_pixmap(skin, pixmap, gc, SKIN_NUMBERS, 20, 6, 101, 6, 5, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
682
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
683 g_object_unref(numbers->pixmap);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
684 g_object_unref(gc);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
685
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
686 numbers->pixmap = pixmap;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
687 numbers->current_width = 108;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
688 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
689 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
690
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
691 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
692 skin_load_cursor(Skin * skin, const gchar * dirname)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
693 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
694 const gchar * basename = "normal.cur";
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
695 gchar * filename = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
696 GdkPixbuf * cursor_pixbuf = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
697 GdkPixbufAnimation * cursor_animated = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
698 GdkCursor * cursor_gdk = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
699 GError * error = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
700
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
701 filename = find_file_recursively(dirname, basename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
702
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
703 if (filename && cfg.custom_cursors) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
704 cursor_animated = gdk_pixbuf_animation_new_from_file(filename, &error);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
705 cursor_pixbuf = gdk_pixbuf_animation_get_static_image(cursor_animated);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
706 cursor_gdk = gdk_cursor_new_from_pixbuf(gdk_display_get_default(),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
707 cursor_pixbuf, 0, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
708 } else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
709 cursor_gdk = gdk_cursor_new(GDK_LEFT_PTR);
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 gdk_window_set_cursor(mainwin->window, cursor_gdk);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
713 gdk_window_set_cursor(playlistwin->window, cursor_gdk);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
714 gdk_window_set_cursor(equalizerwin->window, cursor_gdk);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
715 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
716
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
717 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
718 skin_load_pixmaps(Skin * skin, const gchar * path)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
719 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
720 GdkPixmap *text_pm;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
721 guint i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
722
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
723 for (i = 0; i < SKIN_PIXMAP_COUNT; i++)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
724 skin_load_pixmap_id(skin, i, path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
725
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
726 text_pm = skin->pixmaps[SKIN_TEXT].pixmap;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
727
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
728 if (text_pm)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
729 skin_get_textcolors(text_pm, skin->textbg, skin->textfg);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
730
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
731 #if 0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
732 if (skin->pixmaps[SKIN_NUMBERS].pixmap)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
733 skin_numbers_generate_dash(skin);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
734 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
735
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
736 skin->colors[SKIN_PLEDIT_NORMAL] =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
737 skin_load_color(path, "pledit.txt", "text", "normal");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
738 skin->colors[SKIN_PLEDIT_CURRENT] =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
739 skin_load_color(path, "pledit.txt", "text", "current");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
740 skin->colors[SKIN_PLEDIT_NORMALBG] =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
741 skin_load_color(path, "pledit.txt", "text", "normalbg");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
742 skin->colors[SKIN_PLEDIT_SELECTEDBG] =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
743 skin_load_color(path, "pledit.txt", "text", "selectedbg");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
744
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
745 skin_mask_create(skin, path, SKIN_MASK_MAIN, mainwin->window);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
746 skin_mask_create(skin, path, SKIN_MASK_MAIN_SHADE, mainwin->window);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
747
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
748 skin_mask_create(skin, path, SKIN_MASK_EQ, equalizerwin->window);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
749 skin_mask_create(skin, path, SKIN_MASK_EQ_SHADE, equalizerwin->window);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
750
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
751 skin_load_viscolor(skin, path, "viscolor.txt");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
752 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
753
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
754 static gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
755 skin_load_nolock(Skin * skin, const gchar * path, gboolean force)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
756 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
757 gchar *cpath;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
758
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
759 g_return_val_if_fail(skin != NULL, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
760 g_return_val_if_fail(path != NULL, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
761 REQUIRE_LOCK(skin->lock);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
762
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
763 if (!g_file_test(path, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_DIR))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
764 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
765
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
766 if (!force) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
767 if (skin->path)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
768 if (!strcmp(skin->path, path))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
769 return FALSE;
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 skin_current_num++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
773
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
774 skin->path = g_strdup(path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
775
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
776
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
777 if (!file_is_archive(path)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
778 skin_load_pixmaps(skin, path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
779 skin_load_cursor(skin, path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
780 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
781 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
782
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
783 if (!(cpath = archive_decompress(path))) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
784 g_message("Unable to extract skin archive (%s)", path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
785 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
786 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
787
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
788 skin_load_pixmaps(skin, cpath);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
789 skin_load_cursor(skin, cpath);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
790 del_directory(cpath);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
791 g_free(cpath);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
792
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
793 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
794 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
795
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
796 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
797 skin_install_skin(const gchar * path)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
798 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
799 gchar *command;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
800
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
801 g_return_if_fail(path != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
802
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
803 command = g_strdup_printf("cp %s %s", path, bmp_paths[BMP_PATH_USER_SKIN_DIR]);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
804 if (system(command)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
805 g_message("Unable to install skin (%s) into user directory (%s)",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
806 path, bmp_paths[BMP_PATH_USER_SKIN_DIR]);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
807 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
808 g_free(command);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
809 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
810
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
811
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
812 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
813 skin_load(Skin * skin, const gchar * path)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
814 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
815 gboolean error;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
816
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
817 g_return_val_if_fail(skin != NULL, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
818 g_return_val_if_fail(path != NULL, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
819
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
820 skin_lock(skin);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
821 error = skin_load_nolock(skin, path, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
822 skin_unlock(skin);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
823
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
824 return error;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
825 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
826
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
827 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
828 skin_reload_forced(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
829 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
830 gboolean error;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
831
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
832 skin_lock(bmp_active_skin);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
833 error = skin_load_nolock(bmp_active_skin, bmp_active_skin->path, TRUE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
834 skin_unlock(bmp_active_skin);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
835
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
836 return error;
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 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
840 skin_reload(Skin * skin)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
841 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
842 g_return_if_fail(skin != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
843 skin_load_nolock(skin, skin->path, TRUE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
844 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
845
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
846
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
847 static SkinPixmap *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
848 skin_get_pixmap(Skin * skin, SkinPixmapId map_id)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
849 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
850 g_return_val_if_fail(skin != NULL, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
851 g_return_val_if_fail(map_id < SKIN_PIXMAP_COUNT, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
852
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
853 return &skin->pixmaps[map_id];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
854 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
855
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
856 GdkBitmap *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
857 skin_get_mask(Skin * skin, SkinMaskId mi)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
858 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
859 g_return_val_if_fail(skin != NULL, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
860 g_return_val_if_fail(mi < SKIN_PIXMAP_COUNT, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
861
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
862 return skin->masks[mi];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
863 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
864
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
865 GdkColor *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
866 skin_get_color(Skin * skin, SkinColorId color_id)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
867 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
868 GdkColor *ret = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
869
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
870 g_return_val_if_fail(skin != NULL, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
871
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
872 switch (color_id) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
873 case SKIN_TEXTBG:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
874 if (skin->pixmaps[SKIN_TEXT].pixmap)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
875 ret = skin->textbg;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
876 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
877 ret = skin->def_textbg;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
878 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
879 case SKIN_TEXTFG:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
880 if (skin->pixmaps[SKIN_TEXT].pixmap)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
881 ret = skin->textfg;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
882 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
883 ret = skin->def_textfg;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
884 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
885 default:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
886 if (color_id < SKIN_COLOR_COUNT)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
887 ret = skin->colors[color_id];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
888 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
889 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
890 return ret;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
891 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
892
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
893 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
894 skin_get_viscolor(Skin * skin, guchar vis_color[24][3])
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
895 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
896 gint i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
897
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
898 g_return_if_fail(skin != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
899
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
900 for (i = 0; i < 24; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
901 vis_color[i][0] = skin->vis_color[i][0];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
902 vis_color[i][1] = skin->vis_color[i][1];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
903 vis_color[i][2] = skin->vis_color[i][2];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
904 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
905 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
906
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
907 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
908 skin_get_id(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
909 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
910 return skin_current_num;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
911 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
912
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
913 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
914 skin_draw_pixmap(Skin * skin, GdkDrawable * drawable, GdkGC * gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
915 SkinPixmapId pixmap_id,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
916 gint xsrc, gint ysrc, gint xdest, gint ydest,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
917 gint width, gint height)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
918 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
919 SkinPixmap *pixmap;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
920
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
921 g_return_if_fail(skin != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
922
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
923 pixmap = skin_get_pixmap(skin, pixmap_id);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
924 g_return_if_fail(pixmap != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
925 g_return_if_fail(pixmap->pixmap != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
926
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
927 if (xsrc > pixmap->width || ysrc > pixmap->height)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
928 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
929
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
930 width = MIN(width, pixmap->width - xsrc);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
931 height = MIN(height, pixmap->height - ysrc);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
932 gdk_draw_pixmap(drawable, gc, pixmap->pixmap, xsrc, ysrc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
933 xdest, ydest, width, height);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
934 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
935
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
936 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
937 skin_get_eq_spline_colors(Skin * skin, guint32 colors[19])
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
938 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
939 gint i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
940 GdkPixmap *pixmap;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
941 GdkImage *img;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
942 SkinPixmap *eqmainpm;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
943
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
944 g_return_if_fail(skin != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
945
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
946 eqmainpm = &skin->pixmaps[SKIN_EQMAIN];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
947 if (eqmainpm->pixmap &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
948 eqmainpm->current_width >= 116 && eqmainpm->current_height >= 313)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
949 pixmap = eqmainpm->pixmap;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
950 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
951 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
952
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
953 if (!GDK_IS_DRAWABLE(pixmap))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
954 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
955
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
956 if (!(img = gdk_drawable_get_image(pixmap, 115, 294, 1, 19)))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
957 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
958
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
959 for (i = 0; i < 19; i++)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
960 colors[i] = gdk_image_get_pixel(img, 0, i);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
961
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
962 gdk_image_destroy(img);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
963 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
964
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
965
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
966 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
967 skin_draw_playlistwin_frame_top(Skin * skin,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
968 GdkDrawable * drawable,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
969 GdkGC * gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
970 gint width, gint height, gboolean focus)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
971 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
972 /* The title bar skin consists of 2 sets of 4 images, 1 set
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
973 * for focused state and the other for unfocused. The 4 images
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
974 * are:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
975 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
976 * a. right corner (25,20)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
977 * b. left corner (25,20)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
978 * c. tiler (25,20)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
979 * d. title (100,20)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
980 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
981 * min allowed width = 100+25+25 = 150
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
982 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
983
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
984 gint i, y, c;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
985
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
986 /* get y offset of the pixmap set to use */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
987 if (focus)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
988 y = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
989 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
990 y = 21;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
991
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
992 /* left corner */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
993 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 0, y, 0, 0, 25, 20);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
994
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
995 /* titlebar title */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
996 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 26, y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
997 (width - 100) / 2, 0, 100, 20);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
998
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
999 /* titlebar right corner */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1000 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 153, y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1001 width - 25, 0, 25, 20);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1002
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1003 /* tile draw the remaining frame */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1004
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1005 /* compute tile count */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1006 c = (width - (100 + 25 + 25)) / 25;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1007
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1008 for (i = 0; i < c / 2; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1009 /* left of title */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1010 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 127, y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1011 25 + i * 25, 0, 25, 20);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1012
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1013 /* right of title */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1014 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 127, y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1015 (width + 100) / 2 + i * 25, 0, 25, 20);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1016 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1017
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1018 if (c & 1) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1019 /* Odd tile count, so one remaining to draw. Here we split
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1020 * it into two and draw half on either side of the title */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1021 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 127, y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1022 ((c / 2) * 25) + 25, 0, 12, 20);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1023 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 127, y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1024 (width / 2) + ((c / 2) * 25) + 50, 0, 13, 20);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1025 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1026 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1027
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1028 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1029 skin_draw_playlistwin_frame_bottom(Skin * skin,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1030 GdkDrawable * drawable,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1031 GdkGC * gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1032 gint width, gint height, gboolean focus)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1033 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1034 /* The bottom frame skin consists of 1 set of 4 images. The 4
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1035 * images are:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1036 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1037 * a. left corner with menu buttons (125,38)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1038 * b. visualization window (75,38)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1039 * c. right corner with play buttons (150,38)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1040 * d. frame tile (25,38)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1041 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1042 * (min allowed width = 125+150+25=300
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1043 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1044
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1045 gint i, c;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1046
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1047 /* bottom left corner (menu buttons) */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1048 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 0, 72,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1049 0, height - 38, 125, 38);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1050
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1051 c = (width - 275) / 25;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1052
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1053 /* draw visualization window, if width allows */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1054 if (c >= 3) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1055 c -= 3;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1056 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 205, 0,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1057 width - (150 + 75), height - 38, 75, 38);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1058 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1059
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1060 /* Bottom right corner (playbuttons etc) */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1061 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1062 126, 72, width - 150, height - 38, 150, 38);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1063
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1064 /* Tile draw the remaining undrawn portions */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1065 for (i = 0; i < c; i++)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1066 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 179, 0,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1067 125 + i * 25, height - 38, 25, 38);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1068 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1069
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1070 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1071 skin_draw_playlistwin_frame_sides(Skin * skin,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1072 GdkDrawable * drawable,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1073 GdkGC * gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1074 gint width, gint height, gboolean focus)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1075 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1076 /* The side frames consist of 2 tile images. 1 for the left, 1 for
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1077 * the right.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1078 * a. left (12,29)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1079 * b. right (19,29)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1080 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1081
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1082 gint i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1083
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1084 /* frame sides */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1085 for (i = 0; i < (height - (20 + 38)) / 29; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1086 /* left */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1087 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 0, 42,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1088 0, 20 + i * 29, 12, 29);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1089
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1090 /* right */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1091 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 32, 42,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1092 width - 19, 20 + i * 29, 19, 29);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1093 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1094 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1095
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1096
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1097 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1098 skin_draw_playlistwin_frame(Skin * skin,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1099 GdkDrawable * drawable, GdkGC * gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1100 gint width, gint height, gboolean focus)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1101 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1102 skin_draw_playlistwin_frame_top(skin, drawable, gc, width, height, focus);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1103 skin_draw_playlistwin_frame_bottom(skin, drawable, gc, width, height,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1104 focus);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1105 skin_draw_playlistwin_frame_sides(skin, drawable, gc, width, height,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1106 focus);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1107 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1108
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1109
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1110 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1111 skin_draw_playlistwin_shaded(Skin * skin,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1112 GdkDrawable * drawable, GdkGC * gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1113 gint width, gboolean focus)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1114 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1115 /* The shade mode titlebar skin consists of 4 images:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1116 * a) left corner offset (72,42) size (25,14)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1117 * b) right corner, focused offset (99,57) size (50,14)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1118 * c) right corner, unfocused offset (99,42) size (50,14)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1119 * d) bar tile offset (72,57) size (25,14)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1120 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1121
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1122 gint i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1123
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1124 /* left corner */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1125 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 72, 42, 0, 0, 25, 14);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1126
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1127 /* bar tile */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1128 for (i = 0; i < (width - 75) / 25; i++)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1129 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 72, 57,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1130 (i * 25) + 25, 0, 25, 14);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1131
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1132 /* right corner */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1133 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 99, focus ? 57 : 42,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1134 width - 50, 0, 50, 14);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1135 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1136
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1137
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1138 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1139 skin_draw_mainwin_titlebar(Skin * skin,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1140 GdkDrawable * drawable, GdkGC * gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1141 gboolean shaded, gboolean focus)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1142 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1143 /* The titlebar skin consists of 2 sets of 2 images, one for for
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1144 * shaded and the other for unshaded mode, giving a total of 4.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1145 * The images are exactly 275x14 pixels, aligned and arranged
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1146 * vertically on each other in the pixmap in the following order:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1147 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1148 * a) unshaded, focused offset (27, 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1149 * b) unshaded, unfocused offset (27, 15)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1150 * c) shaded, focused offset (27, 29)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1151 * d) shaded, unfocused offset (27, 42)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1152 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1153
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1154 gint y_offset;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1155
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1156 if (shaded) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1157 if (focus)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1158 y_offset = 29;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1159 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1160 y_offset = 42;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1161 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1162 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1163 if (focus)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1164 y_offset = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1165 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1166 y_offset = 15;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1167 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1168
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1169 skin_draw_pixmap(skin, drawable, gc, SKIN_TITLEBAR, 27, y_offset,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1170 0, 0, MAINWIN_WIDTH, MAINWIN_TITLEBAR_HEIGHT);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1171 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1172
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1173 #if 0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1174 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1175 skin_draw_mainwin(Skin * skin,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1176 GdkDrawable * drawable, GdkGC gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1177 gboolean doublesize, gboolean shaded, gboolean focus)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1178 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1179
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1180 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1181 #endif