aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shell-view.c
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2002-02-23 02:47:40 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2002-02-23 02:47:40 +0800
commit2dd28d3e915503f147dfd65b1d1627cb781e1dfa (patch)
tree1af8ddc5c1d420eec7736b41569fe52d2346b34e /shell/e-shell-view.c
parent377b087df21d972af184734d57f1ad63772759fd (diff)
downloadgsoc2013-evolution-2dd28d3e915503f147dfd65b1d1627cb781e1dfa.tar.gz
gsoc2013-evolution-2dd28d3e915503f147dfd65b1d1627cb781e1dfa.tar.zst
gsoc2013-evolution-2dd28d3e915503f147dfd65b1d1627cb781e1dfa.zip
[First cut at navigation (i.e. back/forward) buttons.]
* e-shell-view.c: New member `history' in `EShellViewPrivate'. (init): Initialize. (destroy): Unref. (e_shell_view_display_uri): Make it a no-op if the URI is the same as the current one. Also, moved code into `display_uri' and use it. (back_clicked_callback): New, callback for the back button on the folder title bar. (forward_clicked_callback): Likewise for the forward button. * e-history.c: New. * e-history.h: New. svn path=/trunk/; revision=15798
Diffstat (limited to 'shell/e-shell-view.c')
-rw-r--r--shell/e-shell-view.c83
1 files changed, 77 insertions, 6 deletions
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index 3a5ce7c851..66fedd29b1 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -56,6 +56,7 @@
#include "evolution-shell-view.h"
#include "e-gray-bar.h"
+#include "e-history.h"
#include "e-shell-constants.h"
#include "e-shell-folder-title-bar.h"
#include "e-shell-utils.h"
@@ -89,6 +90,9 @@ struct _EShellViewPrivate {
BonoboUIComponent *ui_component;
BonoboUIContainer *ui_container;
+ /* History of visited (evolution:) URIs. */
+ EHistory *history;
+
/* Currently displayed URI. */
char *uri;
@@ -180,6 +184,7 @@ static const char *get_storage_set_path_from_uri (const char *uri);
/* Boo. */
static void new_folder_cb (EStorageSet *storage_set, const char *path, void *data);
+static gboolean display_uri (EShellView *shell_view, const char *uri, gboolean add_to_history);
/* View handling. */
@@ -797,6 +802,47 @@ offline_toggle_clicked_cb (GtkButton *button,
}
+/* More callbacks: navigation buttons handling. */
+
+static void
+back_clicked_callback (EShellFolderTitleBar *title_bar,
+ void *data)
+{
+ EShellView *shell_view;
+ EShellViewPrivate *priv;
+ const char *new_uri;
+
+ shell_view = E_SHELL_VIEW (data);
+ priv = shell_view->priv;
+
+ if (! e_history_has_prev (priv->history))
+ return;
+
+ new_uri = (const char *) e_history_prev (priv->history);
+
+ display_uri (shell_view, new_uri, FALSE);
+}
+
+static void
+forward_clicked_callback (EShellFolderTitleBar *title_bar,
+ void *data)
+{
+ EShellView *shell_view;
+ EShellViewPrivate *priv;
+ const char *new_uri;
+
+ shell_view = E_SHELL_VIEW (data);
+ priv = shell_view->priv;
+
+ if (! e_history_has_next (priv->history))
+ return;
+
+ new_uri = (const char *) e_history_next (priv->history);
+
+ display_uri (shell_view, new_uri, FALSE);
+}
+
+
/* Widget setup. */
static void
@@ -1019,6 +1065,10 @@ setup_widgets (EShellView *shell_view)
priv->folder_title_bar = e_shell_folder_title_bar_new ();
gtk_signal_connect (GTK_OBJECT (priv->folder_title_bar), "title_toggled",
GTK_SIGNAL_FUNC (title_bar_toggled_cb), shell_view);
+ gtk_signal_connect (GTK_OBJECT (priv->folder_title_bar), "back_clicked",
+ GTK_SIGNAL_FUNC (back_clicked_callback), shell_view);
+ gtk_signal_connect (GTK_OBJECT (priv->folder_title_bar), "forward_clicked",
+ GTK_SIGNAL_FUNC (forward_clicked_callback), shell_view);
priv->view_hpaned = e_hpaned_new ();
e_paned_pack1 (E_PANED (priv->view_hpaned), priv->storage_set_view_box, FALSE, FALSE);
@@ -1100,6 +1150,9 @@ destroy (GtkObject *object)
gtk_object_unref (GTK_OBJECT (priv->tooltips));
+ if (priv->history != NULL)
+ gtk_object_unref (GTK_OBJECT (priv->history));
+
if (priv->shell != NULL)
bonobo_object_unref (BONOBO_OBJECT (priv->shell));
@@ -1197,6 +1250,7 @@ init (EShellView *shell_view)
priv->shell = NULL;
priv->corba_interface = NULL;
priv->ui_component = NULL;
+ priv->history = e_history_new ((EHistoryItemFreeFunc) g_free);
priv->uri = NULL;
priv->delayed_selection = NULL;
@@ -1996,19 +2050,23 @@ create_new_view_for_uri (EShellView *shell_view,
return TRUE;
}
-gboolean
-e_shell_view_display_uri (EShellView *shell_view,
- const char *uri)
+static gboolean
+display_uri (EShellView *shell_view,
+ const char *uri,
+ gboolean add_to_history)
{
EShellViewPrivate *priv;
View *view;
gboolean retval;
- g_return_val_if_fail (shell_view != NULL, FALSE);
- g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), FALSE);
-
priv = shell_view->priv;
+ if (uri == NULL && priv->uri == NULL)
+ return TRUE;
+
+ if (priv->uri != NULL && uri != NULL && strcmp (priv->uri, uri) == 0)
+ return TRUE;
+
bonobo_window_freeze (BONOBO_WINDOW (shell_view));
if (uri == NULL) {
@@ -2047,6 +2105,9 @@ e_shell_view_display_uri (EShellView *shell_view,
retval = TRUE;
end:
+ if (add_to_history && retval == TRUE && priv->uri != NULL)
+ e_history_add (priv->history, g_strdup (priv->uri));
+
g_free (priv->set_folder_uri);
priv->set_folder_uri = NULL;
@@ -2068,6 +2129,16 @@ e_shell_view_display_uri (EShellView *shell_view,
return retval;
}
+gboolean
+e_shell_view_display_uri (EShellView *shell_view,
+ const char *uri)
+{
+ g_return_val_if_fail (shell_view != NULL, FALSE);
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), FALSE);
+
+ return display_uri (shell_view, uri, TRUE);
+}
+
void
e_shell_view_show_shortcut_bar (EShellView *shell_view,