Re: [evolution-patches] [addressbook] Implements Saving Advanced Search Feature for Addressbook
- From: Devashish <sdevashish novell com>
- To: patches <evolution-patches gnome org>
- Cc:
- Subject: Re: [evolution-patches] [addressbook] Implements Saving Advanced Search Feature for Addressbook
- Date: Wed, 25 Jan 2006 12:36:30 +0530
Forgot one file in the diff, resending the modified patch.
On Wed, 2006-01-25 at 12:08 +0530, Devashish wrote:
> Hi,
>
> The attached Patch implements Saving Advanced Search feature for address
> book.
>
> Thanks
> Devashish Sharma
> _______________________________________________
> Evolution-patches mailing list
> Evolution-patches gnome org
> http://mail.gnome.org/mailman/listinfo/evolution-patches
Index: addressbook/gui/widgets/e-addressbook-view.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/e-addressbook-view.c,v
retrieving revision 1.175
diff -u -p -r1.175 e-addressbook-view.c
--- addressbook/gui/widgets/e-addressbook-view.c 13 Jan 2006 16:37:55 -0000 1.175
+++ addressbook/gui/widgets/e-addressbook-view.c 25 Jan 2006 06:23:39 -0000
@@ -31,6 +31,7 @@
#include <table/e-table-model.h>
#include <misc/e-gui-utils.h>
#include <widgets/menus/gal-view-factory-etable.h>
+#include <filter/rule-editor.h>
#include <widgets/menus/gal-view-etable.h>
#include <e-util/e-xml-utils.h>
#include <libgnomeui/gnome-dialog-util.h>
@@ -163,7 +164,6 @@ enum {
ESB_EMAIL,
ESB_CATEGORY,
ESB_ANY,
- ESB_ADVANCED
};
static ESearchBarItem addressbook_search_option_items[] = {
@@ -171,13 +171,16 @@ static ESearchBarItem addressbook_search
{ N_("Email begins with"), ESB_EMAIL, NULL },
{ N_("Category is"), ESB_CATEGORY, NULL }, /* We attach subitems below */
{ N_("Any field contains"), ESB_ANY, NULL },
- { N_("Advanced..."), ESB_ADVANCED, NULL },
{ NULL, -1, NULL }
};
static ESearchBarItem addressbook_search_items[] = {
- { N_("_Advanced..."), ESB_ADVANCED, NULL },
- { NULL, -1, NULL },
+ E_FILTERBAR_ADVANCED,
+ {NULL, 0, NULL},
+ E_FILTERBAR_SAVE,
+ E_FILTERBAR_EDIT,
+ {NULL, -1, NULL}
+
};
GType
@@ -369,10 +372,10 @@ eab_view_dispose (GObject *object)
eav->invisible = NULL;
}
- if (eav->search_context) {
+ /*if (eav->search_context) {
g_object_unref (eav->search_context);
eav->search_context = NULL;
- }
+ }*/
if (eav->search_rule) {
g_object_unref (eav->search_rule);
@@ -424,6 +427,7 @@ eab_view_new (void)
EABView *eav = EAB_VIEW (widget);
FilterPart *part;
char *xmlfile;
+ char *userfile;
/* create our model */
eav->model = eab_model_new ();
@@ -448,27 +452,20 @@ eab_view_new (void)
eav->editable = FALSE;
eav->query = g_strdup (SHOW_ALL_SEARCH);
- /* create our search bar */
- eav->search = E_SEARCH_BAR (e_search_bar_new (NULL, addressbook_search_option_items));
- e_search_bar_set_menu (eav->search, addressbook_search_items);
- make_suboptions (eav);
- g_signal_connect (eav->search, "query_changed",
- G_CALLBACK (query_changed), eav);
- g_signal_connect (eav->search, "search_activated",
- G_CALLBACK (search_activated), eav);
- g_signal_connect (eav->search, "menu_activated",
- G_CALLBACK (search_menu_activated), eav);
- gtk_box_pack_start (GTK_BOX (eav), GTK_WIDGET (eav->search), FALSE, FALSE, 0);
- gtk_widget_show (GTK_WIDGET (eav->search));
- gtk_widget_set_sensitive (GTK_WIDGET (eav->search), FALSE);
-
/* create the search context */
eav->search_context = rule_context_new ();
rule_context_add_part_set (eav->search_context, "partset", filter_part_get_type (),
rule_context_add_part, rule_context_next_part);
+ rule_context_add_rule_set (eav->search_context, "ruleset", filter_rule_get_type (),
+ rule_context_add_rule, rule_context_next_rule);
+
+ userfile = g_build_filename ( g_get_home_dir (), ".evolution/addressbook/searches.xml", NULL);
xmlfile = g_build_filename (SEARCH_RULE_DIR, "addresstypes.xml", NULL);
- rule_context_load (eav->search_context, xmlfile, "");
- g_free (xmlfile);
+
+ g_object_set_data_full (G_OBJECT (eav->search_context), "user", userfile, g_free);
+ g_object_set_data_full (G_OBJECT (eav->search_context), "system", xmlfile, g_free);
+
+ rule_context_load (eav->search_context, xmlfile, userfile);
eav->search_rule = filter_rule_new ();
part = rule_context_next_part (eav->search_context, NULL);
@@ -478,6 +475,24 @@ eab_view_new (void)
else
filter_rule_add_part (eav->search_rule, filter_part_clone (part));
+ eav->search = e_filter_bar_new (eav->search_context, xmlfile, userfile, NULL, eav);
+
+ g_free (xmlfile);
+ g_free (userfile);
+
+ e_search_bar_set_menu ( (ESearchBar *) eav->search, addressbook_search_items);
+ gtk_widget_show (GTK_WIDGET (eav->search));
+ make_suboptions (eav);
+
+ g_signal_connect (eav->search, "query_changed",
+ G_CALLBACK (query_changed), eav);
+ g_signal_connect (eav->search, "search_activated",
+ G_CALLBACK (search_activated), eav);
+ g_signal_connect (eav->search, "menu_activated",
+ G_CALLBACK (search_menu_activated), eav);
+
+ gtk_box_pack_start (GTK_BOX (eav), GTK_WIDGET (eav->search), FALSE, FALSE, 0);
+
/* create the paned window and contact display */
eav->paned = gtk_vpaned_new ();
gtk_box_pack_start (GTK_BOX (eav), eav->paned, TRUE, TRUE, 0);
@@ -1462,8 +1477,6 @@ change_view_type (EABView *view, EABView
command_state_change (view);
}
-
-
static void
search_activated (ESearchBar *esb, EABView *v)
{
@@ -1479,8 +1492,8 @@ search_activated (ESearchBar *esb, EABVi
"item_id", &search_type,
NULL);
- if (search_type == ESB_ADVANCED) {
- gtk_widget_show(eab_search_dialog_new(v));
+ if (search_type == E_FILTERBAR_ADVANCED_ID) {
+ //gtk_widget_show(eab_search_dialog_new(v));
}
else {
if ((search_word && strlen (search_word)) || search_type == ESB_CATEGORY) {
@@ -1503,7 +1516,6 @@ search_activated (ESearchBar *esb, EABVi
subid = e_search_bar_get_subitem_id (esb);
if (subid < 0 || subid == G_MAXINT) {
- /* match everything */
search_query = g_strdup ("(contains \"x-evolution-any-field\" \"\")");
} else {
master_list = get_master_list ();
@@ -1536,7 +1548,7 @@ search_activated (ESearchBar *esb, EABVi
static void
search_menu_activated (ESearchBar *esb, int id, EABView *view)
{
- if (id == ESB_ADVANCED)
+ if (id == E_FILTERBAR_ADVANCED_ID)
e_search_bar_set_item_id (esb, id);
}
@@ -1544,10 +1556,15 @@ static void
query_changed (ESearchBar *esb, EABView *view)
{
int search_type;
+ char *query;
search_type = e_search_bar_get_item_id(esb);
- if (search_type == ESB_ADVANCED)
- gtk_widget_show(eab_search_dialog_new(view));
+ if (search_type == E_FILTERBAR_ADVANCED_ID) {
+ g_object_get (esb, "query", &query, NULL);
+ g_object_set (view, "query", query, NULL);
+ g_free (query);
+ }
+
}
static int
@@ -1596,7 +1613,7 @@ make_suboptions (EABView *view)
qsort (subitems + 1, N, sizeof (subitems[0]), compare_subitems);
- e_search_bar_set_suboption (view->search, ESB_CATEGORY, subitems);
+ e_search_bar_set_suboption ( (ESearchBar *) view->search, ESB_CATEGORY, subitems);
for (s = subitems; s->id != -1; s++) {
if (s->text)
@@ -1725,7 +1742,7 @@ eab_view_setup_menus (EABView *view,
/* XXX toshok - yeah this really doesn't belong here, but it
needs to happen at the same time and takes the uic */
- e_search_bar_set_ui_component (view->search, uic);
+ e_search_bar_set_ui_component ( (ESearchBar *)view->search, uic);
}
/**
Index: addressbook/gui/Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/Makefile.am,v
retrieving revision 1.7
diff -u -p -r1.7 Makefile.am
--- addressbook/gui/Makefile.am 8 Jun 2004 02:24:11 -0000 1.7
+++ addressbook/gui/Makefile.am 25 Jan 2006 06:24:33 -0000
@@ -1 +1 @@
-SUBDIRS = merging contact-editor contact-list-editor widgets search component
+SUBDIRS = merging contact-editor contact-list-editor widgets component
Index: configure.in
===================================================================
RCS file: /cvs/gnome/evolution/configure.in,v
retrieving revision 1.876
diff -u -p -r1.876 configure.in
--- configure.in 19 Jan 2006 08:21:09 -0000 1.876
+++ configure.in 25 Jan 2006 06:39:00 -0000
@@ -1632,7 +1632,6 @@ addressbook/gui/component/Makefile
addressbook/gui/contact-editor/Makefile
addressbook/gui/contact-list-editor/Makefile
addressbook/gui/merging/Makefile
-addressbook/gui/search/Makefile
addressbook/gui/widgets/Makefile
addressbook/importers/Makefile
addressbook/printing/Makefile
--- /var/null 2006-01-25 11:54:56.000000000 +0530
+++ addressbook/gui/widgets/addresstypes.xml 2006-01-24 19:20:04.000000000 +0530
@@ -0,0 +1,174 @@
+<?xml version="1.0"?>
+<filterdescription>
+<partset>
+ <part name="name">
+ <title>Name</title>
+ <input type="optionlist" name="name-type">
+ <option value="contains">
+ <title>contains</title>
+ <code>(contains "full_name" ${name})</code>
+ </option>
+ <option value="not contains">
+ <title>does not contain</title>
+ <code>(not (contains "full_name" ${name}))</code>
+ </option>
+ <option value="is">
+ <title>is</title>
+ <code>(is "full_name" ${name})))</code>
+ </option>
+ <option value="is not">
+ <title>is not</title>
+ <code>(not (is "full_name" ${name}))</code>
+ </option>
+ <option value="begin">
+ <title>begins with</title>
+ <code>(beginswith "full_name" ${name})</code>
+ </option>
+ <option value="end">
+ <title>ends in</title>
+ <code>(endswith "full_name" ${name})</code>
+ </option>
+ </input>
+ <input type="string" name="name"/>
+ </part>
+ <part name="email">
+ <title>Email</title>
+ <input type="optionlist" name="email-type">
+ <option value="contains">
+ <title>contains</title>
+ <code>(contains "email" ${email})</code>
+ </option>
+ <option value="not contains">
+ <title>does not contain</title>
+ <code>(not (contains "email" ${email}))</code>
+ </option>
+ <option value="is">
+ <title>is</title>
+ <code>(is "email" ${email})</code>
+ </option>
+ <option value="is not">
+ <title>is not</title>
+ <code>(not (is "email" ${email}))</code>
+ </option>
+ </input>
+ <input type="address" name="email"/>
+ </part>
+ <part name="category">
+ <title>Category</title>
+ <input type="optionlist" name="category-type">
+ <option value="contains">
+ <title>contains</title>
+ <code>(contains "category_list" ${category})</code>
+ </option>
+ <option value="not contains">
+ <title>does not contain</title>
+ <code>(not (contains "category_list" ${category}))</code>
+ </option>
+ <option value="is">
+ <title>is</title>
+ <code>(is "category_list" ${category})</code>
+ </option>
+ <option value="is not">
+ <title>is not</title>
+ <code>(not (is "category_list" ${category}))</code>
+ </option>
+ </input>
+ <input type="optionlist" name="category">
+ <option value="Anniversary">
+ <title>Anniversary</title>
+ </option>
+ <option value="Holiday">
+ <title>Holiday</title>
+ </option>
+ <option value="Ideas">
+ <title>Ideas</title>
+ </option>
+ <option value="Status">
+ <title>Status</title>
+ </option>
+ <option value="Holiday Cards">
+ <title>Holiday Cards</title>
+ </option>
+ <option value="Hot Contacts">
+ <title>Hot Contacts</title>
+ </option>
+ <option value="International">
+ <title>International</title>
+ </option>
+ <option value="Birthday">
+ <title>Birthday</title>
+ </option>
+ <option value="VIP">
+ <title>VIP</title>
+ </option>
+ <option value="Gifts">
+ <title>Gifts</title>
+ </option>
+ <option value="Waiting">
+ <title>Waiting</title>
+ </option>
+ <option value="Key Customer">
+ <title>Key Customer</title>
+ </option>
+ <option value="Time & Expenses">
+ <title>Time & Expenses </title>
+ </option>
+ <option value="Miscellaneous">
+ <title>Miscellaneous</title>
+ </option>
+ <option value="Business">
+ <title>Business</title>
+ </option>
+ <option value="Personal">
+ <title>Personal</title>
+ </option>
+ <option value="Suppliers">
+ <title>Suppliers</title>
+ </option>
+ <option value="Goals/Objectives">
+ <title>Goals/Objectives</title>
+ </option>
+ <option value="Strategies">
+ <title>Strategies</title>
+ </option>
+ <option value="Competition">
+ <title>Competition</title>
+ </option>
+ <option value="Favourites">
+ <title>Favourites</title>
+ </option>
+ <option value="Phone Calls">
+ <title>Phone Calls</title>
+ </option>
+ </input>
+ </part>
+ <part name="sexp">
+ <title>Expression</title>
+ <input type="code" name="code"/>
+ </part>
+</partset>
+
+ <ruleset>
+
+ <rule grouping="any" source="demand">
+ <_title>Name begins with</_title>
+ <sources/>
+ </rule>
+
+ <rule grouping="any" source="demand">
+ <_title>Email begins with</_title>
+ <sources/>
+ </rule>
+
+ <rule grouping="any" source="demand">
+ <_title>Category is</_title>
+ <sources/>
+ </rule>
+
+ <rule grouping="any" source="demand">
+ <_title>Any field contains</_title>
+ <sources/>
+ </rule>
+
+ </ruleset>
+</filterdescription>
Index: addressbook/gui/widgets/Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/Makefile.am,v
retrieving revision 1.75
diff -u -p -r1.75 Makefile.am
--- addressbook/gui/widgets/Makefile.am 17 Aug 2005 00:53:37 -0000 1.75
+++ addressbook/gui/widgets/Makefile.am 25 Jan 2006 06:41:22 -0000
@@ -1,4 +1,5 @@
ruledir = $(privdatadir)
+rule_DATA = addresstypes.xml
INCLUDES = \
-DG_LOG_DOMAIN=\"eab-widgets\" \
@@ -98,4 +99,5 @@ etspec_DATA= e-addressbook-view.etspec
EXTRA_DIST = \
$(etspec_DATA) \
- eab-marshal.list
+ eab-marshal.list \
+ addresstypes.xml
Index: addressbook/gui/widgets/e-addressbook-view.h
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/e-addressbook-view.h,v
retrieving revision 1.37
diff -u -p -r1.37 e-addressbook-view.h
--- addressbook/gui/widgets/e-addressbook-view.h 21 Jul 2005 13:27:36 -0000 1.37
+++ addressbook/gui/widgets/e-addressbook-view.h 25 Jan 2006 07:11:54 -0000
@@ -95,7 +95,7 @@ struct _EABView
BonoboUIComponent *uic;
/* the search bar and related machinery */
- ESearchBar *search;
+ struct _EFilterBar *search;
gint ecml_changed_id;
RuleContext *search_context;
FilterRule *search_rule;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]