[simple-scan/gnome-3-28] Fix scan shortcut keys no longer working.



commit 4be7ec5356857492d4b2beb77e9bbcefc091b0bb
Author: Robert Ancell <robert ancell canonical com>
Date:   Tue Jul 23 09:43:54 2019 +1200

    Fix scan shortcut keys no longer working.

 src/app-window.vala | 100 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 91 insertions(+), 9 deletions(-)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index 1475e0a..65adef2 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -19,6 +19,16 @@ public class AppWindow : Gtk.ApplicationWindow
     private const GLib.ActionEntry[] action_entries =
     {
         { "new_document", new_document_activate_cb },
+        { "scan_single", scan_single_cb },
+        { "scan_adf", scan_adf_cb },
+        { "scan_batch", scan_batch_cb },
+        { "scan_stop", scan_stop_cb },
+        { "rotate_left", rotate_left_cb },
+        { "rotate_right", rotate_right_cb },
+        { "move_left", move_left_cb },
+        { "move_right", move_right_cb },
+        { "copy_page", copy_page_cb },
+        { "delete_page", delete_page_cb },
         { "reorder", reorder_document_activate_cb },
         { "save", save_document_activate_cb },
         { "email", email_document_activate_cb },
@@ -614,6 +624,70 @@ public class AppWindow : Gtk.ApplicationWindow
         return false;
     }
 
+    private void scan (ScanOptions options)
+    {
+        status_primary_label.set_text (/* Label shown when scan started */
+                                       _("Contacting scanner…"));
+        start_scan (selected_device, options);
+    }
+
+    private void scan_single_cb ()
+    {
+        var options = make_scan_options ();
+        options.type = ScanType.SINGLE;
+        scan (options);
+    }
+
+    private void scan_adf_cb ()
+    {
+        var options = make_scan_options ();
+        options.type = ScanType.ADF_BOTH;
+        options.type = preferences_dialog.get_page_side ();
+        scan (options);
+    }
+
+    private void scan_batch_cb ()
+    {
+        var options = make_scan_options ();
+        options.type = ScanType.BATCH;
+        scan (options);
+    }
+
+    private void scan_stop_cb ()
+    {
+        stop_scan ();
+    }
+
+    private void rotate_left_cb ()
+    {
+        rotate_left_button_clicked_cb ();
+    }
+
+    private void rotate_right_cb ()
+    {
+        rotate_right_button_clicked_cb ();
+    }
+
+    private void move_left_cb ()
+    {
+        page_move_left_menuitem_activate_cb ();
+    }
+
+    private void move_right_cb ()
+    {
+        page_move_right_menuitem_activate_cb ();
+    }
+
+    private void copy_page_cb ()
+    {
+        copy_to_clipboard_button_clicked_cb ();
+    }
+
+    private void delete_page_cb ()
+    {
+        page_delete_menuitem_activate_cb ();
+    }
+
     [GtkCallback]
     private void new_button_clicked_cb (Gtk.Widget widget)
     {
@@ -688,9 +762,7 @@ public class AppWindow : Gtk.ApplicationWindow
     {
         var options = make_scan_options ();
         options.type = ScanType.SINGLE;
-        status_primary_label.set_text (/* Label shown when scan started */
-                                       _("Contacting scanner…"));
-        start_scan (selected_device, options);
+        scan (options);
     }
 
     [GtkCallback]
@@ -820,7 +892,7 @@ public class AppWindow : Gtk.ApplicationWindow
     }
 
     [GtkCallback]
-    private void rotate_left_button_clicked_cb (Gtk.Widget widget)
+    private void rotate_left_button_clicked_cb ()
     {
         if (updating_page_menu)
             return;
@@ -830,7 +902,7 @@ public class AppWindow : Gtk.ApplicationWindow
     }
 
     [GtkCallback]
-    private void rotate_right_button_clicked_cb (Gtk.Widget widget)
+    private void rotate_right_button_clicked_cb ()
     {
         if (updating_page_menu)
             return;
@@ -934,7 +1006,7 @@ public class AppWindow : Gtk.ApplicationWindow
     }
 
     [GtkCallback]
-    private void page_move_left_menuitem_activate_cb (Gtk.Widget widget)
+    private void page_move_left_menuitem_activate_cb ()
     {
         var page = book_view.selected_page;
         var index = book.get_page_index (page);
@@ -943,7 +1015,7 @@ public class AppWindow : Gtk.ApplicationWindow
     }
 
     [GtkCallback]
-    private void page_move_right_menuitem_activate_cb (Gtk.Widget widget)
+    private void page_move_right_menuitem_activate_cb ()
     {
         var page = book_view.selected_page;
         var index = book.get_page_index (page);
@@ -952,7 +1024,7 @@ public class AppWindow : Gtk.ApplicationWindow
     }
 
     [GtkCallback]
-    private void page_delete_menuitem_activate_cb (Gtk.Widget widget)
+    private void page_delete_menuitem_activate_cb ()
     {
         book_view.book.delete_page (book_view.selected_page);
     }
@@ -1140,7 +1212,7 @@ public class AppWindow : Gtk.ApplicationWindow
     }
 
     [GtkCallback]
-    private void copy_to_clipboard_button_clicked_cb (Gtk.Widget widget)
+    private void copy_to_clipboard_button_clicked_cb ()
     {
         var page = book_view.selected_page;
         if (page != null)
@@ -1577,6 +1649,16 @@ public class AppWindow : Gtk.ApplicationWindow
             app.app_menu = appmenu;
 
             app.add_accelerator ("<Ctrl>N", "app.new_document", null);
+            app.set_accels_for_action ("app.scan_single", { "<Ctrl>1" });
+            app.set_accels_for_action ("app.scan_adf", { "<Ctrl>F" });
+            app.set_accels_for_action ("app.scan_batch", { "<Ctrl>M" });
+            app.set_accels_for_action ("app.scan_stop", { "Escape" });
+            app.set_accels_for_action ("app.rotate_left", { "bracketleft" });
+            app.set_accels_for_action ("app.rotate_right", { "bracketright" });
+            app.set_accels_for_action ("app.move_left", { "less" });
+            app.set_accels_for_action ("app.move_right", { "greater" });
+            app.set_accels_for_action ("app.copy_page", { "<Ctrl>C" });
+            app.set_accels_for_action ("app.delete_page", { "Delete" });
             app.add_accelerator ("<Ctrl>S", "app.save", null);
             app.add_accelerator ("<Ctrl>E", "app.email", null);
             app.add_accelerator ("<Ctrl>P", "app.print", null);


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