From e57d9ca55e51ae60e7c0ed8c3afaf1cd373f998f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erick=20P=C3=A9rez=20Castellanos?= Date: Mon, 29 Dec 2014 16:35:41 -0500 Subject: [PATCH] year-view: initial GtkWidget::size_allocate impl This impl uses internals structures from GcalSubscriber --- src/gcal-year-view.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/gcal-year-view.c b/src/gcal-year-view.c index 554407c7..4322cf82 100644 --- a/src/gcal-year-view.c +++ b/src/gcal-year-view.c @@ -52,6 +52,14 @@ enum PROP_MANAGER //manager inherited property }; +static gboolean get_widget_parts (gint first_cell, + gint last_cell, + gint natural_height, + gdouble vertical_cell_space, + gdouble *size_left, + GArray *cells, + GArray *lengths); + static gboolean get_widget_parts (gint first_cell, gint last_cell, gint natural_height, @@ -121,6 +129,53 @@ G_DEFINE_TYPE_WITH_CODE (GcalYearView, gcal_year_view, GCAL_TYPE_SUBSCRIBER_VIEW G_IMPLEMENT_INTERFACE (GCAL_TYPE_VIEW,gcal_view_interface_init)); +static gboolean +get_widget_parts (gint first_cell, + gint last_cell, + gint natural_height, + gdouble vertical_cell_space, + gdouble *size_left, + GArray *cells, + GArray *lengths) +{ + gint i; + gint current_part_length; + gdouble y, old_y = - 1.0; + + if (last_cell < first_cell) + { + gint swap = last_cell; + last_cell = first_cell; + first_cell = swap; + } + + for (i = first_cell; i <= last_cell; i++) + { + if (size_left[i] < natural_height) + { + return FALSE; + } + else + { + y = vertical_cell_space - size_left[i]; + if (y != old_y) + { + current_part_length = 1; + g_array_append_val (cells, i); + g_array_append_val (lengths, current_part_length); + old_y = y; + } + else + { + current_part_length++; + g_array_index (lengths, gint, lengths->len - 1) = current_part_length; + } + } + } + + return TRUE; +} + static gboolean get_widget_parts (gint first_cell, gint last_cell,