+ set_action_sensitive (ev_window, "GoPreviousPage", page > 0);
+ set_action_sensitive (ev_window, "GoNextPage", page < n_pages - 1);
+ set_action_sensitive (ev_window, "GoFirstPage", page > 0);
+ set_action_sensitive (ev_window, "GoLastPage", page < n_pages - 1);
+ } else {
+ set_action_sensitive (ev_window, "GoFirstPage", FALSE);
+ set_action_sensitive (ev_window, "GoPreviousPage", FALSE);
+ set_action_sensitive (ev_window, "GoNextPage", FALSE);
+ set_action_sensitive (ev_window, "GoLastPage", FALSE);
+ }
+
+ /* Toolbar-specific actions: */
+ set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
+ set_action_sensitive (ev_window, ZOOM_CONTROL_ACTION, has_pages);
+
+ if (has_pages && ev_view_get_sizing_mode (view) == EV_SIZING_FREE) {
+ GtkAction *action;
+ float zoom;
+ float real_zoom;
+
+ action = gtk_action_group_get_action (ev_window->priv->action_group,
+ ZOOM_CONTROL_ACTION);
+
+ real_zoom = ev_view_get_zoom (EV_VIEW (ev_window->priv->view));
+ zoom = ephy_zoom_get_nearest_zoom_level (real_zoom);
+
+ ephy_zoom_action_set_zoom_level (EPHY_ZOOM_ACTION (action), zoom);
+ }
+}
+
+static void
+set_widget_visibility (GtkWidget *widget, gboolean visible)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ if (visible)
+ gtk_widget_show (widget);
+ else
+ gtk_widget_hide (widget);
+}
+
+static void
+update_chrome_visibility (EvWindow *window)
+{
+ EvWindowPrivate *priv = window->priv;
+ gboolean menubar, toolbar, sidebar, findbar, statusbar, fullscreen_toolbar;
+ gboolean fullscreen_mode, presentation, fullscreen;
+
+ presentation = ev_view_get_presentation (EV_VIEW (priv->view));
+ fullscreen = ev_view_get_fullscreen (EV_VIEW (priv->view));
+ fullscreen_mode = fullscreen || presentation;
+
+ menubar = (priv->chrome & EV_CHROME_MENUBAR) != 0 && !fullscreen_mode;
+ toolbar = (priv->chrome & EV_CHROME_TOOLBAR) != 0 && !fullscreen_mode;
+ sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !fullscreen_mode;
+ fullscreen_toolbar = (priv->chrome & EV_CHROME_TOOLBAR) != 0;
+ statusbar = (priv->chrome & EV_CHROME_STATUSBAR) != 0 && !fullscreen_mode;
+ findbar = (priv->chrome & EV_CHROME_FINDBAR) != 0;
+
+ set_widget_visibility (priv->menubar, menubar);
+
+ set_widget_visibility (priv->toolbar_dock, toolbar);
+ set_action_sensitive (window, "EditToolbar", toolbar);
+
+ set_widget_visibility (priv->sidebar, sidebar);
+ set_widget_visibility (priv->find_bar, findbar);
+ set_widget_visibility (priv->statusbar, statusbar);
+ set_widget_visibility (priv->fullscreen_toolbar, fullscreen_toolbar);
+
+ if (priv->fullscreen_popup != NULL) {
+ if (fullscreen)
+ show_fullscreen_popup (window);
+ else
+ set_widget_visibility (priv->fullscreen_popup, FALSE);
+ }
+}
+
+static void
+update_chrome_flag (EvWindow *window, EvChrome flag, const char *pref, gboolean active)
+{
+ EvWindowPrivate *priv = window->priv;
+ GConfClient *client;
+
+ if (active) {
+ priv->chrome |= flag;
+ }
+ else {
+ priv->chrome &= ~flag;
+ }
+
+ if (pref != NULL) {
+ client = gconf_client_get_default ();
+ gconf_client_set_bool (client, pref, active, NULL);
+ g_object_unref (client);
+ }
+
+ update_chrome_visibility (window);
+}
+
+static void
+ev_window_cmd_focus_page_selector (GtkAction *act, EvWindow *window)
+{
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ PAGE_SELECTOR_ACTION);
+ ev_page_action_grab_focus (EV_PAGE_ACTION (action));
+}
+
+static void
+ev_window_cmd_scroll_forward (GtkAction *action, EvWindow *window)
+{
+ ev_view_scroll (EV_VIEW (window->priv->view), EV_SCROLL_PAGE_FORWARD);
+}
+
+static void
+ev_window_cmd_scroll_backward (GtkAction *action, EvWindow *window)
+{
+ ev_view_scroll (EV_VIEW (window->priv->view), EV_SCROLL_PAGE_BACKWARD);
+}
+
+static void
+ev_window_cmd_continuous (GtkAction *action, EvWindow *ev_window)
+{
+ gboolean continuous;
+
+ ev_window_stop_presentation (ev_window);
+ continuous = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ g_object_set (G_OBJECT (ev_window->priv->view),
+ "continuous", continuous,
+ NULL);
+ update_action_sensitivity (ev_window);
+}
+
+static void
+ev_window_cmd_dual (GtkAction *action, EvWindow *ev_window)
+{
+ gboolean dual_page;
+
+ ev_window_stop_presentation (ev_window);
+ dual_page = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ g_object_set (G_OBJECT (ev_window->priv->view),
+ "dual-page", dual_page,
+ NULL);
+ update_action_sensitivity (ev_window);
+}