#include "ev-navigation-action.h"
#include "ev-page-action.h"
#include "ev-sidebar.h"
-#include "ev-sidebar-bookmarks.h"
+#include "ev-sidebar-links.h"
#include "ev-sidebar-thumbnails.h"
#include "ev-view.h"
#include "ev-print-job.h"
GtkUIManager *ui_manager;
GtkWidget *statusbar;
guint help_message_cid;
+ guint view_message_cid;
GtkWidget *exit_fullscreen_popup;
char *uri;
- GtkAction *page_action;
EvDocument *document;
gboolean fullscreen_mode;
};
+#define NAVIGATION_BACK_ACTION "NavigationBack"
+#define NAVIGATION_FORWARD_ACTION "NavigationForward"
+#define PAGE_SELECTOR_ACTION "PageSelector"
+
#if 0
/* enable these to add support for signals */
static guint ev_window_signals [N_SIGNALS] = { 0 };
static void
update_action_sensitivity (EvWindow *ev_window)
{
- int n_pages;
- int page;
+ 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, "FilePrint", document!=NULL);
+ /* "FileCloseWindow": always sensitive */
+
+ /* Edit menu */
+ set_action_sensitive (ev_window, "EditCopy", document!=NULL);
+ set_action_sensitive (ev_window, "EditSelectAll", document!=NULL);
- if (ev_window->priv->document)
- n_pages = ev_document_get_n_pages (ev_window->priv->document);
+ if (document)
+ set_action_sensitive (ev_window, "EditFind", EV_IS_DOCUMENT_FIND (document));
else
- n_pages = 1;
+ set_action_sensitive (ev_window, "EditFind", FALSE);
- page = ev_view_get_page (EV_VIEW (ev_window->priv->view));
+ /* View menu */
+ set_action_sensitive (ev_window, "ViewZoomIn", document!=NULL);
+ set_action_sensitive (ev_window, "ViewZoomOut", document!=NULL);
+ set_action_sensitive (ev_window, "ViewNormalSize", document!=NULL);
+ set_action_sensitive (ev_window, "ViewBestFit", 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;
+
+ page = ev_view_get_page (EV_VIEW (ev_window->priv->view));
+ n_pages = ev_document_get_n_pages (document);
+
+ set_action_sensitive (ev_window, "GoPageDown", page > 1);
+ set_action_sensitive (ev_window, "GoPageUp", page < n_pages);
+ set_action_sensitive (ev_window, "GoFirstPage", page > 1);
+ set_action_sensitive (ev_window, "GoLastPage", page < n_pages);
+ } else {
+ set_action_sensitive (ev_window, "GoFirstPage", FALSE);
+ set_action_sensitive (ev_window, "GoPageDown", FALSE);
+ set_action_sensitive (ev_window, "GoPageUp", FALSE);
+ set_action_sensitive (ev_window, "GoLastPage", FALSE);
+ }
+
+ /* Help menu */
+ /* "HelpContents": always sensitive */
+ /* "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);
+}
- set_action_sensitive (ev_window, "GoFirstPage", page > 1);
- set_action_sensitive (ev_window, "GoPageDown", page > 1);
- set_action_sensitive (ev_window, "GoPageUp", page < n_pages);
- set_action_sensitive (ev_window, "GoLastPage", page < n_pages);
+void
+ev_window_open_link (EvWindow *ev_window, EvLink *link)
+{
+ ev_view_go_to_link (EV_VIEW (ev_window->priv->view), link);
}
gboolean
static void
update_total_pages (EvWindow *ev_window)
{
- EvPageAction *page_action;
+ GtkAction *action;
int pages;
pages = ev_document_get_n_pages (ev_window->priv->document);
- page_action = EV_PAGE_ACTION (ev_window->priv->page_action);
- ev_page_action_set_total_pages (page_action, pages);
+ action = gtk_action_group_get_action
+ (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
+ ev_page_action_set_total_pages (EV_PAGE_ACTION (action), pages);
}
void
ev_window, 0);
if (ev_document_load (document, uri, &error)) {
+ EvHistory *history;
+ EvView *view = EV_VIEW (ev_window->priv->view);
+ EvSidebar *sidebar = EV_SIDEBAR (ev_window->priv->sidebar);
+ GtkAction *action;
+
if (ev_window->priv->document)
g_object_unref (ev_window->priv->document);
ev_window->priv->document = document;
- ev_view_set_document (EV_VIEW (ev_window->priv->view),
- document);
- ev_sidebar_set_document (EV_SIDEBAR (ev_window->priv->sidebar),
- document);
+ ev_view_set_document (view, document);
+ ev_sidebar_set_document (sidebar, 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_total_pages (ev_window);
update_action_sensitivity (ev_window);
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
- /* FIXME */
+ ev_view_go_back (EV_VIEW (ev_window->priv->view));
}
static void
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
- /* FIXME */
+ ev_view_go_forward (EV_VIEW (ev_window->priv->view));
}
static void
static void
update_current_page (EvWindow *ev_window)
{
- EvPageAction *page_action;
int page;
+ GtkAction *action;
+
+ action = gtk_action_group_get_action
+ (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
page = ev_view_get_page (EV_VIEW (ev_window->priv->view));
- page_action = EV_PAGE_ACTION (ev_window->priv->page_action);
- ev_page_action_set_current_page (page_action, page);
+ ev_page_action_set_current_page (EV_PAGE_ACTION (action), page);
}
static void
}
static void
-view_find_status_changed_cb (EvView *view,
- EvWindow *ev_window)
+view_status_changed_cb (EvView *view,
+ GParamSpec *pspec,
+ EvWindow *ev_window)
{
- char *text;
+ const char *message;
+
+ gtk_statusbar_pop (GTK_STATUSBAR (ev_window->priv->statusbar),
+ ev_window->priv->view_message_cid);
- text = ev_view_get_find_status_message (view);
+ message = ev_view_get_status (view);
+ if (message) {
+ gtk_statusbar_push (GTK_STATUSBAR (ev_window->priv->statusbar),
+ ev_window->priv->view_message_cid, message);
+ }
+}
+
+static void
+view_find_status_changed_cb (EvView *view,
+ GParamSpec *pspec,
+ EvWindow *ev_window)
+{
+ const char *text;
+ text = ev_view_get_find_status (view);
egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar),
text);
-
- g_free (text);
}
static void
static void
goto_page_cb (GtkAction *action, int page_number, EvWindow *ev_window)
{
+ EvView *view = EV_VIEW (ev_window->priv->view);
- ev_view_set_page (EV_VIEW (ev_window->priv->view), page_number);
+ if (ev_view_get_page (view) != page_number) {
+ ev_view_set_page (view, page_number);
+ }
}
static void
GtkAction *action;
action = g_object_new (EV_TYPE_NAVIGATION_ACTION,
- "name", "NavigationBack",
+ "name", NAVIGATION_BACK_ACTION,
"label", _("Back"),
"stock_id", GTK_STOCK_GO_BACK,
"tooltip", _("Go back"),
"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", "NavigationForward",
+ "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", "PageSelector",
+ "name", PAGE_SELECTOR_ACTION,
"label", _("Page"),
"tooltip", _("Select Page"),
NULL);
g_signal_connect (action, "goto_page",
G_CALLBACK (goto_page_cb), window);
- window->priv->page_action = action;
gtk_action_group_add_action (group, action);
g_object_unref (action);
}
ev_window->priv->sidebar);
/* Stub sidebar, for now */
- sidebar_widget = ev_sidebar_bookmarks_new ();
+ sidebar_widget = ev_sidebar_links_new ();
gtk_widget_show (sidebar_widget);
ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
- "bookmarks",
- _("Bookmarks"),
+ "index",
+ _("Index"),
sidebar_widget);
sidebar_widget = ev_sidebar_thumbnails_new ();
G_CALLBACK (view_page_changed_cb),
ev_window);
g_signal_connect (ev_window->priv->view,
- "find-status-changed",
+ "notify::find-status",
G_CALLBACK (view_find_status_changed_cb),
ev_window);
-
+ g_signal_connect (ev_window->priv->view,
+ "notify::status",
+ G_CALLBACK (view_status_changed_cb),
+ ev_window);
+
ev_window->priv->statusbar = gtk_statusbar_new ();
gtk_widget_show (ev_window->priv->statusbar);
gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
FALSE, TRUE, 0);
ev_window->priv->help_message_cid = gtk_statusbar_get_context_id
(GTK_STATUSBAR (ev_window->priv->statusbar), "help_message");
+ ev_window->priv->view_message_cid = gtk_statusbar_get_context_id
+ (GTK_STATUSBAR (ev_window->priv->statusbar), "view_message");
ev_window->priv->find_bar = egg_find_bar_new ();
gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),