aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-07-04 23:04:51 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-07-06 04:40:48 +0800
commit31b5261fdbe2c98e7f4f71e908e5d9b58609de94 (patch)
treee9157fa12b3978c68492b04c10137c74eee21b17
parent7d6027be1a9989549c80fdbe6dcf8317c54a6a6a (diff)
downloadgsoc2013-evolution-31b5261fdbe2c98e7f4f71e908e5d9b58609de94.tar.gz
gsoc2013-evolution-31b5261fdbe2c98e7f4f71e908e5d9b58609de94.tar.zst
gsoc2013-evolution-31b5261fdbe2c98e7f4f71e908e5d9b58609de94.zip
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
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c11
-rw-r--r--doc/reference/evolution-shell/evolution-shell-sections.txt4
-rw-r--r--mail/e-mail-paned-view.c19
-rw-r--r--modules/addressbook/e-book-shell-view-actions.c26
-rw-r--r--modules/calendar/e-cal-shell-content.c29
-rw-r--r--modules/calendar/e-cal-shell-content.h3
-rw-r--r--modules/calendar/e-cal-shell-view-actions.c24
-rw-r--r--modules/calendar/e-cal-shell-view-private.c9
-rw-r--r--modules/calendar/e-memo-shell-content.c20
-rw-r--r--modules/calendar/e-memo-shell-content.h3
-rw-r--r--modules/calendar/e-memo-shell-view-actions.c24
-rw-r--r--modules/calendar/e-memo-shell-view-private.c9
-rw-r--r--modules/calendar/e-task-shell-content.c20
-rw-r--r--modules/calendar/e-task-shell-content.h3
-rw-r--r--modules/calendar/e-task-shell-view-actions.c24
-rw-r--r--modules/calendar/e-task-shell-view-private.c9
-rw-r--r--modules/mail/e-mail-shell-view-actions.c27
-rw-r--r--shell/e-shell-view.c188
-rw-r--r--shell/e-shell-view.h10
-rw-r--r--shell/e-shell-window-actions.c16
20 files changed, 221 insertions, 257 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index 763ff87268..3d13a54e14 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -392,9 +392,11 @@ addressbook_view_create_minicard_view (EAddressbookView *view,
}
static void
-addressbook_view_display_view_cb (EAddressbookView *view,
- GalView *gal_view)
+addressbook_view_display_view_cb (GalViewInstance *view_instance,
+ GalView *gal_view,
+ EAddressbookView *view)
{
+ EShellView *shell_view;
GtkWidget *child;
child = gtk_bin_get_child (GTK_BIN (view));
@@ -409,6 +411,9 @@ addressbook_view_display_view_cb (EAddressbookView *view,
addressbook_view_create_minicard_view (
view, GAL_VIEW_MINICARD (gal_view));
+ shell_view = e_addressbook_view_get_shell_view (view);
+ e_shell_view_set_view_instance (shell_view, view_instance);
+
command_state_change (view);
}
@@ -592,7 +597,7 @@ addressbook_view_constructed (GObject *object)
view->priv->model = e_addressbook_model_new (client_cache);
view_instance = e_shell_view_new_view_instance (shell_view, uid);
- g_signal_connect_swapped (
+ g_signal_connect (
view_instance, "display-view",
G_CALLBACK (addressbook_view_display_view_cb), view);
view->priv->view_instance = view_instance;
diff --git a/doc/reference/evolution-shell/evolution-shell-sections.txt b/doc/reference/evolution-shell/evolution-shell-sections.txt
index 8986adc8d6..a72821924c 100644
--- a/doc/reference/evolution-shell/evolution-shell-sections.txt
+++ b/doc/reference/evolution-shell/evolution-shell-sections.txt
@@ -226,6 +226,9 @@ e_shell_view_get_title
e_shell_view_set_title
e_shell_view_get_view_id
e_shell_view_set_view_id
+e_shell_view_new_view_instance
+e_shell_view_get_view_instance
+e_shell_view_set_view_instance
e_shell_view_is_active
e_shell_view_get_page_num
e_shell_view_set_page_num
@@ -250,7 +253,6 @@ e_shell_view_unblock_execute_search
e_shell_view_is_execute_search_blocked
e_shell_view_update_actions
e_shell_view_show_popup_menu
-e_shell_view_new_view_instance
e_shell_view_write_source
e_shell_view_remove_source
e_shell_view_remote_delete_source
diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c
index 41c98f0e23..e0c63992c8 100644
--- a/mail/e-mail-paned-view.c
+++ b/mail/e-mail-paned-view.c
@@ -246,12 +246,17 @@ mail_paned_view_restore_state_cb (EShellWindow *shell_window,
}
static void
-mail_paned_display_view_cb (EMailView *view,
- GalView *gal_view)
+mail_paned_display_view_cb (GalViewInstance *view_instance,
+ GalView *gal_view,
+ EMailView *view)
{
EMailReader *reader;
+ EShellView *shell_view;
GtkWidget *message_list;
+ shell_view = e_mail_view_get_shell_view (view);
+ e_shell_view_set_view_instance (shell_view, view_instance);
+
reader = E_MAIL_READER (view);
message_list = e_mail_reader_get_message_list (reader);
@@ -868,7 +873,7 @@ mail_paned_view_update_view_instance (EMailView *view)
shell_view, view_id);
}
- priv->view_instance = view_instance;
+ priv->view_instance = g_object_ref (view_instance);
orientable = GTK_ORIENTABLE (view);
orientation = gtk_orientable_get_orientation (orientable);
@@ -961,12 +966,16 @@ mail_paned_view_update_view_instance (EMailView *view)
g_free (state_filename);
}
- g_signal_connect_swapped (
+ g_signal_connect (
view_instance, "display-view",
G_CALLBACK (mail_paned_display_view_cb), view);
mail_paned_display_view_cb (
- view, gal_view_instance_get_current_view (view_instance));
+ view_instance,
+ gal_view_instance_get_current_view (view_instance),
+ view);
+
+ g_object_unref (view_instance);
g_clear_object (&folder);
}
diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c
index 9d72ef377c..fe43821eaf 100644
--- a/modules/addressbook/e-book-shell-view-actions.c
+++ b/modules/addressbook/e-book-shell-view-actions.c
@@ -870,28 +870,6 @@ action_contact_view_cb (GtkRadioAction *action,
gtk_orientable_set_orientation (orientable, orientation);
}
-static void
-action_gal_save_custom_view_cb (GtkAction *action,
- EBookShellView *book_shell_view)
-{
- EBookShellContent *book_shell_content;
- EShellView *shell_view;
- EAddressbookView *address_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 (book_shell_view);
- if (!e_shell_view_is_active (shell_view))
- return;
-
- book_shell_content = book_shell_view->priv->book_shell_content;
- address_view = e_book_shell_content_get_current_view (book_shell_content);
- view_instance = e_addressbook_view_get_view_instance (address_view);
- gal_view_instance_save_as (view_instance);
-}
-
static GtkActionEntry contact_entries[] = {
{ "address-book-copy",
@@ -1325,10 +1303,6 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view)
/* Fine tuning. */
- g_signal_connect (
- ACTION (GAL_SAVE_CUSTOM_VIEW), "activate",
- G_CALLBACK (action_gal_save_custom_view_cb), book_shell_view);
-
g_object_bind_property (
ACTION (CONTACT_PREVIEW), "active",
ACTION (CONTACT_VIEW_CLASSIC), "sensitive",
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
@@ -26,26 +26,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
@@ -26,26 +26,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
diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c
index c8bec966d2..e451574ecf 100644
--- a/modules/mail/e-mail-shell-view-actions.c
+++ b/modules/mail/e-mail-shell-view-actions.c
@@ -26,29 +26,6 @@
#include "e-mail-shell-view-private.h"
static void
-action_gal_save_custom_view_cb (GtkAction *action,
- EMailShellView *mail_shell_view)
-{
- EMailShellContent *mail_shell_content;
- EShellView *shell_view;
- EMailView *mail_view;
- GalViewInstance *view_instance;
-
- /* All shell views repond 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 (mail_shell_view);
- if (!e_shell_view_is_active (shell_view))
- return;
-
- mail_shell_content = mail_shell_view->priv->mail_shell_content;
- mail_view = e_mail_shell_content_get_mail_view (mail_shell_content);
- view_instance = e_mail_view_get_view_instance (mail_view);
-
- gal_view_instance_save_as (view_instance);
-}
-
-static void
action_mail_account_disable_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
@@ -2225,10 +2202,6 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view)
shell, "online",
ACTION (MAIL_DOWNLOAD), "sensitive",
G_BINDING_SYNC_CREATE);
-
- g_signal_connect (
- ACTION (GAL_SAVE_CUSTOM_VIEW), "activate",
- G_CALLBACK (action_gal_save_custom_view_cb), mail_shell_view);
}
/* Helper for e_mail_shell_view_update_popup_labels() */
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index 1f979e6ccb..efdebc8b8c 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -53,6 +53,10 @@ struct _EShellViewPrivate {
gpointer state_save_activity; /* weak pointer */
guint state_save_timeout_id;
+ GalViewInstance *view_instance;
+ gulong view_instance_changed_handler_id;
+ gulong view_instance_loaded_handler_id;
+
gchar *title;
gchar *view_id;
gint page_num;
@@ -85,7 +89,8 @@ enum {
PROP_SHELL_WINDOW,
PROP_STATE_KEY_FILE,
PROP_TITLE,
- PROP_VIEW_ID
+ PROP_VIEW_ID,
+ PROP_VIEW_INSTANCE
};
enum {
@@ -404,6 +409,12 @@ shell_view_set_property (GObject *object,
E_SHELL_VIEW (object),
g_value_get_string (value));
return;
+
+ case PROP_VIEW_INSTANCE:
+ e_shell_view_set_view_instance (
+ E_SHELL_VIEW (object),
+ g_value_get_object (value));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -486,6 +497,12 @@ shell_view_get_property (GObject *object,
value, e_shell_view_get_view_id (
E_SHELL_VIEW (object)));
return;
+
+ case PROP_VIEW_INSTANCE:
+ g_value_set_object (
+ value, e_shell_view_get_view_instance (
+ E_SHELL_VIEW (object)));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -513,6 +530,20 @@ shell_view_dispose (GObject *object)
priv->state_save_activity = NULL;
}
+ if (priv->view_instance_changed_handler_id > 0) {
+ g_signal_handler_disconnect (
+ priv->view_instance,
+ priv->view_instance_changed_handler_id);
+ priv->view_instance_changed_handler_id = 0;
+ }
+
+ if (priv->view_instance_loaded_handler_id > 0) {
+ g_signal_handler_disconnect (
+ priv->view_instance,
+ priv->view_instance_loaded_handler_id);
+ priv->view_instance_loaded_handler_id = 0;
+ }
+
if (priv->preferences_window != NULL) {
g_signal_handler_disconnect (
priv->preferences_window,
@@ -526,6 +557,7 @@ shell_view_dispose (GObject *object)
priv->shell_window = NULL;
}
+ g_clear_object (&priv->view_instance);
g_clear_object (&priv->shell_content);
g_clear_object (&priv->shell_sidebar);
g_clear_object (&priv->shell_taskbar);
@@ -923,6 +955,21 @@ e_shell_view_class_init (EShellViewClass *class)
G_PARAM_STATIC_STRINGS));
/**
+ * EShellView:view-instance:
+ *
+ * The current #GalViewInstance.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_VIEW_INSTANCE,
+ g_param_spec_object (
+ "view-instance",
+ "View Instance",
+ "The current view instance",
+ GAL_TYPE_VIEW_INSTANCE,
+ G_PARAM_READWRITE));
+
+ /**
* EShellView::toggled
* @shell_view: the #EShellView which emitted the signal
*
@@ -1214,6 +1261,109 @@ e_shell_view_set_view_id (EShellView *shell_view,
}
/**
+ * e_shell_view_new_view_instance:
+ * @shell_view: an #EShellView
+ * @instance_id: a name for the #GalViewInstance
+ *
+ * Convenience function creates a new #GalViewInstance from the
+ * #GalViewCollection in @shell_view's #EShellViewClass.
+ *
+ * Returns: a new #GalViewInstance
+ **/
+GalViewInstance *
+e_shell_view_new_view_instance (EShellView *shell_view,
+ const gchar *instance_id)
+{
+ EShellViewClass *class;
+ GalViewCollection *view_collection;
+
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ class = E_SHELL_VIEW_GET_CLASS (shell_view);
+
+ view_collection = class->view_collection;
+
+ return gal_view_instance_new (view_collection, instance_id);
+}
+
+/**
+ * e_shell_view_get_view_instance:
+ * @shell_view: an #EShellView
+ *
+ * Returns the current #GalViewInstance for @shell_view.
+ *
+ * #EShellView subclasses are responsible for creating and configuring a
+ * #GalViewInstance and handing it off so the @shell_view can monitor it
+ * and perform common actions on it.
+ *
+ * Returns: a #GalViewInstance, or %NULL
+ **/
+GalViewInstance *
+e_shell_view_get_view_instance (EShellView *shell_view)
+{
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ return shell_view->priv->view_instance;
+}
+
+/**
+ * e_shell_view_set_view_instance:
+ * @shell_view: an #EShellView
+ * @view_instance: a #GalViewInstance, or %NULL
+ *
+ * Sets the current #GalViewInstance for @shell_view.
+ *
+ * #EShellView subclasses are responsible for creating and configuring a
+ * #GalViewInstance and handing it off so the @shell_view can monitor it
+ * and perform common actions on it.
+ **/
+void
+e_shell_view_set_view_instance (EShellView *shell_view,
+ GalViewInstance *view_instance)
+{
+ g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+
+ if (view_instance != NULL) {
+ g_return_if_fail (GAL_IS_VIEW_INSTANCE (view_instance));
+ g_object_ref (view_instance);
+ }
+
+ if (shell_view->priv->view_instance_changed_handler_id > 0) {
+ g_signal_handler_disconnect (
+ shell_view->priv->view_instance,
+ shell_view->priv->view_instance_changed_handler_id);
+ shell_view->priv->view_instance_changed_handler_id = 0;
+ }
+
+ if (shell_view->priv->view_instance_loaded_handler_id > 0) {
+ g_signal_handler_disconnect (
+ shell_view->priv->view_instance,
+ shell_view->priv->view_instance_loaded_handler_id);
+ shell_view->priv->view_instance_loaded_handler_id = 0;
+ }
+
+ g_clear_object (&shell_view->priv->view_instance);
+
+ shell_view->priv->view_instance = view_instance;
+
+ if (view_instance != NULL) {
+ gulong handler_id;
+
+ handler_id = g_signal_connect_swapped (
+ view_instance, "changed",
+ G_CALLBACK (shell_view_update_view_id), shell_view);
+ shell_view->priv->view_instance_changed_handler_id = handler_id;
+
+ handler_id = g_signal_connect_swapped (
+ view_instance, "loaded",
+ G_CALLBACK (shell_view_update_view_id), shell_view);
+ shell_view->priv->view_instance_loaded_handler_id = handler_id;
+ }
+
+ g_object_notify (G_OBJECT (shell_view), "view-instance");
+}
+
+/**
* e_shell_view_get_shell_window:
* @shell_view: an #EShellView
*
@@ -1734,42 +1884,6 @@ e_shell_view_show_popup_menu (EShellView *shell_view,
}
/**
- * e_shell_view_new_view_instance:
- * @shell_view: an #EShellView
- * @instance_id: a name for the #GalViewInstance
- *
- * Creates a new #GalViewInstance and configures it to keep
- * @shell_view<!-- -->'s #EShellView:view-id property up-to-date.
- *
- * Returns: a new #GalViewInstance
- **/
-GalViewInstance *
-e_shell_view_new_view_instance (EShellView *shell_view,
- const gchar *instance_id)
-{
- EShellViewClass *class;
- GalViewCollection *view_collection;
- GalViewInstance *view_instance;
-
- g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
-
- class = E_SHELL_VIEW_GET_CLASS (shell_view);
-
- view_collection = class->view_collection;
- view_instance = gal_view_instance_new (view_collection, instance_id);
-
- g_signal_connect_swapped (
- view_instance, "changed",
- G_CALLBACK (shell_view_update_view_id), shell_view);
-
- g_signal_connect_swapped (
- view_instance, "loaded",
- G_CALLBACK (shell_view_update_view_id), shell_view);
-
- return view_instance;
-}
-
-/**
* e_shell_view_write_source:
* @shell_view: an #EShellView
* @source: an #ESource
diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h
index 5351e7226c..db51c31ca8 100644
--- a/shell/e-shell-view.h
+++ b/shell/e-shell-view.h
@@ -198,6 +198,13 @@ void e_shell_view_set_title (EShellView *shell_view,
const gchar * e_shell_view_get_view_id (EShellView *shell_view);
void e_shell_view_set_view_id (EShellView *shell_view,
const gchar *view_id);
+GalViewInstance *
+ e_shell_view_new_view_instance (EShellView *shell_view,
+ const gchar *instance_id);
+GalViewInstance *
+ e_shell_view_get_view_instance (EShellView *shell_view);
+void e_shell_view_set_view_instance (EShellView *shell_view,
+ GalViewInstance *view_instance);
gboolean e_shell_view_is_active (EShellView *shell_view);
gint e_shell_view_get_page_num (EShellView *shell_view);
void e_shell_view_set_page_num (EShellView *shell_view,
@@ -230,9 +237,6 @@ void e_shell_view_update_actions (EShellView *shell_view);
GtkWidget * e_shell_view_show_popup_menu (EShellView *shell_view,
const gchar *widget_path,
GdkEvent *button_event);
-GalViewInstance *
- e_shell_view_new_view_instance (EShellView *shell_view,
- const gchar *instance_id);
void e_shell_view_write_source (EShellView *shell_view,
ESource *source);
void e_shell_view_remove_source (EShellView *shell_view,
diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c
index 3dcaa73585..8dffb10399 100644
--- a/shell/e-shell-window-actions.c
+++ b/shell/e-shell-window-actions.c
@@ -231,6 +231,20 @@ action_gal_view_cb (GtkRadioAction *action,
*
* Main menu item: View -> Current View -> Save Custom View...
**/
+static void
+action_gal_save_custom_view_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ EShellView *shell_view;
+ GalViewInstance *view_instance;
+ const gchar *view_name;
+
+ view_name = e_shell_window_get_active_view (shell_window);
+ shell_view = e_shell_window_get_shell_view (shell_window, view_name);
+ view_instance = e_shell_view_get_view_instance (shell_view);
+
+ gal_view_instance_save_as (view_instance);
+}
/**
* E_SHELL_WINDOW_ACTION_IMPORT:
@@ -1181,7 +1195,7 @@ static GtkActionEntry shell_gal_view_entries[] = {
N_("Save Custom View..."),
NULL,
N_("Save current custom view"),
- NULL }, /* Handled by subclasses. */
+ G_CALLBACK (action_gal_save_custom_view_cb) },
/*** Menus ***/