#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>
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;
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);
{
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 {
{
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)
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);
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);
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);
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);
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);
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);
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);
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)
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;
}
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);
matcher_list = matcherlist_new(matchers, bool_and);
if (!matcher_list)
return FALSE;
+
matcher_str = matcherlist_to_string(matcher_list);
matcherlist_free(matcher_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);
if (!result)
return FALSE;
+
msgnums = procmsg_get_number_list_for_msgs(msglist);
procmsg_msg_list_free(msglist);
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);
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);
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;
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++) {
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;
}
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);
all_searched = TRUE;
manage_window_focus_in(search_window.window, NULL, NULL);
- } else {
+ } else
break;
- }
}
msginfo = gtk_cmctree_node_get_row_data(ctree, node);
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);
search_window.is_searching = FALSE;
summary_hide_stop_button();
main_window_cursor_normal(summaryview->mainwin);
- if (search_all) {
+ if (search_all)
summary_thaw_with_status(summaryview);
- }
summary_unlock(summaryview);
}
/* 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);
}
}
};
+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)
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)
{