aboutsummaryrefslogtreecommitdiffstats
path: root/modules/calendar/e-memo-shell-sidebar.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/calendar/e-memo-shell-sidebar.c')
-rw-r--r--modules/calendar/e-memo-shell-sidebar.c161
1 files changed, 79 insertions, 82 deletions
diff --git a/modules/calendar/e-memo-shell-sidebar.c b/modules/calendar/e-memo-shell-sidebar.c
index e9c40a44b4..a55218172f 100644
--- a/modules/calendar/e-memo-shell-sidebar.c
+++ b/modules/calendar/e-memo-shell-sidebar.c
@@ -386,6 +386,78 @@ memo_shell_sidebar_primary_selection_changed_cb (EMemoShellSidebar *memo_shell_s
}
static void
+memo_shell_sidebar_restore_state_cb (EShellWindow *shell_window,
+ EShellView *shell_view,
+ EShellSidebar *shell_sidebar)
+{
+ EMemoShellSidebarPrivate *priv;
+ EShell *shell;
+ EShellBackend *shell_backend;
+ EShellSettings *shell_settings;
+ ESourceSelector *selector;
+ ESourceList *source_list;
+ ESource *source;
+ GtkTreeModel *model;
+ GSList *list, *iter;
+ gchar *uid;
+
+ priv = E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (shell_sidebar);
+
+ shell = e_shell_window_get_shell (shell_window);
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ shell_backend = e_shell_view_get_shell_backend (shell_view);
+ g_return_if_fail (E_IS_MEMO_SHELL_BACKEND (shell_backend));
+
+ selector = E_SOURCE_SELECTOR (priv->selector);
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (selector));
+
+ source_list = e_memo_shell_backend_get_source_list (
+ E_MEMO_SHELL_BACKEND (shell_backend));
+
+ g_signal_connect_swapped (
+ model, "row-changed",
+ G_CALLBACK (memo_shell_sidebar_row_changed_cb),
+ shell_sidebar);
+
+ g_signal_connect_swapped (
+ selector, "primary-selection-changed",
+ G_CALLBACK (memo_shell_sidebar_primary_selection_changed_cb),
+ shell_sidebar);
+
+ source = NULL;
+ uid = e_shell_settings_get_string (
+ shell_settings, "cal-primary-memo-list");
+ if (uid != NULL)
+ source = e_source_list_peek_source_by_uid (source_list, uid);
+ if (source == NULL)
+ source = e_source_list_peek_source_any (source_list);
+ if (source != NULL)
+ e_source_selector_set_primary_selection (selector, source);
+ g_free (uid);
+
+ list = calendar_config_get_memos_selected ();
+ for (iter = list; iter != NULL; iter = iter->next) {
+ uid = iter->data;
+ source = e_source_list_peek_source_by_uid (source_list, uid);
+ g_free (uid);
+
+ if (source == NULL)
+ continue;
+
+ e_source_selector_select_source (selector, source);
+ }
+ g_slist_free (list);
+
+ /* Listen for subsequent changes to the selector. */
+
+ g_signal_connect_swapped (
+ selector, "selection-changed",
+ G_CALLBACK (memo_shell_sidebar_selection_changed_cb),
+ shell_sidebar);
+}
+
+static void
memo_shell_sidebar_get_property (GObject *object,
guint property_id,
GValue *value,
@@ -451,6 +523,7 @@ memo_shell_sidebar_constructed (GObject *object)
{
EMemoShellSidebarPrivate *priv;
EShellView *shell_view;
+ EShellWindow *shell_window;
EShellBackend *shell_backend;
EShellSidebar *shell_sidebar;
ESourceList *source_list;
@@ -466,6 +539,7 @@ memo_shell_sidebar_constructed (GObject *object)
shell_sidebar = E_SHELL_SIDEBAR (object);
shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
shell_backend = e_shell_view_get_shell_backend (shell_view);
+ shell_window = e_shell_view_get_shell_window (shell_view);
source_list = e_memo_shell_backend_get_source_list (
E_MEMO_SHELL_BACKEND (shell_backend));
@@ -490,86 +564,13 @@ memo_shell_sidebar_constructed (GObject *object)
atk_object_set_name (a11y, _("Memo List Selector"));
priv->selector = g_object_ref (widget);
gtk_widget_show (widget);
-}
-static void
-memo_shell_sidebar_realize (GtkWidget *widget)
-{
- EMemoShellSidebarPrivate *priv;
- EShell *shell;
- EShellView *shell_view;
- EShellBackend *shell_backend;
- EShellSidebar *shell_sidebar;
- EShellSettings *shell_settings;
- ESourceSelector *selector;
- ESourceList *source_list;
- ESource *source;
- GtkTreeModel *model;
- GSList *list, *iter;
- gchar *uid;
-
- priv = E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (widget);
-
- /* Restore the selector state from the last session. We do this
- * in realize() instead of constructed() so the shell view has a
- * chance to connect handlers to our signals. */
-
- shell_sidebar = E_SHELL_SIDEBAR (widget);
- shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
- shell_backend = e_shell_view_get_shell_backend (shell_view);
-
- shell = e_shell_backend_get_shell (shell_backend);
- shell_settings = e_shell_get_shell_settings (shell);
-
- selector = E_SOURCE_SELECTOR (priv->selector);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (selector));
-
- source_list = e_memo_shell_backend_get_source_list (
- E_MEMO_SHELL_BACKEND (shell_backend));
-
- g_signal_connect_swapped (
- model, "row-changed",
- G_CALLBACK (memo_shell_sidebar_row_changed_cb),
+ /* Restore widget state from the last session once
+ * the shell view is fully initialized and visible. */
+ g_signal_connect (
+ shell_window, "shell-view-created::memos",
+ G_CALLBACK (memo_shell_sidebar_restore_state_cb),
shell_sidebar);
-
- g_signal_connect_swapped (
- selector, "primary-selection-changed",
- G_CALLBACK (memo_shell_sidebar_primary_selection_changed_cb),
- shell_sidebar);
-
- source = NULL;
- uid = e_shell_settings_get_string (
- shell_settings, "cal-primary-memo-list");
- if (uid != NULL)
- source = e_source_list_peek_source_by_uid (source_list, uid);
- if (source == NULL)
- source = e_source_list_peek_source_any (source_list);
- if (source != NULL)
- e_source_selector_set_primary_selection (selector, source);
- g_free (uid);
-
- list = calendar_config_get_memos_selected ();
- for (iter = list; iter != NULL; iter = iter->next) {
- uid = iter->data;
- source = e_source_list_peek_source_by_uid (source_list, uid);
- g_free (uid);
-
- if (source == NULL)
- continue;
-
- e_source_selector_select_source (selector, source);
- }
- g_slist_free (list);
-
- /* Listen for subsequent changes to the selector. */
-
- g_signal_connect_swapped (
- selector, "selection-changed",
- G_CALLBACK (memo_shell_sidebar_selection_changed_cb),
- shell_sidebar);
-
- /* Chain up to parent's realize() method. */
- GTK_WIDGET_CLASS (parent_class)->realize (widget);
}
static guint32
@@ -647,7 +648,6 @@ static void
memo_shell_sidebar_class_init (EMemoShellSidebarClass *class)
{
GObjectClass *object_class;
- GtkWidgetClass *widget_class;
EShellSidebarClass *shell_sidebar_class;
parent_class = g_type_class_peek_parent (class);
@@ -659,9 +659,6 @@ memo_shell_sidebar_class_init (EMemoShellSidebarClass *class)
object_class->finalize = memo_shell_sidebar_finalize;
object_class->constructed = memo_shell_sidebar_constructed;
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->realize = memo_shell_sidebar_realize;
-
shell_sidebar_class = E_SHELL_SIDEBAR_CLASS (class);
shell_sidebar_class->check_state = memo_shell_sidebar_check_state;