[gnome-calendar] year-view: simplify code
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] year-view: simplify code
- Date: Sat, 25 Mar 2017 20:57:00 +0000 (UTC)
commit 19b1563aabc06248663e629aa5ac46827583493c
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat Mar 25 17:54:50 2017 -0300
year-view: simplify code
The code in ECalDataModelSubscriber:component_changed() and
:component_removed() was actually duplicated, and we can
simplify the :component_changed() routine by simply removing
and readding the event.
src/views/gcal-year-view.c | 68 +++++++++----------------------------------
1 files changed, 15 insertions(+), 53 deletions(-)
---
diff --git a/src/views/gcal-year-view.c b/src/views/gcal-year-view.c
index d374b9f..de5a2f3 100644
--- a/src/views/gcal-year-view.c
+++ b/src/views/gcal-year-view.c
@@ -1787,59 +1787,6 @@ gcal_year_view_component_added (ECalDataModelSubscriber *subscriber,
}
static void
-gcal_year_view_component_changed (ECalDataModelSubscriber *subscriber,
- ECalClient *client,
- ECalComponent *comp)
-{
- GcalYearView *self = GCAL_YEAR_VIEW (subscriber);
- GList *children, *l;
- gchar *uuid;
- guint i;
-
- uuid = get_uuid_from_component (e_client_get_source (E_CLIENT (client)), comp);
- children = gtk_container_get_children (GTK_CONTAINER (self->events_sidebar));
-
- /* Remove from the sidebar */
- for (l = children; l != NULL; l = g_list_next (l))
- {
- GcalEventWidget *child_widget;
- GcalEvent *event;
-
- child_widget = GCAL_EVENT_WIDGET (gtk_bin_get_child (GTK_BIN (l->data)));
- event = gcal_event_widget_get_event (child_widget);
-
- if (child_widget && g_strcmp0 (uuid, gcal_event_get_uid (event)) == 0)
- gtk_widget_destroy (l->data);
- }
-
- /* Also remove from the cached list of events */
- for (i = 0; i < 12; i++)
- {
- GPtrArray *events;
- guint j;
-
- events = self->events[i];
-
- for (j = 0; j < events->len; j++)
- {
- GcalEvent *event;
-
- event = g_ptr_array_index (events, j);
-
- if (g_strcmp0 (gcal_event_get_uid (event), uuid) != 0)
- continue;
-
- g_ptr_array_remove (events, event);
- }
- }
-
- g_list_free (children);
- g_free (uuid);
-
- gcal_year_view_component_added (subscriber, client, comp);
-}
-
-static void
gcal_year_view_component_removed (ECalDataModelSubscriber *subscriber,
ECalClient *client,
const gchar *uid,
@@ -1914,6 +1861,21 @@ gcal_year_view_component_removed (ECalDataModelSubscriber *subscriber,
}
static void
+gcal_year_view_component_changed (ECalDataModelSubscriber *subscriber,
+ ECalClient *client,
+ ECalComponent *comp)
+{
+ ECalComponentId *id;
+
+ id = e_cal_component_get_id (comp);
+
+ gcal_year_view_component_removed (subscriber, client, id->uid, id->rid);
+ gcal_year_view_component_added (subscriber, client, comp);
+
+ g_clear_pointer (&id, e_cal_component_free_id);
+}
+
+static void
gcal_year_view_freeze (ECalDataModelSubscriber *subscriber)
{
;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]