[gnome-calendar] event-widget: don't DnD read-only events



commit 08fcf33a28a57203f83545fa7dd51f34c42900f4
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Sep 14 14:10:13 2016 -0300

    event-widget: don't DnD read-only events
    
    Read-only events can't be moved, so don't allow it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=771116

 src/gcal-event-widget.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/src/gcal-event-widget.c b/src/gcal-event-widget.c
index 794a278..31ef63c 100644
--- a/src/gcal-event-widget.c
+++ b/src/gcal-event-widget.c
@@ -620,9 +620,15 @@ gcal_event_widget_drag_begin (GtkWidget      *widget,
 {
   GcalEventWidget *self = GCAL_EVENT_WIDGET (widget);
 
-  /* Setup the drag n' drop icon */
   g_clear_object (&self->dnd_pixbuf);
 
+  if (self->read_only)
+    {
+      gtk_drag_cancel (context);
+      return;
+    }
+
+  /* Setup the drag n' drop icon */
   self->dnd_pixbuf = gdk_pixbuf_get_from_window (self->event_window,
                                                  0,
                                                  0,
@@ -728,6 +734,20 @@ gcal_event_widget_set_read_only (GcalEventWidget *event,
 {
   g_return_if_fail (GCAL_IS_EVENT_WIDGET (event));
 
+  if (read_only)
+    {
+      GtkWidget *widget = GTK_WIDGET (event);
+
+      /* Setup the event widget as a drag source */
+      gtk_drag_source_set (widget,
+                           0,
+                           NULL,
+                           0,
+                           GDK_ACTION_COPY);
+
+      gtk_drag_source_add_text_targets (widget);
+    }
+
   event->read_only = read_only;
 }
 


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