add "sticky" pref for the quicksearch
authorColin Leroy <colin@colino.net>
Wed, 7 Jul 2004 17:03:31 +0000 (17:03 +0000)
committerColin Leroy <colin@colino.net>
Wed, 7 Jul 2004 17:03:31 +0000 (17:03 +0000)
ChangeLog.claws
PATCHSETS
configure.ac
src/gtk/quicksearch.c
src/gtk/quicksearch.h
src/prefs_common.c
src/prefs_common.h
src/summaryview.c

index 5a5f2da..92a9626 100644 (file)
@@ -1,3 +1,16 @@
+2004-07-07 [colin]     0.9.12cvs15
+
+       * src/prefs_common.c [1.225]
+       * src/prefs_common.h [1.112]
+               Add a hidden summary_quicksearch_sticky preference,
+               to allow the quicksearch bar to reset across folders
+       * src/summaryview.c [1.437]
+               Use this preference
+       * src/gtk/quicksearch.c [1.5]
+       * src/gtk/quicksearch.h [1.3]
+               Add this preference, fix focus when hitting Enter,
+               add handling of Esc key to reset
+
 2004-07-06 [colin]     0.9.12cvs14
 
        * src/gtk/quicksearch.c [1.4]
index be18fb0..7d7a45e 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
@@ -1,2 +1,3 @@
 ( cvs diff -u -r 1.15 -r 1.16 src/common/smtp.c; ) > 0.9.12cvs9.patchset
 ( cvs diff -u -r 1.3 -r 1.4 src/gtk/quicksearch.c; ) > 0.9.12cvs14.patchset
+( cvs diff -u -r 1.224 -r 1.225 src/prefs_common.c; cvs diff -u -r 1.111 -r 1.112 src/prefs_common.h; cvs diff -u -r 1.436 -r 1.437 src/summaryview.c; cvs diff -u -r 1.4 -r 1.5 src/gtk/quicksearch.c; cvs diff -u -r 1.2 -r 1.3 src/gtk/quicksearch.h; ) > 0.9.12cvs15.patchset
index 0d45e23..b69cedb 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=12
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=14
+EXTRA_VERSION=15
 EXTRA_RELEASE=
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
index 22e83ec..a2152b5 100644 (file)
@@ -47,8 +47,11 @@ struct _QuickSearch
 
        QuickSearchExecuteCallback       callback;
        gpointer                         callback_data;
+       gboolean                         running;
 };
 
+void quicksearch_set_running(QuickSearch *quicksearch, gboolean run);
+
 static void prepare_matcher(QuickSearch *quicksearch)
 {
        gchar *search_string = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(quicksearch->search_string_entry)->entry));
@@ -88,6 +91,12 @@ static void prepare_matcher(QuickSearch *quicksearch)
 static gint searchbar_pressed(GtkWidget *widget, GdkEventKey *event,
                              QuickSearch *quicksearch)
 {
+       if (event != NULL && event->keyval == GDK_Escape) {
+               quicksearch_set(quicksearch, prefs_common.summary_quicksearch_type, "");
+               gtk_widget_grab_focus(GTK_WIDGET(GTK_COMBO(quicksearch->search_string_entry)->entry));
+               return TRUE;
+       }
+
        if (event != NULL && event->keyval == GDK_Return) {
                gchar *search_string = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(quicksearch->search_string_entry)->entry));
 
@@ -101,9 +110,12 @@ static gint searchbar_pressed(GtkWidget *widget, GdkEventKey *event,
 
                prepare_matcher(quicksearch);
 
+               quicksearch_set_running(quicksearch, TRUE);
                if (quicksearch->callback != NULL)
                        quicksearch->callback(quicksearch, quicksearch->callback_data);
+               quicksearch_set_running(quicksearch, FALSE);
                gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), "key_press_event");
+               gtk_widget_grab_focus(GTK_WIDGET(GTK_COMBO(quicksearch->search_string_entry)->entry));
        }
 
        return TRUE;            
@@ -127,8 +139,10 @@ static void searchtype_changed(GtkMenuItem *widget, gpointer data)
 
        prepare_matcher(quicksearch);
 
+       quicksearch_set_running(quicksearch, TRUE);
        if (quicksearch->callback != NULL)
                quicksearch->callback(quicksearch, quicksearch->callback_data);
+       quicksearch_set_running(quicksearch, FALSE);
 }
 
 /*
@@ -277,12 +291,15 @@ QuickSearch *quicksearch_new()
 
        gtk_box_set_spacing(GTK_BOX(search_hbbox), 5);
 
-       clear_search = gtk_button_new_with_label(_("Clear"));
-       gtk_box_pack_start(GTK_BOX(search_hbbox), clear_search,
-                          FALSE, FALSE, 0);
-       gtk_widget_set_usize(clear_search, 120, -1);
-       
-       gtk_widget_show(clear_search);
+       if (prefs_common.summary_quicksearch_sticky) {
+               clear_search = gtk_button_new_with_label(_("Clear"));
+               gtk_box_pack_start(GTK_BOX(search_hbbox), clear_search,
+                                  FALSE, FALSE, 0);
+               gtk_widget_set_usize(clear_search, 120, -1);
+               gtk_signal_connect(GTK_OBJECT(clear_search), "clicked",
+                                  GTK_SIGNAL_FUNC(clear_search_cb), quicksearch);
+               gtk_widget_show(clear_search);
+       }
 
        search_description = gtk_button_new_with_label(_("Extended Symbols"));
        gtk_box_pack_start(GTK_BOX(search_hbbox), search_description,
@@ -291,8 +308,7 @@ QuickSearch *quicksearch_new()
 
        gtk_signal_connect(GTK_OBJECT(search_description), "clicked",
                           GTK_SIGNAL_FUNC(search_description_cb), NULL);
-       gtk_signal_connect(GTK_OBJECT(clear_search), "clicked",
-                          GTK_SIGNAL_FUNC(clear_search_cb), quicksearch);
+       
        gtk_box_pack_start(GTK_BOX(hbox_search), search_hbbox, FALSE, FALSE, 2);                                
        gtk_widget_show(search_hbbox);
        if (prefs_common.summary_quicksearch_type == QUICK_SEARCH_EXTENDED)
@@ -324,6 +340,7 @@ QuickSearch *quicksearch_new()
        quicksearch->search_description = search_description;
        quicksearch->matcher_list = NULL;
        quicksearch->active = FALSE;
+       quicksearch->running = FALSE;
 
        return quicksearch;
 }
@@ -582,3 +599,14 @@ gchar *expand_search_string(const gchar *search_string)
        g_string_free(matcherstr, FALSE);
        return returnstr;
 }
+
+void quicksearch_set_running(QuickSearch *quicksearch, gboolean run)
+{
+       quicksearch->running = run;
+}
+
+gboolean quicksearch_is_running(QuickSearch *quicksearch) 
+{
+       return quicksearch->running;
+}
+
index d868032..0458b51 100644 (file)
@@ -44,5 +44,6 @@ void quicksearch_set_execute_callback(QuickSearch *quicksearch,
                                      gpointer data);
 gboolean quicksearch_match(QuickSearch *quicksearch, MsgInfo *msginfo);
 gchar *expand_search_string(const gchar *str);
+gboolean quicksearch_is_running(QuickSearch *quicksearch);
 
 #endif /* QUICKSEARCH_H */
index 6a0a2db..f369fbe 100644 (file)
@@ -724,6 +724,8 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"summary_quicksearch_type", "0", &prefs_common.summary_quicksearch_type, P_INT,
         NULL, NULL, NULL},
+       {"summary_quicksearch_sticky", "1", &prefs_common.summary_quicksearch_sticky, P_INT,
+        NULL, NULL, NULL},
 
        {"io_timeout_secs", "60", &prefs_common.io_timeout_secs,
         P_INT, &other.spinbtn_iotimeout,
index 141367c..d54bb47 100644 (file)
@@ -291,6 +291,7 @@ struct _PrefsCommon
        gboolean work_offline;
        
        gint summary_quicksearch_type;
+       gint summary_quicksearch_sticky;
        gulong color_new;
        
        GList *summary_quicksearch_history;
index f63a767..9c53e80 100644 (file)
@@ -787,6 +787,11 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
        inc_lock();
        summary_lock(summaryview);
 
+       if (!prefs_common.summary_quicksearch_sticky
+        && !quicksearch_is_running(summaryview->quicksearch)) {
+               quicksearch_set(summaryview->quicksearch, prefs_common.summary_quicksearch_type, "");
+       }
+
        /* STATUSBAR_POP(summaryview->mainwin); */
 
        is_refresh = (item == summaryview->folder_item) ? TRUE : FALSE;