[gnome-calendar] month-view: wrap around months for selector
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] month-view: wrap around months for selector
- Date: Sat, 12 Mar 2016 01:45:20 +0000 (UTC)
commit a738acb462418ab757531bf6aba4ae8679be829d
Author: pandusonu2 <pandu sonu yahoo com>
Date: Sat Mar 12 01:18:01 2016 +0530
month-view: wrap around months for selector
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
src/gcal-month-view.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c
index 10a8d1c..793666a 100644
--- a/src/gcal-month-view.c
+++ b/src/gcal-month-view.c
@@ -661,7 +661,7 @@ 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);
@@ -669,6 +669,7 @@ gcal_month_view_key_press (GtkWidget *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;
@@ -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)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]