From f245b615c96141e9f63013db9b98c8d3f649dd8d Mon Sep 17 00:00:00 2001 From: Frederic Brodbeck Date: Sat, 2 Oct 2021 16:26:54 +0200 Subject: [PATCH 1/2] fixed indentation --- nemo-preview/src/js/ui/application.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/nemo-preview/src/js/ui/application.js b/nemo-preview/src/js/ui/application.js index 35bbce03..67050df3 100644 --- a/nemo-preview/src/js/ui/application.js +++ b/nemo-preview/src/js/ui/application.js @@ -94,14 +94,15 @@ var Application = new Lang.Class({ this._mainWindow.close(); }, - ShowFile : function(uri, xid, closeIfAlreadyShown) { - let file = Gio.file_new_for_uri(uri); - if (closeIfAlreadyShown && - this._mainWindow.file && - this._mainWindow.file.equal(file)) { - this._mainWindow.close(); - return; - } + ShowFile: function(uri, xid, closeIfAlreadyShown) { + let file = Gio.file_new_for_uri(uri); + if (closeIfAlreadyShown && + this._mainWindow.file && + this._mainWindow.file.equal(file) + ) { + this._mainWindow.close(); + return; + } this._mainWindow.setParent(xid); this._mainWindow.setFile(file); } From 4c9f1a2ba8cf111a765aa789749609bab2838f8e Mon Sep 17 00:00:00 2001 From: Frederic Brodbeck Date: Sat, 2 Oct 2021 17:10:32 +0200 Subject: [PATCH 2/2] send event on arrow key press --- nemo-preview/src/js/ui/application.js | 28 ++++++++++++++++++--------- nemo-preview/src/js/ui/mainWindow.js | 13 +++++++++++++ 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/nemo-preview/src/js/ui/application.js b/nemo-preview/src/js/ui/application.js index 67050df3..d257ef29 100644 --- a/nemo-preview/src/js/ui/application.js +++ b/nemo-preview/src/js/ui/application.js @@ -42,15 +42,18 @@ const NEMO_PREVIEW_DBUS_PATH = '/org/nemo/Preview'; const NEMO_PREVIEW_DBUS_NAME = 'org.nemo.Preview'; const NemoPreviewIface = ' \ - \ - \ - \ - \ - \ - \ - \ - \ - \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ '; var Application = new Lang.Class({ @@ -105,5 +108,12 @@ var Application = new Lang.Class({ } this._mainWindow.setParent(xid); this._mainWindow.setFile(file); + }, + + emitSelectionEvent(direction) { + this._dbusImpl.emit_signal( + 'SelectionEvent', + new GLib.Variant('(u)', [direction]) + ); } }); diff --git a/nemo-preview/src/js/ui/mainWindow.js b/nemo-preview/src/js/ui/mainWindow.js index f70c3060..e298ca39 100644 --- a/nemo-preview/src/js/ui/mainWindow.js +++ b/nemo-preview/src/js/ui/mainWindow.js @@ -200,6 +200,19 @@ MainWindow.prototype = { key == Gdk.KEY_F11) this.toggleFullScreen(); + if (key == Gdk.KEY_Down) { + this._application.emitSelectionEvent(Gtk.DirectionType.DOWN); + } + else if (key == Gdk.KEY_Up) { + this._application.emitSelectionEvent(Gtk.DirectionType.UP); + } + else if (key == Gdk.KEY_Left) { + this._application.emitSelectionEvent(Gtk.DirectionType.LEFT); + } + else if (key == Gdk.KEY_Right) { + this._application.emitSelectionEvent(Gtk.DirectionType.RIGHT); + } + return false; },