After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 763198 - Changing months in the month view using arrow keys.
Changing months in the month view using arrow keys.
Status: RESOLVED FIXED
Product: gnome-calendar
Classification: Applications
Component: Views
3.19.x
Other Linux
: Normal normal
: 3.26
Assigned To: GNOME Calendar maintainers
GNOME Calendar maintainers
Depends on:
Blocks: 763641
 
 
Reported: 2016-03-07 00:03 UTC by Gollapudi Vamsi Krishna
Modified: 2017-04-17 18:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
window: wrap around months for selector (1.99 KB, patch)
2016-03-09 16:54 UTC, Gollapudi Vamsi Krishna
none Details | Review
month-view: wrap around months for selector (1.81 KB, patch)
2016-03-09 19:04 UTC, Gollapudi Vamsi Krishna
none Details | Review
month-view: wrap around months for selector (2.11 KB, patch)
2016-03-09 21:11 UTC, Gollapudi Vamsi Krishna
none Details | Review
Attachment to Bug 763198 - Changing months in the month view using arrow keys. (2.11 KB, patch)
2016-03-09 21:14 UTC, Gollapudi Vamsi Krishna
none Details | Review
month-view: wrap around months for selector (2.11 KB, patch)
2016-03-09 21:16 UTC, Gollapudi Vamsi Krishna
none Details | Review
month-view: wrap around months for selector (2.35 KB, patch)
2016-03-10 04:55 UTC, Gollapudi Vamsi Krishna
none Details | Review
month-view: wrap around months for selector (2.65 KB, patch)
2016-03-11 19:52 UTC, Gollapudi Vamsi Krishna
committed Details | Review

Description Gollapudi Vamsi Krishna 2016-03-07 00:03:09 UTC
While using the arrow navigation in the month view, on reaching the end of the calendar, the selector doesn't move any further. This is an attempt to change that into switching between months.

Steps to Reproduce:
-Enter Month-view
-Navigate towards the end of a calendar in any direction(say 1st of the month)
-Press the Up arrow

Actual Result:
-There is no change in the position of the selector

Expected Result:
-The view should go to the previous month and the selector should be pointing towards the corresponding day which should be in the location if the months were joined.
Comment 1 Gollapudi Vamsi Krishna 2016-03-09 16:54:32 UTC
Created attachment 323522 [details] [review]
window: 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.
Comment 2 Georges Basile Stavracas Neto 2016-03-09 17:13:26 UTC
Review of attachment 323522 [details] [review]:

The changed component changed was month-view, not window. Please update the commit message.

More comments below:

::: src/gcal-month-view.c
@@ +728,3 @@
     {
       priv->keyboard_cell += diff;
+    }else if(priv->keyboard_cell + diff > max){

This code clearly disrespects the GNU C Coding Style. Read https://developer.gnome.org/programming-guidelines/stable/c-coding-style.html.en and update the patch.

@@ +730,3 @@
+    }else if(priv->keyboard_cell + diff > max){
+      priv->date->month = priv->date->month + 1;
+      if(priv->date->month == 13){

Jump a line.

@@ +733,3 @@
+        priv->date->month = 1;
+        priv->date->year = priv->date->year + 1;
+      }

Use icaltime_normalize() instead. See https://github.com/libical/libical/tree/master/src/libical documentation (specially icaltime.h).

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

Jump a line.

@@ +736,3 @@
+      priv->days_delay = (time_day_of_week (1, priv->date->month - 1, priv->date->year) - priv->first_weekday + 7) % 7;
+      priv->keyboard_cell = priv->days_delay + priv->keyboard_cell + diff - max - 1;
+    }else{

Ditto.

@@ +738,3 @@
+    }else{
+      priv->date->month = priv->date->month-1;
+      if(priv->date->month == 0){

Ditto.

@@ +741,3 @@
+        priv->date->month = 12;
+        priv->date->year = priv->date->year - 1;
+      }

Ditto.

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

Ditto.
Comment 3 Gollapudi Vamsi Krishna 2016-03-09 19:04:19 UTC
Created attachment 323540 [details] [review]
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.
Comment 4 Georges Basile Stavracas Neto 2016-03-09 20:28:35 UTC
Review of attachment 323540 [details] [review]:

Some nitpicks.

::: src/gcal-month-view.c
@@ +733,3 @@
+      priv->date->month = priv->date->month + 1;
+      *(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;

Jump a line.

@@ +734,3 @@
+      *(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;
+      priv->keyboard_cell = priv->days_delay + priv->keyboard_cell + diff - max - 1;

Jump a line and add a small comment explaining this line.

@@ +740,3 @@
+      priv->date->month = priv->date->month - 1;
+      *(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;

Jump a line.

@@ +741,3 @@
+      *(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;
+      priv->keyboard_cell = priv->days_delay + icaltime_days_in_month (priv->date->month, priv->date->year) - min + priv->keyboard_cell + diff;

Jump a line and add a small comment explaining this line.
Comment 5 Gollapudi Vamsi Krishna 2016-03-09 21:11:06 UTC
Created attachment 323552 [details] [review]
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.
Comment 6 Gollapudi Vamsi Krishna 2016-03-09 21:14:57 UTC
Created attachment 323553 [details] [review]
Attachment to Bug 763198 - Changing months in the month view using arrow keys.

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.
Comment 7 Gollapudi Vamsi Krishna 2016-03-09 21:16:35 UTC
Created attachment 323554 [details] [review]
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.
Comment 8 Georges Basile Stavracas Neto 2016-03-10 00:23:39 UTC
Review of attachment 323554 [details] [review]:

More nitpicks.

::: src/gcal-month-view.c
@@ +746,3 @@
+      priv->days_delay = (time_day_of_week (1, priv->date->month - 1, priv->date->year) - priv->first_weekday + 7) % 7;
+
+      /*Updating keyboard_cell value to the the displacement in the cell after entering successive month*/

This comment doesn't really explain what the following line does. I expect something like "Set the keyboard selection to the first day of the next month".

Besides that, the comment doesn't respect GNU C Coding Standard. Add a blank space between '*' and the text.

@@ +756,3 @@
+      priv->days_delay = (time_day_of_week (1, priv->date->month - 1, priv->date->year) - priv->first_weekday + 7) % 7;
+
+      /*Updating keyboard_cell value to the the displacement in the cell after entering preceding month*/

Ditto.
Comment 9 Gollapudi Vamsi Krishna 2016-03-10 04:55:16 UTC
Created attachment 323587 [details] [review]
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.
Comment 10 Georges Basile Stavracas Neto 2016-03-11 02:36:11 UTC
Review of attachment 323587 [details] [review]:

I just realized one more issue. Hopefullu, the last one before this patch is good enough.

::: src/gcal-month-view.c
@@ +741,3 @@
+       * the displacement from current cell and the max value in the current month.
+       */
+      priv->keyboard_cell = priv->days_delay + priv->keyboard_cell + diff - max - 1;

After this code, it should call g_object_notify() to notify GcalWindow about the property change.

@@ +755,3 @@
+       * minimum value in current month and the displacement from current cell.
+       */
+      priv->keyboard_cell = priv->days_delay + icaltime_days_in_month (priv->date->month, priv->date->year) - min + priv->keyboard_cell + diff;

Ditto.
Comment 11 Georges Basile Stavracas Neto 2016-03-11 02:36:18 UTC
Review of attachment 323587 [details] [review]:

I just realized one more issue. Hopefully, the last one before this patch is good enough.

::: src/gcal-month-view.c
@@ +741,3 @@
+       * the displacement from current cell and the max value in the current month.
+       */
+      priv->keyboard_cell = priv->days_delay + priv->keyboard_cell + diff - max - 1;

After this code, it should call g_object_notify() to notify GcalWindow about the property change.

@@ +755,3 @@
+       * minimum value in current month and the displacement from current cell.
+       */
+      priv->keyboard_cell = priv->days_delay + icaltime_days_in_month (priv->date->month, priv->date->year) - min + priv->keyboard_cell + diff;

Ditto.
Comment 12 Gollapudi Vamsi Krishna 2016-03-11 19:52:09 UTC
Created attachment 323731 [details] [review]
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.
Comment 13 Georges Basile Stavracas Neto 2016-03-12 01:47:40 UTC
The patch looks good, and works amazingly as well. Thanks for the fix.

Attachment 323731 [details] pushed as a738acb - month-view: wrap around months for selector