[evolution] I#734 - Calendar: Option to start Month View with current week



commit ee8a47b8b78016a42237d61e78ab45d1535cd9b0
Author: Pascal Fuerst <pascalfuerst epost ch>
Date:   Mon Feb 10 09:28:13 2020 +0100

    I#734 - Calendar: Option to start Month View with current week
    
    Closes https://gitlab.gnome.org/GNOME/evolution/issues/734
    Closes https://gitlab.gnome.org/GNOME/evolution/merge_requests/44

 data/org.gnome.evolution.calendar.gschema.xml.in |  5 +++++
 src/calendar/gui/calendar-config.c               |  9 +++++++++
 src/calendar/gui/calendar-config.h               |  3 +++
 src/modules/calendar/e-cal-shell-content.c       | 16 +++++++++-------
 src/modules/calendar/e-calendar-preferences.c    |  6 ++++++
 src/modules/calendar/e-calendar-preferences.ui   | 21 ++++++++++++++++++---
 6 files changed, 50 insertions(+), 10 deletions(-)
---
diff --git a/data/org.gnome.evolution.calendar.gschema.xml.in 
b/data/org.gnome.evolution.calendar.gschema.xml.in
index 3fe4a630ec..a7585f47cc 100644
--- a/data/org.gnome.evolution.calendar.gschema.xml.in
+++ b/data/org.gnome.evolution.calendar.gschema.xml.in
@@ -279,6 +279,11 @@
       <_summary>Scroll Month View by a week, not by a month</_summary>
       <_description>Whether to scroll a Month View by a week, not by a month</_description>
     </key>
+    <key name="month-start-with-current-week" type="b">
+      <default>false</default>
+      <_summary>Let the Month View start with the current week</_summary>
+      <_description>Whether the month view should show weeks starting with the current week instead of the 
first week of the month.</_description>
+    </key>
     <key name="prefer-new-item" type="s">
       <default>''</default>
       <_summary>Preferred New button item</_summary>
diff --git a/src/calendar/gui/calendar-config.c b/src/calendar/gui/calendar-config.c
index 1f1658aac9..b7cb64e6e6 100644
--- a/src/calendar/gui/calendar-config.c
+++ b/src/calendar/gui/calendar-config.c
@@ -172,6 +172,15 @@ calendar_config_add_notification_month_scroll_by_week (CalendarConfigChangedFunc
                G_CALLBACK (func), data);
 }
 
+/* Start month view with current week instead of first week of the month */
+gboolean
+calendar_config_get_month_start_with_current_week (void)
+{
+       calendar_config_init();
+
+       return g_settings_get_boolean (config, "month-start-with-current-week");
+}
+
 /***************************************/
 
 /* Settings to hide completed tasks. */
diff --git a/src/calendar/gui/calendar-config.h b/src/calendar/gui/calendar-config.h
index 2df088c538..ac25fcde13 100644
--- a/src/calendar/gui/calendar-config.h
+++ b/src/calendar/gui/calendar-config.h
@@ -79,6 +79,9 @@ void   calendar_config_add_notification_day_second_zone (CalendarConfigChangedFu
 gboolean calendar_config_get_month_scroll_by_week (void);
 void     calendar_config_add_notification_month_scroll_by_week (CalendarConfigChangedFunc func, gpointer 
data);
 
+/* Start month view with current week instead of first week of the month */
+gboolean calendar_config_get_month_start_with_current_week (void);
+
 gboolean calendar_config_get_prefer_meeting (void);
 
 GDateWeekday   calendar_config_get_week_start_day              (void);
diff --git a/src/modules/calendar/e-cal-shell-content.c b/src/modules/calendar/e-cal-shell-content.c
index 5cca6f5a0b..e2ed40cff8 100644
--- a/src/modules/calendar/e-cal-shell-content.c
+++ b/src/modules/calendar/e-cal-shell-content.c
@@ -683,13 +683,15 @@ cal_shell_content_current_view_id_changed_cb (ECalShellContent *cal_shell_conten
                        break;
                case E_CAL_VIEW_KIND_MONTH:
                case E_CAL_VIEW_KIND_LIST:
-                       if (g_date_get_day (&sel_start) != 1 &&
-                           (g_date_get_julian (&sel_end) - g_date_get_julian (&sel_start) + 1) / 7 >= 3 &&
-                           g_date_get_month (&sel_start) != g_date_get_month (&sel_end)) {
-                               g_date_set_day (&sel_start, 1);
-                               g_date_add_months (&sel_start, 1);
-                       } else {
-                               g_date_set_day (&sel_start, 1);
+                       if (!calendar_config_get_month_start_with_current_week ()) {
+                               if (g_date_get_day (&sel_start) != 1 &&
+                                   (g_date_get_julian (&sel_end) - g_date_get_julian (&sel_start) + 1) / 7 
= 3 &&
+                                   g_date_get_month (&sel_start) != g_date_get_month (&sel_end)) {
+                                       g_date_set_day (&sel_start, 1);
+                                       g_date_add_months (&sel_start, 1);
+                               } else {
+                                       g_date_set_day (&sel_start, 1);
+                               }
                        }
                        sel_end = sel_start;
                        g_date_add_months (&sel_end, 1);
diff --git a/src/modules/calendar/e-calendar-preferences.c b/src/modules/calendar/e-calendar-preferences.c
index 05ea116a13..7fbeaa7521 100644
--- a/src/modules/calendar/e-calendar-preferences.c
+++ b/src/modules/calendar/e-calendar-preferences.c
@@ -972,6 +972,12 @@ calendar_preferences_construct (ECalendarPreferences *prefs,
                widget, "active",
                G_SETTINGS_BIND_DEFAULT);
 
+       widget = e_builder_get_widget(prefs->priv->builder, "month_start_with_current_week");
+       g_settings_bind(
+               settings, "month-start-with-current-week",
+               widget, "active",
+               G_SETTINGS_BIND_DEFAULT);
+
        widget = e_builder_get_widget (prefs->priv->builder, "week_view_days_left_to_right");
        g_settings_bind (
                settings, "week-view-days-left-to-right",
diff --git a/src/modules/calendar/e-calendar-preferences.ui b/src/modules/calendar/e-calendar-preferences.ui
index 5b3e48ae87..b708e52ac1 100644
--- a/src/modules/calendar/e-calendar-preferences.ui
+++ b/src/modules/calendar/e-calendar-preferences.ui
@@ -986,6 +986,21 @@
                     <property name="position">6</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkCheckButton" id="month_start_with_current_week">
+                    <property name="label" translatable="yes">Start Month View with the c_urrent 
week</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">7</property>
+                  </packing>
+                </child>
                 <child>
                   <object class="GtkCheckButton" id="week_view_days_left_to_right">
                     <property name="label" translatable="yes">Order days in Week View from _left to 
right</property>
@@ -998,7 +1013,7 @@
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">False</property>
-                    <property name="position">7</property>
+                    <property name="position">8</property>
                   </packing>
                 </child>
                 <child>
@@ -1013,7 +1028,7 @@
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">False</property>
-                    <property name="position">8</property>
+                    <property name="position">9</property>
                   </packing>
                 </child>
                 <child>
@@ -1028,7 +1043,7 @@
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">False</property>
-                    <property name="position">9</property>
+                    <property name="position">10</property>
                   </packing>
                 </child>
               </object>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]