summaryrefslogtreecommitdiff
path: root/src/book.vala
diff options
context:
space:
mode:
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> ();