[evolution] Calendar: Default to event move on drag&drop in Week/Month/Year views



commit c82def9186896db6d305bf0944c26a4f1b487bf9
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jun 15 13:10:29 2022 +0200

    Calendar: Default to event move on drag&drop in Week/Month/Year views
    
    Instead of copy event by default, do rather move it. It can be copied
    by holding the Ctrl key.
    
    Related to https://gitlab.gnome.org/GNOME/evolution/-/issues/1306

 src/calendar/gui/e-week-view.c | 13 +++++++++++--
 src/calendar/gui/e-year-view.c | 13 +++++++++++--
 2 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/src/calendar/gui/e-week-view.c b/src/calendar/gui/e-week-view.c
index a26276ba0f..261422e363 100644
--- a/src/calendar/gui/e-week-view.c
+++ b/src/calendar/gui/e-week-view.c
@@ -1712,6 +1712,7 @@ e_week_view_drag_motion_cb (GtkWidget *widget,
                            gpointer user_data)
 {
        EWeekView *self = user_data;
+       GdkDragAction drag_action = GDK_ACTION_MOVE;
        gint day;
        gboolean can_drop;
 
@@ -1720,8 +1721,16 @@ e_week_view_drag_motion_cb (GtkWidget *widget,
                self->priv->drag_event_num > -1 &&
                self->priv->drag_from_day != day;
 
-       gdk_drag_status (context,
-               can_drop ? gdk_drag_context_get_selected_action (context) : 0, time);
+       if (can_drop) {
+               GdkModifierType mask;
+
+               gdk_window_get_pointer (gtk_widget_get_window (widget), NULL, NULL, &mask);
+
+               if ((mask & GDK_CONTROL_MASK) != 0)
+                       drag_action = GDK_ACTION_COPY;
+       }
+
+       gdk_drag_status (context, can_drop ? drag_action : 0, time);
 
        return TRUE;
 }
diff --git a/src/calendar/gui/e-year-view.c b/src/calendar/gui/e-year-view.c
index a55c51e476..0c787e243a 100644
--- a/src/calendar/gui/e-year-view.c
+++ b/src/calendar/gui/e-year-view.c
@@ -1428,6 +1428,7 @@ year_view_month_drag_motion_cb (GtkWidget *widget,
        EYearView *self = user_data;
        guint day, year = 0;
        GDateMonth month = 0;
+       GdkDragAction drag_action = GDK_ACTION_MOVE;
        gboolean can_drop;
 
        day = e_month_widget_get_day_at_position (E_MONTH_WIDGET (widget), x, y);
@@ -1450,8 +1451,16 @@ year_view_month_drag_motion_cb (GtkWidget *widget,
                }
        }
 
-       gdk_drag_status (context,
-               can_drop ? gdk_drag_context_get_selected_action (context) : 0, time);
+       if (can_drop) {
+               GdkModifierType mask;
+
+               gdk_window_get_pointer (gtk_widget_get_window (widget), NULL, NULL, &mask);
+
+               if ((mask & GDK_CONTROL_MASK) != 0)
+                       drag_action = GDK_ACTION_COPY;
+       }
+
+       gdk_drag_status (context, can_drop ? drag_action : 0, time);
 
        return TRUE;
 }


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