diff --git a/README.md b/README.md index dfd8002..db0bcc7 100644 --- a/README.md +++ b/README.md @@ -144,9 +144,9 @@ cd Junction ./re.sonny.Junction https://www.gnome.org/ ``` -Make changes and press `Ctrl+Shift+Q` on the Junction window to restart it. +Make changes and press `Q` on the Junction window to restart it. -Use `Ctrl+Shift+I` to open the inspector. +Use `I` to open the inspector. To setup development version as default application first install the desktop file with diff --git a/src/ShortcutsWindow.ui b/src/ShortcutsWindow.ui index a19ffc1..7c04d46 100644 --- a/src/ShortcutsWindow.ui +++ b/src/ShortcutsWindow.ui @@ -28,6 +28,42 @@ >Copy to Clipboard + + + Right + Select next application + + + + + Left + Select previous application + + + + + Return space + Open with selected application + + + + + 1...9 + Open with application at position + + diff --git a/src/main.js b/src/main.js index 1018a14..2538fb0 100644 --- a/src/main.js +++ b/src/main.js @@ -11,7 +11,6 @@ GLib.set_application_name("Junction"); Gtk.init(); export default function main(argv, { version, datadir }) { - log(`datadir: ${datadir}`); bindtextdomain( "re.sonny.Junction", GLib.build_filenamev([datadir, "locale"]), @@ -20,6 +19,7 @@ export default function main(argv, { version, datadir }) { const application = Application({ version }); + log(`datadir: ${datadir}`); log("argv " + argv.join(" ")); log(`programInvocationName: ${programInvocationName}`); log(`_: ${GLib.getenv("_")}`); diff --git a/src/window.js b/src/window.js index 3b48638..19c618d 100644 --- a/src/window.js +++ b/src/window.js @@ -64,9 +64,33 @@ export default function Window({ application, file }) { entry, window, }); + appInfo.button = button; list.append(button); }); + function getAppForKeyval(keyval) { + const keyname = Gdk.keyval_name(keyval); + // Is not 0...9 + if (!/^\d$/.test(keyname)) return null; + const appInfo = applications[+keyname - 1]; + return appInfo; + } + + const eventController = new Gtk.EventControllerKey(); + eventController.connect("key-pressed", (self, keyval) => { + const appInfo = getAppForKeyval(keyval); + if (!appInfo) return false; + appInfo.button.grab_focus(); + return true; + }); + eventController.connect("key-released", (self, keyval) => { + const appInfo = getAppForKeyval(keyval); + if (!appInfo) return false; + appInfo.button.activate(); + return true; + }); + window.add_controller(eventController); + const copy = new Gio.SimpleAction({ name: "copy", parameter_type: null,