aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorJason Leach <jasonleach@usa.net>2001-01-19 15:36:55 +0800
committerJacob Leach <jleach@src.gnome.org>2001-01-19 15:36:55 +0800
commitfb06ffa383cd7f2398ff9332438d78a4921b5fc1 (patch)
tree12c046a50be55304bafb5a7ed577a826e1344ddb /shell
parent788351db0a44bbbb19c2bc4b3962e5abfd001c69 (diff)
downloadgsoc2013-evolution-fb06ffa383cd7f2398ff9332438d78a4921b5fc1.tar
gsoc2013-evolution-fb06ffa383cd7f2398ff9332438d78a4921b5fc1.tar.gz
gsoc2013-evolution-fb06ffa383cd7f2398ff9332438d78a4921b5fc1.tar.bz2
gsoc2013-evolution-fb06ffa383cd7f2398ff9332438d78a4921b5fc1.tar.lz
gsoc2013-evolution-fb06ffa383cd7f2398ff9332438d78a4921b5fc1.tar.xz
gsoc2013-evolution-fb06ffa383cd7f2398ff9332438d78a4921b5fc1.tar.zst
gsoc2013-evolution-fb06ffa383cd7f2398ff9332438d78a4921b5fc1.zip
(Bug #883: Shortcut bar does not update when a folders display name
2001-01-17 Jason Leach <jasonleach@usa.net> (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
Diffstat (limited to 'shell')
-rw-r--r--shell/ChangeLog39
-rw-r--r--shell/e-local-storage.c20
-rw-r--r--shell/e-local-storage.h2
-rw-r--r--shell/e-shell-view.c91
-rw-r--r--shell/e-shell.c17
-rw-r--r--shell/e-shell.h2
-rw-r--r--shell/e-shortcuts.c126
-rw-r--r--shell/e-shortcuts.h15
-rw-r--r--shell/evolution-shell-view.c2
9 files changed, 311 insertions, 3 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 6190823c12..005a55a8fa 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,42 @@
+2001-01-17 Jason Leach <jasonleach@usa.net>
+
+ (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.
+
2001-01-17 Federico Mena Quintero <federico@ximian.com>
* importer/evolution-importer.h: Use "typedef enum { ... } Blah;"
diff --git a/shell/e-local-storage.c b/shell/e-local-storage.c
index a149e21fca..2ab98555da 100644
--- a/shell/e-local-storage.c
+++ b/shell/e-local-storage.c
@@ -69,6 +69,13 @@ struct _ELocalStoragePrivate {
EvolutionLocalStorage *bonobo_interface;
};
+enum {
+ FOLDER_UPDATED,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
/* Utility functions. */
@@ -548,6 +555,8 @@ bonobo_interface_update_folder_cb (EvolutionLocalStorage *bonobo_local_storage,
e_folder_set_name (folder, display_name);
e_folder_set_highlighted (folder, highlighted);
+
+ gtk_signal_emit (GTK_OBJECT (local_storage), signals[FOLDER_UPDATED], path);
}
@@ -568,6 +577,17 @@ class_init (ELocalStorageClass *class)
storage_class->get_name = impl_get_name;
storage_class->async_create_folder = impl_async_create_folder;
storage_class->async_remove_folder = impl_async_remove_folder;
+
+ signals[FOLDER_UPDATED] =
+ gtk_signal_new ("folder_updated",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (ELocalStorageClass, folder_updated),
+ gtk_marshal_NONE__STRING,
+ GTK_TYPE_NONE, 1,
+ GTK_TYPE_STRING);
+
+ gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
}
static void
diff --git a/shell/e-local-storage.h b/shell/e-local-storage.h
index a7cb520ba1..8b1d6f2846 100644
--- a/shell/e-local-storage.h
+++ b/shell/e-local-storage.h
@@ -54,6 +54,8 @@ struct _ELocalStorage {
struct _ELocalStorageClass {
EStorageClass parent_class;
+
+ void (* folder_updated) (ELocalStorage *local_storage, const char *path);
};
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;
diff --git a/shell/e-shell.c b/shell/e-shell.c
index 95556a4528..fec2a2febd 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -911,6 +911,23 @@ e_shell_get_folder_type_registry (EShell *shell)
return shell->priv->folder_type_registry;
}
+/**
+ * e_shell_get_local_storage:
+ * @shell: An EShell object.
+ *
+ * Get the local storage associated to @shell.
+ *
+ * Return value: A pointer to the ELocalStorage associated to @shell.
+ **/
+ELocalStorage *
+e_shell_get_local_storage (EShell *shell)
+{
+ g_return_val_if_fail (shell != NULL, NULL);
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+
+ return shell->priv->local_storage;
+}
+
static gboolean
save_settings_for_views (EShell *shell)
diff --git a/shell/e-shell.h b/shell/e-shell.h
index bb8a2cb5a3..ec2f8a7fb1 100644
--- a/shell/e-shell.h
+++ b/shell/e-shell.h
@@ -44,6 +44,7 @@ typedef struct _EShellClass EShellClass;
#include "Evolution.h"
#include "e-shortcuts.h"
#include "e-shell-view.h"
+#include "e-local-storage.h"
#define E_TYPE_SHELL (e_shell_get_type ())
@@ -85,6 +86,7 @@ EShellView *e_shell_new_view (EShell *shell,
const char *e_shell_get_local_directory (EShell *shell);
EShortcuts *e_shell_get_shortcuts (EShell *shell);
EStorageSet *e_shell_get_storage_set (EShell *shell);
+ELocalStorage *e_shell_get_local_storage (EShell *shell);
EFolderTypeRegistry *e_shell_get_folder_type_registry (EShell *shell);
gboolean e_shell_save_settings (EShell *shell);
diff --git a/shell/e-shortcuts.c b/shell/e-shortcuts.c
index 4719f3965c..63d9480f00 100644
--- a/shell/e-shortcuts.c
+++ b/shell/e-shortcuts.c
@@ -58,6 +58,7 @@
#include "e-shortcuts-view.h"
#include "e-shortcuts.h"
+#include "e-shell-constants.h"
#define PARENT_TYPE GTK_TYPE_OBJECT
@@ -312,6 +313,22 @@ make_dirty (EShortcuts *shortcuts)
schedule_idle (shortcuts);
}
+/* Signal handlers for the storage set */
+static void
+removed_folder_cb (EStorageSet *storage_set,
+ const char *path,
+ void *data)
+{
+ EShortcuts *shortcuts;
+ char *tmp;
+
+ shortcuts = E_SHORTCUTS (data);
+
+ tmp = g_strconcat (E_SHELL_URI_PREFIX, path, NULL);
+ e_shortcuts_remove_shortcut_by_uri (shortcuts, tmp);
+ g_free (tmp);
+}
+
/* Signal handlers for the views. */
@@ -454,6 +471,9 @@ e_shortcuts_construct (EShortcuts *shortcuts,
gtk_object_ref (GTK_OBJECT (storage_set));
priv->storage_set = storage_set;
+ gtk_signal_connect (GTK_OBJECT (priv->storage_set), "removed_folder",
+ removed_folder_cb, shortcuts);
+
gtk_object_ref (GTK_OBJECT (folder_type_registry));
priv->folder_type_registry = folder_type_registry;
}
@@ -708,6 +728,112 @@ e_shortcuts_add_shortcut (EShortcuts *shortcuts,
}
void
+e_shortcuts_update_shortcut (EShortcuts *shortcuts,
+ int group_num,
+ int num,
+ const char *uri)
+{
+ g_return_if_fail (shortcuts != NULL);
+ g_return_if_fail (E_IS_SHORTCUTS (shortcuts));
+
+ /* FIXME: need support in e-shortcut-bar widget (and also
+ e-icon-bar) to be able to "update" a shortcut without doing
+ this lame remove then add */
+
+ e_shortcuts_remove_shortcut (shortcuts, group_num, num);
+ e_shortcuts_add_shortcut (shortcuts, group_num, num, uri);
+}
+
+
+/* The shortcuts_by_uri functions */
+
+
+typedef struct {
+ int group_num;
+ int num;
+} EShortcutPosition;
+
+static GList *
+find_positions_by_uri (EShortcuts *shortcuts,
+ const char *uri)
+{
+ EShortcutsPrivate *priv;
+ GList *p = NULL, *q = NULL;
+ GList *retval = NULL;
+ int group_num = 0, num = 0;
+
+ priv = shortcuts->priv;
+
+ for (p = priv->groups; p != NULL; p = p->next) {
+ ShortcutGroup *group;
+
+ group = (ShortcutGroup *) p->data;
+
+ for (q = group->shortcuts; q != NULL; q = q->next) {
+ char *listeduri = q->data;
+
+ if (!strcmp (uri, listeduri)) {
+ EShortcutPosition *position;
+
+ position = g_new (EShortcutPosition, 1);
+ position->group_num = group_num;
+ position->num = num;
+
+ retval = g_list_append (retval, position);
+ }
+ num++;
+ }
+
+ group_num++;
+ num = 0;
+ }
+
+ return g_list_first (retval);
+}
+
+void
+e_shortcuts_remove_shortcut_by_uri (EShortcuts *shortcuts,
+ const char *uri)
+{
+ GList *items = NULL;
+
+ items = find_positions_by_uri (shortcuts, uri);
+
+ while (items) {
+ EShortcutPosition *pos = (EShortcutPosition *) items->data;
+
+ if (pos) {
+ e_shortcuts_remove_shortcut (shortcuts, pos->group_num, pos->num);
+ g_free (pos);
+ }
+ items = g_list_next (items);
+ }
+ g_list_free (items);
+}
+
+void
+e_shortcuts_update_shortcut_by_uri (EShortcuts *shortcuts,
+ const char *uri)
+{
+ GList *items = NULL;
+
+ items = find_positions_by_uri (shortcuts, uri);
+
+ while (items) {
+ EShortcutPosition *pos = (EShortcutPosition *) items->data;
+
+ if (pos) {
+ e_shortcuts_update_shortcut (shortcuts,
+ pos->group_num, pos->num,
+ uri);
+ g_free (pos);
+ }
+ items = g_list_next (items);
+ }
+ g_list_free (items);
+}
+
+void
e_shortcuts_remove_group (EShortcuts *shortcuts,
int group_num)
{
diff --git a/shell/e-shortcuts.h b/shell/e-shortcuts.h
index 8fc5b335da..da544450fb 100644
--- a/shell/e-shortcuts.h
+++ b/shell/e-shortcuts.h
@@ -63,8 +63,9 @@ struct _EShortcutsClass {
void (* new_group) (EShortcuts *shortcuts, int group_num);
void (* remove_group) (EShortcuts *shortcuts, int group_num);
void (* new_shortcut) (EShortcuts *shortcuts, int group_num, int item_num);
- void (* remove_shortcut) (EShortcuts *shortcuts, int group_num, int item_num);}
-;
+ void (* remove_shortcut) (EShortcuts *shortcuts, int group_num, int item_num);
+};
+
GtkType e_shortcuts_get_type (void);
@@ -100,12 +101,22 @@ void e_shortcuts_add_shortcut (EShortcuts *shortcuts
int group_num,
int num,
const char *uri);
+void e_shortcuts_update_shortcut (EShortcuts *shortcuts,
+ int group_num,
+ int num,
+ const char *uri);
void e_shortcuts_remove_group (EShortcuts *shortcuts,
int group_num);
void e_shortcuts_add_group (EShortcuts *shortcuts,
int group_num,
const char *group_name);
+void e_shortcuts_remove_shortcut_by_uri (EShortcuts *shortcuts,
+ const char *uri);
+
+void e_shortcuts_update_shortcut_by_uri (EShortcuts *shortcuts,
+ const char *uri);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/shell/evolution-shell-view.c b/shell/evolution-shell-view.c
index 9e001f6957..53c525a5cb 100644
--- a/shell/evolution-shell-view.c
+++ b/shell/evolution-shell-view.c
@@ -25,7 +25,7 @@
#include <config.h>
#endif
-#include <gnome.h>
+#include <gtk/gtksignal.h>
#include <bonobo.h>
#include <gal/util/e-util.h>