[Kazehakase-cvs] kazehakase-svn [3028] * src/kz-embed.[ch] (kz_embed_get_name): moved to kz_module_get_name().

Back to archive index

svnno****@sourc***** svnno****@sourc*****
Mon Mar 26 16:57:47 JST 2007


Revision: 3028
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3028
Author:   kous
Date:     2007-03-26 16:57:35 +0900 (Mon, 26 Mar 2007)

Log Message:
-----------
* src/kz-embed.[ch] (kz_embed_get_name): moved to kz_module_get_name().
* src/kz-embed.[ch] (kz_embed_engine_names): added.

* src/kz-module.[ch] (kz_module_get_name): added.
* src/kz-module-impl.h: added get_name() interface.

* src/dialog/kz-about-dialog.c: used kz_embed_engine_names().

* src/kz-search.c: used kz_module_get_name().

* module/embed/gecko/kz-gecko-embed.cpp: implemented get_name()
  for KzModule.

Modified Paths:
--------------
    kazehakase/trunk/ChangeLog
    kazehakase/trunk/module/embed/gecko/kz-gecko-embed.cpp
    kazehakase/trunk/src/dialogs/kz-about-dialog.c
    kazehakase/trunk/src/kz-embed.c
    kazehakase/trunk/src/kz-embed.h
    kazehakase/trunk/src/kz-module-impl.h
    kazehakase/trunk/src/kz-module.c
    kazehakase/trunk/src/kz-module.h
    kazehakase/trunk/src/kz-search.c

Modified: kazehakase/trunk/ChangeLog
===================================================================
--- kazehakase/trunk/ChangeLog	2007-03-26 07:49:22 UTC (rev 3027)
+++ kazehakase/trunk/ChangeLog	2007-03-26 07:57:35 UTC (rev 3028)
@@ -1,3 +1,18 @@
+2007-03-26  Kouhei Sutou  <kou****@cozmi*****>
+
+	* src/kz-embed.[ch] (kz_embed_get_name): moved to kz_module_get_name().
+	* src/kz-embed.[ch] (kz_embed_engine_names): added.
+
+	* src/kz-module.[ch] (kz_module_get_name): added.
+	* src/kz-module-impl.h: added get_name() interface.
+
+	* src/dialog/kz-about-dialog.c: used kz_embed_engine_names().
+
+	* src/kz-search.c: used kz_module_get_name().
+
+	* module/embed/gecko/kz-gecko-embed.cpp: implemented get_name()
+	for KzModule.
+
 2007-03-26  Hiroyuki Ikezoe  <poinc****@ikezo*****>
 
 	* src/net/uri.[ch], src/net/kz-http.c: GURI -> KzURI. gnet_ -> kz_.

Modified: kazehakase/trunk/module/embed/gecko/kz-gecko-embed.cpp
===================================================================
--- kazehakase/trunk/module/embed/gecko/kz-gecko-embed.cpp	2007-03-26 07:49:22 UTC (rev 3027)
+++ kazehakase/trunk/module/embed/gecko/kz-gecko-embed.cpp	2007-03-26 07:57:35 UTC (rev 3028)
@@ -357,7 +357,6 @@
 static void	     kz_gecko_embed_set_allow_images	  (KzEmbed      *kzembed,
 							   gboolean      allow);
 static void          kz_gecko_embed_show_page_certificate (KzEmbed       *kzembed);
-static const gchar  *kz_gecko_embed_get_name              (KzEmbed       *kzembed);
 
 /* KzEmbedPrefs interfaces */
 static void          kz_gecko_embed_prefs_iface_init      (KzEmbedPrefsIFace *iface);
@@ -462,6 +461,13 @@
 	return G_OBJECT(kzembed);
 }
 
+G_MODULE_EXPORT const gchar *
+KZ_MODULE_IMPL_GET_NAME (void)
+{
+	return GECKO_VERSION;
+}
+
+
 GType
 kz_gecko_embed_get_type (void)
 {
@@ -544,7 +550,6 @@
 	iface->get_allow_images       = kz_gecko_embed_get_allow_images;
 	iface->set_allow_images       = kz_gecko_embed_set_allow_images;
 	iface->show_page_certificate  = kz_gecko_embed_show_page_certificate;
-	iface->get_name               = kz_gecko_embed_get_name;
 
 
 #if 0
@@ -3464,12 +3469,6 @@
 
 }
 
-static const gchar *
-kz_gecko_embed_get_name (KzEmbed *kzembed)
-{
-	return GECKO_VERSION;
-}
-
 static void
 nav_link_elem_free(gpointer object, gpointer unused)
 {

Modified: kazehakase/trunk/src/dialogs/kz-about-dialog.c
===================================================================
--- kazehakase/trunk/src/dialogs/kz-about-dialog.c	2007-03-26 07:49:22 UTC (rev 3027)
+++ kazehakase/trunk/src/dialogs/kz-about-dialog.c	2007-03-26 07:57:35 UTC (rev 3028)
@@ -19,6 +19,8 @@
  */
 
 #include "kz-about-dialog.h"
+#include "kz-embed.h"
+#include "kz-module.h"
 
 #include <glib/gi18n.h>
 
@@ -31,7 +33,7 @@
 #endif
 
 static const gchar *copyright = 
-N_("Copyright (C) 2002-2006 Kazehakase Project");
+N_("Copyright (C) 2002-2007 Kazehakase Project");
 
 static	GtkWidget *bg_pixmap   = NULL;
 static	GtkWidget *logo_pixmap = NULL;
@@ -42,12 +44,37 @@
 static  int logo_width;
 static  int logo_height;
 
+static gchar *
+backend_names(void)
+{
+	GString *names;
+	GList *node, *backends;
+
+	names = g_string_new("");
+	backends = kz_embed_engine_names();
+	for (node = backends; node; node = g_list_next(node))
+	{
+		gchar *name = node->data;
+
+		if (names->len == 0)
+			g_string_append(names, name);
+		else if (g_list_next(node))
+			g_string_append_printf(names, ", %s", name);
+		else
+			g_string_append_printf(names, "and %s", name);
+		g_free(name);
+	}
+	g_list_free(backends);
+
+	return g_string_free(names, names->len == 0);
+}
+
 static gboolean
 cb_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
 {
 	PangoLayout *copyright_layout, *info_layout;
 	PangoRectangle link, logical;
-	gchar *version, *powered_by, *info;
+	gchar *version, *backends, *info;
 
 	/* Draw background image */
 	gdk_draw_pixbuf(widget->window,
@@ -69,8 +96,19 @@
 			0, 0);
 	/* Draw version and backends under the logo */
 	version = g_strdup_printf (_("Version %s"), VERSION);
-	powered_by = g_strdup_printf (_("Powered by %s"), KZ_BACKENDS);
-	info = g_strdup_printf ("%s\n%s", version, powered_by);
+	backends = backend_names();
+	if (backends)
+	{
+		gchar *powered_by;
+		powered_by = g_strdup_printf(_("Powered by %s"), backends);
+		info = g_strdup_printf("%s\n%s", version, powered_by);
+		g_free(backends);
+		g_free(powered_by);
+	}
+	else
+	{
+		info = g_strdup(version);
+	}
 	info_layout = gtk_widget_create_pango_layout (widget, info);
 	pango_layout_set_alignment(info_layout, PANGO_ALIGN_RIGHT);
 	pango_layout_get_pixel_extents(info_layout, &link, &logical);
@@ -79,12 +117,11 @@
 			bg_width - logical.width, logo_height,
 			info_layout);
 	g_free (version);
-	g_free (powered_by);
 	g_free (info);
 	g_object_unref(info_layout);
 
 	/* Draw copyright at bottom right */
-	copyright_layout = gtk_widget_create_pango_layout (widget, 
+	copyright_layout = gtk_widget_create_pango_layout (widget,
 							   _(copyright));
 	pango_layout_set_alignment(copyright_layout, PANGO_ALIGN_RIGHT);
 	pango_layout_set_width(copyright_layout, -1);

Modified: kazehakase/trunk/src/kz-embed.c
===================================================================
--- kazehakase/trunk/src/kz-embed.c	2007-03-26 07:49:22 UTC (rev 3027)
+++ kazehakase/trunk/src/kz-embed.c	2007-03-26 07:57:35 UTC (rev 3028)
@@ -60,6 +60,22 @@
 	g_list_foreach(embeds, (GFunc)kz_module_exit, NULL);
 }
 
+GList *
+kz_embed_engine_names(void)
+{
+	GList *node;
+	GList *result = NULL;
+
+	for (node = embeds; node; node = g_list_next(node))
+	{
+		KzModule *module = node->data;
+		result = g_list_append(result,
+				       g_strdup(kz_module_get_name(module)));
+	}
+
+	return result;
+}
+
 static GtkWidget *
 _kz_embed_new (KzModule *module, const gchar *name,
 	       const gchar *first_property, ...)
@@ -1154,15 +1170,6 @@
 	return KZ_EMBED_GET_IFACE(kzembed)->show_page_certificate(kzembed);
 }
 
-const gchar *
-kz_embed_get_name (KzEmbed *kzembed)
-{
-	g_return_val_if_fail(KZ_IS_EMBED(kzembed), NULL);
-	g_return_val_if_fail(KZ_EMBED_GET_IFACE(kzembed)->get_name, NULL);
-
-	return KZ_EMBED_GET_IFACE(kzembed)->get_name(kzembed);
-}
-
 static gchar *
 kz_embed_get_up_location(KzEmbed *kzembed)
 {

Modified: kazehakase/trunk/src/kz-embed.h
===================================================================
--- kazehakase/trunk/src/kz-embed.h	2007-03-26 07:49:22 UTC (rev 3027)
+++ kazehakase/trunk/src/kz-embed.h	2007-03-26 07:57:35 UTC (rev 3028)
@@ -299,6 +299,7 @@
 void            kz_embed_load			(const gchar   *base_dir);
 void            kz_embed_unload			(void);
 void            kz_embed_exit			(void);
+GList	       *kz_embed_engine_names		(void);
 
 GtkWidget      *kz_embed_new			(const gchar   *name);
 void		kz_embed_load_url		(KzEmbed       *kzembed,
@@ -469,7 +470,6 @@
     						 gboolean	allow);
 
 void            kz_embed_show_page_certificate  (KzEmbed       *kzembed);
-const gchar    *kz_embed_get_name               (KzEmbed       *kzembed);
 
 G_END_DECLS
 

Modified: kazehakase/trunk/src/kz-module-impl.h
===================================================================
--- kazehakase/trunk/src/kz-module-impl.h	2007-03-26 07:49:22 UTC (rev 3027)
+++ kazehakase/trunk/src/kz-module-impl.h	2007-03-26 07:57:35 UTC (rev 3028)
@@ -32,16 +32,19 @@
 typedef void     (*KzModuleExitFunc)         (void);
 typedef GObject *(*KzModuleInstantiateFunc)  (const gchar *first_property,
 					      va_list      var_args);
+typedef const gchar *(*KzModuleGetNameFunc)  (void);
 
 #define KZ_MODULE_IMPL_INIT           kz_module_impl_init
 #define KZ_MODULE_IMPL_EXIT           kz_module_impl_exit
 #define KZ_MODULE_IMPL_INSTANTIATE    kz_module_impl_instantiate
+#define KZ_MODULE_IMPL_GET_NAME       kz_module_impl_get_name
 
 
 void     KZ_MODULE_IMPL_INIT           (GTypeModule  *module);
 void     KZ_MODULE_IMPL_EXIT           (void);
 GObject *KZ_MODULE_IMPL_INSTANTIATE    (const gchar *first_property,
 					va_list      var_args);
+const gchar *KZ_MODULE_IMPL_GET_NAME   (void);
 
 G_END_DECLS
 

Modified: kazehakase/trunk/src/kz-module.c
===================================================================
--- kazehakase/trunk/src/kz-module.c	2007-03-26 07:49:22 UTC (rev 3027)
+++ kazehakase/trunk/src/kz-module.c	2007-03-26 07:57:35 UTC (rev 3028)
@@ -44,6 +44,7 @@
 	KzModuleInitFunc         init;
 	KzModuleExitFunc         exit;
 	KzModuleInstantiateFunc  instantiate;
+	KzModuleGetNameFunc      get_name;
 };
 
 G_DEFINE_TYPE (KzModule, kz_module, G_TYPE_TYPE_MODULE)
@@ -124,6 +125,10 @@
 		return FALSE;
 	}
 
+	_kz_module_load_func(priv->library,
+			     G_STRINGIFY(KZ_MODULE_IMPL_GET_NAME),
+			     (gpointer)&priv->get_name);
+
 	priv->exited = FALSE;
 
 	priv->init(module);
@@ -148,6 +153,7 @@
 	priv->init = NULL;
 	priv->exit = NULL;
 	priv->instantiate = NULL;
+	priv->get_name = NULL;
 }
 
 
@@ -205,6 +211,25 @@
 	return object;
 }
 
+const gchar *
+kz_module_get_name (KzModule *module)
+{
+	KzModulePrivate *priv;
+	const gchar *name = NULL;
+
+	priv = KZ_MODULE_GET_PRIVATE(module);
+	if (priv->get_name && g_type_module_use(G_TYPE_MODULE(module)))
+	{
+		name = priv->get_name();
+		g_type_module_unuse(G_TYPE_MODULE(module));
+	}
+
+	if (!name)
+		name = G_TYPE_MODULE(module)->name;
+
+	return name;
+}
+
 static GModule *
 _kz_module_open (const gchar *mod_path)
 {

Modified: kazehakase/trunk/src/kz-module.h
===================================================================
--- kazehakase/trunk/src/kz-module.h	2007-03-26 07:49:22 UTC (rev 3027)
+++ kazehakase/trunk/src/kz-module.h	2007-03-26 07:57:35 UTC (rev 3028)
@@ -58,6 +58,8 @@
 GObject  *kz_module_instantiate		(KzModule	*module,
 					 const gchar	*first_property,
 					 va_list	 var_args);
+const gchar *kz_module_get_name		(KzModule	*module);
+
 void      kz_module_exit		(KzModule	*module);
 void      kz_module_unload		(KzModule	*module);
 

Modified: kazehakase/trunk/src/kz-search.c
===================================================================
--- kazehakase/trunk/src/kz-search.c	2007-03-26 07:49:22 UTC (rev 3027)
+++ kazehakase/trunk/src/kz-search.c	2007-03-26 07:57:35 UTC (rev 3028)
@@ -76,7 +76,7 @@
 	{
 		KzModule *module = node->data;
 		result = g_list_append(result,
-				       g_strdup(G_TYPE_MODULE(module)->name));
+				       g_strdup(kz_module_get_name(module)));
 	}
 
 	return result;




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