sync with 0.7.5cvs9
[claws.git] / src / summary_search.c
index a962e29d4a9c658b60f2fde4b2782f70ee3e7a59..60e517d618dd821f2bd1b9fa9ec2be5d915c0b36 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2001 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2002 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -75,6 +75,8 @@ void summary_search(SummaryView *summaryview)
 {
        if (!window)
                summary_search_create(summaryview);
+       else
+               gtk_widget_hide(window);
 
        gtk_widget_grab_focus(search_btn);
        gtk_widget_grab_focus(subject_entry);
@@ -93,19 +95,15 @@ static void summary_search_create(SummaryView *summaryview)
        GtkWidget *confirm_area;
 
        window = gtk_window_new (GTK_WINDOW_DIALOG);
-       gtk_window_set_title (GTK_WINDOW (window), _("Search folder"));
+       gtk_window_set_title (GTK_WINDOW (window), _("Search messages"));
        gtk_widget_set_usize (window, 450, -1);
-       /*gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);*/
        gtk_window_set_policy(GTK_WINDOW(window), FALSE, TRUE, TRUE);
        gtk_container_set_border_width (GTK_CONTAINER (window), 8);
        gtk_signal_connect(GTK_OBJECT(window), "delete_event",
                           GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete), NULL);
        gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
                           GTK_SIGNAL_FUNC(key_pressed), NULL);
-       gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
-                          GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
-       gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
-                          GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
+       MANAGE_WINDOW_SIGNALS_CONNECT(window);
 
        vbox1 = gtk_vbox_new (FALSE, 0);
        gtk_widget_show (vbox1);
@@ -234,6 +232,9 @@ static void summary_search_execute(GtkButton *button, gpointer data)
        wchar_t *(* WCSFindFunc) (const wchar_t *haystack,
                                  const wchar_t *needle);
 
+       if (summary_is_locked(summaryview)) return;
+       summary_lock(summaryview);
+
        case_sens = gtk_toggle_button_get_active
                (GTK_TOGGLE_BUTTON(case_checkbtn));
        backward = gtk_toggle_button_get_active
@@ -269,7 +270,10 @@ static void summary_search_execute(GtkButton *button, gpointer data)
                else
                        node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list);
 
-               if (!node) return;
+               if (!node) {
+                       summary_unlock(summaryview);
+                       return;
+               }
        } else {
                if (backward)
                        node = GTK_CTREE_NODE_PREV(summaryview->selected);
@@ -350,11 +354,19 @@ static void summary_search_execute(GtkButton *button, gpointer data)
                        if (search_all)
                                gtk_ctree_select(ctree, node);
                        else {
-                               summary_select_node(summaryview, node, TRUE);
-                               if (body_matched) {
-                                       messageview_search_string
-                                               (summaryview->messageview,
-                                                body_str, case_sens);
+                               if (summaryview->msg_is_toggled_on) {
+                                       summary_unlock(summaryview);
+                                       summary_select_node
+                                               (summaryview, node, TRUE, TRUE);
+                                       summary_lock(summaryview);
+                                       if (body_matched) {
+                                               messageview_search_string
+                                                       (summaryview->messageview,
+                                                        body_str, case_sens);
+                                       }
+                               } else {
+                                       summary_select_node
+                                               (summaryview, node, FALSE, TRUE);
                                }
                                break;
                        }
@@ -366,6 +378,8 @@ static void summary_search_execute(GtkButton *button, gpointer data)
 
        if (*body_str)
                main_window_cursor_normal(summaryview->mainwin);
+
+       summary_unlock(summaryview);
 }
 
 static void summary_search_clear(GtkButton *button, gpointer data)