aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorJP Rosevear <jpr@novell.com>2005-01-05 03:58:45 +0800
committerJP Rosevear <jpr@src.gnome.org>2005-01-05 03:58:45 +0800
commit8541e321f0d39295b315f057516f12a1fb4289f6 (patch)
tree051d0a87ec08bf575513879e014a43546b89ddb2 /shell
parent097c33e75eb2e2d06d643e467285310676d1fe62 (diff)
downloadgsoc2013-evolution-8541e321f0d39295b315f057516f12a1fb4289f6.tar
gsoc2013-evolution-8541e321f0d39295b315f057516f12a1fb4289f6.tar.gz
gsoc2013-evolution-8541e321f0d39295b315f057516f12a1fb4289f6.tar.bz2
gsoc2013-evolution-8541e321f0d39295b315f057516f12a1fb4289f6.tar.lz
gsoc2013-evolution-8541e321f0d39295b315f057516f12a1fb4289f6.tar.xz
gsoc2013-evolution-8541e321f0d39295b315f057516f12a1fb4289f6.tar.zst
gsoc2013-evolution-8541e321f0d39295b315f057516f12a1fb4289f6.zip
new protos, modes
2005-01-04 JP Rosevear <jpr@novell.com> * e-sidebar.h: new protos, modes * e-sidebar.c: handle 2 more modes, text only and toolbar style; allow visibility to be set for the buttons * e-shell-window.h: new proto * e-shell-window.c (setup_widgets): set the sidebar setting and visibility based on stored gconf settings (e_shell_window_save_defaults): save the current sidebar setting visibility (e_shell_window_peek_sidebar): return the sidebar * e-shell-window-commands.c (e_shell_window_commands_setup): add listeners for each of the component button radio items and for the hide toggle (view_buttons_icontext_item_toggled_handler): listener callback, set mode (view_buttons_icon_item_toggled_handler): ditto (view_buttons_text_item_toggled_handler): ditto (view_buttons_toolbar_item_toggled_handler): ditto (view_buttons_hide_item_toggled_handler): listener callback, set visibility * apps_evolution_shell.schemas.in.in: add component button style and visibility defaults svn path=/trunk/; revision=28239
Diffstat (limited to 'shell')
-rw-r--r--shell/ChangeLog29
-rw-r--r--shell/apps_evolution_shell.schemas.in.in24
-rw-r--r--shell/e-shell-window-commands.c84
-rw-r--r--shell/e-shell-window.c113
-rw-r--r--shell/e-shell-window.h2
-rw-r--r--shell/e-sidebar.c196
-rw-r--r--shell/e-sidebar.h7
7 files changed, 419 insertions, 36 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index f7529b9012..c12056546d 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,32 @@
+2005-01-04 JP Rosevear <jpr@novell.com>
+
+ * e-sidebar.h: new protos, modes
+
+ * e-sidebar.c: handle 2 more modes, text only and toolbar style;
+ allow visibility to be set for the buttons
+
+ * e-shell-window.h: new proto
+
+ * e-shell-window.c (setup_widgets): set the sidebar setting and
+ visibility based on stored gconf settings
+ (e_shell_window_save_defaults): save the current sidebar setting
+ visibility
+ (e_shell_window_peek_sidebar): return the sidebar
+
+ * e-shell-window-commands.c (e_shell_window_commands_setup): add
+ listeners for each of the component button radio items and for the
+ hide toggle
+ (view_buttons_icontext_item_toggled_handler): listener callback,
+ set mode
+ (view_buttons_icon_item_toggled_handler): ditto
+ (view_buttons_text_item_toggled_handler): ditto
+ (view_buttons_toolbar_item_toggled_handler): ditto
+ (view_buttons_hide_item_toggled_handler): listener callback, set
+ visibility
+
+ * apps_evolution_shell.schemas.in.in: add component button style
+ and visibility defaults
+
2004-12-29 Rodrigo Moya <rodrigo@novell.com>
* main.c (show_development_warning): 2.0 is the current stable
diff --git a/shell/apps_evolution_shell.schemas.in.in b/shell/apps_evolution_shell.schemas.in.in
index fddf73e7f3..0180694241 100644
--- a/shell/apps_evolution_shell.schemas.in.in
+++ b/shell/apps_evolution_shell.schemas.in.in
@@ -96,6 +96,30 @@
</schema>
<schema>
+ <key>/schemas/apps/evolution/shell/view_defaults/buttons_visible</key>
+ <applyto>/apps/evolution/shell/view_defaults/buttons_visible</applyto>
+ <owner>evolution</owner>
+ <type>bool</type>
+ <default>TRUE</default>
+ <locale name="C">
+ <short>Buttons are visible</short>
+ <long>Whether the buttons should be visible.</long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/evolution/shell/view_defaults/buttons_style</key>
+ <applyto>/apps/evolution/shell/view_defaults/buttons_style</applyto>
+ <owner>evolution</owner>
+ <type>string</type>
+ <default>toolbar</default>
+ <locale name="C">
+ <short>Button style</short>
+ <long>The style of the displayed buttons. Can be text, icons, both, toolbar. If toolbar is set, the style of the toolbar is followed as determined by the GNOME setting.</long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/evolution/shell/view_defaults/toolbar_visible</key>
<applyto>/apps/evolution/shell/view_defaults/toolbar_visible</applyto>
<owner>evolution</owner>
diff --git a/shell/e-shell-window-commands.c b/shell/e-shell-window-commands.c
index 11fb3dd337..eaa207d63e 100644
--- a/shell/e-shell-window-commands.c
+++ b/shell/e-shell-window-commands.c
@@ -727,6 +727,75 @@ shell_line_status_changed_cb (EShell *shell,
}
static void
+view_buttons_icontext_item_toggled_handler (BonoboUIComponent *ui_component,
+ const char *path,
+ Bonobo_UIComponent_EventType type,
+ const char *state,
+ EShellWindow *shell_window)
+{
+ ESidebar *sidebar;
+
+ sidebar = e_shell_window_peek_sidebar (shell_window);
+ e_sidebar_set_mode (sidebar, E_SIDEBAR_MODE_BOTH);
+}
+
+static void
+view_buttons_icon_item_toggled_handler (BonoboUIComponent *ui_component,
+ const char *path,
+ Bonobo_UIComponent_EventType type,
+ const char *state,
+ EShellWindow *shell_window)
+{
+ ESidebar *sidebar;
+
+ sidebar = e_shell_window_peek_sidebar (shell_window);
+ e_sidebar_set_mode (sidebar, E_SIDEBAR_MODE_ICON);
+}
+
+static void
+view_buttons_text_item_toggled_handler (BonoboUIComponent *ui_component,
+ const char *path,
+ Bonobo_UIComponent_EventType type,
+ const char *state,
+ EShellWindow *shell_window)
+{
+ ESidebar *sidebar;
+
+ sidebar = e_shell_window_peek_sidebar (shell_window);
+ e_sidebar_set_mode (sidebar, E_SIDEBAR_MODE_TEXT);
+}
+
+static void
+view_buttons_toolbar_item_toggled_handler (BonoboUIComponent *ui_component,
+ const char *path,
+ Bonobo_UIComponent_EventType type,
+ const char *state,
+ EShellWindow *shell_window)
+{
+ ESidebar *sidebar;
+
+ sidebar = e_shell_window_peek_sidebar (shell_window);
+ e_sidebar_set_mode (sidebar, E_SIDEBAR_MODE_TOOLBAR);
+}
+
+static void
+view_buttons_hide_item_toggled_handler (BonoboUIComponent *ui_component,
+ const char *path,
+ Bonobo_UIComponent_EventType type,
+ const char *state,
+ EShellWindow *shell_window)
+{
+ ESidebar *sidebar;
+ gboolean is_visible;
+
+ sidebar = e_shell_window_peek_sidebar (shell_window);
+
+ is_visible = state[0] == '0';
+
+ e_sidebar_set_show_buttons (sidebar, is_visible);
+}
+
+static void
view_toolbar_item_toggled_handler (BonoboUIComponent *ui_component,
const char *path,
Bonobo_UIComponent_EventType type,
@@ -761,6 +830,21 @@ e_shell_window_commands_setup (EShellWindow *shell_window)
bonobo_ui_component_add_verb_list_with_data (uic, actions_verbs, shell_window);
bonobo_ui_component_add_verb_list_with_data (uic, tools_verbs, shell_window);
bonobo_ui_component_add_verb_list_with_data (uic, help_verbs, shell_window);
+ bonobo_ui_component_add_listener (uic, "ViewButtonsIconText",
+ (BonoboUIListenerFn)view_buttons_icontext_item_toggled_handler,
+ (gpointer)shell_window);
+ bonobo_ui_component_add_listener (uic, "ViewButtonsIcon",
+ (BonoboUIListenerFn)view_buttons_icon_item_toggled_handler,
+ (gpointer)shell_window);
+ bonobo_ui_component_add_listener (uic, "ViewButtonsText",
+ (BonoboUIListenerFn)view_buttons_text_item_toggled_handler,
+ (gpointer)shell_window);
+ bonobo_ui_component_add_listener (uic, "ViewButtonsToolbar",
+ (BonoboUIListenerFn)view_buttons_toolbar_item_toggled_handler,
+ (gpointer)shell_window);
+ bonobo_ui_component_add_listener (uic, "ViewButtonsHide",
+ (BonoboUIListenerFn)view_buttons_hide_item_toggled_handler,
+ (gpointer)shell_window);
bonobo_ui_component_add_listener (uic, "ViewToolbar",
(BonoboUIListenerFn)view_toolbar_item_toggled_handler,
(gpointer)shell_window);
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index 9625139de7..6dfb20055c 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -49,6 +49,7 @@
#include <bonobo/bonobo-widget.h>
#include <libgnome/gnome-i18n.h>
+#include <libgnome/gnome-gconf.h>
#include <gconf/gconf-client.h>
@@ -87,7 +88,7 @@ struct _EShellWindowPrivate {
/* The sidebar. */
GtkWidget *sidebar;
-
+
/* Notebooks used to switch between components. */
GtkWidget *sidebar_notebook;
GtkWidget *view_notebook;
@@ -575,6 +576,14 @@ menu_component_selected (BonoboUIComponent *uic,
e_shell_window_switch_to_component (window, component_id+1);
}
+static GConfEnumStringPair button_styles[] = {
+ { E_SIDEBAR_MODE_TEXT, "text" },
+ { E_SIDEBAR_MODE_ICON, "icons" },
+ { E_SIDEBAR_MODE_BOTH, "both" },
+ { E_SIDEBAR_MODE_TOOLBAR, "toolbar" },
+ { -1, NULL }
+};
+
static void
setup_widgets (EShellWindow *window)
{
@@ -585,40 +594,91 @@ setup_widgets (EShellWindow *window)
GSList *p;
GString *xml;
int button_id;
- gboolean toolbar_visible;
-
+ gboolean visible;
+ char *style;
+ int mode;
+
priv->paned = gtk_hpaned_new ();
+ gtk_widget_show (priv->paned);
priv->sidebar = e_sidebar_new ();
g_signal_connect (priv->sidebar, "button_selected",
G_CALLBACK (sidebar_button_selected_callback), window);
gtk_paned_pack1 (GTK_PANED (priv->paned), priv->sidebar, FALSE, FALSE);
+ gtk_widget_show (priv->sidebar);
priv->sidebar_notebook = gtk_notebook_new ();
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->sidebar_notebook), FALSE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->sidebar_notebook), FALSE);
e_sidebar_set_selection_widget (E_SIDEBAR (priv->sidebar), priv->sidebar_notebook);
+ gtk_widget_show (priv->sidebar_notebook);
priv->view_notebook = gtk_notebook_new ();
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->view_notebook), FALSE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->view_notebook), FALSE);
gtk_paned_pack2 (GTK_PANED (priv->paned), priv->view_notebook, TRUE, TRUE);
+ gtk_widget_show (priv->view_notebook);
gtk_paned_set_position (GTK_PANED (priv->paned),
gconf_client_get_int (gconf_client, "/apps/evolution/shell/view_defaults/folder_bar/width", NULL));
- toolbar_visible = gconf_client_get_bool (gconf_client,
- "/apps/evolution/shell/view_defaults/toolbar_visible",
+ /* The buttons */
+ visible = gconf_client_get_bool (gconf_client,
+ "/apps/evolution/shell/view_defaults/buttons_visible",
NULL);
bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window),
+ "/commands/ViewButtonsHide",
+ "state",
+ visible ? "0" : "1",
+ NULL);
+
+ e_sidebar_set_show_buttons (E_SIDEBAR (priv->sidebar), visible);
+
+ style = gconf_client_get_string (gconf_client,
+ "/apps/evolution/shell/view_defaults/buttons_style",
+ NULL);
+
+ if (gconf_string_to_enum (button_styles, style, &mode)) {
+ switch (mode) {
+ case E_SIDEBAR_MODE_TEXT:
+ bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window),
+ "/commands/ViewButtonsText",
+ "state", "1", NULL);
+ break;
+ case E_SIDEBAR_MODE_ICON:
+ bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window),
+ "/commands/ViewButtonsIcon",
+ "state", "1", NULL);
+ break;
+ case E_SIDEBAR_MODE_BOTH:
+ bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window),
+ "/commands/ViewButtonsIconText",
+ "state", "1", NULL);
+ break;
+
+ case E_SIDEBAR_MODE_TOOLBAR:
+ bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window),
+ "/commands/ViewButtonsToolbar",
+ "state", "1", NULL);
+ break;
+ }
+
+ e_sidebar_set_mode (E_SIDEBAR (priv->sidebar), mode);
+ }
+
+ /* The tool bar */
+ visible = gconf_client_get_bool (gconf_client,
+ "/apps/evolution/shell/view_defaults/toolbar_visible",
+ NULL);
+ bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window),
"/commands/ViewToolbar",
"state",
- toolbar_visible ? "1" : "0",
+ visible ? "1" : "0",
NULL);
bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window),
"/Toolbar",
"hidden",
- toolbar_visible ? "0" : "1",
+ visible ? "0" : "1",
NULL);
button_id = 0;
@@ -669,7 +729,7 @@ setup_widgets (EShellWindow *window)
contents_vbox = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (contents_vbox), priv->paned, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (contents_vbox), priv->status_bar, FALSE, TRUE, 0);
- gtk_widget_show_all (contents_vbox);
+ gtk_widget_show (contents_vbox);
/* We only display this when a menu item is actually selected. */
gtk_widget_hide (priv->menu_hint_label);
@@ -892,12 +952,21 @@ e_shell_window_peek_bonobo_ui_component (EShellWindow *window)
return window->priv->ui_component;
}
+ESidebar *
+e_shell_window_peek_sidebar (EShellWindow *window)
+{
+ g_return_val_if_fail (E_IS_SHELL_WINDOW (window), NULL);
+
+ return E_SIDEBAR (window->priv->sidebar);
+}
+
void
e_shell_window_save_defaults (EShellWindow *window)
{
GConfClient *client = gconf_client_get_default ();
char *prop;
- gboolean toolbar_visible;
+ const char *style;
+ gboolean visible;
gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/width",
GTK_WIDGET (window)->allocation.width, NULL);
@@ -907,15 +976,37 @@ e_shell_window_save_defaults (EShellWindow *window)
gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/folder_bar/width",
gtk_paned_get_position (GTK_PANED (window->priv->paned)), NULL);
+ /* The button styles */
+ if ((style = gconf_enum_to_string (button_styles, e_sidebar_get_mode (E_SIDEBAR (window->priv->sidebar))))) {
+ gconf_client_set_string (client,
+ "/apps/evolution/shell/view_defaults/buttons_style",
+ style, NULL);
+ }
+
+ /* Button hiding setting */
+ prop = bonobo_ui_component_get_prop (e_shell_window_peek_bonobo_ui_component (window),
+ "/commands/ViewButtonsHide",
+ "state",
+ NULL);
+ if (prop) {
+ visible = prop[0] == '0';
+ gconf_client_set_bool (client,
+ "/apps/evolution/shell/view_defaults/buttons_visible",
+ visible,
+ NULL);
+ g_free (prop);
+ }
+
+ /* Toolbar visibility setting */
prop = bonobo_ui_component_get_prop (e_shell_window_peek_bonobo_ui_component (window),
"/commands/ViewToolbar",
"state",
NULL);
if (prop) {
- toolbar_visible = prop[0] == '1';
+ visible = prop[0] == '1';
gconf_client_set_bool (client,
"/apps/evolution/shell/view_defaults/toolbar_visible",
- toolbar_visible,
+ visible,
NULL);
g_free (prop);
}
diff --git a/shell/e-shell-window.h b/shell/e-shell-window.h
index 01c231c329..80d5955d51 100644
--- a/shell/e-shell-window.h
+++ b/shell/e-shell-window.h
@@ -25,6 +25,7 @@
#include <bonobo/bonobo-window.h>
#include <bonobo/bonobo-ui-component.h>
+#include "e-sidebar.h"
#define E_TYPE_SHELL_WINDOW (e_shell_window_get_type ())
#define E_SHELL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SHELL_WINDOW, EShellWindow))
@@ -64,6 +65,7 @@ const char *e_shell_window_peek_current_component_id (EShellWindow *shell);
EShell *e_shell_window_peek_shell (EShellWindow *window);
BonoboUIComponent *e_shell_window_peek_bonobo_ui_component (EShellWindow *window);
+ESidebar *e_shell_window_peek_sidebar (EShellWindow *window);
void e_shell_window_save_defaults (EShellWindow *window);
void e_shell_window_show_settings (EShellWindow *window);
diff --git a/shell/e-sidebar.c b/shell/e-sidebar.c
index fc1ca4dd90..7a7932eff0 100644
--- a/shell/e-sidebar.c
+++ b/shell/e-sidebar.c
@@ -33,6 +33,8 @@
#include <gtk/gtklabel.h>
#include <gtk/gtktogglebutton.h>
+#include <gconf/gconf-client.h>
+#include <libgnome/gnome-gconf.h>
typedef struct {
GtkWidget *button_widget;
@@ -44,10 +46,15 @@ typedef struct {
struct _ESidebarPrivate {
ESidebarMode mode;
+ ESidebarMode toolbar_mode;
+
+ gboolean show;
GtkWidget *selection_widget;
GSList *buttons;
+ guint style_changed_id;
+
gboolean in_toggle;
};
@@ -61,10 +68,10 @@ static unsigned int signals[NUM_SIGNALS] = { 0 };
G_DEFINE_TYPE (ESidebar, e_sidebar, GTK_TYPE_CONTAINER)
+#define INTERNAL_MODE(sidebar) (sidebar->priv->mode == E_SIDEBAR_MODE_TOOLBAR ? sidebar->priv->toolbar_mode : sidebar->priv->mode)
#define H_PADDING 6
#define V_PADDING 6
-
/* Utility functions. */
static Button *
@@ -154,7 +161,8 @@ static int
layout_buttons (ESidebar *sidebar)
{
GtkAllocation *allocation = & GTK_WIDGET (sidebar)->allocation;
- gboolean icons_only = (sidebar->priv->mode == E_SIDEBAR_MODE_ICON);
+ ESidebarMode mode;
+ gboolean icons_only;
int num_btns = g_slist_length (sidebar->priv->buttons), btns_per_row;
GSList **rows, *p;
Button *button;
@@ -169,6 +177,9 @@ layout_buttons (ESidebar *sidebar)
if (num_btns == 0)
return y;
+ mode = INTERNAL_MODE (sidebar);
+ icons_only = (mode == E_SIDEBAR_MODE_ICON);
+
/* Figure out the max width and height */
for (p = sidebar->priv->buttons; p != NULL; p = p->next) {
GtkRequisition requisition;
@@ -223,7 +234,7 @@ layout_buttons (ESidebar *sidebar)
y -= max_btn_height;
x = H_PADDING + allocation->x;
len = g_slist_length (rows[i]);
- if (sidebar->priv->mode == E_SIDEBAR_MODE_TEXT)
+ if (mode == E_SIDEBAR_MODE_TEXT || mode == E_SIDEBAR_MODE_BOTH)
extra_width = (allocation->width - (len * max_btn_width ) - (len * H_PADDING)) / len;
else
extra_width = 0;
@@ -257,7 +268,10 @@ do_layout (ESidebar *sidebar)
GtkAllocation child_allocation;
int y;
- y = layout_buttons (sidebar);
+ if (sidebar->priv->show)
+ y = layout_buttons (sidebar);
+ else
+ y = allocation->y + allocation->height;
/* Place the selection widget. */
child_allocation.x = allocation->x;
@@ -330,6 +344,9 @@ impl_size_request (GtkWidget *widget,
gtk_widget_size_request (sidebar->priv->selection_widget, requisition);
}
+ if (!sidebar->priv->show)
+ return;
+
for (p = sidebar->priv->buttons; p != NULL; p = p->next) {
Button *button = p->data;
GtkRequisition button_requisition;
@@ -357,11 +374,19 @@ static void
impl_dispose (GObject *object)
{
ESidebarPrivate *priv = E_SIDEBAR (object)->priv;
+ GConfClient *gconf_client = gconf_client_get_default ();
g_slist_foreach (priv->buttons, (GFunc) button_free, NULL);
g_slist_free (priv->buttons);
priv->buttons = NULL;
+ if (priv->style_changed_id) {
+ gconf_client_notify_remove (gconf_client, priv->style_changed_id);
+ priv->style_changed_id = 0;
+ }
+
+ g_object_unref (gconf_client);
+
(* G_OBJECT_CLASS (e_sidebar_parent_class)->dispose) (object);
}
@@ -418,7 +443,6 @@ e_sidebar_init (ESidebar *sidebar)
priv->mode = E_SIDEBAR_MODE_TEXT;
}
-
GtkWidget *
e_sidebar_new (void)
{
@@ -455,23 +479,40 @@ e_sidebar_add_button (ESidebar *sidebar,
GtkWidget *label_widget;
button_widget = gtk_toggle_button_new ();
+ if (sidebar->priv->show)
+ gtk_widget_show (button_widget);
g_signal_connect (button_widget, "toggled", G_CALLBACK (button_toggled_callback), sidebar);
hbox = gtk_hbox_new (FALSE, 3);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
+ gtk_widget_show (hbox);
+
icon_widget = gtk_image_new_from_pixbuf (icon);
+ gtk_widget_show (icon_widget);
+
label_widget = gtk_label_new (label);
gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (hbox), icon_widget, sidebar->priv->mode == E_SIDEBAR_MODE_ICON, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0);
+ gtk_widget_show (label_widget);
+
+ switch (INTERNAL_MODE (sidebar)) {
+ case E_SIDEBAR_MODE_TEXT:
+ gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0);
+ break;
+ case E_SIDEBAR_MODE_ICON:
+ gtk_box_pack_start (GTK_BOX (hbox), icon_widget, TRUE, TRUE, 0);
+ break;
+ case E_SIDEBAR_MODE_BOTH:
+ default:
+ gtk_box_pack_start (GTK_BOX (hbox), icon_widget, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0);
+ break;
+ }
+
gtk_container_add (GTK_CONTAINER (button_widget), hbox);
sidebar->priv->buttons = g_slist_append (sidebar->priv->buttons, button_new (button_widget, label_widget, icon_widget, hbox, id));
gtk_widget_set_parent (button_widget, GTK_WIDGET (sidebar));
- if (sidebar->priv->mode == E_SIDEBAR_MODE_ICON)
- gtk_container_remove (GTK_CONTAINER (hbox), label_widget);
-
gtk_widget_queue_resize (GTK_WIDGET (sidebar));
}
@@ -490,12 +531,22 @@ e_sidebar_get_mode (ESidebar *sidebar)
return sidebar->priv->mode;
}
-void
-e_sidebar_set_mode (ESidebar *sidebar, ESidebarMode mode)
+
+static GConfEnumStringPair toolbar_styles[] = {
+ { E_SIDEBAR_MODE_TEXT, "text" },
+ { E_SIDEBAR_MODE_ICON, "icons" },
+ { E_SIDEBAR_MODE_BOTH, "both" },
+ { E_SIDEBAR_MODE_BOTH, "both-horiz" },
+ { E_SIDEBAR_MODE_BOTH, "both_horiz" },
+ { -1, NULL }
+};
+
+static void
+set_mode_internal (ESidebar *sidebar, ESidebarMode mode )
{
GSList *p;
-
- if (sidebar->priv->mode == mode)
+
+ if (mode == INTERNAL_MODE (sidebar))
return;
for (p = sidebar->priv->buttons; p != NULL; p = p->next) {
@@ -503,24 +554,121 @@ e_sidebar_set_mode (ESidebar *sidebar, ESidebarMode mode)
switch (mode) {
case E_SIDEBAR_MODE_TEXT:
- gtk_box_pack_start (GTK_BOX (button->hbox), button->label, TRUE, TRUE, 0);
- gtk_container_child_set (GTK_CONTAINER (button->hbox), button->icon,
- "expand", FALSE,
- NULL);
+ gtk_container_remove (GTK_CONTAINER (button->hbox), button->icon);
+ if (INTERNAL_MODE (sidebar) == E_SIDEBAR_MODE_ICON) {
+ gtk_box_pack_start (GTK_BOX (button->hbox), button->label, TRUE, TRUE, 0);
+ gtk_widget_show (button->label);
+ }
break;
case E_SIDEBAR_MODE_ICON:
- gtk_container_remove (GTK_CONTAINER (button->hbox), button->label);
- gtk_container_child_set (GTK_CONTAINER (button->hbox), button->icon,
- "expand", TRUE,
- NULL);
+ gtk_container_remove(GTK_CONTAINER (button->hbox), button->label);
+ if (INTERNAL_MODE (sidebar) == E_SIDEBAR_MODE_TEXT) {
+ gtk_box_pack_start (GTK_BOX (button->hbox), button->icon, TRUE, TRUE, 0);
+ gtk_widget_show (button->icon);
+ } else
+ gtk_container_child_set (GTK_CONTAINER (button->hbox), button->icon,
+ "expand", TRUE,
+ NULL);
+ break;
+ case E_SIDEBAR_MODE_BOTH:
+ if (INTERNAL_MODE (sidebar) == E_SIDEBAR_MODE_TEXT) {
+ gtk_container_remove (GTK_CONTAINER (button->hbox), button->label);
+ gtk_box_pack_start (GTK_BOX (button->hbox), button->icon, FALSE, TRUE, 0);
+ gtk_widget_show (button->icon);
+ } else {
+ gtk_container_child_set (GTK_CONTAINER (button->hbox), button->icon,
+ "expand", FALSE,
+ NULL);
+ }
+
+ gtk_box_pack_start (GTK_BOX (button->hbox), button->label, TRUE, TRUE, 0);
+ gtk_widget_show (button->label);
break;
default:
- g_assert_not_reached ();
- return;
+ break;
}
}
+}
+
+static void
+style_changed_notify (GConfClient *gconf, guint id, GConfEntry *entry, void *data)
+{
+ ESidebar *sidebar = data;
+ char *val;
+ int mode;
+
+ val = gconf_client_get_string (gconf, "/desktop/gnome/interface/toolbar_style", NULL);
+ if (val == NULL || !gconf_string_to_enum (toolbar_styles, val, &mode))
+ mode = E_SIDEBAR_MODE_BOTH;
+ g_free(val);
+
+ set_mode_internal (E_SIDEBAR (sidebar), mode);
+ sidebar->priv->toolbar_mode = mode;
+
+ gtk_widget_queue_resize (GTK_WIDGET (sidebar));
+}
+
+void
+e_sidebar_set_mode (ESidebar *sidebar, ESidebarMode mode)
+{
+ GConfClient *gconf_client = gconf_client_get_default ();
+
+ if (sidebar->priv->mode == mode)
+ return;
+
+ if (sidebar->priv->mode == E_SIDEBAR_MODE_TOOLBAR) {
+ if (sidebar->priv->style_changed_id) {
+ gconf_client_notify_remove (gconf_client, sidebar->priv->style_changed_id);
+ sidebar->priv->style_changed_id = 0;
+ }
+ }
+
+ if (mode != E_SIDEBAR_MODE_TOOLBAR) {
+ set_mode_internal (sidebar, mode);
+
+ gtk_widget_queue_resize (GTK_WIDGET (sidebar));
+ } else {
+ /* This is a little bit tricky, toolbar mode is more
+ * of a meta-mode where the actual mode is dictated by
+ * the gnome toolbar setting, so that is why we have
+ * the is_toolbar_mode bool - it tracks the toolbar
+ * mode while the mode member is the actual look and
+ * feel */
+ sidebar->priv->style_changed_id = gconf_client_notify_add (gconf_client,
+ "/desktop/gnome/interface/toolbar_style",
+ style_changed_notify, sidebar, NULL, NULL);
+ style_changed_notify (gconf_client, 0, NULL, sidebar);
+ }
+
+ g_object_unref (gconf_client);
sidebar->priv->mode = mode;
+}
+
+void
+e_sidebar_set_show_buttons (ESidebar *sidebar, gboolean show)
+{
+ GSList *p;
+
+ if (sidebar->priv->show == show)
+ return;
+
+ for (p = sidebar->priv->buttons; p != NULL; p = p->next) {
+ Button *button = p->data;
+
+ if (show)
+ gtk_widget_show (button->button_widget);
+ else
+ gtk_widget_hide (button->button_widget);
+ }
+
+ sidebar->priv->show = show;
gtk_widget_queue_resize (GTK_WIDGET (sidebar));
}
+
+gboolean
+e_sidebar_get_show_buttons (ESidebar *sidebar)
+{
+ return sidebar->priv->show;
+}
diff --git a/shell/e-sidebar.h b/shell/e-sidebar.h
index fc4b782c96..873d366b38 100644
--- a/shell/e-sidebar.h
+++ b/shell/e-sidebar.h
@@ -38,7 +38,9 @@ typedef struct _ESidebarClass ESidebarClass;
typedef enum {
E_SIDEBAR_MODE_TEXT,
- E_SIDEBAR_MODE_ICON
+ E_SIDEBAR_MODE_ICON,
+ E_SIDEBAR_MODE_BOTH,
+ E_SIDEBAR_MODE_TOOLBAR
} ESidebarMode;
struct _ESidebar {
@@ -71,5 +73,8 @@ void e_sidebar_select_button (ESidebar *sidebar,
ESidebarMode e_sidebar_get_mode (ESidebar *sidebar);
void e_sidebar_set_mode (ESidebar *sidebar, ESidebarMode mode);
+void e_sidebar_set_show_buttons (ESidebar *sidebar, gboolean show);
+gboolean e_sidebar_get_show_buttons (ESidebar *sidebar);
+
#endif /* _E_SIDEBAR_H_ */