[evolution/gnome-3-20] Create new events in the selected calendar in the left tree of calendars



commit 8ab1eda8eb6d709600fab2a606c95542e01cdd02
Author: Milan Crha <mcrha redhat com>
Date:   Tue Jun 14 12:49:52 2016 +0200

    Create new events in the selected calendar in the left tree of calendars
    
    There used to be used the default source, which is not that nice as being
    able to change it just by changed selection in the left tree of the calendars
    (the source selector). Similar applies for tasks and memos.

 calendar/gui/e-cal-ops.c                |    4 ++--
 modules/calendar/e-memo-shell-backend.c |   18 +++++++++++++++++-
 modules/calendar/e-task-shell-backend.c |   18 +++++++++++++++++-
 3 files changed, 36 insertions(+), 4 deletions(-)
---
diff --git a/calendar/gui/e-cal-ops.c b/calendar/gui/e-cal-ops.c
index 8d497dd..b66acf2 100644
--- a/calendar/gui/e-cal-ops.c
+++ b/calendar/gui/e-cal-ops.c
@@ -1504,7 +1504,7 @@ new_component_data_free (gpointer ptr)
                        }
 
                        comp_editor = e_comp_editor_open_for_component (NULL, ncd->shell,
-                               ncd->is_new_component ? NULL : e_client_get_source (E_CLIENT (ncd->client)),
+                               ncd->client ? e_client_get_source (E_CLIENT (ncd->client)) : NULL,
                                e_cal_component_get_icalcomponent (ncd->comp), flags);
 
                        if (comp_editor) {
@@ -1813,7 +1813,7 @@ e_cal_ops_new_component_editor_from_model (ECalModel *model,
        if (!for_client_uid)
                for_client_uid = e_cal_model_get_default_source_uid (model);
 
-       if (for_client_uid && !for_client_uid)
+       if (for_client_uid && !*for_client_uid)
                for_client_uid = NULL;
 
        e_cal_ops_new_component_ex (NULL, model, source_type, for_client_uid, is_assigned, all_day, dtstart, 
dtend,
diff --git a/modules/calendar/e-memo-shell-backend.c b/modules/calendar/e-memo-shell-backend.c
index 0a4d752..cea61fb 100644
--- a/modules/calendar/e-memo-shell-backend.c
+++ b/modules/calendar/e-memo-shell-backend.c
@@ -27,6 +27,7 @@
 #include <calendar/gui/e-cal-ops.h>
 
 #include "e-cal-base-shell-backend.h"
+#include "e-cal-base-shell-sidebar.h"
 #include "e-memo-shell-view.h"
 #include "e-memo-shell-backend.h"
 
@@ -44,9 +45,24 @@ static void
 action_memo_new_cb (GtkAction *action,
                     EShellWindow *shell_window)
 {
+       EShellView *shell_view;
+       ESource *selected_source = NULL;
+
+       shell_view = e_shell_window_peek_shell_view (shell_window, "memos");
+       if (shell_view != NULL) {
+               EShellSidebar *shell_sidebar;
+               ESourceSelector *selector;
+
+               shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
+               selector = e_cal_base_shell_sidebar_get_selector (E_CAL_BASE_SHELL_SIDEBAR (shell_sidebar));
+               selected_source = e_source_selector_ref_primary_selection (selector);
+       }
+
        e_cal_ops_new_component_editor (shell_window,
-               E_CAL_CLIENT_SOURCE_TYPE_MEMOS, NULL,
+               E_CAL_CLIENT_SOURCE_TYPE_MEMOS, selected_source ? e_source_get_uid (selected_source) : NULL,
                g_strcmp0 (gtk_action_get_name (action), "memo-shared-new") == 0);
+
+       g_clear_object (&selected_source);
 }
 
 static void
diff --git a/modules/calendar/e-task-shell-backend.c b/modules/calendar/e-task-shell-backend.c
index 068f9f3..43ccaec 100644
--- a/modules/calendar/e-task-shell-backend.c
+++ b/modules/calendar/e-task-shell-backend.c
@@ -25,6 +25,7 @@
 #include <calendar/gui/comp-util.h>
 #include <calendar/gui/e-cal-ops.h>
 
+#include "e-cal-base-shell-sidebar.h"
 #include "e-task-shell-view.h"
 #include "e-task-shell-backend.h"
 
@@ -42,9 +43,24 @@ static void
 action_task_new_cb (GtkAction *action,
                     EShellWindow *shell_window)
 {
+       EShellView *shell_view;
+       ESource *selected_source = NULL;
+
+       shell_view = e_shell_window_peek_shell_view (shell_window, "tasks");
+       if (shell_view != NULL) {
+               EShellSidebar *shell_sidebar;
+               ESourceSelector *selector;
+
+               shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
+               selector = e_cal_base_shell_sidebar_get_selector (E_CAL_BASE_SHELL_SIDEBAR (shell_sidebar));
+               selected_source = e_source_selector_ref_primary_selection (selector);
+       }
+
        e_cal_ops_new_component_editor (shell_window,
-               E_CAL_CLIENT_SOURCE_TYPE_TASKS, NULL,
+               E_CAL_CLIENT_SOURCE_TYPE_TASKS, selected_source ? e_source_get_uid (selected_source) : NULL,
                g_strcmp0 (gtk_action_get_name (action), "task-assigned-new") == 0);
+
+       g_clear_object (&selected_source);
 }
 
 static void


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