+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_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) {
+ set_widget_visibility (priv->fullscreen_popup, fullscreen);
+ }
+}
+
+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_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);
+}
+
+static void
+ev_window_cmd_view_best_fit (GtkAction *action, EvWindow *ev_window)
+{
+ ev_window_stop_presentation (ev_window);
+
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_BEST_FIT);
+ } else {
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
+ }
+ update_action_sensitivity (ev_window);
+}
+
+static void
+ev_window_cmd_view_page_width (GtkAction *action, EvWindow *ev_window)
+{
+ ev_window_stop_presentation (ev_window);
+
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FIT_WIDTH);
+ } else {
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
+ }
+ update_action_sensitivity (ev_window);
+}
+
+static void
+update_sizing_buttons (EvWindow *window)