evolution r35985 - in branches/kill-bonobo/shell: . test



Author: mbarnes
Date: Thu Aug 14 03:51:16 2008
New Revision: 35985
URL: http://svn.gnome.org/viewvc/evolution?rev=35985&view=rev

Log:
Demonstrate displaying the test shell view.

Also get the "Switcher Appearance" menu working... mostly.  Still need to
respond to GtkSettings notifications and make the preference persistent.


Added:
   branches/kill-bonobo/shell/test/e-test-shell-module.c   (contents, props changed)
      - copied, changed from r35983, /branches/kill-bonobo/shell/test/evolution-test-module.c
   branches/kill-bonobo/shell/test/e-test-shell-view.c
   branches/kill-bonobo/shell/test/e-test-shell-view.h
Removed:
   branches/kill-bonobo/shell/test/evolution-test-module.c
Modified:
   branches/kill-bonobo/shell/e-shell-view.h
   branches/kill-bonobo/shell/e-shell-window-actions.c
   branches/kill-bonobo/shell/e-sidebar.c
   branches/kill-bonobo/shell/e-sidebar.h
   branches/kill-bonobo/shell/test/Makefile.am

Modified: branches/kill-bonobo/shell/e-shell-view.h
==============================================================================
--- branches/kill-bonobo/shell/e-shell-view.h	(original)
+++ branches/kill-bonobo/shell/e-shell-view.h	Thu Aug 14 03:51:16 2008
@@ -37,7 +37,7 @@
 	((obj), E_TYPE_SHELL_VIEW))
 #define E_IS_SHELL_VIEW_CLASS(cls) \
 	(G_TYPE_CHECK_CLASS_TYPE \
-	((obj), E_TYPE_SHELL_VIEW))
+	((cls), E_TYPE_SHELL_VIEW))
 #define E_SHELL_VIEW_GET_CLASS(obj) \
 	(G_TYPE_INSTANCE_GET_CLASS \
 	((obj), E_TYPE_SHELL_VIEW, EShellViewClass))

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	Thu Aug 14 03:51:16 2008
@@ -884,7 +884,24 @@
                           GtkRadioAction *current,
                           EShellWindow *window)
 {
-	/* FIXME  Unfinished. */
+	ESidebar *sidebar;
+	GtkToolbarStyle style;
+
+	sidebar = E_SIDEBAR (window->priv->sidebar);
+	style = gtk_radio_action_get_current_value (action);
+
+	switch (style) {
+		case GTK_TOOLBAR_ICONS:
+		case GTK_TOOLBAR_TEXT:
+		case GTK_TOOLBAR_BOTH:
+		case GTK_TOOLBAR_BOTH_HORIZ:
+			e_sidebar_set_style (sidebar, style);
+			break;
+
+		default:
+			e_sidebar_unset_style (sidebar);
+			break;
+	}
 }
 
 static void
@@ -1147,28 +1164,28 @@
 	  N_("_Icons Only"),
 	  NULL,
 	  N_("Display window buttons with icons only"),
-	  E_SWITCHER_ICONS },
+	  GTK_TOOLBAR_ICONS },
 
 	{ "switcher-style-text",
 	  NULL,
 	  N_("_Text Only"),
 	  NULL,
 	  N_("Display window buttons with text only"),
-	  E_SWITCHER_TEXT },
+	  GTK_TOOLBAR_TEXT },
 
 	{ "switcher-style-both",
 	  NULL,
 	  N_("Icons _and Text"),
 	  NULL,
 	  N_("Display window buttons with icons and text"),
-	  E_SWITCHER_BOTH },
+	  GTK_TOOLBAR_BOTH_HORIZ },
 
 	{ "switcher-style-user",
 	  NULL,
 	  N_("Tool_bar Style"),
 	  NULL,
 	  N_("Display window buttons using the desktop toolbar setting"),
-	  E_SWITCHER_USER }
+	  -1 }
 };
 
 void
@@ -1194,8 +1211,7 @@
 		G_N_ELEMENTS (shell_toggle_entries), window);
 	gtk_action_group_add_radio_actions (
 		action_group, shell_switcher_style_entries,
-		G_N_ELEMENTS (shell_switcher_style_entries),
-		E_SWITCHER_USER,
+		G_N_ELEMENTS (shell_switcher_style_entries), -1,
 		G_CALLBACK (action_switcher_style_cb),  window);
 	gtk_ui_manager_insert_action_group (manager, action_group, 0);
 
@@ -1247,7 +1263,7 @@
 		class = g_type_class_ref (types[ii]);
 		type_name = g_type_name (types[ii]);
 
-		if (class->label != NULL) {
+		if (class->label == NULL) {
 			g_critical ("Label member not set on %s", type_name);
 			continue;
 		}
@@ -1255,9 +1271,17 @@
 		action_name = g_strdup_printf ("shell-view-%s", type_name);
 		tooltip = g_strdup_printf (_("Switch to %s"), class->label);
 
+		/* Note, we have to set "icon-name" separately because
+		 * gtk_radio_action_new() expects a "stock-id".  Sadly,
+		 * GTK+ still distinguishes between the two. */
+
 		action = gtk_radio_action_new (
 			action_name, class->label,
-			tooltip, class->icon_name, ii);
+			tooltip, NULL, ii);
+
+		g_object_set (
+			G_OBJECT (action),
+			"icon-name", class->icon_name, NULL);
 
 		g_signal_connect (
 			action, "changed",

Modified: branches/kill-bonobo/shell/e-sidebar.c
==============================================================================
--- branches/kill-bonobo/shell/e-sidebar.c	(original)
+++ branches/kill-bonobo/shell/e-sidebar.c	Thu Aug 14 03:51:16 2008
@@ -32,7 +32,8 @@
 struct _ESidebarPrivate {
 	GList *proxies;
 	gboolean actions_visible;
-	GtkToolbarStyle toolbar_style;
+	gboolean style_set;
+	GtkToolbarStyle style;
 };
 
 enum {
@@ -41,7 +42,13 @@
 	PROP_TOOLBAR_STYLE
 };
 
+enum {
+	STYLE_CHANGED,
+	LAST_SIGNAL
+};
+
 static gpointer parent_class;
+static guint signals[LAST_SIGNAL];
 
 static int
 sidebar_layout_actions (ESidebar *sidebar)
@@ -62,7 +69,7 @@
 	if (num_btns == 0)
 		return y;
 
-	icons_only = (sidebar->priv->toolbar_style == GTK_TOOLBAR_ICONS);
+	icons_only = (sidebar->priv->style == GTK_TOOLBAR_ICONS);
 
 	/* Figure out the max width and height */
 	for (p = sidebar->priv->proxies; p != NULL; p = p->next) {
@@ -143,8 +150,6 @@
 	return y;
 }
 
-/* GtkWidget methods.  */
-
 static void
 sidebar_set_property (GObject *object,
                       guint property_id,
@@ -159,7 +164,7 @@
 			return;
 
 		case PROP_TOOLBAR_STYLE:
-			e_sidebar_set_toolbar_style (
+			e_sidebar_set_style (
 				E_SIDEBAR (object),
 				g_value_get_enum (value));
 			return;
@@ -183,7 +188,7 @@
 
 		case PROP_TOOLBAR_STYLE:
 			g_value_set_enum (
-				value, e_sidebar_get_toolbar_style (
+				value, e_sidebar_get_style (
 				E_SIDEBAR (object)));
 			return;
 	}
@@ -315,6 +320,23 @@
 		container, include_internals, callback, callback_data);
 }
 
+static void
+sidebar_style_changed (ESidebar *sidebar,
+                       GtkToolbarStyle style)
+{
+	if (sidebar->priv->style == style)
+		return;
+
+	sidebar->priv->style = style;
+
+	g_list_foreach (
+		sidebar->priv->proxies,
+		(GFunc) gtk_tool_item_toolbar_reconfigured, NULL);
+
+	gtk_widget_queue_resize (GTK_WIDGET (sidebar));
+	g_object_notify (G_OBJECT (sidebar), "toolbar-style");
+}
+
 static GtkIconSize
 sidebar_get_icon_size (GtkToolShell *shell)
 {
@@ -330,7 +352,7 @@
 static GtkToolbarStyle
 sidebar_get_style (GtkToolShell *shell)
 {
-	return e_sidebar_get_toolbar_style (E_SIDEBAR (shell));
+	return e_sidebar_get_style (E_SIDEBAR (shell));
 }
 
 static GtkReliefStyle
@@ -362,6 +384,8 @@
 	container_class->remove = sidebar_remove;
 	container_class->forall = sidebar_forall;
 
+	class->style_changed = sidebar_style_changed;
+
 	g_object_class_install_property (
 		object_class,
 		PROP_ACTIONS_VISIBLE,
@@ -384,6 +408,16 @@
 			DEFAULT_TOOLBAR_STYLE,
 			G_PARAM_CONSTRUCT |
 			G_PARAM_READWRITE));
+
+	signals[STYLE_CHANGED] = g_signal_new (
+		"style-changed",
+		G_OBJECT_CLASS_TYPE (class),
+		G_SIGNAL_RUN_FIRST,
+		G_STRUCT_OFFSET (ESidebarClass, style_changed),
+		NULL, NULL,
+		g_cclosure_marshal_VOID__ENUM,
+		G_TYPE_NONE, 1,
+		GTK_TYPE_TOOLBAR_STYLE);
 }
 
 static void
@@ -493,27 +527,42 @@
 }
 
 GtkToolbarStyle
-e_sidebar_get_toolbar_style (ESidebar *sidebar)
+e_sidebar_get_style (ESidebar *sidebar)
 {
 	g_return_val_if_fail (E_IS_SIDEBAR (sidebar), DEFAULT_TOOLBAR_STYLE);
 
-	return sidebar->priv->toolbar_style;
+	return sidebar->priv->style;
 }
 
 void
-e_sidebar_set_toolbar_style (ESidebar *sidebar,
-                             GtkToolbarStyle style)
+e_sidebar_set_style (ESidebar *sidebar,
+                     GtkToolbarStyle style)
 {
 	g_return_if_fail (E_IS_SIDEBAR (sidebar));
 
-	if (sidebar->priv->toolbar_style == style)
+	sidebar->priv->style_set = TRUE;
+	g_signal_emit (sidebar, signals[STYLE_CHANGED], 0, style);
+}
+
+void
+e_sidebar_unset_style (ESidebar *sidebar)
+{
+	GtkSettings *settings;
+	GtkToolbarStyle style;
+
+	g_return_if_fail (E_IS_SIDEBAR (sidebar));
+
+	if (!sidebar->priv->style_set)
 		return;
 
-	sidebar->priv->toolbar_style = style;
+	settings = gtk_widget_get_settings (GTK_WIDGET (sidebar));
+	g_object_get (settings, "gtk-toolbar-style", &style, NULL);
 
-	g_list_foreach (
-		sidebar->priv->proxies,
-		(GFunc) gtk_tool_item_toolbar_reconfigured, NULL);
+	if (style == GTK_TOOLBAR_BOTH)
+		style = GTK_TOOLBAR_BOTH_HORIZ;
 
-	g_object_notify (G_OBJECT (sidebar), "toolbar-style");
+	if (style != sidebar->priv->style)
+		g_signal_emit (sidebar, signals[STYLE_CHANGED], 0, style);
+
+	sidebar->priv->style_set = FALSE;
 }

Modified: branches/kill-bonobo/shell/e-sidebar.h
==============================================================================
--- branches/kill-bonobo/shell/e-sidebar.h	(original)
+++ branches/kill-bonobo/shell/e-sidebar.h	Thu Aug 14 03:51:16 2008
@@ -44,13 +44,6 @@
 
 G_BEGIN_DECLS
 
-typedef enum {
-	E_SWITCHER_ICONS,
-	E_SWITCHER_TEXT,
-	E_SWITCHER_BOTH,
-	E_SWITCHER_USER
-} ESwitcherStyle;
-
 typedef struct _ESidebar ESidebar;
 typedef struct _ESidebarClass ESidebarClass;
 typedef struct _ESidebarPrivate ESidebarPrivate;
@@ -62,6 +55,9 @@
 
 struct _ESidebarClass {
 	GtkBinClass parent_class;
+
+	void		(*style_changed)	(ESidebar *sidebar,
+						 GtkToolbarStyle style);
 };
 
 GType		e_sidebar_get_type		(void);
@@ -71,9 +67,10 @@
 gboolean	e_sidebar_get_actions_visible	(ESidebar *sidebar);
 void		e_sidebar_set_actions_visible	(ESidebar *sidebar,
 						 gboolean visible);
-GtkToolbarStyle	e_sidebar_get_toolbar_style	(ESidebar *sidebar);
-void		e_sidebar_set_toolbar_style	(ESidebar *sidebar,
+GtkToolbarStyle	e_sidebar_get_style		(ESidebar *sidebar);
+void		e_sidebar_set_style		(ESidebar *sidebar,
 						 GtkToolbarStyle style);
+void		e_sidebar_unset_style		(ESidebar *sidebar);
 
 G_END_DECLS
 

Modified: branches/kill-bonobo/shell/test/Makefile.am
==============================================================================
--- branches/kill-bonobo/shell/test/Makefile.am	(original)
+++ branches/kill-bonobo/shell/test/Makefile.am	Thu Aug 14 03:51:16 2008
@@ -8,7 +8,9 @@
 	$(EVOLUTION_TEST_CFLAGS)
 
 libevolution_test_la_SOURCES =			\
-	evolution-test-module.c
+	e-test-shell-module.c			\
+	e-test-shell-view.c			\
+	e-test-shell-view.h
 
 libevolution_test_la_LIBADD =			\
 	$(top_builddir)/shell/libeshell.la	\

Copied: branches/kill-bonobo/shell/test/e-test-shell-module.c (from r35983, /branches/kill-bonobo/shell/test/evolution-test-module.c)
==============================================================================
--- /branches/kill-bonobo/shell/test/evolution-test-module.c	(original)
+++ branches/kill-bonobo/shell/test/e-test-shell-module.c	Thu Aug 14 03:51:16 2008
@@ -20,6 +20,8 @@
 
 #include <e-shell-module.h>
 
+#include "e-test-shell-view.h"
+
 #define MODULE_SORT_ORDER	100
 #define MODULE_ALIASES		"test"
 #define MODULE_SCHEMES		""
@@ -82,5 +84,6 @@
 e_shell_module_init (GTypeModule *module)
 {
 	g_type_module_set_name (module, "name");
+	module_info.shell_view_type = e_test_shell_view_get_type (module);
 	e_shell_module_set_info (E_SHELL_MODULE (module), &module_info);
 }

Added: branches/kill-bonobo/shell/test/e-test-shell-view.c
==============================================================================
--- (empty file)
+++ branches/kill-bonobo/shell/test/e-test-shell-view.c	Thu Aug 14 03:51:16 2008
@@ -0,0 +1,79 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-test-shell-view.c
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "e-test-shell-view.h"
+
+#include <glib/gi18n.h>
+
+#define E_TEST_SHELL_VIEW_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_TEST_SHELL_VIEW, ETestShellViewPrivate))
+
+struct _ETestShellViewPrivate {
+	gint dummy_value;
+};
+
+GType e_test_shell_view_type = 0;
+static gpointer parent_class;
+
+static void
+test_shell_view_class_init (ETestShellViewClass *class)
+{
+	EShellViewClass *shell_view_class;
+
+	parent_class = g_type_class_peek_parent (class);
+	g_type_class_add_private (class, sizeof (ETestShellViewPrivate));
+
+	shell_view_class = E_SHELL_VIEW_CLASS (class);
+	shell_view_class->label = N_("Test");
+	shell_view_class->icon_name = "face-monkey";
+}
+
+static void
+test_shell_view_init (ETestShellView *test_view)
+{
+	test_view->priv = E_TEST_SHELL_VIEW_GET_PRIVATE (test_view);
+}
+
+GType
+e_test_shell_view_get_type (GTypeModule *module)
+{
+	if (e_test_shell_view_type == 0) {
+		const GTypeInfo type_info = {
+			sizeof (ETestShellViewClass),
+			(GBaseInitFunc) NULL,
+			(GBaseFinalizeFunc) NULL,
+			(GClassInitFunc) test_shell_view_class_init,
+			(GClassFinalizeFunc) NULL,
+			NULL,  /* class_data */
+			sizeof (ETestShellView),
+			0,     /* n_preallocs */
+			(GInstanceInitFunc) test_shell_view_init,
+			NULL   /* value_table */
+		};
+
+		e_test_shell_view_type =
+			g_type_module_register_type (
+				module, E_TYPE_SHELL_VIEW,
+				"ETestShellView", &type_info, 0);
+	}
+
+	return e_test_shell_view_type;
+}

Added: branches/kill-bonobo/shell/test/e-test-shell-view.h
==============================================================================
--- (empty file)
+++ branches/kill-bonobo/shell/test/e-test-shell-view.h	Thu Aug 14 03:51:16 2008
@@ -0,0 +1,66 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-test-shell-view.h
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef E_TEST_SHELL_VIEW_H
+#define E_TEST_SHELL_VIEW_H
+
+#include <e-shell-view.h>
+
+/* Standard GObject macros */
+#define E_TYPE_TEST_SHELL_VIEW \
+	(e_test_shell_view_type)
+#define E_TEST_SHELL_VIEW(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_TEST_SHELL_VIEW, ETestShellView))
+#define E_TEST_SHELL_VIEW_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_TEST_SHELL_VIEW, ETestShellViewClass))
+#define E_IS_TEST_SHELL_VIEW(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_TEST_SHELL_VIEW))
+#define E_IS_TEST_SHELL_VIEW_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_TEST_SHELL_VIEW))
+#define E_TEST_SHELL_VIEW_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_TEST_SHELL_VIEW, ETestShellViewClass))
+
+G_BEGIN_DECLS
+
+extern GType e_test_shell_view_type;
+
+typedef struct _ETestShellView ETestShellView;
+typedef struct _ETestShellViewClass ETestShellViewClass;
+typedef struct _ETestShellViewPrivate ETestShellViewPrivate;
+
+struct _ETestShellView {
+	EShellView parent;
+	ETestShellViewPrivate *priv;
+};
+
+struct _ETestShellViewClass {
+	EShellViewClass parent_class;
+};
+
+GType		e_test_shell_view_get_type	(GTypeModule *module);
+
+G_END_DECLS
+
+#endif /* E_TEST_SHELL_VIEW_H */



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