Hiroyuki Ikezoe
ikezo****@users*****
Wed Dec 6 16:08:23 JST 2006
Index: kazehakase/src/prefs_ui/Makefile.am diff -u kazehakase/src/prefs_ui/Makefile.am:1.37 kazehakase/src/prefs_ui/Makefile.am:1.38 --- kazehakase/src/prefs_ui/Makefile.am:1.37 Sun Apr 30 19:22:09 2006 +++ kazehakase/src/prefs_ui/Makefile.am Wed Dec 6 16:08:23 2006 @@ -17,6 +17,7 @@ -DDATADIR=\""$(datadir)"\" \ -DKZ_SYSCONFDIR=\""$(sysconfdir)/$(PACKAGE)"\" \ -DKZ_DATADIR=\""$(datadir)/$(PACKAGE)"\" \ + -DKZ_SEARCH_MODULEDIR=\""$(searchdir)"\" \ -DGTK_DISABLE_DEPRECATED=1 \ -DGDK_DISABLE_DEPRECATED=1 \ -DG_LOG_DOMAIN=\"Kazehakase-PrefsUI\" \ Index: kazehakase/src/prefs_ui/prefs_history.c diff -u kazehakase/src/prefs_ui/prefs_history.c:1.15 kazehakase/src/prefs_ui/prefs_history.c:1.16 --- kazehakase/src/prefs_ui/prefs_history.c:1.15 Wed Dec 6 15:08:04 2006 +++ kazehakase/src/prefs_ui/prefs_history.c Wed Dec 6 16:08:23 2006 @@ -56,6 +56,7 @@ GtkWidget *max_results; GtkWidget *num_summary; GtkWidget *except_keyword; + GtkWidget *search_engine; gboolean changed; } KzPrefsHistory; @@ -106,6 +107,45 @@ g_free(prefsui); } +static void +set_search_engine (GtkComboBox *combo) +{ + GDir *dir; + gchar *search_engine_name; + gint i = 0, active = 0; + + 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); + } + + if (search_engine_name) + g_free(search_engine_name); + gtk_combo_box_set_active(combo, active); +} static GtkWidget * prefs_history_create (void) @@ -113,7 +153,7 @@ KzPrefsHistory *prefsui = g_new0(KzPrefsHistory, 1); GtkWidget *main_vbox, *vbox, *hbox, *frame; GtkWidget *label, *check, *spin, *button; - GtkWidget *entry; + GtkWidget *entry, *combo; GtkAdjustment *adj; gboolean limit, store_cache = TRUE; gint limit_days, max_results, num_summary; @@ -131,11 +171,11 @@ /* - * History Cache + * Local Cache */ KZ_CONF_GET("History", "store_cache", store_cache, BOOL); prefsui->store_cache_check = check = - gtk_check_button_new_with_label(_("Store history cache for search")); + gtk_check_button_new_with_label(_("Store history cache on local disk")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), store_cache); g_signal_connect(check, "toggled", @@ -223,6 +263,21 @@ gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); gtk_container_add(GTK_CONTAINER(vbox), hbox); gtk_widget_show(hbox); + label = gtk_label_new_with_mnemonic(_("Search engine name")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2); + gtk_widget_show(label); + + prefsui->search_engine = combo = gtk_combo_box_new_text(); + set_search_engine(GTK_COMBO_BOX(combo)); + gtk_widget_show(combo); + gtk_box_pack_start (GTK_BOX(hbox), combo, TRUE, TRUE, 0); + g_signal_connect(combo, "changed", + G_CALLBACK(cb_changed), prefsui); + + hbox = gtk_hbox_new(FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); + gtk_container_add(GTK_CONTAINER(vbox), hbox); + gtk_widget_show(hbox); max_results = 20; KZ_CONF_GET("History", "max_results", max_results, INT); @@ -331,6 +386,22 @@ num_summary = gtk_adjustment_get_value(adj); KZ_CONF_SET("History", "num_summary", num_summary, INT); + if (gtk_combo_box_get_active(GTK_COMBO_BOX(prefsui->search_engine)) == 0) + { + KZ_CONF_SET_STR("History", "search_engine", ""); + } + else + { + gchar *search_engine; + search_engine = gtk_combo_box_get_active_text + (GTK_COMBO_BOX(prefsui->search_engine)); + if (search_engine) + { + KZ_CONF_SET_STR("History", "search_engine", search_engine); + g_free(search_engine); + } + } + prefsui->changed = FALSE; break;