Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorNickolay V. Shmyrev <nshmyrev@src.gnome.org>2005-04-24 20:40:54 (GMT)
committer Nickolay V. Shmyrev <nshmyrev@src.gnome.org>2005-04-24 20:40:54 (GMT)
commit16a2c17ee1a0bb5659007a49b4d8e14b71fc415f (patch)
treede4cdd43e24cb024991763bbad089ede2ff7aca3 /shell
parentecb105edd7c7aca576c70ca7729ad386ae0436cb (diff)
Horizontal scroll and zooming with mouse wheel
Diffstat (limited to 'shell')
-rw-r--r--shell/ev-view.c37
-rw-r--r--shell/ev-window.c56
2 files changed, 60 insertions, 33 deletions
diff --git a/shell/ev-view.c b/shell/ev-view.c
index 851b5e4..ef7d299 100644
--- a/shell/ev-view.c
+++ b/shell/ev-view.c
@@ -653,6 +653,37 @@ ev_view_unrealize (GtkWidget *widget)
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)
@@ -1594,6 +1625,7 @@ ev_view_class_init (EvViewClass *class)
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;
@@ -2061,7 +2093,6 @@ ev_view_set_sizing_mode (EvView *view,
view->sizing_mode = sizing_mode;
gtk_widget_queue_resize (GTK_WIDGET (view));
}
-
g_object_notify (G_OBJECT (view), "sizing-mode");
}
@@ -2156,7 +2187,7 @@ ev_view_zoom_for_size_continuous_and_dual_page (EvView *view,
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
@@ -2191,7 +2222,7 @@ ev_view_zoom_for_size_continuous (EvView *view,
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
diff --git a/shell/ev-window.c b/shell/ev-window.c
index b7b172d..9f18753 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -144,10 +144,8 @@ static void ev_window_set_page_mode (EvWindow *window,
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);
@@ -325,9 +323,9 @@ static void
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);
}
@@ -336,9 +334,9 @@ static void
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);
}
@@ -1514,7 +1512,7 @@ ev_window_cmd_view_zoom_in (GtkAction *action, EvWindow *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);
}
@@ -1524,7 +1522,7 @@ ev_window_cmd_view_zoom_out (GtkAction *action, EvWindow *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);
}
@@ -1664,37 +1662,29 @@ size_allocate_cb (GtkWidget *scrolled_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),
@@ -2487,6 +2477,7 @@ ev_window_init (EvWindow *ev_window)
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),
@@ -2495,6 +2486,10 @@ ev_window_init (EvWindow *ev_window)
"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),
@@ -2559,6 +2554,7 @@ ev_window_init (EvWindow *ev_window)
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);
}