aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/e-shell-view.c32
-rw-r--r--shell/e-shell-view.h2
-rw-r--r--shell/e-shell-window.c9
3 files changed, 32 insertions, 11 deletions
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index e307847116..3ab67b6ab0 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -136,13 +136,6 @@ shell_view_set_action (EShellView *shell_view,
}
static void
-shell_view_set_page_num (EShellView *shell_view,
- gint page_num)
-{
- shell_view->priv->page_num = page_num;
-}
-
-static void
shell_view_set_shell_window (EShellView *shell_view,
GtkWidget *shell_window)
{
@@ -169,7 +162,7 @@ shell_view_set_property (GObject *object,
return;
case PROP_PAGE_NUM:
- shell_view_set_page_num (
+ e_shell_view_set_page_num (
E_SHELL_VIEW (object),
g_value_get_int (value));
return;
@@ -406,8 +399,7 @@ shell_view_class_init (EShellViewClass *class)
-1,
G_MAXINT,
-1,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
+ G_PARAM_READWRITE));
/**
* EShellView:title
@@ -814,6 +806,26 @@ e_shell_view_get_page_num (EShellView *shell_view)
}
/**
+ * e_shell_view_set_page_num:
+ * @shell_view: an #EShellView
+ * @page_num: a notebook page number
+ *
+ * This function is only interesting to #EShellWindow. It sets the
+ * #GtkNotebook page number for @shell_view. The rest of the application
+ * must never call this because it could mess up shell view switching.
+ **/
+void
+e_shell_view_set_page_num (EShellView *shell_view,
+ gint page_num)
+{
+ g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+
+ shell_view->priv->page_num = page_num;
+
+ g_object_notify (G_OBJECT (shell_view), "page-num");
+}
+
+/**
* e_shell_view_get_size_group:
* @shell_view: an #EShellView
*
diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h
index 28392d2963..1b1fffd87d 100644
--- a/shell/e-shell-view.h
+++ b/shell/e-shell-view.h
@@ -162,6 +162,8 @@ void e_shell_view_set_view_id (EShellView *shell_view,
const gchar *view_id);
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,
+ gint page_num);
GtkSizeGroup * e_shell_view_get_size_group (EShellView *shell_view);
EShellContent * e_shell_view_get_shell_content (EShellView *shell_view);
EShellSidebar * e_shell_view_get_shell_sidebar (EShellView *shell_view);
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index 467e59d6cd..d1cebe78e1 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -52,7 +52,6 @@ shell_window_new_view (EShellWindow *shell_window,
/* Determine the page number for the new shell view. */
notebook = GTK_NOTEBOOK (shell_window->priv->content_notebook);
- page_num = gtk_notebook_get_n_pages (notebook);
/* Get the switcher action for this view. */
action = e_shell_window_get_shell_view_action (
@@ -64,11 +63,19 @@ shell_window_new_view (EShellWindow *shell_window,
page_num, "shell-window", shell_window, NULL);
/* Register the shell view. */
+ g_debug ("Loaded view '%s' (page %d)", view_name, page_num);
loaded_views = shell_window->priv->loaded_views;
g_hash_table_insert (loaded_views, g_strdup (view_name), shell_view);
/* Add pages to the various shell window notebooks. */
+ /* We can't determine the shell view's page number until after the
+ * shell view is fully initialized because the shell view may load
+ * other shell views during initialization, and those other shell
+ * views will append their widgets to the notebooks before us. */
+ page_num = gtk_notebook_get_n_pages (notebook);
+ e_shell_view_set_page_num (shell_view, page_num);
+
notebook = GTK_NOTEBOOK (shell_window->priv->content_notebook);
widget = GTK_WIDGET (e_shell_view_get_shell_content (shell_view));
gtk_notebook_append_page (notebook, widget, NULL);