Skip to content

[WIP] Arrow key navigation for nemo-preview #427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 28 additions & 17 deletions nemo-preview/src/js/ui/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,18 @@ const NEMO_PREVIEW_DBUS_PATH = '/org/nemo/Preview';
const NEMO_PREVIEW_DBUS_NAME = 'org.nemo.Preview';

const NemoPreviewIface = '<node> \
<interface name="org.nemo.Preview"> \
<method name="ShowFile"> \
<arg type="s" direction="in" name="uri" /> \
<arg type="i" direction="in" name="xid" /> \
<arg type="b" direction="in" name="closeIfAlreadyShown" /> \
</method> \
<method name="Close"> \
</method> \
</interface> \
<interface name="org.nemo.Preview"> \
<method name="ShowFile"> \
<arg type="s" direction="in" name="uri" /> \
<arg type="i" direction="in" name="xid" /> \
<arg type="b" direction="in" name="closeIfAlreadyShown" /> \
</method> \
<method name="Close"> \
</method> \
<signal name="SelectionEvent"> \
<arg type="q" name="direction" /> \
</signal> \
</interface> \
</node>';

var Application = new Lang.Class({
Expand Down Expand Up @@ -94,15 +97,23 @@ 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);
},

emitSelectionEvent(direction) {
this._dbusImpl.emit_signal(
'SelectionEvent',
new GLib.Variant('(u)', [direction])
);
}
});
13 changes: 13 additions & 0 deletions nemo-preview/src/js/ui/mainWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},

Expand Down