Skip to content

Commit 4c9f1a2

Browse files
committed
send event on arrow key press
1 parent f245b61 commit 4c9f1a2

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

nemo-preview/src/js/ui/application.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,18 @@ const NEMO_PREVIEW_DBUS_PATH = '/org/nemo/Preview';
4242
const NEMO_PREVIEW_DBUS_NAME = 'org.nemo.Preview';
4343

4444
const NemoPreviewIface = '<node> \
45-
<interface name="org.nemo.Preview"> \
46-
<method name="ShowFile"> \
47-
<arg type="s" direction="in" name="uri" /> \
48-
<arg type="i" direction="in" name="xid" /> \
49-
<arg type="b" direction="in" name="closeIfAlreadyShown" /> \
50-
</method> \
51-
<method name="Close"> \
52-
</method> \
53-
</interface> \
45+
<interface name="org.nemo.Preview"> \
46+
<method name="ShowFile"> \
47+
<arg type="s" direction="in" name="uri" /> \
48+
<arg type="i" direction="in" name="xid" /> \
49+
<arg type="b" direction="in" name="closeIfAlreadyShown" /> \
50+
</method> \
51+
<method name="Close"> \
52+
</method> \
53+
<signal name="SelectionEvent"> \
54+
<arg type="q" name="direction" /> \
55+
</signal> \
56+
</interface> \
5457
</node>';
5558

5659
var Application = new Lang.Class({
@@ -105,5 +108,12 @@ var Application = new Lang.Class({
105108
}
106109
this._mainWindow.setParent(xid);
107110
this._mainWindow.setFile(file);
111+
},
112+
113+
emitSelectionEvent(direction) {
114+
this._dbusImpl.emit_signal(
115+
'SelectionEvent',
116+
new GLib.Variant('(u)', [direction])
117+
);
108118
}
109119
});

nemo-preview/src/js/ui/mainWindow.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,19 @@ MainWindow.prototype = {
200200
key == Gdk.KEY_F11)
201201
this.toggleFullScreen();
202202

203+
if (key == Gdk.KEY_Down) {
204+
this._application.emitSelectionEvent(Gtk.DirectionType.DOWN);
205+
}
206+
else if (key == Gdk.KEY_Up) {
207+
this._application.emitSelectionEvent(Gtk.DirectionType.UP);
208+
}
209+
else if (key == Gdk.KEY_Left) {
210+
this._application.emitSelectionEvent(Gtk.DirectionType.LEFT);
211+
}
212+
else if (key == Gdk.KEY_Right) {
213+
this._application.emitSelectionEvent(Gtk.DirectionType.RIGHT);
214+
}
215+
203216
return false;
204217
},
205218

0 commit comments

Comments
 (0)