Here is a very rough patch that attempts to make indexing more
noticeable and easy to access. What it does is look to see if a module
is indexed, and if not, it adds a "Index for Fast Search" button
directly below "Find". If the module already has an index, this button
does not appear. The idea is that many users never stumble across
indexing, and putting it here makes it very obvious for them. It
doesn't "clutter the ui" because it's gone once they index. It doesn't
attempt to nag them either.
There are several things left to do on it, but I wanted to get some
general feedback before progressing further. At this point, it's
probably best to not try to put it in the upcoming release.
Matthew
Index: src/gui/search_sidebar.h
===================================================================
--- src/gui/search_sidebar.h (revision 3008)
+++ src/gui/search_sidebar.h (working copy)
@@ -44,11 +44,13 @@
GtkWidget *frame_module;
GtkWidget *radiobutton_search_text;
GtkWidget *radiobutton_search_comm;
+ GtkWidget *button_index;
};
extern SIDESEARCH ss;
void gui_search_update_sidebar(char percent, void *userData);
void gui_create_search_sidebar(void);
+void gui_show_hide_index_button();
#ifdef __cplusplus
}
Index: src/main/search_sidebar.cc
===================================================================
--- src/main/search_sidebar.cc (revision 3008)
+++ src/main/search_sidebar.cc (working copy)
@@ -365,3 +365,36 @@
gtk_main_iteration();
printed = 0;
}
+
+gboolean main_display_index_button()
+{
+ if (GTK_TOGGLE_BUTTON(ss.radiobutton_search_text)->active) {
+ strcpy(settings.sb_search_mod,
+ settings.MainWindowModule);
+ }
+ else if (GTK_TOGGLE_BUTTON(ss.radiobutton_search_comm)->active) {
+ strcpy(settings.sb_search_mod,settings.CommWindowModule);
+ }
+
+ if (settings.sb_search_mod != "")
+ if
(backendSearch->check_for_optimal_search(settings.sb_search_mod) ==
-4)
+ return false;
+ else
+ return true;
+ else
+ return true;
+}
+
+gboolean main_do_index()
+{
+ if (GTK_TOGGLE_BUTTON(ss.radiobutton_search_text)->active) {
+ strcpy(settings.sb_search_mod,
+ settings.MainWindowModule);
+ }
+ else if (GTK_TOGGLE_BUTTON(ss.radiobutton_search_comm)->active) {
+ strcpy(settings.sb_search_mod,settings.CommWindowModule);
+ }
+
+ if (settings.sb_search_mod != "")
+ return backend->do_module_index(settings.sb_search_mod);
+}
Index: src/main/display.cc
===================================================================
--- src/main/display.cc (revision 3008)
+++ src/main/display.cc (working copy)
@@ -1367,7 +1367,7 @@
g_spawn_async ( NULL,
festival_args,
NULL,
- G_SPAWN_STDOUT_TO_DEV_NULL,
+ G_SPAWN_SEARCH_PATH,
NULL,
NULL,
NULL,
Index: src/main/search_sidebar.h
===================================================================
--- src/main/search_sidebar.h (revision 3008)
+++ src/main/search_sidebar.h (working copy)
@@ -32,6 +32,8 @@
void main_init_sidebar_search_backend(void);
void main_delete_sidebar_search_backend(void);
void main_search_sidebar_fill_bounds_combos(void);
+gboolean main_display_index_button();
+gboolean main_do_index();
#ifdef __cplusplus
}
Index: src/gnome2/sidebar.c
===================================================================
--- src/gnome2/sidebar.c (revision 3008)
+++ src/gnome2/sidebar.c (working copy)
@@ -499,7 +499,7 @@
*
* Synopsis
* #include "gui/sidebar.h"
- *
+ * #include "gui/search_sidebar.h"
* void on_search_activate(GtkMenuItem * menuitem, gpointer user_data)
*
* Description
@@ -513,6 +513,7 @@
gpointer user_data)
{
if (button->active) {
+ gui_show_hide_index_button();
gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets.
notebook_sidebar), 2);
}
Index: src/gnome2/menu_popup.c
===================================================================
--- src/gnome2/menu_popup.c (revision 3008)
+++ src/gnome2/menu_popup.c (working copy)
@@ -45,6 +45,7 @@
#include "gui/find_dialog.h"
#include "gui/font_dialog.h"
#include "gui/about_modules.h"
+#include "gui/search_sidebar.h"
#include "main/module_dialogs.h"
#include "main/sword.h"
@@ -1518,6 +1519,7 @@
g_free (module_name);
g_free (key);
}
+ gui_show_hide_index_button();
}
Index: src/gnome2/search_sidebar.c
===================================================================
--- src/gnome2/search_sidebar.c (revision 3008)
+++ src/gnome2/search_sidebar.c (working copy)
@@ -42,6 +42,19 @@
GtkWidget *remember_search; /* needed to change button in search stop */
+void gui_show_hide_index_button()
+{
+ if (main_display_index_button() == TRUE)
+ gtk_widget_show (ss.button_index);
+ else
+ gtk_widget_hide (ss.button_index);
+}
+
+static void on_button_index_clicked()
+{
+ main_do_index();
+}
+
/******************************************************************************
* Name
* on_search_botton_clicked
@@ -144,6 +157,7 @@
GtkWidget *viewport_search;
GtkTooltips *tooltips;
gchar *header;
+ GtkWidget *button_index;
//GtkListStore *store;
tooltips = gtk_tooltips_new();
@@ -190,6 +204,12 @@
NULL);
gtk_button_set_relief (GTK_BUTTON (remember_search), GTK_RELIEF_NONE);
+ button_index = gtk_button_new_with_label(_("Index for Fast Search"));
+ gtk_widget_show (button_index);
+ gtk_box_pack_start(GTK_BOX(vbox5), button_index, TRUE, FALSE, 0);
+ gtk_button_set_relief (GTK_BUTTON (remember_search), GTK_RELIEF_NONE);
+ ss.button_index = button_index;
+
ss.progressbar_search = gtk_progress_bar_new();
gtk_widget_show(ss.progressbar_search);
gtk_box_pack_start(GTK_BOX(vbox5), ss.progressbar_search,
FALSE, TRUE, 0);
@@ -416,6 +436,9 @@
g_signal_connect(GTK_OBJECT(ss.entrySearch), "activate",
G_CALLBACK(on_search_botton_clicked), NULL);
+
+ g_signal_connect(GTK_OBJECT(ss.button_index), "clicked",
+ G_CALLBACK(on_button_index_clicked), NULL);
gtk_object_set_data(GTK_OBJECT(widgets.app), "tooltips",
|