aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--shell/e-shell-view.h2
-rw-r--r--shell/e-shell-window-actions.c42
-rw-r--r--shell/e-sidebar.c83
-rw-r--r--shell/e-sidebar.h15
-rw-r--r--shell/test/Makefile.am4
-rw-r--r--shell/test/e-test-shell-module.c (renamed from shell/test/evolution-test-module.c)3
-rw-r--r--shell/test/e-test-shell-view.c79
-rw-r--r--shell/test/e-test-shell-view.h66
8 files changed, 257 insertions, 37 deletions
diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h
index 01c3e1da75..641eed6406 100644
--- a/shell/e-shell-view.h
+++ b/shell/e-shell-view.h
@@ -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))
diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c
index 81934a46ea..c4d9b1b99e 100644
--- a/shell/e-shell-window-actions.c
+++ b/shell/e-shell-window-actions.c
@@ -884,7 +884,24 @@ action_switcher_style_cb (GtkRadioAction *action,
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 @@ static GtkRadioActionEntry shell_switcher_style_entries[] = {
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 @@ e_shell_window_actions_init (EShellWindow *window)
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 @@ e_shell_window_create_shell_view_actions (EShellWindow *window)
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 @@ e_shell_window_create_shell_view_actions (EShellWindow *window)
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",
diff --git a/shell/e-sidebar.c b/shell/e-sidebar.c
index aca9765e87..ea479918bc 100644
--- a/shell/e-sidebar.c
+++ b/shell/e-sidebar.c
@@ -32,7 +32,8 @@
struct _ESidebarPrivate {
GList *proxies;
gboolean actions_visible;
- GtkToolbarStyle toolbar_style;
+ gboolean style_set;
+ GtkToolbarStyle style;
};
enum {
@@ -41,7 +42,13 @@ enum {
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 @@ sidebar_layout_actions (ESidebar *sidebar)
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 @@ sidebar_layout_actions (ESidebar *sidebar)
return y;
}
-/* GtkWidget methods. */
-
static void
sidebar_set_property (GObject *object,
guint property_id,
@@ -159,7 +164,7 @@ sidebar_set_property (GObject *object,
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 @@ sidebar_get_property (GObject *object,
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 @@ sidebar_forall (GtkContainer *container,
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 @@ sidebar_get_orientation (GtkToolShell *shell)
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 @@ sidebar_class_init (ESidebarClass *class)
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 @@ sidebar_class_init (ESidebarClass *class)
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 @@ e_sidebar_set_actions_visible (ESidebar *sidebar,
}
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;
}
diff --git a/shell/e-sidebar.h b/shell/e-sidebar.h
index 6024b6e229..1695d2d3b5 100644
--- a/shell/e-sidebar.h
+++ b/shell/e-sidebar.h
@@ -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 _ESidebar {
struct _ESidebarClass {
GtkBinClass parent_class;
+
+ void (*style_changed) (ESidebar *sidebar,
+ GtkToolbarStyle style);
};
GType e_sidebar_get_type (void);
@@ -71,9 +67,10 @@ void e_sidebar_add_action (ESidebar *sidebar,
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
diff --git a/shell/test/Makefile.am b/shell/test/Makefile.am
index f667ee42fe..e355da60c8 100644
--- a/shell/test/Makefile.am
+++ b/shell/test/Makefile.am
@@ -8,7 +8,9 @@ INCLUDES = \
$(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 \
diff --git a/shell/test/evolution-test-module.c b/shell/test/e-test-shell-module.c
index a2ec2c7915..16515c1e30 100644
--- a/shell/test/evolution-test-module.c
+++ b/shell/test/e-test-shell-module.c
@@ -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 @@ void
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);
}
diff --git a/shell/test/e-test-shell-view.c b/shell/test/e-test-shell-view.c
new file mode 100644
index 0000000000..7b2ff9a251
--- /dev/null
+++ b/shell/test/e-test-shell-view.c
@@ -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;
+}
diff --git a/shell/test/e-test-shell-view.h b/shell/test/e-test-shell-view.h
new file mode 100644
index 0000000000..036ebc3877
--- /dev/null
+++ b/shell/test/e-test-shell-view.h
@@ -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 */