[gnome-calendar] views: ask for recurrence when dropping recurrent events



commit be9da0cbda5310348ff0f7cfca14725005d36349
Author: Yash Singh <yashdev10p gmail com>
Date:   Wed Jun 14 01:55:42 2017 +0530

    views: ask for recurrence when dropping recurrent events
    
    While dragging and dropping a recurrent event, pop
    up the recurrence-dialog to allow the user to choose
    the set of events to which the changes should be
    applied.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=782755

 src/views/gcal-month-view.c |   13 ++++++++++++-
 src/views/gcal-week-grid.c  |   15 ++++++++++++++-
 src/views/gcal-year-view.c  |   14 +++++++++++++-
 3 files changed, 39 insertions(+), 3 deletions(-)
---
diff --git a/src/views/gcal-month-view.c b/src/views/gcal-month-view.c
index 19ba55d..d8c0073 100644
--- a/src/views/gcal-month-view.c
+++ b/src/views/gcal-month-view.c
@@ -778,6 +778,8 @@ gcal_month_view_drag_drop (GtkWidget      *widget,
   GtkWidget *event_widget;
   GDateTime *start_dt, *end_dt, *current_dt;
   GcalEvent *event;
+  ECalObjModType mod;
+  ESource *source;
   gint cell, diff;
   gint start_month, current_month;
   gint start_year, current_year;
@@ -785,11 +787,19 @@ gcal_month_view_drag_drop (GtkWidget      *widget,
 
   cell = get_dnd_cell (widget, x, y);
   event_widget = gtk_drag_get_source_widget (context);
+  mod = E_CAL_OBJ_MOD_THIS;
 
   if (!GCAL_IS_EVENT_WIDGET (event_widget))
     return FALSE;
 
   event = gcal_event_widget_get_event (GCAL_EVENT_WIDGET (event_widget));
+  source = gcal_event_get_source (event);
+
+  if (gcal_event_has_recurrence (event) &&
+      !ask_recurrence_modification_type (widget, &mod, source))
+    {
+      goto out;
+    }
 
   /* Move the event's date */
   start_dt = gcal_event_get_date_start (event);
@@ -831,7 +841,7 @@ gcal_month_view_drag_drop (GtkWidget      *widget,
           g_clear_pointer (&new_end, g_date_time_unref);
         }
 
-      gcal_manager_update_event (self->manager, event, E_CAL_OBJ_MOD_THIS);
+      gcal_manager_update_event (self->manager, event, mod);
 
       g_clear_pointer (&new_start, g_date_time_unref);
 
@@ -840,6 +850,7 @@ gcal_month_view_drag_drop (GtkWidget      *widget,
 
   g_clear_pointer (&start_dt, g_date_time_unref);
 
+out:
   /* Cancel the DnD */
   self->dnd_cell = -1;
   gtk_drag_unhighlight (widget);
diff --git a/src/views/gcal-week-grid.c b/src/views/gcal-week-grid.c
index a6d2ca2..be4182f 100644
--- a/src/views/gcal-week-grid.c
+++ b/src/views/gcal-week-grid.c
@@ -956,7 +956,9 @@ gcal_week_grid_drag_drop (GtkWidget      *widget,
   g_autoptr (GDateTime) dnd_date;
   g_autoptr (GDateTime) new_end;
   GtkWidget *event_widget;
+  ECalObjModType mod;
   GcalEvent *event;
+  ESource *source;
   GTimeSpan timespan = 0;
   gboolean ltr;
   gint drop_cell;
@@ -966,6 +968,7 @@ gcal_week_grid_drag_drop (GtkWidget      *widget,
   drop_cell = get_dnd_cell (widget, x, y);
   event_widget = gtk_drag_get_source_widget (context);
 
+  mod = E_CAL_OBJ_MOD_THIS;
   week_start = NULL;
   dnd_date = NULL;
   new_end = NULL;
@@ -985,6 +988,14 @@ gcal_week_grid_drag_drop (GtkWidget      *widget,
     }
 
   event = gcal_event_widget_get_event (GCAL_EVENT_WIDGET (event_widget));
+  source = gcal_event_get_source (event);
+
+  if (gcal_event_has_recurrence (event) &&
+      !ask_recurrence_modification_type (widget, &mod, source))
+    {
+      goto out;
+    }
+
   week_start = get_start_of_week (self->active_date);
   dnd_date = g_date_time_add_minutes (week_start, drop_cell * 30);
 
@@ -1007,8 +1018,10 @@ gcal_week_grid_drag_drop (GtkWidget      *widget,
   gcal_event_set_date_end (event, new_end);
 
   /* Commit the changes */
-  gcal_manager_update_event (self->manager, event, E_CAL_OBJ_MOD_THIS);
 
+  gcal_manager_update_event (self->manager, event, mod);
+
+out:
   /* Cancel the DnD */
   self->dnd_cell = -1;
   gtk_drag_unhighlight (widget);
diff --git a/src/views/gcal-year-view.c b/src/views/gcal-year-view.c
index e15814a..218c773 100644
--- a/src/views/gcal-year-view.c
+++ b/src/views/gcal-year-view.c
@@ -1488,12 +1488,23 @@ navigator_drag_drop_cb (GcalYearView   *self,
       if (!is_title)
         {
           GcalEventWidget *event_widget;
+          ECalObjModType mod;
           GcalEvent *event;
           GDateTime *start_dt, *end_dt;
           GDateTime *drop_date;
+          ESource *source;
 
           event_widget = GCAL_EVENT_WIDGET (gtk_drag_get_source_widget (context));
           event = gcal_event_widget_get_event (event_widget);
+          source = gcal_event_get_source (event);
+          mod = E_CAL_OBJ_MOD_THIS;
+
+          if (gcal_event_has_recurrence (event) &&
+              !ask_recurrence_modification_type (GTK_WIDGET (self), &mod, source))
+            {
+              goto out;
+            }
+
           start_dt = gcal_event_get_date_start (event);
           end_dt = gcal_event_get_date_end (event);
 
@@ -1522,7 +1533,7 @@ navigator_drag_drop_cb (GcalYearView   *self,
                   g_clear_pointer (&new_end, g_date_time_unref);
                 }
 
-              gcal_manager_update_event (self->manager, event, E_CAL_OBJ_MOD_THIS);
+              gcal_manager_update_event (self->manager, event, mod);
 
               g_clear_pointer (&new_start, g_date_time_unref);
             }
@@ -1531,6 +1542,7 @@ navigator_drag_drop_cb (GcalYearView   *self,
         }
     }
 
+out:
   /* Cancel the DnD after the event is dropped */
   self->selected_data->dnd_day = -1;
   self->selected_data->dnd_month = -1;


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