EvDocument *document;
EvWindowPageMode page_mode;
EvView *view;
+ gboolean sensitive;
document = ev_window->priv->document;
page_mode = ev_window->priv->page_mode;
/* "FileCloseWindow": always sensitive */
/* Edit menu */
- set_action_sensitive (ev_window, "EditCopy", document!=NULL);
- set_action_sensitive (ev_window, "EditSelectAll", document!=NULL);
+
+ sensitive = document && ev_document_can_get_text (document);
+ set_action_sensitive (ev_window, "EditCopy", sensitive);
+ set_action_sensitive (ev_window, "EditSelectAll", sensitive);
if (document)
set_action_sensitive (ev_window, "EditFind", EV_IS_DOCUMENT_FIND (document));
else
set_action_sensitive (ev_window, "EditFind", FALSE);
+ set_action_sensitive (ev_window, "EditFindNext",
+ ev_view_can_find_next (EV_VIEW (ev_window->priv->view)));
+
/* View menu */
set_action_sensitive (ev_window, "ViewZoomIn", document!=NULL);
set_action_sensitive (ev_window, "ViewZoomOut", document!=NULL);
void
ev_window_open_page (EvWindow *ev_window, int page)
{
- if (ev_window->priv->page_cache)
- ev_page_cache_set_current_page (ev_window->priv->page_cache, page);
+ if (ev_window->priv->page_cache) {
+ page = CLAMP (page, 0, ev_page_cache_get_n_pages (ev_window->priv->page_cache));
+ ev_page_cache_set_current_page (ev_window->priv->page_cache, page);
+ }
}
void
}
+static void
+find_changed_cb (EvDocument *document, int page, EvWindow *ev_window)
+{
+ update_action_sensitivity (ev_window);
+}
+
static void
page_changed_cb (EvPageCache *page_cache,
gint page,
update_action_sensitivity (ev_window);
}
-
static void
ev_window_setup_document (EvWindow *ev_window)
{
"notify::title",
G_CALLBACK (update_window_title),
ev_window, 0);
+ if (EV_IS_DOCUMENT_FIND (document)) {
+ g_signal_connect_object (G_OBJECT (document),
+ "find_changed",
+ G_CALLBACK (find_changed_cb),
+ ev_window, 0);
+ }
ev_window_set_page_mode (ev_window, PAGE_MODE_SINGLE_PAGE);
}
}
+static void
+ev_window_cmd_edit_find_next (GtkAction *action, EvWindow *ev_window)
+{
+ g_return_if_fail (EV_IS_WINDOW (ev_window));
+
+ ev_view_find_next (EV_VIEW (ev_window->priv->view));
+}
+
static void
ev_window_cmd_edit_copy (GtkAction *action, EvWindow *ev_window)
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
-#if 0
- /* FIXME: uncomment when this is written.*/
- page = ev_page_cache_get_page (ev_window->priv->page_cache);
-#else
- page = 1;
-#endif
+ page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
uri = g_strdup (ev_window->priv->uri);
ev_window_open (ev_window, uri);
gtk_window_unfullscreen (GTK_WINDOW (window));
}
+static void
+ev_window_cmd_escape (GtkAction *action, EvWindow *window)
+{
+ GtkWidget *widget;
+
+ widget = gtk_window_get_focus (GTK_WINDOW (window));
+ if (widget && gtk_widget_get_ancestor (widget, EGG_TYPE_FIND_BAR)) {
+ update_chrome_flag (window, EV_CHROME_FINDBAR, NULL, FALSE);
+ } else {
+ gtk_window_unfullscreen (GTK_WINDOW (window));
+ }
+}
+
static void
update_view_size (EvWindow *window)
{
{ "EditFind", GTK_STOCK_FIND, NULL, "<control>F",
N_("Find a word or phrase in the document"),
G_CALLBACK (ev_window_cmd_edit_find) },
+ { "EditFindNext", NULL, N_("Find Ne_xt"), "<control>G",
+ N_("Find next occurrence of the word or phrase"),
+ G_CALLBACK (ev_window_cmd_edit_find_next) },
/* View menu */
{ "ViewZoomIn", GTK_STOCK_ZOOM_IN, NULL, "<control>plus",
G_CALLBACK (ev_window_cmd_help_about) },
/* Toolbar-only */
- { "LeaveFullscreen", EV_STOCK_LEAVE_FULLSCREEN, N_("Leave Fullscreen"), "Escape",
+ { "LeaveFullscreen", EV_STOCK_LEAVE_FULLSCREEN, N_("Leave Fullscreen"), NULL,
N_("Leave fullscreen mode"),
- G_CALLBACK (ev_window_cmd_leave_fullscreen) }
+ G_CALLBACK (ev_window_cmd_leave_fullscreen) },
+
+ { "Escape", NULL, N_("Selection Caret"), "Escape", "",
+ G_CALLBACK (ev_window_cmd_escape) }
};
/* Toggle items */
/*translators: this is the label for toolbar button*/
g_object_set (action, "short_label", _("Previous"), NULL);
g_object_set (action, "is-important", TRUE, NULL);
+
action = gtk_action_group_get_action (action_group, "GoNextPage");
- /*translators: this is the label for toolbar button*/
g_object_set (action, "is-important", TRUE, NULL);
+ /*translators: this is the label for toolbar button*/
g_object_set (action, "short_label", _("Next"), NULL);
+
+ action = gtk_action_group_get_action (action_group, "ViewZoomIn");
+ /*translators: this is the label for toolbar button*/
+ g_object_set (action, "short_label", _("Zoom In"), NULL);
+ action = gtk_action_group_get_action (action_group, "ViewZoomIn");
+
+ action = gtk_action_group_get_action (action_group, "ViewZoomOut");
+ /*translators: this is the label for toolbar button*/
+ g_object_set (action, "short_label", _("Zoom Out"), NULL);
+ action = gtk_action_group_get_action (action_group, "ViewZoomIn");
+
+ action = gtk_action_group_get_action (action_group, "ViewBestFit");
+ /*translators: this is the label for toolbar button*/
+ g_object_set (action, "short_label", _("Best Fit"), NULL);
+ action = gtk_action_group_get_action (action_group, "ViewZoomIn");
+
action = gtk_action_group_get_action (action_group, "ViewPageWidth");
/*translators: this is the label for toolbar button*/
g_object_set (action, "short_label", _("Fit Width"), NULL);
return chrome;
}
+static void
+sidebar_widget_model_set (EvSidebarLinks *ev_sidebar_links,
+ GParamSpec *pspec,
+ EvWindow *ev_window)
+{
+ GtkTreeModel *model;
+ GtkAction *action;
+
+ g_object_get (G_OBJECT (ev_sidebar_links),
+ "model", &model,
+ NULL);
+
+ action = gtk_action_group_get_action (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
+ ev_page_action_set_model (EV_PAGE_ACTION (action), model);
+}
+
static void
ev_window_init (EvWindow *ev_window)
{
/* Stub sidebar, for now */
sidebar_widget = ev_sidebar_links_new ();
+ g_signal_connect (sidebar_widget,
+ "notify::model",
+ G_CALLBACK (sidebar_widget_model_set),
+ ev_window);
gtk_widget_show (sidebar_widget);
ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
"index",