evolution r36279 - in branches/kill-bonobo: addressbook/gui/component shell shell/test



Author: mbarnes
Date: Tue Sep  9 02:53:40 2008
New Revision: 36279
URL: http://svn.gnome.org/viewvc/evolution?rev=36279&view=rev

Log:
Fix some bugs in the way the shell widgets get initialized.


Modified:
   branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-private.c
   branches/kill-bonobo/addressbook/gui/component/e-book-shell-view.c
   branches/kill-bonobo/shell/e-shell-content.c
   branches/kill-bonobo/shell/e-shell-sidebar.c
   branches/kill-bonobo/shell/e-shell-view.c
   branches/kill-bonobo/shell/e-shell-window-actions.c
   branches/kill-bonobo/shell/e-shell-window-private.h
   branches/kill-bonobo/shell/e-shell-window.c
   branches/kill-bonobo/shell/main.c
   branches/kill-bonobo/shell/test/e-test-shell-view.c

Modified: branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-private.c
==============================================================================
--- branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-private.c	(original)
+++ branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-private.c	Tue Sep  9 02:53:40 2008
@@ -284,6 +284,9 @@
 e_book_shell_view_private_init (EBookShellView *book_shell_view)
 {
 	EBookShellViewPrivate *priv = book_shell_view->priv;
+	EShellContent *shell_content;
+	EShellSidebar *shell_sidebar;
+	EShellTaskbar *shell_taskbar;
 	EShellView *shell_view;
 	GHashTable *uid_to_view;
 	GHashTable *uid_to_editor;
@@ -312,20 +315,27 @@
 	/* Construct view widgets. */
 
 	widget = gtk_notebook_new ();
+	shell_content = e_shell_view_get_content (shell_view);
 	gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
 	gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
-	priv->notebook = g_object_ref_sink (widget);
+	gtk_container_add (GTK_CONTAINER (shell_content), widget);
+	priv->notebook = g_object_ref (widget);
 	gtk_widget_show (widget);
 
 	widget = gtk_scrolled_window_new (NULL, NULL);
+	shell_sidebar = e_shell_view_get_sidebar (shell_view);
 	gtk_scrolled_window_set_policy (
 		GTK_SCROLLED_WINDOW (widget),
 		GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
 	gtk_scrolled_window_set_shadow_type (
 		GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
-	priv->scrolled_window = g_object_ref_sink (widget);
+	gtk_container_add (GTK_CONTAINER (shell_sidebar), widget);
 	gtk_widget_show (widget);
 
+	shell_taskbar = e_shell_view_get_taskbar (shell_view);
+	e_activity_handler_attach_task_bar (
+		priv->activity_handler, shell_taskbar);
+
 	container = widget;
 
 	widget = e_addressbook_selector_new (priv->source_list);

Modified: branches/kill-bonobo/addressbook/gui/component/e-book-shell-view.c
==============================================================================
--- branches/kill-bonobo/addressbook/gui/component/e-book-shell-view.c	(original)
+++ branches/kill-bonobo/addressbook/gui/component/e-book-shell-view.c	Tue Sep  9 02:53:40 2008
@@ -172,32 +172,14 @@
 book_shell_view_constructed (GObject *object)
 {
 	EBookShellView *book_shell_view;
-	EShellContent *shell_content;
-	EShellSidebar *shell_sidebar;
-	EShellTaskbar *shell_taskbar;
-	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);
 	book_shell_view = E_BOOK_SHELL_VIEW (object);
 
-	widget = book_shell_view->priv->notebook;
-	shell_content = e_shell_view_get_content (shell_view);
-	gtk_container_add (GTK_CONTAINER (shell_content), widget);
-
-	widget = book_shell_view->priv->scrolled_window;
-	shell_sidebar = e_shell_view_get_sidebar (shell_view);
-	gtk_container_add (GTK_CONTAINER (shell_sidebar), widget);
-
-	shell_taskbar = e_shell_view_get_taskbar (shell_view);
-	e_activity_handler_attach_task_bar (
-		book_shell_view->priv->activity_handler, shell_taskbar);
-
 	e_book_shell_view_actions_init (book_shell_view);
 	e_book_shell_view_update_search_filter (book_shell_view);
+
+	/* Chain up to parent's constructed() method. */
+	G_OBJECT_CLASS (parent_class)->constructed (object);
 }
 
 static void

Modified: branches/kill-bonobo/shell/e-shell-content.c
==============================================================================
--- branches/kill-bonobo/shell/e-shell-content.c	(original)
+++ branches/kill-bonobo/shell/e-shell-content.c	Tue Sep  9 02:53:40 2008
@@ -194,7 +194,8 @@
 		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 @@
 	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 @@
 }
 
 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 @@
 	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;
 

Modified: branches/kill-bonobo/shell/e-shell-sidebar.c
==============================================================================
--- branches/kill-bonobo/shell/e-shell-sidebar.c	(original)
+++ branches/kill-bonobo/shell/e-shell-sidebar.c	Tue Sep  9 02:53:40 2008
@@ -201,12 +201,22 @@
 }
 
 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 @@
 	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;
 

Modified: branches/kill-bonobo/shell/e-shell-view.c
==============================================================================
--- branches/kill-bonobo/shell/e-shell-view.c	(original)
+++ branches/kill-bonobo/shell/e-shell-view.c	Tue Sep  9 02:53:40 2008
@@ -206,26 +206,6 @@
 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 @@
 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

Modified: branches/kill-bonobo/shell/e-shell-window-actions.c
==============================================================================
--- branches/kill-bonobo/shell/e-shell-window-actions.c	(original)
+++ branches/kill-bonobo/shell/e-shell-window-actions.c	Tue Sep  9 02:53:40 2008
@@ -1716,21 +1716,15 @@
 
 	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);
 

Modified: branches/kill-bonobo/shell/e-shell-window-private.h
==============================================================================
--- branches/kill-bonobo/shell/e-shell-window-private.h	(original)
+++ branches/kill-bonobo/shell/e-shell-window-private.h	Tue Sep  9 02:53:40 2008
@@ -73,7 +73,6 @@
 
 	GHashTable *loaded_views;
 	const gchar *current_view;
-	const gchar *default_view;
 
 	/*** Widgetry ***/
 

Modified: branches/kill-bonobo/shell/e-shell-window.c
==============================================================================
--- branches/kill-bonobo/shell/e-shell-window.c	(original)
+++ branches/kill-bonobo/shell/e-shell-window.c	Tue Sep  9 02:53:40 2008
@@ -472,12 +472,13 @@
 	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);
 

Modified: branches/kill-bonobo/shell/main.c
==============================================================================
--- branches/kill-bonobo/shell/main.c	(original)
+++ branches/kill-bonobo/shell/main.c	Tue Sep  9 02:53:40 2008
@@ -302,8 +302,7 @@
 
 		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);
 	}
 

Modified: branches/kill-bonobo/shell/test/e-test-shell-view.c
==============================================================================
--- branches/kill-bonobo/shell/test/e-test-shell-view.c	(original)
+++ branches/kill-bonobo/shell/test/e-test-shell-view.c	Tue Sep  9 02:53:40 2008
@@ -43,42 +43,14 @@
 }
 
 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 @@
 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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]