annotate audacious/skin.c @ 1414:ff637a82e85f trunk

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