[evolution] I#106 - Add an option to "Hide cancelled events"



commit ad2e87b6b6e5ccc6ae2421f7ee093ce4778393f1
Author: Milan Crha <mcrha redhat com>
Date:   Wed Sep 5 17:45:18 2018 +0200

    I#106 - Add an option to "Hide cancelled events"
    
    Closes https://gitlab.gnome.org/GNOME/evolution/issues/106

 data/org.gnome.evolution.calendar.gschema.xml.in |  5 ++
 src/calendar/gui/e-cal-data-model.c              | 96 +++++++++++++++++++++++-
 src/calendar/gui/e-cal-data-model.h              |  5 ++
 src/calendar/gui/e-cal-list-view.c               |  3 +
 src/calendar/gui/e-cal-list-view.etspec          |  4 +-
 src/calendar/gui/e-cal-model.c                   |  7 ++
 src/calendar/gui/e-cal-model.h                   |  1 +
 src/calendar/gui/e-day-view.c                    |  7 ++
 src/calendar/gui/e-memo-table.c                  | 10 ++-
 src/calendar/gui/e-task-table.etspec             | 12 +--
 src/calendar/gui/e-to-do-pane.c                  | 16 ++--
 src/calendar/gui/e-week-view.c                   |  5 ++
 src/modules/calendar/e-cal-base-shell-content.c  |  8 ++
 src/modules/calendar/e-calendar-preferences.c    |  6 ++
 src/modules/calendar/e-calendar-preferences.ui   | 15 ++++
 15 files changed, 184 insertions(+), 16 deletions(-)
---
diff --git a/data/org.gnome.evolution.calendar.gschema.xml.in 
b/data/org.gnome.evolution.calendar.gschema.xml.in
index 9ba4104156..4813b6e14a 100644
--- a/data/org.gnome.evolution.calendar.gschema.xml.in
+++ b/data/org.gnome.evolution.calendar.gschema.xml.in
@@ -219,6 +219,11 @@
       <_summary>Hide task value</_summary>
       <_description>Number of units for determining when to hide tasks</_description>
     </key>
+    <key name="hide-cancelled-events" type="b">
+      <default>false</default>
+      <_summary>Hide cancelled events</_summary>
+      <_description>Whether to hide cancelled events in the calendar view</_description>
+    </key>
     <key name="hide-cancelled-tasks" type="b">
       <default>false</default>
       <_summary>Hide cancelled tasks</_summary>
diff --git a/src/calendar/gui/e-cal-data-model.c b/src/calendar/gui/e-cal-data-model.c
index c43c59eb90..2e2aab826e 100644
--- a/src/calendar/gui/e-cal-data-model.c
+++ b/src/calendar/gui/e-cal-data-model.c
@@ -37,6 +37,7 @@ struct _ECalDataModelPrivate {
 
        gboolean disposing;
        gboolean expand_recurrences;
+       gboolean skip_cancelled;
        gchar *filter;
        gchar *full_filter;     /* to be used with views */
        icaltimezone *zone;
@@ -54,7 +55,8 @@ struct _ECalDataModelPrivate {
 enum {
        PROP_0,
        PROP_EXPAND_RECURRENCES,
-       PROP_TIMEZONE
+       PROP_TIMEZONE,
+       PROP_SKIP_CANCELLED
 };
 
 enum {
@@ -1071,6 +1073,7 @@ typedef struct
        ECalClient *client;
        icaltimezone *zone;
        GSList **pexpanded_recurrences;
+       gboolean skip_cancelled;
 } GenerateInstancesData;
 
 static gboolean
@@ -1082,10 +1085,15 @@ cal_data_model_instance_generated (ECalComponent *comp,
        GenerateInstancesData *gid = data;
        ComponentData *comp_data;
        ECalComponent *comp_copy;
+       icalproperty_status status = ICAL_STATUS_NONE;
        icaltimetype tt, tt2;
 
        g_return_val_if_fail (gid != NULL, FALSE);
 
+       e_cal_component_get_status (comp, &status);
+       if (gid->skip_cancelled && status == ICAL_STATUS_CANCELLED)
+               return TRUE;
+
        comp_copy = e_cal_component_clone (comp);
        g_return_val_if_fail (comp_copy != NULL, FALSE);
 
@@ -1173,6 +1181,7 @@ cal_data_model_expand_recurrences_thread (ECalDataModel *data_model,
                gid.client = client;
                gid.pexpanded_recurrences = &expanded_recurrences;
                gid.zone = data_model->priv->zone;
+               gid.skip_cancelled = data_model->priv->skip_cancelled;
 
                e_cal_client_generate_instances_for_object_sync (client, icomp, range_start, range_end,
                        cal_data_model_instance_generated, &gid);
@@ -1268,6 +1277,10 @@ cal_data_model_process_modified_or_added_objects (ECalClientView *view,
                                ComponentData *comp_data;
                                time_t instance_start, instance_end;
 
+                               if (data_model->priv->skip_cancelled &&
+                                   icalcomponent_get_status (icomp) == ICAL_STATUS_CANCELLED)
+                                       continue;
+
                                comp = e_cal_component_new_from_icalcomponent (icalcomponent_new_clone 
(icomp));
                                if (!comp)
                                        continue;
@@ -1929,6 +1942,12 @@ cal_data_model_set_property (GObject *object,
                                E_CAL_DATA_MODEL (object),
                                g_value_get_pointer (value));
                        return;
+
+               case PROP_SKIP_CANCELLED:
+                       e_cal_data_model_set_skip_cancelled (
+                               E_CAL_DATA_MODEL (object),
+                               g_value_get_boolean (value));
+                       return;
        }
 
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -1954,6 +1973,13 @@ cal_data_model_get_property (GObject *object,
                                e_cal_data_model_get_timezone (
                                E_CAL_DATA_MODEL (object)));
                        return;
+
+               case PROP_SKIP_CANCELLED:
+                       g_value_set_boolean (
+                               value,
+                               e_cal_data_model_get_skip_cancelled (
+                               E_CAL_DATA_MODEL (object)));
+                       return;
        }
 
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -2021,6 +2047,16 @@ e_cal_data_model_class_init (ECalDataModelClass *class)
                        NULL,
                        G_PARAM_READWRITE));
 
+       g_object_class_install_property (
+               object_class,
+               PROP_SKIP_CANCELLED,
+               g_param_spec_boolean (
+                       "skip-cancelled",
+                       "Skip Cancelled",
+                       NULL,
+                       FALSE,
+                       G_PARAM_READWRITE));
+
        signals[VIEW_STATE_CHANGED] = g_signal_new (
                "view-state-changed",
                G_TYPE_FROM_CLASS (class),
@@ -2047,6 +2083,7 @@ e_cal_data_model_init (ECalDataModel *data_model)
 
        data_model->priv->disposing = FALSE;
        data_model->priv->expand_recurrences = FALSE;
+       data_model->priv->skip_cancelled = FALSE;
        data_model->priv->zone = icaltimezone_get_utc_timezone ();
 
        data_model->priv->views_update_freeze = 0;
@@ -2112,6 +2149,7 @@ e_cal_data_model_new_clone (ECalDataModel *src_data_model)
        g_clear_object (&func_responder);
 
        e_cal_data_model_set_expand_recurrences (clone, e_cal_data_model_get_expand_recurrences 
(src_data_model));
+       e_cal_data_model_set_skip_cancelled (clone, e_cal_data_model_get_skip_cancelled (src_data_model));
        e_cal_data_model_set_timezone (clone, e_cal_data_model_get_timezone (src_data_model));
        e_cal_data_model_set_filter (clone, src_data_model->priv->filter);
 
@@ -2241,6 +2279,62 @@ e_cal_data_model_set_expand_recurrences (ECalDataModel *data_model,
        UNLOCK_PROPS ();
 }
 
+/**
+ * e_cal_data_model_get_skip_cancelled:
+ * @data_model: an #EDataModel instance
+ *
+ * Obtains whether the @data_model skips cancelled components.
+ * The default value is #FALSE, to not skip cancelled components.
+ *
+ * Returns: Whether the @data_model skips cancelled components.
+ *
+ * Since: 3.32
+ **/
+gboolean
+e_cal_data_model_get_skip_cancelled (ECalDataModel *data_model)
+{
+       gboolean skip_cancelled;
+
+       g_return_val_if_fail (E_IS_CAL_DATA_MODEL (data_model), FALSE);
+
+       LOCK_PROPS ();
+
+       skip_cancelled = data_model->priv->skip_cancelled;
+
+       UNLOCK_PROPS ();
+
+       return skip_cancelled;
+}
+
+/**
+ * e_cal_data_model_set_skip_cancelled:
+ * @data_model: an #EDataModel instance
+ * @skip_cancelled: whether to skip cancelled components
+ *
+ * Sets whether the @data_model should skip cancelled components.
+ *
+ * Since: 3.32
+ **/
+void
+e_cal_data_model_set_skip_cancelled (ECalDataModel *data_model,
+                                    gboolean skip_cancelled)
+{
+       g_return_if_fail (E_IS_CAL_DATA_MODEL (data_model));
+
+       LOCK_PROPS ();
+
+       if ((data_model->priv->skip_cancelled ? 1 : 0) == (skip_cancelled ? 1 : 0)) {
+               UNLOCK_PROPS ();
+               return;
+       }
+
+       data_model->priv->skip_cancelled = skip_cancelled;
+
+       cal_data_model_rebuild_everything (data_model, TRUE);
+
+       UNLOCK_PROPS ();
+}
+
 /**
  * e_cal_data_model_get_timezone:
  * @data_model: an #EDataModel instance
diff --git a/src/calendar/gui/e-cal-data-model.h b/src/calendar/gui/e-cal-data-model.h
index c0696a3308..ff0b05c581 100644
--- a/src/calendar/gui/e-cal-data-model.h
+++ b/src/calendar/gui/e-cal-data-model.h
@@ -102,6 +102,11 @@ gboolean   e_cal_data_model_get_expand_recurrences
 void           e_cal_data_model_set_expand_recurrences
                                                (ECalDataModel *data_model,
                                                 gboolean expand_recurrences);
+gboolean       e_cal_data_model_get_skip_cancelled
+                                               (ECalDataModel *data_model);
+void           e_cal_data_model_set_skip_cancelled
+                                               (ECalDataModel *data_model,
+                                                gboolean expand_recurrences);
 icaltimezone * e_cal_data_model_get_timezone   (ECalDataModel *data_model);
 void           e_cal_data_model_set_timezone   (ECalDataModel *data_model,
                                                 icaltimezone *zone);
diff --git a/src/calendar/gui/e-cal-list-view.c b/src/calendar/gui/e-cal-list-view.c
index 3ca21de7c6..755d1c8f1d 100644
--- a/src/calendar/gui/e-cal-list-view.c
+++ b/src/calendar/gui/e-cal-list-view.c
@@ -175,6 +175,7 @@ setup_e_table (ECalListView *cal_list_view)
        g_object_set (
                cell,
                "bg_color_column", E_CAL_MODEL_FIELD_COLOR,
+               "strikeout_column", E_CAL_MODEL_FIELD_CANCELLED,
                NULL);
 
        e_table_extras_add_cell (extras, "calstring", cell);
@@ -186,6 +187,7 @@ setup_e_table (ECalListView *cal_list_view)
        g_object_set (
                cell,
                "bg_color_column", E_CAL_MODEL_FIELD_COLOR,
+               "strikeout_column", E_CAL_MODEL_FIELD_CANCELLED,
                NULL);
 
        e_binding_bind_property (
@@ -227,6 +229,7 @@ setup_e_table (ECalListView *cal_list_view)
        g_object_set (
                cell,
                "bg_color_column", E_CAL_MODEL_FIELD_COLOR,
+               "strikeout_column", E_CAL_MODEL_FIELD_CANCELLED,
                "editable", FALSE,
                NULL);
 
diff --git a/src/calendar/gui/e-cal-list-view.etspec b/src/calendar/gui/e-cal-list-view.etspec
index 0a6d10070c..0b772c0d45 100644
--- a/src/calendar/gui/e-cal-list-view.etspec
+++ b/src/calendar/gui/e-cal-list-view.etspec
@@ -1,9 +1,9 @@
 <ETableSpecification draw-grid="true" alternating-row-colors="true">
   <ETableColumn model_col="5" _title="Start Date" expansion="2.0" minimum_width="10" resizable="true" 
cell="dateedit" compare="date-compare" priority="-2"/>
-  <ETableColumn model_col="13" _title="End Date" expansion="2.0" minimum_width="10" resizable="true" 
cell="dateedit" compare="date-compare" priority="-2"/>
+  <ETableColumn model_col="14" _title="End Date" expansion="2.0" minimum_width="10" resizable="true" 
cell="dateedit" compare="date-compare" priority="-2"/>
   <ETableColumn model_col="8" _title="Summary" expansion="3.0" minimum_width="10" resizable="true" 
cell="calstring" compare="collate" priority="10"/>
   <ETableColumn model_col="4" _title="Description" expansion="3.0" minimum_width="10" resizable="true" 
cell="calstring" compare="collate" priority="10"/>
-  <ETableColumn model_col="14" _title="Location" expansion="3.0" minimum_width="10" resizable="true" 
cell="calstring" compare="collate" priority="10"/>
+  <ETableColumn model_col="15" _title="Location" expansion="3.0" minimum_width="10" resizable="true" 
cell="calstring" compare="collate" priority="10"/>
   <ETableColumn model_col="0" _title="Categories" cell="calstring" compare="collate" expansion="1.0" 
minimum_width="10" resizable="true" priority="-2"/>
   <ETableColumn model_col="10" _title="Created" expansion="2.0" minimum_width="10" resizable="true" 
cell="dateedit" compare="date-compare" priority="-2"/>
   <ETableColumn model_col="11" _title="Last modified" expansion="2.0" minimum_width="10" resizable="true" 
cell="dateedit" compare="date-compare" priority="-2"/>
diff --git a/src/calendar/gui/e-cal-model.c b/src/calendar/gui/e-cal-model.c
index 7706d2255d..d15a6d6201 100644
--- a/src/calendar/gui/e-cal-model.c
+++ b/src/calendar/gui/e-cal-model.c
@@ -1663,6 +1663,8 @@ cal_model_value_at (ETableModel *etm,
                return get_uid (comp_data);
        case E_CAL_MODEL_FIELD_SOURCE:
                return get_source_description (registry, comp_data);
+       case E_CAL_MODEL_FIELD_CANCELLED:
+               return GINT_TO_POINTER (icalcomponent_get_status (comp_data->icalcomp) == 
ICAL_STATUS_CANCELLED ? 1 : 0);
        }
 
        return (gpointer) "";
@@ -1760,6 +1762,7 @@ cal_model_duplicate_value (ETableModel *etm,
        case E_CAL_MODEL_FIELD_HAS_ALARMS :
        case E_CAL_MODEL_FIELD_ICON :
        case E_CAL_MODEL_FIELD_COLOR :
+       case E_CAL_MODEL_FIELD_CANCELLED:
                return (gpointer) value;
        case E_CAL_MODEL_FIELD_COMPONENT :
                return icalcomponent_new_clone ((icalcomponent *) value);
@@ -1791,6 +1794,7 @@ cal_model_free_value (ETableModel *etm,
        case E_CAL_MODEL_FIELD_HAS_ALARMS :
        case E_CAL_MODEL_FIELD_ICON :
        case E_CAL_MODEL_FIELD_COLOR :
+       case E_CAL_MODEL_FIELD_CANCELLED:
                break;
        case E_CAL_MODEL_FIELD_DTSTART:
        case E_CAL_MODEL_FIELD_CREATED :
@@ -1832,6 +1836,7 @@ cal_model_initialize_value (ETableModel *etm,
        case E_CAL_MODEL_FIELD_ICON :
        case E_CAL_MODEL_FIELD_COLOR :
        case E_CAL_MODEL_FIELD_COMPONENT :
+       case E_CAL_MODEL_FIELD_CANCELLED:
                return NULL;
        }
 
@@ -1876,6 +1881,7 @@ cal_model_value_is_empty (ETableModel *etm,
        case E_CAL_MODEL_FIELD_ICON :
        case E_CAL_MODEL_FIELD_COLOR :
        case E_CAL_MODEL_FIELD_COMPONENT :
+       case E_CAL_MODEL_FIELD_CANCELLED:
                return TRUE;
        }
 
@@ -1908,6 +1914,7 @@ cal_model_value_to_string (ETableModel *etm,
                else
                        return g_strdup (_("Assigned"));
        case E_CAL_MODEL_FIELD_HAS_ALARMS :
+       case E_CAL_MODEL_FIELD_CANCELLED:
                return g_strdup (value ? _("Yes") : _("No"));
        case E_CAL_MODEL_FIELD_COLOR :
        case E_CAL_MODEL_FIELD_COMPONENT :
diff --git a/src/calendar/gui/e-cal-model.h b/src/calendar/gui/e-cal-model.h
index 720e85996b..ce56036782 100644
--- a/src/calendar/gui/e-cal-model.h
+++ b/src/calendar/gui/e-cal-model.h
@@ -89,6 +89,7 @@ typedef enum {
        E_CAL_MODEL_FIELD_CREATED,
        E_CAL_MODEL_FIELD_LASTMODIFIED,
        E_CAL_MODEL_FIELD_SOURCE,           /* not a real field */
+       E_CAL_MODEL_FIELD_CANCELLED,        /* not a real field */
        E_CAL_MODEL_FIELD_LAST
 } ECalModelField;
 
diff --git a/src/calendar/gui/e-day-view.c b/src/calendar/gui/e-day-view.c
index 7dd7e88f99..2715c04b2e 100644
--- a/src/calendar/gui/e-day-view.c
+++ b/src/calendar/gui/e-day-view.c
@@ -3337,6 +3337,9 @@ set_style_from_attendee (EDayViewEvent *event,
                }
        }
 
+       if (icalcomponent_get_status (event->comp_data->icalcomp) == ICAL_STATUS_CANCELLED)
+               gnome_canvas_item_set (event->canvas_item, "strikeout", TRUE, NULL);
+
        /* The attendee has not yet accepted the meeting, display the summary as bolded.
         * If the attendee is not present, it might have come through a mailing list.
         * In that case, we never show the meeting as bold even if it is unaccepted. */
@@ -3435,6 +3438,8 @@ e_day_view_update_event_label (EDayView *day_view,
 
        if (e_cal_util_component_has_attendee (event->comp_data->icalcomp))
                set_style_from_attendee (event, registry);
+       else if (icalcomponent_get_status (event->comp_data->icalcomp) == ICAL_STATUS_CANCELLED)
+               gnome_canvas_item_set (event->canvas_item, "strikeout", TRUE, NULL);
 
        if (free_text)
                g_free (text);
@@ -3478,6 +3483,8 @@ e_day_view_update_long_event_label (EDayView *day_view,
 
        if (e_cal_util_component_has_attendee (event->comp_data->icalcomp))
                set_style_from_attendee (event, registry);
+       else if (icalcomponent_get_status (event->comp_data->icalcomp) == ICAL_STATUS_CANCELLED)
+               gnome_canvas_item_set (event->canvas_item, "strikeout", TRUE, NULL);
 }
 
 /* Finds the day and index of the event with the given canvas item.
diff --git a/src/calendar/gui/e-memo-table.c b/src/calendar/gui/e-memo-table.c
index 581bf3da4b..829339b496 100644
--- a/src/calendar/gui/e-memo-table.c
+++ b/src/calendar/gui/e-memo-table.c
@@ -283,7 +283,10 @@ memo_table_constructed (GObject *object)
         * Normal string fields.
         */
        cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT);
-       g_object_set (cell, "bg_color_column", E_CAL_MODEL_FIELD_COLOR, NULL);
+       g_object_set (cell,
+               "bg_color_column", E_CAL_MODEL_FIELD_COLOR,
+               "strikeout_column", E_CAL_MODEL_FIELD_CANCELLED,
+               NULL);
        e_table_extras_add_cell (extras, "calstring", cell);
        g_object_unref (cell);
 
@@ -291,7 +294,10 @@ memo_table_constructed (GObject *object)
         * Date fields.
         */
        cell = e_cell_date_edit_text_new (NULL, GTK_JUSTIFY_LEFT);
-       g_object_set (cell, "bg_color_column", E_CAL_MODEL_FIELD_COLOR, NULL);
+       g_object_set (cell,
+               "bg_color_column", E_CAL_MODEL_FIELD_COLOR,
+               "strikeout_column", E_CAL_MODEL_FIELD_CANCELLED,
+               NULL);
 
        e_binding_bind_property (
                model, "timezone",
diff --git a/src/calendar/gui/e-task-table.etspec b/src/calendar/gui/e-task-table.etspec
index d20c8226ee..4cc31faa68 100644
--- a/src/calendar/gui/e-task-table.etspec
+++ b/src/calendar/gui/e-task-table.etspec
@@ -2,12 +2,12 @@
   <ETableColumn model_col= "5" _title="Start date" expansion="2.0" minimum_width="10" resizable="true" 
cell="dateedit" compare="date-compare" priority="-2"/>
   <ETableColumn model_col="7" pixbuf="icon" _title="Type" expansion="1.0" minimum_width="16" 
resizable="false" cell="icon" compare="integer" priority="-4"/>
   <ETableColumn model_col= "8" _title="Summary" expansion="3.0" minimum_width="10" resizable="true" 
cell="calstring" compare="stringcase" priority="10"/>
-  <ETableColumn model_col= "13" _title="Completion date" expansion="2.0" minimum_width="10" resizable="true" 
cell="dateedit" compare="date-compare" priority="-2"/>
-  <ETableColumn model_col="14" pixbuf="complete" _title="Complete" expansion="1.0" minimum_width="16" 
resizable="false" cell="checkbox" compare="integer" priority="-4"/>
-  <ETableColumn model_col= "15" _title="Due date" expansion="2.0" minimum_width="10" resizable="true" 
cell="dateedit" compare="date-compare" priority="-2"/>
-  <ETableColumn model_col= "18" _title="% Complete" expansion="1.0" minimum_width="10" resizable="true" 
cell="percent" compare="percent-compare" priority="-3"/>
-  <ETableColumn model_col= "19" _title="Priority" expansion="1.0" minimum_width="10" resizable="true" 
cell="priority" compare="priority-compare" priority="-3"/>
-  <ETableColumn model_col="20" _title="Status" expansion="1.0" minimum_width="10" resizable="true" 
cell="calstatus" compare="status-compare" priority="-1"/>
+  <ETableColumn model_col= "14" _title="Completion date" expansion="2.0" minimum_width="10" resizable="true" 
cell="dateedit" compare="date-compare" priority="-2"/>
+  <ETableColumn model_col="15" pixbuf="complete" _title="Complete" expansion="1.0" minimum_width="16" 
resizable="false" cell="checkbox" compare="integer" priority="-4"/>
+  <ETableColumn model_col= "16" _title="Due date" expansion="2.0" minimum_width="10" resizable="true" 
cell="dateedit" compare="date-compare" priority="-2"/>
+  <ETableColumn model_col= "19" _title="% Complete" expansion="1.0" minimum_width="10" resizable="true" 
cell="percent" compare="percent-compare" priority="-3"/>
+  <ETableColumn model_col= "20" _title="Priority" expansion="1.0" minimum_width="10" resizable="true" 
cell="priority" compare="priority-compare" priority="-3"/>
+  <ETableColumn model_col="21" _title="Status" expansion="1.0" minimum_width="10" resizable="true" 
cell="calstatus" compare="status-compare" priority="-1"/>
   <ETableColumn model_col="0" _title="Categories" cell="calstring" compare="stringcase" expansion="1.0" 
minimum_width="10" resizable="true" priority="-2"/>
   <ETableColumn model_col="10" _title="Created" expansion="2.0" minimum_width="10" resizable="true" 
cell="dateedit" compare="date-compare" priority="-2"/>
   <ETableColumn model_col="11" _title="Last modified" expansion="2.0" minimum_width="10" resizable="true" 
cell="dateedit" compare="date-compare" priority="-2"/>
diff --git a/src/calendar/gui/e-to-do-pane.c b/src/calendar/gui/e-to-do-pane.c
index 9047fd2cd7..bd235ba32a 100644
--- a/src/calendar/gui/e-to-do-pane.c
+++ b/src/calendar/gui/e-to-do-pane.c
@@ -316,7 +316,8 @@ etdp_get_component_data (EToDoPane *to_do_pane,
        ECalComponentId *id;
        struct icaltimetype itt = icaltime_null_time ();
        const gchar *prefix, *location, *description;
-       gboolean task_has_due_date = TRUE; /* ignored for events, thus like being set */
+       gboolean task_has_due_date = TRUE, is_cancelled = FALSE; /* ignored for events, thus like being set */
+       icalproperty_status status = ICAL_STATUS_NONE;
        GString *tooltip;
 
        g_return_val_if_fail (E_IS_TO_DO_PANE (to_do_pane), FALSE);
@@ -349,6 +350,9 @@ etdp_get_component_data (EToDoPane *to_do_pane,
        *out_is_task = e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_TODO;
        *out_is_completed = FALSE;
 
+       e_cal_component_get_status (comp, &status);
+       is_cancelled = status == ICAL_STATUS_CANCELLED;
+
        if (*out_is_task) {
                ECalComponentDateTime dtstart = { 0 };
                struct icaltimetype *completed = NULL;
@@ -408,9 +412,6 @@ etdp_get_component_data (EToDoPane *to_do_pane,
                        *out_is_completed = TRUE;
                        e_cal_component_free_icaltimetype (completed);
                } else {
-                       icalproperty_status status = ICAL_STATUS_NONE;
-
-                       e_cal_component_get_status (comp, &status);
                        *out_is_completed = *out_is_completed || status == ICAL_STATUS_COMPLETED;
                }
        } else {
@@ -471,7 +472,7 @@ etdp_get_component_data (EToDoPane *to_do_pane,
                        location ? " (" : "", location ? location : "", location ? ")" : "");
        }
 
-       if (*out_is_completed) {
+       if (*out_is_completed || is_cancelled) {
                gchar *tmp = *out_summary;
 
                /* With leading space, to have proper row height in GtkTreeView */
@@ -2505,6 +2506,11 @@ e_to_do_pane_constructed (GObject *object)
                NULL, /* one-way binding */
                NULL, NULL);
 
+       g_settings_bind (
+               settings, "hide-cancelled-events",
+               to_do_pane->priv->events_data_model, "skip-cancelled",
+               G_SETTINGS_BIND_GET);
+
        g_settings_bind (
                settings, "task-overdue-highlight",
                to_do_pane, "highlight-overdue",
diff --git a/src/calendar/gui/e-week-view.c b/src/calendar/gui/e-week-view.c
index 69f37a344d..f9c0b0e78e 100644
--- a/src/calendar/gui/e-week-view.c
+++ b/src/calendar/gui/e-week-view.c
@@ -2701,6 +2701,9 @@ set_style_from_attendee (EWeekViewEvent *event,
                }
        }
 
+       if (icalcomponent_get_status (event->comp_data->icalcomp) == ICAL_STATUS_CANCELLED)
+               gnome_canvas_item_set (span->text_item, "strikeout", TRUE, NULL);
+
        /* The attendee has not yet accepted the meeting, display the summary as bolded.
         * If the attendee is not present, it might have come through a mailing list.
         * In that case, we never show the meeting as bold even if it is unaccepted. */
@@ -3858,6 +3861,8 @@ e_week_view_reshape_event_span (EWeekView *week_view,
 
                if (e_cal_util_component_has_attendee (event->comp_data->icalcomp))
                        set_style_from_attendee (event, span, registry);
+               else if (icalcomponent_get_status (event->comp_data->icalcomp) == ICAL_STATUS_CANCELLED)
+                       gnome_canvas_item_set (span->text_item, "strikeout", TRUE, NULL);
 
                g_signal_connect (
                        span->text_item, "event",
diff --git a/src/modules/calendar/e-cal-base-shell-content.c b/src/modules/calendar/e-cal-base-shell-content.c
index ca62616b83..d313d21639 100644
--- a/src/modules/calendar/e-cal-base-shell-content.c
+++ b/src/modules/calendar/e-cal-base-shell-content.c
@@ -302,6 +302,7 @@ cal_base_shell_content_constructed (GObject *object)
        ECalBaseShellContentClass *klass;
        ESourceRegistry *registry;
        ESource *default_source = NULL;
+       GSettings *settings;
        const gchar *created_signal_name = NULL;
 
        /* Chain up to parent's method. */
@@ -332,6 +333,13 @@ cal_base_shell_content_constructed (GObject *object)
                        e_cal_data_model_set_expand_recurrences (cal_base_shell_content->priv->data_model, 
TRUE);
                        default_source = e_source_registry_ref_default_calendar (registry);
                        created_signal_name = "shell-view-created::calendar";
+
+                       settings = e_util_ref_settings ("org.gnome.evolution.calendar");
+                       g_settings_bind (
+                               settings, "hide-cancelled-events",
+                               cal_base_shell_content->priv->data_model, "skip-cancelled",
+                               G_SETTINGS_BIND_GET);
+                       g_object_unref (settings);
                        break;
                case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
                        default_source = e_source_registry_ref_default_memo_list (registry);
diff --git a/src/modules/calendar/e-calendar-preferences.c b/src/modules/calendar/e-calendar-preferences.c
index cdaa85950a..622a9f0344 100644
--- a/src/modules/calendar/e-calendar-preferences.c
+++ b/src/modules/calendar/e-calendar-preferences.c
@@ -1002,6 +1002,12 @@ calendar_preferences_construct (ECalendarPreferences *prefs,
                widget, "active",
                G_SETTINGS_BIND_DEFAULT);
 
+       widget = e_builder_get_widget (prefs->priv->builder, "hide_cancelled_events");
+       g_settings_bind (
+               settings, "hide-cancelled-events",
+               widget, "active",
+               G_SETTINGS_BIND_DEFAULT);
+
        widget = e_builder_get_widget (prefs->priv->builder, "tasks_due_today_highlight");
        g_settings_bind (
                settings, "task-due-today-highlight",
diff --git a/src/modules/calendar/e-calendar-preferences.ui b/src/modules/calendar/e-calendar-preferences.ui
index a96c3df864..f2b038e737 100644
--- a/src/modules/calendar/e-calendar-preferences.ui
+++ b/src/modules/calendar/e-calendar-preferences.ui
@@ -1016,6 +1016,21 @@
                     <property name="position">8</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkCheckButton" id="hide_cancelled_events">
+                    <property name="label" translatable="yes">Hi_de cancelled events</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">9</property>
+                  </packing>
+                </child>
               </object>
               <packing>
                 <property name="expand">True</property>


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