[gnome-calendar] subscriber-view: gained ::get_child_by_uuid vfunc
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] subscriber-view: gained ::get_child_by_uuid vfunc
- Date: Mon, 5 Jan 2015 16:07:52 +0000 (UTC)
commit 9994377c9f8807938f4db9a114545cbb848eeb4c
Author: Erick Pérez Castellanos <erick red gmail com>
Date: Mon Dec 29 17:24:13 2014 -0500
subscriber-view: gained ::get_child_by_uuid vfunc
Started migrating methods from GcalView to GcalSubscriber
src/gcal-month-view.c | 29 -----------------------------
src/gcal-subscriber-view.c | 24 ++++++++++++++++++++++++
src/gcal-subscriber-view.h | 8 +++++++-
src/gcal-view.c | 21 ---------------------
src/gcal-view.h | 6 ------
src/gcal-week-view.c | 18 ++++++++++--------
src/gcal-window.c | 12 ++++--------
src/gcal-year-view.c | 20 --------------------
8 files changed, 45 insertions(+), 93 deletions(-)
---
diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c
index 5edcb7e..0f142cd 100644
--- a/src/gcal-month-view.c
+++ b/src/gcal-month-view.c
@@ -207,9 +207,6 @@ static gchar* gcal_month_view_get_left_header (GcalView *vie
static gchar* gcal_month_view_get_right_header (GcalView *view);
-static GtkWidget* gcal_month_view_get_by_uuid (GcalView *view,
- const gchar *uuid);
-
G_DEFINE_TYPE_WITH_CODE (GcalMonthView, gcal_month_view,GCAL_TYPE_SUBSCRIBER_VIEW,
G_ADD_PRIVATE (GcalMonthView)
G_IMPLEMENT_INTERFACE (GCAL_TYPE_VIEW, gcal_view_interface_init));
@@ -653,8 +650,6 @@ gcal_view_interface_init (GcalViewIface *iface)
iface->get_left_header = gcal_month_view_get_left_header;
iface->get_right_header = gcal_month_view_get_right_header;
-
- iface->get_by_uuid = gcal_month_view_get_by_uuid;
}
static void
@@ -1845,30 +1840,6 @@ gcal_month_view_get_right_header (GcalView *view)
return g_strdup_printf ("%d", priv->date->year);
}
-/**
- * gcal_month_view_get_by_uuid:
- * @view:
- * @uuid:
- *
- * This will always returns a master widget.
- *
- * Returns:
- **/
-static GtkWidget*
-gcal_month_view_get_by_uuid (GcalView *view,
- const gchar *uuid)
-{
- GcalMonthViewPrivate *priv;
- GList *l;
-
- priv = gcal_month_view_get_instance_private (GCAL_MONTH_VIEW (view));
- l = g_hash_table_lookup (priv->children, uuid);
- if (l != NULL)
- return (GtkWidget*) l->data;
-
- return NULL;
-}
-
/* Public API */
/**
* gcal_month_view_new:
diff --git a/src/gcal-subscriber-view.c b/src/gcal-subscriber-view.c
index 1ec6fe4..5419efd 100644
--- a/src/gcal-subscriber-view.c
+++ b/src/gcal-subscriber-view.c
@@ -392,3 +392,27 @@ static void
gcal_subscriber_view_thaw (ECalDataModelSubscriber *subscriber)
{
}
+
+/* Public API */
+GtkWidget*
+gcal_subscriber_view_get_child_by_uuid (GcalSubscriberView *subscriber_view,
+ const gchar *uuid)
+{
+ GcalSubscriberViewClass *klass;
+ GcalSubscriberViewPrivate *priv;
+ GList *l;
+
+ g_return_val_if_fail (GCAL_IS_SUBSCRIBER_VIEW (subscriber_view), NULL);
+
+ /* Allow for descendants to hook in here */
+ klass = GCAL_SUBSCRIBER_VIEW_GET_CLASS (subscriber_view);
+ if (klass->get_child_by_uuid)
+ return klass->get_child_by_uuid (subscriber_view, uuid);
+
+ priv = gcal_subscriber_view_get_instance_private (subscriber_view);
+ l = g_hash_table_lookup (priv->children, uuid);
+ if (l != NULL)
+ return l->data;
+
+ return 0;
+}
diff --git a/src/gcal-subscriber-view.h b/src/gcal-subscriber-view.h
index 05af278..83489e8 100644
--- a/src/gcal-subscriber-view.h
+++ b/src/gcal-subscriber-view.h
@@ -52,9 +52,15 @@ struct _GcalSubscriberViewClass
/*< public >*/
gboolean (*is_child_multicell) (GcalSubscriberView *subscriber, GcalEventWidget *child);
guint (*get_child_cell) (GcalSubscriberView *subscriber, GcalEventWidget *child);
+
+ /* gcal-view replacements */
+ GtkWidget* (*get_child_by_uuid) (GcalSubscriberView *subscriber_view, const gchar *uuid);
};
-GType gcal_subscriber_view_get_type (void);
+GType gcal_subscriber_view_get_type (void);
+
+GtkWidget* gcal_subscriber_view_get_child_by_uuid (GcalSubscriberView *subscriber_view,
+ const gchar *uuid);
G_END_DECLS
diff --git a/src/gcal-view.c b/src/gcal-view.c
index 4be2930..aad172a 100644
--- a/src/gcal-view.c
+++ b/src/gcal-view.c
@@ -211,24 +211,3 @@ gcal_view_get_right_header (GcalView *view)
return GCAL_VIEW_GET_INTERFACE (view)->get_right_header (view);
}
-
-/**
- * gcal_view_get_by_uuid:
- * @view: a #GcalView
- * @uuid: the uuid of the event-widget
- *
- * The uuid is formed by source-uid:event-uid, and the widget with
- * this uuid is fetched by this method. If there's no widget with this
- * uuid in the view %NULL is returned.
- *
- * Returns: a #GcalEventWidget as #GtkWidget, %NULL otherwise
- **/
-GtkWidget*
-gcal_view_get_by_uuid (GcalView *view,
- const gchar *uuid)
-{
- g_return_val_if_fail (GCAL_IS_VIEW (view), NULL);
- g_return_val_if_fail (GCAL_VIEW_GET_INTERFACE (view)->get_by_uuid, NULL);
-
- return GCAL_VIEW_GET_INTERFACE (view)->get_by_uuid (view, uuid);
-}
diff --git a/src/gcal-view.h b/src/gcal-view.h
index b13e908..581140f 100644
--- a/src/gcal-view.h
+++ b/src/gcal-view.h
@@ -59,9 +59,6 @@ struct _GcalViewIface
/* Update NavBar headings */
gchar* (*get_left_header) (GcalView *view);
gchar* (*get_right_header) (GcalView *view);
-
- /* Container functions related API */
- GtkWidget* (*get_by_uuid) (GcalView *view, const gchar *uuid);
};
GType gcal_view_get_type (void);
@@ -82,9 +79,6 @@ gchar* gcal_view_get_left_header (GcalView *view);
gchar* gcal_view_get_right_header (GcalView *view);
-GtkWidget* gcal_view_get_by_uuid (GcalView *view,
- const gchar *uuid);
-
G_END_DECLS
#endif /* __GCAL_MONTH_VIEW_H__ */
diff --git a/src/gcal-week-view.c b/src/gcal-week-view.c
index a3294f3..9b6ccb6 100644
--- a/src/gcal-week-view.c
+++ b/src/gcal-week-view.c
@@ -160,8 +160,8 @@ static gchar* gcal_week_view_get_left_header (GcalView *view
static gchar* gcal_week_view_get_right_header (GcalView *view);
-static GtkWidget* gcal_week_view_get_by_uuid (GcalView *view,
- const gchar *uuid);
+static GtkWidget* gcal_week_view_get_by_uuid (GcalSubscriberView *view,
+ const gchar *uuid);
G_DEFINE_TYPE_WITH_CODE (GcalWeekView, gcal_week_view, GCAL_TYPE_SUBSCRIBER_VIEW,
G_ADD_PRIVATE (GcalWeekView)
@@ -517,10 +517,14 @@ get_sidebar_width (GtkWidget *widget)
static void
gcal_week_view_class_init (GcalWeekViewClass *klass)
{
+ GcalSubscriberViewClass *subscriber_view_class;
GtkContainerClass *container_class;
GtkWidgetClass *widget_class;
GObjectClass *object_class;
+ subscriber_view_class = GCAL_SUBSCRIBER_VIEW_CLASS (klass);
+ subscriber_view_class->get_child_by_uuid = gcal_week_view_get_by_uuid;
+
container_class = GTK_CONTAINER_CLASS (klass);
container_class->add = gcal_week_view_add;
container_class->remove = gcal_week_view_remove;
@@ -565,8 +569,6 @@ gcal_view_interface_init (GcalViewIface *iface)
iface->get_left_header = gcal_week_view_get_left_header;
iface->get_right_header = gcal_week_view_get_right_header;
-
- iface->get_by_uuid = gcal_week_view_get_by_uuid;
}
static void
@@ -1391,15 +1393,15 @@ gcal_week_view_get_right_header (GcalView *view)
}
static GtkWidget*
-gcal_week_view_get_by_uuid (GcalView *view,
- const gchar *uuid)
+gcal_week_view_get_by_uuid (GcalSubscriberView *subscriber_view,
+ const gchar *uuid)
{
GcalWeekViewPrivate *priv;
gint i;
GList *l;
- g_return_val_if_fail (GCAL_IS_WEEK_VIEW (view), NULL);
- priv = gcal_week_view_get_instance_private (GCAL_WEEK_VIEW(view));
+ g_return_val_if_fail (GCAL_IS_WEEK_VIEW (subscriber_view), NULL);
+ priv = gcal_week_view_get_instance_private (GCAL_WEEK_VIEW(subscriber_view));
for (i = 0; i < 7; i++)
{
diff --git a/src/gcal-window.c b/src/gcal-window.c
index ee9a28c..31a24a1 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -1008,7 +1008,7 @@ edit_dialog_closed (GtkDialog *dialog,
uuid = gcal_edit_dialog_get_event_uuid (edit_dialog);
/* hide widget of the event */
- gtk_widget_hide (gcal_view_get_by_uuid (view, uuid));
+ gtk_widget_hide (gcal_subscriber_view_get_child_by_uuid (GCAL_SUBSCRIBER_VIEW (view), uuid));
g_free (uuid);
break;
@@ -1130,13 +1130,9 @@ undo_remove_event (GtkButton *button,
if (priv->event_to_delete != NULL)
{
- uuid = get_uuid_from_component (
- priv->event_to_delete->source,
- priv->event_to_delete->event_component);
- event_widget = gcal_view_get_by_uuid (
- GCAL_VIEW (priv->views[priv->active_view]),
- uuid);
-
+ uuid = get_uuid_from_component (priv->event_to_delete->source, priv->event_to_delete->event_component);
+ event_widget = gcal_subscriber_view_get_child_by_uuid (GCAL_SUBSCRIBER_VIEW
(priv->views[priv->active_view]),
+ uuid);
gtk_widget_show (event_widget);
g_clear_pointer (&(priv->event_to_delete), g_free);
diff --git a/src/gcal-year-view.c b/src/gcal-year-view.c
index d55bde1..a9bfde6 100644
--- a/src/gcal-year-view.c
+++ b/src/gcal-year-view.c
@@ -120,9 +120,6 @@ static gchar* gcal_year_view_get_left_header (GcalView
static gchar* gcal_year_view_get_right_header (GcalView *view);
-static GtkWidget* gcal_year_view_get_by_uuid (GcalView *view,
- const gchar *uuid);
-
G_DEFINE_TYPE_WITH_CODE (GcalYearView, gcal_year_view, GCAL_TYPE_SUBSCRIBER_VIEW,
G_ADD_PRIVATE (GcalYearView)
G_IMPLEMENT_INTERFACE (GCAL_TYPE_VIEW,gcal_view_interface_init));
@@ -248,8 +245,6 @@ gcal_view_interface_init (GcalViewIface *iface)
iface->get_left_header = gcal_year_view_get_left_header;
iface->get_right_header = gcal_year_view_get_right_header;
-
- iface->get_by_uuid = gcal_year_view_get_by_uuid;
}
static void
@@ -996,21 +991,6 @@ gcal_year_view_get_right_header (GcalView *view)
return g_strdup ("");
}
-static GtkWidget*
-gcal_year_view_get_by_uuid (GcalView *view,
- const gchar *uuid)
-{
- GcalSubscriberViewPrivate *priv;
- GList *l;
-
- priv = GCAL_SUBSCRIBER_VIEW (view)->priv;
- l = g_hash_table_lookup (priv->children, uuid);
- if (l != NULL)
- return (GtkWidget*) l->data;
-
- return NULL;
-}
-
/* Public API */
/**
* gcal_year_view_new:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]