grim/guifications3
Clone
Summary
Browse
Changes
Graph
moved all of our enum junk to use glib-mkenums.
org.guifications.gf3
2009-10-10, Gary Kramlich
0b5513f16fc8
moved all of our enum junk to use glib-mkenums.
This has cleaned up a bunch of duplicated crap as well as gotten me to finally document the enums.
Also, due to the way glib-mkenums works, we had to change the GEnumValue member we use for i18n support from the name to the nick.
#include
<glib.h>
#include
<gflib/gf_lib.h>
static
void
gf_gen_hierarchy_start_object
(
const
GTypeQuery
*
query
)
{
GType
parent
=
g_type_parent
(
query
->
type
);
guint
depth
=
g_type_depth
(
query
->
type
);
printf
(
"
\t
<object name=
\"
%s
\"
parent=
\"
%s
\"
class_size=
\"
%u
\"
"
"instance_size=
\"
%u
\"
depth=
\"
%u
\"
>
\n
"
,
query
->
type_name
,
g_type_name
(
parent
),
query
->
class_size
,
query
->
instance_size
,
depth
);
}
static
void
gf_gen_hierarchy_end_object
(
const
GTypeQuery
*
query
)
{
printf
(
"
\t
</object>
\n
"
);
}
static
void
gf_gen_hierarchy_param
(
const
GParamSpec
*
pspec
)
{
printf
(
"
\t\t
<param name=
\"
%s
\"
flags=
\"
%d
\"
value_type=
\"
%s
\"
>
\n
"
,
pspec
->
name
,
pspec
->
flags
,
g_type_name
(
pspec
->
value_type
));
printf
(
"
\t\t\t
<nick>%s</nick>
\n
"
,
g_param_spec_get_nick
(
pspec
));
printf
(
"
\t\t\t
<blurb>%s</blurb>
\n
"
,
g_param_spec_get_blurb
(
pspec
));
printf
(
"
\t\t
</param>
\n
"
);
}
static
void
gf_gen_hierarchy_signal
(
const
GSignalQuery
*
query
)
{
guint
p
;
printf
(
"
\t\t
<signal name=
\"
%s
\"
flags=
\"
%d
\"
return_type=
\"
%s
\"
"
"n_params=
\"
%d
\"
"
,
query
->
signal_name
,
query
->
signal_flags
,
g_type_name
(
query
->
return_type
),
query
->
n_params
);
if
(
query
->
n_params
>
0
)
{
printf
(
">
\n
"
);
for
(
p
=
0
;
p
<
query
->
n_params
;
p
++
)
{
const
gchar
*
name
=
g_type_name
(
query
->
param_types
[
p
]);
printf
(
"
\t\t\t
<param type=
\"
%s
\"
/>
\n
"
,
name
);
}
printf
(
"
\t\t
</signal>
\n
"
);
}
else
{
printf
(
"/>
\n
"
);
}
}
static
GfTypeParser
parser
=
{
gf_gen_hierarchy_start_object
,
gf_gen_hierarchy_end_object
,
gf_gen_hierarchy_param
,
gf_gen_hierarchy_signal
,
};
gint
main
(
gint
argc
,
gchar
**
argv
)
{
GfTypeParseContext
*
tctx
=
NULL
;
GOptionContext
*
octx
=
NULL
;
octx
=
g_option_context_new
(
NULL
);
g_option_context_add_group
(
octx
,
gf_get_option_group
());
g_option_context_parse
(
octx
,
&
argc
,
&
argv
,
NULL
);
gf_lib_init
(
&
argc
,
&
argv
);
tctx
=
gf_type_parse_context_new
(
&
parser
,
NULL
,
NULL
);
printf
(
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>
\n
"
);
printf
(
"<objects>
\n
"
);
gf_type_parse_context_parse
(
tctx
,
GF_TYPE_OBJECT
);
g_object_unref
(
tctx
);
printf
(
"</objects>
\n
"
);
return
0
;
}