aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/gui')
-rw-r--r--addressbook/gui/search/Makefile.am4
-rw-r--r--addressbook/gui/search/addresstypes.xml38
-rw-r--r--addressbook/gui/search/e-addressbook-search-dialog.c42
-rw-r--r--addressbook/gui/search/e-addressbook-search-dialog.h6
4 files changed, 77 insertions, 13 deletions
diff --git a/addressbook/gui/search/Makefile.am b/addressbook/gui/search/Makefile.am
index 1050da1843..8e08218781 100644
--- a/addressbook/gui/search/Makefile.am
+++ b/addressbook/gui/search/Makefile.am
@@ -1,3 +1,6 @@
+ruledir = $(prefix)/share/evolution
+rule_DATA = addresstypes.xml
+
INCLUDES = \
-DG_LOG_DOMAIN=\"e-addressbook-search\" \
-I$(top_srcdir) \
@@ -6,6 +9,7 @@ INCLUDES = \
-I$(top_srcdir)/addressbook/contact-editor \
-I$(top_srcdir)/widgets/e-text \
-I$(top_srcdir)/widgets/misc \
+ -DSEARCH_RULE_DIR=\"$(ruledir)\" \
$(BONOBO_GNOME_CFLAGS)
noinst_LIBRARIES = \
diff --git a/addressbook/gui/search/addresstypes.xml b/addressbook/gui/search/addresstypes.xml
index d855561cce..bf64e841b0 100644
--- a/addressbook/gui/search/addresstypes.xml
+++ b/addressbook/gui/search/addresstypes.xml
@@ -2,32 +2,56 @@
<filterdescription>
<partset>
<part name="name">
- <title>Sender</title>
+ <title>Name</title>
<input type="optionlist" name="name-type">
<option value="contains">
<title>contains</title>
- <code>(contains "fullname" ${name}))</code>
+ <code>(contains "full_name" ${name})</code>
</option>
<option value="not contains">
<title>does not contain</title>
- <code>(not (contains "fullname" ${name})))</code>
+ <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>Sender</title>
+ <title>Email</title>
<input type="optionlist" name="email-type">
<option value="contains">
<title>contains</title>
- <code>(contains "email" ${email}))</code>
+ <code>(contains "email" ${email})</code>
</option>
<option value="not contains">
<title>does not contain</title>
- <code>(not (contains "email" ${email})))</code>
+ <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="string" name="email"/>
+ <input type="address" name="email"/>
</part>
<part name="sexp">
<title>Expression</title>
diff --git a/addressbook/gui/search/e-addressbook-search-dialog.c b/addressbook/gui/search/e-addressbook-search-dialog.c
index 4acfd1585c..0109b1914a 100644
--- a/addressbook/gui/search/e-addressbook-search-dialog.c
+++ b/addressbook/gui/search/e-addressbook-search-dialog.c
@@ -89,23 +89,46 @@ e_addressbook_search_dialog_class_init (EAddressbookSearchDialogClass *klass)
}
static GtkWidget *
-get_widget ()
+get_widget (EAddressbookSearchDialog *view)
{
- return gtk_entry_new();
+ FilterPart *part;
+
+ view->context = rule_context_new();
+ /* FIXME: hide this in a class */
+ rule_context_add_part_set(view->context, "partset", filter_part_get_type(),
+ rule_context_add_part, rule_context_next_part);
+ rule_context_load(view->context, SEARCH_RULE_DIR "/addresstypes.xml", "");
+ view->rule = filter_rule_new();
+ part = rule_context_next_part(view->context, NULL);
+ if (part == NULL) {
+ g_warning("Problem loading search for addressbook no parts to load");
+ return gtk_entry_new();
+ } else {
+ filter_rule_add_part(view->rule, filter_part_clone(part));
+ return filter_rule_get_widget(view->rule, view->context);
+ }
}
static char *
-get_query ()
+get_query (EAddressbookSearchDialog *view)
{
- return "(contains \"email\" \"\")";
+ GString *out = g_string_new("");
+ char *ret;
+
+ filter_rule_build_code(view->rule, out);
+ ret = out->str;
+ printf("Searching using %s\n", ret);
+ g_string_free(out, FALSE);
+ return ret;
}
static void
button_press (GtkWidget *widget, EAddressbookSearchDialog *dialog)
{
char *query;
+
gtk_widget_show(dialog->scrolled_window);
- query = get_query();
+ query = get_query(dialog);
gtk_object_set(GTK_OBJECT(dialog->view),
"query", query,
NULL);
@@ -120,7 +143,7 @@ e_addressbook_search_dialog_init (EAddressbookSearchDialog *view)
gtk_window_set_policy(GTK_WINDOW(view), FALSE, TRUE, FALSE);
- view->search = get_widget();
+ view->search = get_widget(view);
gtk_box_pack_start(GTK_BOX(dialog->vbox), view->search, TRUE, TRUE, 0);
gtk_widget_show(view->search);
@@ -188,5 +211,12 @@ e_addressbook_search_dialog_get_arg (GtkObject *object, GtkArg *arg, guint arg_i
static void
e_addressbook_search_dialog_destroy (GtkObject *object)
{
+ EAddressbookSearchDialog *view;
+
+ view = E_ADDRESSBOOK_SEARCH_DIALOG (object);
+
+ gtk_object_unref((GtkObject *)view->context);
+ gtk_object_unref((GtkObject *)view->rule);
+
GTK_OBJECT_CLASS(parent_class)->destroy (object);
}
diff --git a/addressbook/gui/search/e-addressbook-search-dialog.h b/addressbook/gui/search/e-addressbook-search-dialog.h
index 84af66b4e1..dc54275a77 100644
--- a/addressbook/gui/search/e-addressbook-search-dialog.h
+++ b/addressbook/gui/search/e-addressbook-search-dialog.h
@@ -24,6 +24,9 @@
#include <gnome.h>
#include <ebook/e-book.h>
+#include "filter/rule-context.h"
+#include "filter/filter-rule.h"
+
#ifdef __cplusplus
extern "C" {
#pragma }
@@ -45,6 +48,9 @@ struct _EAddressbookSearchDialog
GtkWidget *search;
GtkWidget *view;
+
+ RuleContext *context;
+ FilterRule *rule;
GtkWidget *scrolled_window;
};