summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/atril-ui.xml1
-rw-r--r--data/org.mate.Atril.gschema.xml3
-rw-r--r--libview/ev-view-private.h1
-rw-r--r--libview/ev-view.c47
-rw-r--r--shell/ev-window.c90
5 files changed, 100 insertions, 42 deletions
diff --git a/data/atril-ui.xml b/data/atril-ui.xml
index 823f7bd1..d6161396 100644
--- a/data/atril-ui.xml
+++ b/data/atril-ui.xml
@@ -41,6 +41,7 @@
<separator/>
<menuitem name="ViewContinuousMenu" action="ViewContinuous"/>
<menuitem name="ViewDualMenu" action="ViewDual"/>
+ <menuitem name="ViewDualOddLeftMenu" action="ViewDualOddLeft"/>
<separator/>
<menuitem name="ViewInvertedColors" action="ViewInvertedColors"/>
<separator/>
diff --git a/data/org.mate.Atril.gschema.xml b/data/org.mate.Atril.gschema.xml
index e3d32c42..0b2ee18f 100644
--- a/data/org.mate.Atril.gschema.xml
+++ b/data/org.mate.Atril.gschema.xml
@@ -59,6 +59,9 @@
<key name="dual-page" type="b">
<default>false</default>
</key>
+ <key name="dual-page-odd-left" type="b">
+ <default>false</default>
+ </key>
<key name="fullscreen" type="b">
<default>false</default>
</key>
diff --git a/libview/ev-view-private.h b/libview/ev-view-private.h
index 5cfdaae8..b6c0ea5f 100644
--- a/libview/ev-view-private.h
+++ b/libview/ev-view-private.h
@@ -103,6 +103,7 @@ typedef enum {
typedef struct _EvHeightToPageCache {
gint rotation;
+ gboolean dual_even_left;
gdouble *height_to_page;
gdouble *dual_height_to_page;
} EvHeightToPageCache;
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 9da4b8ad..e6634c15 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -143,7 +143,6 @@ static void doc_rect_to_view_rect (EvView
int page,
EvRectangle *doc_rect,
GdkRectangle *view_rect);
-static gboolean get_dual_even_left (EvView *view);
static void find_page_at_location (EvView *view,
gdouble x,
gdouble y,
@@ -339,7 +338,7 @@ static void
ev_view_build_height_to_page_cache (EvView *view,
EvHeightToPageCache *cache)
{
- gboolean swap, uniform, dual_even_left;
+ gboolean swap, uniform;
int i;
double uniform_height, page_height, next_page_height;
double saved_height;
@@ -351,12 +350,12 @@ ev_view_build_height_to_page_cache (EvView *view,
uniform = ev_document_is_page_size_uniform (document);
n_pages = ev_document_get_n_pages (document);
- dual_even_left = get_dual_even_left (view);
g_free (cache->height_to_page);
g_free (cache->dual_height_to_page);
cache->rotation = view->rotation;
+ cache->dual_even_left = view->dual_even_left;
cache->height_to_page = g_new0 (gdouble, n_pages + 1);
cache->dual_height_to_page = g_new0 (gdouble, n_pages + 2);
@@ -382,7 +381,7 @@ ev_view_build_height_to_page_cache (EvView *view,
}
}
- if (dual_even_left && !uniform) {
+ if (cache->dual_even_left && !uniform) {
gdouble w, h;
ev_document_get_page_size (document, 0, &w, &h);
@@ -391,12 +390,12 @@ ev_view_build_height_to_page_cache (EvView *view,
saved_height = 0;
}
- for (i = dual_even_left; i < n_pages + 2; i += 2) {
+ for (i = cache->dual_even_left; i < n_pages + 2; i += 2) {
if (uniform) {
uniform_height = swap ? u_width : u_height;
- cache->dual_height_to_page[i] = ((i + dual_even_left) / 2) * uniform_height;
+ cache->dual_height_to_page[i] = ((i + cache->dual_even_left) / 2) * uniform_height;
if (i + 1 < n_pages + 2)
- cache->dual_height_to_page[i + 1] = ((i + dual_even_left) / 2) * uniform_height;
+ cache->dual_height_to_page[i + 1] = ((i + cache->dual_even_left) / 2) * uniform_height;
} else {
if (i + 1 < n_pages) {
gdouble w, h;
@@ -476,8 +475,10 @@ ev_view_get_height_to_page (EvView *view,
return;
cache = view->height_to_page_cache;
- if (cache->rotation != view->rotation)
+ if (cache->rotation != view->rotation ||
+ cache->dual_even_left != view->dual_even_left) {
ev_view_build_height_to_page_cache (view, cache);
+ }
h = cache->height_to_page[page];
dh = cache->dual_height_to_page[page];
@@ -737,7 +738,7 @@ view_update_range_and_current_page (EvView *view)
}
}
} else if (view->dual_page) {
- if (view->current_page % 2 == get_dual_even_left (view)) {
+ if (view->current_page % 2 == view->dual_even_left) {
view->start_page = view->current_page;
if (view->current_page + 1 < ev_document_get_n_pages (view->document))
view->end_page = view->start_page + 1;
@@ -1164,8 +1165,8 @@ get_page_y_offset (EvView *view, int page, int *y_offset)
if (view->dual_page) {
ev_view_get_height_to_page (view, page, NULL, &offset);
- offset += ((page + get_dual_even_left (view)) / 2 + 1) * view->spacing +
- ((page + get_dual_even_left (view)) / 2 ) * (border.top + border.bottom);
+ offset += ((page + view->dual_even_left) / 2 + 1) * view->spacing +
+ ((page + view->dual_even_left) / 2 ) * (border.top + border.bottom);
} else {
ev_view_get_height_to_page (view, page, &offset, NULL);
offset += (page + 1) * view->spacing + page * (border.top + border.bottom);
@@ -1202,9 +1203,9 @@ ev_view_get_page_extents (EvView *view,
max_width = max_width + border->left + border->right;
/* Get the location of the bounding box */
if (view->dual_page) {
- x = view->spacing + ((page % 2 == get_dual_even_left (view)) ? 0 : 1) * (max_width + view->spacing);
+ x = view->spacing + ((page % 2 == view->dual_even_left) ? 0 : 1) * (max_width + view->spacing);
x = x + MAX (0, allocation.width - (max_width * 2 + view->spacing * 3)) / 2;
- if (page % 2 == get_dual_even_left (view))
+ if (page % 2 == view->dual_even_left)
x = x + (max_width - width - border->left - border->right);
} else {
x = view->spacing;
@@ -1224,7 +1225,7 @@ ev_view_get_page_extents (EvView *view,
GtkBorder overall_border;
gint other_page;
- other_page = (page % 2 == get_dual_even_left (view)) ? page + 1: page - 1;
+ other_page = (page % 2 == view->dual_even_left) ? page + 1: page - 1;
/* First, we get the bounding box of the two pages */
if (other_page < ev_document_get_n_pages (view->document)
@@ -1243,7 +1244,7 @@ ev_view_get_page_extents (EvView *view,
y = view->spacing;
/* Adjust for being the left or right page */
- if (page % 2 == get_dual_even_left (view))
+ if (page % 2 == view->dual_even_left)
x = x + max_width - width;
else
x = x + (max_width + overall_border.left + overall_border.right) + view->spacing;
@@ -1393,13 +1394,6 @@ doc_rect_to_view_rect (EvView *view,
view_rect->height = h * view->scale;
}
-static gboolean
-get_dual_even_left (EvView *view)
-{
- gint n_pages = ev_document_get_n_pages (view->document);
- return (n_pages > 2 && view->dual_even_left);
-}
-
static void
find_page_at_location (EvView *view,
gdouble x,
@@ -5729,7 +5723,7 @@ ev_view_dual_page_changed_cb (EvDocumentModel *model,
{
gboolean dual_page = ev_document_model_get_dual_page (model);
- view->dual_page = dual_page;
+ view->dual_page = dual_page || ev_document_model_get_dual_page_odd_pages_left (model);
view->pending_scroll = SCROLL_TO_PAGE_POSITION;
/* FIXME: if we're keeping the pixbuf cache around, we should extend the
* preload_cache_size to be 2 if dual_page is set.
@@ -5742,11 +5736,12 @@ ev_view_dual_odd_left_changed_cb (EvDocumentModel *model,
GParamSpec *pspec,
EvView *view)
{
- view->dual_even_left = !ev_document_model_get_dual_page_odd_pages_left (model);
+ gboolean dual_odd_left = ev_document_model_get_dual_page_odd_pages_left (model);
+
+ view->dual_page = dual_odd_left || ev_document_model_get_dual_page (model);
+ view->dual_even_left = !dual_odd_left;
view->pending_scroll = SCROLL_TO_PAGE_POSITION;
- /* Total height of some page pairs may changes, recompute cache */
- ev_view_build_height_to_page_cache(view, view->height_to_page_cache);
gtk_widget_queue_resize (GTK_WIDGET (view));
}
diff --git a/shell/ev-window.c b/shell/ev-window.c
index b0768d88..1149c929 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -482,6 +482,7 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window)
*/
ev_window_set_action_sensitive (ev_window, "ViewContinuous", has_pages && !(document->iswebdocument));
ev_window_set_action_sensitive (ev_window, "ViewDual", has_pages && !(document->iswebdocument));
+ ev_window_set_action_sensitive (ev_window, "ViewDualOddLeft", has_pages);
ev_window_set_action_sensitive (ev_window, "ViewBestFit", has_pages && !(document->iswebdocument));
ev_window_set_action_sensitive (ev_window, "ViewPageWidth", has_pages && !(document->iswebdocument));
ev_window_set_action_sensitive (ev_window, "ViewReload", has_pages);
@@ -1144,6 +1145,10 @@ ev_window_init_metadata_with_default_values (EvWindow *window)
ev_metadata_set_boolean (metadata, "dual-page",
g_settings_get_boolean (settings, "dual-page"));
}
+ if (!ev_metadata_has_key (metadata, "dual-page-odd-left")) {
+ ev_metadata_set_boolean (metadata, "dual-page-odd-left",
+ g_settings_get_boolean (settings, "dual-page-odd-left"));
+ }
if (!ev_metadata_has_key (metadata, "inverted-colors")) {
ev_metadata_set_boolean (metadata, "inverted-colors",
g_settings_get_boolean (settings, "inverted-colors"));
@@ -1208,6 +1213,7 @@ setup_model_from_metadata (EvWindow *window)
gboolean inverted_colors = FALSE;
gboolean continuous = FALSE;
gboolean dual_page = FALSE;
+ gboolean dual_page_odd_left = FALSE;
gboolean fullscreen = FALSE;
if (!window->priv->metadata)
@@ -1270,6 +1276,11 @@ setup_model_from_metadata (EvWindow *window)
ev_document_model_set_dual_page (window->priv->model, dual_page);
}
+ /* Dual page odd pages left */
+ if (ev_metadata_get_boolean (window->priv->metadata, "dual-page-odd-left", &dual_page_odd_left)) {
+ ev_document_model_set_dual_page_odd_pages_left (window->priv->model, dual_page_odd_left);
+ }
+
/* Fullscreen */
if (ev_metadata_get_boolean (window->priv->metadata, "fullscreen", &fullscreen)) {
if (fullscreen)
@@ -1417,6 +1428,7 @@ ev_window_setup_default (EvWindow *ev_window)
/* Document model */
ev_document_model_set_continuous (model, g_settings_get_boolean (settings, "continuous"));
ev_document_model_set_dual_page (model, g_settings_get_boolean (settings, "dual-page"));
+ ev_document_model_set_dual_page_odd_pages_left (model, g_settings_get_boolean (settings, "dual-page-odd-left"));
ev_document_model_set_inverted_colors (model, g_settings_get_boolean (settings, "inverted-colors"));
ev_document_model_set_sizing_mode (model, g_settings_get_enum (settings, "sizing-mode"));
if (ev_document_model_get_sizing_mode (model) == EV_SIZING_FREE)
@@ -3937,6 +3949,17 @@ ev_window_cmd_dual (GtkAction *action, EvWindow *ev_window)
}
static void
+ev_window_cmd_dual_odd_pages_left (GtkAction *action, EvWindow *ev_window)
+{
+ gboolean dual_page_odd_left;
+
+ ev_window_stop_presentation (ev_window, TRUE);
+ dual_page_odd_left = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ ev_document_model_set_dual_page_odd_pages_left (ev_window->priv->model,
+ dual_page_odd_left);
+}
+
+static void
ev_window_cmd_view_best_fit (GtkAction *action, EvWindow *ev_window)
{
ev_window_stop_presentation (ev_window, TRUE);
@@ -4633,6 +4656,8 @@ ev_window_cmd_edit_save_settings (GtkAction *action, EvWindow *ev_window)
ev_document_model_get_continuous (model));
g_settings_set_boolean (settings, "dual-page",
ev_document_model_get_dual_page (model));
+ g_settings_set_boolean (settings, "dual-page-odd-left",
+ ev_document_model_get_dual_page_odd_pages_left (model));
g_settings_set_boolean (settings, "fullscreen",
ev_document_model_get_fullscreen (model));
g_settings_set_boolean (settings, "inverted-colors",
@@ -5023,20 +5048,6 @@ ev_window_update_continuous_action (EvWindow *window)
}
static void
-ev_window_update_dual_page_action (EvWindow *window)
-{
- GtkAction *action;
-
- action = gtk_action_group_get_action (window->priv->action_group, "ViewDual");
- g_signal_handlers_block_by_func
- (action, G_CALLBACK (ev_window_cmd_dual), window);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- ev_document_model_get_dual_page (window->priv->model));
- g_signal_handlers_unblock_by_func
- (action, G_CALLBACK (ev_window_cmd_dual), window);
-}
-
-static void
ev_window_continuous_changed_cb (EvDocumentModel *model,
GParamSpec *pspec,
EvWindow *ev_window)
@@ -5094,6 +5105,20 @@ ev_window_inverted_colors_changed_cb (EvDocumentModel *model,
}
static void
+ev_window_update_dual_page_action (EvWindow *window)
+{
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (window->priv->action_group, "ViewDual");
+ g_signal_handlers_block_by_func
+ (action, G_CALLBACK (ev_window_cmd_dual), window);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+ ev_document_model_get_dual_page (window->priv->model));
+ g_signal_handlers_unblock_by_func
+ (action, G_CALLBACK (ev_window_cmd_dual), window);
+}
+
+static void
ev_window_dual_mode_changed_cb (EvDocumentModel *model,
GParamSpec *pspec,
EvWindow *ev_window)
@@ -5105,6 +5130,32 @@ ev_window_dual_mode_changed_cb (EvDocumentModel *model,
ev_document_model_get_dual_page (model));
}
+static void
+ev_window_update_dual_page_odd_pages_left_action (EvWindow *window)
+{
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (window->priv->action_group, "ViewDualOddLeft");
+ g_signal_handlers_block_by_func
+ (action, G_CALLBACK (ev_window_cmd_dual_odd_pages_left), window);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+ ev_document_model_get_dual_page_odd_pages_left (window->priv->model));
+ g_signal_handlers_unblock_by_func
+ (action, G_CALLBACK (ev_window_cmd_dual_odd_pages_left), window);
+}
+
+static void
+ev_window_dual_mode_odd_pages_left_changed_cb (EvDocumentModel *model,
+ GParamSpec *pspec,
+ EvWindow *ev_window)
+{
+ ev_window_update_dual_page_odd_pages_left_action (ev_window);
+
+ if (ev_window->priv->metadata && !ev_window_is_empty (ev_window))
+ ev_metadata_set_boolean (ev_window->priv->metadata, "dual-page-odd-left",
+ ev_document_model_get_dual_page_odd_pages_left (model));
+}
+
static char *
build_comments_string (EvDocument *document)
{
@@ -6278,9 +6329,12 @@ static const GtkToggleActionEntry toggle_entries[] = {
{ "ViewContinuous", EV_STOCK_VIEW_CONTINUOUS, N_("_Continuous"), NULL,
N_("Show the entire document"),
G_CALLBACK (ev_window_cmd_continuous), TRUE },
- { "ViewDual", EV_STOCK_VIEW_DUAL, N_("_Dual"), NULL,
- N_("Show two pages at once"),
+ { "ViewDual", EV_STOCK_VIEW_DUAL, N_("_Dual (Even pages left)"), NULL,
+ N_("Show two pages at once with even pages on the left"),
G_CALLBACK (ev_window_cmd_dual), FALSE },
+ { "ViewDualOddLeft", EV_STOCK_VIEW_DUAL, N_("Dual (_Odd pages left)"), NULL,
+ N_("Show two pages at once with odd pages on the left"),
+ G_CALLBACK (ev_window_cmd_dual_odd_pages_left), FALSE },
{ "ViewFullscreen", GTK_STOCK_FULLSCREEN, N_("_Fullscreen"), "F11",
N_("Expand the window to fill the screen"),
G_CALLBACK (ev_window_cmd_view_fullscreen) },
@@ -7930,6 +7984,10 @@ ev_window_init (EvWindow *ev_window)
G_CALLBACK (ev_window_dual_mode_changed_cb),
ev_window);
g_signal_connect (ev_window->priv->model,
+ "notify::dual-odd-left",
+ G_CALLBACK (ev_window_dual_mode_odd_pages_left_changed_cb),
+ ev_window);
+ g_signal_connect (ev_window->priv->model,
"notify::inverted-colors",
G_CALLBACK (ev_window_inverted_colors_changed_cb),
ev_window);