aboutsummaryrefslogtreecommitdiffstats
path: root/modules/calendar
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-06-11 03:21:10 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-06-11 03:47:13 +0800
commit4f7b4d81e757bfed1b42b888207a0fdf6fae8533 (patch)
tree5c159ca51db5488c7e8c8cf1ab55fd48953ecf3d /modules/calendar
parente51e1d6e4bbd6d33a841a87b15680c824adf8988 (diff)
downloadgsoc2013-evolution-4f7b4d81e757bfed1b42b888207a0fdf6fae8533.tar.gz
gsoc2013-evolution-4f7b4d81e757bfed1b42b888207a0fdf6fae8533.tar.zst
gsoc2013-evolution-4f7b4d81e757bfed1b42b888207a0fdf6fae8533.zip
Reimplement the main toolbar's "prefer-item" feature.
This fixes a bug in the old implementation where the application could crash after a second shell window was created and destroyed, because a signal handler with the destroyed shell window as the closure was left connected. But moreover this simplifies the implementation by using a property binding plus transform function instead of juggling signal handlers, and also adds code comments where things get a little tricky. Removed (now unused) functions: e_shell_window_get_toolbar_new_prefer_item e_shell_window_set_toolbar_new_prefer_item
Diffstat (limited to 'modules/calendar')
-rw-r--r--modules/calendar/e-cal-shell-backend.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/modules/calendar/e-cal-shell-backend.c b/modules/calendar/e-cal-shell-backend.c
index ab8ecd550f..6a9bc1aac8 100644
--- a/modules/calendar/e-cal-shell-backend.c
+++ b/modules/calendar/e-cal-shell-backend.c
@@ -215,6 +215,7 @@ action_event_new_cb (GtkAction *action,
* the view. */
shell_view = e_shell_window_peek_shell_view (shell_window, "calendar");
if (shell_view != NULL) {
+ EShellWindow *shell_window;
EShellContent *shell_content;
GnomeCalendar *gcal;
GnomeCalendarViewType view_type;
@@ -222,6 +223,16 @@ action_event_new_cb (GtkAction *action,
shell_backend = e_shell_view_get_shell_backend (shell_view);
shell_content = e_shell_view_get_shell_content (shell_view);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ e_shell_backend_set_prefer_new_item (
+ shell_backend, action_name);
+
+ /* This forces the shell window to update the "New" toolbar
+ * button menu, and the toolbar button will then update its
+ * button image to reflect the "preferred new item" we just
+ * set on the shell backend. */
+ g_object_notify (G_OBJECT (shell_window), "active-view");
gcal = e_cal_shell_content_get_calendar (
E_CAL_SHELL_CONTENT (shell_content));
@@ -229,11 +240,7 @@ action_event_new_cb (GtkAction *action,
view_type = gnome_calendar_get_view (gcal);
view = gnome_calendar_get_calendar_view (gcal, view_type);
- if (view) {
- g_object_set (
- G_OBJECT (shell_backend),
- "prefer-new-item", action_name, NULL);
-
+ if (view != NULL) {
e_calendar_view_new_appointment_full (
view,
g_str_equal (action_name, "event-all-day-new"),
@@ -250,7 +257,7 @@ action_event_new_cb (GtkAction *action,
source = e_source_registry_ref_default_calendar (registry);
shell_backend = e_shell_get_backend_by_name (shell, "calendar");
- g_object_set (G_OBJECT (shell_backend), "prefer-new-item", action_name, NULL);
+ e_shell_backend_set_prefer_new_item (shell_backend, action_name);
/* Use a callback function appropriate for the action. */
if (strcmp (action_name, "event-all-day-new") == 0)