From 935897c9a256e0d260adc1dd0dc56b1a5c760cd9 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 9 Sep 2008 02:53:40 +0000 Subject: Fix some bugs in the way the shell widgets get initialized. svn path=/branches/kill-bonobo/; revision=36279 --- shell/e-shell-content.c | 22 ++++++++++++++------- shell/e-shell-sidebar.c | 16 ++++++++++++--- shell/e-shell-view.c | 35 ++++++++++++++------------------ shell/e-shell-window-actions.c | 12 +++-------- shell/e-shell-window-private.h | 1 - shell/e-shell-window.c | 5 +++-- shell/main.c | 3 +-- shell/test/e-test-shell-view.c | 45 ++++++++++++++++-------------------------- 8 files changed, 67 insertions(+), 72 deletions(-) (limited to 'shell') diff --git a/shell/e-shell-content.c b/shell/e-shell-content.c index 7ee7711b7e..c1c175d692 100644 --- a/shell/e-shell-content.c +++ b/shell/e-shell-content.c @@ -194,7 +194,8 @@ shell_content_init_search_context (EShellContent *shell_content) rule_context_add_rule, rule_context_next_rule); rule_context_load (context, system_filename, user_filename); - /* XXX Not sure why this is necessary. */ + /* Ownership of the strings is passed to the rule context. + * XXX Not sure why this is necessary. */ g_object_set_data_full ( G_OBJECT (context), "system", system_filename, g_free); g_object_set_data_full ( @@ -210,9 +211,6 @@ shell_content_init_search_context (EShellContent *shell_content) else filter_rule_add_part (rule, filter_part_clone (part)); - g_free (system_filename); - g_free (user_filename); - shell_content->priv->search_context = context; } @@ -447,12 +445,22 @@ shell_content_dispose (GObject *object) } static void -shell_content_constructed (GObject *object) +shell_content_realize (GtkWidget *widget) { EShellContent *shell_content; - shell_content = E_SHELL_CONTENT (object); + /* We can't call this during object construction because the + * shell view is still in its instance initialization phase, + * and so its GET_CLASS() macro won't work correctly. So we + * delay the bits of our own initialization that require the + * E_SHELL_VIEW_GET_CLASS() macro until after the shell view + * is fully constructed. */ + + shell_content = E_SHELL_CONTENT (widget); shell_content_init_search_context (shell_content); + + /* Chain up to parent's realize() method. */ + GTK_WIDGET_CLASS (parent_class)->realize (widget); } static void @@ -561,9 +569,9 @@ shell_content_class_init (EShellContentClass *class) object_class->set_property = shell_content_set_property; object_class->get_property = shell_content_get_property; object_class->dispose = shell_content_dispose; - object_class->constructed = shell_content_constructed; widget_class = GTK_WIDGET_CLASS (class); + widget_class->realize = shell_content_realize; widget_class->size_request = shell_content_size_request; widget_class->size_allocate = shell_content_size_allocate; diff --git a/shell/e-shell-sidebar.c b/shell/e-shell-sidebar.c index 4a83b3462a..560c20c278 100644 --- a/shell/e-shell-sidebar.c +++ b/shell/e-shell-sidebar.c @@ -201,12 +201,22 @@ shell_sidebar_finalize (GObject *object) } static void -shell_sidebar_constructed (GObject *object) +shell_sidebar_realize (GtkWidget *widget) { EShellSidebar *shell_sidebar; - shell_sidebar = E_SHELL_SIDEBAR (object); + /* We can't call this during object construction because the + * shell view is still in its instance initialization phase, + * and so its GET_CLASS() macro won't work correctly. So we + * delay the bits of our own initialization that require the + * E_SHELL_VIEW_GET_CLASS() macro until after the shell view + * is fully constructed. */ + + shell_sidebar = E_SHELL_SIDEBAR (widget); shell_sidebar_init_icon_and_text (shell_sidebar); + + /* Chain up to parent's realize() method. */ + GTK_WIDGET_CLASS (parent_class)->realize (widget); } static void @@ -316,9 +326,9 @@ shell_sidebar_class_init (EShellSidebarClass *class) object_class->get_property = shell_sidebar_get_property; object_class->dispose = shell_sidebar_dispose; object_class->finalize = shell_sidebar_finalize; - object_class->constructed = shell_sidebar_constructed; widget_class = GTK_WIDGET_CLASS (class); + widget_class->realize = shell_sidebar_realize; widget_class->size_request = shell_sidebar_size_request; widget_class->size_allocate = shell_sidebar_size_allocate; diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index f069a33567..4b388e3c93 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -206,26 +206,6 @@ shell_view_finalize (GObject *object) static void shell_view_constructed (GObject *object) { - EShellView *shell_view; - GtkWidget *widget; - - shell_view = E_SHELL_VIEW (object); - - /* We do this AFTER instance initialization so the - * E_SHELL_VIEW_GET_CLASS() macro works properly. */ - - widget = e_shell_content_new (shell_view); - shell_view->priv->content = g_object_ref_sink (widget); - gtk_widget_show (widget); - - widget = e_shell_sidebar_new (shell_view); - shell_view->priv->sidebar = g_object_ref_sink (widget); - gtk_widget_show (widget); - - widget = e_shell_taskbar_new (shell_view); - shell_view->priv->taskbar = g_object_ref_sink (widget); - gtk_widget_show (widget); - /* XXX GObjectClass doesn't implement constructed(), so we will. * Then subclasses won't have to check the function pointer * before chaining up. @@ -306,7 +286,22 @@ shell_view_class_init (EShellViewClass *class) static void shell_view_init (EShellView *shell_view) { + GtkWidget *widget; + shell_view->priv = E_SHELL_VIEW_GET_PRIVATE (shell_view); + + widget = e_shell_content_new (shell_view); + shell_view->priv->content = g_object_ref_sink (widget); + gtk_widget_show (widget); + + widget = e_shell_sidebar_new (shell_view); + shell_view->priv->sidebar = g_object_ref_sink (widget); + gtk_widget_show (widget); + + widget = e_shell_taskbar_new (shell_view); + shell_view->priv->taskbar = g_object_ref_sink (widget); + gtk_widget_show (widget); + } GType diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c index aa14ec44eb..c785b9bc92 100644 --- a/shell/e-shell-window-actions.c +++ b/shell/e-shell-window-actions.c @@ -1716,21 +1716,15 @@ e_shell_window_create_shell_view_actions (EShellWindow *shell_window) list = gtk_action_group_list_actions (action_group); if (list != NULL) { - GObject *object = list->data; - const gchar *view_name; - - /* First view is the default. */ - view_name = g_object_get_data (object, "view-name"); - shell_window->priv->default_view = view_name; + GtkRadioAction *action = list->data; g_signal_connect ( - object, "changed", + action, "changed", G_CALLBACK (action_shell_view_cb), shell_window); /* Sync up with the current shell view. */ - gtk_radio_action_set_current_value ( - GTK_RADIO_ACTION (object), current_value); + gtk_radio_action_set_current_value (action, current_value); } g_list_free (list); diff --git a/shell/e-shell-window-private.h b/shell/e-shell-window-private.h index 161bb17e0b..ef4fa2a728 100644 --- a/shell/e-shell-window-private.h +++ b/shell/e-shell-window-private.h @@ -73,7 +73,6 @@ struct _EShellWindowPrivate { GHashTable *loaded_views; const gchar *current_view; - const gchar *default_view; /*** Widgetry ***/ diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index 218f4f599d..ce144da5fa 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -472,12 +472,13 @@ e_shell_window_set_current_view (EShellWindow *shell_window, g_return_if_fail (E_IS_SHELL_WINDOW (shell_window)); view_name = name_or_alias; + list = e_shell_registry_list_modules (); if (view_name != NULL) view_name = e_shell_registry_get_canonical_name (view_name); - if (view_name == NULL) - view_name = shell_window->priv->default_view; + if (view_name == NULL && list != NULL) + view_name = G_TYPE_MODULE (list->data)->name; g_return_if_fail (view_name != NULL); diff --git a/shell/main.c b/shell/main.c index 1ed06c611a..4b7c3cce3d 100644 --- a/shell/main.c +++ b/shell/main.c @@ -302,8 +302,7 @@ idle_cb (gchar **uris) client = gconf_client_get_default (); key = "/apps/evolution/shell/view_defaults/component_id"; - requested_view = gconf_client_set_string ( - client, key, initial_view, NULL); + gconf_client_set_string (client, key, initial_view, NULL); g_object_unref (client); } diff --git a/shell/test/e-test-shell-view.c b/shell/test/e-test-shell-view.c index be2a747354..ea771e0982 100644 --- a/shell/test/e-test-shell-view.c +++ b/shell/test/e-test-shell-view.c @@ -42,43 +42,15 @@ test_shell_view_changed (EShellView *shell_view) g_debug ("%s (%s)", G_STRFUNC, selected); } -static void -test_shell_view_constructed (GObject *object) -{ - EShellContent *shell_content; - EShellSidebar *shell_sidebar; - EShellView *shell_view; - GtkWidget *widget; - - /* Chain up to parent's constructed() method. */ - G_OBJECT_CLASS (parent_class)->constructed (object); - - shell_view = E_SHELL_VIEW (object); - shell_content = e_shell_view_get_content (shell_view); - shell_sidebar = e_shell_view_get_sidebar (shell_view); - - widget = gtk_label_new ("Content Widget"); - gtk_container_add (GTK_CONTAINER (shell_content), widget); - gtk_widget_show (widget); - - widget = gtk_label_new ("Sidebar Widget"); - gtk_container_add (GTK_CONTAINER (shell_sidebar), widget); - gtk_widget_show (widget); -} - static void test_shell_view_class_init (ETestShellViewClass *class, GTypeModule *type_module) { - GObjectClass *object_class; EShellViewClass *shell_view_class; parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (ETestShellViewPrivate)); - object_class = G_OBJECT_CLASS (class); - object_class->constructed = test_shell_view_constructed; - shell_view_class = E_SHELL_VIEW_CLASS (class); shell_view_class->label = "Test"; shell_view_class->icon_name = "face-monkey"; @@ -89,8 +61,25 @@ test_shell_view_class_init (ETestShellViewClass *class, static void test_shell_view_init (ETestShellView *test_shell_view) { + EShellContent *shell_content; + EShellSidebar *shell_sidebar; + EShellView *shell_view; + GtkWidget *widget; + test_shell_view->priv = E_TEST_SHELL_VIEW_GET_PRIVATE (test_shell_view); + + shell_view = E_SHELL_VIEW (test_shell_view); + shell_content = e_shell_view_get_content (shell_view); + shell_sidebar = e_shell_view_get_sidebar (shell_view); + + widget = gtk_label_new ("Content Widget"); + gtk_container_add (GTK_CONTAINER (shell_content), widget); + gtk_widget_show (widget); + + widget = gtk_label_new ("Sidebar Widget"); + gtk_container_add (GTK_CONTAINER (shell_sidebar), widget); + gtk_widget_show (widget); } GType -- cgit v1.2.3