[simple-scan/relayout: 2/2] WIP



commit 8b4e7a7f34172f81ed502ab83183146497148433
Author: Robert Ancell <robert ancell canonical com>
Date:   Mon Sep 17 12:03:48 2018 +0200

    WIP

 src/app-window.vala | 10 ++++++++++
 src/book.vala       | 15 +++++++++++++++
 2 files changed, 25 insertions(+)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index 688ac89..0a9e3f0 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -82,6 +82,7 @@ public class AppWindow : Gtk.ApplicationWindow
     private Gtk.Button scan_button;
     [GtkChild]
     private Gtk.ActionBar action_bar;
+    private Gtk.Button duplicate_button;
     private Gtk.ToggleButton crop_button;
     private Gtk.Button delete_button;
 
@@ -1596,6 +1597,15 @@ public class AppWindow : Gtk.ApplicationWindow
         button.clicked.connect (rotate_right_button_clicked_cb);
         rotate_box.add (button);
 
+        duplicate_button = new Gtk.Button.from_icon_name ("edit-copy-symbolic");
+        duplicate_button.visible = true;
+        duplicate_button.image.margin_start = 18;
+        duplicate_button.image.margin_end = 18;
+        /* Tooltip for duplicate button */
+        duplicate_button.tooltip_text = _("Duplicate the selected page");
+        duplicate_button.clicked.connect (() => { book.duplicate_page (page_view.page); });
+        box.pack_start (duplicate_button, false, true, 0);
+
         crop_button = new Gtk.ToggleButton ();
         crop_button.visible = true;
         var image = new Gtk.Image.from_icon_name ("edit-cut-symbolic", Gtk.IconSize.BUTTON);
diff --git a/src/book.vala b/src/book.vala
index d53b31a..19f42ef 100644
--- a/src/book.vala
+++ b/src/book.vala
@@ -115,6 +115,21 @@ public class Book
         changed ();
     }
 
+    public void duplicate_page (Page page)
+    {
+        var duplicated_page = new Page.from_data (page.scan_width, page.scan_height, page.rowstride,
+                                                  page.n_channels, page.depth, page.dpi,
+                                                  page.scan_direction,
+                                                  page.color_profile,
+                                                  page.get_pixels (),
+                                                  page.has_crop,
+                                                  page.crop_name,
+                                                  page.crop_x, page.crop_y, page.crop_width, 
page.crop_height);
+        pages.insert (duplicated_page, pages.index (page) + 1);
+        page_added (duplicated_page);
+        changed ();
+    }
+
     public void delete_page (Page page)
     {
         page.pixels_changed.disconnect (page_changed_cb);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]