summaryrefslogtreecommitdiff
path: root/src/book.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2023-06-28 21:39:42 +0200
committerJörg Frings-Fürst <debian@jff.email>2023-06-28 21:39:42 +0200
commit408791709f23be34de957320384d02b228ea488f (patch)
treeca384fbb40da0add2aff715028fc6eff26934943 /src/book.vala
parent4e699c8b150e8705f7b9b85742da2bbaab17358c (diff)
parent76380dae2a51f98cb6269e209bc39133a31372a4 (diff)
Merge branch 'release/debian/44.0-1'debian/44.0-1
Diffstat (limited to 'src/book.vala')
-rw-r--r--src/book.vala26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/book.vala b/src/book.vala
index d2aa54d..e25eb35 100644
--- a/src/book.vala
+++ b/src/book.vala
@@ -11,6 +11,12 @@
public delegate void ProgressionCallback (double fraction);
+// Assumes first page has index 0
+public enum FlipEverySecond {
+ Even = 1,
+ Odd = 0,
+}
+
public class Book : Object
{
private List<Page> pages;
@@ -99,6 +105,26 @@ public class Book : Object
changed ();
}
+ public void flip_every_second (FlipEverySecond flip)
+ {
+ var new_pages = new List<Page> ();
+ for (var i = 0; i < n_pages; i++)
+ {
+ var page = pages.nth_data (i);
+ if (i % 2 == (int)flip) {
+ page.rotate_left();
+ page.rotate_left();
+ new_pages.append (page);
+ } else {
+ new_pages.append (page);
+ }
+ }
+ pages = (owned) new_pages;
+
+ reordered ();
+ changed ();
+ }
+
public void combine_sides_reverse ()
{
var new_pages = new List<Page> ();