1 /*
2 * (SLIK) SimpLIstic sKin functions
3 * (C) 2002 John Ellis
4 *
5 * Author: John Ellis
6 *
7 * This software is released under the GNU General Public License (GNU GPL).
8 * Please read the included file COPYING for more information.
9 * This software comes with no warranty of any kind, use at your own risk!
10 */
11
12 #include "gqradio.h"
13 #include "skin.h"
14
15 #include "ui2_button.h"
16 #include "ui2_item.h"
17 #include "ui2_main.h"
18 #include "ui2_parse.h"
19 #include "ui2_skin.h"
20 #include "ui2_text.h"
21 #include "ui2_util.h"
22 #include "ui2_widget.h"
23
24
25 #include "default_skin/nf_back.xpm"
26 #include "default_skin/nf_btn_prefs.xpm"
27 #include "default_skin/nf_btn_quit.xpm"
28
29
add_button(const gchar * key,gchar ** data,gint prelight,gint light,gint x,gint y,gchar ** clip_data,SkinData * skin,const gchar * text_id)30 static WidgetData *add_button(const gchar *key, gchar **data, gint prelight, gint light, gint x, gint y,
31 gchar **clip_data, SkinData *skin, const gchar *text_id)
32 {
33 ButtonData *button;
34
35 button = button_new_from_data(data, x, y, prelight, light, clip_data);
36 return button_register(skin, button, key, text_id);
37 }
38
add_text(const gchar * key,const gchar * font,gint width,gint sizeable,guint8 r,guint8 g,guint8 b,guint8 a,gint x,gint y,SkinData * skin,const gchar * text_id)39 static WidgetData *add_text(const gchar *key, const gchar *font, gint width, gint sizeable,
40 guint8 r, guint8 g, guint8 b, guint8 a,
41 gint x, gint y, SkinData *skin, const gchar *text_id)
42 {
43 TextData *text;
44
45 text = text_new_from_x(font, x, y, width, sizeable, 0);
46 text_set_color(text, r, g, b, a);
47 return text_register(skin, text, key, text_id);
48 }
49
skin_message(const gchar * message1,const gchar * message2)50 static SkinData *skin_message(const gchar *message1, const gchar *message2)
51 {
52 SkinData *skin;
53 WidgetData *wd;
54
55 skin = skin_new();
56
57 skin->real_overlay = util_size_pixbuf(gdk_pixbuf_new_from_xpm_data((const char **)nf_back_xpm), TRUE);
58 skin->border_top = 22;
59 skin->border_bottom = 46;
60 skin->border_left = 60;
61 skin->border_right = 15;
62 skin->has_border = TRUE;
63 skin->width = 280;
64 skin->height = 96;
65
66 add_button("config", (gchar **)nf_btn_prefs_xpm, FALSE, FALSE, 210, 59, NULL, skin, NULL);
67 add_button("exit", (gchar **)nf_btn_quit_xpm, FALSE, FALSE, 143, 59, NULL, skin, NULL);
68
69 wd = add_text("message1", "-*-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*", 252, TRUE, 0, 0, 0, 179, 13, 19, skin, NULL);
70 ui_widget_set_data(wd, "data", message1);
71 wd = add_text("message2", "-*-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*", 252, TRUE, 0, 0, 0, 179, 13, 35, skin, NULL);
72 ui_widget_set_data(wd, "data", message2);
73
74 skin->width_def = skin->width_min = skin->width_max = skin->width;
75 skin->height_def = skin->height_min = skin->height_max = skin->height;
76
77 return skin;
78 }
79
skin_load_default_cb(UIData * ui,const gchar * key,gpointer data)80 SkinData *skin_load_default_cb(UIData *ui, const gchar *key, gpointer data)
81 {
82 SkinData *skin;
83 gchar *datafile;
84
85 if (!key) key = "skindata";
86
87 datafile = g_strconcat(GQRADIO_SKIN_DEFAULT, "/", key, NULL);
88 skin = skin_parse(GQRADIO_SKIN_DEFAULT, datafile, TRUE);
89 g_free(datafile);
90
91 if (!skin) skin = skin_message(_("Default skin not found:"), GQRADIO_SKIN_DEFAULT);
92
93 return skin;
94 }
95
ui_set_message(UIData * ui,const gchar * path,const gchar * key,const gchar * message1,const gchar * message2)96 void ui_set_message(UIData *ui, const gchar *path, const gchar *key,
97 const gchar *message1, const gchar *message2)
98 {
99 SkinData *skin;
100
101 skin = NULL;
102 if (!key) key = "skindata_dialog";
103
104 if (path)
105 {
106 gchar *datafile;
107
108 datafile = g_strconcat(path, "/", key, NULL);
109 skin = skin_parse(path, datafile, TRUE);
110 g_free(datafile);
111 }
112
113 if (skin)
114 {
115 text_set_text("message1", ui, message1);
116 text_set_text("message2", ui, message2);
117 }
118 else
119 {
120 skin = skin_message(message1, message2);
121 }
122
123 ui_skin_set(ui, skin, path, NULL);
124 }
125
126