aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/e-tasks.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-07-28 03:42:21 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-07-28 03:42:21 +0800
commit7463b3c0eeba36906a6a94130c243a41c65d5e98 (patch)
tree099ddd2aa5815e0427abde9f6bb8aaf78cc57147 /calendar/gui/e-tasks.c
parent35bf394708e6564c698277ff3dff149133036580 (diff)
downloadgsoc2013-evolution-7463b3c0eeba36906a6a94130c243a41c65d5e98.tar
gsoc2013-evolution-7463b3c0eeba36906a6a94130c243a41c65d5e98.tar.gz
gsoc2013-evolution-7463b3c0eeba36906a6a94130c243a41c65d5e98.tar.bz2
gsoc2013-evolution-7463b3c0eeba36906a6a94130c243a41c65d5e98.tar.lz
gsoc2013-evolution-7463b3c0eeba36906a6a94130c243a41c65d5e98.tar.xz
gsoc2013-evolution-7463b3c0eeba36906a6a94130c243a41c65d5e98.tar.zst
gsoc2013-evolution-7463b3c0eeba36906a6a94130c243a41c65d5e98.zip
New files with a derivative of ESearchBar that generates sexps for
2001-07-27 Federico Mena Quintero <federico@ximian.com> * gui/cal-search-bar.[ch]: New files with a derivative of ESearchBar that generates sexps for calendar queries directly. * gui/gnome-cal.c (setup_widgets): Use CalSearchBar instead of ESearchBar. * gui/e-calendar-table.h (ECalendarTable): Removed the ->colors array since it is handled by ETableExtras now. * gui/e-calendar-table.[ch]: Removed the subset_model. Now we use the live query facility to filter tasks. Removed the filter function stuff as well. * gui/e-tasks.c (e_tasks_construct): Use calendar_model_set_cal_client() directly instead of e_calendar_table_set_model(). (setup_widgets): Create a calendar search bar for the tasks component. (search_bar_sexp_changed_cb): Set the query sexp on the table model. (e_tasks_on_filter_selected): Regenerate the query from the selected category and the current sexp. (update_query): New convenience function to recompute the real query sexp. * gui/gnome-cal.c (gnome_calendar_construct): Likewise. * gui/e-calendar-table.c (e_calendar_table_set_cal_client): Removed function; people are now supposed to get the model from the calendar table and operate on it. * gui/calendar-commands.c (verbs): Consistency fixes with the XML file. (pixmaps): Likewise. * gui/Makefile.am (evolution_calendar_SOURCES): Added cal-search-bar.[ch] to the list of sources. 2001-07-20 Federico Mena Quintero <federico@ximian.com> * idl/evolution-calendar.idl (CompEditorFactory): New interface to a centralized factory for calendar component editors. Has editExisting() and editNew() methods to edit an existing component from a URI/UID pair, and to create a new component in a calendar that is in a particular URI, respectively. * gui/comp-editor-factory.[ch]: Implementation files for the component editor factory. * gui/GNOME_Evolution_Calendar.oaf.in: Added the CompEditorFactory stuff. * gui/Makefile.am (evolution_calendar_SOURCES): Added comp-editor-factory.[ch] to the list of sources. svn path=/trunk/; revision=11455
Diffstat (limited to 'calendar/gui/e-tasks.c')
-rw-r--r--calendar/gui/e-tasks.c93
1 files changed, 84 insertions, 9 deletions
diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c
index dbf7a7d779..e0a0b8ef8f 100644
--- a/calendar/gui/e-tasks.c
+++ b/calendar/gui/e-tasks.c
@@ -32,6 +32,7 @@
#include <gal/menus/gal-view-etable.h>
#include "widgets/menus/gal-view-menus.h"
#include "dialogs/task-editor.h"
+#include "cal-search-bar.h"
#include "calendar-config.h"
#include "component-factory.h"
@@ -50,10 +51,17 @@ struct _ETasksPrivate {
/* The ECalendarTable showing the tasks. */
GtkWidget *tasks_view;
+ /* Search bar for tasks and the current sexp */
+ GtkWidget *search_bar;
+ char *sexp;
+
/* The option menu showing the categories, and the popup menu. */
GtkWidget *categories_option_menu;
GtkWidget *categories_menu;
+ /* The category that is currently selected, used to filter out items */
+ char *category;
+
/* View collection and the view menus handler */
GalViewCollection *view_collection;
GalViewMenus *view_menus;
@@ -131,6 +139,9 @@ e_tasks_init (ETasks *tasks)
priv = g_new0 (ETasksPrivate, 1);
tasks->priv = priv;
+ priv->sexp = g_strdup ("#t"); /* Match all */
+ priv->category = NULL;
+
setup_widgets (tasks);
}
@@ -148,6 +159,51 @@ table_selection_change_cb (ETable *etable, gpointer data)
n_selected);
}
+/* Updates the query in the table model by composing the currently selected
+ * category with the current sexp.
+ */
+static void
+update_query (ETasks *tasks)
+{
+ ETasksPrivate *priv;
+ char *new_sexp;
+ gboolean free_new_sexp;
+ CalendarModel *model;
+
+ priv = tasks->priv;
+
+ g_assert (priv->sexp != NULL);
+
+ if (priv->category) {
+ new_sexp = g_strdup_printf ("(and %s (has-categories? \"%s\"))",
+ priv->sexp, priv->category);
+ free_new_sexp = TRUE;
+ } else {
+ new_sexp = priv->sexp;
+ free_new_sexp = FALSE;
+ }
+
+ model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
+ calendar_model_set_query (model, new_sexp);
+
+ if (free_new_sexp)
+ g_free (new_sexp);
+}
+
+/* Callback used when the sexp in the search bar changes */
+static void
+search_bar_sexp_changed_cb (CalSearchBar *cal_search, const char *sexp, gpointer data)
+{
+ ETasks *tasks;
+ ETasksPrivate *priv;
+
+ tasks = E_TASKS (data);
+ priv = tasks->priv;
+
+ priv->sexp = g_strdup (sexp);
+ update_query (tasks);
+}
+
#define E_TASKS_TABLE_DEFAULT_STATE \
"<?xml version=\"1.0\"?>" \
"<ETableState>" \
@@ -169,11 +225,17 @@ setup_widgets (ETasks *tasks)
priv = tasks->priv;
- hbox = gtk_hbox_new (FALSE, 0);
+ hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
gtk_widget_show (hbox);
gtk_table_attach (GTK_TABLE (tasks), hbox, 0, 1, 0, 1,
GTK_EXPAND | GTK_FILL, 0, 0, 0);
+ priv->search_bar = cal_search_bar_new ();
+ gtk_signal_connect (GTK_OBJECT (priv->search_bar), "sexp_changed",
+ GTK_SIGNAL_FUNC (search_bar_sexp_changed_cb), tasks);
+ gtk_box_pack_start (GTK_BOX (hbox), priv->search_bar, TRUE, TRUE, 0);
+ gtk_widget_show (priv->search_bar);
+
priv->categories_option_menu = gtk_option_menu_new ();
gtk_widget_show (priv->categories_option_menu);
gtk_box_pack_end (GTK_BOX (hbox), priv->categories_option_menu,
@@ -215,6 +277,7 @@ GtkWidget *
e_tasks_construct (ETasks *tasks)
{
ETasksPrivate *priv;
+ CalendarModel *model;
g_return_val_if_fail (tasks != NULL, NULL);
g_return_val_if_fail (E_IS_TASKS (tasks), NULL);
@@ -232,8 +295,10 @@ e_tasks_construct (ETasks *tasks)
gtk_signal_connect (GTK_OBJECT (priv->client), "obj_removed",
GTK_SIGNAL_FUNC (obj_removed_cb), tasks);
- e_calendar_table_set_cal_client (E_CALENDAR_TABLE (priv->tasks_view),
- priv->client);
+ model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
+ g_assert (model != NULL);
+
+ calendar_model_set_cal_client (model, priv->client, CALOBJ_TYPE_TODO);
return GTK_WIDGET (tasks);
}
@@ -271,6 +336,15 @@ e_tasks_destroy (GtkObject *object)
tasks = E_TASKS (object);
priv = tasks->priv;
+ g_assert (priv->sexp != NULL);
+ g_free (priv->sexp);
+ priv->sexp = NULL;
+
+ if (priv->category) {
+ g_free (priv->category);
+ priv->category = NULL;
+ }
+
/* Save the ETable layout. */
config_filename = e_tasks_get_config_filename (tasks);
e_calendar_table_save_state (E_CALENDAR_TABLE (priv->tasks_view),
@@ -497,7 +571,6 @@ e_tasks_delete_selected (ETasks *tasks)
e_calendar_table_delete_selected (cal_table);
}
-
static void
e_tasks_on_filter_selected (GtkMenuShell *menu_shell,
ETasks *tasks)
@@ -518,16 +591,18 @@ e_tasks_on_filter_selected (GtkMenuShell *menu_shell,
cal_table = E_CALENDAR_TABLE (priv->tasks_view);
model = cal_table->model;
+ if (priv->category)
+ g_free (priv->category);
+
if (!strcmp (category, _("All"))) {
calendar_model_set_default_category (model, NULL);
- e_calendar_table_set_filter_func (cal_table, NULL, NULL,
- NULL);
+ priv->category = NULL;
} else {
calendar_model_set_default_category (model, category);
- e_calendar_table_set_filter_func (cal_table,
- e_calendar_table_filter_by_category,
- g_strdup (category), g_free);
+ priv->category = g_strdup (category);
}
+
+ update_query (tasks);
}