diff options
author | Martin Kretzschmar <martink@src.gnome.org> | 2005-02-15 08:26:23 (GMT) |
---|---|---|
committer | Martin Kretzschmar <martink@src.gnome.org> | 2005-02-15 08:26:23 (GMT) |
commit | 42ddc3073ecb88271a0ffc74326878627d71b34e (patch) | |
tree | 013c5b6a44139929aa1c478033bc39d7a65ae0ff /shell/ev-window.c | |
parent | 62e17675ff8a850e77cd23a8b8946d68576caa32 (diff) |
add parameters providing allocation width and height without scrollbars
* shell/ev-view.c (ev_view_best_fit, ev_view_fit_width): add
parameters providing allocation width and height without
scrollbars and width of a possible vertical scrollbar. With this
additional information the functions can work as
intended. Unfortunately they're not idempotent. We should
transform these commands to toggles. Fixes Bug #164976
Initial patch by Stephane Loeuillet, then heavily modified.
* shell/ev-view.h: update prototypes.
* shell/ev-window.c (ev_window_cmd_view_best_fit)
(ev_window_cmd_view_page_width): provide EvView fit functions with
all the information they need. Formulas to calculate this
information taken from GtkScrolledWindow.
Diffstat (limited to 'shell/ev-window.c')
-rw-r--r-- | shell/ev-window.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/shell/ev-window.c b/shell/ev-window.c index a1d74f6..547eaf0 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -1197,17 +1197,49 @@ ev_window_cmd_view_normal_size (GtkAction *action, EvWindow *ev_window) static void ev_window_cmd_view_best_fit (GtkAction *action, EvWindow *ev_window) { + EvWindowPrivate *priv = ev_window->priv; + int width, height; + g_return_if_fail (EV_IS_WINDOW (ev_window)); - ev_view_best_fit (EV_VIEW (ev_window->priv->view)); + 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; + + ev_view_best_fit (EV_VIEW (priv->view), + MAX (1, width), MAX (1, height)); } static void ev_window_cmd_view_page_width (GtkAction *action, EvWindow *ev_window) { + EvWindowPrivate *priv = ev_window->priv; + int width, height; + GtkRequisition vsb_requisition; + int scrollbar_spacing; + g_return_if_fail (EV_IS_WINDOW (ev_window)); - ev_view_fit_width (EV_VIEW (ev_window->priv->view)); + 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_view_fit_width (EV_VIEW (ev_window->priv->view), + width, height, + vsb_requisition.width + scrollbar_spacing); } static void |