remove all gtk3 conditionals
[claws.git] / src / summary_search.c
index e4ff06d8e190fd444d107533b5982ccaa1194217..3f1c84656cfbfde1be6ade5d578ec3106b08cf8d 100644 (file)
@@ -28,9 +28,7 @@
 #include <glib/gi18n.h>
 #include <gdk/gdkkeysyms.h>
 #include <gtk/gtk.h>
-#if !GTK_CHECK_VERSION(3, 0, 0)
 #include "gtk/gtksctree.h"
-#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -60,11 +58,16 @@ static struct SummarySearchWindow {
 
        GtkWidget *bool_optmenu;
 
+       GtkWidget *from_label;
        GtkWidget *from_entry;
+       GtkWidget *to_label;
        GtkWidget *to_entry;
+       GtkWidget *subject_label;
        GtkWidget *subject_entry;
+       GtkWidget *body_label;
        GtkWidget *body_entry;
 
+       GtkWidget *adv_condition_label;
        GtkWidget *adv_condition_entry;
        GtkWidget *adv_condition_btn;
        GtkWidget *adv_search_checkbtn;
@@ -119,11 +122,13 @@ static void summary_search_stop_clicked   (GtkButton      *button,
 static void adv_condition_btn_clicked  (GtkButton      *button,
                                         gpointer        data);
 
+static void optmenu_changed                    (GtkComboBox *widget, gpointer user_data);
 static void from_changed                       (void);
 static void to_changed                         (void);
 static void subject_changed                    (void);
 static void body_changed                       (void);
 static void adv_condition_changed      (void);
+static void case_changed                       (GtkToggleButton *togglebutton, gpointer user_data);
 
 static gboolean from_entry_focus_evt_in(GtkWidget *widget, GdkEventFocus *event,
                                  gpointer data);
@@ -145,53 +150,27 @@ static gboolean adv_condition_entry_focus_evt_in(GtkWidget *widget, GdkEventFocu
                                  gpointer data);
 static gboolean adv_condition_entry_focus_evt_out(GtkWidget *widget, GdkEventFocus *event,
                                  gpointer data);
-#ifndef MAEMO
 static gboolean key_pressed            (GtkWidget      *widget,
                                         GdkEventKey    *event,
                                         gpointer        data);
-#endif
 
-#if !GTK_CHECK_VERSION(2,14,0)
-/* Work around http://bugzilla.gnome.org/show_bug.cgi?id=56070 */
 #define GTK_BUTTON_SET_SENSITIVE(widget,sensitive) {                                   \
-       gboolean in_btn = FALSE;                                                        \
-       if (GTK_IS_BUTTON(widget))                                                      \
-               in_btn = GTK_BUTTON(widget)->in_button;                                 \
        gtk_widget_set_sensitive(widget, sensitive);                                    \
-       if (GTK_IS_BUTTON(widget))                                                      \
-               GTK_BUTTON(widget)->in_button = in_btn;                                 \
 }
-#else
-#define GTK_BUTTON_SET_SENSITIVE(widget,sensitive) {                                   \
-       gtk_widget_set_sensitive(widget, sensitive);                                    \
-}
-#endif
 
 static gchar* add_history_get(GtkWidget *from, GList **history)
 {
        gchar *result;
 
-#if !GTK_CHECK_VERSION(2, 24, 0)
-       result = gtk_combo_box_get_active_text(GTK_COMBO_BOX(from));
-#else
        result = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(from));
-#endif
        if (!result)
                result = gtk_editable_get_chars(GTK_EDITABLE(gtk_bin_get_child(GTK_BIN(from))), 0, -1);
 
        if (result && result[0] != '\0') {
                /* add to history */
-#if !GTK_CHECK_VERSION(2, 24, 0)
-               combobox_unset_popdown_strings(GTK_COMBO_BOX(from));
-#else
                combobox_unset_popdown_strings(GTK_COMBO_BOX_TEXT(from));
-#endif
                *history = add_history(*history, result);
-#if !GTK_CHECK_VERSION(2, 24, 0)
-               combobox_set_popdown_strings(GTK_COMBO_BOX(from), *history);
-#else
                combobox_set_popdown_strings(GTK_COMBO_BOX_TEXT(from), *history);
-#endif
 
                return result;
        } else {
@@ -219,18 +198,56 @@ static void summary_show_stop_button(void)
 {
        gtk_widget_hide(search_window.close_btn);
        gtk_widget_show(search_window.stop_btn);
+       GTK_BUTTON_SET_SENSITIVE(search_window.clear_btn, FALSE)
        GTK_BUTTON_SET_SENSITIVE(search_window.all_btn, FALSE)
        GTK_BUTTON_SET_SENSITIVE(search_window.prev_btn, FALSE)
        GTK_BUTTON_SET_SENSITIVE(search_window.next_btn, FALSE)
+       gtk_widget_set_sensitive(search_window.adv_condition_label, FALSE);
+       gtk_widget_set_sensitive(search_window.adv_condition_entry, FALSE);
+       gtk_widget_set_sensitive(search_window.adv_condition_btn, FALSE);
+       gtk_widget_set_sensitive(search_window.to_label, FALSE);
+       gtk_widget_set_sensitive(search_window.to_entry, FALSE);
+       gtk_widget_set_sensitive(search_window.from_label, FALSE);
+       gtk_widget_set_sensitive(search_window.from_entry, FALSE);
+       gtk_widget_set_sensitive(search_window.subject_label, FALSE);
+       gtk_widget_set_sensitive(search_window.subject_entry, FALSE);
+       gtk_widget_set_sensitive(search_window.body_label, FALSE);
+       gtk_widget_set_sensitive(search_window.body_entry, FALSE);
+       gtk_widget_set_sensitive(search_window.bool_optmenu, FALSE);
+       gtk_widget_set_sensitive(search_window.clear_btn, FALSE);
+       gtk_widget_set_sensitive(search_window.case_checkbtn, FALSE);
+       gtk_widget_set_sensitive(search_window.adv_search_checkbtn, FALSE);
 }
 
 static void summary_hide_stop_button(void)
 {
+       GTK_BUTTON_SET_SENSITIVE(search_window.clear_btn, TRUE)
        gtk_widget_hide(search_window.stop_btn);
        gtk_widget_show(search_window.close_btn);
+       if (gtk_toggle_button_get_active
+                       (GTK_TOGGLE_BUTTON(search_window.adv_search_checkbtn))) {
+               gtk_widget_set_sensitive(search_window.adv_condition_label, TRUE);
+               gtk_widget_set_sensitive(search_window.adv_condition_entry, TRUE);
+               gtk_widget_set_sensitive(search_window.adv_condition_btn, TRUE);
+               gtk_widget_set_sensitive(search_window.case_checkbtn, FALSE);
+               gtk_widget_set_sensitive(search_window.bool_optmenu, FALSE);
+       } else {
+               gtk_widget_set_sensitive(search_window.to_label, TRUE);
+               gtk_widget_set_sensitive(search_window.to_entry, TRUE);
+               gtk_widget_set_sensitive(search_window.from_label, TRUE);
+               gtk_widget_set_sensitive(search_window.from_entry, TRUE);
+               gtk_widget_set_sensitive(search_window.subject_label, TRUE);
+               gtk_widget_set_sensitive(search_window.subject_entry, TRUE);
+               gtk_widget_set_sensitive(search_window.body_label, TRUE);
+               gtk_widget_set_sensitive(search_window.body_entry, TRUE);
+               gtk_widget_set_sensitive(search_window.case_checkbtn, TRUE);
+               gtk_widget_set_sensitive(search_window.bool_optmenu, TRUE);
+       }
+       gtk_widget_set_sensitive(search_window.clear_btn, TRUE);
        gtk_widget_set_sensitive(search_window.all_btn, TRUE);
        gtk_widget_set_sensitive(search_window.prev_btn, TRUE);
        gtk_widget_set_sensitive(search_window.next_btn, TRUE);
+       gtk_widget_set_sensitive(search_window.adv_search_checkbtn, TRUE);
 }
 
 static void summary_search_create(void)
@@ -275,12 +292,8 @@ static void summary_search_create(void)
        gtk_container_set_border_width(GTK_CONTAINER (window), 8);
        g_signal_connect(G_OBJECT(window), "delete_event",
                         G_CALLBACK(gtk_widget_hide_on_delete), NULL);
-#ifdef MAEMO
-       maemo_connect_key_press_to_mainwindow(GTK_WINDOW(window));
-#else
        g_signal_connect(G_OBJECT(window), "key_press_event",
                         G_CALLBACK(key_pressed), NULL);
-#endif
        MANAGE_WINDOW_SIGNALS_CONNECT(window);
 
        vbox1 = gtk_vbox_new (FALSE, 0);
@@ -299,6 +312,8 @@ static void summary_search_create(void)
        COMBOBOX_ADD(menu, _("Match any of the following"), 0);
        gtk_combo_box_set_active_iter(GTK_COMBO_BOX(bool_optmenu), &iter);
        COMBOBOX_ADD(menu, _("Match all of the following"), 1);
+       g_signal_connect(G_OBJECT(bool_optmenu), "changed",
+                        G_CALLBACK(optmenu_changed), NULL);
 
        clear_btn = gtk_button_new_from_stock(GTK_STOCK_CLEAR);
        gtk_widget_show(clear_btn);
@@ -311,20 +326,11 @@ static void summary_search_create(void)
        gtk_table_set_row_spacings (GTK_TABLE (table1), 8);
        gtk_table_set_col_spacings (GTK_TABLE (table1), 8);
 
-#if !GTK_CHECK_VERSION(2, 24, 0)
-       from_entry = gtk_combo_box_entry_new_text ();
-#else
        from_entry = gtk_combo_box_text_new_with_entry ();
-#endif
        gtk_combo_box_set_active(GTK_COMBO_BOX(from_entry), -1);
        if (prefs_common.summary_search_from_history)
-#if !GTK_CHECK_VERSION(2, 24, 0)
-               combobox_set_popdown_strings(GTK_COMBO_BOX(from_entry),
-                               prefs_common.summary_search_from_history);
-#else
                combobox_set_popdown_strings(GTK_COMBO_BOX_TEXT(from_entry),
                                prefs_common.summary_search_from_history);
-#endif
        gtk_widget_show (from_entry);
        gtk_table_attach (GTK_TABLE (table1), from_entry, 1, 3, 0, 1,
                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
@@ -335,20 +341,11 @@ static void summary_search_create(void)
        g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN((from_entry)))),
                         "focus_out_event", G_CALLBACK(from_entry_focus_evt_out), NULL);
 
-#if !GTK_CHECK_VERSION(2, 24, 0)
-       to_entry = gtk_combo_box_entry_new_text ();
-#else
        to_entry = gtk_combo_box_text_new_with_entry ();
-#endif
        gtk_combo_box_set_active(GTK_COMBO_BOX(to_entry), -1);
        if (prefs_common.summary_search_to_history)
-#if !GTK_CHECK_VERSION(2, 24, 0)
-               combobox_set_popdown_strings(GTK_COMBO_BOX(to_entry),
-                               prefs_common.summary_search_to_history);
-#else
                combobox_set_popdown_strings(GTK_COMBO_BOX_TEXT(to_entry),
                                prefs_common.summary_search_to_history);
-#endif
        gtk_widget_show (to_entry);
        gtk_table_attach (GTK_TABLE (table1), to_entry, 1, 3, 1, 2,
                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
@@ -359,20 +356,11 @@ static void summary_search_create(void)
        g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN((to_entry)))),
                         "focus_out_event", G_CALLBACK(to_entry_focus_evt_out), NULL);
 
-#if !GTK_CHECK_VERSION(2, 24, 0)
-       subject_entry = gtk_combo_box_entry_new_text ();
-#else
        subject_entry = gtk_combo_box_text_new_with_entry ();
-#endif
        gtk_combo_box_set_active(GTK_COMBO_BOX(subject_entry), -1);
        if (prefs_common.summary_search_subject_history)
-#if !GTK_CHECK_VERSION(2, 24, 0)
-               combobox_set_popdown_strings(GTK_COMBO_BOX(subject_entry),
-                               prefs_common.summary_search_subject_history);
-#else
                combobox_set_popdown_strings(GTK_COMBO_BOX_TEXT(subject_entry),
                                prefs_common.summary_search_subject_history);
-#endif
        gtk_widget_show (subject_entry);
        gtk_table_attach (GTK_TABLE (table1), subject_entry, 1, 3, 2, 3,
                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
@@ -383,20 +371,11 @@ static void summary_search_create(void)
        g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN((subject_entry)))),
                         "focus_out_event", G_CALLBACK(subject_entry_focus_evt_out), NULL);
 
-#if !GTK_CHECK_VERSION(2, 24, 0)
-       body_entry = gtk_combo_box_entry_new_text ();
-#else
        body_entry = gtk_combo_box_text_new_with_entry ();
-#endif
        gtk_combo_box_set_active(GTK_COMBO_BOX(body_entry), -1);
        if (prefs_common.summary_search_body_history)
-#if !GTK_CHECK_VERSION(2, 24, 0)
-               combobox_set_popdown_strings(GTK_COMBO_BOX(body_entry),
-                               prefs_common.summary_search_body_history);
-#else
                combobox_set_popdown_strings(GTK_COMBO_BOX_TEXT(body_entry),
                                prefs_common.summary_search_body_history);
-#endif
        gtk_widget_show (body_entry);
        gtk_table_attach (GTK_TABLE (table1), body_entry, 1, 3, 3, 4,
                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
@@ -407,20 +386,11 @@ static void summary_search_create(void)
        g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN((body_entry)))),
                         "focus_out_event", G_CALLBACK(body_entry_focus_evt_out), NULL);
 
-#if !GTK_CHECK_VERSION(2, 24, 0)
-       adv_condition_entry = gtk_combo_box_entry_new_text ();
-#else
        adv_condition_entry = gtk_combo_box_text_new_with_entry ();
-#endif
        gtk_combo_box_set_active(GTK_COMBO_BOX(adv_condition_entry), -1);
        if (prefs_common.summary_search_adv_condition_history)
-#if !GTK_CHECK_VERSION(2, 24, 0)
-               combobox_set_popdown_strings(GTK_COMBO_BOX(adv_condition_entry),
-                               prefs_common.summary_search_adv_condition_history);
-#else
                combobox_set_popdown_strings(GTK_COMBO_BOX_TEXT(adv_condition_entry),
                                prefs_common.summary_search_adv_condition_history);
-#endif
        gtk_widget_show (adv_condition_entry);
        gtk_table_attach (GTK_TABLE (table1), adv_condition_entry, 1, 2, 4, 5,
                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
@@ -485,11 +455,15 @@ static void summary_search_create(void)
        gtk_widget_show (case_checkbtn);
        gtk_box_pack_start (GTK_BOX (checkbtn_hbox), case_checkbtn,
                            FALSE, FALSE, 0);
+       g_signal_connect(G_OBJECT(case_checkbtn), "changed",
+                        G_CALLBACK(case_changed), NULL);
 
        adv_search_checkbtn = gtk_check_button_new_with_label (_("Extended Search"));
        gtk_widget_show (adv_search_checkbtn);
        gtk_box_pack_start (GTK_BOX (checkbtn_hbox), adv_search_checkbtn,
                            FALSE, FALSE, 0);
+       g_signal_connect(G_OBJECT(adv_search_checkbtn), "changed",
+                        G_CALLBACK(case_changed), NULL);
 
        confirm_area = gtk_hbutton_box_new();
        gtk_widget_show (confirm_area);
@@ -500,37 +474,41 @@ static void summary_search_create(void)
        gtkut_stock_button_add_help(confirm_area, &help_btn);
 
        all_btn = gtk_button_new_with_mnemonic(_("Find _all"));
-       gtkut_widget_set_can_default(all_btn, TRUE);
+       gtk_widget_set_can_default(all_btn, TRUE);
        gtk_box_pack_start(GTK_BOX(confirm_area), all_btn, TRUE, TRUE, 0);
        gtk_widget_show(all_btn);
 
        prev_btn = gtk_button_new_from_stock(GTK_STOCK_GO_BACK);
-       gtkut_widget_set_can_default(prev_btn, TRUE);
+       gtk_widget_set_can_default(prev_btn, TRUE);
        gtk_box_pack_start(GTK_BOX(confirm_area), prev_btn, TRUE, TRUE, 0);
        gtk_widget_show(prev_btn);
 
        next_btn = gtk_button_new_from_stock(GTK_STOCK_GO_FORWARD);
-       gtkut_widget_set_can_default(next_btn, TRUE);
+       gtk_widget_set_can_default(next_btn, TRUE);
        gtk_box_pack_start(GTK_BOX(confirm_area), next_btn, TRUE, TRUE, 0);
        gtk_widget_show(next_btn);
 
        close_btn = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
-       gtkut_widget_set_can_default(close_btn, TRUE);
+       gtk_widget_set_can_default(close_btn, TRUE);
        gtk_box_pack_start(GTK_BOX(confirm_area), close_btn, TRUE, TRUE, 0);
        gtk_widget_show(close_btn);
 
        /* stop button hidden */
        stop_btn = gtk_button_new_from_stock(GTK_STOCK_STOP);
-       gtkut_widget_set_can_default(stop_btn, TRUE);
+       gtk_widget_set_can_default(stop_btn, TRUE);
        gtk_box_pack_start(GTK_BOX(confirm_area), stop_btn, TRUE, TRUE, 0);
 
        gtk_box_pack_start (GTK_BOX (vbox1), confirm_area, FALSE, FALSE, 0);
        gtk_widget_grab_default(next_btn);
 
        SET_TOGGLE_SENSITIVITY_REVERSE(adv_search_checkbtn, bool_optmenu)
+       SET_TOGGLE_SENSITIVITY_REVERSE(adv_search_checkbtn, from_label)
        SET_TOGGLE_SENSITIVITY_REVERSE(adv_search_checkbtn, from_entry)
+       SET_TOGGLE_SENSITIVITY_REVERSE(adv_search_checkbtn, to_label)
        SET_TOGGLE_SENSITIVITY_REVERSE(adv_search_checkbtn, to_entry)
+       SET_TOGGLE_SENSITIVITY_REVERSE(adv_search_checkbtn, subject_label)
        SET_TOGGLE_SENSITIVITY_REVERSE(adv_search_checkbtn, subject_entry)
+       SET_TOGGLE_SENSITIVITY_REVERSE(adv_search_checkbtn, body_label)
        SET_TOGGLE_SENSITIVITY_REVERSE(adv_search_checkbtn, body_entry)
        SET_TOGGLE_SENSITIVITY(adv_search_checkbtn, adv_condition_label)
        SET_TOGGLE_SENSITIVITY(adv_search_checkbtn, adv_condition_entry)
@@ -557,10 +535,15 @@ static void summary_search_create(void)
 
        search_window.window = window;
        search_window.bool_optmenu = bool_optmenu;
+       search_window.from_label = from_label;
        search_window.from_entry = from_entry;
+       search_window.to_label = to_label;
        search_window.to_entry = to_entry;
+       search_window.subject_label = subject_label;
        search_window.subject_entry = subject_entry;
+       search_window.body_label = body_label;
        search_window.body_entry = body_entry;
+       search_window.adv_condition_label = adv_condition_label;
        search_window.adv_condition_entry = adv_condition_entry;
        search_window.adv_condition_btn = adv_condition_btn;
        search_window.case_checkbtn = case_checkbtn;
@@ -577,9 +560,6 @@ static void summary_search_create(void)
        search_window.search_in_progress = FALSE;
        search_window.matched_msgnums = NULL;
        search_window.is_searching = is_searching;
-#ifdef MAEMO
-       maemo_window_full_screen_if_needed(GTK_WINDOW(search_window.window));
-#endif
 }
 
 static gboolean summary_search_verify_match(MsgInfo *msg)
@@ -624,7 +604,7 @@ static gboolean summary_search_prepare_matcher()
        }
 
        adv_search = gtk_toggle_button_get_active
-               (GTK_TOGGLE_BUTTON(search_window.adv_search_checkbtn));
+                       (GTK_TOGGLE_BUTTON(search_window.adv_search_checkbtn));
 
        if (adv_search) {
                matcher_str = add_history_get(search_window.adv_condition_entry, &prefs_common.summary_search_adv_condition_history);
@@ -670,6 +650,7 @@ static gboolean summary_search_prepare_matcher()
                matcher_list = matcherlist_new(matchers, bool_and);
                if (!matcher_list)
                        return FALSE;
+
                matcher_str = matcherlist_to_string(matcher_list);
                matcherlist_free(matcher_list);
        }
@@ -702,14 +683,13 @@ static gboolean summary_search_prereduce_msg_list()
        if (!watch_cursor)
                watch_cursor = gdk_cursor_new(GDK_WATCH);
 
-       if (search_window.matcher_is_outdated && !summary_search_prepare_matcher()) {
+       if (search_window.matcher_is_outdated && !summary_search_prepare_matcher())
                return FALSE;
-       }
 
        main_window_cursor_wait(mainwindow_get_mainwindow());
        gdk_window_set_cursor(gtk_widget_get_window(search_window.window), watch_cursor);
        statusbar_print_all(_("Searching in %s... \n"),
-               item->path ? item->path : "(null)");
+                       item->path ? item->path : "(null)");
 
        result = advsearch_search_msgs_in_folders(search_window.advsearch,
                        &msglist, item, FALSE);
@@ -720,6 +700,7 @@ static gboolean summary_search_prereduce_msg_list()
 
        if (!result)
                return FALSE;
+
        msgnums = procmsg_get_number_list_for_msgs(msglist);
        procmsg_msg_list_free(msglist);
 
@@ -728,9 +709,8 @@ static gboolean summary_search_prereduce_msg_list()
 
        g_hash_table_remove_all(search_window.matched_msgnums);
 
-       for (cur = msgnums; cur != NULL; cur = cur->next) {
+       for (cur = msgnums; cur != NULL; cur = cur->next)
                g_hash_table_insert(search_window.matched_msgnums, cur->data, GINT_TO_POINTER(1));
-       }
 
        g_slist_free(msgnums);
 
@@ -747,18 +727,17 @@ static void summary_search_execute(gboolean backward, gboolean search_all)
        gboolean matched = FALSE;
        gint i = 0;
 
-       if (summary_is_locked(summaryview)) {
+       if (summary_is_locked(summaryview))
                return;
-       }
+
        summary_lock(summaryview);
 
        search_window.is_searching = TRUE;
        main_window_cursor_wait(summaryview->mainwin);
        summary_show_stop_button();
 
-       if (search_window.matcher_is_outdated && !summary_search_prereduce_msg_list()) {
+       if (search_window.matcher_is_outdated && !summary_search_prereduce_msg_list())
                goto exit;
-       }
 
        if (search_all) {
                summary_freeze(summaryview);
@@ -766,11 +745,11 @@ static void summary_search_execute(gboolean backward, gboolean search_all)
                node = GTK_CMCTREE_NODE(GTK_CMCLIST(ctree)->row_list);
                backward = FALSE;
        } else if (!summaryview->selected) {
-               if (backward) {
+               /* no selection, search from from list start */
+               if (backward)
                        node = GTK_CMCTREE_NODE(GTK_CMCLIST(ctree)->row_list_end);
-               } else {
+               else
                        node = GTK_CMCTREE_NODE(GTK_CMCLIST(ctree)->row_list);
-               }
 
                if (!node) {
                        search_window.is_searching = FALSE;
@@ -780,11 +759,11 @@ static void summary_search_execute(gboolean backward, gboolean search_all)
                        return;
                }
        } else {
-               if (backward) {
+               /* search from current selection */
+               if (backward)
                        node = gtkut_ctree_node_prev(ctree, summaryview->selected);
-               } else {
+               else
                        node = gtkut_ctree_node_next(ctree, summaryview->selected);
-               }
        }
 
        for (; search_window.is_searching; i++) {
@@ -792,15 +771,14 @@ static void summary_search_execute(gboolean backward, gboolean search_all)
                        gchar *str;
                        AlertValue val;
 
-                       if (search_all) {
+                       if (search_all)
                                break;
-                       }
 
                        if (all_searched) {
                                alertpanel_full(_("Search failed"),
                                                _("Search string not found."),
-                                               GTK_STOCK_CLOSE, NULL, NULL, FALSE,
-                                               NULL, ALERT_WARNING, G_ALERTDEFAULT);
+                                               GTK_STOCK_CLOSE, NULL, NULL, ALERTFOCUS_FIRST,
+                                               FALSE, NULL, ALERT_WARNING);
                                break;
                        }
 
@@ -810,7 +788,8 @@ static void summary_search_execute(gboolean backward, gboolean search_all)
                                str = _("End of list reached; continue from beginning?");
 
                        val = alertpanel(_("Search finished"), str,
-                                        GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL);
+                                        GTK_STOCK_NO, GTK_STOCK_YES, NULL,
+                                        ALERTFOCUS_SECOND);
                        if (G_ALERTALTERNATE == val) {
                                if (backward) {
                                        node = GTK_CMCTREE_NODE(GTK_CMCLIST(ctree)->row_list_end);
@@ -821,33 +800,31 @@ static void summary_search_execute(gboolean backward, gboolean search_all)
                                all_searched = TRUE;
 
                                manage_window_focus_in(search_window.window, NULL, NULL);
-                       } else {
+                       } else
                                break;
-                       }
                }
 
                msginfo = gtk_cmctree_node_get_row_data(ctree, node);
 
-               matched = summary_search_verify_match(msginfo);
+               if (msginfo)
+                       matched = summary_search_verify_match(msginfo);
+               else
+                       matched = FALSE;
 
                if (matched) {
                        if (search_all) {
                                gtk_cmctree_select(ctree, node);
                        } else {
-                               if (messageview_is_visible(summaryview->messageview)) {
-                                       summary_unlock(summaryview);
-                                       summary_select_node(summaryview, node, TRUE, TRUE);
-                                       summary_lock(summaryview);
-                               } else {
-                                       summary_select_node(summaryview, node, FALSE, TRUE);
-                               }
+                               summary_unlock(summaryview);
+                               summary_select_node(summaryview, node,
+                                               OPEN_SELECTED_ON_SEARCH_RESULTS);
+                               summary_lock(summaryview);
                                break;
                        }
                }
 
-               if (i % (search_window.is_fast ? 1000 : 100) == 0) {
+               if (i % (search_window.is_fast ? 1000 : 100) == 0)
                        GTK_EVENTS_FLUSH();
-               }
 
                node = backward ? gtkut_ctree_node_prev(ctree, node)
                                : gtkut_ctree_node_next(ctree, node);
@@ -857,9 +834,8 @@ exit:
        search_window.is_searching = FALSE;
        summary_hide_stop_button();
        main_window_cursor_normal(summaryview->mainwin);
-       if (search_all) {
-               summary_thaw(summaryview);
-       }
+       if (search_all)
+               summary_thaw_with_status(summaryview);
        summary_unlock(summaryview);
 }
 
@@ -930,11 +906,7 @@ static void adv_condition_btn_clicked(GtkButton *button, gpointer data)
 
        /* re-use the current search value if it's a condition expression,
           otherwise ignore it silently */
-#if !GTK_CHECK_VERSION(2, 24, 0)
-       cond_str = gtk_combo_box_get_active_text(GTK_COMBO_BOX(search_window.adv_condition_entry));
-#else
        cond_str = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(search_window.adv_condition_entry));
-#endif
        if (cond_str && *cond_str != '\0') {
                matchers = matcher_parser_get_cond((gchar*)cond_str, NULL);
        }
@@ -946,6 +918,11 @@ static void adv_condition_btn_clicked(GtkButton *button, gpointer data)
        }
 };
 
+static void optmenu_changed(GtkComboBox *widget, gpointer user_data)
+{
+       search_window.matcher_is_outdated = TRUE;
+}
+
 static void from_changed(void)
 {
        if (!search_window.from_entry_has_focus)
@@ -981,6 +958,11 @@ static void adv_condition_changed(void)
        search_window.matcher_is_outdated = TRUE;
 }
 
+static void case_changed(GtkToggleButton *togglebutton, gpointer user_data)
+{
+       search_window.matcher_is_outdated = TRUE;
+}
+
 static gboolean from_entry_focus_evt_in(GtkWidget *widget, GdkEventFocus *event,
                                  gpointer data)
 {
@@ -1050,7 +1032,7 @@ static gboolean adv_condition_entry_focus_evt_out(GtkWidget *widget, GdkEventFoc
        search_window.adv_condition_entry_has_focus = FALSE;
        return FALSE;
 }
-#ifndef MAEMO
+
 static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event,
                            gpointer data)
 {
@@ -1107,4 +1089,3 @@ static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event,
 
        return FALSE;
 }
-#endif