]> www.fi.muni.cz Git - evince.git/commitdiff
Add a get_orientation api. Improve set_orientation.
authorMarco Pesenti Gritti <mpg@redhat.com>
Thu, 16 Jun 2005 16:40:40 +0000 (16:40 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Thu, 16 Jun 2005 16:40:40 +0000 (16:40 +0000)
2005-06-16  Marco Pesenti Gritti  <mpg@redhat.com>

        * backend/ev-document.c: (ev_document_get_orientation):
        * backend/ev-document.h:
        * pdf/ev-poppler.cc:
        * ps/ps-document.c: (ps_document_get_orientation),
        (ps_document_set_orientation), (ps_document_document_iface_init):

        Add a get_orientation api. Improve set_orientation.

        * data/evince-ui.xml:
        * shell/ev-view.c: (ev_view_set_orientation),
        (ev_view_rotate_right), (ev_view_rotate_left):
        * shell/ev-view.h:
        * shell/ev-window.c: (ev_window_cmd_edit_rotate_left),
        (ev_window_cmd_edit_rotate_right):

        Better ui for changing document orientation

ChangeLog
backend/ev-document.c
backend/ev-document.h
data/evince-ui.xml
pdf/ev-poppler.cc
ps/ps-document.c
shell/ev-view.c
shell/ev-view.h
shell/ev-window.c

index a53082e9fc2591054d8cfe2614a424cdbf1017d2..ab67697c2f40a3eba2cc01d07a39b583d8fcc345 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2005-06-16  Marco Pesenti Gritti  <mpg@redhat.com>
+
+       * backend/ev-document.c: (ev_document_get_orientation):
+       * backend/ev-document.h:
+       * pdf/ev-poppler.cc:
+       * ps/ps-document.c: (ps_document_get_orientation),
+       (ps_document_set_orientation), (ps_document_document_iface_init):
+
+       Add a get_orientation api. Improve set_orientation.
+
+       * data/evince-ui.xml:
+       * shell/ev-view.c: (ev_view_set_orientation),
+       (ev_view_rotate_right), (ev_view_rotate_left):
+       * shell/ev-view.h:
+       * shell/ev-window.c: (ev_window_cmd_edit_rotate_left),
+       (ev_window_cmd_edit_rotate_right):
+
+       Better ui for changing document orientation
+
 2005-06-16  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>
 
        * shell/ev-sidebar-links.c: (ev_sidebar_links_get_property),
index 4513df50e5c09e75510da5333d06b30773dfc335..9bccc4cab7ee2d09ed99e5024ac3144a6cea4456 100644 (file)
@@ -218,6 +218,14 @@ ev_document_render_pixbuf (EvDocument *document,
        return retval;
 }
 
+EvOrientation
+ev_document_get_orientation (EvDocument *document)
+{
+       EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+
+       return iface->get_orientation (document);
+}
+
 void
 ev_document_set_orientation (EvDocument     *document,
                             EvOrientation   orientation)
index 1fd8fe3221eda755b300d6592c32a4aaa12f8df5..044014f370cb8798782d9cd7fca4bea3b7ca7a6f 100644 (file)
@@ -57,7 +57,6 @@ typedef enum
 
 typedef enum
 {
-       EV_ORIENTATION_DOCUMENT,
        EV_ORIENTATION_PORTRAIT,
        EV_ORIENTATION_LANDSCAPE,
        EV_ORIENTATION_UPSIDEDOWN,
@@ -98,6 +97,7 @@ struct _EvDocumentIface
        GdkPixbuf      * (* render_pixbuf)   (EvDocument   *document,
                                              int           page,
                                              double        scale);
+       EvOrientation    (* get_orientation) (EvDocument   *document);
        void             (* set_orientation) (EvDocument   *document,
                                              EvOrientation orientation);
        EvDocumentInfo * (* get_info)        (EvDocument   *document);
@@ -132,6 +132,7 @@ GList              *ev_document_get_links       (EvDocument     *document,
 GdkPixbuf      *ev_document_render_pixbuf   (EvDocument     *document,
                                             int             page,
                                             double          scale);
+EvOrientation   ev_document_get_orientation (EvDocument     *document);
 void           ev_document_set_orientation (EvDocument     *document,
                                             EvOrientation   orientation);
 
index 1d251ca0944bf027cb5e2dd2c4623740997628ff..c64df653c84604703739315ff3022054e0db8e75 100644 (file)
@@ -20,9 +20,8 @@
       <menuitem name="EditFindMenu" action="EditFind"/>
       <menuitem name="EditFindNextMenu" action="EditFindNext"/>
       <separator/>
-      <menuitem name="EditLandscapeMenu" action="EditLandscape"/>
-      <menuitem name="EditPortraitMenu" action="EditPortrait"/>
-      <menuitem name="EditFlipMenu" action="EditFlip"/>
+      <menuitem name="EditRotateLeftMenu" action="EditRotateLeft"/>
+      <menuitem name="EditRotateRigtMenu" action="EditRotateRight"/>
       <separator/>
       <menuitem name="EditToolbarMenu" action="EditToolbar"/>
     </menu>
index 1f1e4e506b5c46f27f0a35e61144f25a6fbb5b23..0f9a3562c2dde199d2ff3a763ba2ade5916be8ff 100644 (file)
@@ -128,6 +128,7 @@ static void
 pdf_document_init (PdfDocument *pdf_document)
 {
        pdf_document->password = NULL;
+       pdf_document->orientation = POPPLER_ORIENTATION_PORTRAIT;
 }
 
 static void
@@ -175,6 +176,24 @@ pdf_document_save (EvDocument  *document,
        return retval;
 }
 
+static PopplerOrientation
+get_document_orientation (PdfDocument *pdf_document)
+{
+#ifdef POPPLER_ORIENTATION
+       PopplerPage *page;
+
+       /* Should prolly be smarter here and check more than first page */
+       page = poppler_document_get_page (pdf_document->document, 0);
+       if (page) {
+               return poppler_page_get_orientation (page);
+       } else {
+               return POPPLER_ORIENTATION_PORTRAIT;
+       }
+#else
+       return POPPLER_ORIENTATION_PORTRAIT;
+#endif
+}
+
 static gboolean
 pdf_document_load (EvDocument   *document,
                   const char   *uri,
@@ -191,6 +210,8 @@ pdf_document_load (EvDocument   *document,
                return FALSE;
        }
 
+       pdf_document->orientation = get_document_orientation (pdf_document);
+
        return TRUE;
 }
 
@@ -488,6 +509,30 @@ pdf_document_get_text (EvDocument *document, int page, EvRectangle *rect)
        return poppler_page_get_text (poppler_page, &r);
 }
 
+static EvOrientation
+pdf_document_get_orientation (EvDocument *document)
+{
+       EvOrientation result;
+       PdfDocument *pdf_document = PDF_DOCUMENT (document);
+       
+       switch (pdf_document->orientation) {
+               case POPPLER_ORIENTATION_PORTRAIT:
+                       result = EV_ORIENTATION_PORTRAIT;
+                       break;
+               case POPPLER_ORIENTATION_LANDSCAPE:
+                       result = EV_ORIENTATION_LANDSCAPE;
+                       break;
+               case POPPLER_ORIENTATION_UPSIDEDOWN:
+                       result = EV_ORIENTATION_UPSIDEDOWN;
+                       break;
+               case POPPLER_ORIENTATION_SEASCAPE:
+                       result = EV_ORIENTATION_SEASCAPE;
+                       break;
+       }
+
+       return result;
+}
+
 static void
 pdf_document_set_orientation (EvDocument *document, EvOrientation orientation)
 {
@@ -495,9 +540,6 @@ pdf_document_set_orientation (EvDocument *document, EvOrientation orientation)
        PopplerOrientation poppler_orientation;
 
        switch (orientation) {
-               case EV_ORIENTATION_DOCUMENT:
-                       poppler_orientation = POPPLER_ORIENTATION_DOCUMENT;
-                       break;
                case EV_ORIENTATION_PORTRAIT:
                        poppler_orientation = POPPLER_ORIENTATION_PORTRAIT;
                        break;
@@ -529,6 +571,7 @@ pdf_document_document_iface_init (EvDocumentIface *iface)
        iface->can_get_text = pdf_document_can_get_text;
        iface->get_info = pdf_document_get_info;
        iface->set_orientation = pdf_document_set_orientation;
+       iface->get_orientation = pdf_document_get_orientation;
 };
 
 static void
index 83fa3d9fe93573659b558fadd6d709b87006a6c1..642f5c8ef9a7a3acbf581162bd70d623433f232d 100644 (file)
@@ -1241,6 +1241,35 @@ ps_document_get_info (EvDocument *document)
        return info;
 }
 
+static EvOrientation
+ps_document_get_orientation (EvDocument *document)
+{
+       EvOrientation orientation;
+       PSDocument *ps = PS_DOCUMENT (document);
+
+       g_return_val_if_fail (ps != NULL, EV_ORIENTATION_PORTRAIT);
+
+       switch (ps->orientation) {
+               case GTK_GS_ORIENTATION_PORTRAIT:
+                       orientation = EV_ORIENTATION_PORTRAIT;
+                       break;
+               case GTK_GS_ORIENTATION_LANDSCAPE:
+                       orientation = EV_ORIENTATION_LANDSCAPE;
+                       break;
+               case GTK_GS_ORIENTATION_UPSIDEDOWN:
+                       orientation = EV_ORIENTATION_UPSIDEDOWN;
+                       break;
+               case GTK_GS_ORIENTATION_SEASCAPE:
+                       orientation = EV_ORIENTATION_SEASCAPE;
+                       break;
+               default:
+                       orientation = EV_ORIENTATION_PORTRAIT;
+                       break;
+       }
+
+       return orientation;
+}
+
 static void
 ps_document_set_orientation (EvDocument *document, EvOrientation orientation)
 {
@@ -1249,9 +1278,6 @@ ps_document_set_orientation (EvDocument *document, EvOrientation orientation)
        g_return_if_fail (ps != NULL);
 
        switch (orientation) {
-               case EV_ORIENTATION_DOCUMENT:
-                       ps->orientation = GTK_GS_ORIENTATION_NONE;
-                       break;
                case EV_ORIENTATION_PORTRAIT:
                        ps->orientation = GTK_GS_ORIENTATION_PORTRAIT;
                        break;
@@ -1277,6 +1303,7 @@ ps_document_document_iface_init (EvDocumentIface *iface)
        iface->get_page_size = ps_document_get_page_size;
        iface->get_info = ps_document_get_info;
        iface->set_orientation = ps_document_set_orientation;
+       iface->get_orientation = ps_document_get_orientation;
 }
 
 static void
index 6ae9ac6139b4ae217cbbaf4f2f4d24dab23d011c..c366b04c4f18dce855d60558b15e55ba42ad31e8 100644 (file)
@@ -2145,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)
 {
@@ -2157,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,
index 2244ae0fd9278ff1a49aa94cb7c6ae113a89ac4e..05b254292372d1113881444a01e80b07dcb47ad1 100644 (file)
@@ -90,8 +90,8 @@ void          ev_view_set_zoom_for_size (EvView         *view,
                                           int             height,
                                           int             vsb_width,
                                           int             hsb_height);
-void           ev_view_set_orientation   (EvView         *view,
-                                          EvOrientation   orientation);
+void           ev_view_rotate_left       (EvView         *view);
+void            ev_view_rotate_right      (EvView         *view);
 
 /* Find */
 gboolean       ev_view_can_find_next     (EvView         *view);
index e9e1c4e65a6699e656aa059941e01fe525a7c3ac..2020e9cebc75e47bd28ca7a3cf90eceb3b17871d 100644 (file)
@@ -1798,24 +1798,15 @@ ev_window_cmd_edit_toolbar_cb (GtkDialog *dialog, gint response, gpointer data)
 }
 
 static void
-ev_window_cmd_edit_landscape (GtkAction *action, EvWindow *ev_window)
+ev_window_cmd_edit_rotate_left (GtkAction *action, EvWindow *ev_window)
 {
-       ev_view_set_orientation (EV_VIEW (ev_window->priv->view),
-                                EV_ORIENTATION_LANDSCAPE);
+       ev_view_rotate_left (EV_VIEW (ev_window->priv->view));
 }
 
 static void
-ev_window_cmd_edit_portrait (GtkAction *action, EvWindow *ev_window)
+ev_window_cmd_edit_rotate_right (GtkAction *action, EvWindow *ev_window)
 {
-       ev_view_set_orientation (EV_VIEW (ev_window->priv->view),
-                                EV_ORIENTATION_PORTRAIT);
-}
-
-static void
-ev_window_cmd_edit_flip (GtkAction *action, EvWindow *ev_window)
-{
-       ev_view_set_orientation (EV_VIEW (ev_window->priv->view),
-                                EV_ORIENTATION_SEASCAPE);
+       ev_view_rotate_right (EV_VIEW (ev_window->priv->view));
 }
 
 static void
@@ -2511,15 +2502,12 @@ static const GtkActionEntry entries[] = {
         { "EditToolbar", NULL, N_("T_oolbar"), NULL,
           N_("Customize the toolbar"),
           G_CALLBACK (ev_window_cmd_edit_toolbar) },
-       { "EditLandscape", NULL, N_("_Landscape"), NULL,
-         N_("Change the document orientation to landscape"),
-         G_CALLBACK (ev_window_cmd_edit_landscape) },
-       { "EditPortrait", NULL, N_("_Portrait"), NULL,
-         N_("Change the document orientation to portrait"),
-         G_CALLBACK (ev_window_cmd_edit_portrait) },
-       { "EditFlip", NULL, N_("_Flip"), NULL,
-         N_("Flip the document"),
-         G_CALLBACK (ev_window_cmd_edit_flip) },
+       { "EditRotateLeft", NULL, N_("Rotate _Left"), NULL,
+         N_("Rotate the document to the left"),
+         G_CALLBACK (ev_window_cmd_edit_rotate_left) },
+       { "EditRotateRight", NULL, N_("Rotate _Right"), NULL,
+         N_("Rotate the document to the right"),
+         G_CALLBACK (ev_window_cmd_edit_rotate_right) },
 
         /* View menu */
         { "ViewZoomIn", GTK_STOCK_ZOOM_IN, NULL, "<control>plus",