[Kazehakase-cvs] kazehakase-svn [2961] * src/Makefile.am, src/kz-ext-impl.h: removed kz-ext-impl.h.

Back to archive index

svnno****@sourc***** svnno****@sourc*****
Thu Mar 22 18:17:51 JST 2007


Revision: 2961
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=2961
Author:   kous
Date:     2007-03-22 18:17:50 +0900 (Thu, 22 Mar 2007)

Log Message:
-----------
* src/Makefile.am, src/kz-ext-impl.h: removed kz-ext-impl.h.
* src/kz-ext.[ch], ext/ruby/kz-rb-ext.c, ext/ruby/Makefile.am:
  used KzModule.
* src/kz-module.[ch], src/kz-embed.c: added instantiate API from
  module and old API is renamed to kz_module_find_and_instantiate().
* src/main.c (init_address): renamed to initial_address.

Modified Paths:
--------------
    kazehakase/trunk/ChangeLog
    kazehakase/trunk/ext/ruby/Makefile.am
    kazehakase/trunk/ext/ruby/kz-rb-ext.c
    kazehakase/trunk/src/Makefile.am
    kazehakase/trunk/src/kz-embed.c
    kazehakase/trunk/src/kz-ext.c
    kazehakase/trunk/src/kz-ext.h
    kazehakase/trunk/src/kz-module.c
    kazehakase/trunk/src/kz-module.h
    kazehakase/trunk/src/main.c

Removed Paths:
-------------
    kazehakase/trunk/src/kz-ext-impl.h

Modified: kazehakase/trunk/ChangeLog
===================================================================
--- kazehakase/trunk/ChangeLog	2007-03-22 07:18:35 UTC (rev 2960)
+++ kazehakase/trunk/ChangeLog	2007-03-22 09:17:50 UTC (rev 2961)
@@ -1,5 +1,15 @@
 2007-03-22  Kouhei Sutou  <kou****@cozmi*****>
 
+	* src/Makefile.am, src/kz-ext-impl.h: removed kz-ext-impl.h.
+
+	* src/kz-ext.[ch], ext/ruby/kz-rb-ext.c, ext/ruby/Makefile.am:
+	used KzModule.
+
+	* src/kz-module.[ch], src/kz-embed.c: added instantiate API from
+	module and old API is renamed to kz_module_find_and_instantiate().
+
+	* src/main.c (init_address): renamed to initial_address.
+
 	* src/bookmarks/kz-bookmark-tab-menu.c (cb_folder_get_children):
 	added NULL check.
 

Modified: kazehakase/trunk/ext/ruby/Makefile.am
===================================================================
--- kazehakase/trunk/ext/ruby/Makefile.am	2007-03-22 07:18:35 UTC (rev 2960)
+++ kazehakase/trunk/ext/ruby/Makefile.am	2007-03-22 09:17:50 UTC (rev 2961)
@@ -1,7 +1,6 @@
 # -*- Mode: Makefile; tab-width: 8; indent-tabs-mode: t; -*-
 
-extrubydir = $(extdir)/ruby
-extruby_LTLIBRARIES = libkzext.la
+ext_LTLIBRARIES = ruby.la
 
 AM_CPPFLAGS =						\
 	-DLOCALEDIR=\""$(localedir)"\"			\
@@ -41,7 +40,7 @@
 	-I$(top_srcdir)/src/utils			\
 	-I$(top_srcdir)/src/widget
 
-libkzext_la_SOURCES =				\
+ruby_la_SOURCES =				\
 	kz-rb-ext.c kz-rb-ext.h			\
 	kz-rb-app.c				\
 	kz-rb-window.c				\
@@ -55,11 +54,18 @@
 	kz-rb-bookmark.c			\
 	kz-rb-sidebar.c
 
-libkzext_la_LDFLAGS =				\
+LDFLAGS =					\
+	-rpath $(extdir)			\
+	-avoid-version				\
+	-module					\
+	-export-dynamic $(no_undefined)		\
+	 $(LIBTOOL_EXPORT_OPTIONS)
+
+ruby_la_LDFLAGS =				\
 	$(RUBY_LDFLAGS)				\
 	$(RUBY_EXT_LDFLAGS)
 
-libkzext_la_LIBADD =				\
+ruby_la_LIBADD =				\
 	$(INTLLIBS)				\
 	$(GTK_LIBS)				\
 	$(LIBGNUTLS_LIBS)			\

Modified: kazehakase/trunk/ext/ruby/kz-rb-ext.c
===================================================================
--- kazehakase/trunk/ext/ruby/kz-rb-ext.c	2007-03-22 07:18:35 UTC (rev 2960)
+++ kazehakase/trunk/ext/ruby/kz-rb-ext.c	2007-03-22 09:17:50 UTC (rev 2961)
@@ -22,8 +22,10 @@
 #include <glib/gi18n.h>
 #include "kz-rb-ext.h"
 
-#include "kz-ext-impl.h"
+#include "kz-ext.h"
+#include "kz-module-impl.h"
 
+
 #ifdef POSIX_SIGNAL
 #define ruby_signal(sig, handle) posix_signal((sig), (handle))
 #else
@@ -125,15 +127,16 @@
 #endif
 }
 
-G_MODULE_EXPORT void
-KZ_EXT_IMPL_INIT (void *init_address)
+
+static void
+init (gpointer initial_address)
 {
     gchar *dirname;
     char *argv[] = {"kazehakase"};
 
     kz_ext_ruby_init();
 
-    Init_stack(init_address);
+    Init_stack(initial_address);
 
     ruby_init_loadpath();
 
@@ -167,8 +170,8 @@
     }
 }
 
-G_MODULE_EXPORT void
-KZ_EXT_IMPL_SETUP (KzWindow *kz)
+static void
+setup (KzExt *ext, KzWindow *kz)
 {
     if (RTEST(rb_const_get(mKz, rb_intern("ENABLE")))) {
         rb_funcall(mKz, rb_intern("setup"), 1, GOBJ2RVAL(kz));
@@ -176,9 +179,197 @@
     }
 }
 
-G_MODULE_EXPORT void
-KZ_EXT_IMPL_EXIT (gboolean success)
+static void
+cleanup (void)
 {
     rb_funcall(mKz, rb_intern("exit"), 0);
     ruby_cleanup(0);
 }
+
+
+enum {
+    PROP_0,
+    PROP_INITIAL_ADDRESS
+};
+
+#define KZ_TYPE_RUBY_EXT		kz_type_ruby_ext
+#define KZ_RUBY_EXT(obj)		(G_TYPE_CHECK_INSTANCE_CAST ((obj), KZ_TYPE_RUBY_EXT, KzRubyExt))
+#define KZ_RUBY_EXT_CLASS(klass)	(G_TYPE_CHECK_CLASS_CAST ((klass), KZ_TYPE_RUBY_EXT, KzRubyExtClass))
+#define KZ_IS_RUBY_EXT(obj)	(G_TYPE_CHECK_INSTANCE_TYPE ((obj), KZ_TYPE_RUBY_EXT))
+#define KZ_IS_RUBY_EXT_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), KZ_TYPE_RUBY_EXT))
+#define KZ_RUBY_EXT_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS ((obj), KZ_TYPE_RUBY_EXT, KzRubyExtClass))
+
+typedef struct _KzRubyExt		KzRubyExt;
+typedef struct _KzRubyExtClass		KzRubyExtClass;
+
+struct _KzRubyExt
+{
+    GObject	parent;
+
+    gpointer	initial_address;
+};
+
+struct _KzRubyExtClass
+{
+    GObjectClass parent_class;
+};
+
+static GType kz_type_ruby_ext = 0;
+static GObjectClass *kz_ruby_ext_parent_class;
+
+static void kz_ruby_ext_class_init	(KzRubyExtClass *klass);
+static void kz_ruby_ext_iface_init	(KzExtIFace	*iface);
+
+static void setup (KzExt *ext, KzWindow *window);
+
+static void     dispose      (GObject      *object);
+static void     set_property (GObject      *object,
+                              guint         prop_id,
+                              const GValue *value,
+                              GParamSpec   *pspec);
+static void     get_property (GObject      *object,
+                              guint         prop_id,
+                              GValue       *value,
+                              GParamSpec   *pspec);
+
+static void
+kz_ruby_ext_register_type (GTypeModule *module)
+{
+    static const GTypeInfo kz_ruby_ext_info =
+	{
+            sizeof (KzRubyExtClass),
+            NULL,		/* base_init */
+            NULL,		/* base_finalize */
+            (GClassInitFunc) kz_ruby_ext_class_init,
+            NULL,		/* class_finalize */
+            NULL,		/* class_data */
+            sizeof (KzRubyExt),
+            0,		/* n_preallocs */
+            NULL,
+	};
+
+    const GInterfaceInfo kz_ext_info =
+	{
+            (GInterfaceInitFunc) kz_ruby_ext_iface_init,
+            NULL,
+            NULL
+	};
+
+    kz_type_ruby_ext = g_type_module_register_type(module,
+                                                   G_TYPE_OBJECT,
+                                                   "KzRubyExt",
+                                                   &kz_ruby_ext_info,
+                                                   (GTypeFlags)0);
+
+    g_type_module_add_interface(module,
+                                KZ_TYPE_RUBY_EXT,
+                                KZ_TYPE_EXT,
+                                &kz_ext_info);
+}
+
+G_MODULE_EXPORT void
+KZ_MODULE_IMPL_INIT (GTypeModule *module)
+{
+    kz_ruby_ext_register_type(module);
+}
+
+G_MODULE_EXPORT void
+KZ_MODULE_IMPL_EXIT (void)
+{
+}
+
+G_MODULE_EXPORT GObject *
+KZ_MODULE_IMPL_INSTANTIATE (const gchar *first_property,
+			    va_list      var_args)
+{
+    KzRubyExt *ext;
+
+    ext = KZ_RUBY_EXT(g_object_new_valist(KZ_TYPE_RUBY_EXT,
+                                          first_property, var_args));
+    init(ext->initial_address);
+    return G_OBJECT(ext);
+}
+
+static void
+kz_ruby_ext_class_init (KzRubyExtClass *klass)
+{
+    GObjectClass *gobject_class;
+
+    kz_ruby_ext_parent_class = (GObjectClass *)g_type_class_peek_parent(klass);
+
+    gobject_class   = (GObjectClass *) klass;
+
+    gobject_class->dispose      = dispose;
+    gobject_class->set_property = set_property;
+    gobject_class->get_property = get_property;
+
+    g_object_class_install_property
+        (gobject_class,
+         PROP_INITIAL_ADDRESS,
+         g_param_spec_pointer(
+             "initial-address",
+             _("The initial address"),
+             _("The initial address of the program"),
+             (GParamFlags) G_PARAM_READWRITE));
+}
+
+
+static void
+dispose (GObject *object)
+{
+    KzRubyExt *ext = KZ_RUBY_EXT(object);
+
+    if (ext->initial_address) {
+        ext->initial_address = 0;
+        cleanup();
+    }
+
+    if (G_OBJECT_CLASS (kz_ruby_ext_parent_class)->dispose)
+        G_OBJECT_CLASS (kz_ruby_ext_parent_class)->dispose(object);
+}
+
+static void
+set_property (GObject         *object,
+              guint            prop_id,
+              const GValue    *value,
+              GParamSpec      *pspec)
+{
+    KzRubyExt *ext = KZ_RUBY_EXT(object);
+
+    switch (prop_id)
+    {
+      case PROP_INITIAL_ADDRESS:
+        ext->initial_address = g_value_get_pointer(value);
+        break;
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+        break;
+    }
+}
+
+
+static void
+get_property (GObject         *object,
+              guint            prop_id,
+              GValue          *value,
+              GParamSpec      *pspec)
+{
+    KzRubyExt *ext = KZ_RUBY_EXT (object);
+
+    switch (prop_id)
+    {
+      case PROP_INITIAL_ADDRESS:
+        g_value_set_pointer(value, ext->initial_address);
+        break;
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+        break;
+    }
+}
+
+
+static void
+kz_ruby_ext_iface_init (KzExtIFace *iface)
+{
+    iface->setup = setup;
+}

Modified: kazehakase/trunk/src/Makefile.am
===================================================================
--- kazehakase/trunk/src/Makefile.am	2007-03-22 07:18:35 UTC (rev 2960)
+++ kazehakase/trunk/src/Makefile.am	2007-03-22 09:17:50 UTC (rev 2961)
@@ -12,7 +12,7 @@
 	-DLOCALEDIR=\""$(localedir)"\" \
 	-DSYSCONFDIR=\""$(sysconfdir)"\" \
 	-DDATADIR=\""$(datadir)"\" \
-	-DEXTDIR=\""$(extdir)"\" \
+	-DKZ_EXTDIR=\""$(extdir)"\" \
 	-DKZ_SYSCONFDIR=\""$(sysconfdir)/$(PACKAGE)"\" \
 	-DKZ_DATADIR=\""$(datadir)/$(PACKAGE)"\" \
 	-DKZ_SEARCH_MODULEDIR=\""$(searchdir)"\" \
@@ -81,8 +81,7 @@
 	kz-search.h \
 	kz-statusbar.h \
 	kz-migemo.h \
-	kz-ext.h \
-	kz-ext-impl.h
+	kz-ext.h
 
 enum_source_prefix = kz-enum-types
 

Modified: kazehakase/trunk/src/kz-embed.c
===================================================================
--- kazehakase/trunk/src/kz-embed.c	2007-03-22 07:18:35 UTC (rev 2960)
+++ kazehakase/trunk/src/kz-embed.c	2007-03-22 09:17:50 UTC (rev 2961)
@@ -65,7 +65,8 @@
 	va_list var_args;
 
 	va_start(var_args, first_property);
-	embed = kz_module_instantiate(embeds, name, first_property, var_args);
+	embed = kz_module_find_and_instantiate(embeds, name,
+					       first_property, var_args);
 	va_end(var_args);
 
 	return GTK_WIDGET(embed);

Deleted: kazehakase/trunk/src/kz-ext-impl.h
===================================================================
--- kazehakase/trunk/src/kz-ext-impl.h	2007-03-22 07:18:35 UTC (rev 2960)
+++ kazehakase/trunk/src/kz-ext-impl.h	2007-03-22 09:17:50 UTC (rev 2961)
@@ -1,46 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- *  Copyright (C) 2006 Kouhei Sutou <kou****@cozmi*****>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2, or (at your option)
- *  any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __KZ_EXT_IMPL_H__
-#define __KZ_EXT_IMPL_H__
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-#include "kz-app.h"
-#include "kz-window.h"
-
-typedef void (*KzExtInitFunc)  (void *init_address);
-typedef void (*KzExtSetupFunc) (KzWindow *window);
-typedef void (*KzExtExitFunc)  (gboolean success);
-
-#define KZ_EXT_IMPL_INIT        kz_ext_impl_init
-#define KZ_EXT_IMPL_SETUP       kz_ext_impl_setup
-#define KZ_EXT_IMPL_EXIT        kz_ext_impl_exit
-
-
-void	KZ_EXT_IMPL_INIT		(void *init_address);
-void	KZ_EXT_IMPL_SETUP		(KzWindow *kz);
-void	KZ_EXT_IMPL_EXIT		(gboolean success);
-
-G_END_DECLS
-
-#endif /* __KZ_EXT_IMPL_H__ */

Modified: kazehakase/trunk/src/kz-ext.c
===================================================================
--- kazehakase/trunk/src/kz-ext.c	2007-03-22 07:18:35 UTC (rev 2960)
+++ kazehakase/trunk/src/kz-ext.c	2007-03-22 09:17:50 UTC (rev 2961)
@@ -1,7 +1,7 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 
 /*
- *  Copyright (C) 2006 Kouhei Sutou
+ *  Copyright (C) 2006 - 2007 Kouhei Sutou
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -19,201 +19,104 @@
  */
 
 #include "kz-ext.h"
-#include "kz-ext-impl.h"
+#include "kz-module.h"
 
-#include "glib-utils.h"
-#include "kz-marshalers.h"
+static GList *exts = NULL;
+static GList *ext_mods = NULL;
 
-#define EXT_NAME "kzext"
+static void kz_ext_base_init (gpointer g_class);
 
-static GList *extensions = NULL;
-static gboolean initted = FALSE;
-
-typedef struct _KzExtInfo		KzExtInfo;
-
-struct _KzExtInfo
+GType
+kz_ext_get_type (void)
 {
-	gchar *name;
-	gchar *path;
-	GModule *module;
-};
-
-static void
-kz_ext_show_error (GModule *module)
-{
-	gchar *message;
-
-	message = g_locale_to_utf8(g_module_error(), -1, NULL, NULL, NULL);
-
-	if (module) {
-		gchar *name;
-		name = g_strdup(g_module_name(module));
-		g_warning("%s: %s", name, message);
-		g_free(name);
-	}
-	else
+	static GType type = 0;
+	if (!type)
 	{
-		g_warning("%s", message);
+		static const GTypeInfo info = {
+			sizeof (KzExtIFace),
+			kz_ext_base_init, /* base_init :*/
+			NULL,               /* base_finalize */
+			NULL,               /* class_init */
+			NULL,               /* class_finalize */
+			NULL,               /* class_data */
+			0,
+			0,                  /* n_preallocs */
+			NULL,               /* instance_init */
+		};
+		type = g_type_register_static(G_TYPE_INTERFACE, "KzExt",
+					      &info, 0);
+		g_type_interface_add_prerequisite(type,
+						  G_TYPE_OBJECT);
 	}
-
-	g_free(message);
+	return type;
 }
 
-static gboolean
-kz_ext_load_func (GModule *module, const gchar *func_name, gpointer *symbol)
-{
-	if (g_module_symbol(module, func_name, symbol))
-	{
-		return TRUE;
-	}
-	else
-	{
-		kz_ext_show_error(module);
-		return FALSE;
-	}
-}
-
 static void
-kz_ext_close_module (GModule *module, gboolean success)
+kz_ext_base_init (gpointer g_class)
 {
-	KzExtExitFunc exit_func;
-	KzExtExitFunc *exit_func_p;
-	gpointer *p;
+	static gboolean initialized = FALSE;
 
-	exit_func_p = &exit_func;
-	p = (gpointer *)exit_func_p;
-	if (kz_ext_load_func(module, G_STRINGIFY(KZ_EXT_IMPL_EXIT), p))
-		exit_func(success);
-	else
-		kz_ext_show_error(module);
+	if (initialized) return;
 
-	if (!g_module_close(module))
-		kz_ext_show_error(module);
+	initialized = TRUE;
 }
 
-static void
-kz_ext_info_free (KzExtInfo *info)
+static KzExt *
+_kz_ext_new (KzModule *module, const gchar *first_property, ...)
 {
-	if (info->name)
-	{
-		g_free(info->name);
-		info->name = NULL;
-	}
+	GObject *ext;
+	va_list var_args;
 
-	if (info->path)
-	{
-		g_free(info->path);
-		info->path = NULL;
-	}
+	va_start(var_args, first_property);
+	ext = kz_module_instantiate(module, first_property, var_args);
+	va_end(var_args);
 
-	if (info->module)
-	{
-		kz_ext_close_module(info->module, TRUE);
-		info->module = NULL;
-	}
+	return KZ_EXT(ext);
 }
 
-static KzExtInfo *
-kz_ext_info_load(const char *name, void *init_address)
-{
-	gchar *mod_dir;
-	gchar *mod_path;
-	GModule *module;
-	KzExtInfo *info = NULL;
-
-	mod_dir = g_build_filename(EXTDIR, name, NULL);
-	mod_path = g_module_build_path(mod_dir, EXT_NAME);
-	if (!g_file_test(mod_path, G_FILE_TEST_EXISTS))
-		return NULL;
-	module = g_module_open(mod_path, G_MODULE_BIND_LAZY);
-
-	if (module)
-	{
-		KzExtInitFunc init_func;
-		KzExtInitFunc *init_func_p;
-		gpointer *p;
-
-		init_func_p = &init_func;
-		p = (gpointer *)init_func_p;
-		if (kz_ext_load_func(module, G_STRINGIFY(KZ_EXT_IMPL_INIT), p))
-		{
-			init_func(init_address);
-			info = g_new0(KzExtInfo, 1);
-			info->name = g_strdup(name);
-			info->path = g_strdup(mod_path);
-			info->module = module;
-		}
-		else
-		{
-			kz_ext_close_module(module, FALSE);
-		}
-	}
-	else
-	{
-		kz_ext_show_error(NULL);
-	}
-
-	g_free(mod_dir);
-	g_free(mod_path);
-
-	return info;
-}
-
 void
-kz_ext_init(void *init_address)
+kz_ext_init (gpointer initial_address)
 {
-	GDir *dir;
+    GList *node;
+    const gchar *base_dir;
+    base_dir = g_getenv("KZ_EXT_DIR");
+    if (!base_dir)
+        base_dir = KZ_EXTDIR;
 
-	if (initted) return;
+    ext_mods = kz_module_load_modules(base_dir);
+    for (node = ext_mods; node; node = g_list_next(node))
+    {
+        KzExt *ext;
+        KzModule *module = node->data;
 
-	extensions = NULL;
-
-	dir = g_dir_open(EXTDIR, 0, NULL);
-	if (dir) {
-		const gchar *entry;
-		KzExtInfo *info;
-
-		while ((entry = g_dir_read_name(dir)))
-		{
-			info = kz_ext_info_load(entry, init_address);
-			if (info)
-				extensions = g_list_append(extensions, info);
-		}
-
-		g_dir_close(dir);
-	}
-
-	initted = TRUE;
+        ext = _kz_ext_new(module, "initial-address", initial_address, NULL);
+        exts = g_list_prepend(exts, ext);
+    }
 }
 
 static void
-kz_ext_info_call_setup_func(KzExtInfo *info, KzWindow *kz)
+_kz_ext_setup (KzExt *ext, KzWindow *window)
 {
-	KzExtSetupFunc setup_func;
-	KzExtSetupFunc *setup_func_p;
-	gpointer *p;
+	g_return_if_fail(KZ_IS_EXT(ext));
+	g_return_if_fail(KZ_EXT_GET_IFACE(ext)->setup);
 
-	setup_func_p = &setup_func;
-	p = (gpointer *)setup_func_p;
-	if (kz_ext_load_func(info->module, G_STRINGIFY(KZ_EXT_IMPL_SETUP), p))
-		setup_func(kz);
-	else
-		kz_ext_show_error(info->module);
+	KZ_EXT_GET_IFACE(ext)->setup(ext, window);
 }
 
 void
-kz_ext_setup(KzWindow *kz)
+kz_ext_setup (KzWindow *window)
 {
-	if (!initted) return;
-
-	g_list_foreach(extensions, (GFunc) kz_ext_info_call_setup_func, kz);
+	g_list_foreach(exts, (GFunc)_kz_ext_setup, window);
 }
 
 void
-kz_ext_exit(void)
+kz_ext_exit (void)
 {
-	if (!initted) return;
+	g_list_foreach(exts, (GFunc)g_object_unref, NULL);
+	g_list_free(exts);
+	exts = NULL;
 
-	g_list_foreach(extensions, (GFunc) kz_ext_info_free, NULL);
-	g_list_free(extensions);
+	g_list_foreach(ext_mods, (GFunc)kz_module_unload, NULL);
+	g_list_free(ext_mods);
+	ext_mods = NULL;
 }

Modified: kazehakase/trunk/src/kz-ext.h
===================================================================
--- kazehakase/trunk/src/kz-ext.h	2007-03-22 07:18:35 UTC (rev 2960)
+++ kazehakase/trunk/src/kz-ext.h	2007-03-22 09:17:50 UTC (rev 2961)
@@ -1,7 +1,7 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 
 /*
- *  Copyright (C) 2006 Kouhei Sutou
+ *  Copyright (C) 2006-2007 Kouhei Sutou
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -28,10 +28,30 @@
 
 G_BEGIN_DECLS
 
-void	 kz_ext_init		(void *init_address);
-void	 kz_ext_setup		(KzWindow *kz);
-void	 kz_ext_exit		(void);
+#define KZ_TYPE_EXT		(kz_ext_get_type())
+#define KZ_EXT(o)		(G_TYPE_CHECK_INSTANCE_CAST((o), KZ_TYPE_EXT, KzExt))
+#define KZ_IS_EXT(o)		(G_TYPE_CHECK_INSTANCE_TYPE((o), KZ_TYPE_EXT))
+#define KZ_EXT_GET_IFACE(o)	(G_TYPE_INSTANCE_GET_INTERFACE((o), KZ_TYPE_EXT, KzExtIFace))
 
+typedef struct _KzExt      KzExt;
+typedef struct _KzExtIFace KzExtIFace;
+
+struct _KzExtIFace {
+	GTypeInterface g_iface;
+
+	/* vtable */
+	void	(*init)		(KzExt		*ext,
+				 gpointer	 initial_address);
+	void	(*setup)	(KzExt		*ext,
+				 KzWindow	*window);
+};
+
+GType		kz_ext_get_type		(void) G_GNUC_CONST;
+
+void		kz_ext_init		(gpointer	 initial_address);
+void		kz_ext_setup		(KzWindow 	*window);
+void		kz_ext_exit		(void);
+
 G_END_DECLS
 
 #endif /* __KZ_EXT_H__ */

Modified: kazehakase/trunk/src/kz-module.c
===================================================================
--- kazehakase/trunk/src/kz-module.c	2007-03-22 07:18:35 UTC (rev 2960)
+++ kazehakase/trunk/src/kz-module.c	2007-03-22 09:17:50 UTC (rev 2961)
@@ -189,23 +189,31 @@
 }
 
 GObject *
-kz_module_instantiate (GList *modules, const gchar *name,
-		       const gchar *first_property, va_list var_args)
+kz_module_find_and_instantiate (GList *modules, const gchar *name,
+				const gchar *first_property, va_list var_args)
 {
 	GObject *object = NULL;
 	KzModule *module;
 
 	module = _kz_module_find(modules, name);
 	if (module)
+		object = kz_module_instantiate(module, first_property, var_args);
+
+	return object;
+}
+
+GObject *
+kz_module_instantiate (KzModule *module,
+		       const gchar *first_property, va_list var_args)
+{
+	GObject *object = NULL;
+	KzModulePrivate *priv;
+
+	priv = KZ_MODULE_GET_PRIVATE(module);
+	if (g_type_module_use(G_TYPE_MODULE(module)))
 	{
-		KzModulePrivate *priv;
-
-		priv = KZ_MODULE_GET_PRIVATE(module);
-		if (g_type_module_use(G_TYPE_MODULE(module)))
-		{
-			object = priv->instantiate(first_property, var_args);
-			g_type_module_unuse(G_TYPE_MODULE(module));
-		}
+		object = priv->instantiate(first_property, var_args);
+		g_type_module_unuse(G_TYPE_MODULE(module));
 	}
 
 	return object;

Modified: kazehakase/trunk/src/kz-module.h
===================================================================
--- kazehakase/trunk/src/kz-module.h	2007-03-22 07:18:35 UTC (rev 2960)
+++ kazehakase/trunk/src/kz-module.h	2007-03-22 09:17:50 UTC (rev 2961)
@@ -53,14 +53,18 @@
 					 const gchar	 *name);
 GList    *kz_module_load_modules	(const gchar *base_dir);
 
-GObject  *kz_module_instantiate		(GList       *modules,
+GObject  *kz_module_find_and_instantiate(GList       *modules,
 					 const gchar *name,
 					 const gchar *first_property,
 					 va_list      var_args);
 
-void      kz_module_exit		(KzModule *module);
-void      kz_module_unload		(KzModule *module);
 
+GObject  *kz_module_instantiate		(KzModule	*module,
+					 const gchar	*first_property,
+					 va_list	 var_args);
+void      kz_module_exit		(KzModule	*module);
+void      kz_module_unload		(KzModule	*module);
+
 G_END_DECLS
 
 #endif /* __KZ_MODULE_H__ */

Modified: kazehakase/trunk/src/main.c
===================================================================
--- kazehakase/trunk/src/main.c	2007-03-22 07:18:35 UTC (rev 2960)
+++ kazehakase/trunk/src/main.c	2007-03-22 09:17:50 UTC (rev 2961)
@@ -417,7 +417,7 @@
 int
 main (int argc, char *argv[])
 {
-	int init_address;
+	int initial_address;
 	GtkWidget *window = NULL;
 	GtkWidget *dupl_check_server = NULL;
 	gchar **argv_copy;
@@ -473,7 +473,7 @@
 	}
 
 	kz_app = kz_app_new(argc, argv);
-	kz_ext_init(&init_address);
+	kz_ext_init(&initial_address);
 
 	/* create window */	
 	KZ_CONF_GET("Session", "restore", restore, BOOL);



More information about the Kazehakase-cvs mailing list
Back to archive index