aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-11-26 22:15:17 +0800
committerMilan Crha <mcrha@redhat.com>2009-11-26 22:15:17 +0800
commite2ca6f7753443a37fddd9d3af8360a9da06c4a9f (patch)
tree5ce60fca7c86b19ee23cd8cb4e6a3ed950aeaefc
parentdae1d43302906876882c153c40a0e7d45f66023d (diff)
downloadgsoc2013-evolution-e2ca6f7753443a37fddd9d3af8360a9da06c4a9f.tar
gsoc2013-evolution-e2ca6f7753443a37fddd9d3af8360a9da06c4a9f.tar.gz
gsoc2013-evolution-e2ca6f7753443a37fddd9d3af8360a9da06c4a9f.tar.bz2
gsoc2013-evolution-e2ca6f7753443a37fddd9d3af8360a9da06c4a9f.tar.lz
gsoc2013-evolution-e2ca6f7753443a37fddd9d3af8360a9da06c4a9f.tar.xz
gsoc2013-evolution-e2ca6f7753443a37fddd9d3af8360a9da06c4a9f.tar.zst
gsoc2013-evolution-e2ca6f7753443a37fddd9d3af8360a9da06c4a9f.zip
Bug #591330 - Do not clear task preview every minute
-rw-r--r--calendar/gui/e-cal-component-preview.c110
-rw-r--r--calendar/gui/e-cal-component-preview.h1
-rw-r--r--calendar/gui/e-calendar-table.c4
-rw-r--r--modules/calendar/e-memo-shell-content.c4
-rw-r--r--modules/calendar/e-memo-shell-view-actions.c2
-rw-r--r--modules/calendar/e-memo-shell-view.c2
-rw-r--r--modules/calendar/e-task-shell-content.c4
-rw-r--r--modules/calendar/e-task-shell-view-actions.c2
-rw-r--r--modules/calendar/e-task-shell-view.c2
9 files changed, 123 insertions, 8 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));
}
diff --git a/modules/calendar/e-memo-shell-content.c b/modules/calendar/e-memo-shell-content.c
index c90b1def26..21ab63e789 100644
--- a/modules/calendar/e-memo-shell-content.c
+++ b/modules/calendar/e-memo-shell-content.c
@@ -202,7 +202,7 @@ memo_shell_content_cursor_change_cb (EMemoShellContent *memo_shell_content,
memo_preview = e_memo_shell_content_get_memo_preview (memo_shell_content);
if (e_table_selected_count (table) != 1) {
- e_web_view_clear (E_WEB_VIEW (memo_preview));
+ e_cal_component_preview_clear (memo_preview);
return;
}
@@ -233,7 +233,7 @@ memo_shell_content_selection_change_cb (EMemoShellContent *memo_shell_content,
/* XXX Old code emits a "selection-changed" signal here. */
if (e_table_selected_count (table) != 1)
- e_web_view_clear (E_WEB_VIEW (memo_preview));
+ e_cal_component_preview_clear (memo_preview);
}
static void
diff --git a/modules/calendar/e-memo-shell-view-actions.c b/modules/calendar/e-memo-shell-view-actions.c
index 57420cd963..734a7c522d 100644
--- a/modules/calendar/e-memo-shell-view-actions.c
+++ b/modules/calendar/e-memo-shell-view-actions.c
@@ -97,7 +97,7 @@ action_memo_delete_cb (GtkAction *action,
e_memo_table_delete_selected (memo_table);
e_memo_shell_view_set_status_message (memo_shell_view, NULL, -1.0);
- e_web_view_clear (E_WEB_VIEW (memo_preview));
+ e_cal_component_preview_clear (memo_preview);
}
static void
diff --git a/modules/calendar/e-memo-shell-view.c b/modules/calendar/e-memo-shell-view.c
index 5d932e1599..242bdfce92 100644
--- a/modules/calendar/e-memo-shell-view.c
+++ b/modules/calendar/e-memo-shell-view.c
@@ -151,7 +151,7 @@ memo_shell_view_execute_search (EShellView *shell_view)
memo_preview =
e_memo_shell_content_get_memo_preview (memo_shell_content);
- e_web_view_clear (E_WEB_VIEW (memo_preview));
+ e_cal_component_preview_clear (memo_preview);
}
static void
diff --git a/modules/calendar/e-task-shell-content.c b/modules/calendar/e-task-shell-content.c
index 2ad4b28051..ca17cdbd5c 100644
--- a/modules/calendar/e-task-shell-content.c
+++ b/modules/calendar/e-task-shell-content.c
@@ -203,7 +203,7 @@ task_shell_content_cursor_change_cb (ETaskShellContent *task_shell_content,
task_preview = e_task_shell_content_get_task_preview (task_shell_content);
if (e_table_selected_count (table) != 1) {
- e_web_view_clear (E_WEB_VIEW (task_preview));
+ e_cal_component_preview_clear (task_preview);
return;
}
@@ -232,7 +232,7 @@ task_shell_content_selection_change_cb (ETaskShellContent *task_shell_content,
task_preview = e_task_shell_content_get_task_preview (task_shell_content);
if (e_table_selected_count (table) != 1)
- e_web_view_clear (E_WEB_VIEW (task_preview));
+ e_cal_component_preview_clear (task_preview);
}
static void
diff --git a/modules/calendar/e-task-shell-view-actions.c b/modules/calendar/e-task-shell-view-actions.c
index 6f70c9afdb..06177784ce 100644
--- a/modules/calendar/e-task-shell-view-actions.c
+++ b/modules/calendar/e-task-shell-view-actions.c
@@ -128,7 +128,7 @@ action_task_delete_cb (GtkAction *action,
e_calendar_table_delete_selected (task_table);
e_task_shell_view_set_status_message (task_shell_view, NULL, -1.0);
- e_web_view_clear (E_WEB_VIEW (task_preview));
+ e_cal_component_preview_clear (task_preview);
}
static void
diff --git a/modules/calendar/e-task-shell-view.c b/modules/calendar/e-task-shell-view.c
index b7c2bc9333..8518a6dcb1 100644
--- a/modules/calendar/e-task-shell-view.c
+++ b/modules/calendar/e-task-shell-view.c
@@ -263,7 +263,7 @@ task_shell_view_execute_search (EShellView *shell_view)
task_preview =
e_task_shell_content_get_task_preview (task_shell_content);
- e_web_view_clear (E_WEB_VIEW (task_preview));
+ e_cal_component_preview_clear (task_preview);
}
static void