[evolution] Bug 200907 - Add support for recurring tasks
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 200907 - Add support for recurring tasks
- Date: Thu, 15 Mar 2018 16:33:12 +0000 (UTC)
commit 8197757ed0897b88e349891a3c526219b5ccd373
Author: Milan Crha <mcrha redhat com>
Date: Thu Mar 15 17:34:29 2018 +0100
Bug 200907 - Add support for recurring tasks
src/calendar/gui/e-cal-component-preview.c | 18 +++++++-
src/calendar/gui/e-cal-model-tasks.c | 46 +--------------------
src/calendar/gui/e-comp-editor-page-recurrence.c | 9 ++++
src/calendar/gui/e-comp-editor-property-part.c | 10 ++--
src/calendar/gui/e-comp-editor-task.c | 48 +++++++++++++++++++++-
src/calendar/gui/e-comp-editor.c | 3 +-
6 files changed, 81 insertions(+), 53 deletions(-)
---
diff --git a/src/calendar/gui/e-cal-component-preview.c b/src/calendar/gui/e-cal-component-preview.c
index 77a0252..bb47e36 100644
--- a/src/calendar/gui/e-cal-component-preview.c
+++ b/src/calendar/gui/e-cal-component-preview.c
@@ -23,8 +23,6 @@
#include "evolution-config.h"
-#include "e-cal-component-preview.h"
-
#include <string.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
@@ -32,6 +30,10 @@
#include "shell/e-shell-utils.h"
+#include "calendar-config.h"
+
+#include "e-cal-component-preview.h"
+
#define E_CAL_COMPONENT_PREVIEW_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_CAL_COMPONENT_PREVIEW, ECalComponentPreviewPrivate))
@@ -288,6 +290,18 @@ cal_component_preview_write_html (ECalComponentPreview *preview,
}
e_cal_component_free_datetime (&dt);
+ if (e_cal_util_component_has_recurrences (e_cal_component_get_icalcomponent (comp))) {
+ str = e_cal_recur_describe_recurrence (e_cal_component_get_icalcomponent (comp),
+ calendar_config_get_week_start_day (), E_CAL_RECUR_DESCRIBE_RECURRENCE_FLAG_NONE);
+
+ if (str) {
+ g_string_append_printf (
+ buffer, "<tr><th>%s</th><td>%s</td></tr>",
+ _("Recurs:"), str);
+ g_free (str);
+ }
+ }
+
/* write status */
icalcomp = e_cal_component_get_icalcomponent (comp);
icalprop = icalcomponent_get_first_property (
diff --git a/src/calendar/gui/e-cal-model-tasks.c b/src/calendar/gui/e-cal-model-tasks.c
index 02ce42f..7df5ebf 100644
--- a/src/calendar/gui/e-cal-model-tasks.c
+++ b/src/calendar/gui/e-cal-model-tasks.c
@@ -76,50 +76,8 @@ static void
ensure_task_complete (ECalModelComponent *comp_data,
time_t completed_date)
{
- icalproperty *prop;
- gboolean set_completed = TRUE;
-
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_COMPLETED_PROPERTY);
-
- /* Date Completed. */
- if (completed_date == -1) {
- if (prop)
- set_completed = FALSE;
- else
- completed_date = time (NULL);
- }
-
- if (set_completed) {
- icaltimezone *utc_zone;
- struct icaltimetype new_completed;
-
- /* COMPLETED is stored in UTC. */
- utc_zone = icaltimezone_get_utc_timezone ();
- new_completed = icaltime_from_timet_with_zone (
- completed_date,
- FALSE,
- utc_zone);
- if (prop)
- icalproperty_set_completed (prop, new_completed);
- else {
- prop = icalproperty_new_completed (new_completed);
- icalcomponent_add_property (comp_data->icalcomp, prop);
- }
- }
-
- /* Percent. */
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_PERCENTCOMPLETE_PROPERTY);
- if (!prop)
- icalcomponent_add_property (comp_data->icalcomp, icalproperty_new_percentcomplete (100));
- else
- icalproperty_set_percentcomplete (prop, 100);
-
- /* Status. */
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_STATUS_PROPERTY);
- if (prop)
- icalproperty_set_status (prop, ICAL_STATUS_COMPLETED);
- else
- icalcomponent_add_property (comp_data->icalcomp, icalproperty_new_status
(ICAL_STATUS_COMPLETED));
+ e_cal_util_mark_task_complete_sync (comp_data->icalcomp, completed_date,
+ comp_data->client, NULL, NULL);
}
static void
diff --git a/src/calendar/gui/e-comp-editor-page-recurrence.c
b/src/calendar/gui/e-comp-editor-page-recurrence.c
index dcbf1e7..c6111cf 100644
--- a/src/calendar/gui/e-comp-editor-page-recurrence.c
+++ b/src/calendar/gui/e-comp-editor-page-recurrence.c
@@ -1957,6 +1957,7 @@ ecep_recurrence_setup_ui (ECompEditorPageRecurrence *page_recurrence)
ECompEditor *comp_editor;
GtkUIManager *ui_manager;
GtkActionGroup *action_group;
+ GtkAction *action;
GError *error = NULL;
g_return_if_fail (E_IS_COMP_EDITOR_PAGE_RECURRENCE (page_recurrence));
@@ -1970,6 +1971,14 @@ ecep_recurrence_setup_ui (ECompEditorPageRecurrence *page_recurrence)
gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
+ action = gtk_action_group_get_action (action_group, "page-recurrence");
+ if (action) {
+ e_binding_bind_property (
+ page_recurrence, "visible",
+ action, "visible",
+ G_BINDING_SYNC_CREATE);
+ }
+
g_clear_object (&comp_editor);
if (error) {
diff --git a/src/calendar/gui/e-comp-editor-property-part.c b/src/calendar/gui/e-comp-editor-property-part.c
index 07b7c5b..ae6a734 100644
--- a/src/calendar/gui/e-comp-editor-property-part.c
+++ b/src/calendar/gui/e-comp-editor-property-part.c
@@ -1183,11 +1183,11 @@ ecepp_picker_fill_component (ECompEditorPropertyPart *property_part,
g_return_if_fail (GTK_IS_COMBO_BOX_TEXT (edit_widget));
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (edit_widget));
- g_return_if_fail (id != NULL);
-
- e_comp_editor_property_part_picker_set_to_component (
- E_COMP_EDITOR_PROPERTY_PART_PICKER (property_part),
- id, component);
+ if (id) {
+ e_comp_editor_property_part_picker_set_to_component (
+ E_COMP_EDITOR_PROPERTY_PART_PICKER (property_part),
+ id, component);
+ }
}
static void
diff --git a/src/calendar/gui/e-comp-editor-task.c b/src/calendar/gui/e-comp-editor-task.c
index 86c1dca..46e69e9 100644
--- a/src/calendar/gui/e-comp-editor-task.c
+++ b/src/calendar/gui/e-comp-editor-task.c
@@ -28,6 +28,7 @@
#include "e-comp-editor-page.h"
#include "e-comp-editor-page-attachments.h"
#include "e-comp-editor-page-general.h"
+#include "e-comp-editor-page-recurrence.h"
#include "e-comp-editor-page-reminders.h"
#include "e-comp-editor-property-part.h"
#include "e-comp-editor-property-parts.h"
@@ -36,6 +37,7 @@
struct _ECompEditorTaskPrivate {
ECompEditorPage *page_general;
+ ECompEditorPage *recurrence_page;
ECompEditorPropertyPart *categories;
ECompEditorPropertyPart *dtstart;
ECompEditorPropertyPart *due_date;
@@ -168,6 +170,7 @@ ece_task_notify_target_client_cb (GObject *object,
GtkAction *action;
gboolean date_only;
gboolean was_allday;
+ gboolean can_recur;
g_return_if_fail (E_IS_COMP_EDITOR_TASK (object));
@@ -197,6 +200,9 @@ ece_task_notify_target_client_cb (GObject *object,
action = e_comp_editor_get_action (comp_editor, "all-day-task");
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
}
+
+ can_recur = !cal_client || e_client_check_capability (E_CLIENT (cal_client),
CAL_STATIC_CAPABILITY_TASK_CAN_RECUR);
+ gtk_widget_set_visible (GTK_WIDGET (task_editor->priv->recurrence_page), can_recur);
}
static void
@@ -524,6 +530,21 @@ ece_task_fill_component (ECompEditor *comp_editor,
return FALSE;
}
+ if (e_cal_util_component_has_recurrences (component)) {
+ struct icaltimetype dtstart;
+
+ dtstart = e_comp_editor_property_part_datetime_get_value
(E_COMP_EDITOR_PROPERTY_PART_DATETIME (task_editor->priv->dtstart));
+
+ if (icaltime_is_null_time (dtstart) || !icaltime_is_valid_time (dtstart)) {
+ e_comp_editor_set_validation_error (comp_editor,
+ task_editor->priv->page_general,
+ e_comp_editor_property_part_get_edit_widget (task_editor->priv->dtstart),
+ _("Start date is required for recurring tasks"));
+
+ return FALSE;
+ }
+ }
+
if (!e_comp_editor_property_part_datetime_check_validity (
E_COMP_EDITOR_PROPERTY_PART_DATETIME (task_editor->priv->due_date), NULL, NULL)) {
@@ -557,7 +578,28 @@ ece_task_fill_component (ECompEditor *comp_editor,
return FALSE;
}
- return E_COMP_EDITOR_CLASS (e_comp_editor_task_parent_class)->fill_component (comp_editor, component);
+ if (!E_COMP_EDITOR_CLASS (e_comp_editor_task_parent_class)->fill_component (comp_editor, component))
+ return FALSE;
+
+ if (e_cal_util_component_has_recurrences (component)) {
+ ECalClient *cal_client;
+
+ cal_client = e_comp_editor_get_source_client (comp_editor);
+ if (!cal_client)
+ cal_client = e_comp_editor_get_target_client (comp_editor);
+
+ if (cal_client) {
+ if ((e_comp_editor_get_flags (comp_editor) & E_COMP_EDITOR_FLAG_IS_NEW) != 0) {
+ e_cal_util_init_recur_task_sync (component, cal_client, NULL, NULL);
+ } else if (icalcomponent_get_first_property (component, ICAL_COMPLETED_PROPERTY)) {
+ e_cal_util_mark_task_complete_sync (component, (time_t) -1, cal_client, NULL,
NULL);
+ } else if (!icalcomponent_get_first_property (component, ICAL_DUE_PROPERTY)) {
+ e_cal_util_init_recur_task_sync (component, cal_client, NULL, NULL);
+ }
+ }
+ }
+
+ return TRUE;
}
static void
@@ -781,6 +823,10 @@ e_comp_editor_task_constructed (GObject *object)
page = e_comp_editor_page_reminders_new (comp_editor);
e_comp_editor_add_page (comp_editor, C_("ECompEditorPage", "Reminders"), page);
+ page = e_comp_editor_page_recurrence_new (comp_editor);
+ e_comp_editor_add_page (comp_editor, C_("ECompEditorPage", "Recurrence"), page);
+ task_editor->priv->recurrence_page = page;
+
page = e_comp_editor_page_attachments_new (comp_editor);
e_comp_editor_add_page (comp_editor, C_("ECompEditorPage", "Attachments"), page);
diff --git a/src/calendar/gui/e-comp-editor.c b/src/calendar/gui/e-comp-editor.c
index 8a43cbc..31936c3 100644
--- a/src/calendar/gui/e-comp-editor.c
+++ b/src/calendar/gui/e-comp-editor.c
@@ -1623,7 +1623,8 @@ ece_fill_component (ECompEditor *comp_editor,
ECompEditorPage *page = link->data;
g_warn_if_fail (E_IS_COMP_EDITOR_PAGE (page));
- if (!E_IS_COMP_EDITOR_PAGE (page))
+ if (!E_IS_COMP_EDITOR_PAGE (page) ||
+ !gtk_widget_get_visible (GTK_WIDGET (page)))
continue;
if (!e_comp_editor_page_fill_component (page, component))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]