* src/prefs_common.[ch]
authorAlfons Hoogervorst <alfons@proteus.demon.nl>
Wed, 24 Mar 2004 18:32:39 +0000 (18:32 +0000)
committerAlfons Hoogervorst <alfons@proteus.demon.nl>
Wed, 24 Mar 2004 18:32:39 +0000 (18:32 +0000)
  src/summaryview.c
  src/common/defs.h
add history to quick search (patch submitted by
Ivan Francolin Martinez - thanks!)

ChangeLog.claws
configure.ac
src/common/defs.h
src/prefs_common.c
src/prefs_common.h
src/summaryview.c

index dbf27d3..439e651 100644 (file)
@@ -1,3 +1,11 @@
+2004-03-24 [alfons]    0.9.10claws29
+
+       * src/prefs_common.[ch]
+         src/summaryview.c
+         src/common/defs.h
+               add history to quick search (patch submitted by 
+               Ivan Francolin Martinez - thanks!)
+
 2004-03-24 [alfons]    0.9.10claws28
 
        * src/imap.c
index 4e7e4b0..306470a 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=10
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=28
+EXTRA_VERSION=29
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index 37b2da2..adefdef 100644 (file)
@@ -59,6 +59,7 @@
 #define ACTIONS_RC             "actionsrc"
 #define RENDERER_RC            "rendererrc"
 #define COMMAND_HISTORY                "command_history"
+#define QUICKSEARCH_HISTORY    "quicksearch_history"
 #define TEMPLATE_DIR           "templates"
 #define TMP_DIR                        "tmp"
 #define NEWSGROUP_LIST         ".newsgroup_list"
index 6013353..13b0e8a 100644 (file)
@@ -864,43 +864,54 @@ PrefsCommon *prefs_common_get(void)
        return &prefs_common;
 }
 
-void prefs_common_read_config(void)
+/*
+ * Read history list from the specified history file
+ */
+GList *prefs_common_read_history(const gchar *history) 
 {
        FILE *fp;
        gchar *path;
        gchar buf[PREFSBUFSIZE];
+       GList *tmp = NULL;
 
-       prefs_read_config(param, "Common", COMMON_RC);
-
-       path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMAND_HISTORY,
+       path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, history,
                           NULL);
        if ((fp = fopen(path, "rb")) == NULL) {
                if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
                g_free(path);
-               return;
+               return NULL;
        }
        g_free(path);
        while (fgets(buf, sizeof(buf), fp) != NULL) {
                g_strstrip(buf);
                if (buf[0] == '\0') continue;
-               prefs_common.mime_open_cmd_history =
-                       add_history(prefs_common.mime_open_cmd_history, buf);
+               tmp = add_history(tmp, buf);
        }
        fclose(fp);
 
+       tmp = g_list_reverse(tmp);
+}
+
+void prefs_common_read_config(void)
+{
+       prefs_read_config(param, "Common", COMMON_RC);
+
        prefs_common.mime_open_cmd_history =
-               g_list_reverse(prefs_common.mime_open_cmd_history);
+               prefs_common_read_history(COMMAND_HISTORY);
+       prefs_common.summary_quicksearch_history =
+               prefs_common_read_history(QUICKSEARCH_HISTORY);
 }
 
-void prefs_common_save_config(void)
+/*
+ * Save history list to the specified history file
+ */
+void prefs_common_save_history(const gchar *history, GList *list)
 {
        GList *cur;
        FILE *fp;
        gchar *path;
 
-       prefs_save_config(param, "Common", COMMON_RC);
-
-       path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMAND_HISTORY,
+       path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, history,
                           NULL);
        if ((fp = fopen(path, "wb")) == NULL) {
                FILE_OP_ERROR(path, "fopen");
@@ -908,8 +919,7 @@ void prefs_common_save_config(void)
                return;
        }
 
-       for (cur = prefs_common.mime_open_cmd_history;
-            cur != NULL; cur = cur->next) {
+       for (cur = list; cur != NULL; cur = cur->next) {
                fputs((gchar *)cur->data, fp);
                fputc('\n', fp);
        }
@@ -918,6 +928,16 @@ void prefs_common_save_config(void)
        g_free(path);
 }
 
+void prefs_common_save_config(void)
+{
+       prefs_save_config(param, "Common", COMMON_RC);
+
+       prefs_common_save_history(COMMAND_HISTORY, 
+               prefs_common.mime_open_cmd_history);
+       prefs_common_save_history(QUICKSEARCH_HISTORY, 
+               prefs_common.summary_quicksearch_history);
+}
+
 void prefs_common_open(void)
 {
        if (prefs_rc_is_readonly(COMMON_RC))
index 9663ddd..2752730 100644 (file)
@@ -292,6 +292,7 @@ struct _PrefsCommon
        gboolean work_offline;
        
        gint summary_quicksearch_type;
+       GList *summary_quicksearch_history;
        gulong color_new;
 };
 
index 62821c2..4c9a12f 100644 (file)
@@ -657,28 +657,35 @@ SummaryView *summary_create(void)
        
        gtk_widget_show(search_type);
        
-       search_string = gtk_entry_new();
-       
+       search_string = gtk_combo_new();
        gtk_box_pack_start(GTK_BOX(hbox_search), search_string, FALSE, FALSE, 2);
-       
+       gtk_combo_set_value_in_list(GTK_COMBO(search_string), FALSE, TRUE);
+       gtk_combo_set_case_sensitive(GTK_COMBO(search_string), FALSE);
+       if (prefs_common.summary_quicksearch_history) 
+               gtk_combo_set_popdown_strings(GTK_COMBO(search_string), 
+                       prefs_common.summary_quicksearch_history);
+       gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(search_string)->entry), "");
+       gtk_widget_show(search_string);
+               
        gtkut_button_set_create(&search_hbbox, &search_description, _("Extended Symbols"),
                                NULL, NULL, NULL, NULL);
        gtk_signal_connect(GTK_OBJECT(search_description), "clicked",
                           GTK_SIGNAL_FUNC(search_description_cb), NULL);
-       gtk_box_pack_start(GTK_BOX(hbox_search), search_hbbox, FALSE, FALSE, 2);
-                               
-       gtk_widget_show(search_string);
+       gtk_box_pack_start(GTK_BOX(hbox_search), search_hbbox, FALSE, FALSE, 2);                                
        gtk_widget_show(hbox_search);
 
-       gtk_signal_connect(GTK_OBJECT(search_string), "key_press_event",
+       gtk_signal_connect(GTK_OBJECT(GTK_COMBO(search_string)->entry), 
+                          "key_press_event",
                           GTK_SIGNAL_FUNC(summary_searchbar_pressed),
                           summaryview);
 
-       gtk_signal_connect(GTK_OBJECT(search_string), "focus_in_event",
+       gtk_signal_connect(GTK_OBJECT(GTK_COMBO(search_string)->entry), 
+                          "focus_in_event",
                           GTK_SIGNAL_FUNC(summary_searchbar_focus_evt),
                           summaryview);
 
-       gtk_signal_connect(GTK_OBJECT(search_string), "focus_out_event",
+       gtk_signal_connect(GTK_OBJECT(GTK_COMBO(search_string)->entry), 
+                          "focus_out_event",
                           GTK_SIGNAL_FUNC(summary_searchbar_focus_evt),
                           summaryview);
 
@@ -914,7 +921,7 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
 
        if (item != summaryview->folder_item) {
                /* changing folder, reset search */
-               gtk_entry_set_text(GTK_ENTRY(summaryview->search_string), "");
+               gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(summaryview->search_string)->entry), "");
        }
        
        /* STATUSBAR_POP(summaryview->mainwin); */
@@ -1015,12 +1022,12 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
                summary_set_hide_read_msgs_menu(summaryview, FALSE);
        }
 
-       if (strlen(gtk_entry_get_text(GTK_ENTRY(summaryview->search_string))) > 0) {
+       if (strlen(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(summaryview->search_string)->entry))) > 0) {
                GSList *not_killed;
                gint search_type = GPOINTER_TO_INT(gtk_object_get_user_data(
                                   GTK_OBJECT(GTK_MENU_ITEM(gtk_menu_get_active(
                                   GTK_MENU(summaryview->search_type))))));
-               gchar *search_string = gtk_entry_get_text(GTK_ENTRY(summaryview->search_string));
+               gchar *search_string = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(summaryview->search_string)->entry));
                gchar *searched_header = NULL;
                MatcherList * tmp_list = NULL;
                
@@ -4531,8 +4538,18 @@ static gint summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
 static gint summary_searchbar_pressed(GtkWidget *widget, GdkEventKey *event,
                                SummaryView *summaryview)
 {
-       if (event != NULL && event->keyval == GDK_Return)
+       if (event != NULL && event->keyval == GDK_Return) {
+               gchar *search_string = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(summaryview->search_string)->entry));
+               if (search_string && strlen(search_string) != 0) {
+                       prefs_common.summary_quicksearch_history =
+                               add_history(prefs_common.summary_quicksearch_history,
+                                           search_string);
+                       gtk_combo_set_popdown_strings(GTK_COMBO(summaryview->search_string), 
+                               prefs_common.summary_quicksearch_history);                      
+               }
                summary_show(summaryview, summaryview->folder_item);
+               gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), "key_press_event");
+       }
        return TRUE;            
 }
 
@@ -4563,7 +4580,7 @@ static void summary_searchtype_changed(GtkMenuItem *widget, gpointer data)
                gtk_widget_hide(sw->search_description);
        }
 
-       if (gtk_entry_get_text(GTK_ENTRY(sw->search_string)))
+       if (gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(sw->search_string)->entry)))
                summary_show(sw, sw->folder_item);
 }
 
@@ -5414,7 +5431,7 @@ static void summary_find_answers (SummaryView *summaryview, MsgInfo *msg)
                                    S_SEARCH_EXTENDED);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(summaryview->toggle_search), TRUE);
 
-       gtk_entry_set_text(GTK_ENTRY(summaryview->search_string), buf);
+       gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(summaryview->search_string)->entry), buf);
        g_free(buf);
        summary_show(summaryview, summaryview->folder_item);
        node = gtk_ctree_node_nth(GTK_CTREE(summaryview->ctree), 0);