diff --git a/bus/connection.c b/bus/connection.c index a1411910..c1f6fcd9 100644 --- a/bus/connection.c +++ b/bus/connection.c @@ -34,7 +34,6 @@ typedef struct _BusConnectionPrivate BusConnectionPrivate; // static guint _signals[LAST_SIGNAL] = { 0 }; /* functions prototype */ -static void bus_connection_init (BusConnection *connection); static void bus_connection_destroy (BusConnection *connection); static gboolean bus_connection_authenticate_unix_user (IBusConnection *connection, diff --git a/bus/dbusimpl.c b/bus/dbusimpl.c index a82b13d8..89a788c2 100644 --- a/bus/dbusimpl.c +++ b/bus/dbusimpl.c @@ -40,7 +40,6 @@ enum { static guint dbus_signals[LAST_SIGNAL] = { 0 }; /* functions prototype */ -static void bus_dbus_impl_init (BusDBusImpl *dbus); static void bus_dbus_impl_destroy (BusDBusImpl *dbus); static gboolean bus_dbus_impl_ibus_message (BusDBusImpl *dbus, BusConnection *connection, diff --git a/bus/engineproxy.c b/bus/engineproxy.c index e8b1f726..a1753d06 100644 --- a/bus/engineproxy.c +++ b/bus/engineproxy.c @@ -52,7 +52,6 @@ static guint engine_signals[LAST_SIGNAL] = { 0 }; // static guint engine_signals[LAST_SIGNAL] = { 0 }; /* functions prototype */ -static void bus_engine_proxy_init (BusEngineProxy *engine); static void bus_engine_proxy_real_destroy (BusEngineProxy *engine); static gboolean bus_engine_proxy_ibus_signal (IBusProxy *proxy, diff --git a/bus/factoryproxy.c b/bus/factoryproxy.c index 0c3cac4b..41abf2ca 100644 --- a/bus/factoryproxy.c +++ b/bus/factoryproxy.c @@ -26,7 +26,6 @@ #include "option.h" /* functions prototype */ -static void bus_factory_proxy_init (BusFactoryProxy *factory); static void bus_factory_proxy_destroy (BusFactoryProxy *factory); G_DEFINE_TYPE (BusFactoryProxy, bus_factory_proxy, IBUS_TYPE_PROXY) diff --git a/bus/ibusimpl.c b/bus/ibusimpl.c index 47bab4fe..404975d3 100644 --- a/bus/ibusimpl.c +++ b/bus/ibusimpl.c @@ -47,7 +47,6 @@ enum { // static guint _signals[LAST_SIGNAL] = { 0 }; /* functions prototype */ -static void bus_ibus_impl_init (BusIBusImpl *ibus); static void bus_ibus_impl_destroy (BusIBusImpl *ibus); static gboolean bus_ibus_impl_ibus_message (BusIBusImpl *ibus, BusConnection *connection, diff --git a/bus/inputcontext.c b/bus/inputcontext.c index c2e2c841..26eb1d54 100644 --- a/bus/inputcontext.c +++ b/bus/inputcontext.c @@ -64,7 +64,6 @@ typedef struct _BusInputContextPrivate BusInputContextPrivate; static guint context_signals[LAST_SIGNAL] = { 0 }; /* functions prototype */ -static void bus_input_context_init (BusInputContext *context); static void bus_input_context_destroy (BusInputContext *context); static gboolean bus_input_context_ibus_message (BusInputContext *context, BusConnection *connection, diff --git a/bus/matchrule.c b/bus/matchrule.c index 836d2c62..840a9127 100644 --- a/bus/matchrule.c +++ b/bus/matchrule.c @@ -25,7 +25,6 @@ (G_TYPE_INSTANCE_GET_PRIVATE ((o), BUS_TYPE_CONFIG_PROXY, BusMatchRulePrivate)) -static void bus_match_rule_init (BusMatchRule *rule); static void bus_match_rule_destroy (BusMatchRule *rule); static void _connection_destroy_cb (BusConnection *connection, BusMatchRule *rule); diff --git a/bus/registry.c b/bus/registry.c index 080b54f4..3f452422 100644 --- a/bus/registry.c +++ b/bus/registry.c @@ -34,7 +34,6 @@ enum { static guint _signals[LAST_SIGNAL] = { 0 }; /* functions prototype */ -static void bus_registry_init (BusRegistry *registry); static void bus_registry_destroy (BusRegistry *registry); static void bus_registry_load (BusRegistry *registry); static void bus_registry_load_in_dir (BusRegistry *registry, diff --git a/bus/server.c b/bus/server.c index fa9e3611..6c147809 100644 --- a/bus/server.c +++ b/bus/server.c @@ -29,7 +29,6 @@ #include "ibusimpl.h" /* functions prototype */ -static void bus_server_init (BusServer *server); static void bus_server_destroy (BusServer *server); static void bus_server_new_connection (BusServer *server, diff --git a/src/ibusattribute.c b/src/ibusattribute.c index f8720edb..3a7c7a37 100644 --- a/src/ibusattribute.c +++ b/src/ibusattribute.c @@ -21,8 +21,6 @@ #include "ibusattribute.h" /* functions prototype */ -static void ibus_attribute_class_init (IBusAttributeClass *klass); -static void ibus_attribute_init (IBusAttribute *attr); // static void ibus_attribute_destroy (IBusAttribute *attr); static gboolean ibus_attribute_serialize (IBusAttribute *attr, IBusMessageIter *iter); @@ -31,42 +29,13 @@ static gboolean ibus_attribute_deserialize (IBusAttribute *attr, static gboolean ibus_attribute_copy (IBusAttribute *dest, const IBusAttribute *src); -static IBusSerializableClass *parent_class = NULL; - -GType -ibus_attribute_get_type (void) -{ - static GType type = 0; - - static const GTypeInfo type_info = { - sizeof (IBusAttributeClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ibus_attribute_class_init, - NULL, /* class finialize */ - NULL, /* class data */ - sizeof (IBusAttribute), - 0, - (GInstanceInitFunc) ibus_attribute_init, - }; - - if (type == 0) { - type = g_type_register_static (IBUS_TYPE_SERIALIZABLE, - "IBusAttribute", - &type_info, - 0); - } - - return type; -} +G_DEFINE_TYPE (IBusAttribute, ibus_attribute, IBUS_TYPE_SERIALIZABLE) static void ibus_attribute_class_init (IBusAttributeClass *klass) { IBusSerializableClass *serializable_class = IBUS_SERIALIZABLE_CLASS (klass); - parent_class = (IBusSerializableClass *) g_type_class_peek_parent (klass); - // object_class->destroy = (IBusObjectDestroyFunc) ibus_attribute_destroy; serializable_class->serialize = (IBusSerializableSerializeFunc) ibus_attribute_serialize; @@ -84,7 +53,7 @@ ibus_attribute_init (IBusAttribute *attr) // static void // ibus_attribute_destroy (IBusAttribute *attr) // { -// IBUS_OBJECT (parent_class)->destroy ((IBusObject *)attr); +// IBUS_OBJECT (ibus_attribute_parent_class)->destroy ((IBusObject *)attr); // } static gboolean @@ -93,7 +62,7 @@ ibus_attribute_serialize (IBusAttribute *attr, { gboolean retval; - retval = parent_class->serialize ((IBusSerializable *) attr, iter); + retval = IBUS_SERIALIZABLE_CLASS (ibus_attribute_parent_class)->serialize ((IBusSerializable *) attr, iter); g_return_val_if_fail (retval, FALSE); g_return_val_if_fail (IBUS_IS_ATTRIBUTE (attr), FALSE); @@ -119,7 +88,7 @@ ibus_attribute_deserialize (IBusAttribute *attr, { gboolean retval; - retval = parent_class->deserialize ((IBusSerializable *) attr, iter); + retval = IBUS_SERIALIZABLE_CLASS (ibus_attribute_parent_class)->deserialize ((IBusSerializable *) attr, iter); g_return_val_if_fail (retval, FALSE); g_return_val_if_fail (IBUS_IS_ATTRIBUTE (attr), FALSE); @@ -150,7 +119,7 @@ ibus_attribute_copy (IBusAttribute *dest, { gboolean retval; - retval = parent_class->copy ((IBusSerializable *)dest, + retval = IBUS_SERIALIZABLE_CLASS (ibus_attribute_parent_class)->copy ((IBusSerializable *)dest, (IBusSerializable *)src); g_return_val_if_fail (retval, FALSE); diff --git a/src/ibusattrlist.c b/src/ibusattrlist.c index cbdea98a..c1ebe16f 100644 --- a/src/ibusattrlist.c +++ b/src/ibusattrlist.c @@ -21,8 +21,6 @@ #include "ibusattrlist.h" /* functions prototype */ -static void ibus_attr_list_class_init (IBusAttrListClass *klass); -static void ibus_attr_list_init (IBusAttrList *attr_list); static void ibus_attr_list_destroy (IBusAttrList *attr_list); static gboolean ibus_attr_list_serialize (IBusAttrList *attr_list, IBusMessageIter *iter); @@ -31,34 +29,7 @@ static gboolean ibus_attr_list_deserialize (IBusAttrList *attr_li static gboolean ibus_attr_list_copy (IBusAttrList *dest, const IBusAttrList *src); -static IBusSerializableClass *parent_class = NULL; - -GType -ibus_attr_list_get_type (void) -{ - static GType type = 0; - - static const GTypeInfo type_info = { - sizeof (IBusAttrListClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ibus_attr_list_class_init, - NULL, /* class finialize */ - NULL, /* class data */ - sizeof (IBusAttrList), - 0, - (GInstanceInitFunc) ibus_attr_list_init, - }; - - if (type == 0) { - type = g_type_register_static (IBUS_TYPE_SERIALIZABLE, - "IBusAttrList", - &type_info, - 0); - } - - return type; -} +G_DEFINE_TYPE (IBusAttrList, ibus_attr_list, IBUS_TYPE_SERIALIZABLE) static void ibus_attr_list_class_init (IBusAttrListClass *klass) @@ -66,8 +37,6 @@ ibus_attr_list_class_init (IBusAttrListClass *klass) IBusObjectClass *object_class = IBUS_OBJECT_CLASS (klass); IBusSerializableClass *serializable_class = IBUS_SERIALIZABLE_CLASS (klass); - parent_class = (IBusSerializableClass *) g_type_class_peek_parent (klass); - object_class->destroy = (IBusObjectDestroyFunc) ibus_attr_list_destroy; serializable_class->serialize = (IBusSerializableSerializeFunc) ibus_attr_list_serialize; @@ -101,7 +70,7 @@ ibus_attr_list_destroy (IBusAttrList *attr_list) g_array_free (attr_list->attributes, TRUE); - IBUS_OBJECT_CLASS (parent_class)->destroy ((IBusObject *)attr_list); + IBUS_OBJECT_CLASS (ibus_attr_list_parent_class)->destroy ((IBusObject *)attr_list); } static gboolean @@ -112,7 +81,7 @@ ibus_attr_list_serialize (IBusAttrList *attr_list, gboolean retval; guint i; - retval = parent_class->serialize ((IBusSerializable *)attr_list, iter); + retval = IBUS_SERIALIZABLE_CLASS (ibus_attr_list_parent_class)->serialize ((IBusSerializable *)attr_list, iter); g_return_val_if_fail (retval, FALSE); g_return_val_if_fail (IBUS_IS_ATTR_LIST (attr_list), FALSE); @@ -147,7 +116,7 @@ ibus_attr_list_deserialize (IBusAttrList *attr_list, DBusMessageIter array_iter; gboolean retval; - retval = parent_class->deserialize ((IBusSerializable *)attr_list, iter); + retval = IBUS_SERIALIZABLE_CLASS (ibus_attr_list_parent_class)->deserialize ((IBusSerializable *)attr_list, iter); g_return_val_if_fail (retval, FALSE); retval = ibus_message_iter_recurse (iter, IBUS_TYPE_ARRAY, &array_iter); @@ -176,7 +145,7 @@ ibus_attr_list_copy (IBusAttrList *dest, { gboolean retval; - retval = parent_class->copy ((IBusSerializable *)dest, + retval = IBUS_SERIALIZABLE_CLASS (ibus_attr_list_parent_class)->copy ((IBusSerializable *)dest, (IBusSerializable *)src); g_return_val_if_fail (retval, FALSE); diff --git a/src/ibusbus.c b/src/ibusbus.c index df9b5791..9a522dad 100644 --- a/src/ibusbus.c +++ b/src/ibusbus.c @@ -53,41 +53,13 @@ typedef struct _IBusBusPrivate IBusBusPrivate; static guint bus_signals[LAST_SIGNAL] = { 0 }; /* functions prototype */ -static void ibus_bus_class_init (IBusBusClass *klass); -static void ibus_bus_init (IBusBus *bus); static void ibus_bus_destroy (IBusObject *object); static void ibus_bus_watch_dbus_signal (IBusBus *bus); static void ibus_bus_unwatch_dbus_signal (IBusBus *bus); -static IBusObjectClass *parent_class = NULL; -GType -ibus_bus_get_type (void) -{ - static GType type = 0; - - static const GTypeInfo type_info = { - sizeof (IBusBusClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ibus_bus_class_init, - NULL, /* class finalize */ - NULL, /* class data */ - sizeof (IBusBus), - 0, - (GInstanceInitFunc) ibus_bus_init, - }; - - if (type == 0) { - type = g_type_register_static (IBUS_TYPE_OBJECT, - "IBusBus", - &type_info, - (GTypeFlags)0); - } - - return type; -} +G_DEFINE_TYPE (IBusBus, ibus_bus, IBUS_TYPE_OBJECT) IBusBus * ibus_bus_new (void) @@ -102,8 +74,6 @@ ibus_bus_class_init (IBusBusClass *klass) { IBusObjectClass *ibus_object_class = IBUS_OBJECT_CLASS (klass); - parent_class = (IBusObjectClass *) g_type_class_peek_parent (klass); - g_type_class_add_private (klass, sizeof (IBusBusPrivate)); ibus_object_class->destroy = ibus_bus_destroy; @@ -289,7 +259,7 @@ ibus_bus_destroy (IBusObject *object) priv->connection = NULL; } - IBUS_OBJECT_CLASS (parent_class)->destroy (object); + IBUS_OBJECT_CLASS (ibus_bus_parent_class)->destroy (object); } gboolean diff --git a/src/ibuscomponent.c b/src/ibuscomponent.c index 4cb16a61..6e268aee 100644 --- a/src/ibuscomponent.c +++ b/src/ibuscomponent.c @@ -39,8 +39,6 @@ typedef struct _IBusComponentPrivate IBusComponentPrivate; // static guint _signals[LAST_SIGNAL] = { 0 }; /* functions prototype */ -static void ibus_component_class_init (IBusComponentClass *klass); -static void ibus_component_init (IBusComponent *component); static void ibus_component_destroy (IBusComponent *component); static gboolean ibus_component_serialize (IBusComponent *component, IBusMessageIter *iter); @@ -60,35 +58,7 @@ static void ibus_component_parse_observed_paths XMLNode *node, gboolean access_fs); -static IBusSerializableClass *parent_class = NULL; - -GType -ibus_component_get_type (void) -{ - static GType type = 0; - - static const GTypeInfo type_info = { - sizeof (IBusComponentClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ibus_component_class_init, - NULL, /* class finalize */ - NULL, /* class data */ - sizeof (IBusComponent), - 0, - (GInstanceInitFunc) ibus_component_init, - }; - - if (type == 0) { - type = g_type_register_static (IBUS_TYPE_SERIALIZABLE, - "IBusComponent", - &type_info, - (GTypeFlags)0); - } - - return type; -} - +G_DEFINE_TYPE (IBusComponent, ibus_component, IBUS_TYPE_SERIALIZABLE) static void ibus_component_class_init (IBusComponentClass *klass) @@ -96,8 +66,6 @@ ibus_component_class_init (IBusComponentClass *klass) IBusObjectClass *object_class = IBUS_OBJECT_CLASS (klass); IBusSerializableClass *serializable_class = IBUS_SERIALIZABLE_CLASS (klass); - parent_class = (IBusSerializableClass *) g_type_class_peek_parent (klass); - object_class->destroy = (IBusObjectDestroyFunc) ibus_component_destroy; serializable_class->serialize = (IBusSerializableSerializeFunc) ibus_component_serialize; @@ -159,7 +127,7 @@ ibus_component_destroy (IBusComponent *component) g_list_free (component->engines); component->engines = NULL; - IBUS_OBJECT_CLASS (parent_class)->destroy (IBUS_OBJECT (component)); + IBUS_OBJECT_CLASS (ibus_component_parent_class)->destroy (IBUS_OBJECT (component)); } static gboolean @@ -170,7 +138,7 @@ ibus_component_serialize (IBusComponent *component, IBusMessageIter array_iter; GList *p; - retval = parent_class->serialize ((IBusSerializable *)component, iter); + retval = IBUS_SERIALIZABLE_CLASS (ibus_component_parent_class)->serialize ((IBusSerializable *)component, iter); g_return_val_if_fail (retval, FALSE); retval = ibus_message_iter_append (iter, G_TYPE_STRING, &component->name); @@ -230,7 +198,7 @@ ibus_component_deserialize (IBusComponent *component, gchar *str; IBusMessageIter array_iter; - retval = parent_class->deserialize ((IBusSerializable *)component, iter); + retval = IBUS_SERIALIZABLE_CLASS (ibus_component_parent_class)->deserialize ((IBusSerializable *)component, iter); g_return_val_if_fail (retval, FALSE); retval = ibus_message_iter_get (iter, G_TYPE_STRING, &str); @@ -310,7 +278,7 @@ ibus_component_copy (IBusComponent *dest, { gboolean retval; - retval = parent_class->copy ((IBusSerializable *)dest, + retval = IBUS_SERIALIZABLE_CLASS (ibus_component_parent_class)->copy ((IBusSerializable *)dest, (IBusSerializable *)src); g_return_val_if_fail (retval, FALSE); diff --git a/src/ibusconnection.c b/src/ibusconnection.c index 5d164187..1a6f1879 100644 --- a/src/ibusconnection.c +++ b/src/ibusconnection.c @@ -47,8 +47,6 @@ typedef struct _IBusConnectionPrivate IBusConnectionPrivate; static guint connection_signals[LAST_SIGNAL] = { 0 }; /* functions prototype */ -static void ibus_connection_class_init (IBusConnectionClass *klass); -static void ibus_connection_init (IBusConnection *connection); static void ibus_connection_destroy (IBusConnection *connection); static gboolean ibus_connection_authenticate_unix_user @@ -64,35 +62,9 @@ static DBusHandlerResult IBusMessage *message, IBusConnection *connection); -static IBusObjectClass *parent_class = NULL; static GHashTable *_connections = NULL; -GType -ibus_connection_get_type (void) -{ - static GType type = 0; - - static const GTypeInfo type_info = { - sizeof (IBusConnectionClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ibus_connection_class_init, - NULL, /* class finalize */ - NULL, /* class data */ - sizeof (IBusConnection), - 0, - (GInstanceInitFunc) ibus_connection_init, - }; - - if (type == 0) { - type = g_type_register_static (IBUS_TYPE_OBJECT, - "IBusConnection", - &type_info, - (GTypeFlags)0); - } - - return type; -} +G_DEFINE_TYPE (IBusConnection, ibus_connection, IBUS_TYPE_OBJECT) IBusConnection * ibus_connection_new (void) @@ -107,8 +79,6 @@ ibus_connection_class_init (IBusConnectionClass *klass) { IBusObjectClass *object_class = IBUS_OBJECT_CLASS (klass); - parent_class = (IBusObjectClass *) g_type_class_peek_parent (klass); - g_type_class_add_private (klass, sizeof (IBusConnectionPrivate)); object_class->destroy = (IBusObjectDestroyFunc) ibus_connection_destroy; @@ -267,7 +237,7 @@ ibus_connection_destroy (IBusConnection *connection) } } while (0); - parent_class->destroy (IBUS_OBJECT (connection)); + IBUS_OBJECT_CLASS (ibus_connection_parent_class)->destroy (IBUS_OBJECT (connection)); } static gboolean diff --git a/src/ibusengine.c b/src/ibusengine.c index 50e02b4e..5195a8e2 100644 --- a/src/ibusengine.c +++ b/src/ibusengine.c @@ -64,8 +64,6 @@ typedef struct _IBusEnginePrivate IBusEnginePrivate; static guint engine_signals[LAST_SIGNAL] = { 0 }; /* functions prototype */ -static void ibus_engine_class_init (IBusEngineClass *klass); -static void ibus_engine_init (IBusEngine *engine); static void ibus_engine_destroy (IBusEngine *engine); static void ibus_engine_set_property (IBusEngine *engine, guint prop_id, @@ -116,33 +114,7 @@ static void ibus_engine_property_hide (IBusEngine *engine, const gchar *prop_name); -static IBusServiceClass *parent_class = NULL; - -GType -ibus_engine_get_type (void) -{ - static GType type = 0; - - static const GTypeInfo type_info = { - sizeof (IBusEngineClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ibus_engine_class_init, - NULL, /* class finalize */ - NULL, /* class data */ - sizeof (IBusEngine), - 0, - (GInstanceInitFunc) ibus_engine_init, - }; - - if (type == 0) { - type = g_type_register_static (IBUS_TYPE_SERVICE, - "IBusEngine", - &type_info, - (GTypeFlags) 0); - } - return type; -} +G_DEFINE_TYPE (IBusEngine, ibus_engine, IBUS_TYPE_SERVICE) IBusEngine * ibus_engine_new (const gchar *name, @@ -169,8 +141,6 @@ ibus_engine_class_init (IBusEngineClass *klass) GObjectClass *gobject_class = G_OBJECT_CLASS (klass); IBusObjectClass *ibus_object_class = IBUS_OBJECT_CLASS (klass); - parent_class = (IBusServiceClass *) g_type_class_peek_parent (klass); - g_type_class_add_private (klass, sizeof (IBusEnginePrivate)); gobject_class->set_property = (GObjectSetPropertyFunc) ibus_engine_set_property; @@ -591,7 +561,7 @@ ibus_engine_destroy (IBusEngine *engine) priv->connection = NULL; } - IBUS_OBJECT_CLASS(parent_class)->destroy (IBUS_OBJECT (engine)); + IBUS_OBJECT_CLASS(ibus_engine_parent_class)->destroy (IBUS_OBJECT (engine)); } static void @@ -683,7 +653,8 @@ ibus_engine_ibus_message (IBusEngine *engine, name = ibus_message_get_member (message); if (interface != NULL && g_strcmp0 (interface, IBUS_INTERFACE_ENGINE) != 0) - return parent_class->ibus_message ((IBusService *) engine, connection, message); + return IBUS_SERVICE_CLASS (ibus_engine_parent_class)->ibus_message ( + (IBusService *) engine, connection, message); do { if (g_strcmp0 (name, "ProcessKeyEvent") == 0) { diff --git a/src/ibusenginedesc.c b/src/ibusenginedesc.c index d71d1574..5563cc0c 100644 --- a/src/ibusenginedesc.c +++ b/src/ibusenginedesc.c @@ -39,8 +39,6 @@ typedef struct _IBusEngineDescPrivate IBusEngineDescPrivate; // static guint _signals[LAST_SIGNAL] = { 0 }; /* functions prototype */ -static void ibus_engine_desc_class_init (IBusEngineDescClass *klass); -static void ibus_engine_desc_init (IBusEngineDesc *desc); static void ibus_engine_desc_destroy (IBusEngineDesc *desc); static gboolean ibus_engine_desc_serialize (IBusEngineDesc *desc, IBusMessageIter *iter); @@ -51,34 +49,7 @@ static gboolean ibus_engine_desc_copy (IBusEngineDesc *des static gboolean ibus_engine_desc_parse_xml_node (IBusEngineDesc *desc, XMLNode *node); -static IBusSerializableClass *parent_class = NULL; - -GType -ibus_engine_desc_get_type (void) -{ - static GType type = 0; - - static const GTypeInfo type_info = { - sizeof (IBusEngineDescClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ibus_engine_desc_class_init, - NULL, /* class finalize */ - NULL, /* class data */ - sizeof (IBusEngineDesc), - 0, - (GInstanceInitFunc) ibus_engine_desc_init, - }; - - if (type == 0) { - type = g_type_register_static (IBUS_TYPE_SERIALIZABLE, - "IBusEngineDesc", - &type_info, - (GTypeFlags)0); - } - - return type; -} +G_DEFINE_TYPE (IBusEngineDesc, ibus_engine_desc, IBUS_TYPE_SERIALIZABLE) static void @@ -87,8 +58,6 @@ ibus_engine_desc_class_init (IBusEngineDescClass *klass) IBusObjectClass *object_class = IBUS_OBJECT_CLASS (klass); IBusSerializableClass *serializable_class = IBUS_SERIALIZABLE_CLASS (klass); - parent_class = (IBusSerializableClass *) g_type_class_peek_parent (klass); - object_class->destroy = (IBusObjectDestroyFunc) ibus_engine_desc_destroy; serializable_class->serialize = (IBusSerializableSerializeFunc) ibus_engine_desc_serialize; @@ -125,7 +94,7 @@ ibus_engine_desc_destroy (IBusEngineDesc *desc) g_free (desc->icon); g_free (desc->layout); - IBUS_OBJECT_CLASS (parent_class)->destroy (IBUS_OBJECT (desc)); + IBUS_OBJECT_CLASS (ibus_engine_desc_parent_class)->destroy (IBUS_OBJECT (desc)); } static gboolean @@ -134,7 +103,7 @@ ibus_engine_desc_serialize (IBusEngineDesc *desc, { gboolean retval; - retval = parent_class->serialize ((IBusSerializable *)desc, iter); + retval = IBUS_SERIALIZABLE_CLASS (ibus_engine_desc_parent_class)->serialize ((IBusSerializable *)desc, iter); g_return_val_if_fail (retval, FALSE); retval = ibus_message_iter_append (iter, G_TYPE_STRING, &desc->name); @@ -174,7 +143,7 @@ ibus_engine_desc_deserialize (IBusEngineDesc *desc, gboolean retval; gchar *str; - retval = parent_class->deserialize ((IBusSerializable *)desc, iter); + retval = IBUS_SERIALIZABLE_CLASS (ibus_engine_desc_parent_class)->deserialize ((IBusSerializable *)desc, iter); g_return_val_if_fail (retval, FALSE); retval = ibus_message_iter_get (iter, G_TYPE_STRING, &str); @@ -230,7 +199,7 @@ ibus_engine_desc_copy (IBusEngineDesc *dest, { gboolean retval; - retval = parent_class->copy ((IBusSerializable *)dest, + retval = IBUS_SERIALIZABLE_CLASS (ibus_engine_desc_parent_class)->copy ((IBusSerializable *)dest, (IBusSerializable *)src); g_return_val_if_fail (retval, FALSE); diff --git a/src/ibusfactory.c b/src/ibusfactory.c index 8a0fefea..aec215ba 100644 --- a/src/ibusfactory.c +++ b/src/ibusfactory.c @@ -41,8 +41,6 @@ struct _IBusFactoryPrivate { typedef struct _IBusFactoryPrivate IBusFactoryPrivate; /* functions prototype */ -static void ibus_factory_class_init (IBusFactoryClass *klass); -static void ibus_factory_init (IBusFactory *factory); static void ibus_factory_destroy (IBusFactory *factory); static gboolean ibus_factory_ibus_message (IBusFactory *factory, IBusConnection *connection, @@ -51,33 +49,7 @@ static gboolean ibus_factory_ibus_message (IBusFactory *factory, static void _engine_destroy_cb (IBusEngine *engine, IBusFactory *factory); -static IBusServiceClass *factory_parent_class = NULL; - -GType -ibus_factory_get_type (void) -{ - static GType type = 0; - - static const GTypeInfo type_info = { - sizeof (IBusFactoryClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ibus_factory_class_init, - NULL, /* class finalize */ - NULL, /* class data */ - sizeof (IBusFactory), - 0, - (GInstanceInitFunc) ibus_factory_init, - }; - - if (type == 0) { - type = g_type_register_static (IBUS_TYPE_SERVICE, - "IBusFactory", - &type_info, - (GTypeFlags) 0); - } - return type; -} +G_DEFINE_TYPE (IBusFactory, ibus_factory, IBUS_TYPE_SERVICE) IBusFactory * ibus_factory_new (IBusConnection *connection) @@ -104,8 +76,6 @@ ibus_factory_class_init (IBusFactoryClass *klass) // GObjectClass *gobject_class = G_OBJECT_CLASS (klass); IBusObjectClass *ibus_object_class = IBUS_OBJECT_CLASS (klass); - factory_parent_class = (IBusServiceClass *) g_type_class_peek_parent (klass); - g_type_class_add_private (klass, sizeof (IBusFactoryPrivate)); ibus_object_class->destroy = (IBusObjectDestroyFunc) ibus_factory_destroy; @@ -152,7 +122,7 @@ ibus_factory_destroy (IBusFactory *factory) g_object_unref (priv->connection); } - IBUS_OBJECT_CLASS(factory_parent_class)->destroy (IBUS_OBJECT (factory)); + IBUS_OBJECT_CLASS(ibus_factory_parent_class)->destroy (IBUS_OBJECT (factory)); } static void @@ -241,9 +211,10 @@ ibus_factory_ibus_message (IBusFactory *factory, return TRUE; } - return factory_parent_class->ibus_message ((IBusService *)factory, - connection, - message); + return IBUS_SERVICE_CLASS (ibus_factory_parent_class)->ibus_message ( + (IBusService *)factory, + connection, + message); } void diff --git a/src/ibusinputcontext.c b/src/ibusinputcontext.c index 66744c79..907544b9 100644 --- a/src/ibusinputcontext.c +++ b/src/ibusinputcontext.c @@ -63,39 +63,11 @@ static guint context_signals[LAST_SIGNAL] = { 0 }; // static guint context_signals[LAST_SIGNAL] = { 0 }; /* functions prototype */ -static void ibus_input_context_class_init (IBusInputContextClass *klass); -static void ibus_input_context_init (IBusInputContext *context); static void ibus_input_context_real_destroy (IBusInputContext *context); static gboolean ibus_input_context_ibus_signal (IBusProxy *proxy, DBusMessage *message); -static IBusProxyClass *parent_class = NULL; - -GType -ibus_input_context_get_type (void) -{ - static GType type = 0; - - static const GTypeInfo type_info = { - sizeof (IBusInputContextClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ibus_input_context_class_init, - NULL, /* class finalize */ - NULL, /* class data */ - sizeof (IBusInputContext), - 0, - (GInstanceInitFunc) ibus_input_context_init, - }; - - if (type == 0) { - type = g_type_register_static (IBUS_TYPE_PROXY, - "IBusInputContext", - &type_info, - (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE (IBusInputContext, ibus_input_context, IBUS_TYPE_PROXY) IBusInputContext * ibus_input_context_new (const gchar *path, @@ -133,9 +105,6 @@ ibus_input_context_class_init (IBusInputContextClass *klass) IBusObjectClass *ibus_object_class = IBUS_OBJECT_CLASS (klass); IBusProxyClass *proxy_class = IBUS_PROXY_CLASS (klass); - - parent_class = (IBusProxyClass *) g_type_class_peek_parent (klass); - g_type_class_add_private (klass, sizeof (IBusInputContextPrivate)); ibus_object_class->destroy = (IBusObjectDestroyFunc) ibus_input_context_real_destroy; @@ -524,7 +493,7 @@ ibus_input_context_real_destroy (IBusInputContext *context) G_TYPE_INVALID); } - IBUS_OBJECT_CLASS(parent_class)->destroy (IBUS_OBJECT (context)); + IBUS_OBJECT_CLASS(ibus_input_context_parent_class)->destroy (IBUS_OBJECT (context)); } static gboolean diff --git a/src/ibuskeymap.c b/src/ibuskeymap.c index 57f2c25b..6abade07 100644 --- a/src/ibuskeymap.c +++ b/src/ibuskeymap.c @@ -28,48 +28,18 @@ #include "ibuskeymap.h" /* functions prototype */ -static void ibus_keymap_class_init (IBusKeymapClass *klass); -static void ibus_keymap_init (IBusKeymap *keymap); static void ibus_keymap_destroy (IBusKeymap *keymap); static gboolean ibus_keymap_load (const gchar *name, KEYMAP keymap); -static IBusObjectClass *parent_class = NULL; static GHashTable *keymaps = NULL; -GType -ibus_keymap_get_type (void) -{ - static GType type = 0; - - static const GTypeInfo type_info = { - sizeof (IBusKeymapClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ibus_keymap_class_init, - NULL, /* class finialize */ - NULL, /* class data */ - sizeof (IBusKeymap), - 0, - (GInstanceInitFunc) ibus_keymap_init, - }; - - if (type == 0) { - type = g_type_register_static (IBUS_TYPE_OBJECT, - "IBusKeymap", - &type_info, - 0); - } - - return type; -} +G_DEFINE_TYPE (IBusKeymap, ibus_keymap, IBUS_TYPE_OBJECT) static void ibus_keymap_class_init (IBusKeymapClass *klass) { IBusObjectClass *object_class = IBUS_OBJECT_CLASS (klass); - parent_class = (IBusObjectClass *) g_type_class_peek_parent (klass); - object_class->destroy = (IBusObjectDestroyFunc) ibus_keymap_destroy; } @@ -90,7 +60,7 @@ ibus_keymap_destroy (IBusKeymap *keymap) g_free (keymap->name); keymap->name = NULL; } - IBUS_OBJECT_CLASS (parent_class)->destroy ((IBusObject *)keymap); + IBUS_OBJECT_CLASS (ibus_keymap_parent_class)->destroy ((IBusObject *)keymap); } #define SKIP_SPACE(p) \ diff --git a/src/ibuslookuptable.c b/src/ibuslookuptable.c index 10c3f345..6c7d9b8e 100644 --- a/src/ibuslookuptable.c +++ b/src/ibuslookuptable.c @@ -21,8 +21,6 @@ #include "ibuslookuptable.h" /* functions prototype */ -static void ibus_lookup_table_class_init (IBusLookupTableClass *klass); -static void ibus_lookup_table_init (IBusLookupTable *table); static void ibus_lookup_table_destroy (IBusLookupTable *table); static gboolean ibus_lookup_table_serialize (IBusLookupTable *table, IBusMessageIter *iter); @@ -31,34 +29,7 @@ static gboolean ibus_lookup_table_deserialize (IBusLookupTable *tab static gboolean ibus_lookup_table_copy (IBusLookupTable *dest, IBusLookupTable *src); -static IBusSerializableClass *parent_class = NULL; - -GType -ibus_lookup_table_get_type (void) -{ - static GType type = 0; - - static const GTypeInfo type_info = { - sizeof (IBusLookupTableClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ibus_lookup_table_class_init, - NULL, /* class finialize */ - NULL, /* class data */ - sizeof (IBusLookupTable), - 0, - (GInstanceInitFunc) ibus_lookup_table_init, - }; - - if (type == 0) { - type = g_type_register_static (IBUS_TYPE_SERIALIZABLE, - "IBusLookupTable", - &type_info, - 0); - } - - return type; -} +G_DEFINE_TYPE (IBusLookupTable, ibus_lookup_table, IBUS_TYPE_SERIALIZABLE) static void ibus_lookup_table_class_init (IBusLookupTableClass *klass) @@ -66,8 +37,6 @@ ibus_lookup_table_class_init (IBusLookupTableClass *klass) IBusObjectClass *object_class = IBUS_OBJECT_CLASS (klass); IBusSerializableClass *serializable_class = IBUS_SERIALIZABLE_CLASS (klass); - parent_class = (IBusSerializableClass *) g_type_class_peek_parent (klass); - object_class->destroy = (IBusObjectDestroyFunc) ibus_lookup_table_destroy; serializable_class->serialize = (IBusSerializableSerializeFunc) ibus_lookup_table_serialize; @@ -109,7 +78,7 @@ ibus_lookup_table_destroy (IBusLookupTable *table) g_free (p); } - IBUS_OBJECT_CLASS (parent_class)->destroy ((IBusObject *) table); + IBUS_OBJECT_CLASS (ibus_lookup_table_parent_class)->destroy ((IBusObject *) table); } static gboolean @@ -120,7 +89,7 @@ ibus_lookup_table_serialize (IBusLookupTable *table, gboolean retval; guint i; - retval = parent_class->serialize ((IBusSerializable *)table, iter); + retval = IBUS_SERIALIZABLE_CLASS (ibus_lookup_table_parent_class)->serialize ((IBusSerializable *)table, iter); g_return_val_if_fail (retval, FALSE); g_return_val_if_fail (IBUS_IS_LOOKUP_TABLE (table), FALSE); @@ -192,7 +161,7 @@ ibus_lookup_table_deserialize (IBusLookupTable *table, DBusMessageIter array_iter; gboolean retval; - retval = parent_class->deserialize ((IBusSerializable *)table, iter); + retval = IBUS_SERIALIZABLE_CLASS (ibus_lookup_table_parent_class)->deserialize ((IBusSerializable *)table, iter); g_return_val_if_fail (retval, FALSE); g_return_val_if_fail (IBUS_IS_LOOKUP_TABLE (table), FALSE); @@ -257,7 +226,7 @@ ibus_lookup_table_copy (IBusLookupTable *dest, gboolean retval; guint i; - retval = parent_class->copy ((IBusSerializable *)dest, (IBusSerializable *)src); + retval = IBUS_SERIALIZABLE_CLASS (ibus_lookup_table_parent_class)->copy ((IBusSerializable *)dest, (IBusSerializable *)src); g_return_val_if_fail (retval, FALSE); g_return_val_if_fail (IBUS_IS_LOOKUP_TABLE (dest), FALSE); diff --git a/src/ibusobject.c b/src/ibusobject.c index c7d061c6..f6723ae6 100644 --- a/src/ibusobject.c +++ b/src/ibusobject.c @@ -44,8 +44,6 @@ static guint _count = 0; #endif /* functions prototype */ -static void ibus_object_class_init (IBusObjectClass *klass); -static void ibus_object_init (IBusObject *obj); static GObject *ibus_object_constructor (GType type, guint n, GObjectConstructParam @@ -54,35 +52,7 @@ static void ibus_object_dispose (IBusObject *obj); static void ibus_object_finalize (IBusObject *obj); static void ibus_object_real_destroy (IBusObject *obj); -static GObjectClass *parent_class = NULL; - - -GType -ibus_object_get_type (void) -{ - static GType type = 0; - - static const GTypeInfo type_info = { - sizeof (IBusObjectClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ibus_object_class_init, - NULL, /* class finialize */ - NULL, /* class data */ - sizeof (IBusObject), - 0, - (GInstanceInitFunc) ibus_object_init, - }; - - if (type == 0) { - type = g_type_register_static (G_TYPE_INITIALLY_UNOWNED, - "IBusObject", - &type_info, - G_TYPE_FLAG_ABSTRACT); - } - - return type; -} +G_DEFINE_TYPE (IBusObject, ibus_object, G_TYPE_INITIALLY_UNOWNED) /** * ibus_object_new: @@ -102,8 +72,6 @@ ibus_object_class_init (IBusObjectClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - parent_class = (GObjectClass *) g_type_class_peek_parent (klass); - g_type_class_add_private (klass, sizeof (IBusObjectPrivate)); gobject_class->constructor = ibus_object_constructor; @@ -155,7 +123,7 @@ ibus_object_constructor (GType type, { GObject *object; - object = parent_class->constructor (type, n ,args); + object = G_OBJECT_CLASS (ibus_object_parent_class)->constructor (type, n ,args); #ifdef DEBUG_MEMORY if (object != NULL) { @@ -185,7 +153,7 @@ ibus_object_dispose (IBusObject *obj) IBUS_OBJECT_UNSET_FLAGS (obj, IBUS_IN_DESTRUCTION); } - G_OBJECT_CLASS(parent_class)->dispose (G_OBJECT (obj)); + G_OBJECT_CLASS(ibus_object_parent_class)->dispose (G_OBJECT (obj)); } static void @@ -200,7 +168,7 @@ ibus_object_finalize (IBusObject *obj) g_debug ("Finalize %s, count = %d, all = %d", G_OBJECT_TYPE_NAME (obj), count, _count); #endif - G_OBJECT_CLASS(parent_class)->finalize (G_OBJECT (obj)); + G_OBJECT_CLASS(ibus_object_parent_class)->finalize (G_OBJECT (obj)); } static void diff --git a/src/ibusobservedpath.c b/src/ibusobservedpath.c index 87a26530..a71b48b2 100644 --- a/src/ibusobservedpath.c +++ b/src/ibusobservedpath.c @@ -40,8 +40,6 @@ typedef struct _IBusObservedPathPrivate IBusObservedPathPrivate; // static guint _signals[LAST_SIGNAL] = { 0 }; /* functions prototype */ -static void ibus_observed_path_class_init (IBusObservedPathClass *klass); -static void ibus_observed_path_init (IBusObservedPath *path); static void ibus_observed_path_destroy (IBusObservedPath *path); static gboolean ibus_observed_path_serialize (IBusObservedPath *path, IBusMessageIter *iter); @@ -52,35 +50,7 @@ static gboolean ibus_observed_path_copy (IBusObservedPath *des static gboolean ibus_observed_path_parse_xml_node (IBusObservedPath *path, XMLNode *node); -static IBusSerializableClass *parent_class = NULL; - -GType -ibus_observed_path_get_type (void) -{ - static GType type = 0; - - static const GTypeInfo type_info = { - sizeof (IBusObservedPathClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ibus_observed_path_class_init, - NULL, /* class finalize */ - NULL, /* class data */ - sizeof (IBusObservedPath), - 0, - (GInstanceInitFunc) ibus_observed_path_init, - }; - - if (type == 0) { - type = g_type_register_static (IBUS_TYPE_SERIALIZABLE, - "IBusObservedPath", - &type_info, - (GTypeFlags)0); - } - - return type; -} - +G_DEFINE_TYPE (IBusObservedPath, ibus_observed_path, IBUS_TYPE_SERIALIZABLE) static void ibus_observed_path_class_init (IBusObservedPathClass *klass) @@ -88,8 +58,6 @@ ibus_observed_path_class_init (IBusObservedPathClass *klass) IBusObjectClass *object_class = IBUS_OBJECT_CLASS (klass); IBusSerializableClass *serializable_class = IBUS_SERIALIZABLE_CLASS (klass); - parent_class = (IBusSerializableClass *) g_type_class_peek_parent (klass); - // g_type_class_add_private (klass, sizeof (IBusObservedPathPrivate)); object_class->destroy = (IBusObjectDestroyFunc) ibus_observed_path_destroy; @@ -112,7 +80,7 @@ static void ibus_observed_path_destroy (IBusObservedPath *path) { g_free (path->path); - IBUS_OBJECT_CLASS (parent_class)->destroy (IBUS_OBJECT (path)); + IBUS_OBJECT_CLASS (ibus_observed_path_parent_class)->destroy (IBUS_OBJECT (path)); } static gboolean @@ -121,7 +89,7 @@ ibus_observed_path_serialize (IBusObservedPath *path, { gboolean retval; - retval = parent_class->serialize ((IBusSerializable *)path, iter); + retval = IBUS_SERIALIZABLE_CLASS (ibus_observed_path_parent_class)->serialize ((IBusSerializable *)path, iter); g_return_val_if_fail (retval, FALSE); retval = ibus_message_iter_append (iter, G_TYPE_STRING, &(path->path)); @@ -140,7 +108,7 @@ ibus_observed_path_deserialize (IBusObservedPath *path, gboolean retval; gchar *str; - retval = parent_class->deserialize ((IBusSerializable *)path, iter); + retval = IBUS_SERIALIZABLE_CLASS (ibus_observed_path_parent_class)->deserialize ((IBusSerializable *)path, iter); g_return_val_if_fail (retval, FALSE); retval = ibus_message_iter_get (iter, G_TYPE_STRING, &str); @@ -161,7 +129,7 @@ ibus_observed_path_copy (IBusObservedPath *dest, { gboolean retval; - retval = parent_class->copy ((IBusSerializable *)dest, (IBusSerializable *)src); + retval = IBUS_SERIALIZABLE_CLASS (ibus_observed_path_parent_class)->copy ((IBusSerializable *)dest, (IBusSerializable *)src); g_return_val_if_fail (retval, FALSE); dest->path = g_strdup (src->path); diff --git a/src/ibuspanelservice.c b/src/ibuspanelservice.c index 4a8eb0e6..8420f2cc 100644 --- a/src/ibuspanelservice.c +++ b/src/ibuspanelservice.c @@ -27,8 +27,6 @@ enum { }; /* functions prototype */ -static void ibus_panel_service_class_init (IBusPanelServiceClass *klass); -static void ibus_panel_service_init (IBusPanelService *panel); static void ibus_panel_service_service_set_property (IBusPanelService *panel, guint prop_id, const GValue *value, @@ -75,33 +73,7 @@ static gboolean ibus_panel_service_update_property (IBusPanelService IBusProperty *prop, IBusError **error); -static IBusServiceClass *parent_class = NULL; - -GType -ibus_panel_service_get_type (void) -{ - static GType type = 0; - - static const GTypeInfo type_info = { - sizeof (IBusPanelServiceClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ibus_panel_service_class_init, - NULL, /* class finalize */ - NULL, /* class data */ - sizeof (IBusPanelService), - 0, - (GInstanceInitFunc) ibus_panel_service_init, - }; - - if (type == 0) { - type = g_type_register_static (IBUS_TYPE_SERVICE, - "IBusPanelService", - &type_info, - (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE (IBusPanelService, ibus_panel_service, IBUS_TYPE_SERVICE) IBusPanelService * ibus_panel_service_new (IBusConnection *connection) @@ -123,8 +95,6 @@ ibus_panel_service_class_init (IBusPanelServiceClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - parent_class = (IBusServiceClass *) g_type_class_peek_parent (klass); - gobject_class->set_property = (GObjectSetPropertyFunc) ibus_panel_service_service_set_property; gobject_class->get_property = (GObjectGetPropertyFunc) ibus_panel_service_service_get_property; @@ -222,7 +192,7 @@ ibus_panel_service_service_get_property (IBusPanelService *panel, static void ibus_panel_service_real_destroy (IBusPanelService *panel) { - IBUS_OBJECT_CLASS(parent_class)->destroy (IBUS_OBJECT (panel)); + IBUS_OBJECT_CLASS(ibus_panel_service_parent_class)->destroy (IBUS_OBJECT (panel)); } static gboolean diff --git a/src/ibusproperty.c b/src/ibusproperty.c index 8827a223..c0e44304 100644 --- a/src/ibusproperty.c +++ b/src/ibusproperty.c @@ -22,8 +22,6 @@ #include "ibusproplist.h" /* functions prototype */ -static void ibus_property_class_init (IBusPropertyClass *klass); -static void ibus_property_init (IBusProperty *prop); static void ibus_property_destroy (IBusProperty *prop); static gboolean ibus_property_serialize (IBusProperty *prop, IBusMessageIter *iter); @@ -32,34 +30,7 @@ static gboolean ibus_property_deserialize (IBusProperty *prop, static gboolean ibus_property_copy (IBusProperty *dest, const IBusProperty *src); -static IBusSerializableClass *parent_class = NULL; - -GType -ibus_property_get_type (void) -{ - static GType type = 0; - - static const GTypeInfo type_info = { - sizeof (IBusPropertyClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ibus_property_class_init, - NULL, /* class finialize */ - NULL, /* class data */ - sizeof (IBusProperty), - 0, - (GInstanceInitFunc) ibus_property_init, - }; - - if (type == 0) { - type = g_type_register_static (IBUS_TYPE_SERIALIZABLE, - "IBusProperty", - &type_info, - 0); - } - - return type; -} +G_DEFINE_TYPE (IBusProperty, ibus_property, IBUS_TYPE_SERIALIZABLE) static void ibus_property_class_init (IBusPropertyClass *klass) @@ -67,8 +38,6 @@ ibus_property_class_init (IBusPropertyClass *klass) IBusObjectClass *object_class = IBUS_OBJECT_CLASS (klass); IBusSerializableClass *serializable_class = IBUS_SERIALIZABLE_CLASS (klass); - parent_class = (IBusSerializableClass *) g_type_class_peek_parent (klass); - object_class->destroy = (IBusObjectDestroyFunc) ibus_property_destroy; serializable_class->serialize = (IBusSerializableSerializeFunc) ibus_property_serialize; @@ -117,7 +86,7 @@ ibus_property_destroy (IBusProperty *prop) prop->sub_props = NULL; } - IBUS_OBJECT_CLASS (parent_class)->destroy ((IBusObject *)prop); + IBUS_OBJECT_CLASS (ibus_property_parent_class)->destroy ((IBusObject *)prop); } gboolean @@ -126,7 +95,7 @@ ibus_property_serialize (IBusProperty *prop, { gboolean retval; - retval = parent_class->serialize ((IBusSerializable *) prop, iter); + retval = IBUS_SERIALIZABLE_CLASS (ibus_property_parent_class)->serialize ((IBusSerializable *) prop, iter); g_return_val_if_fail (retval, FALSE); g_return_val_if_fail (IBUS_IS_PROPERTY (prop), FALSE); @@ -168,7 +137,7 @@ ibus_property_deserialize (IBusProperty *prop, gboolean retval; gchar *p; - retval = parent_class->deserialize ((IBusSerializable *) prop, iter); + retval = IBUS_SERIALIZABLE_CLASS (ibus_property_parent_class)->deserialize ((IBusSerializable *) prop, iter); g_return_val_if_fail (retval, FALSE); retval = ibus_message_iter_get (iter, G_TYPE_STRING, &p); @@ -221,7 +190,7 @@ ibus_property_copy (IBusProperty *dest, { gboolean retval; - retval = parent_class->copy ((IBusSerializable *) dest, (IBusSerializable *) src); + retval = IBUS_SERIALIZABLE_CLASS (ibus_property_parent_class)->copy ((IBusSerializable *) dest, (IBusSerializable *) src); g_return_val_if_fail (retval, FALSE); g_return_val_if_fail (IBUS_IS_PROPERTY (dest), FALSE); diff --git a/src/ibusproplist.c b/src/ibusproplist.c index b3a2dc0f..958db8e4 100644 --- a/src/ibusproplist.c +++ b/src/ibusproplist.c @@ -21,8 +21,6 @@ #include "ibusproplist.h" /* functions prototype */ -static void ibus_prop_list_class_init (IBusPropListClass *klass); -static void ibus_prop_list_init (IBusPropList *prop_list); static void ibus_prop_list_destroy (IBusPropList *prop_list); static gboolean ibus_prop_list_serialize (IBusPropList *prop_list, IBusMessageIter *iter); @@ -31,34 +29,7 @@ static gboolean ibus_prop_list_deserialize (IBusPropList *prop_list, static gboolean ibus_prop_list_copy (IBusPropList *dest, const IBusPropList *src); -static IBusSerializableClass *parent_class = NULL; - -GType -ibus_prop_list_get_type (void) -{ - static GType type = 0; - - static const GTypeInfo type_info = { - sizeof (IBusPropListClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ibus_prop_list_class_init, - NULL, /* class finialize */ - NULL, /* class data */ - sizeof (IBusProperty), - 0, - (GInstanceInitFunc) ibus_prop_list_init, - }; - - if (type == 0) { - type = g_type_register_static (IBUS_TYPE_SERIALIZABLE, - "IBusPropList", - &type_info, - 0); - } - - return type; -} +G_DEFINE_TYPE (IBusPropList, ibus_prop_list, IBUS_TYPE_SERIALIZABLE) static void ibus_prop_list_class_init (IBusPropListClass *klass) @@ -66,8 +37,6 @@ ibus_prop_list_class_init (IBusPropListClass *klass) IBusObjectClass *object_class = IBUS_OBJECT_CLASS (klass); IBusSerializableClass *serializable_class = IBUS_SERIALIZABLE_CLASS (klass); - parent_class = (IBusSerializableClass *) g_type_class_peek_parent (klass); - object_class->destroy = (IBusObjectDestroyFunc) ibus_prop_list_destroy; serializable_class->serialize = (IBusSerializableSerializeFunc) ibus_prop_list_serialize; @@ -96,7 +65,7 @@ ibus_prop_list_destroy (IBusPropList *prop_list) } g_free (p); - IBUS_OBJECT_CLASS (parent_class)->destroy ((IBusObject *) prop_list); + IBUS_OBJECT_CLASS (ibus_prop_list_parent_class)->destroy ((IBusObject *) prop_list); } static gboolean @@ -108,7 +77,7 @@ ibus_prop_list_serialize (IBusPropList *prop_list, IBusProperty *prop; guint i; - retval = parent_class->serialize ((IBusSerializable *) prop_list, iter); + retval = IBUS_SERIALIZABLE_CLASS (ibus_prop_list_parent_class)->serialize ((IBusSerializable *) prop_list, iter); g_return_val_if_fail (retval, FALSE); retval = ibus_message_iter_open_container (iter, IBUS_TYPE_ARRAY, "v", &array_iter); @@ -136,7 +105,7 @@ ibus_prop_list_deserialize (IBusPropList *prop_list, IBusMessageIter array_iter; IBusProperty *prop; - retval = parent_class->deserialize ((IBusSerializable *) prop_list, iter); + retval = IBUS_SERIALIZABLE_CLASS (ibus_prop_list_parent_class)->deserialize ((IBusSerializable *) prop_list, iter); g_return_val_if_fail (retval, FALSE); g_return_val_if_fail (IBUS_IS_PROP_LIST (prop_list), FALSE); @@ -167,7 +136,7 @@ ibus_prop_list_copy (IBusPropList *dest, IBusProperty *prop; guint i; - retval = parent_class->copy ((IBusSerializable *) dest, + retval = IBUS_SERIALIZABLE_CLASS (ibus_prop_list_parent_class)->copy ((IBusSerializable *) dest, (const IBusSerializable *) src); g_return_val_if_fail (retval, FALSE); diff --git a/src/ibusproxy.c b/src/ibusproxy.c index 27987382..6ff15609 100644 --- a/src/ibusproxy.c +++ b/src/ibusproxy.c @@ -54,8 +54,6 @@ typedef struct _IBusProxyPrivate IBusProxyPrivate; static guint proxy_signals[LAST_SIGNAL] = { 0 }; /* functions prototype */ -static void ibus_proxy_class_init (IBusProxyClass *klass); -static void ibus_proxy_init (IBusProxy *proxy); static GObject *ibus_proxy_constructor (GType type, guint n_construct_params, GObjectConstructParam *construct_params); @@ -72,33 +70,7 @@ static void ibus_proxy_get_property(IBusProxy *proxy, static gboolean ibus_proxy_ibus_signal (IBusProxy *proxy, IBusMessage *message); -static IBusObjectClass *parent_class = NULL; - -GType -ibus_proxy_get_type (void) -{ - static GType type = 0; - - static const GTypeInfo type_info = { - sizeof (IBusProxyClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ibus_proxy_class_init, - NULL, /* class finalize */ - NULL, /* class data */ - sizeof (IBusProxy), - 0, - (GInstanceInitFunc) ibus_proxy_init, - }; - - if (type == 0) { - type = g_type_register_static (IBUS_TYPE_OBJECT, - "IBusProxy", - &type_info, - (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE (IBusProxy, ibus_proxy, IBUS_TYPE_OBJECT) IBusProxy * ibus_proxy_new (const gchar *name, @@ -126,8 +98,6 @@ ibus_proxy_class_init (IBusProxyClass *klass) GObjectClass *gobject_class = G_OBJECT_CLASS (klass); IBusObjectClass *ibus_object_class = IBUS_OBJECT_CLASS (klass); - parent_class = (IBusObjectClass *) g_type_class_peek_parent (klass); - g_type_class_add_private (klass, sizeof (IBusProxyPrivate)); gobject_class->constructor = ibus_proxy_constructor; @@ -260,7 +230,7 @@ ibus_proxy_constructor (GType type, IBusProxy *proxy; IBusProxyPrivate *priv; - obj = G_OBJECT_CLASS (parent_class)->constructor (type, n_construct_params, construct_params); + obj = G_OBJECT_CLASS (ibus_proxy_parent_class)->constructor (type, n_construct_params, construct_params); proxy = IBUS_PROXY (obj); priv = IBUS_PROXY_GET_PRIVATE (proxy); @@ -427,7 +397,7 @@ ibus_proxy_destroy (IBusProxy *proxy) priv->connection = NULL; } - IBUS_OBJECT_CLASS(parent_class)->destroy (IBUS_OBJECT (proxy)); + IBUS_OBJECT_CLASS(ibus_proxy_parent_class)->destroy (IBUS_OBJECT (proxy)); } static void diff --git a/src/ibusserializable.c b/src/ibusserializable.c index 5b87a259..b758fa80 100644 --- a/src/ibusserializable.c +++ b/src/ibusserializable.c @@ -51,7 +51,6 @@ static gboolean ibus_serializable_real_copy (IBusSerializable *des static IBusObjectClass *parent_class = NULL; - GType ibus_serializable_get_type (void) { diff --git a/src/ibusserver.c b/src/ibusserver.c index 079da8fd..94c10488 100644 --- a/src/ibusserver.c +++ b/src/ibusserver.c @@ -47,8 +47,6 @@ typedef struct _IBusServerPrivate IBusServerPrivate; static guint server_signals[LAST_SIGNAL] = { 0 }; /* functions prototype */ -static void ibus_server_class_init (IBusServerClass *klass); -static void ibus_server_init (IBusServer *server); static void ibus_server_destroy (IBusServer *server); static void ibus_server_set_property(IBusServer *server, guint prop_id, @@ -65,34 +63,7 @@ static void ibus_server_new_connection (IBusServer *server, IBusConnection *connection); -static IBusObjectClass *parent_class = NULL; - -GType -ibus_server_get_type (void) -{ - static GType type = 0; - - static const GTypeInfo type_info = { - sizeof (IBusServerClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ibus_server_class_init, - NULL, /* class finalize */ - NULL, /* class data */ - sizeof (IBusServer), - 0, - (GInstanceInitFunc) ibus_server_init, - }; - - if (type == 0) { - type = g_type_register_static (IBUS_TYPE_OBJECT, - "IBusServer", - &type_info, - (GTypeFlags)0); - } - - return type; -} +G_DEFINE_TYPE (IBusServer, ibus_server, IBUS_TYPE_OBJECT) IBusServer * ibus_server_new (void) @@ -119,8 +90,6 @@ ibus_server_class_init (IBusServerClass *klass) GObjectClass *gobject_class = G_OBJECT_CLASS (klass); IBusObjectClass *ibus_object_class = IBUS_OBJECT_CLASS (klass); - parent_class = (IBusObjectClass *) g_type_class_peek_parent (klass); - g_type_class_add_private (klass, sizeof (IBusServerPrivate)); gobject_class->set_property = (GObjectSetPropertyFunc) ibus_server_set_property; @@ -189,7 +158,7 @@ ibus_server_destroy (IBusServer *server) priv->server = NULL; } - IBUS_OBJECT_CLASS(parent_class)->destroy (IBUS_OBJECT (server)); + IBUS_OBJECT_CLASS(ibus_server_parent_class)->destroy (IBUS_OBJECT (server)); } static void diff --git a/src/ibusservice.c b/src/ibusservice.c index c194c073..0af0c93d 100644 --- a/src/ibusservice.c +++ b/src/ibusservice.c @@ -46,8 +46,6 @@ typedef struct _IBusServicePrivate IBusServicePrivate; static guint service_signals[LAST_SIGNAL] = { 0 }; /* functions prototype */ -static void ibus_service_class_init (IBusServiceClass *klass); -static void ibus_service_init (IBusService *service); static void ibus_service_destroy (IBusService *service); static void ibus_service_set_property (IBusService *service, guint prop_id, @@ -64,33 +62,7 @@ static gboolean ibus_service_ibus_signal (IBusService *service, IBusConnection *connection, IBusMessage *message); -static IBusObjectClass *parent_class = NULL; - -GType -ibus_service_get_type (void) -{ - static GType type = 0; - - static const GTypeInfo type_info = { - sizeof (IBusServiceClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ibus_service_class_init, - NULL, /* class finalize */ - NULL, /* class data */ - sizeof (IBusService), - 0, - (GInstanceInitFunc) ibus_service_init, - }; - - if (type == 0) { - type = g_type_register_static (IBUS_TYPE_OBJECT, - "IBusService", - &type_info, - (GTypeFlags) 0); - } - return type; -} +G_DEFINE_TYPE (IBusService, ibus_service, IBUS_TYPE_OBJECT) IBusService * ibus_service_new (const gchar *path) @@ -108,8 +80,6 @@ ibus_service_class_init (IBusServiceClass *klass) GObjectClass *gobject_class = G_OBJECT_CLASS (klass); IBusObjectClass *ibus_object_class = IBUS_OBJECT_CLASS (klass); - parent_class = (IBusObjectClass *) g_type_class_peek_parent (klass); - g_type_class_add_private (klass, sizeof (IBusServicePrivate)); gobject_class->set_property = (GObjectSetPropertyFunc) ibus_service_set_property; @@ -206,7 +176,7 @@ ibus_service_destroy (IBusService *service) g_free (priv->path); priv->path = NULL; - IBUS_OBJECT_CLASS(parent_class)->destroy (IBUS_OBJECT (service)); + IBUS_OBJECT_CLASS(ibus_service_parent_class)->destroy (IBUS_OBJECT (service)); } static void diff --git a/src/ibustext.c b/src/ibustext.c index b13b17b8..78d5d054 100644 --- a/src/ibustext.c +++ b/src/ibustext.c @@ -21,8 +21,6 @@ #include "ibustext.h" /* functions prototype */ -static void ibus_text_class_init (IBusTextClass *klass); -static void ibus_text_init (IBusText *text); static void ibus_text_destroy (IBusText *text); static gboolean ibus_text_serialize (IBusText *text, IBusMessageIter *iter); @@ -31,34 +29,7 @@ static gboolean ibus_text_deserialize (IBusText *text, static gboolean ibus_text_copy (IBusText *dest, const IBusText *src); -static IBusSerializableClass *parent_class = NULL; - -GType -ibus_text_get_type (void) -{ - static GType type = 0; - - static const GTypeInfo type_info = { - sizeof (IBusTextClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ibus_text_class_init, - NULL, /* class finialize */ - NULL, /* class data */ - sizeof (IBusText), - 0, - (GInstanceInitFunc) ibus_text_init, - }; - - if (type == 0) { - type = g_type_register_static (IBUS_TYPE_SERIALIZABLE, - "IBusText", - &type_info, - 0); - } - - return type; -} +G_DEFINE_TYPE (IBusText, ibus_text, IBUS_TYPE_SERIALIZABLE) static void ibus_text_class_init (IBusTextClass *klass) @@ -66,7 +37,7 @@ ibus_text_class_init (IBusTextClass *klass) IBusObjectClass *object_class = IBUS_OBJECT_CLASS (klass); IBusSerializableClass *serializable_class = IBUS_SERIALIZABLE_CLASS (klass); - parent_class = (IBusSerializableClass *) g_type_class_peek_parent (klass); + ibus_text_parent_class = (IBusSerializableClass *) g_type_class_peek_parent (klass); object_class->destroy = (IBusObjectDestroyFunc) ibus_text_destroy; @@ -98,7 +69,7 @@ ibus_text_destroy (IBusText *text) text->attrs = NULL; } - IBUS_OBJECT_CLASS (parent_class)->destroy ((IBusObject *)text); + IBUS_OBJECT_CLASS (ibus_text_parent_class)->destroy ((IBusObject *)text); } static gboolean @@ -107,7 +78,8 @@ ibus_text_serialize (IBusText *text, { gboolean retval; - retval = parent_class->serialize ((IBusSerializable *)text, iter); + retval = IBUS_SERIALIZABLE_CLASS (ibus_text_parent_class)->serialize ( + (IBusSerializable *)text, iter); g_return_val_if_fail (retval, FALSE); retval = ibus_message_iter_append (iter, G_TYPE_STRING, &text->text); @@ -131,7 +103,8 @@ ibus_text_deserialize (IBusText *text, gboolean retval; gchar *str; - retval = parent_class->deserialize ((IBusSerializable *)text, iter); + retval = IBUS_SERIALIZABLE_CLASS (ibus_text_parent_class)->deserialize ( + (IBusSerializable *)text, iter); g_return_val_if_fail (retval, FALSE); retval = ibus_message_iter_get (iter, G_TYPE_STRING, &str); @@ -160,8 +133,9 @@ ibus_text_copy (IBusText *dest, { gboolean retval; - retval = parent_class->copy ((IBusSerializable *)dest, - (IBusSerializable *)src); + retval = IBUS_SERIALIZABLE_CLASS (ibus_text_parent_class)->copy ( + (IBusSerializable *)dest, + (IBusSerializable *)src); g_return_val_if_fail (retval, FALSE); g_return_val_if_fail (IBUS_IS_TEXT (dest), FALSE);