diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2023-06-28 21:39:42 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2023-06-28 21:39:42 +0200 |
commit | 408791709f23be34de957320384d02b228ea488f (patch) | |
tree | ca384fbb40da0add2aff715028fc6eff26934943 /src | |
parent | 4e699c8b150e8705f7b9b85742da2bbaab17358c (diff) | |
parent | 76380dae2a51f98cb6269e209bc39133a31372a4 (diff) |
Merge branch 'release/debian/44.0-1'debian/44.0-1
Diffstat (limited to 'src')
-rw-r--r-- | src/app-window.vala | 39 | ||||
-rw-r--r-- | src/book.vala | 26 | ||||
-rw-r--r-- | src/page-icon.vala | 21 | ||||
-rw-r--r-- | src/page.vala | 16 |
4 files changed, 86 insertions, 16 deletions
diff --git a/src/app-window.vala b/src/app-window.vala index cea6837..c4f9af7 100644 --- a/src/app-window.vala +++ b/src/app-window.vala @@ -1343,6 +1343,27 @@ public class AppWindow : Hdy.ApplicationWindow b.visible = true; g.attach (b, 1, 2, 1, 1); + /* Label on button for keeping the ordering, but flip every second upside down */ + b = make_reorder_button (_("Flip even pages upside-down"), "R1U2R3U4R5U6-R1R2R3R4R5R6"); + b.clicked.connect (() => + { + book.flip_every_second(FlipEverySecond.Even); + dialog.destroy (); + }); + b.visible = true; + g.attach (b, 0, 3, 1, 1); + + + /* Label on button for keeping the ordering, but flip every second upside down */ + b = make_reorder_button (_("Flip odd pages upside-down"), "U1R2U3R4U5R6-R1R2R3R4R5R6"); + b.clicked.connect (() => + { + book.flip_every_second(FlipEverySecond.Odd); + dialog.destroy (); + }); + b.visible = true; + g.attach (b, 1, 3, 1, 1); + dialog.present (); } @@ -1401,10 +1422,15 @@ public class AppWindow : Hdy.ApplicationWindow page_box.visible = true; box.add (page_box); } - - var icon = new PageIcon (side, items[i] - '1'); - icon.visible = true; - page_box.add (icon); + if (side == 'U') { + var icon = new PageIcon (side, items[i] - '1', 180); + icon.visible = true; + page_box.add (icon); + } else { + var icon = new PageIcon (side, items[i] - '1', 0); + icon.visible = true; + page_box.add (icon); + } } return box; @@ -1650,8 +1676,8 @@ public class AppWindow : Hdy.ApplicationWindow instructions = _("Drivers for this are available on the <a href=\"http://support.epson.com\">Epson website</a>."); break; case "lexmark_nscan": - /* Message to indicate an Lexmark scanner has been detected */ - message = _("You appear to have an Lexmark scanner."); + /* Message to indicate a Lexmark scanner has been detected */ + message = _("You appear to have a Lexmark scanner."); /* Instructions on how to install Lexmark scanner drivers */ instructions = _("Drivers for this are available on the <a href=\"http://support.lexmark.com\">Lexmark website</a>."); break; @@ -1849,6 +1875,7 @@ public class AppWindow : Hdy.ApplicationWindow app.set_accels_for_action ("app.print", { "<Ctrl>P" }); app.set_accels_for_action ("app.help", { "F1" }); app.set_accels_for_action ("app.quit", { "<Ctrl>Q" }); + app.set_accels_for_action ("app.preferences", { "<Ctrl>comma" }); app.set_accels_for_action ("win.show-help-overlay", { "<Ctrl>question" }); var gear_menu = new Menu (); 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> (); diff --git a/src/page-icon.vala b/src/page-icon.vala index f1a25ea..3e3fa93 100644 --- a/src/page-icon.vala +++ b/src/page-icon.vala @@ -14,12 +14,14 @@ public class PageIcon : Gtk.DrawingArea { private char side; private int position; + private int angle; private const int MINIMUM_WIDTH = 20; - public PageIcon (char side, int position) + public PageIcon (char side, int position, int angle) { this.side = side; this.position = position; + this.angle = angle; } public override void get_preferred_width (out int minimum_width, out int natural_width) @@ -73,6 +75,14 @@ public class PageIcon : Gtk.DrawingArea /* Orange 3 */ rgba.parse ("#ff7800"); break; + case 'U': + /* green 4 */ + rgba.parse ("#5cc02e"); + break; + case 'R': + /* blue 4 */ + rgba.parse ("#0deee7"); + break; default: /* Yellow 3 to Red 2 */ Gdk.RGBA start = {}, end = {}; @@ -109,8 +119,15 @@ public class PageIcon : Gtk.DrawingArea var text = @"$(position + 1)"; Cairo.TextExtents extents; + + var rad = Math.PI / 180.0 * angle; c.text_extents (text, out extents); - c.translate ((w - extents.width) * 0.5 - 0.5, (h + extents.height) * 0.5 - 0.5); + c.translate ((w - extents.width) * 0.5 - 0.5, extents.height + (h - extents.height) * 0.5 - 0.5); + c.rotate(rad); + // only correct for 0 and 180 degree + var tx = (1.0 - Math.sin(rad)) * extents.width / 2; + var ty = (1.0 - Math.sin(rad)) * extents.height / 2; + c.translate(-tx, +ty); c.show_text (text); return true; diff --git a/src/page.vala b/src/page.vala index 62af773..cfe70e1 100644 --- a/src/page.vala +++ b/src/page.vala @@ -400,20 +400,20 @@ public class Page : Object switch (name) { case "A3": - w = 11.7; - h = 16.5; + w = 11.692; + h = 16.535; break; case "A4": - w = 8.3; - h = 11.7; + w = 8.267; + h = 11.692; break; case "A5": - w = 5.8; - h = 8.3; + w = 5.846; + h = 8.267; break; case "A6": - w = 4.1; - h = 5.8; + w = 4.1335; + h = 5.846; break; case "letter": w = 8.5; |