[evolution] Bug 320209 - Option to Order days in Week View from left to right



commit 1a4ce0cc184e81557253a7da7bf402ebf3f81a1a
Author: Milan Crha <mcrha redhat com>
Date:   Tue Sep 19 12:12:49 2017 +0200

    Bug 320209 - Option to Order days in Week View from left to right

 data/org.gnome.evolution.calendar.gschema.xml.in |    4 ++
 src/calendar/gui/e-week-view-layout.c            |   23 +++++++++
 src/calendar/gui/e-week-view.c                   |   55 ++++++++++++++++++++++
 src/calendar/gui/e-week-view.h                   |    5 ++
 src/modules/calendar/e-calendar-preferences.c    |    6 ++
 src/modules/calendar/e-calendar-preferences.ui   |   15 ++++++
 src/modules/settings/e-settings-calendar-view.c  |    5 ++
 7 files changed, 113 insertions(+), 0 deletions(-)
---
diff --git a/data/org.gnome.evolution.calendar.gschema.xml.in 
b/data/org.gnome.evolution.calendar.gschema.xml.in
index 7186101..2a47b52 100644
--- a/data/org.gnome.evolution.calendar.gschema.xml.in
+++ b/data/org.gnome.evolution.calendar.gschema.xml.in
@@ -469,6 +469,10 @@
       <default>true</default>
       <_summary>Draw events as flat, not shaded.</_summary>
     </key>
+    <key name="week-view-days-left-to-right" type="b">
+      <default>false</default>
+      <_summary>Whether to order days in the Week View from left to right, rather than from top to 
bottom.</_summary>
+    </key>
 
     <!-- The following keys are deprecated. -->
 
diff --git a/src/calendar/gui/e-week-view-layout.c b/src/calendar/gui/e-week-view-layout.c
index 818765f..a8ae673 100644
--- a/src/calendar/gui/e-week-view-layout.c
+++ b/src/calendar/gui/e-week-view-layout.c
@@ -341,6 +341,7 @@ e_week_view_layout_get_day_position (gint day,
                gint arr[4] = {1, 1, 1, 1};
                gint edge, i, wd, m, M;
                gboolean any = TRUE;
+               gboolean days_left_to_right;
                gint n_work_days_mon_wed = 0;
                gint n_work_days_thu_sun = 0;
 
@@ -351,6 +352,8 @@ e_week_view_layout_get_day_position (gint day,
 
                settings = e_util_ref_settings ("org.gnome.evolution.calendar");
 
+               days_left_to_right = g_settings_get_boolean (settings, "week-view-days-left-to-right");
+
                if (g_settings_get_boolean (settings, "work-day-monday"))
                        work_days[0] = 1, n_work_days_mon_wed++;
                if (g_settings_get_boolean (settings, "work-day-tuesday"))
@@ -373,6 +376,26 @@ e_week_view_layout_get_day_position (gint day,
                else
                        edge = 3;  /* Thursday */
 
+               if (days_left_to_right) {
+                       /* The default view is always with two columns:
+                            Mon  Thu
+                            Tue  Fri
+                            Wed  Sat/Sun
+                          eventually:
+                            Mon  Fri
+                            Tue  Sat
+                            Wed  Sun
+                            Thu
+                       */
+                       if (edge == 3) {
+                               const gint transform[] = { 0, 3, 1, 4, 2, 5, 6 };
+                               day = transform[day];
+                       } else {
+                               const gint transform[] = { 0, 4, 1, 5, 2, 3, 6 };
+                               day = transform[day];
+                       }
+               }
+
                if (day < edge) {
                        *day_x = 0;
                        m = 0;
diff --git a/src/calendar/gui/e-week-view.c b/src/calendar/gui/e-week-view.c
index ec7a32a..19f0fcb 100644
--- a/src/calendar/gui/e-week-view.c
+++ b/src/calendar/gui/e-week-view.c
@@ -100,6 +100,7 @@ struct _EWeekViewPrivate {
 
        gboolean show_icons_month_view;
        gboolean draw_flat_events;
+       gboolean days_left_to_right;
 };
 
 typedef struct {
@@ -198,6 +199,7 @@ enum {
        PROP_0,
        PROP_COMPRESS_WEEKEND,
        PROP_DRAW_FLAT_EVENTS,
+       PROP_DAYS_LEFT_TO_RIGHT,
        PROP_SHOW_EVENT_END_TIMES,
        PROP_SHOW_ICONS_MONTH_VIEW,
        PROP_IS_EDITING
@@ -784,6 +786,12 @@ week_view_set_property (GObject *object,
                                g_value_get_boolean (value));
                        return;
 
+               case PROP_DAYS_LEFT_TO_RIGHT:
+                       e_week_view_set_days_left_to_right (
+                               E_WEEK_VIEW (object),
+                               g_value_get_boolean (value));
+                       return;
+
                case PROP_DRAW_FLAT_EVENTS:
                        e_week_view_set_draw_flat_events (
                                E_WEEK_VIEW (object),
@@ -820,6 +828,13 @@ week_view_get_property (GObject *object,
                                E_WEEK_VIEW (object)));
                        return;
 
+               case PROP_DAYS_LEFT_TO_RIGHT:
+                       g_value_set_boolean (
+                               value,
+                               e_week_view_get_days_left_to_right (
+                               E_WEEK_VIEW (object)));
+                       return;
+
                case PROP_DRAW_FLAT_EVENTS:
                        g_value_set_boolean (
                                value,
@@ -1657,6 +1672,17 @@ e_week_view_class_init (EWeekViewClass *class)
 
        g_object_class_install_property (
                object_class,
+               PROP_DAYS_LEFT_TO_RIGHT,
+               g_param_spec_boolean (
+                       "days-left-to-right",
+                       "Days Left To Right",
+                       NULL,
+                       FALSE,
+                       G_PARAM_READWRITE |
+                       G_PARAM_STATIC_STRINGS));
+
+       g_object_class_install_property (
+               object_class,
                PROP_DRAW_FLAT_EVENTS,
                g_param_spec_boolean (
                        "draw-flat-events",
@@ -1708,6 +1734,7 @@ e_week_view_init (EWeekView *week_view)
        week_view->priv = E_WEEK_VIEW_GET_PRIVATE (week_view);
        week_view->priv->weeks_shown = 6;
        week_view->priv->compress_weekend = TRUE;
+       week_view->priv->days_left_to_right = FALSE;
        week_view->priv->draw_flat_events = TRUE;
        week_view->priv->show_event_end_times = TRUE;
        week_view->priv->update_base_date = TRUE;
@@ -2526,6 +2553,34 @@ e_week_view_set_draw_flat_events (EWeekView *week_view,
        g_object_notify (G_OBJECT (week_view), "draw-flat-events");
 }
 
+gboolean
+e_week_view_get_days_left_to_right (EWeekView *week_view)
+{
+       g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE);
+
+       return week_view->priv->days_left_to_right;
+}
+
+void
+e_week_view_set_days_left_to_right (EWeekView *week_view,
+                                   gboolean days_left_to_right)
+{
+       g_return_if_fail (E_IS_WEEK_VIEW (week_view));
+
+       if ((week_view->priv->days_left_to_right ? 1 : 0) == (days_left_to_right ? 1 : 0))
+               return;
+
+       week_view->priv->days_left_to_right = days_left_to_right;
+
+       week_view->events_need_layout = TRUE;
+       week_view->events_need_reshape = TRUE;
+
+       gtk_widget_queue_draw (week_view->main_canvas);
+       e_week_view_queue_layout (week_view);
+
+       g_object_notify (G_OBJECT (week_view), "days-left-to-right");
+}
+
 /* Whether we display event end times. */
 gboolean
 e_week_view_get_show_event_end_times (EWeekView *week_view)
diff --git a/src/calendar/gui/e-week-view.h b/src/calendar/gui/e-week-view.h
index afb0966..1276c76 100644
--- a/src/calendar/gui/e-week-view.h
+++ b/src/calendar/gui/e-week-view.h
@@ -338,6 +338,11 @@ gboolean   e_week_view_get_draw_flat_events
 void           e_week_view_set_draw_flat_events
                                                (EWeekView *week_view,
                                                 gboolean draw_flat_events);
+gboolean       e_week_view_get_days_left_to_right
+                                               (EWeekView *week_view);
+void           e_week_view_set_days_left_to_right
+                                               (EWeekView *week_view,
+                                                gboolean days_left_to_right);
 
 /* The first day shown. Note that it will be rounded down to the start of a
  * week when set. The returned value will be invalid if no date has been set
diff --git a/src/modules/calendar/e-calendar-preferences.c b/src/modules/calendar/e-calendar-preferences.c
index 5183ee8..b15a154 100644
--- a/src/modules/calendar/e-calendar-preferences.c
+++ b/src/modules/calendar/e-calendar-preferences.c
@@ -985,6 +985,12 @@ calendar_preferences_construct (ECalendarPreferences *prefs,
                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",
+               widget, "active",
+               G_SETTINGS_BIND_DEFAULT);
+
        widget = e_builder_get_widget (prefs->priv->builder, "tasks_due_today_highlight");
        g_settings_bind (
                settings, "task-due-today-highlight",
diff --git a/src/modules/calendar/e-calendar-preferences.ui b/src/modules/calendar/e-calendar-preferences.ui
index 825883f..17314a1 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="week_view_days_left_to_right">
+                    <property name="label" translatable="yes">Order days in Week View from _left to 
right</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>
               </object>
               <packing>
                 <property name="expand">True</property>
diff --git a/src/modules/settings/e-settings-calendar-view.c b/src/modules/settings/e-settings-calendar-view.c
index c82a599..4084467 100644
--- a/src/modules/settings/e-settings-calendar-view.c
+++ b/src/modules/settings/e-settings-calendar-view.c
@@ -92,6 +92,11 @@ settings_calendar_view_constructed (GObject *object)
                        G_SETTINGS_BIND_GET);
 
                g_settings_bind (
+                       settings, "week-view-days-left-to-right",
+                       extensible, "days-left-to-right",
+                       G_SETTINGS_BIND_GET);
+
+               g_settings_bind (
                        settings, "draw-flat-events",
                        extensible, "draw-flat-events",
                        G_SETTINGS_BIND_GET);


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