gcal-view: modified mark_current_unit API
Added x,y return values, positions of the current unit
This commit is contained in:
+29
-4
@@ -114,7 +114,9 @@ static icaltimetype* gcal_month_view_get_initial_date (GcalView *vie
|
||||
|
||||
static icaltimetype* gcal_month_view_get_final_date (GcalView *view);
|
||||
|
||||
static void gcal_month_view_mark_current_unit (GcalView *view);
|
||||
static void gcal_month_view_mark_current_unit (GcalView *view,
|
||||
gint *x,
|
||||
gint *y);
|
||||
|
||||
static void gcal_month_view_clear_marks (GcalView *view);
|
||||
|
||||
@@ -1162,26 +1164,49 @@ gcal_month_view_get_final_date (GcalView *view)
|
||||
new_date->day = icaltime_days_in_month (priv->date->month, priv->date->year);
|
||||
return new_date;
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_month_view_mark_current_unit (GcalView *view)
|
||||
gcal_month_view_mark_current_unit (GcalView *view,
|
||||
gint *x,
|
||||
gint *y)
|
||||
{
|
||||
GcalMonthViewPrivate *priv;
|
||||
|
||||
gdouble horizontal_block;
|
||||
gdouble vertical_block;
|
||||
|
||||
gint days;
|
||||
gint shown_rows;
|
||||
gint february_gap;
|
||||
gdouble lines_gap;
|
||||
gdouble lines_gap_for_5;
|
||||
|
||||
gint x_pos, y_pos;
|
||||
gdouble start_grid_y;
|
||||
|
||||
priv = gcal_month_view_get_instance_private (GCAL_MONTH_VIEW (view));
|
||||
start_grid_y = gcal_month_view_get_start_grid_y (GTK_WIDGET (view));
|
||||
horizontal_block = (gdouble) gtk_widget_get_allocated_width (GTK_WIDGET (view)) / 7.0;
|
||||
vertical_block = (gdouble) (gtk_widget_get_allocated_height (GTK_WIDGET (view)) - start_grid_y) / 6.0;
|
||||
|
||||
days = priv->days_delay + icaltime_days_in_month (priv->date->month,
|
||||
priv->date->year);
|
||||
days = priv->days_delay + icaltime_days_in_month (priv->date->month, priv->date->year);
|
||||
shown_rows = ceil (days / 7.0);
|
||||
february_gap = shown_rows == 4 ? 1 : 0;
|
||||
lines_gap = ((gdouble) (shown_rows + 1) / 2.0) + 0.5 - ceil (shown_rows / 2.0);
|
||||
lines_gap_for_5 = shown_rows == 5 ? lines_gap : 0;
|
||||
|
||||
priv->start_mark_cell = priv->date->day + 7 * february_gap + priv->days_delay - 1;
|
||||
priv->end_mark_cell = priv->start_mark_cell;
|
||||
|
||||
x_pos = horizontal_block * (( priv->end_mark_cell % 7) + 0.5);
|
||||
y_pos = start_grid_y + vertical_block * (lines_gap_for_5 + ( priv->end_mark_cell / 7) + 0.5);
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (view));
|
||||
|
||||
if (x != NULL)
|
||||
*x = x_pos;
|
||||
if (y != NULL)
|
||||
*y = y_pos;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+9
-4
@@ -159,17 +159,22 @@ gcal_view_get_final_date (GcalView *view)
|
||||
|
||||
/**
|
||||
* gcal_view_mark_current_unit:
|
||||
* @view: a #GcalView
|
||||
* @view: a #GcalView implementation
|
||||
* @x: the x position of the current unit. Returned by the view
|
||||
* @y: the y position of the current unit. Returned by the view
|
||||
*
|
||||
* Mark the current unit in the view as marked for event creation
|
||||
* Mark the current unit in the view as marked for event creation.
|
||||
* The (x, y) pair returned is the center of the cell
|
||||
**/
|
||||
void
|
||||
gcal_view_mark_current_unit (GcalView *view)
|
||||
gcal_view_mark_current_unit (GcalView *view,
|
||||
gint *x,
|
||||
gint *y)
|
||||
{
|
||||
g_return_if_fail (GCAL_IS_VIEW (view));
|
||||
g_return_if_fail (GCAL_VIEW_GET_INTERFACE (view)->mark_current_unit);
|
||||
|
||||
GCAL_VIEW_GET_INTERFACE (view)->mark_current_unit (view);
|
||||
GCAL_VIEW_GET_INTERFACE (view)->mark_current_unit (view, x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+4
-2
@@ -62,7 +62,7 @@ struct _GcalViewIface
|
||||
icaltimetype* (*get_final_date) (GcalView *view);
|
||||
|
||||
/* Marks related API */
|
||||
void (*mark_current_unit) (GcalView *view);
|
||||
void (*mark_current_unit) (GcalView *view, gint *x, gint *y);
|
||||
void (*clear_marks) (GcalView *view);
|
||||
|
||||
/* Update NavBar headings */
|
||||
@@ -94,7 +94,9 @@ icaltimetype* gcal_view_get_initial_date (GcalView *view);
|
||||
|
||||
icaltimetype* gcal_view_get_final_date (GcalView *view);
|
||||
|
||||
void gcal_view_mark_current_unit (GcalView *view);
|
||||
void gcal_view_mark_current_unit (GcalView *view,
|
||||
gint *x,
|
||||
gint *y);
|
||||
|
||||
void gcal_view_clear_marks (GcalView *view);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user