[evince] presentation: Allow to change rotation in presentation mode
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] presentation: Allow to change rotation in presentation mode
- Date: Sat, 12 Feb 2011 11:54:06 +0000 (UTC)
commit ef9c2b1a189ddbdbd7cdb10dad6c3c6db4cb0ccd
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Sat Feb 12 12:49:49 2011 +0100
presentation: Allow to change rotation in presentation mode
libview/ev-view-presentation.c | 91 ++++++++++++++++++++++++++++++++--------
libview/ev-view-presentation.h | 3 +
2 files changed, 76 insertions(+), 18 deletions(-)
---
diff --git a/libview/ev-view-presentation.c b/libview/ev-view-presentation.c
index 3454d77..53acf2f 100644
--- a/libview/ev-view-presentation.c
+++ b/libview/ev-view-presentation.c
@@ -57,6 +57,8 @@ struct _EvViewPresentation
{
GtkWidget base;
+ guint is_constructing : 1;
+
guint current_page;
cairo_surface_t *current_surface;
EvDocument *document;
@@ -380,6 +382,25 @@ ev_view_presentation_delete_job (EvViewPresentation *pview,
}
static void
+ev_view_presentation_reset_jobs (EvViewPresentation *pview)
+{
+ if (pview->curr_job) {
+ ev_view_presentation_delete_job (pview, pview->curr_job);
+ pview->curr_job = NULL;
+ }
+
+ if (pview->prev_job) {
+ ev_view_presentation_delete_job (pview, pview->prev_job);
+ pview->prev_job = NULL;
+ }
+
+ if (pview->next_job) {
+ ev_view_presentation_delete_job (pview, pview->next_job);
+ pview->next_job = NULL;
+ }
+}
+
+static void
ev_view_presentation_update_current_page (EvViewPresentation *pview,
guint page)
{
@@ -927,21 +948,7 @@ ev_view_presentation_dispose (GObject *object)
ev_view_presentation_animation_cancel (pview);
ev_view_presentation_transition_stop (pview);
ev_view_presentation_hide_cursor_timeout_stop (pview);
-
- if (pview->curr_job) {
- ev_view_presentation_delete_job (pview, pview->curr_job);
- pview->curr_job = NULL;
- }
-
- if (pview->prev_job) {
- ev_view_presentation_delete_job (pview, pview->prev_job);
- pview->prev_job = NULL;
- }
-
- if (pview->next_job) {
- ev_view_presentation_delete_job (pview, pview->next_job);
- pview->next_job = NULL;
- }
+ ev_view_presentation_reset_jobs (pview);
if (pview->current_surface) {
cairo_surface_destroy (pview->current_surface);
@@ -1345,7 +1352,7 @@ ev_view_presentation_set_property (GObject *object,
pview->current_page = g_value_get_uint (value);
break;
case PROP_ROTATION:
- pview->rotation = g_value_get_uint (value);
+ ev_view_presentation_set_rotation (pview, g_value_get_uint (value));
break;
case PROP_INVERTED_COLORS:
pview->inverted_colors = g_value_get_boolean (value);
@@ -1355,6 +1362,23 @@ ev_view_presentation_set_property (GObject *object,
}
}
+static void
+ev_view_presentation_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EvViewPresentation *pview = EV_VIEW_PRESENTATION (object);
+
+ switch (prop_id) {
+ case PROP_ROTATION:
+ g_value_set_uint (value, ev_view_presentation_get_rotation (pview));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
static GObject *
ev_view_presentation_constructor (GType type,
guint n_construct_properties,
@@ -1367,6 +1391,7 @@ ev_view_presentation_constructor (GType type,
n_construct_properties,
construct_params);
pview = EV_VIEW_PRESENTATION (object);
+ pview->is_constructing = FALSE;
if (EV_IS_DOCUMENT_LINKS (pview->document)) {
pview->page_cache = ev_page_cache_new (pview->document);
@@ -1400,6 +1425,7 @@ ev_view_presentation_class_init (EvViewPresentationClass *klass)
gobject_class->constructor = ev_view_presentation_constructor;
gobject_class->set_property = ev_view_presentation_set_property;
+ gobject_class->get_property = ev_view_presentation_get_property;
g_object_class_install_property (gobject_class,
PROP_DOCUMENT,
@@ -1423,8 +1449,8 @@ ev_view_presentation_class_init (EvViewPresentationClass *klass)
"Rotation",
"Current rotation angle",
0, 360, 0,
- G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT_ONLY));
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
g_object_class_install_property (gobject_class,
PROP_INVERTED_COLORS,
g_param_spec_boolean ("inverted_colors",
@@ -1507,6 +1533,7 @@ static void
ev_view_presentation_init (EvViewPresentation *pview)
{
gtk_widget_set_can_focus (GTK_WIDGET (pview), TRUE);
+ pview->is_constructing = TRUE;
}
GtkWidget *
@@ -1531,3 +1558,31 @@ ev_view_presentation_get_current_page (EvViewPresentation *pview)
{
return pview->current_page;
}
+
+void
+ev_view_presentation_set_rotation (EvViewPresentation *pview,
+ gint rotation)
+{
+ if (rotation >= 360)
+ rotation -= 360;
+ else if (rotation < 0)
+ rotation += 360;
+
+ if (pview->rotation == rotation)
+ return;
+
+ pview->rotation = rotation;
+ g_object_notify (G_OBJECT (pview), "rotation");
+ if (pview->is_constructing)
+ return;
+
+ pview->scale = 0;
+ ev_view_presentation_reset_jobs (pview);
+ ev_view_presentation_update_current_page (pview, pview->current_page);
+}
+
+guint
+ev_view_presentation_get_rotation (EvViewPresentation *pview)
+{
+ return pview->rotation;
+}
diff --git a/libview/ev-view-presentation.h b/libview/ev-view-presentation.h
index ad0a33a..e785769 100644
--- a/libview/ev-view-presentation.h
+++ b/libview/ev-view-presentation.h
@@ -47,6 +47,9 @@ GtkWidget *ev_view_presentation_new (EvDocument *document,
guint ev_view_presentation_get_current_page (EvViewPresentation *pview);
void ev_view_presentation_next_page (EvViewPresentation *pview);
void ev_view_presentation_previous_page (EvViewPresentation *pview);
+void ev_view_presentation_set_rotation (EvViewPresentation *pview,
+ gint rotation);
+guint ev_view_presentation_get_rotation (EvViewPresentation *pview);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]