diff options
author | Milan Crha <mcrha@redhat.com> | 2009-11-26 22:15:17 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2009-11-26 22:15:17 +0800 |
commit | e2ca6f7753443a37fddd9d3af8360a9da06c4a9f (patch) | |
tree | 5ce60fca7c86b19ee23cd8cb4e6a3ed950aeaefc /calendar | |
parent | dae1d43302906876882c153c40a0e7d45f66023d (diff) | |
download | gsoc2013-evolution-e2ca6f7753443a37fddd9d3af8360a9da06c4a9f.tar.gz gsoc2013-evolution-e2ca6f7753443a37fddd9d3af8360a9da06c4a9f.tar.zst gsoc2013-evolution-e2ca6f7753443a37fddd9d3af8360a9da06c4a9f.zip |
Bug #591330 - Do not clear task preview every minute
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/gui/e-cal-component-preview.c | 110 | ||||
-rw-r--r-- | calendar/gui/e-cal-component-preview.h | 1 | ||||
-rw-r--r-- | calendar/gui/e-calendar-table.c | 4 |
3 files changed, 115 insertions, 0 deletions
diff --git a/calendar/gui/e-cal-component-preview.c b/calendar/gui/e-cal-component-preview.c index 014ce2c7d3..519c165b88 100644 --- a/calendar/gui/e-cal-component-preview.c +++ b/calendar/gui/e-cal-component-preview.c @@ -41,10 +41,91 @@ struct _ECalComponentPreviewPrivate { icaltimezone *zone; + + /* information about currently showing component in a preview; + if it didn't change then the preview is not updated */ + gchar *cal_uid; + gchar *comp_uid; + struct icaltimetype comp_last_modified; + gint comp_sequence; }; static gpointer parent_class; +static void +clear_comp_info (ECalComponentPreview *preview) +{ + ECalComponentPreviewPrivate *priv; + + g_return_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview)); + + priv = preview->priv; + + g_free (priv->cal_uid); + priv->cal_uid = NULL; + g_free (priv->comp_uid); + priv->comp_uid = NULL; + priv->comp_last_modified = icaltime_null_time (); + priv->comp_sequence = -1; +} + +/* Stores information about actually shown component and + returns whether component in the preview changed */ +static gboolean +update_comp_info (ECalComponentPreview *preview, ECal *ecal, ECalComponent *comp) +{ + ECalComponentPreviewPrivate *priv; + gboolean changed; + + g_return_val_if_fail (preview != NULL, TRUE); + g_return_val_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview), TRUE); + + priv = preview->priv; + + if (!E_IS_CAL_COMPONENT (comp) || !E_IS_CAL (ecal)) { + changed = !priv->cal_uid; + clear_comp_info (preview); + } else { + const gchar *uid; + gchar *cal_uid; + gchar *comp_uid; + struct icaltimetype comp_last_modified, *itm = NULL; + gint *sequence = NULL; + gint comp_sequence; + + cal_uid = g_strdup (e_source_peek_uid (e_cal_get_source (ecal))); + e_cal_component_get_uid (comp, &uid); + comp_uid = g_strdup (uid); + e_cal_component_get_last_modified (comp, &itm); + if (itm) { + comp_last_modified = *itm; + e_cal_component_free_icaltimetype (itm); + } else + comp_last_modified = icaltime_null_time (); + e_cal_component_get_sequence (comp, &sequence); + if (sequence) { + comp_sequence = *sequence; + e_cal_component_free_sequence (sequence); + } else + comp_sequence = 0; + + changed = !priv->cal_uid || !priv->comp_uid || !cal_uid || !comp_uid || + !g_str_equal (priv->cal_uid, cal_uid) || + !g_str_equal (priv->comp_uid, comp_uid) || + priv->comp_sequence != comp_sequence || + icaltime_compare (priv->comp_last_modified, comp_last_modified) != 0; + + clear_comp_info (preview); + + priv->cal_uid = cal_uid; + priv->comp_uid = comp_uid; + priv->comp_sequence = comp_sequence; + priv->comp_last_modified = comp_last_modified; + } + + return changed; +} + /* Converts a time_t to a string, relative to the specified timezone */ static gchar * timet_to_str_with_zone (ECalComponentDateTime *dt, @@ -295,10 +376,25 @@ cal_component_preview_write_html (GString *buffer, } static void +cal_component_preview_finalize (GObject *object) +{ + ECalComponentPreview *preview; + + clear_comp_info (E_CAL_COMPONENT_PREVIEW (preview)); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void cal_component_preview_class_init (ECalComponentPreviewClass *class) { + GObjectClass *object_class; + parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (ECalComponentPreviewPrivate)); + + object_class->finalize = cal_component_preview_finalize; } static void @@ -376,6 +472,11 @@ e_cal_component_preview_display (ECalComponentPreview *preview, g_return_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview)); g_return_if_fail (E_IS_CAL_COMPONENT (comp)); + /* do not update preview when setting the same component as last time, + which even didn't change */ + if (!update_comp_info (preview, ecal, comp)) + return; + /* XXX The initial buffer size is arbitrary. Tune it. */ buffer = g_string_sized_new (4096); @@ -384,3 +485,12 @@ e_cal_component_preview_display (ECalComponentPreview *preview, e_web_view_load_string (E_WEB_VIEW (preview), buffer->str); g_string_free (buffer, TRUE); } + +void +e_cal_component_preview_clear (ECalComponentPreview *preview) +{ + g_return_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview)); + + clear_comp_info (preview); + e_web_view_clear (E_WEB_VIEW (preview)); +} diff --git a/calendar/gui/e-cal-component-preview.h b/calendar/gui/e-cal-component-preview.h index 78567f06ec..03798a4727 100644 --- a/calendar/gui/e-cal-component-preview.h +++ b/calendar/gui/e-cal-component-preview.h @@ -75,6 +75,7 @@ void e_cal_component_preview_set_default_timezone void e_cal_component_preview_display (ECalComponentPreview *preview, ECal *ecal, ECalComponent *comp); +void e_cal_component_preview_clear (ECalComponentPreview *preview); G_END_DECLS diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index 2b11da0582..3dd4d7435b 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -1462,6 +1462,7 @@ hide_completed_rows (ECalModel *model, GList *clients_list, gchar *hide_sexp, GP GList *l, *m, *objects; ECal *client; gint pos; + gboolean changed = FALSE; for (l = clients_list; l != NULL; l = l->next) { client = l->data; @@ -1484,6 +1485,7 @@ hide_completed_rows (ECalModel *model, GList *clients_list, gchar *hide_sexp, GP e_table_model_pre_change (E_TABLE_MODEL (model)); pos = get_position_in_array (comp_objects, comp_data); e_table_model_row_deleted (E_TABLE_MODEL (model), pos); + changed = TRUE; if (g_ptr_array_remove (comp_objects, comp_data)) e_cal_model_free_component_data (comp_data); @@ -1494,7 +1496,9 @@ hide_completed_rows (ECalModel *model, GList *clients_list, gchar *hide_sexp, GP g_list_foreach (objects, (GFunc) icalcomponent_free, NULL); g_list_free (objects); + } + if (changed) { /* to notify about changes, because in call of row_deleted there are still all events */ e_table_model_changed (E_TABLE_MODEL (model)); } |