[evolution] Allow select the same source and destination calendar in Copy To Calendar



commit 26edb3f580a8942fad8e7bbca6f67bcb78357eb3
Author: Milan Crha <mcrha redhat com>
Date:   Thu Jun 8 09:58:53 2017 +0200

    Allow select the same source and destination calendar in Copy To Calendar
    
    This way one can "duplicate" an event in the calendar. Move To Calendar
    still requires the source and the destination calendars being different.

 src/calendar/gui/comp-util.c                    |    8 +++++++-
 src/calendar/gui/e-cal-ops.c                    |    4 ++--
 src/modules/calendar/e-cal-shell-view-actions.c |    2 +-
 3 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/src/calendar/gui/comp-util.c b/src/calendar/gui/comp-util.c
index dfbfd5d..e72e1d2 100644
--- a/src/calendar/gui/comp-util.c
+++ b/src/calendar/gui/comp-util.c
@@ -1088,6 +1088,7 @@ cal_comp_transfer_item_to_sync (ECalClient *src_client,
        struct ForeachTzidData ftd;
        ECalClientSourceType source_type;
        GHashTable *processed_uids;
+       gboolean same_client;
        gboolean success = FALSE;
 
        g_return_val_if_fail (E_IS_CAL_CLIENT (src_client), FALSE);
@@ -1112,6 +1113,8 @@ cal_comp_transfer_item_to_sync (ECalClient *src_client,
                        g_return_val_if_reached (FALSE);
        }
 
+       same_client = src_client == dest_client || e_source_equal (
+               e_client_get_source (E_CLIENT (src_client)), e_client_get_source (E_CLIENT (dest_client)));
        processed_uids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
 
        icalcomp_event = icalcomponent_get_first_component (icalcomp_vcal, icalcomp_kind);
@@ -1132,7 +1135,10 @@ cal_comp_transfer_item_to_sync (ECalClient *src_client,
                if (g_hash_table_lookup (processed_uids, uid))
                        continue;
 
-               success = e_cal_client_get_object_sync (dest_client, uid, NULL, &icalcomp, cancellable, 
&local_error);
+               if (do_copy && same_client)
+                       success = FALSE;
+               else
+                       success = e_cal_client_get_object_sync (dest_client, uid, NULL, &icalcomp, 
cancellable, &local_error);
                if (success) {
                        success = e_cal_client_modify_object_sync (
                                dest_client, icalcomp_event, E_CAL_OBJ_MOD_ALL, cancellable, error);
diff --git a/src/calendar/gui/e-cal-ops.c b/src/calendar/gui/e-cal-ops.c
index d0d5a0f..53edf5c 100644
--- a/src/calendar/gui/e-cal-ops.c
+++ b/src/calendar/gui/e-cal-ops.c
@@ -2039,7 +2039,7 @@ e_cal_ops_transfer_components (EShellView *shell_view,
                ESource *source = key;
                GSList *icalcomps = value;
 
-               if (!e_source_equal (source, destination))
+               if (!is_move || !e_source_equal (source, destination))
                        nobjects += g_slist_length (icalcomps);
        }
 
@@ -2086,7 +2086,7 @@ e_cal_ops_transfer_components (EShellView *shell_view,
                ESource *source = key;
                GSList *icalcomps = value;
 
-               if (!e_source_equal (source, destination)) {
+               if (!is_move || !e_source_equal (source, destination)) {
                        GSList *link;
 
                        icalcomps = g_slist_copy (icalcomps);
diff --git a/src/modules/calendar/e-cal-shell-view-actions.c b/src/modules/calendar/e-cal-shell-view-actions.c
index 634079e..0cbf934 100644
--- a/src/modules/calendar/e-cal-shell-view-actions.c
+++ b/src/modules/calendar/e-cal-shell-view-actions.c
@@ -538,7 +538,7 @@ cal_shell_view_transfer_selected (ECalShellView *cal_shell_view,
        selected = e_calendar_view_get_selected_events (calendar_view);
        g_return_if_fail (selected != NULL);
 
-       if (selected->data) {
+       if (selected->data && is_move) {
                ECalendarViewEvent *event = selected->data;
 
                if (is_comp_data_valid (event) && event->comp_data->client)


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