[evolution/wip/gsettings] Bug #657170 - Disallow creating assigned tasks when not supported



commit 8a0ae7db0077177d3e34c9ae00dcd54f2f882bd1
Author: Milan Crha <mcrha redhat com>
Date:   Mon Sep 26 11:08:46 2011 +0200

    Bug #657170 - Disallow creating assigned tasks when not supported

 calendar/calendar.error.xml        |    7 +++++++
 calendar/gui/dialogs/comp-editor.c |   24 ++++++++++++++++++++++++
 calendar/gui/dialogs/task-page.c   |    6 ++++++
 3 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/calendar/calendar.error.xml b/calendar/calendar.error.xml
index 3d7d657..e1c9b3f 100644
--- a/calendar/calendar.error.xml
+++ b/calendar/calendar.error.xml
@@ -259,6 +259,13 @@
   <button stock ="gtk-ok" response="GTK_RESPONSE_YES"/>
  </error>
 
+ <error id="prompt-no-task-assignment-editor" type="error" default="GTK_RESPONSE_YES">
+  <_primary>Cannot save task</_primary>
+  <!-- For Translators: {0} is the name of the calendar source -->
+  <_secondary>'{0}' does not support assigned tasks, please select a different task list.</_secondary>
+  <button stock ="gtk-ok" response="GTK_RESPONSE_YES"/>
+ </error>
+
  <error id="prompt-no-contents-offline-tasks" type="error" default="GTK_RESPONSE_YES">
   <_primary>Error loading task list</_primary>
   <_secondary>The task list is not marked for offline usage.</_secondary>
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index fc062a0..5efab79 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -960,6 +960,18 @@ action_save_cb (GtkAction *action,
 		return;
 	}
 
+	if ((comp_editor_get_flags (editor) & COMP_EDITOR_IS_ASSIGNED) != 0
+	    && e_cal_component_get_vtype (priv->comp) == E_CAL_COMPONENT_TODO
+	    && e_client_check_capability (E_CLIENT (priv->cal_client), CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT)) {
+		e_alert_submit (
+			E_ALERT_SINK (editor),
+			"calendar:prompt-no-task-assignment-editor",
+			e_source_peek_name (
+				e_client_get_source (E_CLIENT (priv->cal_client))),
+			NULL);
+		return;
+	}
+
 	commit_all_fields (editor);
 	if (e_cal_component_has_recurrences (priv->comp)) {
 		if (!recur_component_dialog (
@@ -2209,6 +2221,18 @@ prompt_and_save_changes (CompEditor *editor,
 			return FALSE;
 		}
 
+		if ((comp_editor_get_flags (editor) & COMP_EDITOR_IS_ASSIGNED) != 0
+		    && e_cal_component_get_vtype (priv->comp) == E_CAL_COMPONENT_TODO
+		    && e_client_check_capability (E_CLIENT (priv->cal_client), CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT)) {
+			e_alert_submit (
+				E_ALERT_SINK (editor),
+				"calendar:prompt-no-task-assignment-editor",
+				e_source_peek_name (
+					e_client_get_source (E_CLIENT (priv->cal_client))),
+				NULL);
+			return FALSE;
+		}
+
 		comp = comp_editor_get_current_comp (editor, &correct);
 		e_cal_component_get_summary (comp, &text);
 		g_object_unref (comp);
diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c
index d88976b..e0aa030 100644
--- a/calendar/gui/dialogs/task-page.c
+++ b/calendar/gui/dialogs/task-page.c
@@ -290,6 +290,12 @@ sensitize_widgets (TaskPage *tpage)
 		gchar *tmp = g_strconcat ("<b>", _("Task cannot be fully edited, because you are not the organizer"), "</b>", NULL);
 		task_page_set_info_string (tpage, GTK_STOCK_DIALOG_INFO, tmp);
 		g_free (tmp);
+	} else if ((flags & COMP_EDITOR_IS_ASSIGNED) != 0 && e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT)) {
+		gchar *tmp = g_strconcat ("<b>", _("Task cannot be edited, because the selected task list does not support assigned tasks"), "</b>", NULL);
+		task_page_set_info_string (tpage, GTK_STOCK_DIALOG_INFO, tmp);
+		g_free (tmp);
+		sens = FALSE;
+		read_only = TRUE;
 	} else if (!check_starts_in_the_past (tpage)) {
 		task_page_set_info_string (tpage, priv->subscriber_info_text ? GTK_STOCK_DIALOG_INFO : NULL, priv->subscriber_info_text);
 	}



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