[evolution] I#1556 - Calendar: Add option to hide Memos/Tasks pane



commit b091bb5ea2d3af2dc3910d34f22adfe8657f3b62
Author: Milan Crha <mcrha redhat com>
Date:   Thu Jul 8 19:17:55 2021 +0200

    I#1556 - Calendar: Add option to hide Memos/Tasks pane
    
    Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1556

 data/org.gnome.evolution.calendar.gschema.xml.in |  5 ++
 data/ui/evolution-calendars.ui                   |  5 ++
 src/modules/calendar/e-cal-shell-content.c       | 63 +++++++++++++++++++++++-
 src/modules/calendar/e-cal-shell-content.h       |  3 ++
 src/modules/calendar/e-cal-shell-view-actions.c  | 29 +++++++++++
 src/modules/calendar/e-cal-shell-view-actions.h  |  2 +
 6 files changed, 106 insertions(+), 1 deletion(-)
---
diff --git a/data/org.gnome.evolution.calendar.gschema.xml.in 
b/data/org.gnome.evolution.calendar.gschema.xml.in
index a7585f47cc..a8a2787ac3 100644
--- a/data/org.gnome.evolution.calendar.gschema.xml.in
+++ b/data/org.gnome.evolution.calendar.gschema.xml.in
@@ -349,6 +349,11 @@
       <_summary>Vertical position for the tag pane</_summary>
       <_description>Vertical position for the tag pane</_description>
     </key>
+    <key name="show-tag-vpane" type="b">
+      <default>true</default>
+      <_summary>Show Tasks and Memos pane in the Calendar view</_summary>
+      <_description>Whether to show Tasks and Memos pane in the Calendar view</_description>
+    </key>
     <key name="task-due-today-highlight" type="b">
       <default>true</default>
       <_summary>Highlight tasks due today</_summary>
diff --git a/data/ui/evolution-calendars.ui b/data/ui/evolution-calendars.ui
index 4349c68e56..7663df94e2 100644
--- a/data/ui/evolution-calendars.ui
+++ b/data/ui/evolution-calendars.ui
@@ -26,6 +26,11 @@
       <menuitem action='calendar-go-today'/>
       <menuitem action='calendar-jump-to'/>
       <menuitem action='calendar-manage-groups'/>
+      <menu action='layout-menu'>
+        <placeholder name='view-layout-custom-menus'>
+          <menuitem action='calendar-show-tag-vpane'/>
+        </placeholder>
+      </menu>
     </menu>
     <placeholder name='custom-menus'>
       <menu action='calendar-actions-menu'>
diff --git a/src/modules/calendar/e-cal-shell-content.c b/src/modules/calendar/e-cal-shell-content.c
index 80f699741e..be31341e39 100644
--- a/src/modules/calendar/e-cal-shell-content.c
+++ b/src/modules/calendar/e-cal-shell-content.c
@@ -83,7 +83,8 @@ enum {
        PROP_MEMO_TABLE,
        PROP_TASK_TABLE,
        PROP_CURRENT_VIEW_ID,
-       PROP_CURRENT_VIEW
+       PROP_CURRENT_VIEW,
+       PROP_SHOW_TAG_VPANE
 };
 
 /* Used to indicate who has the focus within the calendar view. */
@@ -1658,6 +1659,10 @@ cal_shell_content_set_property (GObject *object,
                        e_cal_shell_content_set_current_view_id (E_CAL_SHELL_CONTENT (object),
                                g_value_get_int (value));
                        return;
+               case PROP_SHOW_TAG_VPANE:
+                       e_cal_shell_content_set_show_tag_vpane (E_CAL_SHELL_CONTENT (object),
+                               g_value_get_boolean (value));
+                       return;
        }
 
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -1697,6 +1702,11 @@ cal_shell_content_get_property (GObject *object,
                        g_value_set_object (value,
                                e_cal_shell_content_get_current_calendar_view (E_CAL_SHELL_CONTENT (object)));
                        return;
+
+               case PROP_SHOW_TAG_VPANE:
+                       g_value_set_boolean (value,
+                               e_cal_shell_content_get_show_tag_vpane (E_CAL_SHELL_CONTENT (object)));
+                       return;
        }
 
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -1946,6 +1956,11 @@ cal_shell_content_constructed (GObject *object)
                cal_shell_content->priv->vpaned, "proportion",
                G_SETTINGS_BIND_DEFAULT);
 
+       g_settings_bind (
+               settings, "show-tag-vpane",
+               cal_shell_content, "show-tag-vpane",
+               G_SETTINGS_BIND_DEFAULT);
+
        g_object_unref (settings);
 
        /* Cannot access shell sidebar here, thus rely on cal_shell_content_view_created()
@@ -2026,6 +2041,16 @@ e_cal_shell_content_class_init (ECalShellContentClass *class)
                        NULL,
                        E_TYPE_CALENDAR_VIEW,
                        G_PARAM_READABLE));
+
+       g_object_class_install_property (
+               object_class,
+               PROP_SHOW_TAG_VPANE,
+               g_param_spec_boolean (
+                       "show-tag-vpane",
+                       NULL,
+                       NULL,
+                       TRUE,
+                       G_PARAM_READWRITE));
 }
 
 static void
@@ -2626,3 +2651,39 @@ e_cal_shell_content_get_list_view_data_model (ECalShellContent *cal_shell_conten
 
        return cal_shell_content->priv->list_view_data_model;
 }
+
+void
+e_cal_shell_content_set_show_tag_vpane (ECalShellContent *cal_shell_content,
+                                       gboolean show)
+{
+       g_return_if_fail (E_IS_CAL_SHELL_CONTENT (cal_shell_content));
+
+       if ((gtk_widget_get_visible (cal_shell_content->priv->vpaned) ? 1 : 0) == (show ? 1 : 0))
+               return;
+
+       gtk_widget_set_visible (cal_shell_content->priv->vpaned, show);
+
+       if (show) {
+               if (cal_shell_content->priv->task_data_model)
+                       e_cal_data_model_thaw_views_update (cal_shell_content->priv->task_data_model);
+
+               if (cal_shell_content->priv->memo_data_model)
+                       e_cal_data_model_thaw_views_update (cal_shell_content->priv->memo_data_model);
+       } else {
+               if (cal_shell_content->priv->task_data_model)
+                       e_cal_data_model_freeze_views_update (cal_shell_content->priv->task_data_model);
+
+               if (cal_shell_content->priv->memo_data_model)
+                       e_cal_data_model_freeze_views_update (cal_shell_content->priv->memo_data_model);
+       }
+
+       g_object_notify (G_OBJECT (cal_shell_content), "show-tag-vpane");
+}
+
+gboolean
+e_cal_shell_content_get_show_tag_vpane (ECalShellContent *cal_shell_content)
+{
+       g_return_val_if_fail (E_IS_CAL_SHELL_CONTENT (cal_shell_content), FALSE);
+
+       return gtk_widget_get_visible (cal_shell_content->priv->vpaned);
+}
diff --git a/src/modules/calendar/e-cal-shell-content.h b/src/modules/calendar/e-cal-shell-content.h
index 11240d4614..23dfe46d08 100644
--- a/src/modules/calendar/e-cal-shell-content.h
+++ b/src/modules/calendar/e-cal-shell-content.h
@@ -108,6 +108,9 @@ void                e_cal_shell_content_update_tasks_filter (ECalShellContent 
*cal_shell_conte
                                                         const gchar *cal_filter);
 ECalDataModel *        e_cal_shell_content_get_list_view_data_model
                                                        (ECalShellContent *cal_shell_content);
+void           e_cal_shell_content_set_show_tag_vpane  (ECalShellContent *cal_shell_content,
+                                                        gboolean show);
+gboolean       e_cal_shell_content_get_show_tag_vpane  (ECalShellContent *cal_shell_content);
 
 G_END_DECLS
 
diff --git a/src/modules/calendar/e-cal-shell-view-actions.c b/src/modules/calendar/e-cal-shell-view-actions.c
index f433abb04a..c2ffd82089 100644
--- a/src/modules/calendar/e-cal-shell-view-actions.c
+++ b/src/modules/calendar/e-cal-shell-view-actions.c
@@ -1283,6 +1283,15 @@ action_event_schedule_appointment_cb (GtkAction *action,
        edit_event_as (cal_shell_view, FALSE);
 }
 
+static void
+action_calendar_show_tag_vpane_cb (GtkAction *action,
+                                  ECalShellView *cal_shell_view)
+{
+       g_return_if_fail (E_IS_CAL_SHELL_VIEW (cal_shell_view));
+
+       e_cal_shell_content_set_show_tag_vpane (cal_shell_view->priv->cal_shell_content, 
gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+}
+
 static GtkActionEntry calendar_entries[] = {
 
        { "calendar-copy",
@@ -1714,6 +1723,17 @@ static EPopupActionEntry calendar_popup_entries[] = {
          "event-schedule-appointment" }
 };
 
+static GtkToggleActionEntry calendar_toggle_entries[] = {
+
+       { "calendar-show-tag-vpane",
+         NULL,
+         N_("Show T_asks and Memos pane"),
+         NULL,
+         N_("Show Tasks and Memos pane"),
+         G_CALLBACK (action_calendar_show_tag_vpane_cb),
+         TRUE }
+};
+
 static GtkRadioActionEntry calendar_view_entries[] = {
 
        /* This action represents the initial calendar view.
@@ -1903,6 +1923,9 @@ e_cal_shell_view_actions_init (ECalShellView *cal_shell_view)
        e_action_group_add_popup_actions (
                action_group, calendar_popup_entries,
                G_N_ELEMENTS (calendar_popup_entries));
+       gtk_action_group_add_toggle_actions (
+               action_group, calendar_toggle_entries,
+               G_N_ELEMENTS (calendar_toggle_entries), cal_shell_view);
        gtk_action_group_add_radio_actions (
                action_group, calendar_view_entries,
                G_N_ELEMENTS (calendar_view_entries), BOGUS_INITIAL_VALUE,
@@ -1960,6 +1983,12 @@ e_cal_shell_view_actions_init (ECalShellView *cal_shell_view)
        action = ACTION (CALENDAR_VIEW_WORKWEEK);
        gtk_action_set_is_important (action, TRUE);
 
+       action = ACTION (CALENDAR_SHOW_TAG_VPANE);
+       g_settings_bind (
+               cal_shell_view->priv->settings, "show-tag-vpane",
+               action, "active",
+               G_SETTINGS_BIND_GET);
+
        /* Initialize the memo and task pad actions. */
        e_cal_shell_view_memopad_actions_init (cal_shell_view);
        e_cal_shell_view_taskpad_actions_init (cal_shell_view);
diff --git a/src/modules/calendar/e-cal-shell-view-actions.h b/src/modules/calendar/e-cal-shell-view-actions.h
index a8374b211d..6917e74827 100644
--- a/src/modules/calendar/e-cal-shell-view-actions.h
+++ b/src/modules/calendar/e-cal-shell-view-actions.h
@@ -62,6 +62,8 @@
        E_SHELL_WINDOW_ACTION ((window), "calendar-select-all")
 #define E_SHELL_WINDOW_ACTION_CALENDAR_SELECT_ONE(window) \
        E_SHELL_WINDOW_ACTION ((window), "calendar-select-one")
+#define E_SHELL_WINDOW_ACTION_CALENDAR_SHOW_TAG_VPANE(window) \
+       E_SHELL_WINDOW_ACTION ((window), "calendar-show-tag-vpane")
 #define E_SHELL_WINDOW_ACTION_CALENDAR_VIEW_DAY(window) \
        E_SHELL_WINDOW_ACTION ((window), "calendar-view-day")
 #define E_SHELL_WINDOW_ACTION_CALENDAR_VIEW_LIST(window) \


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