aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-12-28 02:20:43 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-12-28 02:20:43 +0000
commit1ac2dec65364b3165e068b38d7941e53595e365d (patch)
tree5b23795840d57f34a5fd70f79deca4286d2a122c /src
parent911f245f5585fed897411ac68241c71ddf9d8f88 (diff)
implemented vertical view. Separated quick search into another module.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1949 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/mainwindow.c226
-rw-r--r--src/mainwindow.h3
-rw-r--r--src/quick_search.c292
-rw-r--r--src/quick_search.h60
-rw-r--r--src/summaryview.c292
-rw-r--r--src/summaryview.h9
7 files changed, 541 insertions, 342 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 15ab682c..59b38aca 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,6 +13,7 @@ sylpheed_SOURCES = \
textview.c textview.h \
imageview.c imageview.h \
mimeview.c mimeview.h \
+ quick_search.c quick_search.h \
query_search.c query_search.h \
message_search.c message_search.h \
colorlabel.c colorlabel.h \
diff --git a/src/mainwindow.c b/src/mainwindow.c
index af3ed9bb..893edef4 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -54,6 +54,7 @@
#include "folderview.h"
#include "foldersel.h"
#include "summaryview.h"
+#include "quick_search.h"
#include "query_search.h"
#include "messageview.h"
#include "mimeview.h"
@@ -124,6 +125,7 @@ static void main_window_set_toolbar_button_visibility
(MainWindow *mainwin);
static void main_window_set_widgets (MainWindow *mainwin,
+ LayoutType layout,
SeparateType type);
static GtkWidget *main_window_toolbar_create (MainWindow *mainwin);
static GtkWidget *main_window_toolbar_create_from_list
@@ -295,6 +297,9 @@ static void toggle_statusbar_cb (MainWindow *mainwin,
static void toolbar_customize_cb (MainWindow *mainwin,
guint action,
GtkWidget *widget);
+static void change_layout_cb (MainWindow *mainwin,
+ guint action,
+ GtkWidget *widget);
static void separate_widget_cb (MainWindow *mainwin,
guint action,
GtkWidget *widget);
@@ -586,6 +591,9 @@ static GtkItemFactoryEntry mainwin_entries[] =
NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
{N_("/_View/_Customize toolbar..."), NULL, toolbar_customize_cb, 0, NULL},
{N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
+ {N_("/_View/Layou_t"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_View/Layou_t/_Normal"), NULL, change_layout_cb, LAYOUT_NORMAL, "<RadioItem>"},
+ {N_("/_View/Layou_t/_Vertical"), NULL, change_layout_cb, LAYOUT_VERTICAL, "/View/Layout/Normal"},
{N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
{N_("/_View/Separate _message view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
{N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
@@ -1017,6 +1025,8 @@ MainWindow *main_window_create(SeparateType type)
mainwin->messageview = messageview = messageview_create();
mainwin->logwin = log_window_create();
+ quick_search_create(summaryview);
+
folderview->mainwin = mainwin;
folderview->summaryview = summaryview;
@@ -1084,7 +1094,7 @@ MainWindow *main_window_create(SeparateType type)
messageview->visible = prefs_common.msgview_visible;
- main_window_set_widgets(mainwin, type);
+ main_window_set_widgets(mainwin, prefs_common.layout_type, type);
if (prefs_common.mainwin_maximized)
gtk_window_maximize(GTK_WINDOW(window));
@@ -1104,7 +1114,7 @@ MainWindow *main_window_create(SeparateType type)
main_window_toolbar_toggle_menu_set_active
(mainwin, prefs_common.toolbar_style);
- gtk_widget_hide(summaryview->search_hbox);
+ gtk_widget_hide(GTK_WIDGET_PTR(summaryview->qsearch));
menuitem = gtk_item_factory_get_item
(ifactory, "/View/Show or hide/Search bar");
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
@@ -1398,17 +1408,20 @@ GtkWidget *main_window_get_message_window(MainWindow *mainwin)
}
}
-void main_window_separation_change(MainWindow *mainwin, SeparateType type)
+void main_window_change_layout(MainWindow *mainwin, LayoutType layout,
+ SeparateType type)
{
GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
+ GtkWidget *qsearch_wid = GTK_WIDGET_PTR(mainwin->summaryview->qsearch);
+ GtkWidget *vbox_summary = qsearch_wid->parent;
GtkWidget *focus_widget;
- debug_print(_("Changing window separation type from %d to %d\n"),
- mainwin->type, type);
+ debug_print("Changing window layout type (layout: %d -> %d, separation: %d -> %d)\n", prefs_common.layout_type, layout, mainwin->type, type);
- if (mainwin->type == type) return;
+ if (prefs_common.layout_type == layout && mainwin->type == type)
+ return;
/* keep previous focus */
focus_widget = gtk_window_get_focus(GTK_WINDOW(mainwin->window));
@@ -1417,34 +1430,50 @@ void main_window_separation_change(MainWindow *mainwin, SeparateType type)
gtk_widget_ref(folder_wid);
gtk_widget_ref(summary_wid);
gtk_widget_ref(message_wid);
+ gtk_widget_ref(qsearch_wid);
gtkut_container_remove
(GTK_CONTAINER(folder_wid->parent), folder_wid);
gtkut_container_remove
(GTK_CONTAINER(summary_wid->parent), summary_wid);
gtkut_container_remove
(GTK_CONTAINER(message_wid->parent), message_wid);
+ gtkut_container_remove
+ (GTK_CONTAINER(qsearch_wid->parent), qsearch_wid);
/* clean containers */
switch (mainwin->type) {
case SEPARATE_NONE:
+ if (!mainwin->win.sep_none.vpaned->parent)
+ gtk_widget_destroy(mainwin->win.sep_none.vpaned);
gtk_widget_destroy(mainwin->win.sep_none.hpaned);
+ mainwin->win.sep_none.hpaned = NULL;
+ mainwin->win.sep_none.vpaned = NULL;
break;
case SEPARATE_FOLDER:
- gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
+ if (!mainwin->win.sep_folder.vpaned->parent)
+ gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
+ gtk_widget_destroy(vbox_summary);
+ mainwin->win.sep_folder.folderwin = NULL;
+ mainwin->win.sep_folder.vpaned = NULL;
break;
case SEPARATE_MESSAGE:
- gtk_widget_destroy(mainwin->win.sep_message.hpaned);
gtk_widget_destroy(mainwin->win.sep_message.messagewin);
+ gtk_widget_destroy(mainwin->win.sep_message.hpaned);
+ mainwin->win.sep_message.messagewin = NULL;
+ mainwin->win.sep_message.hpaned = NULL;
break;
case SEPARATE_BOTH:
- gtk_widget_destroy(mainwin->win.sep_both.messagewin);
+ gtk_widget_destroy(vbox_summary);
gtk_widget_destroy(mainwin->win.sep_both.folderwin);
+ gtk_widget_destroy(mainwin->win.sep_both.messagewin);
+ mainwin->win.sep_both.folderwin = NULL;
+ mainwin->win.sep_both.messagewin = NULL;
break;
}
gtk_widget_hide(mainwin->window);
- main_window_set_widgets(mainwin, type);
+ main_window_set_widgets(mainwin, layout, type);
gtk_widget_show(mainwin->window);
if (focus_widget)
gtk_widget_grab_focus(focus_widget);
@@ -1452,6 +1481,7 @@ void main_window_separation_change(MainWindow *mainwin, SeparateType type)
gtk_widget_unref(folder_wid);
gtk_widget_unref(summary_wid);
gtk_widget_unref(message_wid);
+ gtk_widget_unref(qsearch_wid);
}
void main_window_toggle_message_view(MainWindow *mainwin)
@@ -1461,15 +1491,16 @@ void main_window_toggle_message_view(MainWindow *mainwin)
GtkWidget *vpaned = NULL;
GtkWidget *container = NULL;
GtkWidget *msgwin = NULL;
+ gboolean use_vlayout = (prefs_common.layout_type == LAYOUT_VERTICAL);
switch (mainwin->type) {
case SEPARATE_NONE:
vpaned = cwin->sep_none.vpaned;
- container = cwin->sep_none.hpaned;
+ container = GTK_WIDGET_PTR(summaryview->qsearch)->parent;
break;
case SEPARATE_FOLDER:
vpaned = cwin->sep_folder.vpaned;
- container = mainwin->vbox_body;
+ container = GTK_WIDGET_PTR(summaryview->qsearch)->parent;
break;
case SEPARATE_MESSAGE:
msgwin = mainwin->win.sep_message.messagewin;
@@ -1496,22 +1527,26 @@ void main_window_toggle_message_view(MainWindow *mainwin)
gtk_widget_ref(vpaned);
gtkut_container_remove(GTK_CONTAINER(container), vpaned);
gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
- gtk_widget_hide(summaryview->hseparator);
+ if (!use_vlayout)
+ gtk_widget_hide(summaryview->hseparator);
} else {
/* show message view */
mainwin->messageview->visible = TRUE;
gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
gtk_container_add(GTK_CONTAINER(container), vpaned);
gtk_widget_unref(vpaned);
- gtk_widget_show(summaryview->hseparator);
+ if (!use_vlayout)
+ gtk_widget_show(summaryview->hseparator);
}
if (messageview_is_visible(mainwin->messageview))
gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
- GTK_ARROW_DOWN, GTK_SHADOW_OUT);
+ use_vlayout ? GTK_ARROW_RIGHT : GTK_ARROW_DOWN,
+ GTK_SHADOW_OUT);
else
gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
- GTK_ARROW_UP, GTK_SHADOW_OUT);
+ use_vlayout ? GTK_ARROW_LEFT : GTK_ARROW_UP,
+ GTK_SHADOW_OUT);
if (mainwin->messageview->visible == FALSE)
messageview_clear(mainwin->messageview);
@@ -1526,19 +1561,24 @@ void main_window_toggle_message_view(MainWindow *mainwin)
void main_window_get_size(MainWindow *mainwin)
{
GtkAllocation *allocation;
+ gboolean vlayout = (prefs_common.layout_type == LAYOUT_VERTICAL);
allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
if (allocation->width > 1 && allocation->height > 1) {
- if (!prefs_common.mainwin_maximized) {
- prefs_common.summaryview_width = allocation->width;
- prefs_common.mainview_width = allocation->width;
+ if (vlayout) {
+ if (!(mainwin->type & SEPARATE_MESSAGE))
+ prefs_common.summaryview_vwidth = allocation->width;
+ prefs_common.summaryview_vheight = allocation->height;
+ } else {
+ if (!prefs_common.mainwin_maximized) {
+ prefs_common.summaryview_width = allocation->width;
+ prefs_common.mainview_width = allocation->width;
+ }
+ if ((mainwin->type == SEPARATE_NONE ||
+ mainwin->type == SEPARATE_FOLDER) &&
+ messageview_is_visible(mainwin->messageview))
+ prefs_common.summaryview_height = allocation->height;
}
-
- if ((mainwin->type == SEPARATE_NONE ||
- mainwin->type == SEPARATE_FOLDER) &&
- messageview_is_visible(mainwin->messageview))
- prefs_common.summaryview_height = allocation->height;
-
}
if (prefs_common.mainwin_maximized) {
@@ -1563,8 +1603,13 @@ void main_window_get_size(MainWindow *mainwin)
allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
if (allocation->width > 1 && allocation->height > 1) {
- prefs_common.msgview_width = allocation->width;
- prefs_common.msgview_height = allocation->height;
+ if (vlayout) {
+ prefs_common.msgview_vwidth = allocation->width;
+ prefs_common.msgview_vheight = allocation->height;
+ } else {
+ prefs_common.msgview_width = allocation->width;
+ prefs_common.msgview_height = allocation->height;
+ }
}
#if 0
@@ -2202,27 +2247,43 @@ void main_window_popup(MainWindow *mainwin)
}
}
-static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
+static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout,
+ SeparateType type)
{
GtkWidget *folderwin = NULL;
GtkWidget *messagewin = NULL;
GtkWidget *hpaned;
GtkWidget *vpaned;
GtkWidget *vbox_body = mainwin->vbox_body;
+ GtkWidget *vbox_summary;
GtkItemFactory *ifactory = mainwin->menu_factory;
GtkWidget *menuitem;
+ gboolean use_vlayout = (layout == LAYOUT_VERTICAL);
- debug_print("Setting widgets... ");
+ debug_print("Setting main window widgets...\n");
gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
prefs_common.folderview_width,
prefs_common.folderview_height);
- gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
- prefs_common.summaryview_width,
- prefs_common.summaryview_height);
- gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
- prefs_common.msgview_width,
- prefs_common.msgview_height);
+ if (use_vlayout) {
+ gtk_widget_set_size_request
+ (GTK_WIDGET_PTR(mainwin->summaryview),
+ prefs_common.summaryview_vwidth,
+ prefs_common.summaryview_vheight);
+ gtk_widget_set_size_request
+ (GTK_WIDGET_PTR(mainwin->messageview),
+ prefs_common.msgview_vwidth,
+ prefs_common.msgview_vheight);
+ } else {
+ gtk_widget_set_size_request
+ (GTK_WIDGET_PTR(mainwin->summaryview),
+ prefs_common.summaryview_width,
+ prefs_common.summaryview_height);
+ gtk_widget_set_size_request
+ (GTK_WIDGET_PTR(mainwin->messageview),
+ prefs_common.msgview_width,
+ prefs_common.msgview_height);
+ }
/* create separated window(s) if needed */
if (type & SEPARATE_FOLDER) {
@@ -2264,24 +2325,39 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
gtk_widget_show(messagewin);
}
+ vbox_summary = gtk_vbox_new(FALSE, 1);
+ gtk_box_pack_start(GTK_BOX(vbox_summary),
+ GTK_WIDGET_PTR(mainwin->summaryview->qsearch),
+ FALSE, FALSE, 0);
+ gtk_widget_show(vbox_summary);
+
switch (type) {
case SEPARATE_NONE:
hpaned = gtk_hpaned_new();
gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
gtk_paned_add1(GTK_PANED(hpaned),
GTK_WIDGET_PTR(mainwin->folderview));
+ gtk_paned_add2(GTK_PANED(hpaned), vbox_summary);
gtk_widget_show(hpaned);
gtk_widget_queue_resize(hpaned);
- vpaned = gtk_vpaned_new();
+ if (use_vlayout) {
+ vpaned = gtk_hpaned_new();
+ gtk_widget_hide(mainwin->summaryview->hseparator);
+ } else
+ vpaned = gtk_vpaned_new();
if (messageview_is_visible(mainwin->messageview)) {
- gtk_paned_add2(GTK_PANED(hpaned), vpaned);
gtk_paned_add1(GTK_PANED(vpaned),
GTK_WIDGET_PTR(mainwin->summaryview));
- gtk_widget_show(mainwin->summaryview->hseparator);
+ gtk_box_pack_start(GTK_BOX(vbox_summary), vpaned,
+ TRUE, TRUE, 0);
+ if (!use_vlayout)
+ gtk_widget_show
+ (mainwin->summaryview->hseparator);
} else {
- gtk_paned_add2(GTK_PANED(hpaned),
- GTK_WIDGET_PTR(mainwin->summaryview));
+ gtk_box_pack_start(GTK_BOX(vbox_summary),
+ GTK_WIDGET_PTR(mainwin->summaryview),
+ TRUE, TRUE, 0);
gtk_widget_ref(vpaned);
gtk_widget_hide(mainwin->summaryview->hseparator);
}
@@ -2292,17 +2368,27 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
mainwin->win.sep_none.hpaned = hpaned;
mainwin->win.sep_none.vpaned = vpaned;
+
break;
case SEPARATE_FOLDER:
- vpaned = gtk_vpaned_new();
+ gtk_box_pack_start(GTK_BOX(vbox_body), vbox_summary,
+ TRUE, TRUE, 0);
+
+ if (use_vlayout) {
+ vpaned = gtk_hpaned_new();
+ gtk_widget_hide(mainwin->summaryview->hseparator);
+ } else
+ vpaned = gtk_vpaned_new();
if (messageview_is_visible(mainwin->messageview)) {
- gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
- TRUE, TRUE, 0);
gtk_paned_add1(GTK_PANED(vpaned),
GTK_WIDGET_PTR(mainwin->summaryview));
- gtk_widget_show(mainwin->summaryview->hseparator);
+ gtk_box_pack_start(GTK_BOX(vbox_summary), vpaned,
+ TRUE, TRUE, 0);
+ if (!use_vlayout)
+ gtk_widget_show
+ (mainwin->summaryview->hseparator);
} else {
- gtk_box_pack_start(GTK_BOX(vbox_body),
+ gtk_box_pack_start(GTK_BOX(vbox_summary),
GTK_WIDGET_PTR(mainwin->summaryview),
TRUE, TRUE, 0);
gtk_widget_ref(vpaned);
@@ -2322,8 +2408,10 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
gtk_paned_add1(GTK_PANED(hpaned),
GTK_WIDGET_PTR(mainwin->folderview));
- gtk_paned_add2(GTK_PANED(hpaned),
- GTK_WIDGET_PTR(mainwin->summaryview));
+ gtk_paned_add2(GTK_PANED(hpaned), vbox_summary);
+ gtk_box_pack_start(GTK_BOX(vbox_summary),
+ GTK_WIDGET_PTR(mainwin->summaryview),
+ TRUE, TRUE, 0);
gtk_widget_hide(mainwin->summaryview->hseparator);
gtk_widget_show(hpaned);
gtk_widget_queue_resize(hpaned);
@@ -2333,7 +2421,9 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
break;
case SEPARATE_BOTH:
- gtk_box_pack_start(GTK_BOX(vbox_body),
+ gtk_box_pack_start(GTK_BOX(vbox_body), vbox_summary,
+ TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox_summary),
GTK_WIDGET_PTR(mainwin->summaryview),
TRUE, TRUE, 0);
gtk_widget_hide(mainwin->summaryview->hseparator);
@@ -2346,10 +2436,12 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
if (messageview_is_visible(mainwin->messageview))
gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
- GTK_ARROW_DOWN, GTK_SHADOW_OUT);
+ use_vlayout ? GTK_ARROW_RIGHT : GTK_ARROW_DOWN,
+ GTK_SHADOW_OUT);
else
gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
- GTK_ARROW_UP, GTK_SHADOW_OUT);
+ use_vlayout ? GTK_ARROW_LEFT : GTK_ARROW_UP,
+ GTK_SHADOW_OUT);
gtk_widget_set_uposition(mainwin->window,
prefs_common.mainwin_x,
@@ -2360,6 +2452,7 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
gtk_widget_queue_resize(mainwin->window);
mainwin->type = type;
+ prefs_common.layout_type = layout;
/* toggle menu state */
menuitem = gtk_item_factory_get_item
@@ -2374,6 +2467,18 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
(GTK_CHECK_MENU_ITEM(menuitem),
messageview_is_visible(mainwin->messageview));
+ if (layout == LAYOUT_NORMAL) {
+ menuitem = gtk_item_factory_get_item
+ (ifactory, "/View/Layout/Normal");
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
+ TRUE);
+ } else if (layout == LAYOUT_VERTICAL) {
+ menuitem = gtk_item_factory_get_item
+ (ifactory, "/View/Layout/Vertical");
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
+ TRUE);
+ }
+
menuitem = gtk_item_factory_get_item
(ifactory, "/View/Separate folder tree");
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
@@ -2952,7 +3057,7 @@ static gboolean main_window_key_pressed(GtkWidget *widget, GdkEventKey *event,
if (!mainwin)
return FALSE;
- if (!GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->search_entry))
+ if (!GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->qsearch->entry))
return FALSE;
/* g_print("keyval: %d, state: %d\n", event->keyval, event->state); */
@@ -3263,10 +3368,10 @@ static void toggle_searchbar_cb(MainWindow *mainwin, guint action,
GtkWidget *widget)
{
if (GTK_CHECK_MENU_ITEM(widget)->active) {
- gtk_widget_show(mainwin->summaryview->search_hbox);
+ gtk_widget_show(mainwin->summaryview->qsearch->hbox);
prefs_common.show_searchbar = TRUE;
} else {
- gtk_widget_hide(mainwin->summaryview->search_hbox);
+ gtk_widget_hide(mainwin->summaryview->qsearch->hbox);
summary_qsearch_reset(mainwin->summaryview);
prefs_common.show_searchbar = FALSE;
}
@@ -3290,6 +3395,15 @@ static void toolbar_customize_cb(MainWindow *mainwin, guint action,
toolbar_customize(widget, mainwin);
}
+static void change_layout_cb(MainWindow *mainwin, guint action,
+ GtkWidget *widget)
+{
+ LayoutType type = action;
+
+ if (GTK_CHECK_MENU_ITEM(widget)->active)
+ main_window_change_layout(mainwin, type, mainwin->type);
+}
+
static void separate_widget_cb(MainWindow *mainwin, guint action,
GtkWidget *widget)
{
@@ -3300,7 +3414,7 @@ static void separate_widget_cb(MainWindow *mainwin, guint action,
else
type = mainwin->type & ~action;
- main_window_separation_change(mainwin, type);
+ main_window_change_layout(mainwin, prefs_common.layout_type, type);
prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
@@ -3653,9 +3767,9 @@ static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->treeview))
summary_select_all(mainwin->summaryview);
- else if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->search_entry))
+ else if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->qsearch->entry))
gtk_editable_select_region
- (GTK_EDITABLE(mainwin->summaryview->search_entry),
+ (GTK_EDITABLE(mainwin->summaryview->qsearch->entry),
0, -1);
else if (messageview_is_visible(msgview) &&
(GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 9aaa08a3..e7564453 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -151,7 +151,8 @@ MainWindow *main_window_get (void);
GtkWidget *main_window_get_folder_window (MainWindow *mainwin);
GtkWidget *main_window_get_message_window (MainWindow *mainwin);
-void main_window_separation_change (MainWindow *mainwin,
+void main_window_change_layout (MainWindow *mainwin,
+ LayoutType layout,
SeparateType type);
void main_window_toggle_message_view (MainWindow *mainwin);
diff --git a/src/quick_search.c b/src/quick_search.c
new file mode 100644
index 00000000..b1997cc6
--- /dev/null
+++ b/src/quick_search.c
@@ -0,0 +1,292 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "defs.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtkwidget.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtkvbox.h>
+#include <gtk/gtkoptionmenu.h>
+#include <gtk/gtkimage.h>
+
+#include "summaryview.h"
+#include "quick_search.h"
+#include "filter.h"
+#include "procheader.h"
+#include "menu.h"
+
+static const struct {
+ QSearchCondType type;
+ FilterCondType ftype;
+} qsearch_cond_types[] = {
+ {QS_ALL, -1},
+ {QS_UNREAD, FLT_COND_UNREAD},
+ {QS_MARK, FLT_COND_MARK},
+ {QS_CLABEL, FLT_COND_COLOR_LABEL},
+ {QS_MIME, FLT_COND_MIME},
+ {QS_W1DAY, -1},
+ {QS_LAST5, -1}
+};
+
+static void menu_activated (GtkWidget *menuitem,
+ QuickSearch *qsearch);
+static void entry_changed (GtkWidget *entry,
+ QuickSearch *qsearch);
+static void entry_activated (GtkWidget *entry,
+ QuickSearch *qsearch);
+static gboolean entry_key_pressed (GtkWidget *treeview,
+ GdkEventKey *event,
+ QuickSearch *qsearch);
+static void clear_clicked (GtkWidget *button,
+ QuickSearch *qsearch);
+
+
+QuickSearch *quick_search_create(SummaryView *summaryview)
+{
+ QuickSearch *qsearch;
+ GtkWidget *hbox;
+ GtkWidget *optmenu;
+ GtkWidget *menu;
+ GtkWidget *menuitem;
+ GtkWidget *hbox2;
+ GtkWidget *label;
+ GtkWidget *entry;
+ GtkTooltips *tip;
+ GtkWidget *vbox;
+ GtkWidget *clear_btn;
+ GtkWidget *image;
+
+ qsearch = g_new0(QuickSearch, 1);
+
+ hbox = gtk_hbox_new(FALSE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(hbox), 2);
+
+ optmenu = gtk_option_menu_new();
+ gtk_box_pack_start(GTK_BOX(hbox), optmenu, FALSE, FALSE, 0);
+
+#define COND_MENUITEM_ADD(str, action) \
+{ \
+ MENUITEM_ADD(menu, menuitem, str, action); \
+ g_signal_connect(G_OBJECT(menuitem), "activate", \
+ G_CALLBACK(menu_activated), \
+ summaryview); \
+}
+
+ menu = gtk_menu_new();
+ COND_MENUITEM_ADD(_("All"), QS_ALL);
+ COND_MENUITEM_ADD(_("Unread"), QS_UNREAD);
+ COND_MENUITEM_ADD(_("Marked"), QS_MARK);
+ COND_MENUITEM_ADD(_("Have color label"), QS_CLABEL);
+ COND_MENUITEM_ADD(_("Have attachment"), QS_MIME);
+ MENUITEM_ADD(menu, menuitem, NULL, 0);
+ COND_MENUITEM_ADD(_("Within 1 day"), QS_W1DAY);
+ COND_MENUITEM_ADD(_("Last 5 days"), QS_LAST5);
+ gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
+
+#undef COND_MENUITEM_ADD
+
+ hbox2 = gtk_hbox_new(FALSE, 0);
+ gtk_widget_set_size_request(hbox2, 8, -1);
+ gtk_box_pack_start(GTK_BOX(hbox), hbox2, FALSE, FALSE, 0);
+
+ label = gtk_label_new(_("Search:"));
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+
+ hbox2 = gtk_hbox_new(FALSE, 0);
+ gtk_widget_set_size_request(hbox2, 4, -1);
+ gtk_box_pack_start(GTK_BOX(hbox), hbox2, FALSE, FALSE, 0);
+
+ entry = gtk_entry_new();
+ gtk_widget_set_size_request(entry, 200, -1);
+ gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0);
+ g_signal_connect(G_OBJECT(entry), "changed",
+ G_CALLBACK(entry_changed), qsearch);
+ g_signal_connect(G_OBJECT(entry), "activate",
+ G_CALLBACK(entry_activated), qsearch);
+ g_signal_connect(G_OBJECT(entry), "key_press_event",
+ G_CALLBACK(entry_key_pressed), qsearch);
+
+ tip = gtk_tooltips_new();
+ gtk_tooltips_set_tip(tip, entry, _("Search for Subject or From"), NULL);
+
+ hbox2 = gtk_hbox_new(FALSE, 0);
+ gtk_widget_set_size_request(hbox2, 2, -1);
+ gtk_box_pack_start(GTK_BOX(hbox), hbox2, FALSE, FALSE, 0);
+
+ vbox = gtk_vbox_new(FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
+
+ clear_btn = gtk_button_new();
+ gtk_button_set_relief(GTK_BUTTON(clear_btn), GTK_RELIEF_NONE);
+ gtk_widget_set_size_request(clear_btn, 20, 20);
+ image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
+ gtk_container_add(GTK_CONTAINER(clear_btn), image);
+ GTK_WIDGET_UNSET_FLAGS(clear_btn, GTK_CAN_FOCUS);
+ gtk_box_pack_start(GTK_BOX(vbox), clear_btn, TRUE, FALSE, 0);
+ g_signal_connect(G_OBJECT(clear_btn), "clicked",
+ G_CALLBACK(clear_clicked), qsearch);
+
+ qsearch->hbox = hbox;
+ qsearch->optmenu = optmenu;
+ qsearch->menu = menu;
+ qsearch->label = label;
+ qsearch->entry = entry;
+ qsearch->clear_btn = clear_btn;
+ qsearch->summaryview = summaryview;
+ summaryview->qsearch = qsearch;
+
+ gtk_widget_show_all(hbox);
+ gtk_widget_hide(clear_btn);
+
+ return qsearch;
+}
+
+void quick_search_clear_entry(QuickSearch *qsearch)
+{
+ gtk_entry_set_text(GTK_ENTRY(qsearch->entry), "");
+}
+
+GSList *quick_search_filter(QuickSearch *qsearch, QSearchCondType type,
+ const gchar *key)
+{
+ SummaryView *summaryview = qsearch->summaryview;
+ FilterCondType ftype;
+ FilterRule *status_rule = NULL;
+ FilterRule *rule = NULL;
+ FilterCond *cond;
+ FilterInfo fltinfo;
+ GSList *cond_list = NULL;
+ GSList *flt_mlist = NULL;
+ GSList *cur;
+
+ if (!summaryview->all_mlist)
+ return NULL;
+
+ switch (type) {
+ case QS_UNREAD:
+ case QS_MARK:
+ case QS_CLABEL:
+ case QS_MIME:
+ ftype = qsearch_cond_types[type].ftype;
+ cond = filter_cond_new(ftype, 0, 0, NULL, NULL);
+ cond_list = g_slist_append(cond_list, cond);
+ status_rule = filter_rule_new("Status filter rule", FLT_OR,
+ cond_list, NULL);
+ break;
+ case QS_W1DAY:
+ cond = filter_cond_new(FLT_COND_AGE_GREATER, 0, FLT_NOT_MATCH,
+ NULL, "1");
+ cond_list = g_slist_append(cond_list, cond);
+ status_rule = filter_rule_new("Status filter rule", FLT_OR,
+ cond_list, NULL);
+ break;
+ case QS_LAST5:
+ cond = filter_cond_new(FLT_COND_AGE_GREATER, 0, FLT_NOT_MATCH,
+ NULL, "5");
+ cond_list = g_slist_append(cond_list, cond);
+ status_rule = filter_rule_new("Status filter rule", FLT_OR,
+ cond_list, NULL);
+ break;
+ case QS_ALL:
+ default:
+ break;
+ }
+
+ cond_list = NULL;
+
+ if (key && *key != '\0') {
+ cond = filter_cond_new(FLT_COND_HEADER, FLT_CONTAIN, 0,
+ "Subject", key);
+ cond_list = g_slist_append(cond_list, cond);
+ cond = filter_cond_new(FLT_COND_HEADER, FLT_CONTAIN, 0,
+ "From", key);
+ cond_list = g_slist_append(cond_list, cond);
+ rule = filter_rule_new("Quick search rule", FLT_OR, cond_list,
+ NULL);
+ }
+
+ memset(&fltinfo, 0, sizeof(FilterInfo));
+
+ for (cur = summaryview->all_mlist; cur != NULL; cur = cur->next) {
+ MsgInfo *msginfo = (MsgInfo *)cur->data;
+ GSList *hlist;
+
+ if (status_rule) {
+ if (!filter_match_rule(status_rule, msginfo, NULL,
+ &fltinfo))
+ continue;
+ }
+
+ if (rule) {
+ hlist = procheader_get_header_list_from_msginfo
+ (msginfo);
+ if (filter_match_rule(rule, msginfo, hlist, &fltinfo))
+ flt_mlist = g_slist_prepend(flt_mlist, msginfo);
+
+ procheader_header_list_destroy(hlist);
+ } else
+ flt_mlist = g_slist_prepend(flt_mlist, msginfo);
+ }
+ flt_mlist = g_slist_reverse(flt_mlist);
+
+ filter_rule_free(rule);
+ filter_rule_free(status_rule);
+
+ return flt_mlist;
+}
+
+static void menu_activated(GtkWidget *menuitem, QuickSearch *qsearch)
+{
+ summary_qsearch(qsearch->summaryview);
+}
+
+static void entry_changed(GtkWidget *entry, QuickSearch *qsearch)
+{
+ const gchar *text;
+
+ text = gtk_entry_get_text(GTK_ENTRY(entry));
+ if (text && *text != '\0')
+ gtk_widget_show(qsearch->clear_btn);
+ else
+ gtk_widget_hide(qsearch->clear_btn);
+}
+
+static void entry_activated(GtkWidget *entry, QuickSearch *qsearch)
+{
+ gtk_editable_select_region(GTK_EDITABLE(entry), 0, -1);
+ summary_qsearch(qsearch->summaryview);
+}
+
+static gboolean entry_key_pressed(GtkWidget *treeview, GdkEventKey *event,
+ QuickSearch *qsearch)
+{
+ if (event && event->keyval == GDK_Escape) {
+ summary_qsearch_clear_entry(qsearch->summaryview);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static void clear_clicked(GtkWidget *button, QuickSearch *qsearch)
+{
+ summary_qsearch_clear_entry(qsearch->summaryview);
+}
diff --git a/src/quick_search.h b/src/quick_search.h
new file mode 100644
index 00000000..50f4de32
--- /dev/null
+++ b/src/quick_search.h
@@ -0,0 +1,60 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __QUICK_SEARCH_H__
+#define __QUICK_SEARCH_H__
+
+#include <glib.h>
+
+typedef struct _QuickSearch QuickSearch;
+
+#include "summaryview.h"
+
+typedef enum
+{
+ QS_ALL,
+ QS_UNREAD,
+ QS_MARK,
+ QS_CLABEL,
+ QS_MIME,
+ QS_W1DAY,
+ QS_LAST5
+} QSearchCondType;
+
+struct _QuickSearch
+{
+ GtkWidget *hbox;
+ GtkWidget *optmenu;
+ GtkWidget *menu;
+ GtkWidget *label;
+ GtkWidget *entry;
+ GtkWidget *clear_btn;
+
+ SummaryView *summaryview;
+};
+
+QuickSearch *quick_search_create(SummaryView *summaryview);
+
+void quick_search_clear_entry (QuickSearch *qsearch);
+
+GSList *quick_search_filter (QuickSearch *qsearch,
+ QSearchCondType type,
+ const gchar *key);
+
+#endif /* __QUICK_SEARCH_H__ */
diff --git a/src/summaryview.c b/src/summaryview.c
index abf71a57..5236d835 100644
--- a/src/summaryview.c
+++ b/src/summaryview.c
@@ -125,17 +125,6 @@
# define SUMMARY_COL_MIME_WIDTH 17
#endif
-typedef enum
-{
- QS_ALL,
- QS_UNREAD,
- QS_MARK,
- QS_CLABEL,
- QS_MIME,
- QS_W1DAY,
- QS_LAST5
-} QSearchCondType;
-
static GdkPixbuf *mark_pixbuf;
static GdkPixbuf *deleted_pixbuf;
@@ -259,26 +248,7 @@ static void summary_colorlabel_menu_create
static GtkWidget *summary_tree_view_create
(SummaryView *summaryview);
-static GSList *summary_qsearch_filter (SummaryView *summaryview,
- QSearchCondType type,
- const gchar *key);
-
/* callback functions */
-static void summary_filter_menu_activated
- (GtkWidget *menuitem,
- SummaryView *summaryview);
-static void summary_search_entry_changed(GtkWidget *entry,
- SummaryView *summaryview);
-static void summary_search_entry_activated
- (GtkWidget *entry,
- SummaryView *summaryview);
-static gboolean summary_search_entry_key_pressed
- (GtkWidget *treeview,
- GdkEventKey *event,
- SummaryView *summaryview);
-static void summary_search_clear_clicked(GtkWidget *button,
- SummaryView *summaryview);
-
static gboolean summary_toggle_pressed (GtkWidget *eventbox,
GdkEventButton *event,
SummaryView *summaryview);
@@ -424,19 +394,6 @@ static FolderSortKey col_to_sort_key[] = {
SORT_BY_TO
};
-static const struct {
- QSearchCondType type;
- FilterCondType ftype;
-} qsearch_cond_types[] = {
- {QS_ALL, -1},
- {QS_UNREAD, FLT_COND_UNREAD},
- {QS_MARK, FLT_COND_MARK},
- {QS_CLABEL, FLT_COND_COLOR_LABEL},
- {QS_MIME, FLT_COND_MIME},
- {QS_W1DAY, -1},
- {QS_LAST5, -1}
-};
-
enum
{
DRAG_TYPE_TEXT,
@@ -513,16 +470,6 @@ SummaryView *summary_create(void)
{
SummaryView *summaryview;
GtkWidget *vbox;
- GtkWidget *search_hbox;
- GtkWidget *filter_optmenu;
- GtkWidget *filter_menu;
- GtkWidget *menuitem;
- GtkWidget *search_label;
- GtkWidget *search_entry;
- GtkTooltips *search_tip;
- GtkWidget *search_vbox;
- GtkWidget *search_clear_btn;
- GtkWidget *image;
GtkWidget *scrolledwin;
GtkWidget *treeview;
GtkTreeStore *store;
@@ -544,81 +491,6 @@ SummaryView *summary_create(void)
vbox = gtk_vbox_new(FALSE, 1);
- search_hbox = gtk_hbox_new(FALSE, 0);
- gtk_container_set_border_width(GTK_CONTAINER(search_hbox), 2);
- gtk_box_pack_start(GTK_BOX(vbox), search_hbox, FALSE, FALSE, 0);
-
- filter_optmenu = gtk_option_menu_new();
- gtk_box_pack_start(GTK_BOX(search_hbox), filter_optmenu,
- FALSE, FALSE, 0);
-
-#define COND_MENUITEM_ADD(str, action) \
-{ \
- MENUITEM_ADD(filter_menu, menuitem, str, action); \
- g_signal_connect(G_OBJECT(menuitem), "activate", \
- G_CALLBACK(summary_filter_menu_activated), \
- summaryview); \
-}
-
- filter_menu = gtk_menu_new();
- COND_MENUITEM_ADD(_("All"), QS_ALL);
- COND_MENUITEM_ADD(_("Unread"), QS_UNREAD);
- COND_MENUITEM_ADD(_("Marked"), QS_MARK);
- COND_MENUITEM_ADD(_("Have color label"), QS_CLABEL);
- COND_MENUITEM_ADD(_("Have attachment"), QS_MIME);
- MENUITEM_ADD(filter_menu, menuitem, NULL, 0);
- COND_MENUITEM_ADD(_("Within 1 day"), QS_W1DAY);
- COND_MENUITEM_ADD(_("Last 5 days"), QS_LAST5);
- gtk_option_menu_set_menu(GTK_OPTION_MENU(filter_optmenu), filter_menu);
-
-#undef COND_MENUITEM_ADD
-
- hbox = gtk_hbox_new(FALSE, 0);
- gtk_widget_set_size_request(hbox, 8, -1);
- gtk_box_pack_start(GTK_BOX(search_hbox), hbox, FALSE, FALSE, 0);
-
- search_label = gtk_label_new(_("Search:"));
- gtk_box_pack_start(GTK_BOX(search_hbox), search_label, FALSE, FALSE, 0);
-
- hbox = gtk_hbox_new(FALSE, 0);
- gtk_widget_set_size_request(hbox, 4, -1);
- gtk_box_pack_start(GTK_BOX(search_hbox), hbox, FALSE, FALSE, 0);
-
- search_entry = gtk_entry_new();
- gtk_widget_set_size_request(search_entry, 200, -1);
- gtk_box_pack_start(GTK_BOX(search_hbox), search_entry, FALSE, FALSE, 0);
- g_signal_connect(G_OBJECT(search_entry), "changed",
- G_CALLBACK(summary_search_entry_changed), summaryview);
- g_signal_connect(G_OBJECT(search_entry), "activate",
- G_CALLBACK(summary_search_entry_activated),
- summaryview);
- g_signal_connect(G_OBJECT(search_entry), "key_press_event",
- G_CALLBACK(summary_search_entry_key_pressed),
- summaryview);
-
- search_tip = gtk_tooltips_new();
- gtk_tooltips_set_tip(search_tip, search_entry,
- _("Search for Subject or From"), NULL);
-
- hbox = gtk_hbox_new(FALSE, 0);
- gtk_widget_set_size_request(hbox, 2, -1);
- gtk_box_pack_start(GTK_BOX(search_hbox), hbox, FALSE, FALSE, 0);
-
- search_vbox = gtk_vbox_new(FALSE, 0);
- gtk_box_pack_start(GTK_BOX(search_hbox), search_vbox, FALSE, FALSE, 0);
-
- search_clear_btn = gtk_button_new();
- gtk_button_set_relief(GTK_BUTTON(search_clear_btn), GTK_RELIEF_NONE);
- gtk_widget_set_size_request(search_clear_btn, 20, 20);
- image = gtk_image_new_from_stock(GTK_STOCK_CLOSE,
- GTK_ICON_SIZE_MENU);
- gtk_container_add(GTK_CONTAINER(search_clear_btn), image);
- GTK_WIDGET_UNSET_FLAGS(search_clear_btn, GTK_CAN_FOCUS);
- gtk_box_pack_start(GTK_BOX(search_vbox), search_clear_btn,
- TRUE, FALSE, 0);
- g_signal_connect(G_OBJECT(search_clear_btn), "clicked",
- G_CALLBACK(summary_search_clear_clicked), summaryview);
-
scrolledwin = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
GTK_POLICY_AUTOMATIC,
@@ -673,12 +545,6 @@ SummaryView *summary_create(void)
summaryview);
summaryview->vbox = vbox;
- summaryview->search_hbox = search_hbox;
- summaryview->filter_optmenu = filter_optmenu;
- summaryview->filter_menu = filter_menu;
- summaryview->search_label = search_label;
- summaryview->search_entry = search_entry;
- summaryview->search_clear_btn = search_clear_btn;
summaryview->scrolledwin = scrolledwin;
summaryview->treeview = treeview;
summaryview->store = store;
@@ -710,7 +576,6 @@ SummaryView *summary_create(void)
summaryview->junk_separator = GTK_WIDGET(child->next->data);
gtk_widget_show_all(vbox);
- gtk_widget_hide(search_clear_btn);
return summaryview;
}
@@ -881,7 +746,7 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item,
do_qsearch = TRUE;
if (is_refresh) {
key = gtk_entry_get_text
- (GTK_ENTRY(summaryview->search_entry));
+ (GTK_ENTRY(summaryview->qsearch->entry));
if (key && *key != '\0')
do_qsearch = TRUE;
else
@@ -894,22 +759,23 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item,
QSearchCondType type = item->qsearch_cond_type;
index = menu_find_option_menu_index
- (GTK_OPTION_MENU(summaryview->filter_optmenu),
+ (GTK_OPTION_MENU(summaryview->qsearch->optmenu),
GINT_TO_POINTER(type), NULL);
if (index > 0) {
gtk_option_menu_set_history
- (GTK_OPTION_MENU(summaryview->filter_optmenu),
+ (GTK_OPTION_MENU(summaryview->qsearch->optmenu),
index);
} else {
gtk_option_menu_set_history
- (GTK_OPTION_MENU(summaryview->filter_optmenu),
+ (GTK_OPTION_MENU(summaryview->qsearch->optmenu),
0);
type = QS_ALL;
}
if (type > QS_ALL || key) {
summaryview->flt_mlist =
- summary_qsearch_filter(summaryview, type, key);
+ quick_search_filter(summaryview->qsearch,
+ type, key);
summaryview->on_filter = TRUE;
summary_set_tree_model_from_list
(summaryview, summaryview->flt_mlist);
@@ -1100,9 +966,9 @@ static void summary_clear_list_full(SummaryView *summaryview,
summaryview->flt_copied = 0;
summaryview->flt_new = summaryview->flt_unread = 0;
if (!is_refresh) {
- gtk_entry_set_text(GTK_ENTRY(summaryview->search_entry), "");
+ quick_search_clear_entry(summaryview->qsearch);
gtk_option_menu_set_history
- (GTK_OPTION_MENU(summaryview->filter_optmenu), 0);
+ (GTK_OPTION_MENU(summaryview->qsearch->optmenu), 0);
}
summaryview->on_filter = FALSE;
@@ -5333,9 +5199,9 @@ void summary_qsearch_reset(SummaryView *summaryview)
(GSignalMatchType)G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, summaryview);
- gtk_entry_set_text(GTK_ENTRY(summaryview->search_entry), "");
+ quick_search_clear_entry(summaryview->qsearch);
gtk_option_menu_set_history
- (GTK_OPTION_MENU(summaryview->filter_optmenu), 0);
+ (GTK_OPTION_MENU(summaryview->qsearch->optmenu), 0);
selected_msgnum = summary_get_msgnum(summaryview,
summaryview->selected);
@@ -5381,98 +5247,10 @@ void summary_qsearch_reset(SummaryView *summaryview)
void summary_qsearch_clear_entry(SummaryView *summaryview)
{
- gtk_entry_set_text(GTK_ENTRY(summaryview->search_entry), "");
+ quick_search_clear_entry(summaryview->qsearch);
summary_qsearch(summaryview);
}
-static GSList *summary_qsearch_filter(SummaryView *summaryview,
- QSearchCondType type, const gchar *key)
-{
- FilterCondType ftype;
- FilterRule *status_rule = NULL;
- FilterRule *rule = NULL;
- FilterCond *cond;
- FilterInfo fltinfo;
- GSList *cond_list = NULL;
- GSList *flt_mlist = NULL;
- GSList *cur;
-
- if (!summaryview->all_mlist)
- return NULL;
-
- switch (type) {
- case QS_UNREAD:
- case QS_MARK:
- case QS_CLABEL:
- case QS_MIME:
- ftype = qsearch_cond_types[type].ftype;
- cond = filter_cond_new(ftype, 0, 0, NULL, NULL);
- cond_list = g_slist_append(cond_list, cond);
- status_rule = filter_rule_new("Status filter rule", FLT_OR,
- cond_list, NULL);
- break;
- case QS_W1DAY:
- cond = filter_cond_new(FLT_COND_AGE_GREATER, 0, FLT_NOT_MATCH,
- NULL, "1");
- cond_list = g_slist_append(cond_list, cond);
- status_rule = filter_rule_new("Status filter rule", FLT_OR,
- cond_list, NULL);
- break;
- case QS_LAST5:
- cond = filter_cond_new(FLT_COND_AGE_GREATER, 0, FLT_NOT_MATCH,
- NULL, "5");
- cond_list = g_slist_append(cond_list, cond);
- status_rule = filter_rule_new("Status filter rule", FLT_OR,
- cond_list, NULL);
- break;
- case QS_ALL:
- default:
- break;
- }
-
- cond_list = NULL;
-
- if (key && *key != '\0') {
- cond = filter_cond_new(FLT_COND_HEADER, FLT_CONTAIN, 0,
- "Subject", key);
- cond_list = g_slist_append(cond_list, cond);
- cond = filter_cond_new(FLT_COND_HEADER, FLT_CONTAIN, 0,
- "From", key);
- cond_list = g_slist_append(cond_list, cond);
- rule = filter_rule_new("Quick search rule", FLT_OR, cond_list,
- NULL);
- }
-
- memset(&fltinfo, 0, sizeof(FilterInfo));
-
- for (cur = summaryview->all_mlist; cur != NULL; cur = cur->next) {
- MsgInfo *msginfo = (MsgInfo *)cur->data;
- GSList *hlist;
-
- if (status_rule) {
- if (!filter_match_rule(status_rule, msginfo, NULL,
- &fltinfo))
- continue;
- }
-
- if (rule) {
- hlist = procheader_get_header_list_from_msginfo
- (msginfo);
- if (filter_match_rule(rule, msginfo, hlist, &fltinfo))
- flt_mlist = g_slist_prepend(flt_mlist, msginfo);
-
- procheader_header_list_destroy(hlist);
- } else
- flt_mlist = g_slist_prepend(flt_mlist, msginfo);
- }
- flt_mlist = g_slist_reverse(flt_mlist);
-
- filter_rule_free(rule);
- filter_rule_free(status_rule);
-
- return flt_mlist;
-}
-
void summary_qsearch(SummaryView *summaryview)
{
QSearchCondType type;
@@ -5482,7 +5260,7 @@ void summary_qsearch(SummaryView *summaryview)
guint selected_msgnum = 0;
guint displayed_msgnum = 0;
- menuitem = gtk_menu_get_active(GTK_MENU(summaryview->filter_menu));
+ menuitem = gtk_menu_get_active(GTK_MENU(summaryview->qsearch->menu));
type = GPOINTER_TO_INT
(g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
summaryview->folder_item->qsearch_cond_type = type;
@@ -5490,7 +5268,7 @@ void summary_qsearch(SummaryView *summaryview)
if (!summaryview->all_mlist)
return;
- key = gtk_entry_get_text(GTK_ENTRY(summaryview->search_entry));
+ key = gtk_entry_get_text(GTK_ENTRY(summaryview->qsearch->entry));
if (type == QS_ALL && (!key || *key == '\0')) {
summary_qsearch_reset(summaryview);
return;
@@ -5515,7 +5293,7 @@ void summary_qsearch(SummaryView *summaryview)
summary_lock(summaryview);
main_window_cursor_wait(summaryview->mainwin);
- flt_mlist = summary_qsearch_filter(summaryview, type, key);
+ flt_mlist = quick_search_filter(summaryview->qsearch, type, key);
summaryview->on_filter = TRUE;
summaryview->flt_mlist = flt_mlist;
@@ -5548,48 +5326,6 @@ void summary_qsearch(SummaryView *summaryview)
/* callback functions */
-static void summary_filter_menu_activated(GtkWidget *menuitem,
- SummaryView *summaryview)
-{
- summary_qsearch(summaryview);
-}
-
-static void summary_search_entry_changed(GtkWidget *entry,
- SummaryView *summaryview)
-{
- const gchar *text;
-
- text = gtk_entry_get_text(GTK_ENTRY(entry));
- if (text && *text != '\0')
- gtk_widget_show(summaryview->search_clear_btn);
- else
- gtk_widget_hide(summaryview->search_clear_btn);
-}
-
-static void summary_search_entry_activated(GtkWidget *entry,
- SummaryView *summaryview)
-{
- gtk_editable_select_region(GTK_EDITABLE(entry), 0, -1);
- summary_qsearch(summaryview);
-}
-
-static gboolean summary_search_entry_key_pressed(GtkWidget *treeview,
- GdkEventKey *event,
- SummaryView *summaryview)
-{
- if (event && event->keyval == GDK_Escape) {
- summary_qsearch_clear_entry(summaryview);
- return TRUE;
- }
- return FALSE;
-}
-
-static void summary_search_clear_clicked(GtkWidget *button,
- SummaryView *summaryview)
-{
- summary_qsearch_clear_entry(summaryview);
-}
-
static gboolean summary_toggle_pressed(GtkWidget *eventbox,
GdkEventButton *event,
SummaryView *summaryview)
diff --git a/src/summaryview.h b/src/summaryview.h
index 6187257f..230318f0 100644
--- a/src/summaryview.h
+++ b/src/summaryview.h
@@ -36,6 +36,7 @@ typedef struct _SummaryColumnState SummaryColumnState;
#include "folderview.h"
#include "headerview.h"
#include "messageview.h"
+#include "quick_search.h"
#include "compose.h"
#include "filter.h"
#include "folder.h"
@@ -59,13 +60,6 @@ struct _SummaryView
{
GtkWidget *vbox;
- GtkWidget *search_hbox;
- GtkWidget *filter_optmenu;
- GtkWidget *filter_menu;
- GtkWidget *search_label;
- GtkWidget *search_entry;
- GtkWidget *search_clear_btn;
-
GtkWidget *scrolledwin;
GtkWidget *treeview;
@@ -112,6 +106,7 @@ struct _SummaryView
FolderView *folderview;
HeaderView *headerview;
MessageView *messageview;
+ QuickSearch *qsearch;
FolderItem *folder_item;