]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-view.c
Add a get_orientation api. Improve set_orientation.
[evince.git] / shell / ev-view.c
index 3e31d293448250094b2317bbcdc781aaea81e15b..c366b04c4f18dce855d60558b15e55ba42ad31e8 100644 (file)
@@ -1322,6 +1322,9 @@ ev_view_motion_notify_event (GtkWidget      *widget,
 {
        EvView *view = EV_VIEW (widget);
 
+       if (!view->document)
+               return FALSE;
+
        if (view->pressed_button == 1) {
                GdkRectangle selection;
 
@@ -1371,7 +1374,7 @@ ev_view_motion_notify_event (GtkWidget      *widget,
 
                        return TRUE;
                }
-       } else if (view->pressed_button <= 0 && view->document) {
+       } else if (view->pressed_button <= 0) {
                EvLink *link;
 
                link = get_link_at_location (view, event->x + view->scroll_x, event->y + view->scroll_y);
@@ -2142,7 +2145,7 @@ ev_view_zoom_out (EvView *view)
        ev_view_set_zoom (view, ZOOM_OUT_FACTOR, TRUE);
 }
 
-void
+static void
 ev_view_set_orientation (EvView         *view,
                         EvOrientation   orientation)
 {
@@ -2154,6 +2157,42 @@ ev_view_set_orientation (EvView         *view,
        gtk_widget_queue_resize (GTK_WIDGET (view));
 }
 
+void
+ev_view_rotate_right (EvView *view)
+{
+       EvOrientation orientation, new_orientation;
+
+       orientation = ev_document_get_orientation (view->document);
+       if (orientation == EV_ORIENTATION_PORTRAIT) {
+               new_orientation = EV_ORIENTATION_LANDSCAPE;
+       } else if (orientation == EV_ORIENTATION_LANDSCAPE) {
+               new_orientation = EV_ORIENTATION_UPSIDEDOWN;
+       } else if (orientation == EV_ORIENTATION_UPSIDEDOWN) {
+               new_orientation = EV_ORIENTATION_SEASCAPE;
+       } else {
+               new_orientation = EV_ORIENTATION_PORTRAIT;
+       }
+       ev_view_set_orientation (view, new_orientation);
+}
+
+void
+ev_view_rotate_left (EvView *view)
+{
+       EvOrientation orientation, new_orientation;
+
+       orientation = ev_document_get_orientation (view->document);
+       if (orientation == EV_ORIENTATION_PORTRAIT) {
+               new_orientation = EV_ORIENTATION_SEASCAPE;
+       } else if (orientation == EV_ORIENTATION_SEASCAPE) {
+               new_orientation = EV_ORIENTATION_UPSIDEDOWN;
+       } else if (orientation == EV_ORIENTATION_UPSIDEDOWN) {
+               new_orientation = EV_ORIENTATION_LANDSCAPE;
+       } else {
+               new_orientation = EV_ORIENTATION_PORTRAIT;
+       }
+       ev_view_set_orientation (view, new_orientation);
+}
+
 static double
 zoom_for_size_fit_width (int doc_width,
                         int doc_height,