grim/guifications1
Clone
Summary
Browse
Changes
Graph
compiles on windows now, crashes at startup though. Updated README to let people know about gaim pre 0.75 support being dropped
2004-01-02, grim
cce21470e16b
compiles on windows now, crashes at startup though. Updated README to let people know about gaim pre 0.75 support being dropped
#include
<gtk/gtk.h>
#include
<stdlib.h>
#include
"xmlnode.h"
#include
"gf_theme.h"
static
void
process_theme_info
(
xmlnode
*
node
,
gchar
**
info
)
{
xmlnode
*
child
;
child
=
xmlnode_get_child
(
node
,
"name"
);
info
[
0
]
=
g_strdup
(
xmlnode_get_attrib
(
child
,
"value"
));
child
=
xmlnode_get_child
(
node
,
"version"
);
info
[
1
]
=
g_strdup
(
xmlnode_get_attrib
(
child
,
"value"
));
child
=
xmlnode_get_child
(
node
,
"description"
);
info
[
2
]
=
g_strdup
(
xmlnode_get_attrib
(
child
,
"value"
));
child
=
xmlnode_get_child
(
node
,
"author"
);
info
[
3
]
=
g_strdup
(
xmlnode_get_attrib
(
child
,
"value"
));
child
=
xmlnode_get_child
(
node
,
"website"
);
info
[
4
]
=
g_strdup
(
xmlnode_get_attrib
(
child
,
"value"
));
}
static
void
process_basic_theme
(
xmlnode
*
node
,
gf_basic_theme
*
basic
)
{
xmlnode
*
parent
,
*
child
;
/* image */
parent
=
xmlnode_get_child
(
node
,
"image"
);
basic
->
image
=
g_strdup
(
xmlnode_get_attrib
(
parent
,
"value"
));
/* text */
parent
=
xmlnode_get_child
(
node
,
"text"
);
child
=
xmlnode_get_child
(
parent
,
"font"
);
basic
->
text_custom_font
=
atoi
(
xmlnode_get_attrib
(
child
,
"custom"
));
basic
->
text_font
=
g_strdup
(
xmlnode_get_attrib
(
child
,
"value"
));
child
=
xmlnode_get_child
(
parent
,
"color"
);
basic
->
text_custom_color
=
atoi
(
xmlnode_get_attrib
(
child
,
"custom"
));
basic
->
text_color
=
g_strdup
(
xmlnode_get_attrib
(
child
,
"value"
));
child
=
xmlnode_get_child
(
parent
,
"clipping"
);
basic
->
text_clipping
=
atoi
(
xmlnode_get_attrib
(
child
,
"value"
));
child
=
xmlnode_get_child
(
parent
,
"position"
);
basic
->
text_position
=
atoi
(
xmlnode_get_attrib
(
child
,
"value"
));
child
=
xmlnode_get_child
(
parent
,
"offset"
);
basic
->
text_horz_offset
=
atoi
(
xmlnode_get_attrib
(
child
,
"horizontal"
));
basic
->
text_vert_offset
=
atoi
(
xmlnode_get_attrib
(
child
,
"vertical"
));
/* icon */
parent
=
xmlnode_get_child
(
node
,
"icon"
);
child
=
xmlnode_get_child
(
parent
,
"position"
);
basic
->
proto_position
=
atoi
(
xmlnode_get_attrib
(
child
,
"value"
));
child
=
xmlnode_get_child
(
parent
,
"size"
);
basic
->
proto_size
=
atoi
(
xmlnode_get_attrib
(
child
,
"value"
));
child
=
xmlnode_get_child
(
parent
,
"offset"
);
basic
->
proto_horz_offset
=
atoi
(
xmlnode_get_attrib
(
child
,
"horizontal"
));
basic
->
proto_vert_offset
=
atoi
(
xmlnode_get_attrib
(
child
,
"vertical"
));
/* messages */
parent
=
xmlnode_get_child
(
node
,
"messages"
);
child
=
xmlnode_get_child
(
parent
,
"signon"
);
basic
->
messages
[
0
]
=
g_strdup
(
xmlnode_get_attrib
(
child
,
"value"
));
child
=
xmlnode_get_child
(
parent
,
"signoff"
);
basic
->
messages
[
1
]
=
g_strdup
(
xmlnode_get_attrib
(
child
,
"value"
));
child
=
xmlnode_get_child
(
parent
,
"away"
);
basic
->
messages
[
2
]
=
g_strdup
(
xmlnode_get_attrib
(
child
,
"value"
));
child
=
xmlnode_get_child
(
parent
,
"back"
);
basic
->
messages
[
3
]
=
g_strdup
(
xmlnode_get_attrib
(
child
,
"value"
));
child
=
xmlnode_get_child
(
parent
,
"idle"
);
basic
->
messages
[
4
]
=
g_strdup
(
xmlnode_get_attrib
(
child
,
"value"
));
child
=
xmlnode_get_child
(
parent
,
"unidle"
);
basic
->
messages
[
5
]
=
g_strdup
(
xmlnode_get_attrib
(
child
,
"value"
));
/* done */
}
gboolean
read_theme
(
gchar
*
path
,
gf_theme
*
theme
,
gchar
**
error
)
{
GError
*
gerror
;
xmlnode
*
node
,
*
parent
,
*
child
;
gchar
*
file
,
*
contents
;
gint
length
;
file
=
g_strdup_printf
(
"%s%stheme.xml"
,
path
,
G_DIR_SEPARATOR_S
);
if
(
!
g_file_get_contents
(
file
,
&
contents
,
&
length
,
&
gerror
))
{
if
((
*
error
)
!=
NULL
)
(
*
error
)
=
g_strdup
(
gerror
->
message
);
g_error_free
(
gerror
);
g_free
(
file
);
return
FALSE
;
}
g_free
(
file
);
node
=
xmlnode_from_str
(
contents
,
length
);
if
(
!
node
)
{
if
((
*
error
)
!=
NULL
)
(
*
error
)
=
g_strdup
(
"Error parsing theme"
);
return
FALSE
;
}
parent
=
xmlnode_get_child
(
node
,
"info"
);
if
(
parent
)
{
child
=
xmlnode_get_child
(
parent
,
"type"
);
theme
->
type
=
atoi
(
xmlnode_get_attrib
(
child
,
"value"
));
process_theme_info
(
parent
,
theme
->
info
);
}
if
(
theme
->
type
==
gf_theme_type_basic
)
{
parent
=
xmlnode_get_child
(
node
,
"basic"
);
if
(
parent
)
process_basic_theme
(
parent
,
&
theme
->
data
.
basic
);
}
else
if
(
theme
->
type
==
gf_theme_type_advanced
)
{
}
return
TRUE
;
}