+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),
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)
typedef enum
{
- EV_ORIENTATION_DOCUMENT,
EV_ORIENTATION_PORTRAIT,
EV_ORIENTATION_LANDSCAPE,
EV_ORIENTATION_UPSIDEDOWN,
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);
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);
<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>
pdf_document_init (PdfDocument *pdf_document)
{
pdf_document->password = NULL;
+ pdf_document->orientation = POPPLER_ORIENTATION_PORTRAIT;
}
static void
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,
return FALSE;
}
+ pdf_document->orientation = get_document_orientation (pdf_document);
+
return TRUE;
}
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)
{
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;
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
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)
{
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;
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
ev_view_set_zoom (view, ZOOM_OUT_FACTOR, TRUE);
}
-void
+static void
ev_view_set_orientation (EvView *view,
EvOrientation orientation)
{
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,
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);
}
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
{ "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",