[Kazehakase-cvs] CVS update: kazehakase/src/utils

Back to archive index

Hiroyuki Ikezoe ikezo****@users*****
Sun Dec 3 11:17:41 JST 2006


Index: kazehakase/src/utils/estsearch.c
diff -u kazehakase/src/utils/estsearch.c:1.37 kazehakase/src/utils/estsearch.c:1.38
--- kazehakase/src/utils/estsearch.c:1.37	Sat Jun 17 15:56:59 2006
+++ kazehakase/src/utils/estsearch.c	Sun Dec  3 11:17:41 2006
@@ -50,7 +50,99 @@
 	        "Powered by <a href=\"%s\">Hyper Estraier</a> version %s\n" \
 		"</div>\n"
 
+typedef struct _KzSearchEstPrivate	KzSearchEstPrivate;
+struct _KzSearchEstPrivate
+{
+};
+
+#define KZ_SEARCH_EST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), KZ_TYPE_SEARCH_EST, KzSearchEstPrivate))
+
+static GObject *constructor  (GType type,
+                              guint n_props,
+                              GObjectConstructParam *props);
+static void     dispose      (GObject *object);
+
+static gchar	  *get_search_result_html     (KzSearch *search, const gchar *text);
+static KzBookmark *get_search_result_bookmark (KzSearch *search, const gchar *text);
+static gboolean    register_document          (KzSearch *search, const gchar *filename);
+static gboolean    update_index		      (KzSearch *search);
+static gboolean    purge_index		      (KzSearch *search);
+static GPid        optimize_index             (KzSearch *search);
+static void        make_index                 (KzSearch *search);
+static gboolean    exist_index_dir            (KzSearch *search);
+
 static gchar *estsearch_get_version (void);
+static gboolean _update_index (gpointer data);
+
+static KzSearchEst *the_kz_search_est = NULL;
+
+G_DEFINE_TYPE(KzSearchEst, kz_search_est, KZ_TYPE_SEARCH)
+
+static void
+kz_search_est_class_init (KzSearchEstClass *klass)
+{
+	GObjectClass *object_class;
+	KzSearchClass *search_class;
+
+	kz_search_est_parent_class = g_type_class_peek_parent (klass);
+	object_class = (GObjectClass *) klass;
+	search_class = (KzSearchClass *) klass;
+
+	object_class->constructor = constructor;
+	object_class->dispose     = dispose;
+	
+	search_class->get_search_result_html     = get_search_result_html;
+	search_class->get_search_result_bookmark = get_search_result_bookmark;
+	search_class->register_document          = register_document;
+	search_class->update_index               = update_index;
+	search_class->purge_index                = purge_index;
+	search_class->optimize_index             = optimize_index;
+	search_class->make_index                 = make_index;
+	search_class->exist_index_dir            = exist_index_dir;
+
+	g_type_class_add_private (object_class, sizeof(KzSearchEstPrivate));
+}
+
+
+static void
+kz_search_est_init (KzSearchEst *est)
+{
+}
+
+static GObject*
+constructor (GType                  type,
+             guint                  n_props,
+             GObjectConstructParam *props)
+{
+	GObject *object;
+
+	if (!the_kz_search_est) 
+	{
+		GObjectClass *klass = G_OBJECT_CLASS(kz_search_est_parent_class);
+		object = klass->constructor(type, n_props, props);
+		/* singleton does not work */
+		/*the_kz_search_est = KZ_SEARCH_EST(object);*/
+	}
+	else
+	{
+		object = g_object_ref(G_OBJECT(the_kz_search_est));
+	}
+	return object;
+}
+
+static void
+dispose (GObject *object)
+{
+	if (G_OBJECT_CLASS (kz_search_est_parent_class)->dispose)
+		G_OBJECT_CLASS (kz_search_est_parent_class)->dispose(object);
+}
+
+
+KzSearch *
+kz_search_est_get_instance (void)
+{
+	return KZ_SEARCH(g_object_new(KZ_TYPE_SEARCH_EST, NULL));
+}
 
 static gboolean
 execute_search_command(const gchar *search_text, gint *standard_output)
@@ -135,7 +227,6 @@
 				       NULL);
 	g_strfreev(argv);
 	g_free(command);
-	g_print("%s\n", command);
 
 	return ret;
 }
@@ -233,7 +324,7 @@
 
 
 gchar *
-estsearch_get_search_result (const gchar *text)
+get_search_result_html (KzSearch *search, const gchar *text)
 {
 	gint out;
 
@@ -246,8 +337,8 @@
 	return create_search_result_html(out, text);
 }
 
-gboolean
-estsearch_update_index (gpointer data)
+static gboolean
+_update_index (gpointer data)
 {
 	const gchar *estindex_prefix = "estcmd gather -sd -cm ";
 	gchar *index_dir;
@@ -302,10 +393,22 @@
 	
 	return FALSE;
 }
+gboolean
+register_document (KzSearch *search, const gchar *filename)
+{
+	g_idle_add (_update_index, (gpointer)filename);
 
+	return TRUE;
+}
 
 gboolean
-estsearch_purge_index (void)
+update_index (KzSearch *search)
+{
+	return TRUE;
+}
+
+static gboolean
+purge_index (KzSearch *search)
 {
 	const gchar *estpurge = "estcmd purge ";
 	gchar *command;
@@ -344,8 +447,8 @@
 	return FALSE;
 }
 
-GPid
-estsearch_optimize_index (void)
+static GPid
+optimize_index (KzSearch *search)
 {
 	const gchar *estoptimize = "estcmd optimize "; 
 	gchar *command;
@@ -491,8 +594,8 @@
 	return result;
 }
 
-KzBookmark *
-estsearch_get_search_result_bookmark (const gchar *text)
+static KzBookmark *
+get_search_result_bookmark (KzSearch *search, const gchar *text)
 {
 	gint out;
 
@@ -505,8 +608,8 @@
 	return create_search_result_bookmark(out, text);
 }
 
-void
-estsearch_make_index(void)
+static void
+make_index (KzSearch *search)
 {
 	const gchar *estgather = "estcmd gather -sd "; 
 	gchar *command;
@@ -541,8 +644,8 @@
 	g_free(command);
 }
 
-gboolean
-estsearch_exist_index_dir(void)
+static gboolean
+exist_index_dir(KzSearch *search)
 {
 	gchar *index_dir;
 	gboolean exist = FALSE;
Index: kazehakase/src/utils/estsearch.h
diff -u kazehakase/src/utils/estsearch.h:1.9 kazehakase/src/utils/estsearch.h:1.10
--- kazehakase/src/utils/estsearch.h:1.9	Mon Jan 23 12:05:28 2006
+++ kazehakase/src/utils/estsearch.h	Sun Dec  3 11:17:41 2006
@@ -21,20 +21,35 @@
 #ifndef __ESTSEARCH_H__
 #define __ESTSEARCH_H__
 
-#include <glib.h>
-#include <kz-bookmark.h>
+#include <glib-object.h>
+#include "kz-search.h"
+#include "kz-bookmark.h"
 
 G_BEGIN_DECLS
 
-gchar      *estsearch_get_search_result (const gchar* text);
+#define KZ_TYPE_SEARCH_EST		(kz_search_est_get_type ())
+#define KZ_SEARCH_EST(obj)		(G_TYPE_CHECK_INSTANCE_CAST ((obj), KZ_TYPE_SEARCH_EST, KzSearchEst))
+#define KZ_SEARCH_EST_CLASS(klass)	(G_TYPE_CHECK_CLASS_CAST ((klass), KZ_TYPE_SEARCH_EST, KzSearchEstClass))
+#define KZ_IS_SEARCH_EST(obj)	   	(G_TYPE_CHECK_INSTANCE_TYPE ((obj), KZ_TYPE_SEARCH_EST))
+#define KZ_IS_SEARCH_EST_CLASS(klass) 	(G_TYPE_CHECK_CLASS_TYPE ((klass), KZ_TYPE_SEARCH_EST))
+#define KZ_SEARCH_EST_GET_CLASS(obj)  	(G_TYPE_INSTANCE_GET_CLASS ((obj), KZ_TYPE_SEARCH_EST, KzSearchEstClass))
+
+typedef struct _KzSearchEst		KzSearchEst;
+typedef struct _KzSearchEstClass	KzSearchEstClass;
+
+struct _KzSearchEst
+{
+	KzSearch parent;
+};
+
+struct _KzSearchEstClass
+{
+	KzSearchClass parent_class;
+};
 
-KzBookmark *estsearch_get_search_result_bookmark (const gchar* text);
+GType      kz_search_est_get_type      (void) G_GNUC_CONST;
 
-gboolean    estsearch_update_index      (gpointer data);
-gboolean    estsearch_purge_index       (void);
-GPid        estsearch_optimize_index    (void);
-void        estsearch_make_index              (void);
-gboolean    estsearch_exist_index_dir         (void);
+KzSearch  *kz_search_est_get_instance  (void);
 
 G_END_DECLS
 


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