[evolution] Bug 516943 - Disable direct event Summary edit by default



commit 7a36dabc7f241242b4dc44b48943d7b97a2f08b8
Author: Milan Crha <mcrha redhat com>
Date:   Thu Mar 22 13:50:19 2018 +0100

    Bug 516943 - Disable direct event Summary edit by default

 data/org.gnome.evolution.calendar.gschema.xml.in |    4 ++
 src/calendar/gui/e-calendar-view.c               |   47 +++++++++++++++++++++-
 src/calendar/gui/e-calendar-view.h               |    5 ++
 src/calendar/gui/e-day-view.c                    |   15 +++++--
 src/calendar/gui/e-week-view.c                   |    3 +-
 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 ++
 8 files changed, 93 insertions(+), 7 deletions(-)
---
diff --git a/data/org.gnome.evolution.calendar.gschema.xml.in 
b/data/org.gnome.evolution.calendar.gschema.xml.in
index 2a47b52..44c4892 100644
--- a/data/org.gnome.evolution.calendar.gschema.xml.in
+++ b/data/org.gnome.evolution.calendar.gschema.xml.in
@@ -473,6 +473,10 @@
       <default>false</default>
       <_summary>Whether to order days in the Week View from left to right, rather than from top to 
bottom.</_summary>
     </key>
+    <key name="allow-direct-summary-edit" type="b">
+      <default>false</default>
+      <_summary>Allow direct edit of event Summary when clicking on it in the Day, Work Week, Week or Month 
view.</_summary>
+    </key>
 
     <!-- The following keys are deprecated. -->
 
diff --git a/src/calendar/gui/e-calendar-view.c b/src/calendar/gui/e-calendar-view.c
index 00c90a2..3ed9b95 100644
--- a/src/calendar/gui/e-calendar-view.c
+++ b/src/calendar/gui/e-calendar-view.c
@@ -62,6 +62,8 @@ struct _ECalendarViewPrivate {
        /* All keyboard devices are grabbed
         * while a tooltip window is shown. */
        GQueue grabbed_keyboards;
+
+       gboolean allow_direct_summary_edit;
 };
 
 enum {
@@ -70,7 +72,8 @@ enum {
        PROP_MODEL,
        PROP_PASTE_TARGET_LIST,
        PROP_TIME_DIVISIONS,
-       PROP_IS_EDITING
+       PROP_IS_EDITING,
+       PROP_ALLOW_DIRECT_SUMMARY_EDIT
 };
 
 /* FIXME Why are we emitting these event signals here? Can't the model just be listened to? */
@@ -298,6 +301,12 @@ calendar_view_set_property (GObject *object,
                                E_CALENDAR_VIEW (object),
                                g_value_get_int (value));
                        return;
+
+               case PROP_ALLOW_DIRECT_SUMMARY_EDIT:
+                       e_calendar_view_set_allow_direct_summary_edit (
+                               E_CALENDAR_VIEW (object),
+                               g_value_get_boolean (value));
+                       return;
        }
 
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -337,6 +346,10 @@ calendar_view_get_property (GObject *object,
                case PROP_IS_EDITING:
                        g_value_set_boolean (value, e_calendar_view_is_editing (E_CALENDAR_VIEW (object)));
                        return;
+
+               case PROP_ALLOW_DIRECT_SUMMARY_EDIT:
+                       g_value_set_boolean (value, e_calendar_view_get_allow_direct_summary_edit 
(E_CALENDAR_VIEW (object)));
+                       return;
        }
 
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -1134,6 +1147,16 @@ e_calendar_view_class_init (ECalendarViewClass *class)
                        FALSE,
                        G_PARAM_READABLE));
 
+       g_object_class_install_property (
+               object_class,
+               PROP_ALLOW_DIRECT_SUMMARY_EDIT,
+               g_param_spec_boolean (
+                       "allow-direct-summary-edit",
+                       "Whether can edit event Summary directly",
+                       NULL,
+                       FALSE,
+                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
        signals[POPUP_EVENT] = g_signal_new (
                "popup-event",
                G_TYPE_FROM_CLASS (class),
@@ -2346,3 +2369,25 @@ e_calendar_view_move_view_range (ECalendarView *cal_view,
 
        g_signal_emit (cal_view, signals[MOVE_VIEW_RANGE], 0, mode_type, (gint64) exact_date);
 }
+
+gboolean
+e_calendar_view_get_allow_direct_summary_edit (ECalendarView *cal_view)
+{
+       g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), FALSE);
+
+       return cal_view->priv->allow_direct_summary_edit;
+}
+
+void
+e_calendar_view_set_allow_direct_summary_edit (ECalendarView *cal_view,
+                                              gboolean allow)
+{
+       g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
+
+       if ((cal_view->priv->allow_direct_summary_edit ? 1 : 0) == (allow ? 1 : 0))
+               return;
+
+       cal_view->priv->allow_direct_summary_edit = allow;
+
+       g_object_notify (G_OBJECT (cal_view), "allow-direct-summary-edit");
+}
diff --git a/src/calendar/gui/e-calendar-view.h b/src/calendar/gui/e-calendar-view.h
index 6c6c094..f114e76 100644
--- a/src/calendar/gui/e-calendar-view.h
+++ b/src/calendar/gui/e-calendar-view.h
@@ -276,6 +276,11 @@ void               draw_curved_rectangle           (cairo_t *cr,
 GdkColor       get_today_background            (GdkColor event_background);
 
 gboolean       e_calendar_view_is_editing      (ECalendarView *cal_view);
+gboolean       e_calendar_view_get_allow_direct_summary_edit
+                                               (ECalendarView *cal_view);
+void           e_calendar_view_set_allow_direct_summary_edit
+                                               (ECalendarView *cal_view,
+                                                gboolean allow);
 
 G_END_DECLS
 
diff --git a/src/calendar/gui/e-day-view.c b/src/calendar/gui/e-day-view.c
index 63c0161..7dd7e88 100644
--- a/src/calendar/gui/e-day-view.c
+++ b/src/calendar/gui/e-day-view.c
@@ -4935,7 +4935,8 @@ e_day_view_on_top_canvas_button_release (GtkWidget *widget,
                e_day_view_finish_selection (day_view);
        } else if (day_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE) {
                e_day_view_finish_long_event_resize (day_view);
-       } else if (day_view->pressed_event_day != -1) {
+       } else if (day_view->pressed_event_day != -1 &&
+                  e_calendar_view_get_allow_direct_summary_edit (E_CALENDAR_VIEW (day_view))) {
                e_day_view_start_editing_event (
                        day_view,
                        day_view->pressed_event_day,
@@ -4971,7 +4972,8 @@ e_day_view_on_main_canvas_button_release (GtkWidget *widget,
        } else if (day_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE) {
                e_day_view_finish_resize (day_view);
                e_day_view_stop_auto_scroll (day_view);
-       } else if (day_view->pressed_event_day != -1) {
+       } else if (day_view->pressed_event_day != -1 &&
+                  e_calendar_view_get_allow_direct_summary_edit (E_CALENDAR_VIEW (day_view))) {
                e_day_view_start_editing_event (
                        day_view,
                        day_view->pressed_event_day,
@@ -6142,8 +6144,10 @@ e_day_view_reshape_day_events (EDayView *day_view,
                        continue;
                }
 
-               if (strncmp (current_comp_string, day_view->last_edited_comp_string,50) == 0) {
-                       e_canvas_item_grab_focus (event->canvas_item, TRUE);
+               if (strncmp (current_comp_string, day_view->last_edited_comp_string, 50) == 0) {
+                       if (e_calendar_view_get_allow_direct_summary_edit (E_CALENDAR_VIEW (day_view)))
+                               e_canvas_item_grab_focus (event->canvas_item, TRUE);
+
                        g_free (day_view->last_edited_comp_string);
                        day_view-> last_edited_comp_string = NULL;
                }
@@ -7208,7 +7212,8 @@ e_day_view_start_editing_event (EDayView *day_view,
        if (!is_comp_data_valid (event))
                return;
 
-       if (e_client_is_readonly (E_CLIENT (event->comp_data->client)))
+       if (e_client_is_readonly (E_CLIENT (event->comp_data->client)) ||
+           (!key_event && !e_calendar_view_get_allow_direct_summary_edit (E_CALENDAR_VIEW (day_view))))
                return;
 
        /* If the event is not shown, don't try to edit it. */
diff --git a/src/calendar/gui/e-week-view.c b/src/calendar/gui/e-week-view.c
index 04503d6..69f37a3 100644
--- a/src/calendar/gui/e-week-view.c
+++ b/src/calendar/gui/e-week-view.c
@@ -4051,7 +4051,8 @@ e_week_view_start_editing_event (EWeekView *week_view,
        span = &g_array_index (week_view->spans, EWeekViewEventSpan,
                               event->spans_index + span_num);
 
-       if (e_client_is_readonly (E_CLIENT (event->comp_data->client)))
+       if (e_client_is_readonly (E_CLIENT (event->comp_data->client)) ||
+           (!initial_text && !e_calendar_view_get_allow_direct_summary_edit (E_CALENDAR_VIEW (week_view))))
                return FALSE;
 
        /* If the event is not shown, don't try to edit it. */
diff --git a/src/modules/calendar/e-calendar-preferences.c b/src/modules/calendar/e-calendar-preferences.c
index 3f40929..fbf3ac2 100644
--- a/src/modules/calendar/e-calendar-preferences.c
+++ b/src/modules/calendar/e-calendar-preferences.c
@@ -994,6 +994,12 @@ calendar_preferences_construct (ECalendarPreferences *prefs,
                widget, "active",
                G_SETTINGS_BIND_DEFAULT);
 
+       widget = e_builder_get_widget (prefs->priv->builder, "allow_direct_summary_edit");
+       g_settings_bind (
+               settings, "allow-direct-summary-edit",
+               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 cbaabc4..00b5435 100644
--- a/src/modules/calendar/e-calendar-preferences.ui
+++ b/src/modules/calendar/e-calendar-preferences.ui
@@ -1001,6 +1001,21 @@
                     <property name="position">7</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkCheckButton" id="allow_direct_summary_edit">
+                    <property name="label" translatable="yes">Allo_w direct edit of event Summary</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">8</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 4084467..614ed27 100644
--- a/src/modules/settings/e-settings-calendar-view.c
+++ b/src/modules/settings/e-settings-calendar-view.c
@@ -52,6 +52,11 @@ settings_calendar_view_constructed (GObject *object)
                extensible, "time-divisions",
                G_SETTINGS_BIND_DEFAULT);
 
+       g_settings_bind (
+               settings, "allow-direct-summary-edit",
+               extensible, "allow-direct-summary-edit",
+               G_SETTINGS_BIND_DEFAULT);
+
        /*** EDayView ***/
 
        if (E_IS_DAY_VIEW (extensible)) {


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