[GObject, long] Gtype for enum + runtime init or by init function.
- From: Uzytkownik <uzytkownik2 poczta onet pl>
- To: gtk-app-devel-list gnome org
- Subject: [GObject, long] Gtype for enum + runtime init or by init function.
- Date: Wed, 22 Jun 2005 22:13:29 +0200
1. In g_param_spec_enum I must have GType of this enum.
a) Why this function need it?
b) How create for enum GType?
2. I should register GType in package_name_get_type or
package_class_init:
a)
GType package_name_get_type() {
static GType type = 0;
if(type == 0) {
static const GTypeInfo info = {
sizeof(PackageNameClass),
(GBaseInitFunc)NULL,
(GBaseFinalizeFunc)NULL,
(GClassInitFunc)package_name_class_init,
(GClassFinalizeFunc)NULL,
(gconstpointer)NULL,
sizeof(PackageName),
0,
(GInstanceInitFunc)package_name_init
};
type = g_type_register_static(G_TYPE_OBJECT, "PackageName", &info, 0);
}
return type;
}
b)
static GType package_name_type;
GType package_name_get_type() {
return package_name_type;
}
void package_name_init() {
static const GTypeInfo info = {
sizeof(PackageNameClass),
(GBaseInitFunc)NULL,
(GBaseFinalizeFunc)NULL,
(GClassInitFunc)package_name_class_init,
(GClassFinalizeFunc)NULL,
(gconstpointer)NULL,
sizeof(PackageName),
0,
(GInstanceInitFunc)package_name_init
};
package_name_type = g_type_register_static(G_TYPE_OBJECT,
"PackageName", &info, 0);
}
void package_init() {
//(...)
package_name_init();
}
Thanks in advance.
Regards
--
Linux user: #376500 (patrz http://counter.li.org/)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]