aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorSrinivasa Ragavan <sragavan@src.gnome.org>2006-09-29 15:37:56 +0800
committerSrinivasa Ragavan <sragavan@src.gnome.org>2006-09-29 15:37:56 +0800
commit1992a65ef8d2a2ff0aad65b708c4eb023c53caaa (patch)
treebb95ffd8544b5956f61ada1ce2abab4b7036bb48 /widgets
parent0e5cccbd8a13b407422e2c1bdd2f3228bc87506b (diff)
downloadgsoc2013-evolution-1992a65ef8d2a2ff0aad65b708c4eb023c53caaa.tar
gsoc2013-evolution-1992a65ef8d2a2ff0aad65b708c4eb023c53caaa.tar.gz
gsoc2013-evolution-1992a65ef8d2a2ff0aad65b708c4eb023c53caaa.tar.bz2
gsoc2013-evolution-1992a65ef8d2a2ff0aad65b708c4eb023c53caaa.tar.lz
gsoc2013-evolution-1992a65ef8d2a2ff0aad65b708c4eb023c53caaa.tar.xz
gsoc2013-evolution-1992a65ef8d2a2ff0aad65b708c4eb023c53caaa.tar.zst
gsoc2013-evolution-1992a65ef8d2a2ff0aad65b708c4eb023c53caaa.zip
Fixes a lot of search issues.
svn path=/trunk/; revision=32821
Diffstat (limited to 'widgets')
-rw-r--r--widgets/misc/ChangeLog16
-rw-r--r--widgets/misc/e-filter-bar.c124
-rw-r--r--widgets/misc/e-search-bar.c117
-rw-r--r--widgets/misc/e-search-bar.h6
4 files changed, 198 insertions, 65 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog
index 615912f4e8..3776029d95 100644
--- a/widgets/misc/ChangeLog
+++ b/widgets/misc/ChangeLog
@@ -1,5 +1,21 @@
2006-09-29 Srinivasa Ragavan <sragavan@novell.com>
+ ** Fixes a lot of search issues.
+
+ * e-filter-bar.c: (rule_advanced_response), (do_advanced),
+ (menubar_activated), (option_changed), (free_items),
+ (get_property), (set_property):
+ * e-search-bar.c: (clear_search), (clear_verb_cb),
+ (paint_search_text), (e_search_bar_paint), (viewitem_activated_cb),
+ (scopeitem_activated_cb), (option_activated_cb),
+ (clear_button_clicked_cb), (scopeoption_changed_cb), (set_option),
+ (init), (e_search_bar_construct), (e_search_bar_set_viewitem_id),
+ (e_search_bar_set_item_id), (e_search_bar_set_item_menu),
+ (e_search_bar_set_search_scope), (e_search_bar_set_ids):
+ * e-search-bar.h:
+
+2006-09-29 Srinivasa Ragavan <sragavan@novell.com>
+
** Fixes bug #341474 patch from Ushveen
* e-attachment-bar.c: (size_to_string): Use
diff --git a/widgets/misc/e-filter-bar.c b/widgets/misc/e-filter-bar.c
index 363a0127ae..ce4ebf2658 100644
--- a/widgets/misc/e-filter-bar.c
+++ b/widgets/misc/e-filter-bar.c
@@ -107,7 +107,7 @@ rule_advanced_response (GtkWidget *dialog, int response, void *data)
{
EFilterBar *efb = data;
/* the below generates a compiler warning about incompatible pointer types */
- ESearchBar *esb = efb;
+ ESearchBar *esb = (ESearchBar *)efb;
FilterRule *rule;
if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY) {
@@ -157,8 +157,10 @@ do_advanced (ESearchBar *esb)
if (efb->current_query)
rule = filter_rule_clone (efb->current_query);
- else
+ else {
rule = filter_rule_new ();
+ efb->current_query = rule;
+ }
w = filter_rule_get_widget (rule, efb->context);
filter_rule_set_source (rule, FILTER_SOURCE_INCOMING);
@@ -239,7 +241,7 @@ static void
menubar_activated (ESearchBar *esb, int id, void *data)
{
EFilterBar *efb = (EFilterBar *)esb;
- GtkWidget *dialog, *w;
+ GtkWidget *dialog;
d(printf ("menubar activated!\n"));
@@ -294,7 +296,13 @@ option_changed (ESearchBar *esb, void *data)
int id = e_search_bar_get_item_id (esb);
char *query;
- d(printf("option changed, id = %d, setquery = %s\n", id, efb->setquery ? "true" : "false"));
+ d(printf("option changed, id = %d, setquery = %s %d\n", id, efb->setquery ? "true" : "false", esb->block_search));
+
+ if (esb->scopeitem_id == E_FILTERBAR_CURRENT_MESSAGE_ID) {
+ gtk_widget_set_sensitive (esb->option_button, FALSE);
+ } else {
+ gtk_widget_set_sensitive (esb->option_button, TRUE);
+ }
if (efb->setquery)
return;
@@ -306,7 +314,8 @@ option_changed (ESearchBar *esb, void *data)
break;
case E_FILTERBAR_ADVANCED_ID:
d(printf ("do_advanced\n"));
- do_advanced (esb);
+ if (!esb->block_search)
+ do_advanced (esb);
break;
default:
if (id >= efb->option_base && id < efb->option_base + efb->option_rules->len) {
@@ -321,6 +330,7 @@ option_changed (ESearchBar *esb, void *data)
gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, NULL);
gtk_widget_modify_base (esb->icon_entry, GTK_STATE_NORMAL, NULL);
efb->current_query = NULL;
+ gtk_entry_set_text ((GtkEntry *)esb->entry, "");
}
}
}
@@ -464,7 +474,7 @@ generate_menu (ESearchBar *esb, ESearchBarItem *items)
static void
free_items (ESearchBarItem *items)
{
- int i, j;
+ int i;
for (i = 0; items[i].id != -1; i++)
g_free (items[i].text);
@@ -549,6 +559,7 @@ static void
get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
{
EFilterBar *efb = (EFilterBar *) object;
+ ESearchBar *esb = E_SEARCH_BAR (object);
switch (property_id) {
case PROP_QUERY:
@@ -565,7 +576,7 @@ get_property (GObject *object, guint property_id, GValue *value, GParamSpec *psp
case PROP_STATE: {
/* FIXME: we should have ESearchBar save its own state to the xmlDocPtr */
char *xmlbuf, *text, buf[12];
- int searchscope, item_id, n;
+ int searchscope, item_id, n, view_id;
xmlNodePtr root, node;
xmlDocPtr doc;
@@ -574,15 +585,27 @@ get_property (GObject *object, guint property_id, GValue *value, GParamSpec *psp
doc = xmlNewDoc ("1.0");
root = xmlNewDocNode (doc, NULL, "state", NULL);
xmlDocSetRootElement (doc, root);
+ searchscope = e_search_bar_get_search_scope ((ESearchBar *) efb);
+ view_id = e_search_bar_get_viewitem_id ((ESearchBar *) efb);
+
+ if (searchscope < E_FILTERBAR_CURRENT_FOLDER_ID)
+ item_id = esb->last_search_option;
if (item_id == E_FILTERBAR_ADVANCED_ID) {
/* advanced query, save the filterbar state */
node = xmlNewChild (root, NULL, "filter-bar", NULL);
- xmlAddChild (node, filter_rule_xml_encode (efb->current_query));
+
+ sprintf (buf, "%d", esb->last_search_option);
+ xmlSetProp (node, "item_id", buf);
+ sprintf (buf, "%d", searchscope);
+ xmlSetProp (node, "searchscope", buf);
+ sprintf (buf, "%d", view_id);
+ xmlSetProp (node, "view_id", buf);
+
+ xmlAddChild (node, filter_rule_xml_encode (efb->current_query));
} else {
/* simple query, save the searchbar state */
text = e_search_bar_get_text ((ESearchBar *) efb);
- searchscope = e_search_bar_get_search_scope ((ESearchBar *) efb);
node = xmlNewChild (root, NULL, "search-bar", NULL);
xmlSetProp (node, "text", text ? text : "");
@@ -590,6 +613,8 @@ get_property (GObject *object, guint property_id, GValue *value, GParamSpec *psp
xmlSetProp (node, "item_id", buf);
sprintf (buf, "%d", searchscope);
xmlSetProp (node, "searchscope", buf);
+ sprintf (buf, "%d", view_id);
+ xmlSetProp (node, "view_id", buf);
g_free (text);
}
@@ -631,11 +656,12 @@ static void
set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
EFilterBar *efb = (EFilterBar *) object;
+ ESearchBar *esb = E_SEARCH_BAR (object);
xmlNodePtr root, node;
const char *state;
xmlDocPtr doc;
-
-
+ gboolean rule_set = FALSE, is_cur_folder=FALSE;
+ int view_id, scope, item_id;
switch (property_id) {
case PROP_STATE:
@@ -653,18 +679,28 @@ set_property (GObject *object, guint property_id, const GValue *value, GParamSpe
while (node != NULL) {
if (!strcmp (node->name, "filter-bar")) {
FilterRule *rule = NULL;
+
+
+ view_id = xml_get_prop_int (node, "view_id");
+ scope = xml_get_prop_int (node, "searchscope");
+ item_id = xml_get_prop_int (node, "item_id");
+
+ if (scope == E_FILTERBAR_CURRENT_FOLDER_ID)
+ is_cur_folder = TRUE;
if ((node = node->children)) {
GtkStyle *style = gtk_widget_get_default_style ();
rule = filter_rule_new ();
- if (filter_rule_xml_decode (rule, node, efb->context) != 0) {
+ if (filter_rule_xml_decode (rule, node, efb->context) != 0) {
gtk_widget_modify_base (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, NULL);
gtk_widget_modify_text (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, NULL);
gtk_widget_modify_base (((ESearchBar *)efb)->icon_entry, GTK_STATE_NORMAL, NULL);
g_object_unref (rule);
rule = NULL;
} else {
+ rule_set = TRUE;
+ gtk_widget_set_sensitive (esb->clear_button, TRUE);
gtk_widget_modify_base (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
gtk_widget_modify_text (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED]));
gtk_widget_modify_base (((ESearchBar *)efb)->icon_entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
@@ -672,23 +708,59 @@ set_property (GObject *object, guint property_id, const GValue *value, GParamSpe
g_object_set_data_full (object, "rule", rule, (GDestroyNotify) g_object_unref);
}
}
-
+
+
+ if (rule_set) {
+ esb->block_search = TRUE;
+ e_search_bar_set_text (esb, _("Advanced Search"));
+ e_search_bar_set_item_menu ((ESearchBar *) efb, item_id);
+ e_search_bar_set_search_scope ((ESearchBar *) efb, scope);
+ esb->block_search = FALSE;
+ efb->current_query = (FilterRule *)efb->option_rules->pdata[item_id - efb->option_base];
+ if (efb->config && efb->current_query) {
+ char *query = e_search_bar_get_text (esb);
+ efb->config (efb, efb->current_query, item_id, query, efb->config_data);
+ g_free (query);
+
+ }
+ }
+ e_search_bar_set_viewitem_id ((ESearchBar *) efb, view_id);
efb->current_query = rule;
-
efb->setquery = TRUE;
- e_search_bar_set_item_id ((ESearchBar *) efb, E_FILTERBAR_ADVANCED_ID);
+ e_search_bar_set_item_id ((ESearchBar *) efb, E_FILTERBAR_ADVANCED_ID);
efb->setquery = FALSE;
break;
} else if (!strcmp (node->name, "search-bar")) {
- int subitem_id, item_id;
+ int subitem_id, item_id, scope, view_id;
char *text;
GtkStyle *style = gtk_widget_get_default_style ();
/* set the text first (it doesn't emit a signal) */
+
+
+ /* now set the item_id and subitem_id */
+ item_id = xml_get_prop_int (node, "item_id");
+ subitem_id = xml_get_prop_int (node, "subitem_id");
+
+ esb->block_search = TRUE;
+ if (subitem_id >= 0)
+ e_search_bar_set_ids ((ESearchBar *) efb, item_id, subitem_id);
+ else
+ e_search_bar_set_item_menu ((ESearchBar *) efb, item_id);
+ esb->block_search = FALSE;
+ view_id = xml_get_prop_int (node, "view_id");
+ e_search_bar_set_viewitem_id ((ESearchBar *) efb, view_id);
+ scope = xml_get_prop_int (node, "searchscope");
+ e_search_bar_set_search_scope ((ESearchBar *) efb, scope);
+
text = xmlGetProp (node, "text");
e_search_bar_set_text ((ESearchBar *) efb, text);
if (text && *text) {
+ efb->current_query = (FilterRule *)efb->option_rules->pdata[item_id - efb->option_base];
+ if (efb->config && efb->current_query)
+ efb->config (efb, efb->current_query, item_id, text, efb->config_data);
+ gtk_widget_set_sensitive (esb->clear_button, TRUE);
gtk_widget_modify_base (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
gtk_widget_modify_text (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED]));
gtk_widget_modify_base (((ESearchBar *)efb)->icon_entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
@@ -697,18 +769,13 @@ set_property (GObject *object, guint property_id, const GValue *value, GParamSpe
gtk_widget_modify_base (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, NULL);
gtk_widget_modify_text (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, NULL);
gtk_widget_modify_base (((ESearchBar *)efb)->icon_entry, GTK_STATE_NORMAL, NULL);
+ e_search_bar_paint (esb);
+ efb->current_query = NULL;
}
- xmlFree (text);
-
- /* now set the item_id and subitem_id */
- item_id = xml_get_prop_int (node, "item_id");
- subitem_id = xml_get_prop_int (node, "subitem_id");
-
- if (subitem_id >= 0)
- e_search_bar_set_ids ((ESearchBar *) efb, item_id, subitem_id);
- else
- e_search_bar_set_item_id ((ESearchBar *) efb, item_id);
+ xmlFree (text);
+
+
break;
}
@@ -718,13 +785,14 @@ set_property (GObject *object, guint property_id, const GValue *value, GParamSpe
xmlFreeDoc (doc);
} else {
/* set default state */
- e_search_bar_set_text ((ESearchBar *) efb, "");
e_search_bar_set_item_id ((ESearchBar *) efb, 0);
+ e_search_bar_set_viewitem_id ((ESearchBar *) efb, 0);
+ e_search_bar_set_search_scope ((ESearchBar *) efb, E_FILTERBAR_CURRENT_FOLDER_ID);
}
/* we don't want to run option_changed */
efb->setquery = TRUE;
- g_signal_emit_by_name (efb, "search-activated", NULL);
+ g_signal_emit_by_name (efb, "search_activated", NULL);
efb->setquery = FALSE;
break;
diff --git a/widgets/misc/e-search-bar.c b/widgets/misc/e-search-bar.c
index 5d771854ca..50969d7078 100644
--- a/widgets/misc/e-search-bar.c
+++ b/widgets/misc/e-search-bar.c
@@ -107,12 +107,14 @@ verb_name_from_id (int id)
static void
clear_search (ESearchBar *esb)
{
+ e_search_bar_set_text (esb, "");
+ esb->block_search = TRUE;
if (esb->item_id < 0)
- e_search_bar_set_item_id (esb, esb->last_search_option);
-
- e_search_bar_set_text (esb, "");
+ e_search_bar_set_item_id (esb, esb->last_search_option);
e_search_bar_set_viewitem_id (esb, 0);
+ esb->block_search = FALSE;
emit_search_activated (esb);
+
}
static void
@@ -212,6 +214,7 @@ clear_verb_cb (BonoboUIComponent *ui_component,
gtk_widget_modify_base (esb->icon_entry, GTK_STATE_NORMAL, NULL);
clear_search (esb);
+ gtk_entry_set_text (GTK_ENTRY (esb->entry), "");
gtk_widget_grab_focus (esb->entry);
}
@@ -302,7 +305,7 @@ paint_search_text (GtkWidget *widget, ESearchBar *esb)
if (!GTK_WIDGET_SENSITIVE (esb->option_button)) {
menu_widget = esb->scopeoption_menu;
- text = g_object_get_data (gtk_menu_get_active ( GTK_MENU (esb->scopeoption_menu)),"string");
+ text = g_object_get_data (G_OBJECT(gtk_menu_get_active ( GTK_MENU (esb->scopeoption_menu))),"string");
} else if (!GTK_IS_RADIO_MENU_ITEM (gtk_menu_get_active ( GTK_MENU (esb->option_menu))))
return FALSE;
else /* no query in search entry .. so set the current option */
@@ -310,8 +313,10 @@ paint_search_text (GtkWidget *widget, ESearchBar *esb)
if (text && *text) {
- gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_INSENSITIVE]));
- gtk_entry_set_text (GTK_ENTRY (esb->entry), text);
+ if (!GTK_WIDGET_HAS_FOCUS(esb->entry)) {
+ gtk_entry_set_text (GTK_ENTRY (esb->entry), text);
+ gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_INSENSITIVE]));
+ }
gtk_tooltips_set_tip (esb->tooltips, esb->option_button, text, "Search type");
gtk_widget_set_sensitive (esb->clear_button, FALSE);
}
@@ -319,6 +324,12 @@ paint_search_text (GtkWidget *widget, ESearchBar *esb)
return FALSE;
}
+void
+e_search_bar_paint (ESearchBar *search_bar)
+{
+ paint_search_text (search_bar->entry, search_bar);
+}
+
static gboolean
entry_focus_out_cb (GtkWidget *widget,
GdkEventFocus *event,
@@ -387,7 +398,9 @@ viewitem_activated_cb(GtkWidget *widget, ESearchBar *esb)
gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, NULL);
}
+ esb->block_search = TRUE;
emit_search_activated (esb);
+ esb->block_search = FALSE;
}
static void
@@ -406,11 +419,14 @@ scopeitem_activated_cb(GtkWidget *widget, ESearchBar *esb)
/* If the text is grayed, Its not the query string */
if (gdk_color_equal (&(entry_style->text[GTK_STATE_NORMAL]), &(default_style->text[GTK_STATE_INSENSITIVE]))) {
+ gtk_widget_grab_focus (esb->entry);
gtk_entry_set_text (GTK_ENTRY (esb->entry), "");
gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, NULL);
}
+ esb->block_search = TRUE;
emit_search_activated (esb);
+ esb->block_search = FALSE;
}
static char *
@@ -443,12 +459,12 @@ static void
option_activated_cb (GtkWidget *widget,
ESearchBar *esb)
{
-/* int id; */
-
-/* id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "EsbItemId")); */
+ int id;
+ const char *text;
+
+ id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "EsbItemId"));
-/* esb->item_id = id; */
- char *text;
+ e_search_bar_set_item_id (esb, id);
if (GTK_IS_RADIO_MENU_ITEM (gtk_menu_get_active ( GTK_MENU (esb->option_menu)))) {
text = get_selected_item_label (esb->option_menu);
@@ -456,8 +472,12 @@ option_activated_cb (GtkWidget *widget,
gtk_tooltips_set_tip (esb->tooltips, esb->option_button, text, "Search type");
}
- emit_query_changed (esb);
- emit_search_activated (esb);
+ if (!esb->block_search) {
+ emit_query_changed (esb);
+ }
+ if (!esb->block_search && id > 0) {
+ emit_search_activated (esb);
+ }
}
static void
@@ -478,7 +498,7 @@ clear_button_clicked_cb (GtkWidget *widget, GdkEventButton *event,
gtk_widget_modify_base (esb->icon_entry, GTK_STATE_NORMAL, NULL);
clear_search (esb);
-
+ gtk_entry_set_text (GTK_ENTRY (esb->entry), "");
gtk_widget_grab_focus (esb->entry);
}
@@ -496,21 +516,24 @@ entry_key_press_cb (GtkWidget *widget,
return FALSE;
}
+#if 0
static void
scopeoption_changed_cb (GtkWidget *option_menu, ESearchBar *search_bar)
{
const gchar *text = NULL;
- GtkStyle *style = gtk_widget_get_default_style ();
text = e_search_bar_get_text (search_bar);
if (!(text && *text))
gtk_widget_grab_focus (search_bar->entry);
-
- emit_query_changed (search_bar);
+
+ if(!search_bar->block_search)
+ emit_query_changed (search_bar);
}
+#endif
/* Widgetry creation. */
+#if 0
/* This function exists to fix the irreparable GtkOptionMenu stupidity. In
fact, this lame-ass widget adds a 1-pixel-wide empty border around the
button for no reason. So we have add a 1-pixel-wide border around the the
@@ -527,6 +550,7 @@ put_in_spacer_widget (GtkWidget *widget)
return holder;
}
+#endif
static void
append_xml_menu_item (GString *xml,
@@ -705,7 +729,7 @@ set_option (ESearchBar *esb, ESearchBarItem *items)
}
gtk_widget_show_all (menu);
- g_object_set_data (esb->option_menu, "group", group);
+ g_object_set_data (G_OBJECT(esb->option_menu), "group", group);
entry_focus_out_cb (esb->entry, NULL, esb);
}
@@ -903,6 +927,7 @@ init (ESearchBar *esb)
esb->item_id = 0;
esb->scopeitem_id = 0;
esb->last_search_option = 0;
+ esb->block_search = FALSE;
}
@@ -951,11 +976,11 @@ e_search_bar_construct (ESearchBar *search_bar,
G_CALLBACK (entry_key_press_cb), search_bar);
search_bar->clear_button = e_icon_entry_create_button ("gtk-clear");
- g_signal_connect (G_OBJECT (search_bar->clear_button), "button-press-event", clear_button_clicked_cb, search_bar);
+ g_signal_connect (G_OBJECT (search_bar->clear_button), "button-press-event", G_CALLBACK(clear_button_clicked_cb), search_bar);
e_icon_entry_pack_widget (E_ICON_ENTRY (search_bar->icon_entry), search_bar->clear_button, FALSE);
search_bar->option_button = e_icon_entry_create_button ("gtk-find");
- g_signal_connect (G_OBJECT (search_bar->option_button), "button-press-event", option_button_clicked_cb, search_bar);
+ g_signal_connect (G_OBJECT (search_bar->option_button), "button-press-event", G_CALLBACK(option_button_clicked_cb), search_bar);
e_icon_entry_pack_widget (E_ICON_ENTRY (search_bar->icon_entry), search_bar->option_button, TRUE);
gtk_box_pack_start (GTK_BOX(search_bar->entry_box), search_bar->icon_entry, FALSE, FALSE, 0);
@@ -973,7 +998,7 @@ e_search_bar_construct (ESearchBar *search_bar,
gtk_box_pack_start (GTK_BOX(search_bar->viewoption_box), label, FALSE, FALSE, 0);
search_bar->viewoption = gtk_option_menu_new ();
- gtk_label_set_mnemonic_widget (label, search_bar->viewoption);
+ gtk_label_set_mnemonic_widget ((GtkLabel *)label, search_bar->viewoption);
gtk_box_pack_start (GTK_BOX(search_bar->viewoption_box), search_bar->viewoption, FALSE, TRUE, 0);
gtk_widget_show_all (search_bar->viewoption_box);
gtk_box_pack_start (GTK_BOX(search_bar), search_bar->viewoption_box, FALSE, FALSE, 0);
@@ -990,7 +1015,7 @@ e_search_bar_construct (ESearchBar *search_bar,
gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(hbox), search_bar->entry_box, FALSE, FALSE, 0);
gtk_widget_show (search_bar->entry_box);
- gtk_label_set_mnemonic_widget (label, search_bar->entry);
+ gtk_label_set_mnemonic_widget ((GtkLabel *)label, search_bar->entry);
/* Search Scope Widgets */
search_bar->scopeoption_box = gtk_hbox_new (0, FALSE);
@@ -1002,11 +1027,11 @@ e_search_bar_construct (ESearchBar *search_bar,
gtk_box_pack_start (GTK_BOX(search_bar->scopeoption_box), label, FALSE, FALSE, 0);
search_bar->scopeoption = gtk_option_menu_new ();
- g_signal_connect (GTK_OPTION_MENU (search_bar->scopeoption), "changed", scopeoption_changed_cb, search_bar);
+/* g_signal_connect (GTK_OPTION_MENU (search_bar->scopeoption), "changed", scopeoption_changed_cb, search_bar); */
gtk_box_pack_start (GTK_BOX(search_bar->scopeoption_box), search_bar->scopeoption, FALSE, FALSE, 0);
gtk_widget_show_all (search_bar->scopeoption_box);
gtk_widget_hide (hbox);
- gtk_label_set_mnemonic_widget (label, search_bar->scopeoption);
+ gtk_label_set_mnemonic_widget ((GtkLabel *)label, search_bar->scopeoption);
gtk_box_pack_end (GTK_BOX(hbox), search_bar->scopeoption_box, FALSE, FALSE, 0);
gtk_widget_hide (search_bar->scopeoption_box);
@@ -1305,8 +1330,8 @@ e_search_bar_set_viewitem_id (ESearchBar *search_bar, int id)
g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
row = find_id (search_bar->viewoption_menu, id, "EsbItemId", NULL);
- g_return_if_fail (row != -1);
-
+ if (row == -1)
+ return;
search_bar->viewitem_id = id;
gtk_option_menu_set_history (GTK_OPTION_MENU (search_bar->viewoption), row);
@@ -1328,14 +1353,32 @@ e_search_bar_set_item_id (ESearchBar *search_bar, int id)
g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
row = find_id (search_bar->option_menu, id, "EsbItemId", NULL);
- g_return_if_fail (row != -1);
+ if (row == -1)
+ return;
if (id>=0)
search_bar->last_search_option = id;
search_bar->item_id = id;
- gtk_menu_set_active (search_bar->option_menu, row);
+ gtk_menu_set_active ((GtkMenu *)search_bar->option_menu, row);
- emit_query_changed (search_bar);
+ if (!search_bar->block_search)
+ emit_query_changed (search_bar);
+}
+
+void
+e_search_bar_set_item_menu (ESearchBar *search_bar, int id)
+{
+ int row;
+ GtkWidget *item;
+ g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
+
+ row = find_id (search_bar->option_menu, id, "EsbItemId", &item);
+ if (row == -1)
+ return;
+
+ gtk_menu_set_active ((GtkMenu *)search_bar->option_menu, row);
+ if (id>=0)
+ gtk_check_menu_item_set_active ((GtkCheckMenuItem *)item, TRUE);
}
/**
@@ -1352,13 +1395,15 @@ e_search_bar_set_search_scope (ESearchBar *search_bar, int id)
g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
- row = find_id (search_bar->option_menu, id, "EsbItemId", NULL);
- g_return_if_fail (row != -1);
+ row = find_id (search_bar->scopeoption_menu, id, "EsbItemId", NULL);
+ if (row == -1)
+ return;
- search_bar->item_id = id;
- gtk_option_menu_set_history (GTK_OPTION_MENU (search_bar->option), row);
+ search_bar->scopeitem_id = id;
+ gtk_option_menu_set_history (GTK_OPTION_MENU (search_bar->scopeoption), row);
- emit_query_changed (search_bar);
+ if (!search_bar->block_search)
+ emit_query_changed (search_bar);
}
@@ -1457,8 +1502,8 @@ e_search_bar_set_ids (ESearchBar *search_bar, int item_id, int subitem_id)
g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
item_row = find_id (search_bar->option_menu, item_id, "EsbChoiceId", &item_widget);
- g_return_if_fail (item_row != -1);
- g_assert (item_widget != NULL);
+ if (item_row == -1 || !item_widget)
+ return;
search_bar->item_id = item_id;
gtk_option_menu_set_history (GTK_OPTION_MENU (search_bar->option), item_row);
diff --git a/widgets/misc/e-search-bar.h b/widgets/misc/e-search-bar.h
index 3693b8055d..e6ccb27121 100644
--- a/widgets/misc/e-search-bar.h
+++ b/widgets/misc/e-search-bar.h
@@ -101,6 +101,8 @@ struct _ESearchBar
int viewitem_id; /* Current View Id */
int scopeitem_id; /* Scope of search */
int last_search_option;
+
+ gboolean block_search;
};
struct _ESearchBarClass
@@ -140,7 +142,7 @@ void e_search_bar_add_menu (ESearchBar *search_bar,
void e_search_bar_set_option (ESearchBar *search_bar,
ESearchBarItem *option_items);
-
+void e_search_bar_paint (ESearchBar *search_bar);
void e_search_bar_set_viewoption (ESearchBar *search_bar,
int option_id,
ESearchBarItem *subitems);
@@ -151,6 +153,8 @@ void e_search_bar_set_menu_sensitive (ESearchBar *search_bar,
void e_search_bar_set_item_id (ESearchBar *search_bar,
int id);
+void e_search_bar_set_item_menu (ESearchBar *search_bar,
+ int id);
int e_search_bar_get_item_id (ESearchBar *search_bar);
int e_search_bar_get_viewitem_id (ESearchBar *search_bar);