+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
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);
#define MAX_ITEMS 50
-typedef struct _GeditMetadataManager GeditMetadataManager;
+typedef struct _EvMetadataManager EvMetadataManager;
typedef struct _Item Item;
GHashTable *values;
};
-struct _GeditMetadataManager
+struct _EvMetadataManager
{
gboolean values_loaded; /* It is true if the file
has been read */
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)
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;
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)
{
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,
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);
GValue dual_page = { 0, };
GValue presentation = { 0, };
GValue fullscreen = { 0, };
+ GValue rotation = { 0, };
/* Window size */
if (!GTK_WIDGET_VISIBLE (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
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
{
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