GTK_WIDGET_CLASS (ev_view_parent_class)->unrealize (widget);
}
+static gboolean
+ev_view_scroll_event (GtkWidget *widget, GdkEventScroll *event)
+{
+ EvView *view = EV_VIEW (widget);
+
+ if ((event->state & GDK_CONTROL_MASK) != 0) {
+
+ ev_view_set_sizing_mode (view, EV_SIZING_FREE);
+
+ if ((event->direction == GDK_SCROLL_DOWN ||
+ event->direction == GDK_SCROLL_LEFT) &&
+ ev_view_can_zoom_in (view)) {
+ ev_view_zoom_in (view);
+ } else if (ev_view_can_zoom_out (view)) {
+ ev_view_zoom_out (view);
+ }
+
+ return TRUE;
+ }
+
+ if ((event->state & GDK_SHIFT_MASK) != 0) {
+ if (event->direction == GDK_SCROLL_UP)
+ event->direction = GDK_SCROLL_LEFT;
+ if (event->direction == GDK_SCROLL_DOWN)
+ event->direction = GDK_SCROLL_RIGHT;
+ }
+
+ return FALSE;
+}
+
+
#if 0
static guint32
ev_gdk_color_to_rgb (const GdkColor *color)
widget_class->size_allocate = ev_view_size_allocate;
widget_class->realize = ev_view_realize;
widget_class->unrealize = ev_view_unrealize;
+ widget_class->scroll_event = ev_view_scroll_event;
gtk_object_class->destroy = ev_view_destroy;
class->set_scroll_adjustments = ev_view_set_scroll_adjustments;
view->sizing_mode = sizing_mode;
gtk_widget_queue_resize (GTK_WIDGET (view));
}
-
g_object_notify (G_OBJECT (view), "sizing-mode");
}
doc_width = doc_width * 2;
width -= (2 * (border.left + border.right) + 3 * view->spacing);
- height -= (border.top + border.bottom + 2 * view->spacing);
+ height -= (border.top + border.bottom + 2 * view->spacing - 1);
/* FIXME: We really need to calculate the overall height here, not the
* page height. We assume there's always a vertical scrollbar for
compute_border (view, doc_width, doc_height, &border);
width -= (border.left + border.right + 2 * view->spacing);
- height -= (border.top + border.bottom + 2 * view->spacing);
+ height -= (border.top + border.bottom + 2 * view->spacing - 1);
/* FIXME: We really need to calculate the overall height here, not the
* page height. We assume there's always a vertical scrollbar for
static gboolean start_loading_document (EvWindow *ev_window,
EvDocument *document,
const char *uri);
-static void ev_window_set_sizing_mode (EvWindow *ev_window,
- EvSizingMode sizing_mode,
- gboolean first_time);
-
+static void ev_window_sizing_mode_changed_cb (EvView *view, GParamSpec *pspec,
+ EvWindow *ev_window);
static void ev_window_add_recent (EvWindow *window, const char *filename);
static void ev_window_fullscreen (EvWindow *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, FALSE);
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_BEST_FIT);
} else {
- ev_window_set_sizing_mode (ev_window, EV_SIZING_FREE, FALSE);
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
}
update_action_sensitivity (ev_window);
}
ev_window_cmd_view_page_width (GtkAction *action, EvWindow *ev_window)
{
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
- ev_window_set_sizing_mode (ev_window, EV_SIZING_FIT_WIDTH, FALSE);
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FIT_WIDTH);
} else {
- ev_window_set_sizing_mode (ev_window, EV_SIZING_FREE, FALSE);
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
}
update_action_sensitivity (ev_window);
}
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
- ev_window_set_sizing_mode (ev_window, EV_SIZING_FREE, FALSE);
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
ev_view_zoom_in (EV_VIEW (ev_window->priv->view));
update_action_sensitivity (ev_window);
}
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
- ev_window_set_sizing_mode (ev_window, EV_SIZING_FREE, FALSE);
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
ev_view_zoom_out (EV_VIEW (ev_window->priv->view));
update_action_sensitivity (ev_window);
}
update_view_size (window);
}
-static void
-ev_window_set_sizing_mode (EvWindow *ev_window,
- EvSizingMode sizing_mode,
- gboolean first_time)
+static void
+ev_window_sizing_mode_changed_cb (EvView *view, GParamSpec *pspec,
+ EvWindow *ev_window)
{
GtkWidget *scrolled_window;
+ EvSizingMode sizing_mode;
- /* Short circuit the call if it's not the first time we call this */
- if (!first_time) {
- EvSizingMode old_sizing_mode;
-
- g_object_get (ev_window->priv->view,
- "sizing-mode", &old_sizing_mode,
- NULL);
- if (old_sizing_mode == sizing_mode)
- return;
- }
+ g_object_get (ev_window->priv->view,
+ "sizing-mode", &sizing_mode,
+ NULL);
scrolled_window = ev_window->priv->scrolled_window;
- g_object_set (ev_window->priv->view,
- "sizing-mode", sizing_mode,
- NULL);
+
g_signal_handlers_disconnect_by_func (scrolled_window, size_allocate_cb, ev_window);
- update_view_size (ev_window);
+ if (sizing_mode != EV_SIZING_FREE)
+ update_view_size (ev_window);
switch (sizing_mode) {
case EV_SIZING_BEST_FIT:
g_object_set (G_OBJECT (scrolled_window),
"hscrollbar-policy", GTK_POLICY_NEVER,
- "vscrollbar-policy", GTK_POLICY_NEVER,
+ "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
NULL);
g_signal_connect (scrolled_window, "size-allocate",
G_CALLBACK (size_allocate_cb),
gtk_container_add (GTK_CONTAINER (ev_window->priv->scrolled_window),
ev_window->priv->view);
+
g_signal_connect (ev_window->priv->view,
"notify::find-status",
G_CALLBACK (view_find_status_changed_cb),
"notify::status",
G_CALLBACK (view_status_changed_cb),
ev_window);
+ g_signal_connect (ev_window->priv->view,
+ "notify::sizing-mode",
+ G_CALLBACK (ev_window_sizing_mode_changed_cb),
+ ev_window);
ev_window->priv->statusbar = gtk_statusbar_new ();
gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
G_CALLBACK (drag_data_received_cb), NULL);
/* Set it to something random to force a change */
- ev_window_set_sizing_mode (ev_window, EV_SIZING_FIT_WIDTH, TRUE);
+
+ ev_window_sizing_mode_changed_cb (EV_VIEW (ev_window->priv->view), NULL, ev_window);
update_action_sensitivity (ev_window);
}