]> www.fi.muni.cz Git - evince.git/commitdiff
* shell/ev-metadata-manager.c: (ev_metadata_manager_init): *
authorJonathan Blandford <jrb@redhat.com>
Mon, 15 Aug 2005 04:41:30 +0000 (04:41 +0000)
committerJonathan Blandford <jrb@src.gnome.org>
Mon, 15 Aug 2005 04:41:30 +0000 (04:41 +0000)
Mon Aug 15 00:40:21 2005  Jonathan Blandford  <jrb@redhat.com>

        * pdf/ev-poppler.cc: * shell/ev-metadata-manager.c:
        (ev_metadata_manager_init): * shell/ev-view.c:
        (ev_view_rotate_left), (ev_view_set_rotation),
        (ev_view_get_rotation): * shell/ev-view.h: * shell/ev-window.c:
        (setup_view_from_metadata),
        (save_rotation_to_file), (ev_window_cmd_edit_rotate_left),
        (ev_window_cmd_edit_rotate_right): Fix rotation.  Save it to disk.

ChangeLog
pdf/ev-poppler.cc
shell/ev-metadata-manager.c
shell/ev-view.c
shell/ev-view.h
shell/ev-window.c

index f22af3b00d5eacc32eaaa1823121790d4e93f800..88edbf7628fe507dd03f53767e9d4290c0a37c60 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Mon Aug 15 00:40:21 2005  Jonathan Blandford  <jrb@redhat.com>
+
+       * pdf/ev-poppler.cc: * shell/ev-metadata-manager.c:
+       (ev_metadata_manager_init): * shell/ev-view.c:
+       (ev_view_rotate_left), (ev_view_set_rotation),
+       (ev_view_get_rotation): * shell/ev-view.h: * shell/ev-window.c:
+       (setup_view_from_metadata),
+       (save_rotation_to_file), (ev_window_cmd_edit_rotate_left),
+       (ev_window_cmd_edit_rotate_right): Fix rotation.  Save it to disk.
+
 2005-08-14  Baris Cicek <baris@teamforce.name.tr>
 
        * configure.ac: Added tr to ALL_LINGUAS
index 610f598388a1bf093568a1ac12a2951f06a6cdb4..ef95956e6a6a2225b1b1f81dbad0571979067b01 100644 (file)
@@ -247,21 +247,19 @@ static void
 set_page_orientation (PdfDocument *pdf_document, PopplerPage *page, int rotation)
 {
        PopplerOrientation orientation;
-       int r = rotation;
 
-       orientation = poppler_page_get_orientation (page);
-
-       while (r > 0) {
-               if (orientation == POPPLER_ORIENTATION_PORTRAIT) {
-                       orientation = POPPLER_ORIENTATION_LANDSCAPE;
-               } else if (orientation == POPPLER_ORIENTATION_LANDSCAPE) {
-                       orientation = POPPLER_ORIENTATION_UPSIDEDOWN;
-               } else if (orientation == POPPLER_ORIENTATION_UPSIDEDOWN) {
-                       orientation = POPPLER_ORIENTATION_SEASCAPE;
-               } else {
-                       orientation = POPPLER_ORIENTATION_PORTRAIT;
-               }
-               r -= 90;
+       switch (rotation) {
+       case 90:
+               orientation = POPPLER_ORIENTATION_LANDSCAPE;
+               break;
+       case 180:
+               orientation = POPPLER_ORIENTATION_UPSIDEDOWN;
+               break;
+       case 270:
+               orientation = POPPLER_ORIENTATION_SEASCAPE;
+               break;
+       default:
+               orientation = POPPLER_ORIENTATION_PORTRAIT;
        }
 
        poppler_page_set_orientation (page, orientation);
index 2bbd291580362bd9ab04f33adf2a80cbad2c2bf5..7acf6a14c456a9a89f12a84a8976601abf53f3bf 100644 (file)
@@ -43,7 +43,7 @@
 
 #define MAX_ITEMS      50
 
-typedef struct _GeditMetadataManager GeditMetadataManager;
+typedef struct _EvMetadataManager EvMetadataManager;
 
 typedef struct _Item Item;
 
@@ -54,7 +54,7 @@ struct _Item
        GHashTable      *values;
 };
        
-struct _GeditMetadataManager
+struct _EvMetadataManager
 {
        gboolean         values_loaded; /* It is true if the file 
                                           has been read */
@@ -70,7 +70,7 @@ struct _GeditMetadataManager
 static gboolean ev_metadata_manager_save (gpointer data);
 
 
-static GeditMetadataManager *ev_metadata_manager = NULL;
+static EvMetadataManager *ev_metadata_manager = NULL;
 
 static void
 item_free (gpointer data)
@@ -90,7 +90,7 @@ item_free (gpointer data)
 void
 ev_metadata_manager_init (void)
 {
-       ev_metadata_manager = g_new0 (GeditMetadataManager, 1);
+       ev_metadata_manager = g_new0 (EvMetadataManager, 1);
 
        ev_metadata_manager->values_loaded = FALSE;
        ev_metadata_manager->modified = FALSE;
index b22b1f52545f2f4c65eb165720f58071ca0f6ef9..07fee0d7a11ba01339bb175f467c399efa167b65 100644 (file)
@@ -2409,15 +2409,6 @@ ev_view_zoom_out (EvView *view)
        ev_view_set_zoom (view, ZOOM_OUT_FACTOR, TRUE);
 }
 
-static void
-ev_view_set_rotation (EvView *view, int rotation)
-{
-       view->rotation = rotation;
-
-       ev_pixbuf_cache_clear (view->pixbuf_cache);
-       gtk_widget_queue_resize (GTK_WIDGET (view));
-}
-
 void
 ev_view_rotate_right (EvView *view)
 {
@@ -2442,6 +2433,23 @@ ev_view_rotate_left (EvView *view)
        ev_view_set_rotation (view, rotation);
 }
 
+void
+ev_view_set_rotation (EvView *view, int rotation)
+{
+       view->rotation = rotation;
+
+       if (view->pixbuf_cache) {
+               ev_pixbuf_cache_clear (view->pixbuf_cache);
+               gtk_widget_queue_resize (GTK_WIDGET (view));
+       }
+}
+
+int
+ev_view_get_rotation (EvView *view)
+{
+       return view->rotation;
+}
+
 static double
 zoom_for_size_fit_width (int doc_width,
                         int doc_height,
index 2790a1c4c97300c1ae8eed1679afcb284d19a6b3..09ac1eec1e699750e2d24d27d763f82d1e7599c4 100644 (file)
@@ -101,6 +101,9 @@ void                ev_view_set_zoom_for_size (EvView         *view,
                                           int             hsb_height);
 void           ev_view_rotate_left       (EvView         *view);
 void            ev_view_rotate_right      (EvView         *view);
+void            ev_view_set_rotation      (EvView         *view,
+                                          int             rotation);
+int             ev_view_get_rotation      (EvView         *view);
 
 /* Find */
 gboolean       ev_view_can_find_next     (EvView         *view);
index dc67739915faf9eba3864a8469952a3e363cebac..a264cbc81b55a220b146c57abd09f25ad149db4b 100644 (file)
@@ -956,6 +956,7 @@ setup_view_from_metadata (EvWindow *window)
        GValue dual_page = { 0, };
        GValue presentation = { 0, };
        GValue fullscreen = { 0, };
+       GValue rotation = { 0, };
 
        /* Window size */
        if (!GTK_WIDGET_VISIBLE (window)) {
@@ -1018,6 +1019,25 @@ setup_view_from_metadata (EvWindow *window)
                        ev_window_run_fullscreen (window);
                }
        }
+
+       /* Rotation */
+       if (ev_metadata_manager_get (uri, "rotation", &rotation)) {
+               if (g_value_get_int (&rotation)) {
+                       switch (g_value_get_int (&rotation)) {
+                       case 90:
+                               ev_view_set_rotation (view, 90);
+                               break;
+                       case 180:
+                               ev_view_set_rotation (view, 180);
+                               break;
+                       case 270:
+                               ev_view_set_rotation (view, 270);
+                               break;
+                       default:
+                               break;
+                       }
+               }
+       }
 }
 
 void
@@ -2036,11 +2056,27 @@ ev_window_cmd_edit_toolbar_cb (GtkDialog *dialog, gint response, gpointer data)
         gtk_widget_destroy (GTK_WIDGET (dialog));
 }
 
+/* should these be hooked up to properties?? */
+static void
+save_rotation_to_file (EvWindow *window)
+{
+       int rotation;
+
+       if (window->priv->uri) {
+               rotation = ev_view_get_rotation (EV_VIEW (window->priv->view));
+               ev_metadata_manager_set_int (window->priv->uri, "rotation",
+                                            rotation);
+       }
+
+
+}
+
 static void
 ev_window_cmd_edit_rotate_left (GtkAction *action, EvWindow *ev_window)
 {
        ev_view_rotate_left (EV_VIEW (ev_window->priv->view));
        ev_sidebar_thumbnails_refresh (EV_SIDEBAR_THUMBNAILS (ev_window->priv->sidebar_thumbs));
+       save_rotation_to_file (ev_window);
 }
 
 static void
@@ -2048,6 +2084,7 @@ ev_window_cmd_edit_rotate_right (GtkAction *action, EvWindow *ev_window)
 {
        ev_view_rotate_right (EV_VIEW (ev_window->priv->view));
        ev_sidebar_thumbnails_refresh (EV_SIDEBAR_THUMBNAILS (ev_window->priv->sidebar_thumbs));
+       save_rotation_to_file (ev_window);
 }
 
 static void