summaryrefslogtreecommitdiff
path: root/libview/ev-document-model.c
diff options
context:
space:
mode:
authorWilliam Jon McCann <[email protected]>2013-01-10 18:35:04 +0100
committerraveit65 <[email protected]>2017-08-31 13:28:21 +0200
commit2fb770b3245c3066cd9c556f12793f4ed69ee52d (patch)
treeffb21c769d2c05f7d7e768e1a8142e4539b23b0a /libview/ev-document-model.c
parent3e3b8bad7b5b272e3a535e7b3fe22c04fc722a78 (diff)
downloadatril-2fb770b3245c3066cd9c556f12793f4ed69ee52d.tar.bz2
atril-2fb770b3245c3066cd9c556f12793f4ed69ee52d.tar.xz
libview: Make page layout a mode
Instead of having a few different mutually exclusive booleans it makes sense to have it be a mode with the following options: automatic, single, dual. This allows us to have a way to automatically determine if dual page mode should be used when the window is large enough. https://bugzilla.gnome.org/show_bug.cgi?id=689468 origin commit: https://git.gnome.org/browse/evince/commit/?h=gnome-3-10&id=42f6d4b
Diffstat (limited to 'libview/ev-document-model.c')
-rw-r--r--libview/ev-document-model.c72
1 files changed, 63 insertions, 9 deletions
diff --git a/libview/ev-document-model.c b/libview/ev-document-model.c
index 856ee36e..d5d97f62 100644
--- a/libview/ev-document-model.c
+++ b/libview/ev-document-model.c
@@ -35,6 +35,7 @@ struct _EvDocumentModel
gint rotation;
gdouble scale;
EvSizingMode sizing_mode;
+ EvPageLayout page_layout;
guint continuous : 1;
guint dual_page : 1;
guint dual_page_odd_left : 1;
@@ -66,7 +67,8 @@ enum {
PROP_CONTINUOUS,
PROP_DUAL_PAGE,
PROP_DUAL_PAGE_ODD_LEFT,
- PROP_FULLSCREEN
+ PROP_FULLSCREEN,
+ PROP_PAGE_LAYOUT
};
enum
@@ -122,6 +124,9 @@ ev_document_model_set_property (GObject *object,
case PROP_CONTINUOUS:
ev_document_model_set_continuous (model, g_value_get_boolean (value));
break;
+ case PROP_PAGE_LAYOUT:
+ ev_document_model_set_page_layout (model, g_value_get_enum (value));
+ break;
case PROP_DUAL_PAGE:
ev_document_model_set_dual_page (model, g_value_get_boolean (value));
break;
@@ -166,6 +171,9 @@ ev_document_model_get_property (GObject *object,
case PROP_CONTINUOUS:
g_value_set_boolean (value, ev_document_model_get_continuous (model));
break;
+ case PROP_PAGE_LAYOUT:
+ g_value_set_enum (value, model->page_layout);
+ break;
case PROP_DUAL_PAGE:
g_value_set_boolean (value, ev_document_model_get_dual_page (model));
break;
@@ -234,6 +242,15 @@ ev_document_model_class_init (EvDocumentModelClass *klass)
EV_SIZING_FIT_WIDTH,
G_PARAM_READWRITE));
g_object_class_install_property (g_object_class,
+ PROP_PAGE_LAYOUT,
+ g_param_spec_enum ("page-layout",
+ "Page Layout",
+ "Current page layout",
+ EV_TYPE_PAGE_LAYOUT,
+ EV_PAGE_LAYOUT_SINGLE,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (g_object_class,
PROP_CONTINUOUS,
g_param_spec_boolean ("continuous",
"Continuous",
@@ -472,6 +489,47 @@ ev_document_model_get_sizing_mode (EvDocumentModel *model)
return model->sizing_mode;
}
+static void
+_ev_document_model_set_dual_page_internal (EvDocumentModel *model,
+ gboolean dual_page)
+{
+ g_return_if_fail (EV_IS_DOCUMENT_MODEL (model));
+
+ dual_page = dual_page != FALSE;
+
+ if (dual_page == model->dual_page)
+ return;
+
+ model->dual_page = dual_page;
+
+ g_object_notify (G_OBJECT (model), "dual-page");
+}
+
+void
+ev_document_model_set_page_layout (EvDocumentModel *model,
+ EvPageLayout layout)
+{
+ g_return_if_fail (EV_IS_DOCUMENT_MODEL (model));
+
+ if (layout == model->page_layout)
+ return;
+
+ model->page_layout = layout;
+
+ g_object_notify (G_OBJECT (model), "page-layout");
+
+ /* set deprecated property as well */
+ _ev_document_model_set_dual_page_internal (model, layout == EV_PAGE_LAYOUT_DUAL);
+}
+
+EvPageLayout
+ev_document_model_get_page_layout (EvDocumentModel *model)
+{
+ g_return_val_if_fail (EV_IS_DOCUMENT_MODEL (model), EV_PAGE_LAYOUT_SINGLE);
+
+ return model->page_layout;
+}
+
void
ev_document_model_set_rotation (EvDocumentModel *model,
gint rotation)
@@ -549,16 +607,12 @@ void
ev_document_model_set_dual_page (EvDocumentModel *model,
gboolean dual_page)
{
- g_return_if_fail (EV_IS_DOCUMENT_MODEL (model));
-
- dual_page = dual_page != FALSE;
-
- if (dual_page == model->dual_page)
- return;
+ EvPageLayout layout;
- model->dual_page = dual_page;
+ g_return_if_fail (EV_IS_DOCUMENT_MODEL (model));
- g_object_notify (G_OBJECT (model), "dual-page");
+ layout = dual_page ? EV_PAGE_LAYOUT_DUAL : EV_PAGE_LAYOUT_SINGLE;
+ ev_document_model_set_page_layout (model, layout);
}
gboolean