#include "ev-password.h"
#include "ev-password-view.h"
#include "ev-print-job.h"
+#include "ev-document-thumbnails.h"
+#include "ev-document-links.h"
#include "ev-document-find.h"
#include "ev-document-security.h"
#include "eggfindbar.h"
#include "ev-application.h"
#include "ev-stock-icons.h"
+typedef enum {
+ EV_SIZING_BEST_FIT,
+ EV_SIZING_FIT_WIDTH,
+ EV_SIZING_FREE,
+} EvSizingMode;
+
typedef enum {
PAGE_MODE_SINGLE_PAGE,
PAGE_MODE_CONTINUOUS_PAGE,
#define GCONF_CHROME_STATUSBAR "/apps/evince/show_statusbar"
static void ev_window_update_fullscreen_popup (EvWindow *window);
+static void ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar, GParamSpec *pspec,
+ EvWindow *ev_window);
static void ev_window_set_page_mode (EvWindow *window,
EvWindowPageMode page_mode);
static gboolean start_loading_document (EvWindow *ev_window,
}
static void
-update_sizing_buttons (EvWindow *ev_window)
+ev_window_cmd_view_best_fit (GtkAction *action, EvWindow *ev_window)
+{
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
+ ev_window_set_sizing_mode (ev_window, EV_SIZING_BEST_FIT);
+ } else {
+ ev_window_set_sizing_mode (ev_window, EV_SIZING_FREE);
+ }
+}
+
+static void
+ev_window_cmd_view_page_width (GtkAction *action, EvWindow *ev_window)
{
- GtkWidget *best_fit;
- GtkWidget *fit_width;
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
+ ev_window_set_sizing_mode (ev_window, EV_SIZING_FIT_WIDTH);
+ } else {
+ ev_window_set_sizing_mode (ev_window, EV_SIZING_FREE);
+ }
+}
- best_fit = gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
- "/ToolBar/ViewBestFit");
- fit_width = gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
- "/ToolBar/ViewPageWidth");
+static void
+update_sizing_buttons (EvWindow *window)
+{
+ GtkActionGroup *action_group = window->priv->action_group;
+ GtkAction *action;
+ gboolean best_fit, page_width;
- switch (ev_window->priv->sizing_mode) {
+ switch (window->priv->sizing_mode) {
case EV_SIZING_BEST_FIT:
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (best_fit), TRUE);
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (fit_width), FALSE);
+ best_fit = TRUE;
+ page_width = FALSE;
break;
case EV_SIZING_FIT_WIDTH:
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (best_fit), FALSE);
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (fit_width), TRUE);
+ best_fit = FALSE;
+ page_width = TRUE;
break;
- case EV_SIZING_FREE:
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (best_fit), FALSE);
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (fit_width), FALSE);
+
+ default:
+ best_fit = page_width = FALSE;
break;
}
+
+ action = gtk_action_group_get_action (action_group, "ViewBestFit");
+ g_signal_handlers_block_by_func
+ (action, G_CALLBACK (ev_window_cmd_view_best_fit), window);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), best_fit);
+ g_signal_handlers_unblock_by_func
+ (action, G_CALLBACK (ev_window_cmd_view_best_fit), window);
+
+ action = gtk_action_group_get_action (action_group, "ViewPageWidth");
+ g_signal_handlers_block_by_func
+ (action, G_CALLBACK (ev_window_cmd_view_page_width), window);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), page_width);
+ g_signal_handlers_unblock_by_func
+ (action, G_CALLBACK (ev_window_cmd_view_page_width), window);
}
void
/* This function assumes that ev_window just had ev_window->document set.
*/
+static gboolean
+document_supports_sidebar (EvDocument *document)
+{
+ return (EV_IS_DOCUMENT_THUMBNAILS (document) && EV_IS_DOCUMENT_LINKS (document));
+}
+
+static void
+hide_sidebar_and_actions (EvWindow *ev_window)
+{
+ GtkAction *action;
+ /* Alsthough we update the hiddenness of the sidebar, we don't want to
+ * store the value */
+ g_signal_handlers_disconnect_by_func (ev_window->priv->sidebar,
+ ev_window_sidebar_visibility_changed_cb,
+ ev_window);
+ gtk_widget_hide (ev_window->priv->sidebar);
+ action = gtk_action_group_get_action (ev_window->priv->action_group, "ViewSidebar");
+ gtk_action_set_sensitive (action, FALSE);
+
+}
+
static void
ev_window_setup_document (EvWindow *ev_window)
{
ev_window_set_page_mode (ev_window, PAGE_MODE_SINGLE_PAGE);
- ev_sidebar_set_document (sidebar, document);
+ if (document_supports_sidebar (document))
+ ev_sidebar_set_document (sidebar, document);
+ else
+ hide_sidebar_and_actions (ev_window);
ev_view_set_document (view, document);
update_window_title (document, NULL, ev_window);
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
- ev_view_normal_size (EV_VIEW (ev_window->priv->view));
-}
-
-static void
-ev_window_cmd_view_best_fit (GtkAction *action, EvWindow *ev_window)
-{
- EvWindowPrivate *priv = ev_window->priv;
- GtkWidget *button;
-
- g_return_if_fail (EV_IS_WINDOW (ev_window));
-
- button = gtk_ui_manager_get_widget (priv->ui_manager, "/ToolBar/ViewBestFit");
- if (! gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (button)))
- return;
-
- ev_window_set_sizing_mode (ev_window, EV_SIZING_BEST_FIT);
-}
-
-static void
-ev_window_cmd_view_page_width (GtkAction *action, EvWindow *ev_window)
-{
- EvWindowPrivate *priv = ev_window->priv;
- GtkWidget *button;
- int width, height;
- GtkRequisition vsb_requisition;
- int scrollbar_spacing;
-
- g_return_if_fail (EV_IS_WINDOW (ev_window));
-
- button = gtk_ui_manager_get_widget (priv->ui_manager, "/ToolBar/ViewPageWidth");
- if (! gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (button)))
- return;
-
-
- width = priv->scrolled_window->allocation.width;
- height = priv->scrolled_window->allocation.height;
-
- /* the scrolled window has a GTK_SHADOW_IN */
- width -= 2 * priv->view->style->xthickness;
- height -= 2 * priv->view->style->ythickness;
-
- gtk_widget_size_request (
- GTK_SCROLLED_WINDOW (priv->scrolled_window)->vscrollbar,
- &vsb_requisition);
- gtk_widget_style_get (priv->scrolled_window,
- "scrollbar_spacing", &scrollbar_spacing,
- NULL);
-
- ev_window_set_sizing_mode (ev_window, EV_SIZING_FIT_WIDTH);
-
- ev_view_fit_width (EV_VIEW (ev_window->priv->view),
- width, height,
- vsb_requisition.width + scrollbar_spacing);
+ ev_view_set_size (EV_VIEW (ev_window->priv->view), -1, -1);
}
static void
}
static void
-size_allocate_cb (GtkWidget *scrolled_window,
- GtkAllocation *allocation,
- EvWindow *ev_window)
+update_view_size (EvWindow *window)
{
int width, height;
GtkRequisition vsb_requisition;
int scrollbar_spacing;
- width = ev_window->priv->scrolled_window->allocation.width;
- height = ev_window->priv->scrolled_window->allocation.height;
+ width = window->priv->scrolled_window->allocation.width;
+ height = window->priv->scrolled_window->allocation.height;
/* the scrolled window has a GTK_SHADOW_IN */
- width -= 2 * ev_window->priv->view->style->xthickness;
- height -= 2 * ev_window->priv->view->style->ythickness;
+ width -= 2 * window->priv->view->style->xthickness;
+ height -= 2 * window->priv->view->style->ythickness;
- if (ev_window->priv->sizing_mode == EV_SIZING_BEST_FIT) {
- ev_view_best_fit (EV_VIEW (ev_window->priv->view),
+ if (window->priv->sizing_mode == EV_SIZING_BEST_FIT) {
+ ev_view_set_size (EV_VIEW (window->priv->view),
MAX (1, width), MAX (1, height));
- } else if (ev_window->priv->sizing_mode == EV_SIZING_FIT_WIDTH) {
- gtk_widget_size_request (GTK_SCROLLED_WINDOW (ev_window->priv->scrolled_window)->vscrollbar,
+ } else if (window->priv->sizing_mode == EV_SIZING_FIT_WIDTH) {
+ gtk_widget_size_request (GTK_SCROLLED_WINDOW (window->priv->scrolled_window)->vscrollbar,
&vsb_requisition);
- gtk_widget_style_get (ev_window->priv->scrolled_window,
+ gtk_widget_style_get (window->priv->scrolled_window,
"scrollbar_spacing", &scrollbar_spacing,
NULL);
- ev_view_fit_width (EV_VIEW (ev_window->priv->view),
- width, height,
- vsb_requisition.width + scrollbar_spacing);
+ ev_view_set_size (EV_VIEW (window->priv->view),
+ width - vsb_requisition.width - scrollbar_spacing, -1);
}
}
+static void
+size_allocate_cb (GtkWidget *scrolled_window,
+ GtkAllocation *allocation,
+ EvWindow *window)
+{
+ update_view_size (window);
+}
+
static void
ev_window_set_sizing_mode (EvWindow *ev_window,
EvSizingMode sizing_mode)
g_signal_handlers_disconnect_by_func (scrolled_window, size_allocate_cb, ev_window);
+ update_view_size (ev_window);
+
switch (sizing_mode) {
case EV_SIZING_BEST_FIT:
g_object_set (G_OBJECT (scrolled_window),
break;
}
- ev_view_set_mode (EV_VIEW (ev_window->priv->view), sizing_mode);
update_sizing_buttons (ev_window);
}