root / src / summary_search.c @ 237
History | View | Annotate | Download (13.6 kB)
| 1 | 1 | hiro | /*
|
|---|---|---|---|
| 2 | 1 | hiro | * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client |
| 3 | 31 | hiro | * Copyright (C) 1999-2005 Hiroyuki Yamamoto |
| 4 | 1 | hiro | * |
| 5 | 1 | hiro | * This program is free software; you can redistribute it and/or modify |
| 6 | 1 | hiro | * it under the terms of the GNU General Public License as published by |
| 7 | 1 | hiro | * the Free Software Foundation; either version 2 of the License, or |
| 8 | 1 | hiro | * (at your option) any later version. |
| 9 | 1 | hiro | * |
| 10 | 1 | hiro | * This program is distributed in the hope that it will be useful, |
| 11 | 1 | hiro | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | 1 | hiro | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | 1 | hiro | * GNU General Public License for more details. |
| 14 | 1 | hiro | * |
| 15 | 1 | hiro | * You should have received a copy of the GNU General Public License |
| 16 | 1 | hiro | * along with this program; if not, write to the Free Software |
| 17 | 1 | hiro | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | 1 | hiro | */ |
| 19 | 1 | hiro | |
| 20 | 1 | hiro | #ifdef HAVE_CONFIG_H
|
| 21 | 1 | hiro | # include "config.h" |
| 22 | 1 | hiro | #endif
|
| 23 | 1 | hiro | |
| 24 | 1 | hiro | #include "defs.h" |
| 25 | 1 | hiro | |
| 26 | 1 | hiro | #include <glib.h> |
| 27 | 92 | hiro | #include <glib/gi18n.h> |
| 28 | 1 | hiro | #include <gdk/gdkkeysyms.h> |
| 29 | 1 | hiro | #include <gtk/gtkwidget.h> |
| 30 | 1 | hiro | #include <gtk/gtkwindow.h> |
| 31 | 1 | hiro | #include <gtk/gtkvbox.h> |
| 32 | 1 | hiro | #include <gtk/gtktable.h> |
| 33 | 1 | hiro | #include <gtk/gtkoptionmenu.h> |
| 34 | 1 | hiro | #include <gtk/gtklabel.h> |
| 35 | 1 | hiro | #include <gtk/gtkentry.h> |
| 36 | 1 | hiro | #include <gtk/gtkhbox.h> |
| 37 | 1 | hiro | #include <gtk/gtkcheckbutton.h> |
| 38 | 1 | hiro | #include <gtk/gtkhbbox.h> |
| 39 | 1 | hiro | #include <gtk/gtkbutton.h> |
| 40 | 237 | hiro | #include <gtk/gtkmenuitem.h> |
| 41 | 237 | hiro | #include <gtk/gtkstock.h> |
| 42 | 1 | hiro | #include <stdio.h> |
| 43 | 1 | hiro | #include <stdlib.h> |
| 44 | 1 | hiro | #include <string.h> |
| 45 | 1 | hiro | |
| 46 | 1 | hiro | #include "main.h" |
| 47 | 1 | hiro | #include "summary_search.h" |
| 48 | 1 | hiro | #include "summaryview.h" |
| 49 | 1 | hiro | #include "messageview.h" |
| 50 | 1 | hiro | #include "mainwindow.h" |
| 51 | 1 | hiro | #include "menu.h" |
| 52 | 1 | hiro | #include "utils.h" |
| 53 | 1 | hiro | #include "gtkutils.h" |
| 54 | 1 | hiro | #include "manage_window.h" |
| 55 | 1 | hiro | #include "alertpanel.h" |
| 56 | 1 | hiro | |
| 57 | 1 | hiro | static GtkWidget *window;
|
| 58 | 1 | hiro | static GtkWidget *bool_optmenu;
|
| 59 | 1 | hiro | static GtkWidget *from_entry;
|
| 60 | 1 | hiro | static GtkWidget *to_entry;
|
| 61 | 1 | hiro | static GtkWidget *subject_entry;
|
| 62 | 1 | hiro | static GtkWidget *body_entry;
|
| 63 | 1 | hiro | static GtkWidget *case_checkbtn;
|
| 64 | 1 | hiro | static GtkWidget *backward_checkbtn;
|
| 65 | 1 | hiro | static GtkWidget *all_checkbtn;
|
| 66 | 1 | hiro | static GtkWidget *search_btn;
|
| 67 | 1 | hiro | static GtkWidget *clear_btn;
|
| 68 | 1 | hiro | static GtkWidget *close_btn;
|
| 69 | 1 | hiro | |
| 70 | 1 | hiro | static void summary_search_create(SummaryView *summaryview); |
| 71 | 1 | hiro | static void summary_search_execute(GtkButton *button, gpointer data); |
| 72 | 1 | hiro | static void summary_search_clear(GtkButton *button, gpointer data); |
| 73 | 1 | hiro | static void from_activated(void); |
| 74 | 1 | hiro | static void to_activated(void); |
| 75 | 1 | hiro | static void subject_activated(void); |
| 76 | 1 | hiro | static void body_activated(void); |
| 77 | 1 | hiro | static void all_clicked(GtkButton *button); |
| 78 | 1 | hiro | static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event,
|
| 79 | 1 | hiro | gpointer data); |
| 80 | 1 | hiro | |
| 81 | 1 | hiro | void summary_search(SummaryView *summaryview)
|
| 82 | 1 | hiro | {
|
| 83 | 1 | hiro | if (!window)
|
| 84 | 1 | hiro | summary_search_create(summaryview); |
| 85 | 1 | hiro | else
|
| 86 | 1 | hiro | gtk_widget_hide(window); |
| 87 | 1 | hiro | |
| 88 | 1 | hiro | gtk_widget_grab_focus(search_btn); |
| 89 | 1 | hiro | gtk_widget_grab_focus(subject_entry); |
| 90 | 1 | hiro | gtk_widget_show(window); |
| 91 | 1 | hiro | } |
| 92 | 1 | hiro | |
| 93 | 1 | hiro | static void summary_search_create(SummaryView *summaryview) |
| 94 | 1 | hiro | {
|
| 95 | 1 | hiro | GtkWidget *vbox1; |
| 96 | 1 | hiro | GtkWidget *bool_hbox; |
| 97 | 1 | hiro | GtkWidget *bool_menu; |
| 98 | 1 | hiro | GtkWidget *menuitem; |
| 99 | 1 | hiro | GtkWidget *table1; |
| 100 | 1 | hiro | GtkWidget *from_label; |
| 101 | 1 | hiro | GtkWidget *to_label; |
| 102 | 1 | hiro | GtkWidget *subject_label; |
| 103 | 1 | hiro | GtkWidget *body_label; |
| 104 | 1 | hiro | GtkWidget *checkbtn_hbox; |
| 105 | 1 | hiro | GtkWidget *confirm_area; |
| 106 | 1 | hiro | |
| 107 | 1 | hiro | window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
| 108 | 1 | hiro | gtk_window_set_title(GTK_WINDOW (window), _("Search messages"));
|
| 109 | 1 | hiro | gtk_widget_set_size_request(window, 450, -1); |
| 110 | 1 | hiro | gtk_window_set_policy(GTK_WINDOW(window), FALSE, TRUE, TRUE); |
| 111 | 1 | hiro | gtk_container_set_border_width(GTK_CONTAINER (window), 8);
|
| 112 | 1 | hiro | g_signal_connect(G_OBJECT(window), "delete_event",
|
| 113 | 1 | hiro | G_CALLBACK(gtk_widget_hide_on_delete), NULL);
|
| 114 | 1 | hiro | g_signal_connect(G_OBJECT(window), "key_press_event",
|
| 115 | 1 | hiro | G_CALLBACK(key_pressed), NULL);
|
| 116 | 1 | hiro | MANAGE_WINDOW_SIGNALS_CONNECT(window); |
| 117 | 1 | hiro | |
| 118 | 1 | hiro | vbox1 = gtk_vbox_new (FALSE, 0);
|
| 119 | 1 | hiro | gtk_widget_show (vbox1); |
| 120 | 1 | hiro | gtk_container_add (GTK_CONTAINER (window), vbox1); |
| 121 | 1 | hiro | |
| 122 | 1 | hiro | bool_hbox = gtk_hbox_new(FALSE, 4);
|
| 123 | 1 | hiro | gtk_widget_show(bool_hbox); |
| 124 | 1 | hiro | gtk_box_pack_start(GTK_BOX(vbox1), bool_hbox, FALSE, FALSE, 0);
|
| 125 | 1 | hiro | |
| 126 | 1 | hiro | bool_optmenu = gtk_option_menu_new(); |
| 127 | 1 | hiro | gtk_widget_show(bool_optmenu); |
| 128 | 1 | hiro | gtk_box_pack_start(GTK_BOX(bool_hbox), bool_optmenu, FALSE, FALSE, 0);
|
| 129 | 1 | hiro | |
| 130 | 1 | hiro | bool_menu = gtk_menu_new(); |
| 131 | 1 | hiro | MENUITEM_ADD(bool_menu, menuitem, _("Match any of the following"), 0); |
| 132 | 1 | hiro | MENUITEM_ADD(bool_menu, menuitem, _("Match all of the following"), 1); |
| 133 | 1 | hiro | gtk_option_menu_set_menu(GTK_OPTION_MENU(bool_optmenu), bool_menu); |
| 134 | 1 | hiro | |
| 135 | 1 | hiro | table1 = gtk_table_new (4, 3, FALSE); |
| 136 | 1 | hiro | gtk_widget_show (table1); |
| 137 | 1 | hiro | gtk_box_pack_start (GTK_BOX (vbox1), table1, TRUE, TRUE, 0);
|
| 138 | 1 | hiro | gtk_container_set_border_width (GTK_CONTAINER (table1), 4);
|
| 139 | 1 | hiro | gtk_table_set_row_spacings (GTK_TABLE (table1), 8);
|
| 140 | 1 | hiro | gtk_table_set_col_spacings (GTK_TABLE (table1), 8);
|
| 141 | 1 | hiro | |
| 142 | 1 | hiro | from_entry = gtk_entry_new (); |
| 143 | 1 | hiro | gtk_widget_show (from_entry); |
| 144 | 1 | hiro | gtk_table_attach (GTK_TABLE (table1), from_entry, 1, 3, 0, 1, |
| 145 | 1 | hiro | GTK_EXPAND|GTK_FILL, 0, 0, 0); |
| 146 | 1 | hiro | g_signal_connect(G_OBJECT(from_entry), "activate",
|
| 147 | 1 | hiro | G_CALLBACK(from_activated), summaryview); |
| 148 | 1 | hiro | |
| 149 | 1 | hiro | to_entry = gtk_entry_new (); |
| 150 | 1 | hiro | gtk_widget_show (to_entry); |
| 151 | 1 | hiro | gtk_table_attach (GTK_TABLE (table1), to_entry, 1, 3, 1, 2, |
| 152 | 1 | hiro | GTK_EXPAND|GTK_FILL, 0, 0, 0); |
| 153 | 1 | hiro | g_signal_connect(G_OBJECT(to_entry), "activate",
|
| 154 | 1 | hiro | G_CALLBACK(to_activated), summaryview); |
| 155 | 1 | hiro | |
| 156 | 1 | hiro | subject_entry = gtk_entry_new (); |
| 157 | 1 | hiro | gtk_widget_show (subject_entry); |
| 158 | 1 | hiro | gtk_table_attach (GTK_TABLE (table1), subject_entry, 1, 3, 2, 3, |
| 159 | 1 | hiro | GTK_EXPAND|GTK_FILL, 0, 0, 0); |
| 160 | 1 | hiro | g_signal_connect(G_OBJECT(subject_entry), "activate",
|
| 161 | 1 | hiro | G_CALLBACK(subject_activated), summaryview); |
| 162 | 1 | hiro | |
| 163 | 1 | hiro | body_entry = gtk_entry_new (); |
| 164 | 1 | hiro | gtk_widget_show (body_entry); |
| 165 | 1 | hiro | gtk_table_attach (GTK_TABLE (table1), body_entry, 1, 3, 3, 4, |
| 166 | 1 | hiro | GTK_EXPAND|GTK_FILL, 0, 0, 0); |
| 167 | 1 | hiro | g_signal_connect(G_OBJECT(body_entry), "activate",
|
| 168 | 1 | hiro | G_CALLBACK(body_activated), summaryview); |
| 169 | 1 | hiro | |
| 170 | 1 | hiro | from_label = gtk_label_new (_("From:"));
|
| 171 | 1 | hiro | gtk_widget_show (from_label); |
| 172 | 1 | hiro | gtk_table_attach (GTK_TABLE (table1), from_label, 0, 1, 0, 1, |
| 173 | 1 | hiro | GTK_FILL, 0, 0, 0); |
| 174 | 1 | hiro | gtk_label_set_justify (GTK_LABEL (from_label), GTK_JUSTIFY_RIGHT); |
| 175 | 1 | hiro | gtk_misc_set_alignment (GTK_MISC (from_label), 1, 0.5); |
| 176 | 1 | hiro | |
| 177 | 1 | hiro | to_label = gtk_label_new (_("To:"));
|
| 178 | 1 | hiro | gtk_widget_show (to_label); |
| 179 | 1 | hiro | gtk_table_attach (GTK_TABLE (table1), to_label, 0, 1, 1, 2, |
| 180 | 1 | hiro | GTK_FILL, 0, 0, 0); |
| 181 | 1 | hiro | gtk_label_set_justify (GTK_LABEL (to_label), GTK_JUSTIFY_RIGHT); |
| 182 | 1 | hiro | gtk_misc_set_alignment (GTK_MISC (to_label), 1, 0.5); |
| 183 | 1 | hiro | |
| 184 | 1 | hiro | subject_label = gtk_label_new (_("Subject:"));
|
| 185 | 1 | hiro | gtk_widget_show (subject_label); |
| 186 | 1 | hiro | gtk_table_attach (GTK_TABLE (table1), subject_label, 0, 1, 2, 3, |
| 187 | 1 | hiro | GTK_FILL, 0, 0, 0); |
| 188 | 1 | hiro | gtk_label_set_justify (GTK_LABEL (subject_label), GTK_JUSTIFY_RIGHT); |
| 189 | 1 | hiro | gtk_misc_set_alignment (GTK_MISC (subject_label), 1, 0.5); |
| 190 | 1 | hiro | |
| 191 | 1 | hiro | body_label = gtk_label_new (_("Body:"));
|
| 192 | 1 | hiro | gtk_widget_show (body_label); |
| 193 | 1 | hiro | gtk_table_attach (GTK_TABLE (table1), body_label, 0, 1, 3, 4, |
| 194 | 1 | hiro | GTK_FILL, 0, 0, 0); |
| 195 | 1 | hiro | gtk_label_set_justify (GTK_LABEL (body_label), GTK_JUSTIFY_RIGHT); |
| 196 | 1 | hiro | gtk_misc_set_alignment (GTK_MISC (body_label), 1, 0.5); |
| 197 | 1 | hiro | |
| 198 | 1 | hiro | checkbtn_hbox = gtk_hbox_new (FALSE, 8);
|
| 199 | 1 | hiro | gtk_widget_show (checkbtn_hbox); |
| 200 | 1 | hiro | gtk_box_pack_start (GTK_BOX (vbox1), checkbtn_hbox, TRUE, TRUE, 0);
|
| 201 | 1 | hiro | gtk_container_set_border_width (GTK_CONTAINER (checkbtn_hbox), 8);
|
| 202 | 1 | hiro | |
| 203 | 1 | hiro | case_checkbtn = gtk_check_button_new_with_label (_("Case sensitive"));
|
| 204 | 1 | hiro | gtk_widget_show (case_checkbtn); |
| 205 | 1 | hiro | gtk_box_pack_start (GTK_BOX (checkbtn_hbox), case_checkbtn, |
| 206 | 1 | hiro | FALSE, FALSE, 0);
|
| 207 | 1 | hiro | |
| 208 | 1 | hiro | backward_checkbtn = |
| 209 | 1 | hiro | gtk_check_button_new_with_label (_("Backward search"));
|
| 210 | 1 | hiro | gtk_widget_show (backward_checkbtn); |
| 211 | 1 | hiro | gtk_box_pack_start (GTK_BOX (checkbtn_hbox), backward_checkbtn, |
| 212 | 1 | hiro | FALSE, FALSE, 0);
|
| 213 | 1 | hiro | |
| 214 | 1 | hiro | all_checkbtn = |
| 215 | 1 | hiro | gtk_check_button_new_with_label (_("Select all matched"));
|
| 216 | 1 | hiro | gtk_widget_show (all_checkbtn); |
| 217 | 1 | hiro | gtk_box_pack_start (GTK_BOX (checkbtn_hbox), all_checkbtn, |
| 218 | 1 | hiro | FALSE, FALSE, 0);
|
| 219 | 1 | hiro | g_signal_connect(G_OBJECT(all_checkbtn), "clicked",
|
| 220 | 1 | hiro | G_CALLBACK(all_clicked), summaryview); |
| 221 | 1 | hiro | |
| 222 | 31 | hiro | gtkut_stock_button_set_create(&confirm_area, |
| 223 | 31 | hiro | &search_btn, GTK_STOCK_FIND, |
| 224 | 31 | hiro | &clear_btn, GTK_STOCK_CLEAR, |
| 225 | 31 | hiro | &close_btn, GTK_STOCK_CLOSE); |
| 226 | 1 | hiro | gtk_widget_show (confirm_area); |
| 227 | 1 | hiro | gtk_box_pack_start (GTK_BOX (vbox1), confirm_area, FALSE, FALSE, 0);
|
| 228 | 1 | hiro | gtk_widget_grab_default(search_btn); |
| 229 | 1 | hiro | |
| 230 | 1 | hiro | g_signal_connect(G_OBJECT(search_btn), "clicked",
|
| 231 | 1 | hiro | G_CALLBACK(summary_search_execute), summaryview); |
| 232 | 1 | hiro | g_signal_connect(G_OBJECT(clear_btn), "clicked",
|
| 233 | 1 | hiro | G_CALLBACK(summary_search_clear), summaryview); |
| 234 | 1 | hiro | g_signal_connect_closure |
| 235 | 1 | hiro | (G_OBJECT(close_btn), "clicked",
|
| 236 | 1 | hiro | g_cclosure_new_swap(G_CALLBACK(gtk_widget_hide), |
| 237 | 1 | hiro | window, NULL),
|
| 238 | 1 | hiro | FALSE); |
| 239 | 1 | hiro | } |
| 240 | 1 | hiro | |
| 241 | 1 | hiro | static void summary_search_execute(GtkButton *button, gpointer data) |
| 242 | 1 | hiro | {
|
| 243 | 237 | hiro | #if 0
|
| 244 | 1 | hiro | SummaryView *summaryview = data; |
| 245 | 1 | hiro | MsgInfo *msginfo; |
| 246 | 1 | hiro | gboolean bool_and; |
| 247 | 1 | hiro | gboolean case_sens; |
| 248 | 1 | hiro | gboolean backward; |
| 249 | 1 | hiro | gboolean search_all; |
| 250 | 1 | hiro | gboolean all_searched = FALSE; |
| 251 | 1 | hiro | gboolean matched; |
| 252 | 1 | hiro | gboolean body_matched; |
| 253 | 1 | hiro | const gchar *from_str, *to_str, *subject_str, *body_str; |
| 254 | 1 | hiro | StrFindFunc str_find_func; |
| 255 | 1 | hiro | |
| 256 | 1 | hiro | if (summary_is_locked(summaryview)) return; |
| 257 | 1 | hiro | summary_lock(summaryview); |
| 258 | 1 | hiro | |
| 259 | 1 | hiro | bool_and = menu_get_option_menu_active_index |
| 260 | 1 | hiro | (GTK_OPTION_MENU(bool_optmenu)); |
| 261 | 1 | hiro | case_sens = gtk_toggle_button_get_active |
| 262 | 1 | hiro | (GTK_TOGGLE_BUTTON(case_checkbtn)); |
| 263 | 1 | hiro | backward = gtk_toggle_button_get_active |
| 264 | 1 | hiro | (GTK_TOGGLE_BUTTON(backward_checkbtn)); |
| 265 | 1 | hiro | search_all = gtk_toggle_button_get_active |
| 266 | 1 | hiro | (GTK_TOGGLE_BUTTON(all_checkbtn)); |
| 267 | 1 | hiro | |
| 268 | 1 | hiro | if (case_sens) |
| 269 | 1 | hiro | str_find_func = str_find; |
| 270 | 1 | hiro | else |
| 271 | 1 | hiro | str_find_func = str_case_find; |
| 272 | 1 | hiro | |
| 273 | 1 | hiro | from_str = gtk_entry_get_text(GTK_ENTRY(from_entry)); |
| 274 | 1 | hiro | to_str = gtk_entry_get_text(GTK_ENTRY(to_entry)); |
| 275 | 1 | hiro | subject_str = gtk_entry_get_text(GTK_ENTRY(subject_entry)); |
| 276 | 1 | hiro | body_str = gtk_entry_get_text(GTK_ENTRY(body_entry)); |
| 277 | 1 | hiro | |
| 278 | 1 | hiro | if (search_all) {
|
| 279 | 1 | hiro | gtk_clist_freeze(GTK_CLIST(ctree)); |
| 280 | 1 | hiro | gtk_clist_unselect_all(GTK_CLIST(ctree)); |
| 281 | 1 | hiro | node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list); |
| 282 | 1 | hiro | backward = FALSE; |
| 283 | 1 | hiro | } else if (!summaryview->selected) {
|
| 284 | 1 | hiro | if (backward) |
| 285 | 1 | hiro | node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list_end); |
| 286 | 1 | hiro | else |
| 287 | 1 | hiro | node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list); |
| 288 | 1 | hiro | |
| 289 | 1 | hiro | if (!node) {
|
| 290 | 1 | hiro | summary_unlock(summaryview); |
| 291 | 1 | hiro | return; |
| 292 | 1 | hiro | } |
| 293 | 1 | hiro | } else {
|
| 294 | 1 | hiro | if (backward) |
| 295 | 1 | hiro | node = gtkut_ctree_node_prev |
| 296 | 1 | hiro | (ctree, summaryview->selected); |
| 297 | 1 | hiro | else |
| 298 | 1 | hiro | node = gtkut_ctree_node_next |
| 299 | 1 | hiro | (ctree, summaryview->selected); |
| 300 | 1 | hiro | } |
| 301 | 1 | hiro | |
| 302 | 1 | hiro | if (*body_str) |
| 303 | 1 | hiro | main_window_cursor_wait(summaryview->mainwin); |
| 304 | 1 | hiro | |
| 305 | 1 | hiro | for (;;) {
|
| 306 | 1 | hiro | if (!node) {
|
| 307 | 1 | hiro | gchar *str; |
| 308 | 1 | hiro | AlertValue val; |
| 309 | 1 | hiro | |
| 310 | 1 | hiro | if (search_all) {
|
| 311 | 1 | hiro | gtk_clist_thaw(GTK_CLIST(ctree)); |
| 312 | 1 | hiro | break; |
| 313 | 1 | hiro | } |
| 314 | 1 | hiro | |
| 315 | 1 | hiro | if (all_searched) {
|
| 316 | 1 | hiro | alertpanel_message |
| 317 | 1 | hiro | (_("Search failed"),
|
| 318 | 1 | hiro | _("Search string not found."),
|
| 319 | 1 | hiro | ALERT_WARNING); |
| 320 | 1 | hiro | break; |
| 321 | 1 | hiro | } |
| 322 | 1 | hiro | |
| 323 | 1 | hiro | if (backward) |
| 324 | 1 | hiro | str = _("Beginning of list reached; continue from end?");
|
| 325 | 1 | hiro | else |
| 326 | 1 | hiro | str = _("End of list reached; continue from beginning?");
|
| 327 | 1 | hiro | |
| 328 | 1 | hiro | val = alertpanel(_("Search finished"), str,
|
| 329 | 47 | hiro | GTK_STOCK_YES, GTK_STOCK_NO, NULL); |
| 330 | 1 | hiro | if (G_ALERTDEFAULT == val) {
|
| 331 | 1 | hiro | if (backward) |
| 332 | 1 | hiro | node = GTK_CTREE_NODE |
| 333 | 1 | hiro | (GTK_CLIST(ctree)->row_list_end); |
| 334 | 1 | hiro | else |
| 335 | 1 | hiro | node = GTK_CTREE_NODE |
| 336 | 1 | hiro | (GTK_CLIST(ctree)->row_list); |
| 337 | 1 | hiro | |
| 338 | 1 | hiro | all_searched = TRUE; |
| 339 | 1 | hiro | |
| 340 | 1 | hiro | manage_window_focus_in(window, NULL, NULL); |
| 341 | 1 | hiro | } else |
| 342 | 1 | hiro | break; |
| 343 | 1 | hiro | } |
| 344 | 1 | hiro | |
| 345 | 1 | hiro | |
| 346 | 1 | hiro | msginfo = gtk_ctree_node_get_row_data(ctree, node); |
| 347 | 1 | hiro | body_matched = FALSE; |
| 348 | 1 | hiro | |
| 349 | 1 | hiro | if (bool_and) {
|
| 350 | 1 | hiro | matched = TRUE; |
| 351 | 1 | hiro | if (*from_str) {
|
| 352 | 1 | hiro | if (!msginfo->from || |
| 353 | 1 | hiro | !str_find_func(msginfo->from, from_str)) |
| 354 | 1 | hiro | matched = FALSE; |
| 355 | 1 | hiro | } |
| 356 | 1 | hiro | if (matched && *to_str) {
|
| 357 | 1 | hiro | if (!msginfo->to || |
| 358 | 1 | hiro | !str_find_func(msginfo->to, to_str)) |
| 359 | 1 | hiro | matched = FALSE; |
| 360 | 1 | hiro | } |
| 361 | 1 | hiro | if (matched && *subject_str) {
|
| 362 | 1 | hiro | if (!msginfo->subject || |
| 363 | 1 | hiro | !str_find_func(msginfo->subject, subject_str)) |
| 364 | 1 | hiro | matched = FALSE; |
| 365 | 1 | hiro | } |
| 366 | 1 | hiro | if (matched && *body_str) {
|
| 367 | 1 | hiro | if (procmime_find_string(msginfo, body_str, |
| 368 | 1 | hiro | str_find_func)) |
| 369 | 1 | hiro | body_matched = TRUE; |
| 370 | 1 | hiro | else |
| 371 | 1 | hiro | matched = FALSE; |
| 372 | 1 | hiro | } |
| 373 | 1 | hiro | if (matched && !*from_str && !*to_str && |
| 374 | 1 | hiro | !*subject_str && !*body_str) |
| 375 | 1 | hiro | matched = FALSE; |
| 376 | 1 | hiro | } else {
|
| 377 | 1 | hiro | matched = FALSE; |
| 378 | 1 | hiro | if (*from_str && msginfo->from) {
|
| 379 | 1 | hiro | if (str_find_func(msginfo->from, from_str)) |
| 380 | 1 | hiro | matched = TRUE; |
| 381 | 1 | hiro | } |
| 382 | 1 | hiro | if (!matched && *to_str && msginfo->to) {
|
| 383 | 1 | hiro | if (str_find_func(msginfo->to, to_str)) |
| 384 | 1 | hiro | matched = TRUE; |
| 385 | 1 | hiro | } |
| 386 | 1 | hiro | if (!matched && *subject_str && msginfo->subject) {
|
| 387 | 1 | hiro | if (str_find_func(msginfo->subject, subject_str)) |
| 388 | 1 | hiro | matched = TRUE; |
| 389 | 1 | hiro | } |
| 390 | 1 | hiro | if (!matched && *body_str) {
|
| 391 | 1 | hiro | if (procmime_find_string(msginfo, body_str, |
| 392 | 1 | hiro | str_find_func)) {
|
| 393 | 1 | hiro | matched = TRUE; |
| 394 | 1 | hiro | body_matched = TRUE; |
| 395 | 1 | hiro | } |
| 396 | 1 | hiro | } |
| 397 | 1 | hiro | } |
| 398 | 1 | hiro | |
| 399 | 1 | hiro | if (matched) {
|
| 400 | 1 | hiro | if (search_all) |
| 401 | 1 | hiro | gtk_ctree_select(ctree, node); |
| 402 | 1 | hiro | else {
|
| 403 | 1 | hiro | if (messageview_is_visible |
| 404 | 1 | hiro | (summaryview->messageview)) {
|
| 405 | 1 | hiro | summary_unlock(summaryview); |
| 406 | 237 | hiro | summary_select_row |
| 407 | 237 | hiro | (summaryview, &iter, TRUE, TRUE); |
| 408 | 1 | hiro | summary_lock(summaryview); |
| 409 | 1 | hiro | if (body_matched) {
|
| 410 | 1 | hiro | messageview_search_string |
| 411 | 1 | hiro | (summaryview->messageview, |
| 412 | 1 | hiro | body_str, case_sens); |
| 413 | 1 | hiro | } |
| 414 | 1 | hiro | } else {
|
| 415 | 1 | hiro | summary_select_node |
| 416 | 1 | hiro | (summaryview, node, FALSE, TRUE); |
| 417 | 1 | hiro | } |
| 418 | 1 | hiro | break; |
| 419 | 1 | hiro | } |
| 420 | 1 | hiro | } |
| 421 | 1 | hiro | |
| 422 | 1 | hiro | node = backward ? gtkut_ctree_node_prev(ctree, node) |
| 423 | 1 | hiro | : gtkut_ctree_node_next(ctree, node); |
| 424 | 1 | hiro | } |
| 425 | 1 | hiro | |
| 426 | 1 | hiro | if (*body_str) |
| 427 | 1 | hiro | main_window_cursor_normal(summaryview->mainwin); |
| 428 | 1 | hiro | |
| 429 | 1 | hiro | summary_unlock(summaryview); |
| 430 | 237 | hiro | #endif |
| 431 | 1 | hiro | } |
| 432 | 1 | hiro | |
| 433 | 1 | hiro | static void summary_search_clear(GtkButton *button, gpointer data) |
| 434 | 1 | hiro | {
|
| 435 | 1 | hiro | gtk_editable_delete_text(GTK_EDITABLE(from_entry), 0, -1); |
| 436 | 1 | hiro | gtk_editable_delete_text(GTK_EDITABLE(to_entry), 0, -1); |
| 437 | 1 | hiro | gtk_editable_delete_text(GTK_EDITABLE(subject_entry), 0, -1); |
| 438 | 1 | hiro | gtk_editable_delete_text(GTK_EDITABLE(body_entry), 0, -1); |
| 439 | 1 | hiro | } |
| 440 | 1 | hiro | |
| 441 | 1 | hiro | static void from_activated(void) |
| 442 | 1 | hiro | {
|
| 443 | 1 | hiro | gtk_widget_grab_focus(to_entry); |
| 444 | 1 | hiro | } |
| 445 | 1 | hiro | |
| 446 | 1 | hiro | static void to_activated(void) |
| 447 | 1 | hiro | {
|
| 448 | 1 | hiro | gtk_widget_grab_focus(subject_entry); |
| 449 | 1 | hiro | } |
| 450 | 1 | hiro | |
| 451 | 1 | hiro | static void subject_activated(void) |
| 452 | 1 | hiro | {
|
| 453 | 1 | hiro | gtk_button_clicked(GTK_BUTTON(search_btn)); |
| 454 | 1 | hiro | } |
| 455 | 1 | hiro | |
| 456 | 1 | hiro | static void body_activated(void) |
| 457 | 1 | hiro | {
|
| 458 | 1 | hiro | gtk_button_clicked(GTK_BUTTON(search_btn)); |
| 459 | 1 | hiro | } |
| 460 | 1 | hiro | |
| 461 | 1 | hiro | static void all_clicked(GtkButton *button) |
| 462 | 1 | hiro | {
|
| 463 | 1 | hiro | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
|
| 464 | 1 | hiro | gtk_widget_set_sensitive(backward_checkbtn, FALSE); |
| 465 | 1 | hiro | else
|
| 466 | 1 | hiro | gtk_widget_set_sensitive(backward_checkbtn, TRUE); |
| 467 | 1 | hiro | } |
| 468 | 1 | hiro | |
| 469 | 1 | hiro | static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event,
|
| 470 | 1 | hiro | gpointer data) |
| 471 | 1 | hiro | {
|
| 472 | 1 | hiro | if (event && event->keyval == GDK_Escape)
|
| 473 | 1 | hiro | gtk_widget_hide(window); |
| 474 | 1 | hiro | return FALSE;
|
| 475 | 1 | hiro | } |