[gnome-calendar/wip/pandusonu/week-view: 30/60] week-header: reposition present events on changing active date.



commit 175d22e9ef989b8a9e6df634d45392333f127b0f
Author: pandusonu2 <pandu sonu yahoo com>
Date:   Sat Jun 25 19:05:35 2016 +0530

    week-header: reposition present events on changing active date.
    
    When an event lasts beyond the active week, the event placement doesn't change on changing the week.
    
    We removed all the present events and added them to the list of events to be added to reposition them.

 src/views/gcal-week-header.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/src/views/gcal-week-header.c b/src/views/gcal-week-header.c
index 7a3077b..dd92fd3 100644
--- a/src/views/gcal-week-header.c
+++ b/src/views/gcal-week-header.c
@@ -63,6 +63,8 @@ static void           update_headers                        (GcalWeekHeader *sel
 
 static void           place_events                          (GcalWeekHeader *self);
 
+static void           clear_current_events                  (GcalWeekHeader *self);
+
 static void           gcal_week_header_finalize             (GObject *object);
 
 static void           gcal_week_header_get_property         (GObject    *object,
@@ -238,6 +240,28 @@ place_events (GcalWeekHeader *self)
 }
 
 static void
+clear_current_events (GcalWeekHeader *self)
+{
+  GList *children, *l;
+
+  children = g_list_copy (gtk_container_get_children (GTK_CONTAINER (self->grid)));
+
+  for (l = children; l != NULL; l = l->next)
+    {
+      if (!GCAL_IS_EVENT_WIDGET (l->data))
+        continue;
+
+      /* Add current events to events list to add later if necessary */
+      self->events = g_list_append (self->events,
+                                    gcal_event_widget_get_event (l->data));
+
+      gtk_widget_destroy (l->data);
+    }
+
+  g_list_free (children);
+}
+
+static void
 gcal_week_header_finalize (GObject *object)
 {
   GcalWeekHeader *self = GCAL_WEEK_HEADER (object);
@@ -313,6 +337,7 @@ gcal_week_header_set_property (GObject      *object,
       self->active_date = g_value_dup_boxed (value);
 
       update_headers (self);
+      clear_current_events (self);
       place_events (self);
 
       gtk_widget_queue_draw (self->draw_area);
@@ -573,6 +598,7 @@ gcal_week_header_set_current_date (GcalWeekHeader *self,
   self->current_date = gcal_dup_icaltime (current_date);
 
   update_headers (self);
+  clear_current_events (self);
   place_events (self);
 
   gtk_widget_queue_draw (self->draw_area);


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