subscriber-view: gained ::get_child_by_uuid vfunc
Started migrating methods from GcalView to GcalSubscriber
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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__ */
|
||||
|
||||
+10
-8
@@ -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++)
|
||||
{
|
||||
|
||||
+4
-8
@@ -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);
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user