Use G_DEFINE_TYPE to simplified code.
This commit is contained in:
Родитель
bfdbf9855d
Коммит
f0a7973f66
|
@ -34,7 +34,6 @@ typedef struct _BusConnectionPrivate BusConnectionPrivate;
|
|||
// static guint _signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
/* functions prototype */
|
||||
static void bus_connection_class_init (BusConnectionClass *klass);
|
||||
static void bus_connection_init (BusConnection *connection);
|
||||
static void bus_connection_destroy (BusConnection *connection);
|
||||
static gboolean bus_connection_authenticate_unix_user
|
||||
|
@ -47,34 +46,7 @@ static gboolean bus_connection_dbus_signal (BusConnection *connection,
|
|||
DBusMessage *message);
|
||||
#endif
|
||||
|
||||
static IBusObjectClass *parent_class = NULL;
|
||||
|
||||
GType
|
||||
bus_connection_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
static const GTypeInfo type_info = {
|
||||
sizeof (BusConnectionClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) bus_connection_class_init,
|
||||
NULL, /* class finalize */
|
||||
NULL, /* class data */
|
||||
sizeof (IBusConnection),
|
||||
0,
|
||||
(GInstanceInitFunc) bus_connection_init,
|
||||
};
|
||||
|
||||
if (type == 0) {
|
||||
type = g_type_register_static (IBUS_TYPE_CONNECTION,
|
||||
"BusConnection",
|
||||
&type_info,
|
||||
(GTypeFlags)0);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
G_DEFINE_TYPE (BusConnection, bus_connection, IBUS_TYPE_CONNECTION)
|
||||
|
||||
BusConnection *
|
||||
bus_connection_new (void)
|
||||
|
@ -89,8 +61,6 @@ bus_connection_class_init (BusConnectionClass *klass)
|
|||
IBusObjectClass *ibus_object_class = IBUS_OBJECT_CLASS (klass);
|
||||
IBusConnectionClass *ibus_connection_class = IBUS_CONNECTION_CLASS (klass);
|
||||
|
||||
parent_class = (IBusObjectClass *) g_type_class_peek_parent (klass);
|
||||
|
||||
ibus_object_class->destroy = (IBusObjectDestroyFunc) bus_connection_destroy;
|
||||
|
||||
ibus_connection_class->authenticate_unix_user = bus_connection_authenticate_unix_user;
|
||||
|
@ -111,7 +81,7 @@ bus_connection_destroy (BusConnection *connection)
|
|||
{
|
||||
GList *name;
|
||||
|
||||
IBUS_OBJECT_CLASS(parent_class)->destroy (IBUS_OBJECT (connection));
|
||||
IBUS_OBJECT_CLASS(bus_connection_parent_class)->destroy (IBUS_OBJECT (connection));
|
||||
|
||||
if (connection->unique_name) {
|
||||
g_free (connection->unique_name);
|
||||
|
@ -147,7 +117,7 @@ bus_connection_ibus_message (BusConnection *connection,
|
|||
g_free(str);
|
||||
#endif
|
||||
|
||||
retval = IBUS_CONNECTION_CLASS (parent_class)->ibus_message (
|
||||
retval = IBUS_CONNECTION_CLASS (bus_connection_parent_class)->ibus_message (
|
||||
(IBusConnection *)connection,
|
||||
message);
|
||||
return retval;
|
||||
|
@ -159,7 +129,7 @@ bus_connection_dbus_signal (BusConnection *connection,
|
|||
DBusMessage *message)
|
||||
{
|
||||
gboolean retval;
|
||||
retval = IBUS_CONNECTION_CLASS (parent_class)->dbus_signal (
|
||||
retval = IBUS_CONNECTION_CLASS (bus_connection_parent_class)->dbus_signal (
|
||||
IBUS_CONNECTION (connection), message);
|
||||
return retval;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ enum {
|
|||
static guint dbus_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
/* functions prototype */
|
||||
static void bus_dbus_impl_class_init (BusDBusImplClass *klass);
|
||||
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,
|
||||
|
@ -57,33 +56,7 @@ static void _connection_destroy_cb (BusConnection *connection,
|
|||
static void _rule_destroy_cb (BusMatchRule *rule,
|
||||
BusDBusImpl *dbus);
|
||||
|
||||
static IBusServiceClass *parent_class = NULL;
|
||||
|
||||
GType
|
||||
bus_dbus_impl_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
static const GTypeInfo type_info = {
|
||||
sizeof (BusDBusImplClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) bus_dbus_impl_class_init,
|
||||
NULL, /* class finalize */
|
||||
NULL, /* class data */
|
||||
sizeof (BusDBusImpl),
|
||||
0,
|
||||
(GInstanceInitFunc) bus_dbus_impl_init,
|
||||
};
|
||||
|
||||
if (type == 0) {
|
||||
type = g_type_register_static (IBUS_TYPE_SERVICE,
|
||||
"BusDBusImpl",
|
||||
&type_info,
|
||||
(GTypeFlags) 0);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
G_DEFINE_TYPE(BusDBusImpl, bus_dbus_impl, IBUS_TYPE_SERVICE)
|
||||
|
||||
BusDBusImpl *
|
||||
bus_dbus_impl_get_default (void)
|
||||
|
@ -105,8 +78,6 @@ bus_dbus_impl_class_init (BusDBusImplClass *klass)
|
|||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
IBusServiceClass *service_class = IBUS_SERVICE_CLASS (klass);
|
||||
|
||||
parent_class = (IBusServiceClass *) g_type_class_peek_parent (klass);
|
||||
|
||||
IBUS_OBJECT_CLASS (gobject_class)->destroy = (IBusObjectDestroyFunc) bus_dbus_impl_destroy;
|
||||
|
||||
service_class->ibus_message = (ServiceIBusMessageFunc) bus_dbus_impl_ibus_message;
|
||||
|
@ -175,7 +146,7 @@ bus_dbus_impl_destroy (BusDBusImpl *dbus)
|
|||
dbus->names = NULL;
|
||||
dbus->objects = NULL;
|
||||
|
||||
G_OBJECT_CLASS(parent_class)->dispose (G_OBJECT (dbus));
|
||||
G_OBJECT_CLASS(bus_dbus_impl_parent_class)->dispose (G_OBJECT (dbus));
|
||||
}
|
||||
|
||||
|
||||
|
@ -778,9 +749,10 @@ bus_dbus_impl_ibus_message (BusDBusImpl *dbus,
|
|||
}
|
||||
}
|
||||
|
||||
return parent_class->ibus_message ((IBusService *) dbus,
|
||||
(IBusConnection *) connection,
|
||||
message);
|
||||
return IBUS_SERVICE_CLASS (bus_dbus_impl_parent_class)->ibus_message (
|
||||
(IBusService *) dbus,
|
||||
(IBusConnection *) connection,
|
||||
message);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -52,40 +52,13 @@ static guint engine_signals[LAST_SIGNAL] = { 0 };
|
|||
// static guint engine_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
/* functions prototype */
|
||||
static void bus_engine_proxy_class_init (BusEngineProxyClass *klass);
|
||||
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,
|
||||
IBusMessage *message);
|
||||
|
||||
static IBusProxyClass *parent_class = NULL;
|
||||
|
||||
GType
|
||||
bus_engine_proxy_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
static const GTypeInfo type_info = {
|
||||
sizeof (BusEngineProxyClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) bus_engine_proxy_class_init,
|
||||
NULL, /* class finalize */
|
||||
NULL, /* class data */
|
||||
sizeof (BusEngineProxy),
|
||||
0,
|
||||
(GInstanceInitFunc) bus_engine_proxy_init,
|
||||
};
|
||||
|
||||
if (type == 0) {
|
||||
type = g_type_register_static (IBUS_TYPE_PROXY,
|
||||
"BusEngineProxy",
|
||||
&type_info,
|
||||
(GTypeFlags)0);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
G_DEFINE_TYPE (BusEngineProxy, bus_engine_proxy, IBUS_TYPE_PROXY)
|
||||
|
||||
BusEngineProxy *
|
||||
bus_engine_proxy_new (const gchar *path,
|
||||
|
@ -124,7 +97,7 @@ bus_engine_proxy_class_init (BusEngineProxyClass *klass)
|
|||
IBusProxyClass *proxy_class = IBUS_PROXY_CLASS (klass);
|
||||
|
||||
|
||||
parent_class = (IBusProxyClass *) g_type_class_peek_parent (klass);
|
||||
bus_engine_proxy_parent_class = (IBusProxyClass *) g_type_class_peek_parent (klass);
|
||||
|
||||
ibus_object_class->destroy = (IBusObjectDestroyFunc) bus_engine_proxy_real_destroy;
|
||||
|
||||
|
@ -361,7 +334,7 @@ bus_engine_proxy_real_destroy (BusEngineProxy *engine)
|
|||
engine->keymap = NULL;
|
||||
}
|
||||
|
||||
IBUS_OBJECT_CLASS(parent_class)->destroy (IBUS_OBJECT (engine));
|
||||
IBUS_OBJECT_CLASS(bus_engine_proxy_parent_class)->destroy (IBUS_OBJECT (engine));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
@ -26,38 +26,10 @@
|
|||
#include "option.h"
|
||||
|
||||
/* functions prototype */
|
||||
static void bus_factory_proxy_class_init (BusFactoryProxyClass *klass);
|
||||
static void bus_factory_proxy_init (BusFactoryProxy *factory);
|
||||
static void bus_factory_proxy_destroy (BusFactoryProxy *factory);
|
||||
|
||||
|
||||
static IBusProxyClass *parent_class = NULL;
|
||||
|
||||
GType
|
||||
bus_factory_proxy_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
static const GTypeInfo type_info = {
|
||||
sizeof (BusFactoryProxyClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) bus_factory_proxy_class_init,
|
||||
NULL, /* class finalize */
|
||||
NULL, /* class data */
|
||||
sizeof (BusFactoryProxy),
|
||||
0,
|
||||
(GInstanceInitFunc) bus_factory_proxy_init,
|
||||
};
|
||||
|
||||
if (type == 0) {
|
||||
type = g_type_register_static (IBUS_TYPE_PROXY,
|
||||
"BusFactoryProxy",
|
||||
&type_info,
|
||||
(GTypeFlags)0);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
G_DEFINE_TYPE (BusFactoryProxy, bus_factory_proxy, IBUS_TYPE_PROXY)
|
||||
|
||||
BusFactoryProxy *
|
||||
bus_factory_proxy_new (IBusComponent *component,
|
||||
|
@ -102,10 +74,7 @@ bus_factory_proxy_class_init (BusFactoryProxyClass *klass)
|
|||
{
|
||||
IBusObjectClass *ibus_object_class = IBUS_OBJECT_CLASS (klass);
|
||||
|
||||
parent_class = (IBusProxyClass *) g_type_class_peek_parent (klass);
|
||||
|
||||
ibus_object_class->destroy = (IBusObjectDestroyFunc) bus_factory_proxy_destroy;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -133,7 +102,7 @@ bus_factory_proxy_destroy (BusFactoryProxy *factory)
|
|||
factory->component = NULL;
|
||||
}
|
||||
|
||||
IBUS_OBJECT_CLASS(parent_class)->destroy (IBUS_OBJECT (factory));
|
||||
IBUS_OBJECT_CLASS(bus_factory_proxy_parent_class)->destroy (IBUS_OBJECT (factory));
|
||||
}
|
||||
|
||||
IBusComponent *
|
||||
|
|
|
@ -47,7 +47,6 @@ enum {
|
|||
// static guint _signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
/* functions prototype */
|
||||
static void bus_ibus_impl_class_init (BusIBusImplClass *klass);
|
||||
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,
|
||||
|
@ -68,33 +67,7 @@ static void bus_ibus_impl_registry_changed (BusIBusImpl *ibus);
|
|||
static void _factory_destroy_cb (BusFactoryProxy *factory,
|
||||
BusIBusImpl *ibus);
|
||||
|
||||
static IBusServiceClass *parent_class = NULL;
|
||||
|
||||
GType
|
||||
bus_ibus_impl_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
static const GTypeInfo type_info = {
|
||||
sizeof (BusIBusImplClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) bus_ibus_impl_class_init,
|
||||
NULL, /* class finalize */
|
||||
NULL, /* class data */
|
||||
sizeof (BusIBusImpl),
|
||||
0,
|
||||
(GInstanceInitFunc) bus_ibus_impl_init,
|
||||
};
|
||||
|
||||
if (type == 0) {
|
||||
type = g_type_register_static (IBUS_TYPE_SERVICE,
|
||||
"BusIBusImpl",
|
||||
&type_info,
|
||||
(GTypeFlags) 0);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
G_DEFINE_TYPE(BusIBusImpl, bus_ibus_impl, IBUS_TYPE_SERVICE)
|
||||
|
||||
BusIBusImpl *
|
||||
bus_ibus_impl_get_default (void)
|
||||
|
@ -116,8 +89,6 @@ bus_ibus_impl_class_init (BusIBusImplClass *klass)
|
|||
{
|
||||
IBusObjectClass *ibus_object_class = IBUS_OBJECT_CLASS (klass);
|
||||
|
||||
parent_class = (IBusServiceClass *) g_type_class_peek_parent (klass);
|
||||
|
||||
ibus_object_class->destroy = (IBusObjectDestroyFunc) bus_ibus_impl_destroy;
|
||||
|
||||
IBUS_SERVICE_CLASS (klass)->ibus_message = (ServiceIBusMessageFunc) bus_ibus_impl_ibus_message;
|
||||
|
@ -599,7 +570,7 @@ bus_ibus_impl_destroy (BusIBusImpl *ibus)
|
|||
|
||||
bus_server_quit (BUS_DEFAULT_SERVER);
|
||||
ibus_object_destroy ((IBusObject *) BUS_DEFAULT_SERVER);
|
||||
IBUS_OBJECT_CLASS(parent_class)->destroy (IBUS_OBJECT (ibus));
|
||||
IBUS_OBJECT_CLASS(bus_ibus_impl_parent_class)->destroy (IBUS_OBJECT (ibus));
|
||||
}
|
||||
|
||||
/* introspectable interface */
|
||||
|
@ -1259,9 +1230,10 @@ bus_ibus_impl_ibus_message (BusIBusImpl *ibus,
|
|||
}
|
||||
}
|
||||
|
||||
return parent_class->ibus_message ((IBusService *) ibus,
|
||||
(IBusConnection *) connection,
|
||||
message);
|
||||
return IBUS_SERVICE_CLASS(bus_ibus_impl_parent_class)->ibus_message (
|
||||
(IBusService *) ibus,
|
||||
(IBusConnection *) connection,
|
||||
message);
|
||||
}
|
||||
|
||||
BusFactoryProxy *
|
||||
|
|
|
@ -39,7 +39,6 @@ static guint panel_signals[LAST_SIGNAL] = { 0 };
|
|||
// static guint engine_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
/* functions prototype */
|
||||
static void bus_panel_proxy_class_init (BusPanelProxyClass *klass);
|
||||
static void bus_panel_proxy_init (BusPanelProxy *panel);
|
||||
static void bus_panel_proxy_real_destroy (BusPanelProxy *panel);
|
||||
|
||||
|
@ -59,33 +58,8 @@ static void bus_panel_proxy_property_activate
|
|||
const gchar *prop_name,
|
||||
gint prop_state);
|
||||
|
||||
static IBusProxyClass *parent_class = NULL;
|
||||
|
||||
GType
|
||||
bus_panel_proxy_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
static const GTypeInfo type_info = {
|
||||
sizeof (BusPanelProxyClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) bus_panel_proxy_class_init,
|
||||
NULL, /* class finalize */
|
||||
NULL, /* class data */
|
||||
sizeof (BusPanelProxy),
|
||||
0,
|
||||
(GInstanceInitFunc) bus_panel_proxy_init,
|
||||
};
|
||||
|
||||
if (type == 0) {
|
||||
type = g_type_register_static (IBUS_TYPE_PROXY,
|
||||
"BusPanelProxy",
|
||||
&type_info,
|
||||
(GTypeFlags)0);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
G_DEFINE_TYPE(BusPanelProxy, bus_panel_proxy, IBUS_TYPE_PROXY)
|
||||
|
||||
BusPanelProxy *
|
||||
bus_panel_proxy_new (BusConnection *connection)
|
||||
|
@ -108,9 +82,6 @@ bus_panel_proxy_class_init (BusPanelProxyClass *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);
|
||||
|
||||
klass->page_up = bus_panel_proxy_page_up;
|
||||
klass->page_down = bus_panel_proxy_page_down;
|
||||
klass->cursor_up = bus_panel_proxy_cursor_up;
|
||||
|
@ -225,7 +196,7 @@ bus_panel_proxy_real_destroy (BusPanelProxy *panel)
|
|||
panel->focused_context = NULL;
|
||||
}
|
||||
|
||||
IBUS_OBJECT_CLASS(parent_class)->destroy (IBUS_OBJECT (panel));
|
||||
IBUS_OBJECT_CLASS(bus_panel_proxy_parent_class)->destroy (IBUS_OBJECT (panel));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
Загрузка…
Ссылка в новой задаче