month-view: helper to calculate the split of widgets

This calculates the split according to the space left on each cell
This commit is contained in:
Erick Pérez Castellanos
2014-12-18 00:59:58 -05:00
parent 51c7e5e2ea
commit 9c29618fb6
+55
View File
@@ -97,6 +97,14 @@ static gint get_cell_and_center_from_position (GcalMonthView *vie
static gdouble get_start_grid_y (GtkWidget *widget);
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 void gcal_view_interface_init (GcalViewIface *iface);
static void gcal_month_view_set_property (GObject *object,
@@ -251,6 +259,53 @@ get_start_grid_y (GtkWidget *widget)
return start_grid_y;
}
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 void
gcal_month_view_class_init (GcalMonthViewClass *klass)
{