add "sticky" pref for the quicksearch
[claws.git] / src / gtk / quicksearch.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 2004 Hiroyuki Yamamoto & the Sylpheed-Claws team
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
23
24 #include <gtk/gtk.h>
25 #include <gdk/gdkkeysyms.h>
26
27 #include "intl.h"
28 #include "utils.h"
29 #include "menu.h"
30 #include "prefs_common.h"
31 #include "description_window.h"
32 #include "matcher.h"
33 #include "matcher_parser.h"
34 #include "quicksearch.h"
35
36 struct _QuickSearch
37 {
38         GtkWidget                       *hbox_search;
39         GtkWidget                       *search_type;
40         GtkWidget                       *search_type_opt;
41         GtkWidget                       *search_string_entry;
42         GtkWidget                       *search_description;
43
44         gboolean                         active;
45         gchar                           *search_string;
46         MatcherList                     *matcher_list;
47
48         QuickSearchExecuteCallback       callback;
49         gpointer                         callback_data;
50         gboolean                         running;
51 };
52
53 void quicksearch_set_running(QuickSearch *quicksearch, gboolean run);
54
55 static void prepare_matcher(QuickSearch *quicksearch)
56 {
57         gchar *search_string = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(quicksearch->search_string_entry)->entry));
58
59         if (quicksearch->matcher_list != NULL) {
60                 matcherlist_free(quicksearch->matcher_list);
61                 quicksearch->matcher_list = NULL;
62         }
63
64         if (search_string == NULL || search_string[0] == '\0') {
65                 quicksearch->active = FALSE;
66                 return;
67         }
68
69         if (prefs_common.summary_quicksearch_type == QUICK_SEARCH_EXTENDED) {
70                 char *newstr = NULL;
71
72                 newstr = expand_search_string(search_string);
73                 if (newstr && newstr[0] != '\0') {
74                         quicksearch->matcher_list = matcher_parser_get_cond(newstr);
75                         g_free(newstr);
76                 } else {
77                         quicksearch->matcher_list = NULL;
78                         quicksearch->active = FALSE;
79
80                         return;
81                 }
82         } else {
83                 if (quicksearch->search_string != NULL)
84                         g_free(quicksearch->search_string);
85                 quicksearch->search_string = g_strdup(search_string);
86         }
87
88         quicksearch->active = TRUE;
89 }
90
91 static gint searchbar_pressed(GtkWidget *widget, GdkEventKey *event,
92                               QuickSearch *quicksearch)
93 {
94         if (event != NULL && event->keyval == GDK_Escape) {
95                 quicksearch_set(quicksearch, prefs_common.summary_quicksearch_type, "");
96                 gtk_widget_grab_focus(GTK_WIDGET(GTK_COMBO(quicksearch->search_string_entry)->entry));
97                 return TRUE;
98         }
99
100         if (event != NULL && event->keyval == GDK_Return) {
101                 gchar *search_string = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(quicksearch->search_string_entry)->entry));
102
103                 if (search_string && strlen(search_string) != 0) {
104                         prefs_common.summary_quicksearch_history =
105                                 add_history(prefs_common.summary_quicksearch_history,
106                                             search_string);
107                         gtk_combo_set_popdown_strings(GTK_COMBO(quicksearch->search_string_entry), 
108                                 prefs_common.summary_quicksearch_history);                      
109                 }
110
111                 prepare_matcher(quicksearch);
112
113                 quicksearch_set_running(quicksearch, TRUE);
114                 if (quicksearch->callback != NULL)
115                         quicksearch->callback(quicksearch, quicksearch->callback_data);
116                 quicksearch_set_running(quicksearch, FALSE);
117                 gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), "key_press_event");
118                 gtk_widget_grab_focus(GTK_WIDGET(GTK_COMBO(quicksearch->search_string_entry)->entry));
119         }
120
121         return TRUE;            
122 }
123
124 static void searchtype_changed(GtkMenuItem *widget, gpointer data)
125 {
126         QuickSearch *quicksearch = (QuickSearch *)data;
127
128         prefs_common.summary_quicksearch_type = GPOINTER_TO_INT(gtk_object_get_user_data(
129                                    GTK_OBJECT(GTK_MENU_ITEM(gtk_menu_get_active(
130                                    GTK_MENU(quicksearch->search_type))))));
131
132         /* Show extended search description button, only when Extended is selected */
133         if (prefs_common.summary_quicksearch_type == QUICK_SEARCH_EXTENDED) {
134                 gtk_widget_show(quicksearch->search_description);
135         } else {
136                 gtk_widget_hide(quicksearch->search_description);
137
138         }
139
140         prepare_matcher(quicksearch);
141
142         quicksearch_set_running(quicksearch, TRUE);
143         if (quicksearch->callback != NULL)
144                 quicksearch->callback(quicksearch, quicksearch->callback_data);
145         quicksearch_set_running(quicksearch, FALSE);
146 }
147
148 /*
149  * Strings describing how to use Extended Search
150  * 
151  * When adding new lines, remember to put 2 strings for each line
152  */
153 static gchar *search_descr_strings[] = {
154         "a",     N_("all messages"),
155         "ag #",  N_("messages whose age is greater than #"),
156         "al #",  N_("messages whose age is less than #"),
157         "b S",   N_("messages which contain S in the message body"),
158         "B S",   N_("messages which contain S in the whole message"),
159         "c S",   N_("messages carbon-copied to S"),
160         "C S",   N_("message is either to: or cc: to S"),
161         "D",     N_("deleted messages"), /** how I can filter deleted messages **/
162         "e S",   N_("messages which contain S in the Sender field"),
163         "E S",   N_("true if execute \"S\" succeeds"),
164         "f S",   N_("messages originating from user S"),
165         "F",     N_("forwarded messages"),
166         "h S",   N_("messages which contain header S"),
167         "i S",   N_("messages which contain S in Message-Id header"),
168         "I S",   N_("messages which contain S in inreplyto header"),
169         "L",     N_("locked messages"),
170         "n S",   N_("messages which are in newsgroup S"),
171         "N",     N_("new messages"),
172         "O",     N_("old messages"),
173         "r",     N_("messages which have been replied to"),
174         "R",     N_("read messages"),
175         "s S",   N_("messages which contain S in subject"),
176         "se #",  N_("messages whose score is equal to #"),
177         "sg #",  N_("messages whose score is greater than #"),
178         "sl #",  N_("messages whose score is lower than #"),
179         "Se #",  N_("messages whose size is equal to #"),
180         "Sg #",  N_("messages whose size is greater than #"),
181         "Ss #",  N_("messages whose size is smaller than #"),
182         "t S",   N_("messages which have been sent to S"),
183         "T",     N_("marked messages"),
184         "U",     N_("unread messages"),
185         "x S",   N_("messages which contain S in References header"),
186         "X cmd", N_("messages returning 0 when passed to command"),
187         "y S",   N_("messages which contain S in X-Label header"),
188         "",      "" ,
189         "&",     N_("logical AND operator"),
190         "|",     N_("logical OR operator"),
191         "! or ~",       N_("logical NOT operator"),
192         "%",     N_("case sensitive search"),
193         "",      "" ,
194         " ",     N_("all filtering expressions are allowed"),
195         NULL,    NULL 
196 };
197  
198 static DescriptionWindow search_descr = {
199         NULL, 
200         2,
201         N_("Extended Search symbols"),
202         search_descr_strings
203 };
204         
205 static void search_description_cb(GtkWidget *widget)
206 {
207         description_window_create(&search_descr);
208 };
209
210 static void clear_search_cb(GtkWidget *widget, gpointer data)
211 {
212         QuickSearch *quicksearch = (QuickSearch *)data;
213
214         quicksearch_set(quicksearch, prefs_common.summary_quicksearch_type, "");
215 }
216
217 /*
218 static void summary_searchbar_focus_evt(GtkWidget *widget, GdkEventFocus *event,
219                                         SummaryView *summaryview)
220 {
221         if (event != NULL && event->in)
222                 gtk_signal_handler_block_by_func(GTK_OBJECT(summaryview->mainwin->window), 
223                                                  GTK_SIGNAL_FUNC(mainwindow_key_pressed),
224                                                  summaryview->mainwin);
225         else
226                 gtk_signal_handler_unblock_by_func(GTK_OBJECT(summaryview->mainwin->window), 
227                                                    GTK_SIGNAL_FUNC(mainwindow_key_pressed),
228                                                    summaryview->mainwin);
229 }
230 */
231
232 QuickSearch *quicksearch_new()
233 {
234         QuickSearch *quicksearch;
235
236         GtkWidget *hbox_search;
237         GtkWidget *search_type_opt;
238         GtkWidget *search_type;
239         GtkWidget *search_string_entry;
240         GtkWidget *search_hbbox;
241         GtkWidget *search_description;
242         GtkWidget *clear_search;
243         GtkWidget *menuitem;
244
245         quicksearch = g_new0(QuickSearch, 1);
246
247         /* quick search */
248         hbox_search = gtk_hbox_new(FALSE, 0);
249
250         search_type_opt = gtk_option_menu_new();
251         gtk_widget_show(search_type_opt);
252         gtk_box_pack_start(GTK_BOX(hbox_search), search_type_opt, FALSE, FALSE, 0);
253
254         search_type = gtk_menu_new();
255         MENUITEM_ADD (search_type, menuitem, _("Subject"), QUICK_SEARCH_SUBJECT);
256         gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
257                            GTK_SIGNAL_FUNC(searchtype_changed),
258                            quicksearch);
259         MENUITEM_ADD (search_type, menuitem, _("From"), QUICK_SEARCH_FROM);
260         gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
261                            GTK_SIGNAL_FUNC(searchtype_changed),
262                            quicksearch);
263         MENUITEM_ADD (search_type, menuitem, _("To"), QUICK_SEARCH_TO);
264         gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
265                            GTK_SIGNAL_FUNC(searchtype_changed),
266                            quicksearch);
267         MENUITEM_ADD (search_type, menuitem, _("Extended"), QUICK_SEARCH_EXTENDED);
268         gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
269                            GTK_SIGNAL_FUNC(searchtype_changed),
270                            quicksearch);
271
272         gtk_option_menu_set_menu(GTK_OPTION_MENU(search_type_opt), search_type);
273         
274         gtk_option_menu_set_history(GTK_OPTION_MENU(search_type_opt), prefs_common.summary_quicksearch_type);
275         
276         gtk_widget_show(search_type);
277         
278         search_string_entry = gtk_combo_new();
279         gtk_box_pack_start(GTK_BOX(hbox_search), search_string_entry, FALSE, FALSE, 2);
280         gtk_combo_set_value_in_list(GTK_COMBO(search_string_entry), FALSE, TRUE);
281         gtk_combo_set_case_sensitive(GTK_COMBO(search_string_entry), TRUE);
282         if (prefs_common.summary_quicksearch_history) 
283                 gtk_combo_set_popdown_strings(GTK_COMBO(search_string_entry), 
284                         prefs_common.summary_quicksearch_history);
285         gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(search_string_entry)->entry), "");
286         gtk_widget_show(search_string_entry);
287                 
288         search_hbbox = gtk_hbutton_box_new();
289         gtk_button_box_set_layout(GTK_BUTTON_BOX(search_hbbox),
290                                   GTK_BUTTONBOX_START);
291
292         gtk_box_set_spacing(GTK_BOX(search_hbbox), 5);
293
294         if (prefs_common.summary_quicksearch_sticky) {
295                 clear_search = gtk_button_new_with_label(_("Clear"));
296                 gtk_box_pack_start(GTK_BOX(search_hbbox), clear_search,
297                                    FALSE, FALSE, 0);
298                 gtk_widget_set_usize(clear_search, 120, -1);
299                 gtk_signal_connect(GTK_OBJECT(clear_search), "clicked",
300                                    GTK_SIGNAL_FUNC(clear_search_cb), quicksearch);
301                 gtk_widget_show(clear_search);
302         }
303
304         search_description = gtk_button_new_with_label(_("Extended Symbols"));
305         gtk_box_pack_start(GTK_BOX(search_hbbox), search_description,
306                            TRUE, TRUE, 0);
307         gtk_widget_show(search_description);
308
309         gtk_signal_connect(GTK_OBJECT(search_description), "clicked",
310                            GTK_SIGNAL_FUNC(search_description_cb), NULL);
311         
312         gtk_box_pack_start(GTK_BOX(hbox_search), search_hbbox, FALSE, FALSE, 2);                                
313         gtk_widget_show(search_hbbox);
314         if (prefs_common.summary_quicksearch_type == QUICK_SEARCH_EXTENDED)
315                 gtk_widget_show(search_description);
316         else
317                 gtk_widget_hide(search_description);
318
319         gtk_signal_connect(GTK_OBJECT(GTK_COMBO(search_string_entry)->entry), 
320                            "key_press_event",
321                            GTK_SIGNAL_FUNC(searchbar_pressed),
322                            quicksearch);
323
324         /*
325         gtk_signal_connect(GTK_OBJECT(GTK_COMBO(search_string_entry)->entry), 
326                            "focus_in_event",
327                            GTK_SIGNAL_FUNC(searchbar_focus_evt),
328                            quicksearch);
329
330         gtk_signal_connect(GTK_OBJECT(GTK_COMBO(search_string_entry)->entry), 
331                            "focus_out_event",
332                            GTK_SIGNAL_FUNC(searchbar_focus_evt),
333                            quicksearch);
334         */
335
336         quicksearch->hbox_search = hbox_search;
337         quicksearch->search_type = search_type;
338         quicksearch->search_type_opt = search_type_opt;
339         quicksearch->search_string_entry = search_string_entry;
340         quicksearch->search_description = search_description;
341         quicksearch->matcher_list = NULL;
342         quicksearch->active = FALSE;
343         quicksearch->running = FALSE;
344
345         return quicksearch;
346 }
347
348 GtkWidget *quicksearch_get_widget(QuickSearch *quicksearch)
349 {
350         return quicksearch->hbox_search;
351 }
352
353 void quicksearch_show(QuickSearch *quicksearch)
354 {
355         prepare_matcher(quicksearch);
356         gtk_widget_show(quicksearch->hbox_search);
357 }
358
359 void quicksearch_hide(QuickSearch *quicksearch)
360 {
361         quicksearch->active = FALSE;
362         gtk_widget_hide(quicksearch->hbox_search);
363 }
364
365 void quicksearch_set(QuickSearch *quicksearch, QuickSearchType type,
366                      const gchar *matchstring)
367 {
368         gtk_option_menu_set_history(GTK_OPTION_MENU(quicksearch->search_type_opt),
369                                     type);
370         gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(quicksearch->search_string_entry)->entry),
371                            matchstring);
372         prefs_common.summary_quicksearch_type = type;
373
374         prepare_matcher(quicksearch);
375
376         if (quicksearch->callback != NULL)
377                 quicksearch->callback(quicksearch, quicksearch->callback_data); 
378 }
379
380 gboolean quicksearch_is_active(QuickSearch *quicksearch)
381 {
382         return quicksearch->active;
383 }
384
385 void quicksearch_set_execute_callback(QuickSearch *quicksearch,
386                                       QuickSearchExecuteCallback callback,
387                                       gpointer data)
388 {
389         quicksearch->callback = callback;
390         quicksearch->callback_data = data;
391 }
392
393 gboolean quicksearch_match(QuickSearch *quicksearch, MsgInfo *msginfo)
394 {
395         gchar *searched_header = NULL;
396
397         if (!quicksearch->active)
398                 return TRUE;
399
400         switch (prefs_common.summary_quicksearch_type) {
401         case QUICK_SEARCH_SUBJECT:
402                 searched_header = msginfo->subject;
403                 break;
404         case QUICK_SEARCH_FROM:
405                 searched_header = msginfo->from;
406                 break;
407         case QUICK_SEARCH_TO:
408                 searched_header = msginfo->to;
409                 break;
410         case QUICK_SEARCH_EXTENDED:
411                 break;
412         default:
413                 debug_print("unknown search type (%d)\n", prefs_common.summary_quicksearch_type);
414                 break;
415         }
416
417         if (prefs_common.summary_quicksearch_type != QUICK_SEARCH_EXTENDED && quicksearch->search_string &&
418             searched_header && strcasestr(searched_header, quicksearch->search_string) != NULL)
419                 return TRUE;
420         else if ((quicksearch->matcher_list != NULL) && matcherlist_match(quicksearch->matcher_list, msginfo))
421                 return TRUE;
422
423         return FALSE;
424 }
425
426 /* allow Mutt-like patterns in quick search */
427 gchar *expand_search_string(const gchar *search_string)
428 {
429         int i = 0;
430         gchar term_char, save_char;
431         gchar *cmd_start, *cmd_end;
432         GString *matcherstr;
433         gchar *returnstr = NULL;
434         gchar *copy_str;
435         gboolean casesens, dontmatch;
436         /* list of allowed pattern abbreviations */
437         struct {
438                 gchar           *abbreviated;   /* abbreviation */
439                 gchar           *command;       /* actual matcher command */ 
440                 gint            numparams;      /* number of params for cmd */
441                 gboolean        qualifier;      /* do we append regexpcase */
442                 gboolean        quotes;         /* do we need quotes */
443         }
444         cmds[] = {
445                 { "a",  "all",                          0,      FALSE,  FALSE },
446                 { "ag", "age_greater",                  1,      FALSE,  FALSE },
447                 { "al", "age_lower",                    1,      FALSE,  FALSE },
448                 { "b",  "body_part",                    1,      TRUE,   TRUE  },
449                 { "B",  "message",                      1,      TRUE,   TRUE  },
450                 { "c",  "cc",                           1,      TRUE,   TRUE  },
451                 { "C",  "to_or_cc",                     1,      TRUE,   TRUE  },
452                 { "D",  "deleted",                      0,      FALSE,  FALSE },
453                 { "e",  "header \"Sender\"",            1,      TRUE,   TRUE  },
454                 { "E",  "execute",                      1,      FALSE,  TRUE  },
455                 { "f",  "from",                         1,      TRUE,   TRUE  },
456                 { "F",  "forwarded",                    0,      FALSE,  FALSE },
457                 { "h",  "headers_part",                 1,      TRUE,   TRUE  },
458                 { "i",  "header \"Message-Id\"",        1,      TRUE,   TRUE  },
459                 { "I",  "inreplyto",                    1,      TRUE,   TRUE  },
460                 { "L",  "locked",                       0,      FALSE,  FALSE },
461                 { "n",  "newsgroups",                   1,      TRUE,   TRUE  },
462                 { "N",  "new",                          0,      FALSE,  FALSE },
463                 { "O",  "~new",                         0,      FALSE,  FALSE },
464                 { "r",  "replied",                      0,      FALSE,  FALSE },
465                 { "R",  "~unread",                      0,      FALSE,  FALSE },
466                 { "s",  "subject",                      1,      TRUE,   TRUE  },
467                 { "se", "score_equal",                  1,      FALSE,  FALSE },
468                 { "sg", "score_greater",                1,      FALSE,  FALSE },
469                 { "sl", "score_lower",                  1,      FALSE,  FALSE },
470                 { "Se", "size_equal",                   1,      FALSE,  FALSE },
471                 { "Sg", "size_greater",                 1,      FALSE,  FALSE },
472                 { "Ss", "size_smaller",                 1,      FALSE,  FALSE },
473                 { "t",  "to",                           1,      TRUE,   TRUE  },
474                 { "T",  "marked",                       0,      FALSE,  FALSE },
475                 { "U",  "unread",                       0,      FALSE,  FALSE },
476                 { "x",  "header \"References\"",        1,      TRUE,   TRUE  },
477                 { "X",  "test",                         1,      FALSE,  FALSE }, 
478                 { "y",  "header \"X-Label\"",           1,      TRUE,   TRUE  },
479                 { "&",  "&",                            0,      FALSE,  FALSE },
480                 { "|",  "|",                            0,      FALSE,  FALSE },
481                 { NULL, NULL,                           0,      FALSE,  FALSE }
482         };
483
484         if (search_string == NULL)
485                 return NULL;
486
487         copy_str = g_strdup(search_string);
488
489         matcherstr = g_string_sized_new(16);
490         cmd_start = copy_str;
491         while (cmd_start && *cmd_start) {
492                 /* skip all white spaces */
493                 while (*cmd_start && isspace((guchar)*cmd_start))
494                         cmd_start++;
495                 cmd_end = cmd_start;
496
497                 /* extract a command */
498                 while (*cmd_end && !isspace((guchar)*cmd_end))
499                         cmd_end++;
500
501                 /* save character */
502                 save_char = *cmd_end;
503                 *cmd_end = '\0';
504
505                 dontmatch = FALSE;
506                 casesens = FALSE;
507
508                 /* ~ and ! mean logical NOT */
509                 if (*cmd_start == '~' || *cmd_start == '!')
510                 {
511                         dontmatch = TRUE;
512                         cmd_start++;
513                 }
514                 /* % means case sensitive match */
515                 if (*cmd_start == '%')
516                 {
517                         casesens = TRUE;
518                         cmd_start++;
519                 }
520
521                 /* find matching abbreviation */
522                 for (i = 0; cmds[i].command; i++) {
523                         if (!strcmp(cmd_start, cmds[i].abbreviated)) {
524                                 /* restore character */
525                                 *cmd_end = save_char;
526
527                                 /* copy command */
528                                 if (matcherstr->len > 0) {
529                                         g_string_append(matcherstr, " ");
530                                 }
531                                 if (dontmatch)
532                                         g_string_append(matcherstr, "~");
533                                 g_string_append(matcherstr, cmds[i].command);
534                                 g_string_append(matcherstr, " ");
535
536                                 /* stop if no params required */
537                                 if (cmds[i].numparams == 0)
538                                         break;
539
540                                 /* extract a parameter, allow quotes */
541                                 while (*cmd_end && isspace((guchar)*cmd_end))
542                                         cmd_end++;
543
544                                 cmd_start = cmd_end;
545                                 if (*cmd_start == '"') {
546                                         term_char = '"';
547                                         cmd_end++;
548                                 }
549                                 else
550                                         term_char = ' ';
551
552                                 /* extract actual parameter */
553                                 while ((*cmd_end) && (*cmd_end != term_char))
554                                         cmd_end++;
555
556                                 if (*cmd_end == '"')
557                                         cmd_end++;
558
559                                 save_char = *cmd_end;
560                                 *cmd_end = '\0';
561
562                                 if (cmds[i].qualifier) {
563                                         if (casesens)
564                                                 g_string_append(matcherstr, "regexp ");
565                                         else
566                                                 g_string_append(matcherstr, "regexpcase ");
567                                 }
568
569                                 /* do we need to add quotes ? */
570                                 if (cmds[i].quotes && term_char != '"')
571                                         g_string_append(matcherstr, "\"");
572
573                                 /* copy actual parameter */
574                                 g_string_append(matcherstr, cmd_start);
575
576                                 /* do we need to add quotes ? */
577                                 if (cmds[i].quotes && term_char != '"')
578                                         g_string_append(matcherstr, "\"");
579
580                                 /* restore original character */
581                                 *cmd_end = save_char;
582
583                                 break;
584                         }
585                 }
586
587                 if (*cmd_end)
588                         cmd_end++;
589                 cmd_start = cmd_end;
590         }
591
592         g_free(copy_str);
593
594         /* return search string if no match is found to allow 
595            all available filtering expressions in quicksearch */
596         if (matcherstr->len > 0) returnstr = matcherstr->str;
597         else returnstr = g_strdup(search_string);
598
599         g_string_free(matcherstr, FALSE);
600         return returnstr;
601 }
602
603 void quicksearch_set_running(QuickSearch *quicksearch, gboolean run)
604 {
605         quicksearch->running = run;
606 }
607
608 gboolean quicksearch_is_running(QuickSearch *quicksearch) 
609 {
610         return quicksearch->running;
611 }
612