+2005-01-27 Marco Pesenti Gritti <marco@gnome.org>
+
+ * data/evince-ui.xml:
+ * shell/Makefile.am:
+ * shell/ev-history.c:
+ * shell/ev-history.h:
+ * shell/ev-navigation-action.c:
+ * shell/ev-navigation-action.h:
+ * shell/ev-view.c: (ev_view_finalize), (ev_view_go_to_link),
+ (ev_view_set_page), (ev_view_fit_width):
+ * shell/ev-view.h:
+ * shell/ev-window.c: (update_action_sensitivity),
+ (ev_window_setup_document), (register_custom_actions):
+
+ Kill session history
+
2005-01-27 Marco Pesenti Gritti <marco@gnome.org>
* shell/ev-window.c: (update_action_sensitivity):
</menu>
<menu name="GoMenu" action="Go">
- <menuitem name="GoBackMenu" action="GoBack"/>
- <menuitem name="GoForwardMenu" action="GoForward"/>
- <separator/>
<menuitem name="GoPageUpMenu" action="GoPageUp"/>
<menuitem name="GoPageDownMenu" action="GoPageDown"/>
<separator/>
</menubar>
<toolbar name="ToolBar">
- <toolitem action="NavigationBack"/>
- <toolitem action="NavigationForward"/>
+ <toolitem action="GoPageDown"/>
+ <toolitem action="GoPageUp"/>
<separator/>
<toolitem action="PageSelector"/>
- <toolitem action="GoPageUp"/>
- <toolitem action="GoPageDown"/>
<separator/>
<toolitem action="ViewZoomIn"/>
<toolitem action="ViewZoomOut"/>
eggfindbar.h \
ev-application.c \
ev-application.h \
- ev-history.c \
- ev-history.h \
ev-marshal.c \
ev-marshal.h \
- ev-navigation-action.c \
- ev-navigation-action.h \
ev-page-action.c \
ev-page-action.h \
ev-password.h \
+++ /dev/null
-/*
- * Copyright (C) 2005 Marco Pesenti Gritti
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- */
-
-#include "config.h"
-
-#include <glib/gi18n.h>
-
-#include "ev-history.h"
-
-struct _EvHistoryPrivate
-{
- GList *links;
- int current_index;
-};
-
-enum {
- PROP_0,
- PROP_INDEX
-};
-
-static void ev_history_init (EvHistory *history);
-static void ev_history_class_init (EvHistoryClass *class);
-
-static GObjectClass *parent_class = NULL;
-
-G_DEFINE_TYPE (EvHistory, ev_history, G_TYPE_OBJECT)
-
-#define EV_HISTORY_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_HISTORY, EvHistoryPrivate))
-
-static void
-ev_history_init (EvHistory *history)
-{
- history->priv = EV_HISTORY_GET_PRIVATE (history);
-
- history->priv->links = NULL;
- history->priv->current_index = -1;
-}
-
-static void
-free_links_list (GList *l)
-{
- g_list_foreach (l, (GFunc)g_object_unref, NULL);
- g_list_free (l);
-}
-
-static void
-ev_history_finalize (GObject *object)
-{
- EvHistory *history = EV_HISTORY (object);
-
- free_links_list (history->priv->links);
-
- parent_class->finalize (object);
-}
-
-static void
-ev_history_get_property (GObject *object, guint prop_id, GValue *value,
- GParamSpec *param_spec)
-{
- EvHistory *self;
-
- self = EV_HISTORY (object);
-
- switch (prop_id) {
- case PROP_INDEX:
- g_value_set_int (value, self->priv->current_index);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
- prop_id,
- param_spec);
- break;
- }
-}
-
-static void
-ev_history_set_property (GObject *object, guint prop_id, const GValue *value,
- GParamSpec *param_spec)
-{
- EvHistory *self;
-
- self = EV_HISTORY (object);
-
- switch (prop_id) {
- case PROP_INDEX:
- ev_history_set_current_index (self, g_value_get_int (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
- prop_id,
- param_spec);
- break;
- }
-}
-
-static void
-ev_history_class_init (EvHistoryClass *class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
-
- object_class->finalize = ev_history_finalize;
- object_class->set_property = ev_history_set_property;
- object_class->get_property = ev_history_get_property;
-
- parent_class = g_type_class_peek_parent (class);
-
- g_object_class_install_property (object_class,
- PROP_INDEX,
- g_param_spec_int ("index",
- "Current Index",
- "The current index",
- -1,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
-
- g_type_class_add_private (object_class, sizeof (EvHistoryPrivate));
-}
-
-void
-ev_history_add_link (EvHistory *history, EvLink *link)
-{
- int length;
-
- g_return_if_fail (EV_IS_HISTORY (history));
- g_return_if_fail (EV_IS_LINK (link));
-
- length = g_list_length (history->priv->links);
- if (history->priv->current_index < length - 1) {
- GList *l = g_list_nth (history->priv->links,
- history->priv->current_index + 1);
-
- if (l->prev) {
- l->prev->next = NULL;
- free_links_list (l);
- } else {
- free_links_list (history->priv->links);
- history->priv->links = NULL;
- }
- }
-
- g_object_ref (link);
- history->priv->links = g_list_append (history->priv->links,
- link);
-
- length = g_list_length (history->priv->links);
- history->priv->current_index = length - 1;
-}
-
-void
-ev_history_add_page (EvHistory *history, int page)
-{
- EvLink *link;
- char *title;
-
- g_return_if_fail (EV_IS_HISTORY (history));
-
- title = g_strdup_printf (_("Page %d"), page);
- link = ev_link_new_page (title, page);
- g_free (title);
-
- ev_history_add_link (history, link);
-}
-
-EvLink *
-ev_history_get_link_nth (EvHistory *history, int index)
-{
- GList *l;
-
- g_return_val_if_fail (EV_IS_HISTORY (history), NULL);
-
- l = g_list_nth (history->priv->links, index);
-
- return EV_LINK (l->data);
-}
-
-int
-ev_history_get_n_links (EvHistory *history)
-{
- g_return_val_if_fail (EV_IS_HISTORY (history), -1);
-
- return g_list_length (history->priv->links);
-}
-
-int
-ev_history_get_current_index (EvHistory *history)
-{
- g_return_val_if_fail (EV_IS_HISTORY (history), -1);
-
- return history->priv->current_index;
-}
-
-void
-ev_history_set_current_index (EvHistory *history, int index)
-{
- g_return_if_fail (EV_IS_HISTORY (history));
-
- history->priv->current_index = index;
-
- g_object_notify (G_OBJECT (history), "index");
-}
-
-EvHistory *
-ev_history_new (void)
-{
- return EV_HISTORY (g_object_new (EV_TYPE_HISTORY, NULL));
-}
+++ /dev/null
-/*
- * Copyright (C) 2005 Marco Pesenti Gritti
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- */
-
-#ifndef EV_HISTORY_H
-#define EV_HISTORY_H
-
-#include <glib-object.h>
-
-#include "ev-link.h"
-
-G_BEGIN_DECLS
-
-#define EV_TYPE_HISTORY (ev_history_get_type ())
-#define EV_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EV_TYPE_HISTORY, EvHistory))
-#define EV_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EV_TYPE_HISTORY, EvHistoryClass))
-#define EV_IS_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EV_TYPE_HISTORY))
-#define EV_IS_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EV_TYPE_HISTORY))
-#define EV_HISTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EV_TYPE_HISTORY, EvHistoryClass))
-
-typedef struct _EvHistory EvHistory;
-typedef struct _EvHistoryPrivate EvHistoryPrivate;
-typedef struct _EvHistoryClass EvHistoryClass;
-
-struct _EvHistory
-{
- GObject parent;
-
- /*< private >*/
- EvHistoryPrivate *priv;
-};
-
-struct _EvHistoryClass
-{
- GObjectClass parent_class;
-};
-
-GType ev_history_get_type (void);
-EvHistory *ev_history_new (void);
-void ev_history_add_link (EvHistory *history,
- EvLink *linkk);
-void ev_history_add_page (EvHistory *history,
- int page);
-EvLink *ev_history_get_link_nth (EvHistory *history,
- int index);
-int ev_history_get_n_links (EvHistory *history);
-int ev_history_get_current_index (EvHistory *history);
-void ev_history_set_current_index (EvHistory *history,
- int index);
-
-G_END_DECLS
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 2003, 2004 Marco Pesenti Gritti
- * Copyright (C) 2003, 2004 Christian Persch
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- */
-
-#include "config.h"
-
-#include "ev-navigation-action.h"
-#include "ev-window.h"
-
-#include <gtk/gtklabel.h>
-#include <gtk/gtkimage.h>
-#include <gtk/gtkmenuitem.h>
-#include <gtk/gtkimagemenuitem.h>
-#include <gtk/gtkmenushell.h>
-#include <gtk/gtkmenu.h>
-#include <gtk/gtkmenutoolbutton.h>
-
-struct _EvNavigationActionPrivate
-{
- EvWindow *window;
- EvNavigationDirection direction;
- char *arrow_tooltip;
- EvHistory *history;
-};
-
-enum
-{
- PROP_0,
- PROP_ARROW_TOOLTIP,
- PROP_DIRECTION
-};
-
-static void ev_navigation_action_init (EvNavigationAction *action);
-static void ev_navigation_action_class_init (EvNavigationActionClass *class);
-
-static GObjectClass *parent_class = NULL;
-
-G_DEFINE_TYPE (EvNavigationAction, ev_navigation_action, GTK_TYPE_ACTION)
-
-#define MAX_LABEL_LENGTH 48
-
-#define EV_NAVIGATION_ACTION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_NAVIGATION_ACTION, EvNavigationActionPrivate))
-
-void
-ev_navigation_action_set_history (EvNavigationAction *action,
- EvHistory *history)
-{
- action->priv->history = history;
-
- g_object_add_weak_pointer (G_OBJECT (action->priv->history),
- (gpointer *) &action->priv->history);
-}
-
-static void
-activate_menu_item_cb (GtkWidget *widget, EvNavigationAction *action)
-{
- int index;
-
- g_return_if_fail (EV_IS_HISTORY (action->priv->history));
-
- index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "index"));
- ev_history_set_current_index (action->priv->history, index);
-}
-
-static GtkWidget *
-new_history_menu_item (EvNavigationAction *action,
- EvLink *link,
- int index)
-{
- GtkLabel *label;
- GtkWidget *item;
- const char *title;
-
- title = ev_link_get_title (link);
- item = gtk_image_menu_item_new_with_label (title);
- g_object_set_data (G_OBJECT (item), "index",
- GINT_TO_POINTER (index));
-
- label = GTK_LABEL (GTK_BIN (item)->child);
- gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END);
- gtk_label_set_max_width_chars (label, MAX_LABEL_LENGTH);
-
- g_signal_connect (item, "activate",
- G_CALLBACK (activate_menu_item_cb),
- action);
-
- gtk_widget_show (item);
-
- return item;
-}
-
-static GtkWidget *
-build_menu (EvNavigationAction *action)
-{
- GtkMenuShell *menu;
- EvHistory *history = action->priv->history;
- int start, end, i;
-
- menu = GTK_MENU_SHELL (gtk_menu_new ());
-
- if (history == NULL) {
- return GTK_WIDGET (menu);
- }
-
- if (action->priv->direction == EV_NAVIGATION_DIRECTION_BACK) {
- start = 0;
- end = ev_history_get_current_index (history);
- } else {
- start = ev_history_get_current_index (history) + 1;
- end = ev_history_get_n_links (history);
- }
-
- for (i = start; i < end; i++) {
- EvLink *link = ev_history_get_link_nth (history, i);
- GtkWidget *item;
-
- item = new_history_menu_item (action, link, i);
- gtk_menu_shell_append (menu, item);
- }
-
- return GTK_WIDGET (menu);
-}
-
-static void
-menu_activated_cb (GtkMenuToolButton *button,
- EvNavigationAction *action)
-{
- GtkWidget *menu;
-
- menu = build_menu (action);
- gtk_menu_tool_button_set_menu (button, menu);
-}
-
-static gboolean
-set_tooltip_cb (GtkMenuToolButton *proxy,
- GtkTooltips *tooltips,
- const char *tip,
- const char *tip_private,
- EvNavigationAction *action)
-{
- gtk_menu_tool_button_set_arrow_tooltip (proxy, tooltips,
- action->priv->arrow_tooltip,
- NULL);
-
- /* don't stop emission */
- return FALSE;
-}
-
-static void
-connect_proxy (GtkAction *action, GtkWidget *proxy)
-{
- if (GTK_IS_MENU_TOOL_BUTTON (proxy))
- {
- GtkWidget *menu;
-
- /* set dummy menu so the arrow gets sensitive */
- menu = gtk_menu_new ();
- gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (proxy), menu);
-
- g_signal_connect (proxy, "show-menu",
- G_CALLBACK (menu_activated_cb), action);
-
- g_signal_connect (proxy, "set-tooltip",
- G_CALLBACK (set_tooltip_cb), action);
- }
-
- GTK_ACTION_CLASS (parent_class)->connect_proxy (action, proxy);
-}
-
-static void
-ev_navigation_action_init (EvNavigationAction *action)
-{
- action->priv = EV_NAVIGATION_ACTION_GET_PRIVATE (action);
-}
-
-static void
-ev_navigation_action_finalize (GObject *object)
-{
- EvNavigationAction *action = EV_NAVIGATION_ACTION (object);
-
- if (action->priv->history) {
- g_object_add_weak_pointer (G_OBJECT (action->priv->history),
- (gpointer *) &action->priv->history);
- }
-
- g_free (action->priv->arrow_tooltip);
-
- parent_class->finalize (object);
-}
-
-static void
-ev_navigation_action_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EvNavigationAction *nav = EV_NAVIGATION_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_ARROW_TOOLTIP:
- nav->priv->arrow_tooltip = g_value_dup_string (value);
- g_object_notify (object, "tooltip");
- break;
- case PROP_DIRECTION:
- nav->priv->direction = g_value_get_int (value);
- break;
- }
-}
-
-static void
-ev_navigation_action_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EvNavigationAction *nav = EV_NAVIGATION_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_ARROW_TOOLTIP:
- g_value_set_string (value, nav->priv->arrow_tooltip);
- break;
- case PROP_DIRECTION:
- g_value_set_int (value, nav->priv->direction);
- break;
- }
-}
-
-static void
-ev_navigation_action_class_init (EvNavigationActionClass *class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
- GtkActionClass *action_class = GTK_ACTION_CLASS (class);
-
- object_class->finalize = ev_navigation_action_finalize;
- object_class->set_property = ev_navigation_action_set_property;
- object_class->get_property = ev_navigation_action_get_property;
-
- parent_class = g_type_class_peek_parent (class);
-
- action_class->toolbar_item_type = GTK_TYPE_MENU_TOOL_BUTTON;
- action_class->connect_proxy = connect_proxy;
-
- g_object_class_install_property (object_class,
- PROP_ARROW_TOOLTIP,
- g_param_spec_string ("arrow-tooltip",
- "Arrow Tooltip",
- "Arrow Tooltip",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_DIRECTION,
- g_param_spec_int ("direction",
- "Direction",
- "Direction",
- 0,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
-
- g_type_class_add_private (object_class, sizeof (EvNavigationActionPrivate));
-}
+++ /dev/null
-/*
- * Copyright (C) 2003, 2004 Marco Pesenti Gritti
- * Copyright (C) 2003, 2004 Christian Persch
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- */
-
-#ifndef EV_NAVIGATION_ACTION_H
-#define EV_NAVIGATION_ACTION_H
-
-#include <gtk/gtkaction.h>
-
-#include "ev-history.h"
-
-G_BEGIN_DECLS
-
-#define EV_TYPE_NAVIGATION_ACTION (ev_navigation_action_get_type ())
-#define EV_NAVIGATION_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EV_TYPE_NAVIGATION_ACTION, EvNavigationAction))
-#define EV_NAVIGATION_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EV_TYPE_NAVIGATION_ACTION, EvNavigationActionClass))
-#define EV_IS_NAVIGATION_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EV_TYPE_NAVIGATION_ACTION))
-#define EV_IS_NAVIGATION_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EV_TYPE_NAVIGATION_ACTION))
-#define EV_NAVIGATION_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EV_TYPE_NAVIGATION_ACTION, EvNavigationActionClass))
-
-typedef struct _EvNavigationAction EvNavigationAction;
-typedef struct _EvNavigationActionPrivate EvNavigationActionPrivate;
-typedef struct _EvNavigationActionClass EvNavigationActionClass;
-
-typedef enum
-{
- EV_NAVIGATION_DIRECTION_BACK,
- EV_NAVIGATION_DIRECTION_FORWARD
-} EvNavigationDirection;
-
-struct _EvNavigationAction
-{
- GtkAction parent;
-
- /*< private >*/
- EvNavigationActionPrivate *priv;
-};
-
-struct _EvNavigationActionClass
-{
- GtkActionClass parent_class;
-};
-
-GType ev_navigation_action_get_type (void);
-void ev_navigation_action_set_history (EvNavigationAction *action,
- EvHistory *history);
-
-G_END_DECLS
-
-#endif
GtkWidget parent_instance;
EvDocument *document;
- EvHistory *history;
GdkWindow *bin_window;
if (view->document)
g_object_unref (view->document);
- if (view->history)
- g_object_unref (view->history);
-
ev_view_set_scroll_adjustments (view, NULL, NULL);
g_array_free (view->find_results, TRUE);
void
ev_view_go_to_link (EvView *view, EvLink *link)
{
- EvLinkType type;
-
go_to_link (view, link);
-
- type = ev_link_get_link_type (link);
- if (type == EV_LINK_TYPE_PAGE) {
- ev_history_add_link (view->history, link);
- }
-}
-
-static void
-go_to_index (EvView *view, int index)
-{
- EvLink *link;
-
- link = ev_history_get_link_nth (view->history, index);
- g_return_if_fail (link != NULL);
-
- go_to_link (view, link);
-}
-
-gboolean
-ev_view_can_go_back (EvView *view)
-{
- int index, n;
-
- if (view->history == NULL) {
- return FALSE;
- }
-
- index = ev_history_get_current_index (view->history);
- n = ev_history_get_n_links (view->history);
-
- if (n > 0) {
- return index != MAX (0, index - 1);
- } else {
- return FALSE;
- }
-}
-
-void
-ev_view_go_back (EvView *view)
-{
- int index, n;
-
- g_return_if_fail (EV_IS_HISTORY (view->history));
-
- index = ev_history_get_current_index (view->history);
- n = ev_history_get_n_links (view->history);
-
- if (n > 0) {
- index = MAX (0, index - 1);
- ev_history_set_current_index (view->history, index);
- }
}
-gboolean
-ev_view_can_go_forward (EvView *view)
-{
- int index, n;
-
- if (view->history == NULL) {
- return FALSE;
- }
-
- index = ev_history_get_current_index (view->history);
- n = ev_history_get_n_links (view->history);
-
- if (n > 0) {
- return index != MIN (n - 1, index + 1);
- } else {
- return FALSE;
- }
-}
-
-void
-ev_view_go_forward (EvView *view)
-{
- int index, n;
-
- g_return_if_fail (EV_IS_HISTORY (view->history));
-
- index = ev_history_get_current_index (view->history);
- n = ev_history_get_n_links (view->history);
-
- if (n > 0) {
- index = MIN (n - 1, index + 1);
- ev_history_set_current_index (view->history, index);
- }
-}
-
-
void
ev_view_set_page (EvView *view,
int page)
{
g_return_if_fail (EV_IS_VIEW (view));
- g_return_if_fail (EV_IS_HISTORY (view->history));
set_document_page (view, page);
- ev_history_add_page (view->history, page);
}
int
ev_view_zoom (view, scale, FALSE);
}
-static void
-history_index_changed_cb (EvHistory *history,
- GParamSpec *pspec,
- EvView *view)
-{
- int index;
-
- index = ev_history_get_current_index (history);
- go_to_index (view, index);
-}
-
-void
-ev_view_set_history (EvView *view,
- EvHistory *history)
-{
- if (view->history) {
- g_object_unref (view->history);
- }
-
- view->history = g_object_ref (history);
- ev_history_add_page (view->history, ev_view_get_page (view));
-
- g_signal_connect (view->history, "notify::index",
- G_CALLBACK (history_index_changed_cb),
- view);
-}
-
const char *
ev_view_get_status (EvView *view)
{
#include "ev-document.h"
#include "ev-link.h"
-#include "ev-history.h"
G_BEGIN_DECLS
GtkWidget* ev_view_new (void);
void ev_view_set_document (EvView *view,
EvDocument *document);
-void ev_view_set_history (EvView *view,
- EvHistory *history);
/* Clipboard */
void ev_view_copy (EvView *view);
#endif
#include "ev-window.h"
-#include "ev-navigation-action.h"
#include "ev-page-action.h"
#include "ev-sidebar.h"
#include "ev-sidebar-links.h"
(G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_WINDOW, EvWindowPrivate))
-#define NAVIGATION_BACK_ACTION "NavigationBack"
-#define NAVIGATION_FORWARD_ACTION "NavigationForward"
#define PAGE_SELECTOR_ACTION "PageSelector"
EvDocument *document;
EvView *view;
- gboolean can_go_back = FALSE;
- gboolean can_go_forward = FALSE;
-
document = ev_window->priv->document;
view = EV_VIEW (ev_window->priv->view);
- if (document) {
- can_go_back = ev_view_can_go_back (view);
- can_go_forward = ev_view_can_go_forward (view);
- }
-
/* File menu */
/* "FileOpen": always sensitive */
set_action_sensitive (ev_window, "FileSaveAs", document!=NULL);
set_action_sensitive (ev_window, "ViewPageWidth", document!=NULL);
/* Go menu */
- set_action_sensitive (ev_window, "GoBack", can_go_back);
- set_action_sensitive (ev_window, "GoForward", can_go_forward);
if (document) {
int n_pages;
int page;
/* "HelpAbout": always sensitive */
/* Toolbar-specific actions: */
- set_action_sensitive (ev_window, NAVIGATION_BACK_ACTION, can_go_back);
- set_action_sensitive (ev_window, NAVIGATION_FORWARD_ACTION, can_go_forward);
set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, document!=NULL);
}
ev_window_setup_document (EvWindow *ev_window)
{
EvDocument *document;
- EvHistory *history;
EvView *view = EV_VIEW (ev_window->priv->view);
EvSidebar *sidebar = EV_SIDEBAR (ev_window->priv->sidebar);
- GtkAction *action;
document = ev_window->priv->document;
ev_sidebar_set_document (sidebar, document);
ev_view_set_document (view, document);
- history = ev_history_new ();
- ev_view_set_history (view, history);
- g_object_unref (history);
-
- action = gtk_action_group_get_action
- (ev_window->priv->action_group, NAVIGATION_BACK_ACTION);
- ev_navigation_action_set_history
- (EV_NAVIGATION_ACTION (action), history);
-
- action = gtk_action_group_get_action
- (ev_window->priv->action_group, NAVIGATION_FORWARD_ACTION);
- ev_navigation_action_set_history
- (EV_NAVIGATION_ACTION (action), history);
-
update_window_title (ev_window->priv->document, NULL, ev_window);
update_total_pages (ev_window);
update_action_sensitivity (ev_window);
ev_view_fit_width (EV_VIEW (ev_window->priv->view));
}
-static void
-ev_window_cmd_go_back (GtkAction *action, EvWindow *ev_window)
-{
- g_return_if_fail (EV_IS_WINDOW (ev_window));
-
- ev_view_go_back (EV_VIEW (ev_window->priv->view));
-}
-
-static void
-ev_window_cmd_go_forward (GtkAction *action, EvWindow *ev_window)
-{
- g_return_if_fail (EV_IS_WINDOW (ev_window));
-
- ev_view_go_forward (EV_VIEW (ev_window->priv->view));
-}
-
static void
ev_window_cmd_go_page_up (GtkAction *action, EvWindow *ev_window)
{
G_CALLBACK (ev_window_cmd_view_page_width) },
/* Go menu */
- { "GoBack", GTK_STOCK_GO_BACK, N_("_Back"), "<mod1>Left",
- N_("Go to the page viewed before this one"),
- G_CALLBACK (ev_window_cmd_go_back) },
- { "GoForward", GTK_STOCK_GO_FORWARD, N_("Fo_rward"), "<mod1>Right",
- N_("Go to the page viewed before this one"),
- G_CALLBACK (ev_window_cmd_go_forward) },
{ "GoPageUp", GTK_STOCK_GO_UP, N_("_Page Up"), "<control>Page_Up",
N_("Go to the previous page"),
G_CALLBACK (ev_window_cmd_go_page_up) },
{
GtkAction *action;
- action = g_object_new (EV_TYPE_NAVIGATION_ACTION,
- "name", NAVIGATION_BACK_ACTION,
- "label", _("Back"),
- "stock_id", GTK_STOCK_GO_BACK,
- "tooltip", _("Go back"),
- "arrow-tooltip", _("Back history"),
- "direction", EV_NAVIGATION_DIRECTION_BACK,
- "is_important", TRUE,
- NULL);
- g_signal_connect (action, "activate",
- G_CALLBACK (ev_window_cmd_go_back), window);
- gtk_action_group_add_action (group, action);
- g_object_unref (action);
-
- action = g_object_new (EV_TYPE_NAVIGATION_ACTION,
- "name", NAVIGATION_FORWARD_ACTION,
- "label", _("Forward"),
- "stock_id", GTK_STOCK_GO_FORWARD,
- "tooltip", _("Go forward"),
- "arrow-tooltip", _("Forward history"),
- "direction", EV_NAVIGATION_DIRECTION_FORWARD,
- NULL);
- g_signal_connect (action, "activate",
- G_CALLBACK (ev_window_cmd_go_forward), window);
- gtk_action_group_add_action (group, action);
- g_object_unref (action);
-
action = g_object_new (EV_TYPE_PAGE_ACTION,
"name", PAGE_SELECTOR_ACTION,
"label", _("Page"),