[gnome-calendar/wip/pandusonu/week-view] week-header: simplify event removal
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/wip/pandusonu/week-view] week-header: simplify event removal
- Date: Wed, 7 Dec 2016 23:32:24 +0000 (UTC)
commit adc4bbae9ebe23a510b18d6f31b75e5de389dc3d
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Dec 2 21:05:54 2016 -0200
week-header: simplify event removal
src/views/gcal-week-header.c | 36 ++++++++++++++++++++++++++----------
1 files changed, 26 insertions(+), 10 deletions(-)
---
diff --git a/src/views/gcal-week-header.c b/src/views/gcal-week-header.c
index df3e959..5933ef1 100644
--- a/src/views/gcal-week-header.c
+++ b/src/views/gcal-week-header.c
@@ -110,6 +110,26 @@ typedef enum
G_DEFINE_TYPE (GcalWeekHeader, gcal_week_header, GTK_TYPE_GRID);
+static GcalEvent*
+get_event_by_uuid (GcalWeekHeader *self,
+ const gchar *uuid)
+{
+ gint weekday;
+
+ for (weekday = 0; weekday < 7; weekday++)
+ {
+ GList *l;
+
+ for (l = self->events[weekday]; l != NULL; l = l->next)
+ {
+ if (g_strcmp0 (gcal_event_get_uid (l->data), uuid) == 0)
+ return l->data;
+ }
+ }
+
+ return NULL;
+}
+
static GDateTime*
get_start_of_week (icaltimetype *date)
{
@@ -1042,8 +1062,12 @@ gcal_week_header_remove_event (GcalWeekHeader *self,
g_return_if_fail (GCAL_IS_WEEK_HEADER (self));
+ removed_event = get_event_by_uuid (self, uuid);
+
+ if (!removed_event)
+ return;
+
children = gtk_container_get_children (GTK_CONTAINER (self->grid));
- removed_event = NULL;
for (l = children; l != NULL; l = l->next)
{
@@ -1057,15 +1081,9 @@ gcal_week_header_remove_event (GcalWeekHeader *self,
event = gcal_event_widget_get_event (child_widget);
if (g_strcmp0 (uuid, gcal_event_get_uid (event)) == 0)
- {
- removed_event = g_object_ref (event);
- gtk_widget_destroy (l->data);
- }
+ gtk_widget_destroy (l->data);
}
- if (!removed_event)
- goto out;
-
/* Remove from the weekday's GList */
for (weekday = 0; weekday < 7; weekday++)
{
@@ -1089,9 +1107,7 @@ gcal_week_header_remove_event (GcalWeekHeader *self,
/* Check if we eventually can merge events */
check_mergeable_events (self);
-out:
g_clear_pointer (&children, g_list_free);
- g_clear_object (&removed_event);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]