evolution r36554 - in branches/kill-bonobo: addressbook/gui/component calendar/gui calendar/modules



Author: mbarnes
Date: Sat Oct  4 04:46:50 2008
New Revision: 36554
URL: http://svn.gnome.org/viewvc/evolution?rev=36554&view=rev

Log:
Tweak some aspects of the Contacts module to be more consistent with
Tasks and Memos.

Take a crack at handling command-line URIs.  It's far too long-winded
though.  Will need to revisit and tighten up the code.


Modified:
   branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-actions.c
   branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-private.c
   branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-private.h
   branches/kill-bonobo/addressbook/gui/component/e-book-shell-view.c
   branches/kill-bonobo/calendar/gui/apps_evolution_calendar.schemas.in
   branches/kill-bonobo/calendar/modules/e-memo-shell-module.c
   branches/kill-bonobo/calendar/modules/e-memo-shell-view-actions.c
   branches/kill-bonobo/calendar/modules/e-memo-shell-view-private.c
   branches/kill-bonobo/calendar/modules/e-task-shell-module.c
   branches/kill-bonobo/calendar/modules/e-task-shell-view-actions.c
   branches/kill-bonobo/calendar/modules/e-task-shell-view-private.c
   branches/kill-bonobo/calendar/modules/e-task-shell-view-private.h

Modified: branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-actions.c
==============================================================================
--- branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-actions.c	(original)
+++ branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-actions.c	Sat Oct  4 04:46:50 2008
@@ -463,93 +463,7 @@
 action_search_execute_cb (GtkAction *action,
                           EBookShellView *book_shell_view)
 {
-	EBookShellContent *book_shell_content;
-	EShellView *shell_view;
-	EShellWindow *shell_window;
-	EShellContent *shell_content;
-	GString *string;
-	EAddressbookView *view;
-	EAddressbookModel *model;
-	FilterRule *rule;
-	const gchar *format;
-	const gchar *text;
-	gchar *query;
-	gint value;
-
-	shell_view = E_SHELL_VIEW (book_shell_view);
-	if (!e_shell_view_is_active (shell_view))
-		return;
-
-	shell_content = e_shell_view_get_shell_content (shell_view);
-	text = e_shell_content_get_search_text (shell_content);
-
-	shell_window = e_shell_view_get_shell_window (shell_view);
-	action = ACTION (CONTACT_SEARCH_ANY_FIELD_CONTAINS);
-	value = gtk_radio_action_get_current_value (
-		GTK_RADIO_ACTION (action));
-
-	if (text == NULL || *text == '\0') {
-		text = "";
-		value = CONTACT_SEARCH_ANY_FIELD_CONTAINS;
-	}
-
-	switch (value) {
-		case CONTACT_SEARCH_NAME_CONTAINS:
-			format = "(contains \"full_name\" %s)";
-			break;
-
-		case CONTACT_SEARCH_EMAIL_BEGINS_WITH:
-			format = "(beginswith \"email\" %s)";
-			break;
-
-		default:
-			text = "";
-			/* fall through */
-
-		case CONTACT_SEARCH_ANY_FIELD_CONTAINS:
-			format = "(contains \"x-evolution-any-field\" %s)";
-			break;
-	}
-
-	/* Build the query. */
-	string = g_string_new ("");
-	e_sexp_encode_string (string, text);
-	query = g_strdup_printf (format, string->str);
-	g_string_free (string, TRUE);
-
-	/* Apply selected filter. */
-	value = e_shell_content_get_filter_value (shell_content);
-	if (value > CONTACT_FILTER_ANY_CATEGORY) {
-		GList *categories;
-		const gchar *category_name;
-		gchar *temp;
-
-		categories = e_categories_get_list ();
-		category_name = g_list_nth_data (categories, value);
-		g_list_free (categories);
-
-		temp = g_strdup_printf (
-			"(and (is \"category_list\" \"%s\") %s)",
-			category_name, query);
-		g_free (query);
-		query = temp;
-	}
-
-	/* XXX This is wrong.  We need to programmatically construct a
-	 *     FilterRule, tell it to build code, and pass the resulting
-	 *     expression string to EAddressbookModel. */
-	rule = filter_rule_new ();
-	e_shell_content_set_search_rule (shell_content, rule);
-	g_object_unref (rule);
-
-	/* Submit the query. */
-	book_shell_content = book_shell_view->priv->book_shell_content;
-	view = e_book_shell_content_get_current_view (book_shell_content);
-	model = e_addressbook_view_get_model (view);
-	e_addressbook_model_set_query (model, query);
-	g_free (query);
-
-	e_book_shell_content_set_preview_contact (book_shell_content, NULL);
+	e_book_shell_view_execute_search (book_shell_view);
 }
 
 static void
@@ -856,126 +770,6 @@
 }
 
 void
-e_book_shell_view_actions_update (EBookShellView *book_shell_view)
-{
-	EShellView *shell_view;
-	EShellWindow *shell_window;
-	EAddressbookModel *model;
-	EAddressbookView *view;
-	EBookShellContent *book_shell_content;
-	EBookShellSidebar *book_shell_sidebar;
-	ESelectionModel *selection_model;
-	ESourceSelector *selector;
-	ESource *source;
-	GtkAction *action;
-	const gchar *label;
-	gboolean editable;
-	gboolean sensitive;
-	gint n_contacts;
-	gint n_selected;
-
-	shell_view = E_SHELL_VIEW (book_shell_view);
-	shell_window = e_shell_view_get_shell_window (shell_view);
-
-	book_shell_content = book_shell_view->priv->book_shell_content;
-	view = e_book_shell_content_get_current_view (book_shell_content);
-
-	book_shell_sidebar = book_shell_view->priv->book_shell_sidebar;
-	selector = e_book_shell_sidebar_get_selector (book_shell_sidebar);
-	source = e_source_selector_peek_primary_selection (selector);
-
-	model = e_addressbook_view_get_model (view);
-	editable = e_addressbook_model_get_editable (model);
-
-	selection_model = e_addressbook_view_get_selection_model (view);
-	n_contacts = (selection_model != NULL) ?
-		e_selection_model_row_count (selection_model) : 0;
-	n_selected = (selection_model != NULL) ?
-		e_selection_model_selected_count (selection_model) : 0;
-
-	action = ACTION (ADDRESS_BOOK_STOP);
-	sensitive = e_addressbook_model_can_stop (model);
-	gtk_action_set_sensitive (action, sensitive);
-
-	action = ACTION (CONTACT_CLIPBOARD_COPY);
-	sensitive = (n_selected > 0);
-	gtk_action_set_sensitive (action, sensitive);
-
-	action = ACTION (CONTACT_CLIPBOARD_CUT);
-	sensitive = editable && (n_selected > 0);
-	gtk_action_set_sensitive (action, sensitive);
-
-	action = ACTION (CONTACT_CLIPBOARD_PASTE);
-	sensitive = editable;
-	gtk_action_set_sensitive (action, sensitive);
-
-	action = ACTION (CONTACT_COPY);
-	sensitive = (n_selected > 0);
-	gtk_action_set_sensitive (action, sensitive);
-
-	action = ACTION (CONTACT_DELETE);
-	sensitive = editable && (n_selected > 0);
-	gtk_action_set_sensitive (action, sensitive);
-
-	action = ACTION (CONTACT_FORWARD);
-	sensitive = (n_selected > 0);
-	gtk_action_set_sensitive (action, sensitive);
-	label = ngettext (
-		"_Forward Contact",
-		"_Forward Contacts", n_selected);
-	g_object_set (action, "label", label, NULL);
-
-	action = ACTION (CONTACT_MOVE);
-	sensitive = editable && (n_selected > 0);
-	gtk_action_set_sensitive (action, sensitive);
-
-	action = ACTION (CONTACT_OPEN);
-	sensitive = (n_selected > 0);
-	gtk_action_set_sensitive (action, sensitive);
-
-	action = ACTION (CONTACT_PRINT);
-	sensitive = (n_contacts > 0);
-	gtk_action_set_sensitive (action, sensitive);
-
-	action = ACTION (CONTACT_PRINT_PREVIEW);
-	sensitive = (n_contacts > 0);
-	gtk_action_set_sensitive (action, sensitive);
-
-	action = ACTION (CONTACT_SAVE_AS);
-	sensitive = (n_selected > 0);
-	gtk_action_set_sensitive (action, sensitive);
-
-	action = ACTION (CONTACT_SELECT_ALL);
-	sensitive = (n_contacts > 0);
-	gtk_action_set_sensitive (action, sensitive);
-
-	/* FIXME Also check for email address. */
-	action = ACTION (CONTACT_SEND_MESSAGE);
-	sensitive = (n_selected > 0);
-	gtk_action_set_sensitive (action, sensitive);
-	label = ngettext (
-		"_Send Message to Contact",
-		"_Send Message to Contacts", n_selected);
-	g_object_set (action, "label", label, NULL);
-
-	/* TODO Add some context sensitivity to SEND_MESSAGE:
-	 *      Send Message to Contact  (n_selected == 1)
-	 *      Send Message to Contacts (n_selected > 1)
-	 *      Send Message to List     (n_selected == 1 && is_list)
-	 */
-
-	action = ACTION (ADDRESS_BOOK_DELETE);
-	if (source != NULL) {
-		const gchar *uri;
-
-		uri = e_source_peek_relative_uri (source);
-		sensitive = (uri == NULL || strcmp ("system", uri) != 0);
-	} else
-		sensitive = FALSE;
-	gtk_action_set_sensitive (action, sensitive);
-}
-
-void
 e_book_shell_view_update_search_filter (EBookShellView *book_shell_view)
 {
 	EShellContent *shell_content;

Modified: branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-private.c
==============================================================================
--- branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-private.c	(original)
+++ branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-private.c	Sat Oct  4 04:46:50 2008
@@ -36,7 +36,6 @@
 	widget_path = "/contact-popup";
 	shell_view = E_SHELL_VIEW (book_shell_view);
 
-	e_book_shell_view_actions_update (book_shell_view);
 	e_shell_view_show_popup_menu (shell_view, widget_path, event);
 }
 
@@ -68,15 +67,17 @@
 	EBookShellContent *book_shell_content;
 	EAddressbookView *current_view;
 	ESelectionModel *selection_model;
+	EShellView *shell_view;
 	gint n_selected;
 
+	shell_view = E_SHELL_VIEW (shell_view);
 	book_shell_content = book_shell_view->priv->book_shell_content;
 	current_view = e_book_shell_content_get_current_view (book_shell_content);
 
 	if (view != current_view)
 		return;
 
-	e_book_shell_view_actions_update (book_shell_view);
+	e_shell_view_update_actions (shell_view);
 
 	selection_model = e_addressbook_view_get_selection_model (view);
 
@@ -219,7 +220,7 @@
 
 		g_signal_connect_swapped (
 			widget, "command-state-change",
-			G_CALLBACK (e_book_shell_view_actions_update),
+			G_CALLBACK (e_shell_view_update_actions),
 			book_shell_view);
 
 		g_signal_connect_swapped (
@@ -475,6 +476,105 @@
 }
 
 void
+e_book_shell_view_execute_search (EBookShellView *book_shell_view)
+{
+	EBookShellContent *book_shell_content;
+	EShellView *shell_view;
+	EShellWindow *shell_window;
+	EShellContent *shell_content;
+	GtkAction *action;
+	GString *string;
+	EAddressbookView *view;
+	EAddressbookModel *model;
+	FilterRule *rule;
+	const gchar *format;
+	const gchar *text;
+	gchar *query;
+	gchar *temp;
+	gint value;
+
+	shell_view = E_SHELL_VIEW (book_shell_view);
+	if (!e_shell_view_is_active (shell_view))
+		return;
+
+	shell_content = e_shell_view_get_shell_content (shell_view);
+	text = e_shell_content_get_search_text (shell_content);
+
+	shell_window = e_shell_view_get_shell_window (shell_view);
+	action = ACTION (CONTACT_SEARCH_ANY_FIELD_CONTAINS);
+	value = gtk_radio_action_get_current_value (
+		GTK_RADIO_ACTION (action));
+
+	if (text == NULL || *text == '\0') {
+		text = "";
+		value = CONTACT_SEARCH_ANY_FIELD_CONTAINS;
+	}
+
+	switch (value) {
+		case CONTACT_SEARCH_NAME_CONTAINS:
+			format = "(contains \"full_name\" %s)";
+			break;
+
+		case CONTACT_SEARCH_EMAIL_BEGINS_WITH:
+			format = "(beginswith \"email\" %s)";
+			break;
+
+		default:
+			text = "";
+			/* fall through */
+
+		case CONTACT_SEARCH_ANY_FIELD_CONTAINS:
+			format = "(contains \"x-evolution-any-field\" %s)";
+			break;
+	}
+
+	/* Build the query. */
+	string = g_string_new ("");
+	e_sexp_encode_string (string, text);
+	query = g_strdup_printf (format, string->str);
+	g_string_free (string, TRUE);
+
+	/* Apply selected filter. */
+	value = e_shell_content_get_filter_value (shell_content);
+	switch (value) {
+		case CONTACT_FILTER_ANY_CATEGORY:
+			break;
+
+		default:
+		{
+			GList *categories;
+			const gchar *category_name;
+
+			categories = e_categories_get_list ();
+			category_name = g_list_nth_data (categories, value);
+			g_list_free (categories);
+
+			temp = g_strdup_printf (
+				"(and (is \"category_list\" \"%s\") %s)",
+				category_name, query);
+			g_free (query);
+			query = temp;
+		}
+	}
+
+	/* XXX This is wrong.  We need to programmatically construct a
+	 *     FilterRule, tell it to build code, and pass the resulting
+	 *     expression string to EAddressbookModel. */
+	rule = filter_rule_new ();
+	e_shell_content_set_search_rule (shell_content, rule);
+	g_object_unref (rule);
+
+	/* Submit the query. */
+	book_shell_content = book_shell_view->priv->book_shell_content;
+	view = e_book_shell_content_get_current_view (book_shell_content);
+	model = e_addressbook_view_get_model (view);
+	e_addressbook_model_set_query (model, query);
+	g_free (query);
+
+	e_book_shell_content_set_preview_contact (book_shell_content, NULL);
+}
+
+void
 e_book_shell_view_editor_weak_notify (EditorUidClosure *closure,
                                       GObject *where_the_object_was)
 {

Modified: branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-private.h
==============================================================================
--- branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-private.h	(original)
+++ branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-private.h	Sat Oct  4 04:46:50 2008
@@ -120,7 +120,7 @@
 
 void		e_book_shell_view_actions_init
 					(EBookShellView *book_shell_view);
-void		e_book_shell_view_actions_update
+void		e_book_shell_view_execute_search
 					(EBookShellView *book_shell_view);
 void		e_book_shell_view_editor_weak_notify
 					(EditorUidClosure *closure,

Modified: branches/kill-bonobo/addressbook/gui/component/e-book-shell-view.c
==============================================================================
--- branches/kill-bonobo/addressbook/gui/component/e-book-shell-view.c	(original)
+++ branches/kill-bonobo/addressbook/gui/component/e-book-shell-view.c	Sat Oct  4 04:46:50 2008
@@ -35,8 +35,10 @@
 {
 	EBookShellViewPrivate *priv = book_shell_view->priv;
 	EBookShellContent *book_shell_content;
+	EShellView *shell_view;
 	GList *keys, *iter;
 
+	shell_view = E_SHELL_VIEW (book_shell_view);
 	book_shell_content = book_shell_view->priv->book_shell_content;
 
 	keys = g_hash_table_get_keys (priv->uid_to_view);
@@ -74,7 +76,7 @@
 	}
 	g_list_free (keys);
 
-	e_book_shell_view_actions_update (book_shell_view);
+	e_shell_view_update_actions (shell_view);
 }
 
 static void
@@ -131,6 +133,127 @@
 }
 
 static void
+book_shell_view_update_actions (EShellView *shell_view)
+{
+	EBookShellViewPrivate *priv;
+	EBookShellContent *book_shell_content;
+	EBookShellSidebar *book_shell_sidebar;
+	EShellWindow *shell_window;
+	EAddressbookModel *model;
+	EAddressbookView *view;
+	ESelectionModel *selection_model;
+	ESourceSelector *selector;
+	ESource *source;
+	GtkAction *action;
+	const gchar *label;
+	gboolean editable;
+	gboolean sensitive;
+	gint n_contacts;
+	gint n_selected;
+
+	priv = E_BOOK_SHELL_VIEW_GET_PRIVATE (shell_view);
+
+	shell_window = e_shell_view_get_shell_window (shell_view);
+
+	book_shell_content = priv->book_shell_content;
+	view = e_book_shell_content_get_current_view (book_shell_content);
+
+	book_shell_sidebar = priv->book_shell_sidebar;
+	selector = e_book_shell_sidebar_get_selector (book_shell_sidebar);
+	source = e_source_selector_peek_primary_selection (selector);
+
+	model = e_addressbook_view_get_model (view);
+	editable = e_addressbook_model_get_editable (model);
+
+	selection_model = e_addressbook_view_get_selection_model (view);
+	n_contacts = (selection_model != NULL) ?
+		e_selection_model_row_count (selection_model) : 0;
+	n_selected = (selection_model != NULL) ?
+		e_selection_model_selected_count (selection_model) : 0;
+
+	action = ACTION (ADDRESS_BOOK_STOP);
+	sensitive = e_addressbook_model_can_stop (model);
+	gtk_action_set_sensitive (action, sensitive);
+
+	action = ACTION (CONTACT_CLIPBOARD_COPY);
+	sensitive = (n_selected > 0);
+	gtk_action_set_sensitive (action, sensitive);
+
+	action = ACTION (CONTACT_CLIPBOARD_CUT);
+	sensitive = editable && (n_selected > 0);
+	gtk_action_set_sensitive (action, sensitive);
+
+	action = ACTION (CONTACT_CLIPBOARD_PASTE);
+	sensitive = editable;
+	gtk_action_set_sensitive (action, sensitive);
+
+	action = ACTION (CONTACT_COPY);
+	sensitive = (n_selected > 0);
+	gtk_action_set_sensitive (action, sensitive);
+
+	action = ACTION (CONTACT_DELETE);
+	sensitive = editable && (n_selected > 0);
+	gtk_action_set_sensitive (action, sensitive);
+
+	action = ACTION (CONTACT_FORWARD);
+	sensitive = (n_selected > 0);
+	gtk_action_set_sensitive (action, sensitive);
+	label = ngettext (
+		"_Forward Contact",
+		"_Forward Contacts", n_selected);
+	g_object_set (action, "label", label, NULL);
+
+	action = ACTION (CONTACT_MOVE);
+	sensitive = editable && (n_selected > 0);
+	gtk_action_set_sensitive (action, sensitive);
+
+	action = ACTION (CONTACT_OPEN);
+	sensitive = (n_selected > 0);
+	gtk_action_set_sensitive (action, sensitive);
+
+	action = ACTION (CONTACT_PRINT);
+	sensitive = (n_contacts > 0);
+	gtk_action_set_sensitive (action, sensitive);
+
+	action = ACTION (CONTACT_PRINT_PREVIEW);
+	sensitive = (n_contacts > 0);
+	gtk_action_set_sensitive (action, sensitive);
+
+	action = ACTION (CONTACT_SAVE_AS);
+	sensitive = (n_selected > 0);
+	gtk_action_set_sensitive (action, sensitive);
+
+	action = ACTION (CONTACT_SELECT_ALL);
+	sensitive = (n_contacts > 0);
+	gtk_action_set_sensitive (action, sensitive);
+
+	/* FIXME Also check for email address. */
+	action = ACTION (CONTACT_SEND_MESSAGE);
+	sensitive = (n_selected > 0);
+	gtk_action_set_sensitive (action, sensitive);
+	label = ngettext (
+		"_Send Message to Contact",
+		"_Send Message to Contacts", n_selected);
+	g_object_set (action, "label", label, NULL);
+
+	/* TODO Add some context sensitivity to SEND_MESSAGE:
+	 *      Send Message to Contact  (n_selected == 1)
+	 *      Send Message to Contacts (n_selected > 1)
+	 *      Send Message to List     (n_selected == 1 && is_list)
+	 */
+
+	action = ACTION (ADDRESS_BOOK_DELETE);
+	if (source != NULL) {
+		const gchar *uri;
+
+		uri = e_source_peek_relative_uri (source);
+		sensitive = (uri == NULL || strcmp ("system", uri) != 0);
+	} else
+		sensitive = FALSE;
+	gtk_action_set_sensitive (action, sensitive);
+}
+
+static void
 book_shell_view_class_init (EBookShellViewClass *class,
                             GTypeModule *type_module)
 {
@@ -155,6 +278,7 @@
 	shell_view_class->type_module = type_module;
 	shell_view_class->new_shell_content = e_book_shell_content_new;
 	shell_view_class->new_shell_sidebar = e_book_shell_sidebar_new;
+	shell_view_class->update_actions = book_shell_view_update_actions;
 
 	g_object_class_install_property (
 		object_class,

Modified: branches/kill-bonobo/calendar/gui/apps_evolution_calendar.schemas.in
==============================================================================
--- branches/kill-bonobo/calendar/gui/apps_evolution_calendar.schemas.in	(original)
+++ branches/kill-bonobo/calendar/gui/apps_evolution_calendar.schemas.in	Sat Oct  4 04:46:50 2008
@@ -256,13 +256,25 @@
     </schema>
 
     <schema>
+      <key>/schemas/apps/evolution/calendar/display/memo_vpane_position</key>
+      <applyto>/apps/evolution/calendar/display/memo_vpane_position</applyto>
+      <owner>evolution-calendar</owner>
+      <type>int</type>
+      <default>400</default>
+      <locale name="C">
+        <short>Memos vertical pane position</short>
+        <long>Position of the vertical pane, between the memo list and the memo preview pane, in pixels.</long>
+      </locale>
+    </schema>
+
+    <schema>
       <key>/schemas/apps/evolution/calendar/display/task_vpane_position</key>
       <applyto>/apps/evolution/calendar/display/task_vpane_position</applyto>
       <owner>evolution-calendar</owner>
       <type>int</type>
       <default>400</default>
       <locale name="C">
-        <short>Tasks vertical pane position </short>
+        <short>Tasks vertical pane position</short>
         <long>Position of the vertical pane, between the task list and the task preview pane, in pixels.</long>
       </locale>
     </schema>

Modified: branches/kill-bonobo/calendar/modules/e-memo-shell-module.c
==============================================================================
--- branches/kill-bonobo/calendar/modules/e-memo-shell-module.c	(original)
+++ branches/kill-bonobo/calendar/modules/e-memo-shell-module.c	Sat Oct  4 04:46:50 2008
@@ -22,6 +22,7 @@
 #include <string.h>
 #include <glib/gi18n.h>
 #include <libecal/e-cal.h>
+#include <libedataserver/e-url.h>
 #include <libedataserver/e-source.h>
 #include <libedataserver/e-source-list.h>
 #include <libedataserver/e-source-group.h>
@@ -307,8 +308,137 @@
 memo_module_handle_uri (EShellModule *shell_module,
                         const gchar *uri)
 {
-	/* FIXME */
-	return FALSE;
+	CompEditor *editor;
+	CompEditorFlags flags = 0;
+	ECal *client;
+	ECalComponent *comp;
+	ESource *source;
+	ESourceList *source_list;
+	ECalSourceType source_type;
+	EUri *euri;
+	icalcomponent *icalcomp;
+	const gchar *cp;
+	gchar *source_uid = NULL;
+	gchar *comp_uid = NULL;
+	gchar *comp_rid = NULL;
+	gboolean handled = FALSE;
+	GError *error = NULL;
+
+	source_type = E_CAL_SOURCE_TYPE_JOURNAL;
+
+	if (strncmp (uri, "memo:", 5) != 0)
+		return FALSE;
+
+	euri = e_uri_new (uri);
+	cp = euri->query;
+	if (cp == NULL)
+		goto exit;
+
+	while (*cp != '\0') {
+		gchar *header;
+		gchar *content;
+		gsize header_len;
+		gsize content_len;
+
+		header_len = strcspn (cp, "=&");
+
+		/* If it's malformed, give up. */
+		if (cp[header_len] != '=')
+			break;
+
+		header = (gchar *) cp;
+		header[header_len] = '\0';
+		cp += header_len + 1;
+
+		content_len = strcspn (cp, "&");
+
+		content = g_strndup (cp, content_len);
+		if (g_ascii_strcasecmp (header, "source-uid") == 0)
+			source_uid = g_strdup (content);
+		else if (g_ascii_strcasecmp (header, "comp-uid") == 0)
+			comp_uid = g_strdup (content);
+		else if (g_ascii_strcasecmp (header, "comp-rid") == 0)
+			comp_rid = g_strdup (content);
+		g_free (content);
+
+		cp += content_len;
+		if (*cp == '&') {
+			cp++;
+			if (strcmp (cp, "amp;") == 0)
+				cp += 4;
+		}
+	}
+
+	if (source_uid == NULL || comp_uid == NULL)
+		goto exit;
+
+	/* URI is valid, so consider it handled.  Whether
+	 * we successfully open it is another matter... */
+	handled = TRUE;
+
+	if (!e_cal_get_sources (&source_list, source_type, NULL)) {
+		g_printerr ("Could not get memo sources from GConf!\n");
+		goto exit;
+	}
+
+	source = e_source_list_peek_source_by_uid (source_list, source_uid);
+	if (source == NULL) {
+		g_printerr ("No source for UID `%s'\n", source_uid);
+		g_object_unref (source_list);
+		goto exit;
+	}
+
+	client = auth_new_cal_from_source (source, source_type);
+	if (client == NULL || !e_cal_open (client, TRUE, &error)) {
+		g_printerr ("%s\n", error->message);
+		g_object_unref (source_list);
+		g_error_free (error);
+		goto exit;
+	}
+
+	/* XXX Copied from e_memo_shell_view_open_memo().
+	 *     Clearly a new utility function is needed. */
+
+	editor = comp_editor_find_instance (comp_uid);
+
+	if (editor != NULL)
+		goto present;
+
+	if (!e_cal_get_object (client, comp_uid, comp_rid, &icalcomp, &error)) {
+		g_printerr ("%s\n", error->message);
+		g_object_unref (source_list);
+		g_error_free (error);
+		goto exit;
+	}
+
+	comp = e_cal_component_new ();
+	e_cal_component_set_icalcomponent (comp, icalcomp);
+
+	if (e_cal_component_has_organizer (comp))
+		flags |= COMP_EDITOR_IS_SHARED;
+
+	if (itip_organizer_is_user (comp, client))
+		flags |= COMP_EDITOR_USER_ORG;
+
+	editor = memo_editor_new (client, flags);
+	comp_editor_edit_comp (editor, comp);
+
+	g_object_unref (comp);
+
+present:
+	gtk_window_present (GTK_WINDOW (editor));
+
+	g_object_unref (source_list);
+	g_object_unref (client);
+
+exit:
+	g_free (source_uid);
+	g_free (comp_uid);
+	g_free (comp_rid);
+
+	e_uri_free (euri);
+
+	return handled;
 }
 
 static void

Modified: branches/kill-bonobo/calendar/modules/e-memo-shell-view-actions.c
==============================================================================
--- branches/kill-bonobo/calendar/modules/e-memo-shell-view-actions.c	(original)
+++ branches/kill-bonobo/calendar/modules/e-memo-shell-view-actions.c	Sat Oct  4 04:46:50 2008
@@ -785,6 +785,6 @@
 	/* Use any action in the group; doesn't matter which. */
 	e_shell_content_set_filter_action (shell_content, radio_action);
 
-	e_shell_content_add_filter_separator_after (
-		shell_content, MEMO_FILTER_UNMATCHED);
+	ii = MEMO_FILTER_UNMATCHED;
+	e_shell_content_add_filter_separator_after (shell_content, ii);
 }

Modified: branches/kill-bonobo/calendar/modules/e-memo-shell-view-private.c
==============================================================================
--- branches/kill-bonobo/calendar/modules/e-memo-shell-view-private.c	(original)
+++ branches/kill-bonobo/calendar/modules/e-memo-shell-view-private.c	Sat Oct  4 04:46:50 2008
@@ -322,6 +322,7 @@
 	const gchar *format;
 	const gchar *text;
 	gchar *query;
+	gchar *temp;
 	gint value;
 
 	shell_view = E_SHELL_VIEW (memo_shell_view);
@@ -364,27 +365,32 @@
 
 	/* Apply selected filter. */
 	value = e_shell_content_get_filter_value (shell_content);
-	if (value == MEMO_FILTER_UNMATCHED) {
-		gchar *temp;
+	switch (value) {
+		case MEMO_FILTER_ANY_CATEGORY:
+			break;
+
+		case MEMO_FILTER_UNMATCHED:
+			temp = g_strdup_printf (
+				"(and (has-categories? #f) %s", query);
+			g_free (query);
+			query = temp;
+			break;
 
-		temp = g_strdup_printf (
-			"(and (has-categories? #f) %s", query);
-		g_free (query);
-		query = temp;
-	} else if (value >= 0) {
-		GList *categories;
-		const gchar *category_name;
-		gchar *temp;
-
-		categories = e_categories_get_list ();
-		category_name = g_list_nth_data (categories, value);
-		g_list_free (categories);
-
-		temp = g_strdup_printf (
-			"(and (has-categories? \"%s\") %s)",
-			category_name, query);
-		g_free (query);
-		query = temp;
+		default:
+		{
+			GList *categories;
+			const gchar *category_name;
+
+			categories = e_categories_get_list ();
+			category_name = g_list_nth_data (categories, value);
+			g_list_free (categories);
+
+			temp = g_strdup_printf (
+				"(and (has-categories? \"%s\") %s)",
+				category_name, query);
+			g_free (query);
+			query = temp;
+		}
 	}
 
 	/* XXX This is wrong.  We need to programmatically construct a

Modified: branches/kill-bonobo/calendar/modules/e-task-shell-module.c
==============================================================================
--- branches/kill-bonobo/calendar/modules/e-task-shell-module.c	(original)
+++ branches/kill-bonobo/calendar/modules/e-task-shell-module.c	Sat Oct  4 04:46:50 2008
@@ -22,6 +22,7 @@
 #include <string.h>
 #include <glib/gi18n.h>
 #include <libecal/e-cal.h>
+#include <libedataserver/e-url.h>
 #include <libedataserver/e-source.h>
 #include <libedataserver/e-source-list.h>
 #include <libedataserver/e-source-group.h>
@@ -307,8 +308,143 @@
 task_module_handle_uri (EShellModule *shell_module,
                         const gchar *uri)
 {
-        /* FIXME */
-        return FALSE;
+	CompEditor *editor;
+	CompEditorFlags flags = 0;
+	ECal *client;
+	ECalComponent *comp;
+	ESource *source;
+	ESourceList *source_list;
+	ECalSourceType source_type;
+	EUri *euri;
+	icalcomponent *icalcomp;
+	icalproperty *icalprop;
+	const gchar *cp;
+	gchar *source_uid = NULL;
+	gchar *comp_uid = NULL;
+	gchar *comp_rid = NULL;
+	gboolean handled = FALSE;
+	GError *error = NULL;
+
+	source_type = E_CAL_SOURCE_TYPE_TODO;
+
+	if (strncmp (uri, "task:", 5) != 0)
+		return FALSE;
+
+	euri = e_uri_new (uri);
+	cp = euri->query;
+	if (cp == NULL)
+		goto exit;
+
+	while (*cp != '\0') {
+                gchar *header;
+                gchar *content;
+                gsize header_len;
+                gsize content_len;
+
+                header_len = strcspn (cp, "=&");
+
+                /* If it's malformed, give up. */
+                if (cp[header_len] != '=')
+                        break;
+
+                header = (gchar *) cp;
+                header[header_len] = '\0';
+                cp += header_len + 1;
+
+                content_len = strcspn (cp, "&");
+
+                content = g_strndup (cp, content_len);
+                if (g_ascii_strcasecmp (header, "source-uid") == 0)
+                        source_uid = g_strdup (content);
+                else if (g_ascii_strcasecmp (header, "comp-uid") == 0)
+                        comp_uid = g_strdup (content);
+                else if (g_ascii_strcasecmp (header, "comp-rid") == 0)
+                        comp_rid = g_strdup (content);
+                g_free (content);
+
+                cp += content_len;
+                if (*cp == '&') {
+                        cp++;
+                        if (strcmp (cp, "amp;") == 0)
+                                cp += 4;
+                }
+	}
+
+	if (source_uid != NULL || comp_uid != NULL)
+		goto exit;
+
+	/* URI is valid, so consider it handled.  Whether
+	 * we successfully open it is another matter... */
+	handled = TRUE;
+
+	if (!e_cal_get_sources (&source_list, source_type, NULL)) {
+		g_printerr ("Could not get task sources from GConf!\n");
+		goto exit;
+	}
+
+	source = e_source_list_peek_source_by_uid (source_list, source_uid);
+	if (source == NULL) {
+		g_printerr ("No source for UID `%s'\n", source_uid);
+		g_object_unref (source_list);
+		goto exit;
+	}
+
+	client = auth_new_cal_from_source (source, source_type);
+	if (client == NULL || !e_cal_open (client, TRUE, &error)) {
+		g_printerr ("%s\n", error->message);
+		g_object_unref (source_list);
+		g_error_free (error);
+		goto exit;
+	}
+
+	/* XXX Copied from e_task_shell_view_open_task().
+	 *     Clearly a new utility function is needed. */
+
+	editor = comp_editor_find_instance (comp_uid);
+
+	if (editor != NULL)
+		goto present;
+
+	if (!e_cal_get_object (client, comp_uid, comp_rid, &icalcomp, &error)) {
+		g_printerr ("%s\n", error->message);
+		g_object_unref (source_list);
+		g_error_free (error);
+		goto exit;
+	}
+
+	comp = e_cal_component_new ();
+	e_cal_component_set_icalcomponent (comp, icalcomp);
+
+	icalprop = icalcomponent_get_first_property (
+		icalcomp, ICAL_ATTENDEE_PROPERTY);
+	if (icalprop != NULL)
+		flags |= COMP_EDITOR_IS_ASSIGNED;
+
+	if (itip_organizer_is_user (comp, client))
+		flags |= COMP_EDITOR_USER_ORG;
+
+	if (!e_cal_component_has_attendees (comp))
+		flags |= COMP_EDITOR_USER_ORG;
+
+	editor = task_editor_new (client, flags);
+	comp_editor_edit_comp (editor, comp);
+
+	g_object_unref (comp);
+
+present:
+	gtk_window_present (GTK_WINDOW (editor));
+
+	g_object_unref (source_list);
+	g_object_unref (client);
+
+exit:
+	g_free (source_uid);
+	g_free (comp_uid);
+	g_free (comp_rid);
+
+	e_uri_free (euri);
+
+	return handled;
 }
 
 static void

Modified: branches/kill-bonobo/calendar/modules/e-task-shell-view-actions.c
==============================================================================
--- branches/kill-bonobo/calendar/modules/e-task-shell-view-actions.c	(original)
+++ branches/kill-bonobo/calendar/modules/e-task-shell-view-actions.c	Sat Oct  4 04:46:50 2008
@@ -785,7 +785,14 @@
 	  N_("Tasks with Attachments"),
 	  NULL,
 	  NULL,  /* XXX Add a tooltip! */
-	  TASK_FILTER_TASKS_WITH_ATTACHMENTS }
+	  TASK_FILTER_TASKS_WITH_ATTACHMENTS },
+
+	{ "task-filter-unmatched",
+	  NULL,
+	  N_("Unmatched"),
+	  NULL,
+	  NULL,  /* XXX Add a tooltip! */
+	  TASK_FILTER_UNMATCHED }
 };
 
 static GtkRadioActionEntry task_search_entries[] = {
@@ -924,4 +931,10 @@
 
 	/* Use any action in the group; doesn't matter which. */
 	e_shell_content_set_filter_action (shell_content, radio_action);
+
+	ii = TASK_FILTER_UNMATCHED;
+	e_shell_content_add_filter_separator_after (shell_content, ii);
+
+	ii = TASK_FILTER_TASKS_WITH_ATTACHMENTS;
+	e_shell_content_add_filter_separator_after (shell_content, ii);
 }

Modified: branches/kill-bonobo/calendar/modules/e-task-shell-view-private.c
==============================================================================
--- branches/kill-bonobo/calendar/modules/e-task-shell-view-private.c	(original)
+++ branches/kill-bonobo/calendar/modules/e-task-shell-view-private.c	Sat Oct  4 04:46:50 2008
@@ -321,7 +321,11 @@
 	FilterRule *rule;
 	const gchar *format;
 	const gchar *text;
+	time_t start_range;
+	time_t end_range;
+	gchar *start, *end;
 	gchar *query;
+	gchar *temp;
 	gint value;
 
 	shell_view = E_SHELL_VIEW (task_shell_view);
@@ -364,7 +368,92 @@
 
 	/* Apply selected filter. */
 	value = e_shell_content_get_filter_value (shell_content);
-	/* FIXME */
+	switch (value) {
+		case TASK_FILTER_ANY_CATEGORY:
+			break;
+
+		case TASK_FILTER_UNMATCHED:
+			temp = g_strdup_printf (
+				"(and (has-categories? #f) %s)", query);
+			g_free (query);
+			query = temp;
+			break;
+
+		case TASK_FILTER_NEXT_7_DAYS_TASKS:
+			start_range = time (NULL);
+			end_range = time_add_day (start_range, 7);
+			start = isodate_from_time_t (start_range);
+			end = isodate_from_time_t (end_range);
+
+			temp = g_strdup_printf (
+				"(and %s (due-in-time-range? "
+				"(make-time \"%s\") (make-time \"%s\")))",
+				query, start, end);
+			g_free (query);
+			query = temp;
+			break;
+
+		case TASK_FILTER_ACTIVE_TASKS:
+			start_range = time (NULL);
+			end_range = time_add_day (start_range, 365);
+			start = isodate_from_time_t (start_range);
+			end = isodate_from_time_t (end_range);
+
+			temp = g_strdup_printf (
+				"(and %s (due-in-time-range? "
+				"(make-time \"%s\") (make-time \"%s\")) "
+				"(not (is-completed?)))",
+				query, start, end);
+			g_free (query);
+			query = temp;
+			break;
+
+		case TASK_FILTER_OVERDUE_TASKS:
+			start_range = 0;
+			end_range = time (NULL);
+			start = isodate_from_time_t (start_range);
+			end = isodate_from_time_t (end_range);
+
+			temp = g_strdup_printf (
+				"(and %s (due-in-time-range? "
+				"(make-time \"%s\") (make-time \"%s\")) "
+				"(not (is-completed?)))",
+				query, start, end);
+			g_free (query);
+			query = temp;
+			break;
+
+		case TASK_FILTER_COMPLETED_TASKS:
+			temp = g_strdup_printf (
+				"(and (is-completed?) %s)", query);
+			g_free (query);
+			query = temp;
+			break;
+
+		case TASK_FILTER_TASKS_WITH_ATTACHMENTS:
+			temp = g_strdup_printf (
+				"(and (has-attachments?) %s)", query);
+			g_free (query);
+			query = temp;
+			break;
+
+		default:
+		{
+			GList *categories;
+			const gchar *category_name;
+
+			categories = e_categories_get_list ();
+			category_name = g_list_nth_data (categories, value);
+			g_list_free (categories);
+
+			temp = g_strdup_printf (
+				"(and (has-categories? \"%s\") %s)",
+				category_name, query);
+			g_free (query);
+			query = temp;
+			break;
+		}
+	}
 
 	/* XXX This is wrong.  We need to programmatically construct a
 	 *     FilterRule, tell it to build code, and pass the resulting
@@ -402,7 +491,7 @@
 	uid = icalcomponent_get_uid (comp_data->icalcomp);
 	editor = comp_editor_find_instance (uid);
 
-	if (editor == NULL)
+	if (editor != NULL)
 		goto exit;
 
 	comp = e_cal_component_new ();

Modified: branches/kill-bonobo/calendar/modules/e-task-shell-view-private.h
==============================================================================
--- branches/kill-bonobo/calendar/modules/e-task-shell-view-private.h	(original)
+++ branches/kill-bonobo/calendar/modules/e-task-shell-view-private.h	Sat Oct  4 04:46:50 2008
@@ -26,6 +26,7 @@
 
 #include <string.h>
 #include <glib/gi18n.h>
+#include <libecal/e-cal-time-util.h>
 #include <libedataserver/e-categories.h>
 #include <libedataserver/e-sexp.h>
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]