[Kazehakase-cvs] kazehakase-svn [2984] * src/prefs_ui/prefs_history.c ( prefs_history_response): apply

Back to archive index

svnno****@sourc***** svnno****@sourc*****
Fri Mar 23 16:05:44 JST 2007


Revision: 2984
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=2984
Author:   kous
Date:     2007-03-23 16:05:43 +0900 (Fri, 23 Mar 2007)

Log Message:
-----------
* src/prefs_ui/prefs_history.c (prefs_history_response): apply
  search engine configuration immediately.
  (set_search_engine): used engine names from kz_history_engine_names().
* src/kz-search.c (kz_search_engine_names): loaded search engines
  if aren't loaded.
* src/kz-module.c (kz_module_load_module): set more human-readable
  module name.
* src/kz-app.[ch], src/kazehakase.h: added search engine update API.
* module/search/kz-hyper-estraier-search.c: added more checks.

Modified Paths:
--------------
    kazehakase/trunk/ChangeLog
    kazehakase/trunk/module/search/kz-hyper-estraier-search.c
    kazehakase/trunk/src/kazehakase.h
    kazehakase/trunk/src/kz-app.c
    kazehakase/trunk/src/kz-app.h
    kazehakase/trunk/src/kz-module.c
    kazehakase/trunk/src/kz-search.c
    kazehakase/trunk/src/prefs_ui/prefs_history.c

Modified: kazehakase/trunk/ChangeLog
===================================================================
--- kazehakase/trunk/ChangeLog	2007-03-23 06:23:44 UTC (rev 2983)
+++ kazehakase/trunk/ChangeLog	2007-03-23 07:05:43 UTC (rev 2984)
@@ -1,3 +1,20 @@
+2007-03-23  Kouhei Sutou  <kou****@cozmi*****>
+
+	* src/prefs_ui/prefs_history.c (prefs_history_response): apply
+	search engine configuration immediately.
+	(set_search_engine): used engine names from
+	kz_history_engine_names().
+
+	* src/kz-search.c (kz_search_engine_names): loaded search engines
+	if aren't loaded.
+
+	* src/kz-module.c (kz_module_load_module): set more human-readable
+	module name.
+
+	* src/kz-app.[ch], src/kazehakase.h: added search engine update API.
+
+	* module/search/kz-hyper-estraier-search.c: added more checks.
+
 2007-03-23  Hiroyuki Ikezoe  <poinc****@ikezo*****>
 
 	* module/embed/mozilla.[cpp|h], module/embed/kz-gecko-embed.cpp:

Modified: kazehakase/trunk/module/search/kz-hyper-estraier-search.c
===================================================================
--- kazehakase/trunk/module/search/kz-hyper-estraier-search.c	2007-03-23 06:23:44 UTC (rev 2983)
+++ kazehakase/trunk/module/search/kz-hyper-estraier-search.c	2007-03-23 07:05:43 UTC (rev 2984)
@@ -388,6 +388,8 @@
 	gchar *tmp_filename, *tmp_path;
 	KzHyperEstraierSearch *he_search;
 
+	g_return_val_if_fail (uri, FALSE);
+
 	he_search = KZ_HYPER_ESTRAIER_SEARCH(search);
 	db = est_mtdb_open(he_search->dbname, ESTDBWRITER | ESTDBCREAT, &ecode);
 	if (!db)
@@ -512,7 +514,7 @@
 		}
 		else
 		{
-			gchar *uri, *contents;
+			gchar *uri, *title, *contents;
 			gchar *encoding = NULL;
 			GTime mtime;
 			struct stat st;
@@ -521,8 +523,8 @@
 			g_stat(new_path, &st);
 			mtime = st.st_mtime;
 			uri = create_uri_from_filename(new_path +
-						       strlen("file://") +
 						       he_search->cache_path_len);
+			title = uri;
 
 			encoding = get_document_encoding(contents);
 			if (!encoding)
@@ -539,15 +541,17 @@
 							  NULL);
 				if (utf8_contents)
 				{
-					kz_search_register_document(search, uri,
-								    NULL,
+					kz_search_register_document(search,
+								    uri,
+								    title,
 								    utf8_contents,
 								    mtime);
 					g_free(utf8_contents);
 				}
 			}
 			else
-				kz_search_register_document(search, uri, NULL, contents, mtime);
+				kz_search_register_document(search, uri, title,
+							    contents, mtime);
  
  			if (encoding)
 				g_free(encoding);

Modified: kazehakase/trunk/src/kazehakase.h
===================================================================
--- kazehakase/trunk/src/kazehakase.h	2007-03-23 06:23:44 UTC (rev 2983)
+++ kazehakase/trunk/src/kazehakase.h	2007-03-23 07:05:43 UTC (rev 2984)
@@ -69,6 +69,8 @@
 #define KZ_GET_WINDOW_LIST     kz_app_get_window_list(kz_app)
 #define KZ_GET_MIGEMO          kz_app_get_migemo(kz_app)
 
+#define KZ_SET_SEARCH(engine_name)	kz_app_set_search(kz_app, engine_name)
+
 G_END_DECLS
 
 #endif /* __KAZEAKASE_H__ */

Modified: kazehakase/trunk/src/kz-app.c
===================================================================
--- kazehakase/trunk/src/kz-app.c	2007-03-23 06:23:44 UTC (rev 2983)
+++ kazehakase/trunk/src/kz-app.c	2007-03-23 07:05:43 UTC (rev 2984)
@@ -257,15 +257,7 @@
 	search_engine = kz_profile_get_string(priv->profile, "History" , "search_engine");
 	if (search_engine)
 	{
-		if (!strcmp(search_engine, "hyper-estraier") ||
-		    !strcmp(search_engine, "rast"))
-			priv->search = kz_search_new(search_engine);
-
-		if (priv->search)
-		{
-			if (!kz_search_exist_index_dir(priv->search))
-				kz_search_make_index(priv->search);
-		}
+		kz_app_set_search(app, search_engine);
 		g_free(search_engine);
 	}
 
@@ -632,6 +624,23 @@
 	return KZ_APP_GET_PRIVATE(app)->search;
 }
 
+void
+kz_app_set_search (KzApp *app, const gchar *engine_name)
+{
+	KzAppPrivate *priv;
+
+	priv = KZ_APP_GET_PRIVATE(app);
+	if (priv->search)
+		g_object_unref(priv->search);
+
+	priv->search = kz_search_new(engine_name);
+	if (priv->search)
+	{
+		if (!kz_search_exist_index_dir(priv->search))
+			kz_search_make_index(priv->search);
+	}
+}
+
 KzRootBookmark *
 kz_app_get_root_bookmark (KzApp *app)
 {

Modified: kazehakase/trunk/src/kz-app.h
===================================================================
--- kazehakase/trunk/src/kz-app.h	2007-03-23 06:23:44 UTC (rev 2983)
+++ kazehakase/trunk/src/kz-app.h	2007-03-23 07:05:43 UTC (rev 2984)
@@ -72,6 +72,7 @@
 KzUILevel       kz_app_get_ui_level        (KzApp *app);
 KzFavicon      *kz_app_get_favicon         (KzApp *app);
 KzSearch       *kz_app_get_search          (KzApp *app);
+void		kz_app_set_search          (KzApp *app, const gchar *search);
 KzRootBookmark *kz_app_get_root_bookmark   (KzApp *app);
 KzProfile      *kz_app_get_profile         (KzApp *app);
 KzProfile      *kz_app_get_proxy           (KzApp *app);

Modified: kazehakase/trunk/src/kz-module.c
===================================================================
--- kazehakase/trunk/src/kz-module.c	2007-03-23 06:23:44 UTC (rev 2983)
+++ kazehakase/trunk/src/kz-module.c	2007-03-23 07:05:43 UTC (rev 2984)
@@ -262,10 +262,21 @@
 
 	if (g_file_test(mod_path, G_FILE_TEST_EXISTS)) {
 		KzModulePrivate *priv;
+		gchar *mod_name;
+
 		module = g_object_new(KZ_TYPE_MODULE, NULL);
 		priv = KZ_MODULE_GET_PRIVATE(module);
 		priv->mod_path = g_strdup(mod_path);
-		g_type_module_set_name(G_TYPE_MODULE(module), priv->mod_path);
+
+		mod_name = g_strdup(name);
+		if (g_str_has_suffix(mod_name, "."G_MODULE_SUFFIX)) {
+			guint last_index;
+			last_index =
+				strlen(mod_name) - strlen("."G_MODULE_SUFFIX);
+			mod_name[last_index] = '\0';
+		}
+		g_type_module_set_name(G_TYPE_MODULE(module), mod_name);
+		g_free(mod_name);
 	}
 	g_free(mod_path);
 

Modified: kazehakase/trunk/src/kz-search.c
===================================================================
--- kazehakase/trunk/src/kz-search.c	2007-03-23 06:23:44 UTC (rev 2983)
+++ kazehakase/trunk/src/kz-search.c	2007-03-23 07:05:43 UTC (rev 2984)
@@ -69,6 +69,9 @@
 	GList *node;
 	GList *result = NULL;
 
+	if (!searches)
+		kz_search_load(NULL);
+
 	for (node = searches; node; node = g_list_next(node))
 	{
 		KzModule *module = node->data;

Modified: kazehakase/trunk/src/prefs_ui/prefs_history.c
===================================================================
--- kazehakase/trunk/src/prefs_ui/prefs_history.c	2007-03-23 06:23:44 UTC (rev 2983)
+++ kazehakase/trunk/src/prefs_ui/prefs_history.c	2007-03-23 07:05:43 UTC (rev 2984)
@@ -110,37 +110,25 @@
 static void
 set_search_engine (GtkComboBox *combo)
 {
-	GDir *dir;
 	gchar *search_engine_name;
 	gint i = 0, active = 0;
+	GList *node;
+	GList *search_engine_names = NULL;
 
 	search_engine_name = KZ_CONF_GET_STR("History", "search_engine");
 	gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("None"));
-	dir = g_dir_open(KZ_SEARCH_MODULEDIR, 0, NULL);
-	if (dir)
-	{
-		const gchar *name;
-		while ((name = g_dir_read_name(dir)))
-		{
-			gchar *path;
-			path = g_module_build_path(KZ_SEARCH_MODULEDIR, name);
 
-			if (g_str_has_suffix(name, G_MODULE_SUFFIX) &&
-			    g_file_test(path, G_FILE_TEST_EXISTS))
-			{
-				gchar *engine_name;
-				size_t len = strlen(name);
-				i++;
-				engine_name = g_strndup(name+3, len - 4 - strlen(G_MODULE_SUFFIX));
-				gtk_combo_box_append_text(combo, engine_name);
-				if (!strcmp(engine_name, search_engine_name))
-					active = i;
-				g_free(engine_name);
-			}
-			g_free(path);
-		}
-		g_dir_close(dir);
+	search_engine_names = kz_search_engine_names();
+	for (node = search_engine_names; node; node = g_list_next(node))
+	{
+		gchar *engine_name = node->data;
+		gtk_combo_box_append_text(combo, engine_name);
+		i++;
+		if (strcmp(engine_name, search_engine_name) == 0)
+			active = i;
+		g_free(engine_name);
 	}
+	g_list_free(search_engine_names);
 
 	if (search_engine_name)
 		g_free(search_engine_name);
@@ -397,6 +385,7 @@
 				(GTK_COMBO_BOX(prefsui->search_engine));
 			if (search_engine)
 			{
+				KZ_SET_SEARCH(search_engine);
 				KZ_CONF_SET_STR("History", "search_engine", search_engine);
 				g_free(search_engine);
 			}




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