[gnome-calendar] Added reposition_child to GcalView interface.



commit 6e8ffcf5cfcd3fdfefe01e74af4fc6cf57ee6777
Author: Erick PÃrez Castellanos <erick red gmail com>
Date:   Sun Oct 7 11:29:28 2012 -0400

    Added reposition_child to GcalView interface.
    
    Provided implementation for GcalMonthView.

 src/gcal-month-view.c |   59 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/gcal-view.c       |    9 +++++++
 src/gcal-view.h       |    5 ++++
 3 files changed, 73 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c
index 81b61e5..f2ec2f7 100644
--- a/src/gcal-month-view.c
+++ b/src/gcal-month-view.c
@@ -147,6 +147,9 @@ static void           gcal_month_view_remove_by_uuid        (GcalView       *vie
 static GtkWidget*     gcal_month_view_get_by_uuid           (GcalView       *view,
                                                              const gchar    *uuid);
 
+static void           gcal_month_view_reposition_child      (GcalView       *view,
+                                                             const gchar    *uuid);
+
 static void           gcal_month_view_clear_selection       (GcalView       *view);
 
 G_DEFINE_TYPE_WITH_CODE (GcalMonthView,
@@ -234,6 +237,7 @@ gcal_view_interface_init (GcalViewIface *iface)
   iface->contains = gcal_month_view_contains;
   iface->remove_by_uuid = gcal_month_view_remove_by_uuid;
   iface->get_by_uuid = gcal_month_view_get_by_uuid;
+  iface->reposition_child = gcal_month_view_reposition_child;
 
   iface->clear_selection = gcal_month_view_clear_selection;
 }
@@ -1390,6 +1394,61 @@ gcal_month_view_get_by_uuid (GcalView    *view,
 }
 
 static void
+gcal_month_view_reposition_child (GcalView    *view,
+                                  const gchar *uuid)
+{
+  GcalMonthViewPrivate *priv;
+  gint i;
+  GList *l;
+
+  g_return_if_fail (GCAL_IS_MONTH_VIEW (view));
+  priv = GCAL_MONTH_VIEW (view)->priv;
+
+  for (i = 0; i < 35; i++)
+    {
+      for (l = priv->days[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;
+              gint day;
+
+              date = gcal_event_widget_get_date (GCAL_EVENT_WIDGET (child->widget));
+
+              if (gcal_month_view_contains (view, date))
+                {
+                  day = date->day + ( - priv->days_delay);
+
+                  if (day == i)
+                    {
+                      return;
+                    }
+                  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));
+                    }
+                }
+              else
+                {
+                  gcal_month_view_remove_by_uuid (view, uuid);
+                }
+
+              g_free (date);
+            }
+        }
+    }
+}
+
+static void
 gcal_month_view_clear_selection (GcalView *view)
 {
   GcalMonthViewPrivate *priv;
diff --git a/src/gcal-view.c b/src/gcal-view.c
index 99f39af..32a7008 100644
--- a/src/gcal-view.c
+++ b/src/gcal-view.c
@@ -159,6 +159,15 @@ gcal_view_get_by_uuid (GcalView    *view,
 }
 
 void
+gcal_view_reposition_child (GcalView    *view,
+                            const gchar *uuid)
+{
+  g_return_if_fail (GCAL_IS_VIEW (view));
+
+  GCAL_VIEW_GET_INTERFACE (view)->reposition_child (view, uuid);
+}
+
+void
 gcal_view_clear_selection (GcalView *view)
 {
   g_return_if_fail (GCAL_IS_VIEW (view));
diff --git a/src/gcal-view.h b/src/gcal-view.h
index 21808ee..7e2e4f2 100644
--- a/src/gcal-view.h
+++ b/src/gcal-view.h
@@ -51,12 +51,14 @@ struct _GcalViewIface
   gboolean        (*contains)             (GcalView *view, icaltimetype *date);
   void            (*remove_by_uuid)       (GcalView *view, const gchar *uuid);
   GtkWidget*      (*get_by_uuid)          (GcalView *view, const gchar *uuid);
+  void            (*reposition_child)     (GcalView *view, const gchar *uuid);
 
   void            (*clear_selection)      (GcalView *view);
 };
 
 GType         gcal_view_get_type          (void);
 
+
 void          gcal_view_set_date          (GcalView     *view,
                                            icaltimetype *date);
 
@@ -75,6 +77,9 @@ void          gcal_view_remove_by_uuid    (GcalView     *view,
 GtkWidget*    gcal_view_get_by_uuid       (GcalView     *view,
                                            const gchar  *uuid);
 
+void          gcal_view_reposition_child  (GcalView     *view,
+					   const gchar  *uuid);
+
 void          gcal_view_clear_selection   (GcalView     *view);
 
 G_END_DECLS



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