From fb06ffa383cd7f2398ff9332438d78a4921b5fc1 Mon Sep 17 00:00:00 2001 From: Jason Leach Date: Fri, 19 Jan 2001 07:36:55 +0000 Subject: (Bug #883: Shortcut bar does not update when a folders display name 2001-01-17 Jason Leach (Bug #883: Shortcut bar does not update when a folders display name changes) * e-local-storage.c (class_init): Define a new "folder_updated" signal here. (bonobo_interface_update_folder_cb): Emit the new folder_updated signal here. * e-shell-view.c (e_shell_view_construct): Connect the EShell::ELocalStorage folder_updated signal here. Also connect the updated_folder signal coming from EShell::EStorageSet to the new callback. * e-shell-view.c (folder_updated_cb): Callback that actually initiates the shell updating. * e-shortcuts.c (e_shortcuts_update_shortcut_by_uri): New function. Given a uri for a shortcut bar item, we'll update it. * e-shortcuts.c (e_shortcuts_remove_shortcut_by_uri): New function. Given a uri for a shortcut bar item, we'll remove it. * e-shortcuts.c (removed_folder_cb): Connect this callback that will remove a renamed vfolder from the shortcut bar. Temporary fix to the problem of renaming vfolders and having the shortcut bar think the old vfolder still exists. (Bug #1168: Shortcut bar and icon size persistence) * e-shell-view.c (save_shortcut_bar_icon_modes): New static function, save the icon modes (for all shortcut bar groups, even though we only have one group now). (load_shortcut_bar_icon_modes): New static function, load the saved shortcut bar group icon modes and apply them to our shortcut bar. svn path=/trunk/; revision=7639 --- shell/e-shell-view.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) (limited to 'shell/e-shell-view.c') diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index a6aeca1815..0b9a6a13c3 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -129,6 +129,9 @@ static guint signals[LAST_SIGNAL] = { 0 }; #define DEFAULT_URI "evolution:/local/Inbox" +static void update_for_current_uri (EShellView *shell_view); +static const char * get_storage_set_path_from_uri (const char *uri); + /* Utility functions. */ @@ -884,6 +887,38 @@ unmerge_on_error (BonoboObject *object, win, cobject); } +static void +folder_updated_cb (EStorage *storage, + const char *path, + void *data) +{ + EShellView *shell_view; + EShellViewPrivate *priv; + char *full_path; + char *uri; + + shell_view = E_SHELL_VIEW (data); + priv = shell_view->priv; + + /* Build the URI from the @path we're given */ + if (! g_path_is_absolute (path)) + full_path = g_strconcat (G_DIR_SEPARATOR_S, e_storage_get_name (storage), + G_DIR_SEPARATOR_S, path, NULL); + else + full_path = g_strconcat (G_DIR_SEPARATOR_S, e_storage_get_name (storage), + path, NULL); + + uri = g_strconcat (E_SHELL_URI_PREFIX, full_path, NULL); + g_free (full_path); + + /* Update the shortcut bar */ + e_shortcuts_update_shortcut_by_uri (e_shell_get_shortcuts (priv->shell), uri); + g_free (uri); + + /* Update the folder title bar and the window title bar */ + update_for_current_uri (shell_view); +} + EShellView * e_shell_view_construct (EShellView *shell_view, @@ -915,6 +950,11 @@ e_shell_view_construct (EShellView *shell_view, priv->shell = shell; + gtk_signal_connect (GTK_OBJECT (e_shell_get_local_storage (priv->shell)), "folder_updated", + folder_updated_cb, shell_view); + gtk_signal_connect (GTK_OBJECT (e_shell_get_storage_set (priv->shell)), "updated_folder", + folder_updated_cb, shell_view); + container = bonobo_ui_container_new (); bonobo_ui_container_set_win (container, BONOBO_WINDOW (shell_view)); gtk_signal_connect (GTK_OBJECT (container), "system_exception", @@ -1662,6 +1702,53 @@ e_shell_view_get_current_uri (EShellView *shell_view) return shell_view->priv->uri; } +static void +save_shortcut_bar_icon_modes (EShellView *shell_view) +{ + EShellViewPrivate *priv; + EShortcutBar *shortcut_bar; + int num_groups; + int group; + + priv = shell_view->priv; + shortcut_bar = E_SHORTCUT_BAR (priv->shortcut_bar); + + num_groups = e_shortcut_model_get_num_groups (shortcut_bar->model); + + for (group = 0; group < num_groups; group++) { + char *tmp; + + tmp = g_strdup_printf ("ShortcutBarGroup%dIconMode", group); + gnome_config_set_int (tmp, e_shortcut_bar_get_view_type (shortcut_bar, group)); + g_free (tmp); + } +} + +static void +load_shortcut_bar_icon_modes (EShellView *shell_view) +{ + EShellViewPrivate *priv; + EShortcutBar *shortcut_bar; + int num_groups; + int group; + + priv = shell_view->priv; + shortcut_bar = E_SHORTCUT_BAR (priv->shortcut_bar); + + num_groups = e_shortcut_model_get_num_groups (shortcut_bar->model); + + for (group = 0; group < num_groups; group++) { + char *tmp; + int iconmode; + + tmp = g_strdup_printf ("ShortcutBarGroup%dIconMode", group); + iconmode = gnome_config_get_int (tmp); + g_free (tmp); + + e_shortcut_bar_set_view_type (shortcut_bar, group, iconmode); + } +} + /** * e_shell_view_save_settings: @@ -1698,6 +1785,8 @@ e_shell_view_save_settings (EShellView *shell_view, else gnome_config_set_string ("DisplayedURI", DEFAULT_URI); + save_shortcut_bar_icon_modes (shell_view); + gnome_config_pop_prefix (); return TRUE; @@ -1745,6 +1834,8 @@ e_shell_view_load_settings (EShellView *shell_view, e_shell_view_display_uri (shell_view, DEFAULT_URI); g_free (stringval); + load_shortcut_bar_icon_modes (shell_view); + gnome_config_pop_prefix (); return TRUE; -- cgit v1.2.3