Skip to content

Commit

Permalink
month-view: wrap around months for selector
Browse files Browse the repository at this point in the history
In this commit, we modify the position of the selector in the month view when the selector is out of bound of the present month

Presently, the selector in the month view doesn't move when it reaches the border of the month.

To fix this, whenever the keyboard_cell is less than first index of the month, we reduce the value of month by 1 and in the case it is greater than the max key cell, we are increasing the value of month by 1.

https://bugzilla.gnome.org/show_bug.cgi?id=763198
  • Loading branch information
pandusonu2 authored and GeorgesStavracas committed Mar 12, 2016
1 parent 97704c3 commit a738acb
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/gcal-month-view.c
Expand Up @@ -661,14 +661,15 @@ gcal_month_view_key_press (GtkWidget *widget,
GcalMonthViewPrivate *priv;
gboolean selection, valid_key;
gdouble x, y;
gint min, max, diff;
gint min, max, diff, month_change;

g_return_val_if_fail (GCAL_IS_MONTH_VIEW (widget), FALSE);

priv = gcal_month_view_get_instance_private (GCAL_MONTH_VIEW (widget));
selection = event->state & GDK_SHIFT_MASK;
valid_key = FALSE;
diff = 0;
month_change = 0;
min = priv->days_delay;
max = priv->days_delay + icaltime_days_in_month (priv->date->month, priv->date->year) - 1;

Expand Down Expand Up @@ -728,6 +729,28 @@ gcal_month_view_key_press (GtkWidget *widget,
{
priv->keyboard_cell += diff;
}
else
{
month_change = priv->keyboard_cell + diff > max ? 1 : -1;
priv->date->month += month_change;
*(priv->date) = icaltime_normalize(*(priv->date));

priv->days_delay = (time_day_of_week (1, priv->date->month - 1, priv->date->year) - priv->first_weekday + 7) % 7;

/*
* Set keyboard cell value to the sum or difference of days delay of successive
* month or last day of preceeding month and overload value depending on
* month_change. Overload value is the equal to the deviation of the value
* of keboard_cell from the min or max value of the current month depending
* on the overload point.
*/
if (month_change == 1)
priv->keyboard_cell = priv->days_delay + priv->keyboard_cell + diff - max - 1;
else
priv->keyboard_cell = priv->days_delay + icaltime_days_in_month (priv->date->month, priv->date->year) - min + priv->keyboard_cell + diff;

g_object_notify (G_OBJECT (widget), "active-date");
}

if (selection)
{
Expand Down

0 comments on commit a738acb

Please sign in to comment.