From 6f50f2c45467cbbf05ef5d4b7ef1ba3ee71456fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Arrufat?= Date: Sat, 27 May 2017 16:57:53 +0200 Subject: [PATCH] add Ctrl+o and Ctrl+q shortcuts --- src/main.vala | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main.vala b/src/main.vala index cd83276..4b148f2 100644 --- a/src/main.vala +++ b/src/main.vala @@ -226,6 +226,8 @@ public class Pdftag : ApplicationWindow { this.add (grid); + this.add_accels (); + /* handle first argument -- it only works as an absolute path */ if (args[1] != null) { this.filename = args[1]; @@ -235,6 +237,21 @@ public class Pdftag : ApplicationWindow { } + [Signal (action = true)] + private signal void open_file_dialog (); + + [Signal (action = true)] + private signal void quit_app (); + + private void add_accels () { + var accel_group = new AccelGroup (); + this.add_accel_group (accel_group); + this.open_file_dialog.connect (on_open_clicked); + this.quit_app.connect (Gtk.main_quit); + this.add_accelerator ("open_file_dialog", accel_group, Gdk.keyval_from_name ("o"), Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE); + this.add_accelerator ("quit_app", accel_group, Gdk.keyval_from_name ("q"), Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE); + } + private void on_creation_now_clicked () { this.creation_date = new DateTime.now_local (); this.creation_date_btn.label = creation_date.format (this.date_format);