[gnome-calendar] Implemented GcalView::reposition_child in GcalYearView.



commit a3e7f9a3604acec5eeef733532b32b552e3b9db0
Author: Erick PÃrez Castellanos <erick red gmail com>
Date:   Thu Nov 22 21:38:42 2012 -0500

    Implemented GcalView::reposition_child in GcalYearView.
    
    Fixed the same method in GcalMonthView.

 src/gcal-month-view.c |   15 +++++++++---
 src/gcal-year-view.c  |   56 +++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 65 insertions(+), 6 deletions(-)
---
diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c
index 2e1ee99..55dc9e9 100644
--- a/src/gcal-month-view.c
+++ b/src/gcal-month-view.c
@@ -1430,16 +1430,22 @@ gcal_month_view_reposition_child (GcalView    *view,
 
                   if (day == i)
                     {
-                      return;
+                      priv->days[day] =
+                        g_list_sort (priv->days[day],
+                                     gcal_compare_event_widget_by_date);
                     }
                   else
                     {
                       priv->days[i] = g_list_remove (priv->days[i], child);
 
-                      child->hidden_by_me = FALSE;
-                      priv->days[day] = g_list_append (priv->days[day], child);
-                      gtk_widget_queue_resize (GTK_WIDGET (view));
+                      child->hidden_by_me = TRUE;
+                      priv->days[day] =
+                        g_list_insert_sorted (priv->days[day],
+                                              child,
+                                              gcal_compare_event_widget_by_date);
                     }
+
+                  gtk_widget_queue_resize (GTK_WIDGET (view));
                 }
               else
                 {
@@ -1447,6 +1453,7 @@ gcal_month_view_reposition_child (GcalView    *view,
                 }
 
               g_free (date);
+              return;
             }
         }
     }
diff --git a/src/gcal-year-view.c b/src/gcal-year-view.c
index 3082c66..3278bfd 100644
--- a/src/gcal-year-view.c
+++ b/src/gcal-year-view.c
@@ -1002,8 +1002,60 @@ static void
 gcal_year_view_reposition_child (GcalView    *view,
                                  const gchar *uuid)
 {
-  /* FIXME: Implement this one */
-  ;
+  GcalYearViewPrivate *priv;
+  gint i;
+  GList *l;
+
+  g_return_if_fail (GCAL_IS_YEAR_VIEW (view));
+  priv = GCAL_YEAR_VIEW (view)->priv;
+
+  for (i = 0; i < 12; i++)
+    {
+      for (l = priv->months[i]; l != NULL; l = l->next)
+        {
+          GcalViewChild *child;
+          const gchar* widget_uuid;
+
+          child = (GcalViewChild*) l->data;
+          widget_uuid = gcal_event_widget_peek_uuid (GCAL_EVENT_WIDGET (child->widget));
+          if (g_strcmp0 (uuid, widget_uuid) == 0)
+            {
+              icaltimetype *date;
+
+              date =
+                gcal_event_widget_get_date (GCAL_EVENT_WIDGET (child->widget));
+
+              if (gcal_year_view_contains (view, date))
+                {
+                  if (date->month - 1 == i)
+                    {
+                      priv->months[i] =
+                        g_list_sort (priv->months[i],
+                                     gcal_compare_event_widget_by_date);
+                    }
+                  else
+                    {
+                      priv->months[i] = g_list_remove (priv->months[i], child);
+
+                      child->hidden_by_me = TRUE;
+                      priv->months[date->month - 1] =
+                        g_list_insert_sorted (priv->months[date->month - 1],
+                                              child,
+                                              gcal_compare_event_widget_by_date);
+                    }
+
+                  gtk_widget_queue_resize (GTK_WIDGET (view));
+                }
+              else
+                {
+                  gcal_year_view_remove_by_uuid (view, uuid);
+                }
+
+              g_free (date);
+              return;
+            }
+        }
+    }
 }
 
 /* Public API */



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