Enable dynamic registration of StrongswanConnection(s) type.

Because status menu plugins get loaded and unloaded dynamically by the
Hildon Desktop, we have to register our Types dynamically.
This commit is contained in:
Tobias Brunner 2010-06-04 14:41:45 +02:00
parent 41b2fbb29f
commit 59df6ff93c
4 changed files with 38 additions and 0 deletions

View File

@ -42,7 +42,15 @@ enum
PROP_PASS,
};
#ifndef USE_DYNAMIC_TYPES
G_DEFINE_TYPE (StrongswanConnection, strongswan_connection, G_TYPE_OBJECT);
#else
G_DEFINE_DYNAMIC_TYPE (StrongswanConnection, strongswan_connection, G_TYPE_OBJECT);
void strongswan_connection_register (GTypeModule *type_module)
{
strongswan_connection_register_type (type_module);
}
#endif
static void
strongswan_connection_get_property (GObject *object,
@ -176,6 +184,13 @@ strongswan_connection_class_init (StrongswanConnectionClass *klass)
g_type_class_add_private (klass, sizeof (StrongswanConnectionPrivate));
}
#ifdef USE_DYNAMIC_TYPES
static void
strongswan_connection_class_finalize (StrongswanConnectionClass *klass)
{
}
#endif
static inline gchar *
get_string_from_key_file (GKeyFile *key_file,
const gchar *name,

View File

@ -51,6 +51,10 @@ StrongswanConnection *strongswan_connection_new (const gchar *name);
StrongswanConnection *strongswan_connection_new_from_key_file(GKeyFile *key_file, const gchar *name);
void strongswan_connection_save_to_key_file (GKeyFile *key_file, StrongswanConnection *connection);
#ifdef USE_DYNAMIC_TYPES
void strongswan_connection_register (GTypeModule *type_module);
#endif
G_END_DECLS
#endif /* __STRONGSWAN_CONNECTION_H__ */

View File

@ -34,7 +34,15 @@ struct _StrongswanConnectionsPrivate
GtkTreeModel *model;
};
#ifndef USE_DYNAMIC_TYPES
G_DEFINE_TYPE (StrongswanConnections, strongswan_connections, G_TYPE_OBJECT);
#else
G_DEFINE_DYNAMIC_TYPE (StrongswanConnections, strongswan_connections, G_TYPE_OBJECT);
void strongswan_connections_register (GTypeModule *type_module)
{
strongswan_connections_register_type (type_module);
}
#endif
static void
strongswan_connections_load_connections (StrongswanConnections *connections)
@ -218,6 +226,13 @@ strongswan_connections_class_init (StrongswanConnectionsClass *klass)
g_type_class_add_private (klass, sizeof (StrongswanConnectionsPrivate));
}
#ifdef USE_DYNAMIC_TYPES
static void
strongswan_connections_class_finalize (StrongswanConnectionsClass *klass)
{
}
#endif
GtkTreeModel *
strongswan_connections_get_model (StrongswanConnections *self)
{

View File

@ -56,6 +56,10 @@ StrongswanConnection *strongswan_connections_get_connection (StrongswanConnectio
void strongswan_connections_save_connection (StrongswanConnections *self, StrongswanConnection *conn);
void strongswan_connections_remove_connection (StrongswanConnections *self, const gchar *name);
#ifdef USE_DYNAMIC_TYPES
void strongswan_connections_register (GTypeModule *type_module);
#endif
G_END_DECLS
#endif /* __STRONGSWAN_CONNECTIONS_H__ */