Enable dynamic registration of StrongswanConnection(s) type.
authorTobias Brunner <tobias@strongswan.org>
Fri, 4 Jun 2010 12:41:45 +0000 (14:41 +0200)
committerTobias Brunner <tobias@strongswan.org>
Thu, 14 Oct 2010 15:36:17 +0000 (17:36 +0200)
Because status menu plugins get loaded and unloaded dynamically by the
Hildon Desktop, we have to register our Types dynamically.

src/frontends/maemo/src/strongswan-connection.c
src/frontends/maemo/src/strongswan-connection.h
src/frontends/maemo/src/strongswan-connections.c
src/frontends/maemo/src/strongswan-connections.h

index a861dfa..28c8f13 100644 (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,
index e80a162..2e4fd45 100644 (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__ */
index 3f152c2..2686a62 100644 (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)
 {
index ff75341..f7a42ac 100644 (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__ */