aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/gui/Makefile.am2
-rw-r--r--calendar/gui/e-cal-component-preview.c322
-rw-r--r--calendar/gui/e-cal-component-preview.h63
-rw-r--r--calendar/gui/e-memo-preview.c356
-rw-r--r--calendar/gui/e-memo-preview.h84
-rw-r--r--calendar/modules/e-cal-shell-module.c2
-rw-r--r--calendar/modules/e-cal-shell-view.c1
-rw-r--r--calendar/modules/e-memo-shell-content.c28
-rw-r--r--calendar/modules/e-memo-shell-content.h5
-rw-r--r--calendar/modules/e-memo-shell-module.c2
-rw-r--r--calendar/modules/e-memo-shell-view-actions.c8
-rw-r--r--calendar/modules/e-memo-shell-view-private.c23
-rw-r--r--calendar/modules/e-memo-shell-view-private.h12
-rw-r--r--calendar/modules/e-memo-shell-view.c1
-rw-r--r--calendar/modules/e-task-shell-content.c28
-rw-r--r--calendar/modules/e-task-shell-module.c76
-rw-r--r--calendar/modules/e-task-shell-view-actions.c410
-rw-r--r--calendar/modules/e-task-shell-view-actions.h46
-rw-r--r--calendar/modules/e-task-shell-view-private.c247
-rw-r--r--calendar/modules/e-task-shell-view-private.h33
-rw-r--r--calendar/modules/e-task-shell-view.c142
21 files changed, 963 insertions, 928 deletions
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
index 7cf356add8..1edc28d0a7 100644
--- a/calendar/gui/Makefile.am
+++ b/calendar/gui/Makefile.am
@@ -135,8 +135,6 @@ libcal_gui_la_SOURCES = \
e-meeting-types.h \
e-meeting-utils.c \
e-meeting-utils.h \
- e-memo-preview.c \
- e-memo-preview.h \
e-memo-table.c \
e-memo-table.h \
e-memo-table-config.c \
diff --git a/calendar/gui/e-cal-component-preview.c b/calendar/gui/e-cal-component-preview.c
index 853183bf53..8d3a903119 100644
--- a/calendar/gui/e-cal-component-preview.c
+++ b/calendar/gui/e-cal-component-preview.c
@@ -22,48 +22,48 @@
*
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "e-cal-component-preview.h"
#include <string.h>
-#include <gio/gio.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
-#include <libgnome/gnome-url.h>
-#include <libedataserver/e-categories.h>
#include <libecal/e-cal-time-util.h>
-#include <gtkhtml/gtkhtml.h>
+#include <libedataserver/e-categories.h>
#include <gtkhtml/gtkhtml-stream.h>
#include <libedataserver/e-time-utils.h>
#include <e-util/e-categories-config.h>
#include "calendar-config.h"
-#include "e-cal-component-preview.h"
#include <camel/camel-mime-filter-tohtml.h>
-struct _ECalComponentPreviewPrivate {
- GtkWidget *html;
+#define E_CAL_COMPONENT_PREVIEW_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_CAL_COMPONENT_PREVIEW, ECalComponentPreviewPrivate))
+struct _ECalComponentPreviewPrivate {
icaltimezone *zone;
};
-G_DEFINE_TYPE (ECalComponentPreview, e_cal_component_preview, GTK_TYPE_TABLE)
+static gpointer parent_class;
static void
-on_link_clicked (GtkHTML *html, const char *url, gpointer data)
+cal_component_preview_link_clicked (GtkHTML *html,
+ const gchar *url)
{
- GError *err = NULL;
+ GdkScreen *screen;
+ GError *error = NULL;
- gnome_url_show (url, &err);
+ screen = gtk_widget_get_screen (GTK_WIDGET (html));
+ gtk_show_uri (screen, url, GDK_CURRENT_TIME, &error);
- if (err) {
- g_warning ("gnome_url_show: %s", err->message);
- g_error_free (err);
+ if (error != NULL) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
}
}
static void
-on_url_cb (GtkHTML *html, const char *url, gpointer data)
+cal_component_preview_on_url (GtkHTML *html,
+ const gchar *url)
{
#if 0
char *msg;
@@ -78,51 +78,11 @@ on_url_cb (GtkHTML *html, const char *url, gpointer data)
#endif
}
-/* Callback used when the user selects a URL in the HTML widget */
-void
-e_cal_comp_preview_url_requested_cb (GtkHTML *html, const char *url, GtkHTMLStream *html_stream, gpointer data)
-{
- int len = strlen ("file:///");
-
- if (!strncmp ("file:///", url, len)) {
- GFile *file;
- const char *path = url + len - 1;
-
- g_return_if_fail (html_stream != NULL);
- g_return_if_fail (path != NULL);
-
- file = g_file_new_for_path (path);
- if (file) {
- char buffer[4096];
- GInputStream *stream;
-
- /* ignore errors here */
- stream = G_INPUT_STREAM (g_file_read (file, NULL, NULL));
-
- if (stream) {
- gssize bread;
-
- do {
- /* ignore errors here as well */
- bread = g_input_stream_read (stream, buffer, sizeof (buffer), NULL, NULL);
- if (bread > 0)
- gtk_html_stream_write (html_stream, buffer, bread);
- } while (bread > 0);
-
- g_input_stream_close (stream, NULL, NULL);
- g_object_unref (stream);
-
- gtk_html_stream_close (html_stream, GTK_HTML_STREAM_OK);
- }
-
- g_object_unref (file);
- }
- }
-}
-
/* Converts a time_t to a string, relative to the specified timezone */
static char *
-timet_to_str_with_zone (ECalComponentDateTime *dt, ECal *ecal, icaltimezone *default_zone)
+timet_to_str_with_zone (ECalComponentDateTime *dt,
+ ECal *ecal,
+ icaltimezone *default_zone)
{
struct icaltimetype itt;
icaltimezone *zone;
@@ -152,12 +112,18 @@ timet_to_str_with_zone (ECalComponentDateTime *dt, ECal *ecal, icaltimezone *def
}
static void
-write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone *default_zone)
+cal_component_preview_write_html (GtkHTMLStream *stream,
+ ECal *ecal,
+ ECalComponent *comp,
+ icaltimezone *default_zone)
{
ECalComponentText text;
ECalComponentDateTime dt;
gchar *str;
- GSList *l;
+ GString *string;
+ GSList *list, *iter;
+ icalcomponent *icalcomp;
+ icalproperty *icalprop;
icalproperty_status status;
const char *location;
int *priority_value;
@@ -176,28 +142,34 @@ write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone
"<HTML><BODY><H1><I>%s</I></H1>",
_("Untitled"));
-
/* write icons for the categories */
- e_cal_component_get_categories_list (comp, &l);
- if (l) {
- GSList *node;
-
- for (node = l; node != NULL; node = node->next) {
- const char *icon_file;
-
- icon_file = e_categories_get_icon_file_for ((const char *) node->data);
- if (icon_file) {
- gchar *icon_file_uri = g_filename_to_uri (icon_file, NULL, NULL);
- gtk_html_stream_printf (stream, "<IMG ALT=\"%s\" SRC=\"%s\">",
- (const char *) node->data, icon_file_uri);
- g_free (icon_file_uri);
- }
+ string = g_string_new (NULL);
+ e_cal_component_get_categories_list (comp, &list);
+ if (list != NULL)
+ gtk_html_stream_printf (stream, "<H3>%s ", _("Categories:"));
+ for (iter = list; iter != NULL; iter = iter->next) {
+ const gchar *category = iter->data;
+ const gchar *icon_file;
+
+ icon_file = e_categories_get_icon_file_for (category);
+ if (icon_file && g_file_test (icon_file, G_FILE_TEST_EXISTS)) {
+ gchar *uri;
+
+ uri = g_filename_to_uri (icon_file, NULL, NULL);
+ gtk_html_stream_printf (
+ stream, "<IMG ALT=\"%s\" SRC=\"%s\">",
+ category, uri);
+ g_free (uri);
+ } else {
+ if (iter != list)
+ g_string_append_len (string, ", ", 2);
+ g_string_append (string, category);
}
-
- e_cal_component_free_categories_list (l);
-
- gtk_html_stream_printf (stream, "<BR><BR><BR>");
}
+ if (string->len > 0)
+ gtk_html_stream_printf (stream, "%s</H3>", string->str);
+ e_cal_component_free_categories_list (list);
+ g_string_free (string, TRUE);
/* Start table */
gtk_html_stream_printf (stream, "<TABLE BORDER=\"0\" WIDTH=\"80%%\">"
@@ -243,26 +215,31 @@ write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone
e_cal_component_free_datetime (&dt);
/* write status */
- gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Status:"));
- e_cal_component_get_status (comp, &status);
- switch (status) {
- case ICAL_STATUS_INPROCESS :
- str = g_strdup (_("In Progress"));
- break;
- case ICAL_STATUS_COMPLETED :
- str = g_strdup (_("Completed"));
- break;
- case ICAL_STATUS_CANCELLED :
- str = g_strdup (_("Canceled"));
- break;
- case ICAL_STATUS_NONE :
- default :
- str = g_strdup (_("Not Started"));
- break;
- }
+ icalcomp = e_cal_component_get_icalcomponent (comp);
+ icalprop = icalcomponent_get_first_property (
+ icalcomp, ICAL_STATUS_PROPERTY);
+ if (icalprop != NULL) {
+ gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Status:"));
+ e_cal_component_get_status (comp, &status);
+ switch (status) {
+ case ICAL_STATUS_INPROCESS :
+ str = g_strdup (_("In Progress"));
+ break;
+ case ICAL_STATUS_COMPLETED :
+ str = g_strdup (_("Completed"));
+ break;
+ case ICAL_STATUS_CANCELLED :
+ str = g_strdup (_("Canceled"));
+ break;
+ case ICAL_STATUS_NONE :
+ default :
+ str = g_strdup (_("Not Started"));
+ break;
+ }
- gtk_html_stream_printf (stream, "<TD>%s</TD></TR>", str);
- g_free (str);
+ gtk_html_stream_printf (stream, "<TD>%s</TD></TR>", str);
+ g_free (str);
+ }
/* write priority */
e_cal_component_get_priority (comp, &priority_value);
@@ -284,15 +261,15 @@ write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone
/* write description and URL */
gtk_html_stream_printf (stream, "<TR><TD COLSPAN=\"2\"><HR></TD></TR>");
- e_cal_component_get_description_list (comp, &l);
- if (l) {
+ e_cal_component_get_description_list (comp, &list);
+ if (list) {
GSList *node;
gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Description:"));
gtk_html_stream_printf (stream, "<TD><TT>");
- for (node = l; node != NULL; node = node->next) {
+ for (node = list; node != NULL; node = node->next) {
char *html;
text = * (ECalComponentText *) node->data;
@@ -306,7 +283,7 @@ write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone
gtk_html_stream_printf (stream, "</TT></TD></TR>");
- e_cal_component_free_text_list (l);
+ e_cal_component_free_text_list (list);
}
/* URL */
@@ -323,135 +300,120 @@ write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone
}
static void
-e_cal_component_preview_init (ECalComponentPreview *preview)
+cal_component_preview_finalize (GObject *object)
{
ECalComponentPreviewPrivate *priv;
- GtkWidget *scroll;
- priv = g_new0 (ECalComponentPreviewPrivate, 1);
- preview->priv = priv;
+ priv = E_CAL_COMPONENT_PREVIEW_GET_PRIVATE (object);
+
+ /* XXX Nothing to do? */
- priv->html = gtk_html_new ();
- gtk_html_set_default_content_type (GTK_HTML (priv->html), "charset=utf-8");
- gtk_html_load_empty (GTK_HTML (priv->html));
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
- g_signal_connect (G_OBJECT (priv->html), "url_requested",
- G_CALLBACK (e_cal_comp_preview_url_requested_cb), NULL);
- g_signal_connect (G_OBJECT (priv->html), "link_clicked",
- G_CALLBACK (on_link_clicked), preview);
- g_signal_connect (G_OBJECT (priv->html), "on_url",
- G_CALLBACK (on_url_cb), preview);
+static void
+cal_component_preview_class_init (ECalComponentPreviewClass *class)
+{
+ GObjectClass *object_class;
+ GtkHTMLClass *gtkhtml_class;
- scroll = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN);
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (ECalComponentPreviewPrivate));
- gtk_container_add (GTK_CONTAINER (scroll), priv->html);
- gtk_container_add (GTK_CONTAINER (preview), scroll);
- gtk_widget_show_all (scroll);
+ object_class = G_OBJECT_CLASS (class);
+ object_class->finalize = cal_component_preview_finalize;
- priv->zone = icaltimezone_get_utc_timezone ();
+ gtkhtml_class = GTK_HTML_CLASS (class);
+ gtkhtml_class->link_clicked = cal_component_preview_link_clicked;
+ gtkhtml_class->on_url = cal_component_preview_on_url;
}
static void
-e_cal_component_preview_destroy (GtkObject *object)
+cal_component_preview_init (ECalComponentPreview *preview)
{
- ECalComponentPreview *preview;
ECalComponentPreviewPrivate *priv;
+ GtkHTML *html;
- g_return_if_fail (object != NULL);
- g_return_if_fail (E_IS_CAL_COMPONENT_PREVIEW (object));
+ preview->priv = E_CAL_COMPONENT_PREVIEW_GET_PRIVATE (preview);
- preview = E_CAL_COMPONENT_PREVIEW (object);
- priv = preview->priv;
+ html = GTK_HTML (preview);
+ gtk_html_set_default_content_type (html, "charset=utf-8");
+ gtk_html_load_empty (html);
- if (priv) {
-
- g_free (priv);
- preview->priv = NULL;
- }
-
- if (GTK_OBJECT_CLASS (e_cal_component_preview_parent_class)->destroy)
- (* GTK_OBJECT_CLASS (e_cal_component_preview_parent_class)->destroy) (object);
+ priv->zone = icaltimezone_get_utc_timezone ();
}
-static void
-e_cal_component_preview_class_init (ECalComponentPreviewClass *klass)
+GType
+e_cal_component_preview_get_type (void)
{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass *) klass;
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (ECalComponentPreviewClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) cal_component_preview_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (ECalComponentPreview),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) cal_component_preview_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ GTK_TYPE_HTML, "ECalComponentPreview", &type_info, 0);
+ }
- object_class->destroy = e_cal_component_preview_destroy;
+ return type;
}
GtkWidget *
e_cal_component_preview_new (void)
{
- ECalComponentPreview *preview;
-
- preview = g_object_new (e_cal_component_preview_get_type (), NULL);
-
- return GTK_WIDGET (preview);
+ return g_object_new (E_TYPE_CAL_COMPONENT_PREVIEW, NULL);
}
icaltimezone *
e_cal_component_preview_get_default_timezone (ECalComponentPreview *preview)
{
- ECalComponentPreviewPrivate *priv;
-
- g_return_val_if_fail (preview != NULL, NULL);
g_return_val_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview), NULL);
- priv = preview->priv;
-
- return priv->zone;
+ return preview->priv->zone;
}
void
-e_cal_component_preview_set_default_timezone (ECalComponentPreview *preview, icaltimezone *zone)
+e_cal_component_preview_set_default_timezone (ECalComponentPreview *preview,
+ icaltimezone *zone)
{
- ECalComponentPreviewPrivate *priv;
-
- g_return_if_fail (preview != NULL);
g_return_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview));
g_return_if_fail (zone != NULL);
- priv = preview->priv;
-
- priv->zone = zone;
+ preview->priv->zone = zone;
}
void
-e_cal_component_preview_display (ECalComponentPreview *preview, ECal *ecal, ECalComponent *comp)
+e_cal_component_preview_display (ECalComponentPreview *preview,
+ ECal *ecal,
+ ECalComponent *comp)
{
- ECalComponentPreviewPrivate *priv;
GtkHTMLStream *stream;
- g_return_if_fail (preview != NULL);
g_return_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview));
- g_return_if_fail (comp != NULL);
g_return_if_fail (E_IS_CAL_COMPONENT (comp));
- priv = preview->priv;
-
- stream = gtk_html_begin (GTK_HTML (priv->html));
- write_html (stream, ecal, comp, priv->zone);
+ stream = gtk_html_begin (GTK_HTML (preview));
+ cal_component_preview_write_html (
+ stream, ecal, comp, preview->priv->zone);
gtk_html_stream_close (stream, GTK_HTML_STREAM_OK);
}
void
e_cal_component_preview_clear (ECalComponentPreview *preview)
{
- ECalComponentPreviewPrivate *priv;
-
- g_return_if_fail (preview != NULL);
g_return_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview));
- priv = preview->priv;
-
- gtk_html_load_empty (GTK_HTML (priv->html));
+ gtk_html_load_empty (GTK_HTML (preview));
}
-
diff --git a/calendar/gui/e-cal-component-preview.h b/calendar/gui/e-cal-component-preview.h
index e5cc98109c..dd04019e44 100644
--- a/calendar/gui/e-cal-component-preview.h
+++ b/calendar/gui/e-cal-component-preview.h
@@ -1,5 +1,4 @@
/*
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -22,51 +21,63 @@
*
*/
-#ifndef _E_CAL_COMPONENT_PREVIEW_H_
-#define _E_CAL_COMPONENT_PREVIEW_H_
+#ifndef E_CAL_COMPONENT_PREVIEW_H
+#define E_CAL_COMPONENT_PREVIEW_H
#include <gtk/gtk.h>
#include <libecal/e-cal.h>
#include <gtkhtml/gtkhtml.h>
-#include <gtkhtml/gtkhtml-stream.h>
-#define E_TYPE_CAL_COMPONENT_PREVIEW (e_cal_component_preview_get_type ())
-#define E_CAL_COMPONENT_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CAL_COMPONENT_PREVIEW, ECalComponentPreview))
-#define E_CAL_COMPONENT_PREVIEW_CLASS(klass) (G_TYPE_CHECK_INSTANCE_CAST_CLASS ((klass), E_TYPE_CAL_COMPONENT_PREVIEW, \
- ECalComponentPreviewClass))
-#define E_IS_CAL_COMPONENT_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CAL_COMPONENT_PREVIEW))
-#define E_IS_CAL_COMPONENT_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_CAL_COMPONENT_PREVIEW))
+/* Standard GObject macros */
+#define E_TYPE_CAL_COMPONENT_PREVIEW \
+ (e_cal_component_preview_get_type ())
+#define E_CAL_COMPONENT_PREVIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_CAL_COMPONENT_PREVIEW, ECalComponentPreview))
+#define E_CAL_COMPONENT_PREVIEW_CLASS(cls) \
+ (G_TYPE_CHECK_INSTANCE_CAST_CLASS \
+ ((cls), E_TYPE_CAL_COMPONENT_PREVIEW, ECalComponentPreviewClass))
+#define E_IS_CAL_COMPONENT_PREVIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_CAL_COMPONENT_PREVIEW))
+#define E_IS_CAL_COMPONENT_PREVIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_CAL_COMPONENT_PREVIEW))
+#define E_CAL_COMPONENT_PREVIEW_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_CAL_COMPONENT_PREVIEW, ECalComponentPreviewClass))
+
+G_BEGIN_DECLS
typedef struct _ECalComponentPreview ECalComponentPreview;
typedef struct _ECalComponentPreviewClass ECalComponentPreviewClass;
typedef struct _ECalComponentPreviewPrivate ECalComponentPreviewPrivate;
struct _ECalComponentPreview {
- GtkTable table;
-
- /* Private data */
+ GtkHTML parent;
ECalComponentPreviewPrivate *priv;
};
struct _ECalComponentPreviewClass {
- GtkTableClass parent_class;
+ GtkHTMLClass parent_class;
/* Notification signals */
void (* selection_changed) (ECalComponentPreview *preview, int n_selected);
};
-GType e_cal_component_preview_get_type (void);
-GtkWidget *e_cal_component_preview_new (void);
-
-icaltimezone *e_cal_component_preview_get_default_timezone (ECalComponentPreview *preview);
-void e_cal_component_preview_set_default_timezone (ECalComponentPreview *preview, icaltimezone *zone);
-
-void e_cal_component_preview_display (ECalComponentPreview *preview, ECal *ecal, ECalComponent *comp);
-void e_cal_component_preview_clear (ECalComponentPreview *preview);
-
-/* Callback used when GtkHTML widget requests URL */
-void e_cal_comp_preview_url_requested_cb (GtkHTML *html, const char *url, GtkHTMLStream *html_stream, gpointer data);
+GType e_cal_component_preview_get_type(void);
+GtkWidget * e_cal_component_preview_new (void);
+icaltimezone * e_cal_component_preview_get_default_timezone
+ (ECalComponentPreview *preview);
+void e_cal_component_preview_set_default_timezone
+ (ECalComponentPreview *preview,
+ icaltimezone *zone);
+void e_cal_component_preview_display (ECalComponentPreview *preview,
+ ECal *ecal,
+ ECalComponent *comp);
+void e_cal_component_preview_clear (ECalComponentPreview *preview);
+G_END_DECLS
-#endif /* _E_CAL_COMPONENT_PREVIEW_H_ */
+#endif /* E_CAL_COMPONENT_PREVIEW_H */
diff --git a/calendar/gui/e-memo-preview.c b/calendar/gui/e-memo-preview.c
deleted file mode 100644
index f5b725c02f..0000000000
--- a/calendar/gui/e-memo-preview.c
+++ /dev/null
@@ -1,356 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-tasks.c
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * Authors: Federico Mena Quintero <federico@ximian.com>
- * Damon Chaplin <damon@ximian.com>
- * Rodrigo Moya <rodrigo@ximian.com>
- * Nathan Owens <pianocomp81@yahoo.com>
- */
-
-#include "e-memo-preview.h"
-
-#include <string.h>
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-#include <libecal/e-cal-time-util.h>
-#include <libedataserver/e-categories.h>
-#include <gtkhtml/gtkhtml-stream.h>
-#include <libedataserver/e-time-utils.h>
-#include <e-util/e-categories-config.h>
-#include "calendar-config.h"
-#include "e-cal-component-preview.h"
-#include <camel/camel-mime-filter-tohtml.h>
-
-#define E_MEMO_PREVIEW_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_MEMO_PREVIEW, EMemoPreviewPrivate))
-
-struct _EMemoPreviewPrivate {
- icaltimezone *zone;
-};
-
-static gpointer parent_class;
-
-static void
-memo_preview_link_clicked (GtkHTML *html,
- const gchar *url)
-{
- GdkScreen *screen;
- GError *error = NULL;
-
- screen = gtk_widget_get_screen (GTK_WIDGET (html));
- gtk_show_uri (screen, url, GDK_CURRENT_TIME, &error);
-
- if (error != NULL) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-}
-
-static void
-memo_preview_on_url (GtkHTML *html,
- const gchar *url)
-{
-#if 0
- char *msg;
- EMemoPreview *preview = data;
-
- if (url && *url) {
- msg = g_strdup_printf (_("Click to open %s"), url);
- e_calendar_table_set_status_message (e_tasks_get_calendar_table (tasks), msg);
- g_free (msg);
- } else
- e_calendar_table_set_status_message (e_tasks_get_calendar_table (tasks), NULL);
-#endif
-}
-
-/* Converts a time_t to a string, relative to the specified timezone */
-static char *
-timet_to_str_with_zone (ECalComponentDateTime *dt,
- ECal *ecal,
- icaltimezone *default_zone)
-{
- struct icaltimetype itt;
- icaltimezone *zone;
- struct tm tm;
- char buf[256];
-
- if (dt->tzid) {
- /* If we can't find the zone, we'll guess its "local" */
- if (!e_cal_get_timezone (ecal, dt->tzid, &zone, NULL))
- zone = NULL;
- } else if (dt->value->is_utc) {
- zone = icaltimezone_get_utc_timezone ();
- } else {
- zone = NULL;
- }
-
-
- itt = *dt->value;
- if (zone)
- icaltimezone_convert_time (&itt, zone, default_zone);
- tm = icaltimetype_to_tm (&itt);
-
- e_time_format_date_and_time (&tm, calendar_config_get_24_hour_format (),
- FALSE, FALSE, buf, sizeof (buf));
-
- return g_locale_to_utf8 (buf, -1, NULL, NULL, NULL);
-}
-
-static void
-memo_preview_write_html (GtkHTMLStream *stream,
- ECal *ecal,
- ECalComponent *comp,
- icaltimezone *default_zone)
-{
- ECalComponentText text;
- ECalComponentDateTime dt;
- gchar *str;
- GSList *l;
- gboolean one_added = FALSE;
-
- g_return_if_fail (E_IS_CAL_COMPONENT (comp));
-
- /* write document header */
- e_cal_component_get_summary (comp, &text);
-
- if (text.value)
- gtk_html_stream_printf (stream,
- "<HTML><BODY><H1>%s</H1>",
- text.value);
- else
- gtk_html_stream_printf (stream,
- "<HTML><BODY><H1><I>%s</I></H1>",
- _("Untitled"));
-
- /* write icons for the categories */
- e_cal_component_get_categories_list (comp, &l);
- if (l) {
- GSList *node;
- GString *string = g_string_new (NULL);
-
-
- gtk_html_stream_printf(stream, "<H3>%s: ", _("Categories"));
-
- for (node = l; node != NULL; node = node->next) {
- const char *icon_file;
-
- icon_file = e_categories_get_icon_file_for ((const char *) node->data);
- if (icon_file && g_file_test(icon_file, G_FILE_TEST_EXISTS)) {
- gchar *icon_file_uri = g_filename_to_uri (icon_file, NULL, NULL);
- gtk_html_stream_printf (stream, "<IMG ALT=\"%s\" SRC=\"%s\">",
- (const char *) node->data, icon_file_uri);
- g_free (icon_file_uri);
- one_added = TRUE;
- }
- else{
- if(one_added == FALSE){
- g_string_append_printf (string, "%s", (const char *) node->data);
- one_added = TRUE;
- }
- else{
- g_string_append_printf (string, ", %s", (const char *) node->data);
- }
- }
- }
-
- if (string->len > 0)
- gtk_html_stream_printf(stream, "%s", string->str);
-
- g_string_free (string, TRUE);
-
- gtk_html_stream_printf(stream, "</H3>");
-
- e_cal_component_free_categories_list (l);
- }
-
- /* Start table */
- gtk_html_stream_printf (stream, "<TABLE BORDER=\"0\" WIDTH=\"80%%\">"
- "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\" WIDTH=\"15%%\"></TD></TR>");
-
- /* write start date */
- e_cal_component_get_dtstart (comp, &dt);
- if (dt.value != NULL) {
- str = timet_to_str_with_zone (&dt, ecal, default_zone);
- gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD><TD>%s</TD></TR>",
- _("Start Date:"), str);
-
- g_free (str);
- }
- e_cal_component_free_datetime (&dt);
-
- /* write description and URL */
- gtk_html_stream_printf (stream, "<TR><TD COLSPAN=\"2\"><HR></TD></TR>");
-
- e_cal_component_get_description_list (comp, &l);
- if (l) {
- GSList *node;
-
- gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Description:"));
-
- gtk_html_stream_printf (stream, "<TD><TT>");
-
- for (node = l; node != NULL; node = node->next) {
- char *html;
-
- text = * (ECalComponentText *) node->data;
- html = camel_text_to_html (text.value ? text.value : "", CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES | CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES, 0);
-
- if (html)
- gtk_html_stream_printf (stream, "%s", html);
-
- g_free (html);
- }
-
- gtk_html_stream_printf (stream, "</TT></TD></TR>");
-
- e_cal_component_free_text_list (l);
- }
-
- /* URL */
- e_cal_component_get_url (comp, (const char **) &str);
- if (str) {
- gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Web Page:"));
- gtk_html_stream_printf (stream, "<TD><A HREF=\"%s\">%s</A></TD></TR>", str, str);
- }
-
- gtk_html_stream_printf (stream, "</TABLE>");
-
- /* close document */
- gtk_html_stream_printf (stream, "</BODY></HTML>");
-}
-
-static void
-memo_preview_finalize (GObject *object)
-{
- EMemoPreviewPrivate *priv;
-
- priv = E_MEMO_PREVIEW_GET_PRIVATE (object);
-
- /* XXX Nothing to do? */
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-memo_preview_class_init (EMemoPreviewClass *class)
-{
- GObjectClass *object_class;
- GtkHTMLClass *gtkhtml_class;
-
- parent_class = g_type_class_peek_parent (class);
- g_type_class_add_private (class, sizeof (EMemoPreviewPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->finalize = memo_preview_finalize;
-
- gtkhtml_class = GTK_HTML_CLASS (class);
- gtkhtml_class->link_clicked = memo_preview_link_clicked;
- gtkhtml_class->on_url = memo_preview_on_url;
-}
-
-static void
-memo_preview_init (EMemoPreview *preview)
-{
- EMemoPreviewPrivate *priv;
- GtkHTML *html;
-
- preview->priv = E_MEMO_PREVIEW_GET_PRIVATE (preview);
-
- html = GTK_HTML (preview);
- gtk_html_set_default_content_type (html, "charset=utf-8");
- gtk_html_load_empty (html);
-
- priv->zone = icaltimezone_get_utc_timezone ();
-}
-
-GType
-e_memo_preview_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- static const GTypeInfo type_info = {
- sizeof (EMemoPreviewClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) memo_preview_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class_data */
- sizeof (EMemoPreview),
- 0, /* n_preallocs */
- (GInstanceInitFunc) memo_preview_init,
- NULL /* value_table */
- };
-
- type = g_type_register_static (
- GTK_TYPE_HTML, "EMemoPreview", &type_info, 0);
- }
-
- return type;
-}
-
-GtkWidget *
-e_memo_preview_new (void)
-{
- return g_object_new (E_TYPE_MEMO_PREVIEW, NULL);
-}
-
-icaltimezone *
-e_memo_preview_get_default_timezone (EMemoPreview *preview)
-{
- g_return_val_if_fail (E_IS_MEMO_PREVIEW (preview), NULL);
-
- return preview->priv->zone;
-}
-
-void
-e_memo_preview_set_default_timezone (EMemoPreview *preview,
- icaltimezone *zone)
-{
- g_return_if_fail (E_IS_MEMO_PREVIEW (preview));
- g_return_if_fail (zone != NULL);
-
- preview->priv->zone = zone;
-}
-
-void
-e_memo_preview_display (EMemoPreview *preview,
- ECal *ecal,
- ECalComponent *comp)
-{
- GtkHTMLStream *stream;
-
- g_return_if_fail (E_IS_MEMO_PREVIEW (preview));
- g_return_if_fail (E_IS_CAL_COMPONENT (comp));
-
- stream = gtk_html_begin (GTK_HTML (preview));
- memo_preview_write_html (stream, ecal, comp, preview->priv->zone);
- gtk_html_stream_close (stream, GTK_HTML_STREAM_OK);
-}
-
-void
-e_memo_preview_clear (EMemoPreview *preview)
-{
- g_return_if_fail (E_IS_MEMO_PREVIEW (preview));
-
- gtk_html_load_empty (GTK_HTML (preview));
-}
-
diff --git a/calendar/gui/e-memo-preview.h b/calendar/gui/e-memo-preview.h
deleted file mode 100644
index 50d509e705..0000000000
--- a/calendar/gui/e-memo-preview.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Federico Mena Quintero <federico@ximian.com>
- * Damon Chaplin <damon@ximian.com>
- * Nathan Owens <pianocomp81@yahoo.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_MEMO_PREVIEW_H
-#define E_MEMO_PREVIEW_H
-
-#include <gtk/gtk.h>
-#include <libecal/e-cal.h>
-#include <gtkhtml/gtkhtml.h>
-
-/* Standard GObject macros */
-#define E_TYPE_MEMO_PREVIEW \
- (e_memo_preview_get_type ())
-#define E_MEMO_PREVIEW(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_MEMO_PREVIEW, EMemoPreview))
-#define E_MEMO_PREVIEW_CLASS(cls) \
- (G_TYPE_CHECK_INSTANCE_CAST_CLASS \
- ((cls), E_TYPE_MEMO_PREVIEW, EMemoPreviewClass))
-#define E_IS_MEMO_PREVIEW(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_MEMO_PREVIEW))
-#define E_IS_MEMO_PREVIEW_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_MEMO_PREVIEW))
-#define E_MEMO_PREVIEW_GET_CLASS \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_MEMO_PREVIEW, EMemoPreviewClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EMemoPreview EMemoPreview;
-typedef struct _EMemoPreviewClass EMemoPreviewClass;
-typedef struct _EMemoPreviewPrivate EMemoPreviewPrivate;
-
-struct _EMemoPreview {
- GtkHTML parent;
- EMemoPreviewPrivate *priv;
-};
-
-struct _EMemoPreviewClass {
- GtkHTMLClass parent_class;
-
- /* Notification signals */
- void (*selection_changed) (EMemoPreview *preview, int n_selected);
-};
-
-
-GType e_memo_preview_get_type (void);
-GtkWidget * e_memo_preview_new (void);
-icaltimezone * e_memo_preview_get_default_timezone
- (EMemoPreview *preview);
-void e_memo_preview_set_default_timezone
- (EMemoPreview *preview,
- icaltimezone *zone);
-void e_memo_preview_display (EMemoPreview *preview,
- ECal *ecal,
- ECalComponent *comp);
-void e_memo_preview_clear (EMemoPreview *preview);
-
-G_END_DECLS
-
-#endif /* E_MEMO_PREVIEW_H */
diff --git a/calendar/modules/e-cal-shell-module.c b/calendar/modules/e-cal-shell-module.c
index a655774c39..f5cdbe0f48 100644
--- a/calendar/modules/e-cal-shell-module.c
+++ b/calendar/modules/e-cal-shell-module.c
@@ -37,7 +37,6 @@
#define MODULE_NAME "calendar"
#define MODULE_ALIASES ""
#define MODULE_SCHEMES "calendar"
-#define MODULE_SEARCHES "caltypes.xml"
#define MODULE_SORT_ORDER 400
#define CONTACTS_BASE_URI "contacts://"
@@ -371,7 +370,6 @@ static EShellModuleInfo module_info = {
MODULE_NAME,
MODULE_ALIASES,
MODULE_SCHEMES,
- MODULE_SEARCHES,
MODULE_SORT_ORDER
};
diff --git a/calendar/modules/e-cal-shell-view.c b/calendar/modules/e-cal-shell-view.c
index 30c2ce8272..06e433be31 100644
--- a/calendar/modules/e-cal-shell-view.c
+++ b/calendar/modules/e-cal-shell-view.c
@@ -107,6 +107,7 @@ cal_shell_view_class_init (ECalShellView *class,
shell_view_class->icon_name = "evolution-cals";
shell_view_class->ui_definition = "evolution-calendars.ui";
shell_view_class->search_options = "/calendar-search-options";
+ shell_view_class->search_rules = "caltypes.xml";
shell_view_class->type_module = type_module;
shell_view_class->new_shell_sidebar = e_cal_shell_sidebar_new;
shell_view_class->update_actions = cal_shell_view_update_actions;
diff --git a/calendar/modules/e-memo-shell-content.c b/calendar/modules/e-memo-shell-content.c
index d893e47b43..ba3650d141 100644
--- a/calendar/modules/e-memo-shell-content.c
+++ b/calendar/modules/e-memo-shell-content.c
@@ -131,18 +131,19 @@ memo_shell_content_cursor_change_cb (EMemoShellContent *memo_shell_content,
gint row,
ETable *table)
{
- EMemoPreview *memo_preview;
+ ECalComponentPreview *memo_preview;
EMemoTable *memo_table;
ECalModel *model;
ECalModelComponent *comp_data;
ECalComponent *comp;
const gchar *uid;
- memo_preview = E_MEMO_PREVIEW (memo_shell_content->priv->memo_preview);
+ memo_preview = E_CAL_COMPONENT_PREVIEW (
+ memo_shell_content->priv->memo_preview);
memo_table = E_MEMO_TABLE (memo_shell_content->priv->memo_table);
if (e_table_selected_count (table) != 1) {
- e_memo_preview_clear (memo_preview);
+ e_cal_component_preview_clear (memo_preview);
return;
}
@@ -153,7 +154,8 @@ memo_shell_content_cursor_change_cb (EMemoShellContent *memo_shell_content,
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (
comp, icalcomponent_new_clone (comp_data->icalcomp));
- e_memo_preview_display (memo_preview, comp_data->client, comp);
+ e_cal_component_preview_display (
+ memo_preview, comp_data->client, comp);
e_cal_component_get_uid (comp, &uid);
g_free (memo_shell_content->priv->current_uid);
@@ -166,14 +168,15 @@ static void
memo_shell_content_selection_change_cb (EMemoShellContent *memo_shell_content,
ETable *table)
{
- EMemoPreview *memo_preview;
+ ECalComponentPreview *memo_preview;
- memo_preview = E_MEMO_PREVIEW (memo_shell_content->priv->memo_preview);
+ memo_preview = E_CAL_COMPONENT_PREVIEW (
+ memo_shell_content->priv->memo_preview);
/* XXX Old code emits a "selection-changed" signal here. */
if (e_table_selected_count (table) != 1)
- e_memo_preview_clear (memo_preview);
+ e_cal_component_preview_clear (memo_preview);
}
static void
@@ -341,9 +344,9 @@ memo_shell_content_constructed (GObject *object)
container = widget;
- widget = e_memo_preview_new ();
- e_memo_preview_set_default_timezone (
- E_MEMO_PREVIEW (widget),
+ widget = e_cal_component_preview_new ();
+ e_cal_component_preview_set_default_timezone (
+ E_CAL_COMPONENT_PREVIEW (widget),
calendar_config_get_icaltimezone ());
gtk_container_add (GTK_CONTAINER (container), widget);
priv->memo_preview = g_object_ref (widget);
@@ -485,13 +488,14 @@ e_memo_shell_content_new (EShellView *shell_view)
"shell-view", shell_view, NULL);
}
-EMemoPreview *
+ECalComponentPreview *
e_memo_shell_content_get_memo_preview (EMemoShellContent *memo_shell_content)
{
g_return_val_if_fail (
E_IS_MEMO_SHELL_CONTENT (memo_shell_content), NULL);
- return E_MEMO_PREVIEW (memo_shell_content->priv->memo_preview);
+ return E_CAL_COMPONENT_PREVIEW (
+ memo_shell_content->priv->memo_preview);
}
EMemoTable *
diff --git a/calendar/modules/e-memo-shell-content.h b/calendar/modules/e-memo-shell-content.h
index 50809772bc..3965c24e8d 100644
--- a/calendar/modules/e-memo-shell-content.h
+++ b/calendar/modules/e-memo-shell-content.h
@@ -25,8 +25,8 @@
#include <shell/e-shell-content.h>
#include <shell/e-shell-view.h>
-#include <calendar/gui/e-memo-preview.h>
#include <calendar/gui/e-memo-table.h>
+#include <calendar/gui/e-cal-component-preview.h>
#include <widgets/menus/gal-view-instance.h>
@@ -66,7 +66,8 @@ struct _EMemoShellContentClass {
GType e_memo_shell_content_get_type (void);
GtkWidget * e_memo_shell_content_new (EShellView *shell_view);
-EMemoPreview * e_memo_shell_content_get_memo_preview
+ECalComponentPreview *
+ e_memo_shell_content_get_memo_preview
(EMemoShellContent *memo_shell_content);
EMemoTable * e_memo_shell_content_get_memo_table
(EMemoShellContent *memo_shell_content);
diff --git a/calendar/modules/e-memo-shell-module.c b/calendar/modules/e-memo-shell-module.c
index eceed252a7..0590479bdb 100644
--- a/calendar/modules/e-memo-shell-module.c
+++ b/calendar/modules/e-memo-shell-module.c
@@ -41,7 +41,6 @@
#define MODULE_NAME "memos"
#define MODULE_ALIASES ""
#define MODULE_SCHEMES "memo"
-#define MODULE_SEARCHES "memotypes.xml"
#define MODULE_SORT_ORDER 500
#define WEB_BASE_URI "webcal://"
@@ -334,7 +333,6 @@ static EShellModuleInfo module_info = {
MODULE_NAME,
MODULE_ALIASES,
MODULE_SCHEMES,
- MODULE_SEARCHES,
MODULE_SORT_ORDER
};
diff --git a/calendar/modules/e-memo-shell-view-actions.c b/calendar/modules/e-memo-shell-view-actions.c
index b63c008d6b..6ec64b15c6 100644
--- a/calendar/modules/e-memo-shell-view-actions.c
+++ b/calendar/modules/e-memo-shell-view-actions.c
@@ -79,7 +79,7 @@ action_memo_delete_cb (GtkAction *action,
EMemoShellView *memo_shell_view)
{
EMemoShellContent *memo_shell_content;
- EMemoPreview *memo_preview;
+ ECalComponentPreview *memo_preview;
EMemoTable *memo_table;
const gchar *status_message;
@@ -92,7 +92,7 @@ action_memo_delete_cb (GtkAction *action,
e_memo_table_delete_selected (memo_table);
e_memo_shell_view_set_status_message (memo_shell_view, NULL);
- e_memo_preview_clear (memo_preview);
+ e_cal_component_preview_clear (memo_preview);
}
static void
@@ -258,7 +258,7 @@ action_memo_list_print_preview_cb (GtkAction *action,
memo_table = e_memo_shell_content_get_memo_table (memo_shell_content);
table = e_memo_table_get_table (memo_table);
- print_action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG;
+ print_action = GTK_PRINT_OPERATION_ACTION_PREVIEW;
print_table (table, _("Print Memos"), _("Memos"), print_action);
}
@@ -292,6 +292,8 @@ action_memo_list_select_one_cb (GtkAction *action,
ESource *primary;
GSList *list, *iter;
+ /* XXX ESourceSelector should provide a function for this. */
+
memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar;
selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
primary = e_source_selector_peek_primary_selection (selector);
diff --git a/calendar/modules/e-memo-shell-view-private.c b/calendar/modules/e-memo-shell-view-private.c
index a78129dff2..04ee8eecc3 100644
--- a/calendar/modules/e-memo-shell-view-private.c
+++ b/calendar/modules/e-memo-shell-view-private.c
@@ -204,11 +204,6 @@ e_memo_shell_view_private_constructed (EMemoShellView *memo_shell_view)
selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
g_signal_connect_swapped (
- shell_sidebar, "status-message",
- G_CALLBACK (e_memo_shell_view_set_status_message),
- memo_shell_view);
-
- g_signal_connect_swapped (
memo_table, "open-component",
G_CALLBACK (e_memo_shell_view_open_memo),
memo_shell_view);
@@ -249,16 +244,21 @@ e_memo_shell_view_private_constructed (EMemoShellView *memo_shell_view)
memo_shell_view);
g_signal_connect_swapped (
- shell_sidebar, "client-added",
+ memo_shell_sidebar, "client-added",
G_CALLBACK (memo_shell_view_selector_client_added_cb),
memo_shell_view);
g_signal_connect_swapped (
- shell_sidebar, "client-removed",
+ memo_shell_sidebar, "client-removed",
G_CALLBACK (memo_shell_view_selector_client_removed_cb),
memo_shell_view);
g_signal_connect_swapped (
+ memo_shell_sidebar, "status-message",
+ G_CALLBACK (e_memo_shell_view_set_status_message),
+ memo_shell_view);
+
+ g_signal_connect_swapped (
selector, "popup-event",
G_CALLBACK (memo_shell_view_selector_popup_event_cb),
memo_shell_view);
@@ -315,7 +315,7 @@ e_memo_shell_view_execute_search (EMemoShellView *memo_shell_view)
EShellContent *shell_content;
GtkAction *action;
GString *string;
- EMemoPreview *memo_preview;
+ ECalComponentPreview *memo_preview;
EMemoTable *memo_table;
ECalModel *model;
FilterRule *rule;
@@ -371,7 +371,7 @@ e_memo_shell_view_execute_search (EMemoShellView *memo_shell_view)
"(and (has-categories? #f) %s", query);
g_free (query);
query = temp;
- } else if (value != MEMO_FILTER_ANY_CATEGORY) {
+ } else if (value >= 0) {
GList *categories;
const gchar *category_name;
gchar *temp;
@@ -401,8 +401,9 @@ e_memo_shell_view_execute_search (EMemoShellView *memo_shell_view)
e_cal_model_set_search_query (model, query);
g_free (query);
- memo_preview = e_memo_shell_content_get_memo_preview (memo_shell_content);
- e_memo_preview_clear (memo_preview);
+ memo_preview =
+ e_memo_shell_content_get_memo_preview (memo_shell_content);
+ e_cal_component_preview_clear (memo_preview);
}
void
diff --git a/calendar/modules/e-memo-shell-view-private.h b/calendar/modules/e-memo-shell-view-private.h
index 6d59301301..0a68ef1f98 100644
--- a/calendar/modules/e-memo-shell-view-private.h
+++ b/calendar/modules/e-memo-shell-view-private.h
@@ -35,8 +35,8 @@
#include "e-util/gconf-bridge.h"
#include "calendar/gui/comp-util.h"
+#include "calendar/gui/e-cal-component-preview.h"
#include "calendar/gui/e-calendar-selector.h"
-#include "calendar/gui/e-memo-preview.h"
#include "calendar/gui/print.h"
#include "calendar/gui/dialogs/calendar-setup.h"
#include "calendar/gui/dialogs/copy-source-dialog.h"
@@ -67,14 +67,14 @@
G_BEGIN_DECLS
-/* List these in the order to be displayed.
- * Positive values are reserved for categories. */
+/* Filter items are displayed in ascending order.
+ * Non-negative values are reserved for categories. */
enum {
- MEMO_FILTER_ANY_CATEGORY = -2,
- MEMO_FILTER_UNMATCHED = -1
+ MEMO_FILTER_ANY_CATEGORY = -2,
+ MEMO_FILTER_UNMATCHED = -1
};
-/* List these in the order to be displayed. */
+/* Search items are displayed in ascending order. */
enum {
MEMO_SEARCH_SUMMARY_CONTAINS,
MEMO_SEARCH_DESCRIPTION_CONTAINS,
diff --git a/calendar/modules/e-memo-shell-view.c b/calendar/modules/e-memo-shell-view.c
index 06876f6db8..17a28fb0d8 100644
--- a/calendar/modules/e-memo-shell-view.c
+++ b/calendar/modules/e-memo-shell-view.c
@@ -199,6 +199,7 @@ memo_shell_view_class_init (EMemoShellView *class,
shell_view_class->icon_name = "evolution-memos";
shell_view_class->ui_definition = "evolution-memos.ui";
shell_view_class->search_options = "/memo-search-options";
+ shell_view_class->search_rules = "memotypes.xml";
shell_view_class->type_module = type_module;
shell_view_class->new_shell_content = e_memo_shell_content_new;
shell_view_class->new_shell_sidebar = e_memo_shell_sidebar_new;
diff --git a/calendar/modules/e-task-shell-content.c b/calendar/modules/e-task-shell-content.c
index 97ceafee28..7cf7da3e7c 100644
--- a/calendar/modules/e-task-shell-content.c
+++ b/calendar/modules/e-task-shell-content.c
@@ -131,18 +131,19 @@ task_shell_content_cursor_change_cb (ETaskShellContent *task_shell_content,
gint row,
ETable *table)
{
- ETaskPreview *task_preview;
+ ECalComponentPreview *task_preview;
ETaskTable *task_table;
ECalModel *model;
ECalModelComponent *comp_data;
ECalComponent *comp;
const gchar *uid;
- task_preview = E_TASK_PREVIEW (task_shell_content->priv->task_preview);
+ task_preview = E_CAL_COMPONENT_PREVIEW (
+ task_shell_content->priv->task_preview);
task_table = E_TASK_TABLE (task_shell_content->priv->task_table);
if (e_table_selected_count (table) != 1) {
- e_task_preview_clear (task_preview);
+ e_cal_component_preview_clear (task_preview);
return;
}
@@ -153,7 +154,8 @@ task_shell_content_cursor_change_cb (ETaskShellContent *task_shell_content,
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (
comp, icalcomponent_new_clone (comp_data->icalcomp));
- e_task_preview_display (task_preview, comp_data->client, comp);
+ e_cal_component_preview_display (
+ task_preview, comp_data->client, comp);
e_cal_component_get_uid (comp, &uid);
g_free (task_shell_content->priv->current_uid);
@@ -166,14 +168,15 @@ static void
task_shell_content_selection_change_cb (ETaskShellContent *task_shell_content,
ETable *table)
{
- ETaskPreview *task_preview;
+ ECalComponentPreview *task_preview;
- task_preview = E_TASK_PREVIEW (task_shell_content->priv->task_preview);
+ task_preview = E_CAL_COMPONENT_PREVIEW (
+ task_shell_content->priv->task_preview);
/* XXX Old code emits a "selection-changed" signal here. */
if (e_table_selected_count (table) != 1)
- e_task_preview_clear (task_preview);
+ e_cal_component_preview_clear (task_preview);
}
static void
@@ -340,9 +343,9 @@ task_shell_content_constructed (GObject *object)
container = widget;
- widget = e_task_preview_new ();
- e_task_preview_set_default_timezone (
- E_TASK_PREVIEW (widget),
+ widget = e_cal_component_preview_new ();
+ e_cal_component_preview_set_default_timezone (
+ E_CAL_COMPONENT_PREVIEW (widget),
calendar_config_get_icaltimezone ());
gtk_container_add (GTK_CONTAINER (container), widget);
priv->task_preview = g_object_ref (widget);
@@ -484,13 +487,14 @@ e_task_shell_content_new (EShellView *shell_view)
"shell-view", shell_view, NULL);
}
-ETaskPreview *
+ECalComponentPreview *
e_task_shell_content_get_task_preview (ETaskShellContent *task_shell_content)
{
g_return_val_if_fail (
E_IS_TASK_SHELL_CONTENT (task_shell_content), NULL);
- return E_TASK_PREVIEW (task_shell_content->priv->task_preview);
+ return E_CAL_COMPONENT_PREVIEW (
+ task_shell_content->priv->task_preview);
}
ETaskTable *
diff --git a/calendar/modules/e-task-shell-module.c b/calendar/modules/e-task-shell-module.c
index 59f9c9db86..4b062646fd 100644
--- a/calendar/modules/e-task-shell-module.c
+++ b/calendar/modules/e-task-shell-module.c
@@ -37,7 +37,6 @@
#define MODULE_NAME "tasks"
#define MODULE_ALIASES ""
#define MODULE_SCHEMES "task"
-#define MODULE_SEARCHES "tasktypes.xml"
#define MODULE_SORT_ORDER 600
#define WEB_BASE_URI "webcal://"
@@ -194,21 +193,83 @@ task_module_ensure_sources (EShellModule *shell_module)
}
static void
-action_task_new_cb (GtkAction *action,
- EShellWindow *shell_window)
+task_module_cal_opened_cb (ECal *cal,
+ ECalendarStatus status,
+ GtkAction *action)
{
+ ECalComponent *comp;
+ CompEditor *editor;
+ CompEditorFlags flags = 0;
+ const gchar *action_name;
+
+ /* XXX Handle errors better. */
+ if (status != E_CALENDAR_STATUS_OK)
+ return;
+
+ action_name = gtk_action_get_name (action);
+
+ flags |= COMP_EDITOR_NEW_ITEM;
+ if (strcmp (action_name, "task-assigned-new") == 0) {
+ flags |= COMP_EDITOR_IS_ASSIGNED;
+ flags |= COMP_EDITOR_USER_ORG;
+ }
+
+ editor = task_editor_new (cal, flags);
+ comp = cal_comp_task_new_with_defaults (cal);
+ comp_editor_edit_comp (editor, comp);
+
+ gtk_window_present (GTK_WINDOW (editor));
+
+ g_object_unref (comp);
+ g_object_unref (cal);
}
static void
-action_task_assigned_new_cb (GtkAction *action,
- EShellWindow *shell_window)
+action_task_new_cb (GtkAction *action,
+ EShellWindow *shell_window)
{
+ ECal *cal = NULL;
+ ECalSourceType source_type;
+ ESourceList *source_list;
+ gchar *uid;
+
+ /* This callback is used for both tasks and assigned tasks. */
+
+ source_type = E_CAL_SOURCE_TYPE_TODO;
+
+ if (!e_cal_get_sources (&source_list, source_type, NULL)) {
+ g_warning ("Could not get task sources from GConf!");
+ return;
+ }
+
+ uid = calendar_config_get_primary_tasks ();
+
+ if (uid != NULL) {
+ ESource *source;
+
+ source = e_source_list_peek_source_by_uid (source_list, uid);
+ if (source != NULL)
+ cal = auth_new_cal_from_source (source, source_type);
+ g_free (uid);
+ }
+
+ if (cal == NULL)
+ cal = auth_new_cal_from_default (source_type);
+
+ g_return_if_fail (cal != NULL);
+
+ g_signal_connect (
+ cal, "cal-opened",
+ G_CALLBACK (task_module_cal_opened_cb), action);
+
+ e_cal_open_async (cal, FALSE);
}
static void
action_task_list_new_cb (GtkAction *action,
EShellWindow *shell_window)
{
+ calendar_setup_new_task_list (GTK_WINDOW (shell_window));
}
static GtkActionEntry item_entries[] = {
@@ -216,7 +277,7 @@ static GtkActionEntry item_entries[] = {
{ "task-new",
"stock_task",
N_("_Task"), /* XXX Need C_() here */
- "<Control>t",
+ "<Shift><Control>t",
N_("Create a new task"),
G_CALLBACK (action_task_new_cb) },
@@ -225,7 +286,7 @@ static GtkActionEntry item_entries[] = {
N_("Assigne_d Task"),
NULL,
N_("Create a new assigned task"),
- G_CALLBACK (action_task_assigned_new_cb) }
+ G_CALLBACK (action_task_new_cb) }
};
static GtkActionEntry source_entries[] = {
@@ -268,7 +329,6 @@ static EShellModuleInfo module_info = {
MODULE_NAME,
MODULE_ALIASES,
MODULE_SCHEMES,
- MODULE_SEARCHES,
MODULE_SORT_ORDER
};
diff --git a/calendar/modules/e-task-shell-view-actions.c b/calendar/modules/e-task-shell-view-actions.c
index 0b787d6e25..f1b8cd40f7 100644
--- a/calendar/modules/e-task-shell-view-actions.c
+++ b/calendar/modules/e-task-shell-view-actions.c
@@ -22,6 +22,44 @@
#include "e-task-shell-view-private.h"
static void
+action_gal_save_custom_view_cb (GtkAction *action,
+ ETaskShellView *task_shell_view)
+{
+ ETaskShellContent *task_shell_content;
+ EShellView *shell_view;
+ GalViewInstance *view_instance;
+
+ shell_view = E_SHELL_VIEW (task_shell_view);
+ if (!e_shell_view_is_active (shell_view))
+ return;
+
+ task_shell_content = task_shell_view->priv->task_shell_content;
+ view_instance = e_task_shell_content_get_view_instance (task_shell_content);
+ gal_view_instance_save_as (view_instance);
+}
+
+static void
+action_search_execute_cb (GtkAction *action,
+ ETaskShellView *task_shell_view)
+{
+ EShellView *shell_view;
+
+ shell_view = E_SHELL_VIEW (task_shell_view);
+ if (!e_shell_view_is_active (shell_view))
+ return;
+
+ e_task_shell_view_execute_search (task_shell_view);
+}
+
+static void
+action_search_filter_cb (GtkRadioAction *action,
+ GtkRadioAction *current,
+ ETaskShellView *task_shell_view)
+{
+ e_task_shell_view_execute_search (task_shell_view);
+}
+
+static void
action_task_assign_cb (GtkAction *action,
ETaskShellView *task_shell_view)
{
@@ -85,7 +123,7 @@ action_task_delete_cb (GtkAction *action,
ETaskShellView *task_shell_view)
{
ETaskShellContent *task_shell_content;
- ETaskPreview *task_preview;
+ ECalComponentPreview *task_preview;
ETaskTable *task_table;
const gchar *status_message;
@@ -98,7 +136,7 @@ action_task_delete_cb (GtkAction *action,
e_task_table_delete_selected (task_table);
e_task_shell_view_set_status_message (task_shell_view, NULL);
- e_task_preview_clear (task_preview);
+ e_cal_component_preview_clear (task_preview);
}
static void
@@ -134,20 +172,104 @@ static void
action_task_list_copy_cb (GtkAction *action,
ETaskShellView *task_shell_view)
{
- /* FIXME */
+ ETaskShellSidebar *task_shell_sidebar;
+ EShellWindow *shell_window;
+ EShellView *shell_view;
+ ESourceSelector *selector;
+ ESource *source;
+
+ shell_view = E_SHELL_VIEW (task_shell_view);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ task_shell_sidebar = task_shell_view->priv->task_shell_sidebar;
+ selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
+ source = e_source_selector_peek_primary_selection (selector);
+ g_return_if_fail (E_IS_SOURCE (source));
+
+ copy_source_dialog (
+ GTK_WINDOW (shell_window),
+ source, E_CAL_SOURCE_TYPE_TODO);
}
static void
action_task_list_delete_cb (GtkAction *action,
ETaskShellView *task_shell_view)
{
- /* FIXME */
+ ETaskShellContent *task_shell_content;
+ ETaskShellSidebar *task_shell_sidebar;
+ EShellWindow *shell_window;
+ EShellView *shell_view;
+ ETaskTable *task_table;
+ ECal *client;
+ ECalModel *model;
+ ESourceSelector *selector;
+ ESourceGroup *source_group;
+ ESourceList *source_list;
+ ESource *source;
+ gint response;
+ gchar *uri;
+ GError *error = NULL;
+
+ shell_view = E_SHELL_VIEW (task_shell_view);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ task_shell_content = task_shell_view->priv->task_shell_content;
+ task_table = e_task_shell_content_get_task_table (task_shell_content);
+ model = e_task_table_get_model (task_table);
+
+ task_shell_sidebar = task_shell_view->priv->task_shell_sidebar;
+ selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
+ source = e_source_selector_peek_primary_selection (selector);
+ g_return_if_fail (E_IS_SOURCE (source));
+
+ /* Ask for confirmation. */
+ response = e_error_run (
+ GTK_WINDOW (shell_window),
+ "calendar:prompt-delete-task-list",
+ e_source_peek_name (source));
+ if (response != GTK_RESPONSE_YES)
+ return;
+
+ uri = e_source_get_uri (source);
+ client = e_cal_model_get_client_for_uri (model, uri);
+ if (client == NULL)
+ client = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_JOURNAL);
+ g_free (uri);
+
+ g_return_if_fail (client != NULL);
+
+ if (!e_cal_remove (client, &error)) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ if (e_source_selector_source_is_selected (selector, source)) {
+ e_task_shell_sidebar_remove_source (
+ task_shell_sidebar, source);
+ e_source_selector_unselect_source (selector, source);
+ }
+
+ source_group = e_source_peek_group (source);
+ e_source_group_remove_source (source_group, source);
+
+ source_list = task_shell_view->priv->source_list;
+ if (!e_source_list_sync (source_list, &error)) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
}
static void
action_task_list_new_cb (GtkAction *action,
ETaskShellView *task_shell_view)
{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+
+ shell_view = E_SHELL_VIEW (task_shell_view);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ calendar_setup_new_task_list (GTK_WINDOW (shell_window));
}
static void
@@ -157,14 +279,14 @@ action_task_list_print_cb (GtkAction *action,
ETaskShellContent *task_shell_content;
ETaskTable *task_table;
ETable *table;
+ GtkPrintOperationAction print_action;
task_shell_content = task_shell_view->priv->task_shell_content;
task_table = e_task_shell_content_get_task_table (task_shell_content);
table = e_task_table_get_table (task_table);
- print_table (
- table, _("Print Tasks"), _("Tasks"),
- GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG);
+ print_action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG;
+ print_table (table, _("Print Tasks"), _("Tasks"), print_action);
}
static void
@@ -174,20 +296,65 @@ action_task_list_print_preview_cb (GtkAction *action,
ETaskShellContent *task_shell_content;
ETaskTable *task_table;
ETable *table;
+ GtkPrintOperationAction print_action;
task_shell_content = task_shell_view->priv->task_shell_content;
task_table = e_task_shell_content_get_task_table (task_shell_content);
table = e_task_table_get_table (task_table);
- print_table (
- table, _("Print Tasks"), _("Tasks"),
- GTK_PRINT_OPERATION_ACTION_PREVIEW);
+ print_action = GTK_PRINT_OPERATION_ACTION_PREVIEW;
+ print_table (table, _("Print Tasks"), _("Tasks"), print_action);
}
static void
action_task_list_properties_cb (GtkAction *action,
ETaskShellView *task_shell_view)
{
+ ETaskShellSidebar *task_shell_sidebar;
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ ESource *source;
+ ESourceSelector *selector;
+
+ shell_view = E_SHELL_VIEW (task_shell_view);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ task_shell_sidebar = task_shell_view->priv->task_shell_sidebar;
+ selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
+ source = e_source_selector_peek_primary_selection (selector);
+ g_return_if_fail (E_IS_SOURCE (source));
+
+ calendar_setup_edit_task_list (GTK_WINDOW (shell_window), source);
+}
+
+static void
+action_task_list_select_one_cb (GtkAction *action,
+ ETaskShellView *task_shell_view)
+{
+ ETaskShellSidebar *task_shell_sidebar;
+ ESourceSelector *selector;
+ ESource *primary;
+ GSList *list, *iter;
+
+ /* XXX ESourceSelector should provide a function for this. */
+
+ task_shell_sidebar = task_shell_view->priv->task_shell_sidebar;
+ selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
+ primary = e_source_selector_peek_primary_selection (selector);
+ g_return_if_fail (primary != NULL);
+
+ list = e_source_selector_get_selection (selector);
+ for (iter = list; iter != NULL; iter = iter->next) {
+ ESource *source = iter->data;
+
+ if (source == primary)
+ continue;
+
+ e_source_selector_unselect_source (selector, source);
+ }
+ e_source_selector_free_selection (list);
+
+ e_source_selector_select_source (selector, primary);
}
static void
@@ -238,6 +405,31 @@ static void
action_task_new_cb (GtkAction *action,
ETaskShellView *task_shell_view)
{
+ ETaskShellContent *task_shell_content;
+ ETaskTable *task_table;
+ ECalModelComponent *comp_data;
+ ECal *client;
+ ECalComponent *comp;
+ CompEditor *editor;
+ GSList *list;
+
+ task_shell_content = task_shell_view->priv->task_shell_content;
+ task_table = e_task_shell_content_get_task_table (task_shell_content);
+
+ list = e_task_table_get_selected (task_table);
+ g_return_if_fail (list != NULL);
+ comp_data = list->data;
+ g_slist_free (list);
+
+ client = comp_data->client;
+ editor = task_editor_new (client, COMP_EDITOR_NEW_ITEM);
+ comp = cal_comp_task_new_with_defaults (client);
+ comp_editor_edit_comp (editor, comp);
+
+ gtk_window_present (GTK_WINDOW (editor));
+
+ g_object_unref (comp);
+ g_object_unref (client);
}
static void
@@ -246,11 +438,19 @@ action_task_open_cb (GtkAction *action,
{
ETaskShellContent *task_shell_content;
ETaskTable *task_table;
+ ECalModelComponent *comp_data;
+ GSList *list;
task_shell_content = task_shell_view->priv->task_shell_content;
task_table = e_task_shell_content_get_task_table (task_shell_content);
- e_task_table_open_selected (task_table);
+ list = e_task_table_get_selected (task_table);
+ g_return_if_fail (list != NULL);
+ comp_data = list->data;
+ g_slist_free (list);
+
+ /* XXX We only open the first selected task. */
+ e_task_shell_view_open_task (task_shell_view, comp_data);
}
static void
@@ -464,6 +664,13 @@ static GtkActionEntry task_entries[] = {
N_("Mark selected tasks as complete"),
G_CALLBACK (action_task_mark_complete_cb) },
+ { "task-mark-incomplete",
+ NULL,
+ N_("Mar_k as Incomplete"),
+ NULL,
+ N_("Mark selected tasks as incomplete"),
+ G_CALLBACK (action_task_mark_incomplete_cb) },
+
{ "task-new",
"stock_task",
N_("New _Task"),
@@ -518,6 +725,75 @@ static GtkToggleActionEntry task_toggle_entries[] = {
TRUE }
};
+static GtkRadioActionEntry task_filter_entries[] = {
+
+ { "task-filter-active-tasks",
+ NULL,
+ N_("Active Tasks"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ TASK_FILTER_ACTIVE_TASKS },
+
+ { "task-filter-any-category",
+ NULL,
+ N_("Any Category"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ TASK_FILTER_ANY_CATEGORY },
+
+ { "task-filter-completed-tasks",
+ NULL,
+ N_("Completed Tasks"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ TASK_FILTER_COMPLETED_TASKS },
+
+ { "task-filter-next-7-days-tasks",
+ NULL,
+ N_("Next 7 Days' Tasks"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ TASK_FILTER_NEXT_7_DAYS_TASKS },
+
+ { "task-filter-overdue-tasks",
+ NULL,
+ N_("Overdue Tasks"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ TASK_FILTER_OVERDUE_TASKS },
+
+ { "task-filter-tasks-with-attachments",
+ NULL,
+ N_("Tasks with Attachments"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ TASK_FILTER_TASKS_WITH_ATTACHMENTS }
+};
+
+static GtkRadioActionEntry task_search_entries[] = {
+
+ { "task-search-any-field-contains",
+ NULL,
+ N_("Any field contains"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ TASK_SEARCH_ANY_FIELD_CONTAINS },
+
+ { "task-search-description-contains",
+ NULL,
+ N_("Description contains"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ TASK_SEARCH_DESCRIPTION_CONTAINS },
+
+ { "task-search-summary-contains",
+ NULL,
+ N_("Summary contains"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ TASK_SEARCH_SUMMARY_CONTAINS }
+};
+
void
e_task_shell_view_actions_init (ETaskShellView *task_shell_view)
{
@@ -536,8 +812,6 @@ e_task_shell_view_actions_init (ETaskShellView *task_shell_view)
manager = e_shell_window_get_ui_manager (shell_window);
domain = GETTEXT_PACKAGE;
- e_load_ui_definition (manager, "evolution-tasks.ui");
-
action_group = task_shell_view->priv->task_actions;
gtk_action_group_set_translation_domain (action_group, domain);
gtk_action_group_add_actions (
@@ -546,6 +820,11 @@ e_task_shell_view_actions_init (ETaskShellView *task_shell_view)
gtk_action_group_add_toggle_actions (
action_group, task_toggle_entries,
G_N_ELEMENTS (task_toggle_entries), task_shell_view);
+ gtk_action_group_add_radio_actions (
+ action_group, task_search_entries,
+ G_N_ELEMENTS (task_search_entries),
+ TASK_SEARCH_SUMMARY_CONTAINS,
+ NULL, NULL);
gtk_ui_manager_insert_action_group (manager, action_group, 0);
/* Bind GObject properties to GConf keys. */
@@ -560,58 +839,71 @@ e_task_shell_view_actions_init (ETaskShellView *task_shell_view)
action = ACTION (TASK_DELETE);
g_object_set (action, "short-label", _("Delete"), NULL);
+
+ g_signal_connect (
+ ACTION (GAL_SAVE_CUSTOM_VIEW), "activate",
+ G_CALLBACK (action_gal_save_custom_view_cb), task_shell_view);
+
+ g_signal_connect (
+ ACTION (SEARCH_EXECUTE), "activate",
+ G_CALLBACK (action_search_execute_cb), task_shell_view);
}
void
-e_task_shell_view_actions_update (ETaskShellView *task_shell_view)
+e_task_shell_view_update_search_filter (ETaskShellView *task_shell_view)
{
- ETaskShellContent *task_shell_content;
- ECal *client;
- ETable *table;
- ECalModel *model;
- ETaskTable *task_table;
+ EShellContent *shell_content;
EShellView *shell_view;
- EShellWindow *shell_window;
- GtkAction *action;
- const gchar *label;
- gboolean read_only = TRUE;
- gboolean sensitive;
- gint n_selected;
+ GtkActionGroup *action_group;
+ GtkRadioAction *radio_action;
+ GList *list, *iter;
+ GSList *group;
+ gint ii;
shell_view = E_SHELL_VIEW (task_shell_view);
- shell_window = e_shell_view_get_shell_window (shell_view);
-
- task_shell_content = task_shell_view->priv->task_shell_content;
- task_table = e_task_shell_content_get_task_table (task_shell_content);
-
- model = e_task_table_get_model (task_table);
- client = e_cal_model_get_default_client (model);
-
- table = e_task_table_get_table (task_table);
- n_selected = e_table_selected_count (table);
-
- if (client != NULL)
- e_cal_is_read_only (client, &read_only, NULL);
-
- action = ACTION (TASK_OPEN);
- sensitive = (n_selected == 1);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (TASK_CLIPBOARD_COPY);
- sensitive = (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (TASK_CLIPBOARD_CUT);
- sensitive = (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (TASK_CLIPBOARD_PASTE);
- sensitive = (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+ action_group = task_shell_view->priv->filter_actions;
+
+ e_action_group_remove_all_actions (action_group);
+
+ /* Add the standard filter actions. */
+ gtk_action_group_add_radio_actions (
+ action_group, task_filter_entries,
+ G_N_ELEMENTS (task_filter_entries),
+ TASK_FILTER_ANY_CATEGORY,
+ G_CALLBACK (action_search_filter_cb),
+ task_shell_view);
+
+ /* Retrieve the radio group from an action we just added. */
+ list = gtk_action_group_list_actions (action_group);
+ radio_action = GTK_RADIO_ACTION (list->data);
+ group = gtk_radio_action_get_group (radio_action);
+ g_list_free (list);
+
+ /* Build the category actions. */
+
+ list = e_categories_get_list ();
+ for (iter = list, ii = 0; iter != NULL; iter = iter->next, ii++) {
+ const gchar *category_name = iter->data;
+ GtkAction *action;
+ gchar *action_name;
+
+ action_name = g_strdup_printf (
+ "task-filter-category-%d", ii);
+ radio_action = gtk_radio_action_new (
+ action_name, category_name, NULL, NULL, ii);
+ g_free (action_name);
+
+ gtk_radio_action_set_group (radio_action, group);
+ group = gtk_radio_action_get_group (radio_action);
+
+ /* The action group takes ownership of the action. */
+ action = GTK_ACTION (radio_action);
+ gtk_action_group_add_action (action_group, action);
+ g_object_unref (radio_action);
+ }
+ g_list_free (list);
- action = ACTION (TASK_DELETE);
- sensitive = (n_selected > 0) && !read_only;
- gtk_action_set_sensitive (action, sensitive);
- label = ngettext ("Delete Task", "Delete Tasks", n_selected);
- g_object_set (action, "label", label, NULL);
+ /* Use any action in the group; doesn't matter which. */
+ e_shell_content_set_filter_action (shell_content, radio_action);
}
diff --git a/calendar/modules/e-task-shell-view-actions.h b/calendar/modules/e-task-shell-view-actions.h
index dd09220f28..0b7212e469 100644
--- a/calendar/modules/e-task-shell-view-actions.h
+++ b/calendar/modules/e-task-shell-view-actions.h
@@ -39,16 +39,58 @@
E_SHELL_WINDOW_ACTION ((window), "task-forward")
#define E_SHELL_WINDOW_ACTION_TASK_MARK_COMPLETE(window) \
E_SHELL_WINDOW_ACTION ((window), "task-mark-complete")
+#define E_SHELL_WINDOW_ACTION_TASK_MARK_INCOMPLETE(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-mark-incomplete")
+#define E_SHELL_WINDOW_ACTION_TASK_NEW(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-new")
#define E_SHELL_WINDOW_ACTION_TASK_OPEN(window) \
E_SHELL_WINDOW_ACTION ((window), "task-open")
+#define E_SHELL_WINDOW_ACTION_TASK_OPEN_URL(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-open-url")
#define E_SHELL_WINDOW_ACTION_TASK_PREVIEW(window) \
E_SHELL_WINDOW_ACTION ((window), "task-preview")
#define E_SHELL_WINDOW_ACTION_TASK_PRINT(window) \
E_SHELL_WINDOW_ACTION ((window), "task-print")
-#define E_SHELL_WINDOW_ACTION_TASK_PRINT_PREVIEW(window) \
- E_SHELL_WINDOW_ACTION ((window), "task-print-preview")
#define E_SHELL_WINDOW_ACTION_TASK_PURGE(window) \
E_SHELL_WINDOW_ACTION ((window), "task-purge")
+#define E_SHELL_WINDOW_ACTION_TASK_SAVE_AS(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-save-as")
+
+/* Task List Actions */
+#define E_SHELL_WINDOW_ACTION_TASK_LIST_COPY(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-list-copy")
+#define E_SHELL_WINDOW_ACTION_TASK_LIST_DELETE(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-list-delete")
+#define E_SHELL_WINDOW_ACTION_TASK_LIST_NEW(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-list-new")
+#define E_SHELL_WINDOW_ACTION_TASK_LIST_PRINT(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-list-print")
+#define E_SHELL_WINDOW_ACTION_TASK_LIST_PRINT_PREVIEW(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-list-print-preview")
+#define E_SHELL_WINDOW_ACTION_TASK_LIST_PROPERTIES(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-list-properties")
+
+/* Task Query Actions */
+#define E_SHELL_WINDOW_ACTION_TASK_FILTER_ACTIVE_TASKS(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-filter-active-tasks")
+#define E_SHELL_WINDOW_ACTION_TASK_FILTER_ANY_CATEGORY(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-filter-any-category")
+#define E_SHELL_WINDOW_ACTION_TASK_FILTER_COMPLETED_TASKS(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-filter-completed-tasks")
+#define E_SHELL_WINDOW_ACTION_TASK_FILTER_NEXT_7_DAYS_TASKS(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-filter-next-7-days-tasks")
+#define E_SHELL_WINDOW_ACTION_TASK_FILTER_OVERDUE_TASKS(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-filter-overdue-tasks")
+#define E_SHELL_WINDOW_ACTION_TASK_FILTER_TASKS_WITH_ATTACHMENTS(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-filter-tasks-with-attachments")
+#define E_SHELL_WINDOW_ACTION_TASK_FILTER_UNMATCHED(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-filter-unmatched")
+#define E_SHELL_WINDOW_ACTION_TASK_SEARCH_ANY_FIELD_CONTAINS(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-search-any-field-contains")
+#define E_SHELL_WINDOW_ACTION_TASK_SEARCH_DESCRIPTION_CONTAINS(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-search-description-contains")
+#define E_SHELL_WINDOW_ACTION_TASK_SEARCH_SUMMARY_CONTAINS(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-search-summary-contains")
/* Action Groups */
#define E_SHELL_WINDOW_ACTION_GROUP_TASKS(window) \
diff --git a/calendar/modules/e-task-shell-view-private.c b/calendar/modules/e-task-shell-view-private.c
index d41f6e6033..741913f05a 100644
--- a/calendar/modules/e-task-shell-view-private.c
+++ b/calendar/modules/e-task-shell-view-private.c
@@ -24,175 +24,77 @@
#include <widgets/menus/gal-view-factory-etable.h>
static void
-task_shell_view_backend_died_cb (ETaskShellView *task_shell_view,
- ECal *client)
+task_shell_view_table_popup_event_cb (EShellView *shell_view,
+ GdkEventButton *event)
{
- EShellView *shell_view;
- EShellWindow *shell_window;
- GHashTable *client_table;
- ESource *source;
- const gchar *uid;
-
- shell_view = E_SHELL_VIEW (task_shell_view);
- shell_window = e_shell_view_get_shell_window (shell_view);
-
- source = e_cal_get_source (client);
- uid = e_source_peek_uid (source);
-
- g_object_ref (source);
-
- g_hash_table_remove (client_table, uid);
- e_task_shell_view_set_status_message (task_shell_view, NULL);
-
- e_error_run (
- GTK_WINDOW (shell_window),
- "calendar:tasks-crashed", NULL);
+ const gchar *widget_path;
- g_object_unref (source);
+ widget_path = "/task-popup";
+ e_shell_view_show_popup_menu (shell_view, widget_path, event);
}
static void
-task_shell_view_backend_error_cb (ETaskShellView *task_shell_view,
- const gchar *message,
- ECal *client)
+task_shell_view_table_user_created_cb (ETaskShellView *task_shell_view,
+ ETaskTable *task_table)
{
- EShellView *shell_view;
- EShellWindow *shell_window;
- GtkWidget *dialog;
- const gchar *uri;
- gchar *uri_no_passwd;
-
- shell_view = E_SHELL_VIEW (task_shell_view);
- shell_window = e_shell_view_get_shell_window (shell_view);
+ ETaskShellSidebar *task_shell_sidebar;
+ ECalModel *model;
+ ECal *client;
+ ESource *source;
- uri = e_cal_get_uri (client);
- uri_no_passwd = get_uri_without_password (uri);
+ /* This is the "Click to Add" handler. */
- dialog = gtk_message_dialog_new (
- GTK_WINDOW (shell_window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- _("Error on %s:\n%s"),
- uri_no_passwd, message);
+ model = e_task_table_get_model (task_table);
+ client = e_cal_model_get_default_client (model);
+ source = e_cal_get_source (client);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ task_shell_sidebar = task_shell_view->priv->task_shell_sidebar;
+ e_task_shell_sidebar_add_source (task_shell_sidebar, source);
- g_free (uri_no_passwd);
+ e_cal_model_add_client (model, client);
}
static void
-task_shell_view_client_opened_cb (ETaskShellView *task_shell_view,
- ECalendarStatus status,
- ECal *client)
-{
- /* FIXME */
-}
-
-static gboolean
-task_shell_view_add_source (ETaskShellView *task_shell_view,
- ESource *source)
+task_shell_view_selector_client_added_cb (ETaskShellView *task_shell_view,
+ ECal *client)
{
- ETaskShellSidebar *task_shell_sidebar;
- ESourceSelector *selector;
- GHashTable *client_table;
- ECal *default_client;
- ECal *client;
- const gchar *uid;
- const gchar *uri;
- gchar *status_message;
-
- client_table = task_shell_view->priv->client_table;
- default_client = task_shell_view->priv->default_client;
-
- uid = e_source_peek_uid (source);
- client = g_hash_table_lookup (client_table, uid);
-
- if (client != NULL)
- return TRUE;
-
- if (default_client != NULL) {
- ESource *default_source;
- const gchar *default_uid;
-
- default_source = e_cal_get_source (default_client);
- default_uid = e_source_peek_uid (default_source);
-
- if (strcmp (uid, default_uid) == 0)
- client = g_object_ref (default_client);
- }
-
- if (client == NULL)
- client = auth_new_cal_from_source (
- source, E_CAL_SOURCE_TYPE_TODO);
-
- if (client == NULL)
- return FALSE;
-
- g_signal_connect_swapped (
- client, "backend-died",
- G_CALLBACK (task_shell_view_backend_died_cb),
- task_shell_view);
-
- g_signal_connect_swapped (
- client, "backend-error",
- G_CALLBACK (task_shell_view_backend_error_cb),
- task_shell_view);
-
- g_hash_table_insert (client_table, g_strdup (uid), client);
-
- uri = e_cal_get_uri (client);
-
- status_message = g_strdup_printf (_("Opening tasks at %s"), uri);
- e_task_shell_view_set_status_message (task_shell_view, status_message);
- g_free (status_message);
-
- task_shell_sidebar = task_shell_view->priv->task_shell_sidebar;
- selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
- e_source_selector_select_source (selector, source);
-
- g_signal_connect_swapped (
- client, "cal-opened",
- G_CALLBACK (task_shell_view_client_opened_cb),
- task_shell_view);
+ ETaskShellContent *task_shell_content;
+ ETaskTable *task_table;
+ ECalModel *model;
- e_cal_open_async (client, FALSE);
+ task_shell_content = task_shell_view->priv->task_shell_content;
+ task_table = e_task_shell_content_get_task_table (task_shell_content);
+ model = e_task_table_get_model (task_table);
- return TRUE;
+ e_cal_model_add_client (model, client);
}
static void
-task_shell_view_table_popup_event_cb (ETaskShellView *task_shell_view,
- GdkEventButton *event)
+task_shell_view_selector_client_removed_cb (ETaskShellView *task_shell_view,
+ ECal *client)
{
- EShellView *shell_view;
- const gchar *widget_path;
+ ETaskShellContent *task_shell_content;
+ ETaskTable *task_table;
+ ECalModel *model;
- shell_view = E_SHELL_VIEW (task_shell_view);
- widget_path = "/task-popup";
+ task_shell_content = task_shell_view->priv->task_shell_content;
+ task_table = e_task_shell_content_get_task_table (task_shell_content);
+ model = e_task_table_get_model (task_table);
- e_task_shell_view_actions_update (task_shell_view);
- e_shell_view_show_popup_menu (shell_view, widget_path, event);
+ e_cal_model_remove_client (model, client);
}
-static void
-task_shell_view_table_user_created (ETaskShellView *task_shell_view,
- ETaskTable *task_table)
+static gboolean
+task_shell_view_selector_popup_event_cb (EShellView *shell_view,
+ ESource *primary_source,
+ GdkEventButton *event)
{
- ECal *client;
- ESource *source;
-
- if (task_table->user_created_cal != NULL)
- client = task_table->user_created_cal;
- else {
- ECalModel *model;
+ const gchar *widget_path;
- model = e_task_table_get_model (task_table);
- client = e_cal_model_get_default_client (model);
- }
+ widget_path = "/task-list-popup";
+ e_shell_view_show_popup_menu (shell_view, widget_path, event);
- source = e_cal_get_source (client);
- task_shell_view_add_source (task_shell_view, source);
+ return TRUE;
}
static void
@@ -251,21 +153,15 @@ e_task_shell_view_private_init (ETaskShellView *task_shell_view,
{
ETaskShellViewPrivate *priv = task_shell_view->priv;
ESourceList *source_list;
- GHashTable *client_table;
GObject *object;
object = G_OBJECT (shell_view_class->type_module);
source_list = g_object_get_data (object, "source-list");
g_return_if_fail (E_IS_SOURCE_LIST (source_list));
- client_table = g_hash_table_new_full (
- g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_object_unref);
-
priv->source_list = g_object_ref (source_list);
priv->task_actions = gtk_action_group_new ("tasks");
- priv->client_table = client_table;
+ priv->filter_actions = gtk_action_group_new ("tasks-filter");
if (!gal_view_collection_loaded (shell_view_class->view_collection))
task_shell_view_load_view_collection (shell_view_class);
@@ -280,14 +176,18 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view)
{
ETaskShellViewPrivate *priv = task_shell_view->priv;
ETaskShellContent *task_shell_content;
+ ETaskShellSidebar *task_shell_sidebar;
+ EShellView *shell_view;
+ EShellWindow *shell_window;
EShellContent *shell_content;
EShellSidebar *shell_sidebar;
- EShellView *shell_view;
ETaskTable *task_table;
ECalModel *model;
ETable *table;
+ ESourceSelector *selector;
shell_view = E_SHELL_VIEW (task_shell_view);
+ shell_window = e_shell_view_get_shell_window (shell_view);
shell_content = e_shell_view_get_shell_content (shell_view);
shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
@@ -300,6 +200,9 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view)
model = e_task_table_get_model (task_table);
table = e_task_table_get_table (task_table);
+ task_shell_sidebar = E_TASK_SHELL_SIDEBAR (shell_sidebar);
+ selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
+
g_signal_connect_swapped (
task_table, "open-component",
G_CALLBACK (e_task_shell_view_open_task),
@@ -340,8 +243,40 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view)
G_CALLBACK (e_task_shell_view_update_sidebar),
task_shell_view);
+ g_signal_connect_swapped (
+ task_shell_sidebar, "client-added",
+ G_CALLBACK (task_shell_view_selector_client_added_cb),
+ task_shell_view);
+
+ g_signal_connect_swapped (
+ task_shell_sidebar, "client-removed",
+ G_CALLBACK (task_shell_view_selector_client_removed_cb),
+ task_shell_view);
+
+ g_signal_connect_swapped (
+ task_shell_sidebar, "status-message",
+ G_CALLBACK (e_task_shell_view_set_status_message),
+ task_shell_view);
+
+ g_signal_connect_swapped (
+ selector, "popup-event",
+ G_CALLBACK (task_shell_view_selector_popup_event_cb),
+ task_shell_view);
+
+ g_signal_connect_swapped (
+ selector, "primary-selection-changed",
+ G_CALLBACK (e_shell_view_update_actions),
+ task_shell_view);
+
+ e_categories_register_change_listener (
+ G_CALLBACK (e_task_shell_view_update_search_filter),
+ task_shell_view);
+
e_task_shell_view_actions_init (task_shell_view);
e_task_shell_view_update_sidebar (task_shell_view);
+ e_task_shell_view_update_search_filter (task_shell_view);
+
+ e_task_shell_view_execute_search (task_shell_view);
}
void
@@ -352,13 +287,11 @@ e_task_shell_view_private_dispose (ETaskShellView *task_shell_view)
DISPOSE (priv->source_list);
DISPOSE (priv->task_actions);
+ DISPOSE (priv->filter_actions);
DISPOSE (priv->task_shell_content);
DISPOSE (priv->task_shell_sidebar);
- g_hash_table_remove_all (priv->client_table);
- DISPOSE (priv->default_client);
-
if (task_shell_view->priv->activity != NULL) {
/* XXX Activity is no cancellable. */
e_activity_complete (task_shell_view->priv->activity);
@@ -370,9 +303,13 @@ e_task_shell_view_private_dispose (ETaskShellView *task_shell_view)
void
e_task_shell_view_private_finalize (ETaskShellView *task_shell_view)
{
- ETaskShellViewPrivate *priv = task_shell_view->priv;
+ /* XXX Nothing to do? */
+}
- g_hash_table_destroy (priv->client_table);
+void
+e_task_shell_view_execute_search (ETaskShellView *task_shell_view)
+{
+ /* FIXME */
}
void
diff --git a/calendar/modules/e-task-shell-view-private.h b/calendar/modules/e-task-shell-view-private.h
index ed55a794df..ac198b936d 100644
--- a/calendar/modules/e-task-shell-view-private.h
+++ b/calendar/modules/e-task-shell-view-private.h
@@ -26,15 +26,18 @@
#include <string.h>
#include <glib/gi18n.h>
+#include <libedataserver/e-categories.h>
+#include <libedataserver/e-sexp.h>
#include "e-util/e-dialog-utils.h"
#include "e-util/e-error.h"
#include "e-util/e-util.h"
+#include "e-util/gconf-bridge.h"
#include "calendar/common/authentication.h"
#include "calendar/gui/misc.h"
+#include "calendar/gui/e-cal-component-preview.h"
#include "calendar/gui/e-calendar-selector.h"
-#include "calendar/gui/e-task-preview.h"
#include "calendar/gui/dialogs/calendar-setup.h"
#include "calendar/gui/dialogs/task-editor.h"
@@ -63,6 +66,25 @@
G_BEGIN_DECLS
+/* Filter items are displayed in ascending order.
+ * Non-negative values are reserved for categories. */
+enum {
+ TASK_FILTER_ANY_CATEGORY = -7,
+ TASK_FILTER_UNMATCHED = -6,
+ TASK_FILTER_NEXT_7_DAYS_TASKS = -5,
+ TASK_FILTER_ACTIVE_TASKS = -4,
+ TASK_FILTER_OVERDUE_TASKS = -3,
+ TASK_FILTER_COMPLETED_TASKS = -2,
+ TASK_FILTER_TASKS_WITH_ATTACHMENTS = -1
+};
+
+/* Search items are displayed in ascending order. */
+enum {
+ TASK_SEARCH_SUMMARY_CONTAINS,
+ TASK_SEARCH_DESCRIPTION_CONTAINS,
+ TASK_SEARCH_ANY_FIELD_CONTAINS
+};
+
struct _ETaskShellViewPrivate {
/*** Module Data ***/
@@ -72,6 +94,7 @@ struct _ETaskShellViewPrivate {
/*** UI Management ***/
GtkActionGroup *task_actions;
+ GtkActionGroup *filter_actions;
/*** Other Stuff ***/
@@ -79,10 +102,6 @@ struct _ETaskShellViewPrivate {
ETaskShellContent *task_shell_content;
ETaskShellSidebar *task_shell_sidebar;
- /* UID -> Client */
- GHashTable *client_table;
- ECal *default_client;
-
EActivity *activity;
};
@@ -100,7 +119,7 @@ void e_task_shell_view_private_finalize
void e_task_shell_view_actions_init
(ETaskShellView *task_shell_view);
-void e_task_shell_view_actions_update
+void e_task_shell_view_execute_search
(ETaskShellView *task_shell_view);
void e_task_shell_view_open_task
(ETaskShellView *task_shell_view,
@@ -110,6 +129,8 @@ void e_task_shell_view_set_status_message
const gchar *status_message);
void e_task_shell_view_update_sidebar
(ETaskShellView *task_shell_view);
+void e_task_shell_view_update_search_filter
+ (ETaskShellView *task_shell_view);
G_END_DECLS
diff --git a/calendar/modules/e-task-shell-view.c b/calendar/modules/e-task-shell-view.c
index c5284a6397..6de83e90eb 100644
--- a/calendar/modules/e-task-shell-view.c
+++ b/calendar/modules/e-task-shell-view.c
@@ -74,6 +74,145 @@ task_shell_view_constructed (GObject *object)
}
static void
+task_shell_view_update_actions (EShellView *shell_view)
+{
+ ETaskShellViewPrivate *priv;
+ ETaskShellContent *task_shell_content;
+ ETaskShellSidebar *task_shell_sidebar;
+ EShellWindow *shell_window;
+ ESourceSelector *selector;
+ ETable *table;
+ ETaskTable *task_table;
+ ESource *source;
+ GtkAction *action;
+ GSList *list, *iter;
+ const gchar *label;
+ const gchar *uri = NULL;
+ gboolean user_created_source;
+ gboolean assignable = TRUE;
+ gboolean editable = TRUE;
+ gboolean has_url = FALSE;
+ gboolean sensitive;
+ gint n_selected;
+ gint n_complete = 0;
+ gint n_incomplete = 0;
+
+ priv = E_TASK_SHELL_VIEW_GET_PRIVATE (shell_view);
+
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ task_shell_content = priv->task_shell_content;
+ task_table = e_task_shell_content_get_task_table (task_shell_content);
+
+ task_shell_sidebar = priv->task_shell_sidebar;
+ selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
+
+ table = e_task_table_get_table (task_table);
+ n_selected = e_table_selected_count (table);
+
+ list = e_task_table_get_selected (task_table);
+ for (iter = list; iter != NULL; iter = iter->next) {
+ ECalModelComponent *comp_data = iter->data;
+ icalproperty *prop;
+ const gchar *cap;
+ gboolean read_only;
+
+ e_cal_is_read_only (comp_data->client, &read_only, NULL);
+ editable &= !read_only;
+
+ cap = CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT;
+ if (e_cal_get_static_capability (comp_data->client, cap))
+ assignable = FALSE;
+
+ cap = CAL_STATIC_NO_CONV_TO_ASSIGN_TASK;
+ if (e_cal_get_static_capability (comp_data->client, cap))
+ assignable = FALSE;
+
+ prop = icalcomponent_get_first_property (
+ comp_data->icalcomp, ICAL_URL_PROPERTY);
+ has_url |= (prop != NULL);
+
+ prop = icalcomponent_get_first_property (
+ comp_data->icalcomp, ICAL_COMPLETED_PROPERTY);
+ if (prop != NULL)
+ n_complete++;
+ else
+ n_incomplete++;
+ }
+ g_slist_free (list);
+
+ source = e_source_selector_peek_primary_selection (selector);
+ if (source != NULL)
+ uri = e_source_peek_relative_uri (source);
+ user_created_source = (uri != NULL && strcmp (uri, "system") != 0);
+
+ action = ACTION (TASK_ASSIGN);
+ sensitive = (n_selected == 1) && editable && assignable;
+
+ action = ACTION (TASK_CLIPBOARD_COPY);
+ sensitive = (n_selected > 0);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (TASK_CLIPBOARD_CUT);
+ sensitive = (n_selected > 0) && editable;
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (TASK_CLIPBOARD_PASTE);
+ sensitive = editable;
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (TASK_DELETE);
+ sensitive = (n_selected > 0) && editable;
+ gtk_action_set_sensitive (action, sensitive);
+ label = ngettext ("Delete Task", "Delete Tasks", n_selected);
+ g_object_set (action, "label", label, NULL);
+
+ action = ACTION (TASK_FORWARD);
+ sensitive = (n_selected == 1);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (TASK_LIST_COPY);
+ sensitive = (source != NULL);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (TASK_LIST_DELETE);
+ sensitive = user_created_source;
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (TASK_LIST_PROPERTIES);
+ sensitive = (source != NULL);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (TASK_MARK_COMPLETE);
+ sensitive = (n_selected > 0) && editable && (n_incomplete > 0);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (TASK_MARK_INCOMPLETE);
+ sensitive = (n_selected > 0) && editable && (n_complete > 0);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (TASK_OPEN);
+ sensitive = (n_selected == 1);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (TASK_OPEN_URL);
+ sensitive = (n_selected == 1) && has_url;
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (TASK_PRINT);
+ sensitive = (n_selected == 1);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (TASK_PURGE);
+ sensitive = editable;
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (TASK_SAVE_AS);
+ sensitive = (n_selected == 1);
+ gtk_action_set_sensitive (action, sensitive);
+}
+
+static void
task_shell_view_class_init (ETaskShellView *class,
GTypeModule *type_module)
{
@@ -94,8 +233,11 @@ task_shell_view_class_init (ETaskShellView *class,
shell_view_class->icon_name = "evolution-tasks";
shell_view_class->ui_definition = "evolution-tasks.ui";
shell_view_class->search_options = "/task-search-options";
+ shell_view_class->search_rules = "tasktypes.xml";
shell_view_class->type_module = type_module;
+ shell_view_class->new_shell_content = e_task_shell_content_new;
shell_view_class->new_shell_sidebar = e_task_shell_sidebar_new;
+ shell_view_class->update_actions = task_shell_view_update_actions;
g_object_class_install_property (
object_class,