From 31b5261fdbe2c98e7f4f71e908e5d9b58609de94 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 4 Jul 2013 11:04:51 -0400 Subject: EShellView: Add a "view-instance" property. EShellView now holds a reference to the active GalViewInstance. Where applicable, the EShellView subclass is responsible for keeping this up to date when the sidebar selection changes. Holding a reference allows EShellView to implement common actions like "Save Current View" directly instead pushing it on to subclasses. New functions: e_shell_view_get_view_instance e_shell_view_set_view_instance --- modules/calendar/e-cal-shell-content.c | 29 ++++++++++------------------ modules/calendar/e-cal-shell-content.h | 3 --- modules/calendar/e-cal-shell-view-actions.c | 24 ----------------------- modules/calendar/e-cal-shell-view-private.c | 9 +++------ modules/calendar/e-memo-shell-content.c | 20 ++----------------- modules/calendar/e-memo-shell-content.h | 3 --- modules/calendar/e-memo-shell-view-actions.c | 24 ----------------------- modules/calendar/e-memo-shell-view-private.c | 9 +++------ modules/calendar/e-task-shell-content.c | 20 ++----------------- modules/calendar/e-task-shell-content.h | 3 --- modules/calendar/e-task-shell-view-actions.c | 24 ----------------------- modules/calendar/e-task-shell-view-private.c | 9 +++------ 12 files changed, 23 insertions(+), 154 deletions(-) (limited to 'modules/calendar') diff --git a/modules/calendar/e-cal-shell-content.c b/modules/calendar/e-cal-shell-content.c index 38724aca3e..5c91354d51 100644 --- a/modules/calendar/e-cal-shell-content.c +++ b/modules/calendar/e-cal-shell-content.c @@ -50,8 +50,6 @@ struct _ECalShellContentPrivate { GtkWidget *calendar; GtkWidget *task_table; GtkWidget *memo_table; - - GalViewInstance *view_instance; }; enum { @@ -291,11 +289,6 @@ cal_shell_content_dispose (GObject *object) priv->memo_table = NULL; } - if (priv->view_instance != NULL) { - g_object_unref (priv->view_instance); - priv->view_instance = NULL; - } - /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (e_cal_shell_content_parent_class)->dispose (object); } @@ -520,7 +513,8 @@ cal_shell_content_constructed (GObject *object) object); /* XXX Actually, don't load the view instance just yet. * The GtkWidget::map() callback below explains why. */ - priv->view_instance = view_instance; + e_shell_view_set_view_instance (shell_view, view_instance); + g_object_unref (view_instance); g_signal_connect_swapped ( shell_view, "notify::view-id", @@ -545,7 +539,13 @@ cal_shell_content_constructed (GObject *object) static void cal_shell_content_map (GtkWidget *widget) { - ECalShellContentPrivate *priv; + EShellView *shell_view; + EShellContent *shell_content; + GalViewInstance *view_instance; + + shell_content = E_SHELL_CONTENT (widget); + shell_view = e_shell_content_get_shell_view (shell_content); + view_instance = e_shell_view_get_view_instance (shell_view); /* XXX Delay loading the GalViewInstance until after ECalShellView * has a chance to install the sidebar's date navigator into @@ -553,8 +553,7 @@ cal_shell_content_map (GtkWidget *widget) * callback in GnomeCalendar that requires the date navigator. * Ordinarily we would do this at the end of constructed(), but * that's too soon in this case. (This feels kind of kludgy.) */ - priv = E_CAL_SHELL_CONTENT_GET_PRIVATE (widget); - gal_view_instance_load (priv->view_instance); + gal_view_instance_load (view_instance); /* Chain up to parent's map() method. */ GTK_WIDGET_CLASS (e_cal_shell_content_parent_class)->map (widget); @@ -932,11 +931,3 @@ e_cal_shell_content_get_searchbar (ECalShellContent *cal_shell_content) return E_SHELL_SEARCHBAR (widget); } -GalViewInstance * -e_cal_shell_content_get_view_instance (ECalShellContent *cal_shell_content) -{ - g_return_val_if_fail ( - E_IS_CAL_SHELL_CONTENT (cal_shell_content), NULL); - - return cal_shell_content->priv->view_instance; -} diff --git a/modules/calendar/e-cal-shell-content.h b/modules/calendar/e-cal-shell-content.h index 45aedf90c2..b42d099cb6 100644 --- a/modules/calendar/e-cal-shell-content.h +++ b/modules/calendar/e-cal-shell-content.h @@ -90,9 +90,6 @@ ETaskTable * e_cal_shell_content_get_task_table EShellSearchbar * e_cal_shell_content_get_searchbar (ECalShellContent *cal_shell_content); -GalViewInstance * - e_cal_shell_content_get_view_instance - (ECalShellContent *cal_shell_content); void e_cal_shell_content_save_state (ECalShellContent *cal_shell_content); diff --git a/modules/calendar/e-cal-shell-view-actions.c b/modules/calendar/e-cal-shell-view-actions.c index 9a54b0603f..b59a3f3ef4 100644 --- a/modules/calendar/e-cal-shell-view-actions.c +++ b/modules/calendar/e-cal-shell-view-actions.c @@ -1345,26 +1345,6 @@ action_event_schedule_appointment_cb (GtkAction *action, edit_event_as (cal_shell_view, FALSE); } -static void -action_gal_save_custom_view_cb (GtkAction *action, - ECalShellView *cal_shell_view) -{ - ECalShellContent *cal_shell_content; - EShellView *shell_view; - GalViewInstance *view_instance; - - /* All shell views respond to the activation of this action, - * which is defined by EShellWindow. But only the currently - * active shell view proceeds with saving the custom view. */ - shell_view = E_SHELL_VIEW (cal_shell_view); - if (!e_shell_view_is_active (shell_view)) - return; - - cal_shell_content = cal_shell_view->priv->cal_shell_content; - view_instance = e_cal_shell_content_get_view_instance (cal_shell_content); - gal_view_instance_save_as (view_instance); -} - static GtkActionEntry calendar_entries[] = { { "calendar-copy", @@ -1938,10 +1918,6 @@ e_cal_shell_view_actions_init (ECalShellView *cal_shell_view) action = ACTION (CALENDAR_VIEW_WORKWEEK); gtk_action_set_is_important (action, TRUE); - g_signal_connect ( - ACTION (GAL_SAVE_CUSTOM_VIEW), "activate", - G_CALLBACK (action_gal_save_custom_view_cb), cal_shell_view); - /* Initialize the memo and task pad actions. */ e_cal_shell_view_memopad_actions_init (cal_shell_view); e_cal_shell_view_taskpad_actions_init (cal_shell_view); diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c index c8ace44255..7b0c6c472b 100644 --- a/modules/calendar/e-cal-shell-view-private.c +++ b/modules/calendar/e-cal-shell-view-private.c @@ -460,16 +460,13 @@ cal_shell_view_load_view_collection (EShellViewClass *shell_view_class) } static void -cal_shell_view_notify_view_id_cb (ECalShellView *cal_shell_view) +cal_shell_view_notify_view_id_cb (EShellView *shell_view) { - ECalShellContent *cal_shell_content; GalViewInstance *view_instance; const gchar *view_id; - cal_shell_content = cal_shell_view->priv->cal_shell_content; - view_instance = - e_cal_shell_content_get_view_instance (cal_shell_content); - view_id = e_shell_view_get_view_id (E_SHELL_VIEW (cal_shell_view)); + view_id = e_shell_view_get_view_id (shell_view); + view_instance = e_shell_view_get_view_instance (shell_view); /* A NULL view ID implies we're in a custom view. But you can * only get to a custom view via the "Define Views" dialog, which diff --git a/modules/calendar/e-memo-shell-content.c b/modules/calendar/e-memo-shell-content.c index 3df2c424ee..ec97019f65 100644 --- a/modules/calendar/e-memo-shell-content.c +++ b/modules/calendar/e-memo-shell-content.c @@ -44,7 +44,6 @@ struct _EMemoShellContentPrivate { GtkWidget *preview_pane; ECalModel *memo_model; - GalViewInstance *view_instance; GtkOrientation orientation; gchar *current_uid; @@ -401,11 +400,6 @@ memo_shell_content_dispose (GObject *object) priv->memo_model = NULL; } - if (priv->view_instance != NULL) { - g_object_unref (priv->view_instance); - priv->view_instance = NULL; - } - /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (e_memo_shell_content_parent_class)->dispose (object); } @@ -553,11 +547,9 @@ memo_shell_content_constructed (GObject *object) view_instance, "display-view", G_CALLBACK (memo_shell_content_display_view_cb), object); - priv->view_instance = view_instance; - - /* Do this last so e_memo_shell_content_get_view_instance() returns - * the correct instance in GalViewInstance::loaded signal handlers. */ + e_shell_view_set_view_instance (shell_view, view_instance); gal_view_instance_load (view_instance); + g_object_unref (view_instance); /* Restore pane positions from the last session once * the shell view is fully initialized and visible. */ @@ -771,11 +763,3 @@ e_memo_shell_content_get_searchbar (EMemoShellContent *memo_shell_content) return E_SHELL_SEARCHBAR (widget); } -GalViewInstance * -e_memo_shell_content_get_view_instance (EMemoShellContent *memo_shell_content) -{ - g_return_val_if_fail ( - E_IS_MEMO_SHELL_CONTENT (memo_shell_content), NULL); - - return memo_shell_content->priv->view_instance; -} diff --git a/modules/calendar/e-memo-shell-content.h b/modules/calendar/e-memo-shell-content.h index 03a7fdc2eb..29b6985c4c 100644 --- a/modules/calendar/e-memo-shell-content.h +++ b/modules/calendar/e-memo-shell-content.h @@ -88,9 +88,6 @@ void e_memo_shell_content_set_preview_visible EShellSearchbar * e_memo_shell_content_get_searchbar (EMemoShellContent *memo_shell_content); -GalViewInstance * - e_memo_shell_content_get_view_instance - (EMemoShellContent *memo_shell_content); G_END_DECLS diff --git a/modules/calendar/e-memo-shell-view-actions.c b/modules/calendar/e-memo-shell-view-actions.c index f0c16bb99a..29dd68df9c 100644 --- a/modules/calendar/e-memo-shell-view-actions.c +++ b/modules/calendar/e-memo-shell-view-actions.c @@ -25,26 +25,6 @@ #include "e-memo-shell-view-private.h" -static void -action_gal_save_custom_view_cb (GtkAction *action, - EMemoShellView *memo_shell_view) -{ - EMemoShellContent *memo_shell_content; - EShellView *shell_view; - GalViewInstance *view_instance; - - /* All shell views respond to the activation of this action, - * which is defined by EShellWindow. But only the currently - * active shell view proceeds with saving the custom view. */ - shell_view = E_SHELL_VIEW (memo_shell_view); - if (!e_shell_view_is_active (shell_view)) - return; - - memo_shell_content = memo_shell_view->priv->memo_shell_content; - view_instance = e_memo_shell_content_get_view_instance (memo_shell_content); - gal_view_instance_save_as (view_instance); -} - static void action_memo_delete_cb (GtkAction *action, EMemoShellView *memo_shell_view) @@ -961,10 +941,6 @@ e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view) /* Fine tuning. */ - g_signal_connect ( - ACTION (GAL_SAVE_CUSTOM_VIEW), "activate", - G_CALLBACK (action_gal_save_custom_view_cb), memo_shell_view); - g_object_bind_property ( ACTION (MEMO_PREVIEW), "active", ACTION (MEMO_VIEW_CLASSIC), "sensitive", diff --git a/modules/calendar/e-memo-shell-view-private.c b/modules/calendar/e-memo-shell-view-private.c index e83685548f..78d636027a 100644 --- a/modules/calendar/e-memo-shell-view-private.c +++ b/modules/calendar/e-memo-shell-view-private.c @@ -154,16 +154,13 @@ memo_shell_view_load_view_collection (EShellViewClass *shell_view_class) } static void -memo_shell_view_notify_view_id_cb (EMemoShellView *memo_shell_view) +memo_shell_view_notify_view_id_cb (EShellView *shell_view) { - EMemoShellContent *memo_shell_content; GalViewInstance *view_instance; const gchar *view_id; - memo_shell_content = memo_shell_view->priv->memo_shell_content; - view_instance = - e_memo_shell_content_get_view_instance (memo_shell_content); - view_id = e_shell_view_get_view_id (E_SHELL_VIEW (memo_shell_view)); + view_id = e_shell_view_get_view_id (shell_view); + view_instance = e_shell_view_get_view_instance (shell_view); /* A NULL view ID implies we're in a custom view. But you can * only get to a custom view via the "Define Views" dialog, which diff --git a/modules/calendar/e-task-shell-content.c b/modules/calendar/e-task-shell-content.c index c4fa849609..33c65081c4 100644 --- a/modules/calendar/e-task-shell-content.c +++ b/modules/calendar/e-task-shell-content.c @@ -43,7 +43,6 @@ struct _ETaskShellContentPrivate { GtkWidget *preview_pane; ECalModel *task_model; - GalViewInstance *view_instance; GtkOrientation orientation; gchar *current_uid; @@ -400,11 +399,6 @@ task_shell_content_dispose (GObject *object) priv->task_model = NULL; } - if (priv->view_instance != NULL) { - g_object_unref (priv->view_instance); - priv->view_instance = NULL; - } - /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (e_task_shell_content_parent_class)->dispose (object); } @@ -552,11 +546,9 @@ task_shell_content_constructed (GObject *object) view_instance, "display-view", G_CALLBACK (task_shell_content_display_view_cb), object); - priv->view_instance = view_instance; - - /* Do this last so e_task_shell_content_get_view_instance() returns - * the correct instance in GalViewInstance::loaded signal handlers. */ + e_shell_view_set_view_instance (shell_view, view_instance); gal_view_instance_load (view_instance); + g_object_unref (view_instance); /* Restore pane positions from the last session once * the shell view is fully initialized and visible. */ @@ -795,11 +787,3 @@ e_task_shell_content_get_searchbar (ETaskShellContent *task_shell_content) return E_SHELL_SEARCHBAR (widget); } -GalViewInstance * -e_task_shell_content_get_view_instance (ETaskShellContent *task_shell_content) -{ - g_return_val_if_fail ( - E_IS_TASK_SHELL_CONTENT (task_shell_content), NULL); - - return task_shell_content->priv->view_instance; -} diff --git a/modules/calendar/e-task-shell-content.h b/modules/calendar/e-task-shell-content.h index 778dbde875..7f5fac68b1 100644 --- a/modules/calendar/e-task-shell-content.h +++ b/modules/calendar/e-task-shell-content.h @@ -92,9 +92,6 @@ void e_task_shell_content_set_preview_visible EShellSearchbar * e_task_shell_content_get_searchbar (ETaskShellContent *task_shell_content); -GalViewInstance * - e_task_shell_content_get_view_instance - (ETaskShellContent *task_shell_content); G_END_DECLS diff --git a/modules/calendar/e-task-shell-view-actions.c b/modules/calendar/e-task-shell-view-actions.c index 5102def69b..fe0dd051b2 100644 --- a/modules/calendar/e-task-shell-view-actions.c +++ b/modules/calendar/e-task-shell-view-actions.c @@ -25,26 +25,6 @@ #include "e-task-shell-view-private.h" -static void -action_gal_save_custom_view_cb (GtkAction *action, - ETaskShellView *task_shell_view) -{ - ETaskShellContent *task_shell_content; - EShellView *shell_view; - GalViewInstance *view_instance; - - /* All shell views respond to the activation of this action, - * which is defined by EShellWindow. But only the currently - * active shell view proceeds with saving the custom view. */ - shell_view = E_SHELL_VIEW (task_shell_view); - if (!e_shell_view_is_active (shell_view)) - return; - - task_shell_content = task_shell_view->priv->task_shell_content; - view_instance = e_task_shell_content_get_view_instance (task_shell_content); - gal_view_instance_save_as (view_instance); -} - static void action_task_assign_cb (GtkAction *action, ETaskShellView *task_shell_view) @@ -1160,10 +1140,6 @@ e_task_shell_view_actions_init (ETaskShellView *task_shell_view) /* Fine tuning. */ - g_signal_connect ( - ACTION (GAL_SAVE_CUSTOM_VIEW), "activate", - G_CALLBACK (action_gal_save_custom_view_cb), task_shell_view); - g_object_bind_property ( ACTION (TASK_PREVIEW), "active", ACTION (TASK_VIEW_CLASSIC), "sensitive", diff --git a/modules/calendar/e-task-shell-view-private.c b/modules/calendar/e-task-shell-view-private.c index 5cba0571b7..fa70b5bcae 100644 --- a/modules/calendar/e-task-shell-view-private.c +++ b/modules/calendar/e-task-shell-view-private.c @@ -219,16 +219,13 @@ task_shell_view_load_view_collection (EShellViewClass *shell_view_class) } static void -task_shell_view_notify_view_id_cb (ETaskShellView *task_shell_view) +task_shell_view_notify_view_id_cb (EShellView *shell_view) { - ETaskShellContent *task_shell_content; GalViewInstance *view_instance; const gchar *view_id; - task_shell_content = task_shell_view->priv->task_shell_content; - view_instance = - e_task_shell_content_get_view_instance (task_shell_content); - view_id = e_shell_view_get_view_id (E_SHELL_VIEW (task_shell_view)); + view_id = e_shell_view_get_view_id (shell_view); + view_instance = e_shell_view_get_view_instance (shell_view); /* A NULL view ID implies we're in a custom view. But you can * only get to a custom view via the "Define Views" dialog, which -- cgit v1.2.3