From 846953d493d286b63b3345442834591551c6d338 Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Wed, 2 Jun 2004 20:37:14 +0000 Subject: Add listener for the ViewToolbar command. 2004-06-01 William Jon McCann * e-shell-window-commands.c (e_shell_window_commands_setup): Add listener for the ViewToolbar command. (view_toolbar_item_toggled_handler): New function to handle toggling toolbar visibility and saving state. * e-shell-window.c (e_shell_window_save_defaults): Save the status of the toolbar visibility. (setup_widgets): Set initial state of toolbar visibility. * apps_evolution_shell.schemas.in.in: Added schema for toolbar_visible. svn path=/trunk/; revision=26157 --- shell/ChangeLog | 13 +++++++++++++ shell/apps_evolution_shell.schemas.in.in | 12 ++++++++++++ shell/e-shell-window-commands.c | 19 +++++++++++++++++++ shell/e-shell-window.c | 30 ++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+) (limited to 'shell') diff --git a/shell/ChangeLog b/shell/ChangeLog index 03da33a026..11f5f37da6 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,16 @@ +2004-06-01 William Jon McCann + + * e-shell-window-commands.c (e_shell_window_commands_setup): + Add listener for the ViewToolbar command. + (view_toolbar_item_toggled_handler): + New function to handle toggling toolbar visibility and saving state. + + * e-shell-window.c (e_shell_window_save_defaults): + Save the status of the toolbar visibility. + (setup_widgets): Set initial state of toolbar visibility. + + * apps_evolution_shell.schemas.in.in: Added schema for toolbar_visible. + 2004-06-01 Christophe Fergeau * e-shell-importer.c: sort the various available importer plugins by diff --git a/shell/apps_evolution_shell.schemas.in.in b/shell/apps_evolution_shell.schemas.in.in index e71bbb4537..e26cb28717 100644 --- a/shell/apps_evolution_shell.schemas.in.in +++ b/shell/apps_evolution_shell.schemas.in.in @@ -83,6 +83,18 @@ + + /schemas/apps/evolution/shell/view_defaults/toolbar_visible + /apps/evolution/shell/view_defaults/toolbar_visible + evolution + bool + TRUE + + Toolbar is visible + Whether the toolbar should be visible. + + + /schemas/apps/evolution/shell/view_defaults/component_id /apps/evolution/shell/view_defaults/component_id diff --git a/shell/e-shell-window-commands.c b/shell/e-shell-window-commands.c index 35ccb7d40e..b8e067c3d7 100644 --- a/shell/e-shell-window-commands.c +++ b/shell/e-shell-window-commands.c @@ -46,6 +46,7 @@ #include +#include /* Utility functions. */ @@ -608,6 +609,21 @@ shell_line_status_changed_cb (EShell *shell, update_offline_menu_item (shell_window, new_status); } +static void +view_toolbar_item_toggled_handler (BonoboUIComponent *ui_component, + const char *path, + Bonobo_UIComponent_EventType type, + const char *state, + EShellWindow *shell_window) +{ + gboolean is_visible; + + is_visible = state[0] == '1'; + + bonobo_ui_component_set_prop (ui_component, "/Toolbar", + "hidden", is_visible ? "0" : "1", NULL); +} + /* Public API. */ @@ -628,6 +644,9 @@ 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, "ViewToolbar", + (BonoboUIListenerFn)view_toolbar_item_toggled_handler, + (gpointer)shell_window); e_pixmaps_update (uic, pixmaps); diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index 996c151db9..3b7ed348bc 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -574,6 +574,7 @@ setup_widgets (EShellWindow *window) GSList *p; GString *xml; int button_id; + gboolean toolbar_visible; priv->paned = gtk_hpaned_new (); @@ -595,6 +596,20 @@ setup_widgets (EShellWindow *window) 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", + NULL); + bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window), + "/commands/ViewToolbar", + "state", + toolbar_visible ? "1" : "0", + NULL); + bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window), + "/Toolbar", + "hidden", + toolbar_visible ? "0" : "1", + NULL); + button_id = 0; xml = g_string_new(""); for (p = e_component_registry_peek_list (registry); p != NULL; p = p->next) { @@ -862,6 +877,8 @@ void e_shell_window_save_defaults (EShellWindow *window) { GConfClient *client = gconf_client_get_default (); + char *prop; + gboolean toolbar_visible; gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/width", GTK_WIDGET (window)->allocation.width, NULL); @@ -871,6 +888,19 @@ 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); + 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'; + gconf_client_set_bool (client, + "/apps/evolution/shell/view_defaults/toolbar_visible", + toolbar_visible, + NULL); + g_free (prop); + } + g_object_unref (client); } -- cgit v1.2.3