aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2002-02-23 04:55:51 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2002-02-23 04:55:51 +0800
commit51b03dbcdfdc984834867a04792781ad8f073f65 (patch)
treee7a1d41940ae89408eaad53b9f6e40650ebf6b4c /shell
parentd7ea6022c14604e845edef89e61c253804273cba (diff)
downloadgsoc2013-evolution-51b03dbcdfdc984834867a04792781ad8f073f65.tar
gsoc2013-evolution-51b03dbcdfdc984834867a04792781ad8f073f65.tar.gz
gsoc2013-evolution-51b03dbcdfdc984834867a04792781ad8f073f65.tar.bz2
gsoc2013-evolution-51b03dbcdfdc984834867a04792781ad8f073f65.tar.lz
gsoc2013-evolution-51b03dbcdfdc984834867a04792781ad8f073f65.tar.xz
gsoc2013-evolution-51b03dbcdfdc984834867a04792781ad8f073f65.tar.zst
gsoc2013-evolution-51b03dbcdfdc984834867a04792781ad8f073f65.zip
New helper function to remove all the matching URIs from the history.
* e-shell-view.c (remove_uri_from_history): New helper function to remove all the matching URIs from the history. (history_uri_matching_func): Compare function for using e_history_remove_matching. (storage_set_removed_folder_callback): Call `remove_uri_from_history()'. * e-history.c (e_history_remove_matching): New. svn path=/trunk/; revision=15803
Diffstat (limited to 'shell')
-rw-r--r--shell/ChangeLog11
-rw-r--r--shell/e-history.c24
-rw-r--r--shell/e-history.h4
-rw-r--r--shell/e-shell-view.c59
4 files changed, 85 insertions, 13 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index dbeb008ce4..88a3fb8f9e 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,5 +1,16 @@
2002-02-22 Ettore Perazzoli <ettore@ximian.com>
+ * e-shell-view.c (remove_uri_from_history): New helper function to
+ remove all the matching URIs from the history.
+ (history_uri_matching_func): Compare function for using
+ e_history_remove_matching.
+ (storage_set_removed_folder_callback): Call
+ `remove_uri_from_history()'.
+
+ * e-history.c (e_history_remove_matching): New.
+
+2002-02-22 Ettore Perazzoli <ettore@ximian.com>
+
* e-shell-view.c (update_navigation_buttons): New.
(display_uri): Call it before returning so the navigation buttons
always have the right sensitivity.
diff --git a/shell/e-history.c b/shell/e-history.c
index 99579871e1..16df6cfc10 100644
--- a/shell/e-history.c
+++ b/shell/e-history.c
@@ -234,5 +234,29 @@ e_history_add (EHistory *history,
priv->current_item = priv->current_item->next;
}
+void
+e_history_remove_matching (EHistory *history,
+ const void *data,
+ GCompareFunc compare_func)
+{
+ EHistoryPrivate *priv;
+ GList *p;
+
+ g_return_if_fail (history != NULL);
+ g_return_if_fail (E_IS_HISTORY (history));
+ g_return_if_fail (compare_func != NULL);
+
+ priv = history->priv;
+
+ for (p = priv->items; p != NULL; p = p->next) {
+ if ((* compare_func) (data, p->data) == 0) {
+ if (priv->items == priv->current_item)
+ priv->items = priv->current_item = g_list_remove_link (priv->items, p);
+ else
+ priv->items = g_list_remove_link (priv->items, p);
+ }
+ }
+}
+
E_MAKE_TYPE (e_history, "EHistory", EHistory, class_init, init, GTK_TYPE_OBJECT)
diff --git a/shell/e-history.h b/shell/e-history.h
index f2d4efb1fa..d9204441f5 100644
--- a/shell/e-history.h
+++ b/shell/e-history.h
@@ -77,6 +77,10 @@ void *e_history_get_current (EHistory *history);
void e_history_add (EHistory *history,
void *data);
+void e_history_remove_matching (EHistory *history,
+ const void *data,
+ GCompareFunc compare_func);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index 0df938d816..7d369a9037 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -316,6 +316,42 @@ setup_verb_sensitivity_for_folder (EShellView *shell_view,
bonobo_ui_component_set_prop (ui_component, "/commands/RenameFolder", "sensitive", prop, NULL);
}
+
+static void
+update_navigation_buttons (EShellView *shell_view)
+{
+ EShellViewPrivate *priv;
+
+ priv = shell_view->priv;
+
+ e_shell_folder_title_bar_update_navigation_buttons (E_SHELL_FOLDER_TITLE_BAR (priv->folder_title_bar),
+ e_history_has_prev (priv->history),
+ e_history_has_next (priv->history));
+}
+
+static int
+history_uri_matching_func (const void *a,
+ const void *b)
+{
+ const char *s1, *s2;
+
+ s1 = (const char *) a;
+ s2 = (const char *) b;
+
+ return strcmp (s1, s2);
+}
+
+static void
+remove_uri_from_history (EShellView *shell_view,
+ const char *uri)
+{
+ EShellViewPrivate *priv;
+
+ priv = shell_view->priv;
+
+ e_history_remove_matching (priv->history, uri, history_uri_matching_func);
+}
+
/* Callbacks for the EStorageSet. */
@@ -336,7 +372,16 @@ storage_set_removed_folder_callback (EStorageSet *storage_set,
priv = shell_view->priv;
uri = g_strconcat (E_SHELL_URI_PREFIX, path, NULL);
+
+ remove_uri_from_history (shell_view, uri);
+ update_navigation_buttons (shell_view);
+
+ /* (Note that at this point the current URI in the history might have
+ been changed and not match the current view. But we catch this case
+ when checking if this was the current view, below.) */
+
view = g_hash_table_lookup (priv->uri_to_view, uri);
+
g_free (uri);
if (view == NULL)
@@ -802,7 +847,7 @@ offline_toggle_clicked_cb (GtkButton *button,
}
-/* Handling of the navigation buttons. */
+/* Navigation button callbacks. */
static void
back_clicked_callback (EShellFolderTitleBar *title_bar,
@@ -842,18 +887,6 @@ forward_clicked_callback (EShellFolderTitleBar *title_bar,
display_uri (shell_view, new_uri, FALSE);
}
-static void
-update_navigation_buttons (EShellView *shell_view)
-{
- EShellViewPrivate *priv;
-
- priv = shell_view->priv;
-
- e_shell_folder_title_bar_update_navigation_buttons (priv->folder_title_bar,
- e_history_has_prev (priv->history),
- e_history_has_next (priv->history));
-}
-
/* Widget setup. */