Add gobject-2.0 fix to make TypeModule an abstract class
authorPhilipp Zabel <philipp.zabel@gmail.com>
Thu, 8 Jul 2010 17:31:31 +0000 (19:31 +0200)
committerPhilipp Zabel <philipp.zabel@gmail.com>
Wed, 14 Jul 2010 21:34:08 +0000 (23:34 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=621317

Makefile.am
src/plugin-registrar.vala
vapi/gobject-2.0-fix.vapi [new file with mode: 0644]

index 0f7b627..ab4ca35 100644 (file)
@@ -82,7 +82,8 @@ src/main.c: ${cinaest_VALASOURCES}
        ${VALAC} -C ${cinaest_VALASOURCES} ${cinaest_VALAFLAGS}
 
 cinaest_VALAFLAGS = --disable-dbus-transformation --vapidir ./vapi --pkg config --pkg cinaest \
-       --pkg dbus-glib-1 --pkg gconf-2.0 --pkg hildon-1 --pkg libosso --pkg gmodule-2.0
+       --pkg dbus-glib-1 --pkg gconf-2.0 --pkg hildon-1 --pkg libosso --pkg gmodule-2.0 \
+       --pkg gobject-2.0-fix
 cinaest_CFLAGS = ${CINAEST_CFLAGS} ${DBUS_CFLAGS} ${GCONF_CFLAGS} ${HILDON_CFLAGS} \
        ${MAEMO_LAUNCHER_CFLAGS} ${OSSO_CFLAGS} ${GMODULE_CFLAGS} \
        -DGETTEXT_PACKAGE=\"@GETTEXT_PACKAGE@\"
index 69eccb7..6dd314d 100644 (file)
  * along with Cinaest. If not, see <http://www.gnu.org/licenses/>.
  */
 
-public class PluginRegistrar<T> : Object {
+public class PluginRegistrar<T> : GLibFix.TypeModule {
        public string path { get; construct; }
 
        private Type type;
        private Module module;
 
-       private delegate Type RegisterPluginFunction ();
+       private delegate Type RegisterPluginFunction (GLibFix.TypeModule module);
 
        construct {
                assert (Module.supported ());
@@ -32,7 +32,7 @@ public class PluginRegistrar<T> : Object {
                Object (path: _path);
        }
 
-       public bool load () {
+       public override bool load () {
                stdout.printf ("Loading plugin with path: '%s'\n", path);
 
                module = Module.open (path, ModuleFlags.BIND_LAZY);
@@ -46,7 +46,7 @@ public class PluginRegistrar<T> : Object {
                module.symbol ("register_plugin", out function);
                RegisterPluginFunction register_plugin = (RegisterPluginFunction) function;
 
-               type = register_plugin ();
+               type = register_plugin (this);
                stdout.printf ("Plugin type: %s\n\n", type.name ());
 
                // So it doesn't vanish as soon as the registar goes
@@ -55,6 +55,9 @@ public class PluginRegistrar<T> : Object {
                return true;
        }
 
+       public override void unload () {
+       }
+
        public T new_object () {
                return Object.new (type);
        }
diff --git a/vapi/gobject-2.0-fix.vapi b/vapi/gobject-2.0-fix.vapi
new file mode 100644 (file)
index 0000000..f45e822
--- /dev/null
@@ -0,0 +1,15 @@
+using GLib;
+
+[CCode (cprefix = "G", lower_case_cprefix = "g_", cheader_filename = "glib.h", gir_namespace = "GObject", gir_version = "2.0")]
+namespace GLibFix {
+       [CCode (lower_case_csuffix = "type_module", unref_function = "")]
+       public abstract class TypeModule : Object, TypePlugin {
+               public bool use ();
+               public void unuse ();
+               public void set_name (string name);
+               [NoWrapper]
+               public abstract bool load ();
+               [NoWrapper]
+               public abstract void unload ();
+       }
+}