mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 16:02:00 +02:00
Merge pull request #126 from Rafostar/gestures
Add side double tap gesture and update shortcuts window
This commit is contained in:
13
src/misc.js
13
src/misc.js
@@ -219,6 +219,19 @@ function getUriProtocol(uri)
|
|||||||
return (arr.length > 1) ? arr[0] : null;
|
return (arr.length > 1) ? arr[0] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getIsTouch(gesture)
|
||||||
|
{
|
||||||
|
const { source } = gesture.get_device();
|
||||||
|
|
||||||
|
switch(source) {
|
||||||
|
case Gdk.InputSource.PEN:
|
||||||
|
case Gdk.InputSource.TOUCHSCREEN:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function encodeHTML(text)
|
function encodeHTML(text)
|
||||||
{
|
{
|
||||||
return text.replace(/&/g, '&')
|
return text.replace(/&/g, '&')
|
||||||
|
@@ -676,6 +676,26 @@ class ClapperWidget extends Gtk.Grid
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_handleDoublePress(gesture, x, y)
|
||||||
|
{
|
||||||
|
if(!this.isFullscreenMode || !Misc.getIsTouch(gesture))
|
||||||
|
return this.toggleFullscreen();
|
||||||
|
|
||||||
|
const fieldSize = this.layoutWidth / 6;
|
||||||
|
|
||||||
|
if(x < fieldSize) {
|
||||||
|
debug('left side double press');
|
||||||
|
this.player.playlistWidget.prevTrack();
|
||||||
|
}
|
||||||
|
else if(x > this.layoutWidth - fieldSize) {
|
||||||
|
debug('right side double press');
|
||||||
|
this.player.playlistWidget.nextTrack();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.toggleFullscreen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_getClickGesture()
|
_getClickGesture()
|
||||||
{
|
{
|
||||||
const clickGesture = new Gtk.GestureClick({
|
const clickGesture = new Gtk.GestureClick({
|
||||||
@@ -767,6 +787,7 @@ class ClapperWidget extends Gtk.Grid
|
|||||||
{
|
{
|
||||||
const button = gesture.get_current_button();
|
const button = gesture.get_current_button();
|
||||||
const isDouble = (nPress % 2 == 0);
|
const isDouble = (nPress % 2 == 0);
|
||||||
|
|
||||||
this.isDragAllowed = !isDouble;
|
this.isDragAllowed = !isDouble;
|
||||||
this.isSwipePerformed = false;
|
this.isSwipePerformed = false;
|
||||||
this.isLongPressed = false;
|
this.isLongPressed = false;
|
||||||
@@ -774,7 +795,7 @@ class ClapperWidget extends Gtk.Grid
|
|||||||
switch(button) {
|
switch(button) {
|
||||||
case Gdk.BUTTON_PRIMARY:
|
case Gdk.BUTTON_PRIMARY:
|
||||||
if(isDouble)
|
if(isDouble)
|
||||||
this.toggleFullscreen();
|
this._handleDoublePress(gesture, x, y);
|
||||||
break;
|
break;
|
||||||
case Gdk.BUTTON_SECONDARY:
|
case Gdk.BUTTON_SECONDARY:
|
||||||
this.player.toggle_play();
|
this.player.toggle_play();
|
||||||
@@ -788,20 +809,11 @@ class ClapperWidget extends Gtk.Grid
|
|||||||
{
|
{
|
||||||
/* Reveal if touch was not a swipe/long press or was already revealed */
|
/* Reveal if touch was not a swipe/long press or was already revealed */
|
||||||
if(
|
if(
|
||||||
(!this.isSwipePerformed && !this.isLongPressed)
|
((!this.isSwipePerformed && !this.isLongPressed)
|
||||||
|| this.revealerBottom.child_revealed
|
|| this.revealerBottom.child_revealed)
|
||||||
) {
|
&& Misc.getIsTouch(gesture)
|
||||||
const { source } = gesture.get_device();
|
)
|
||||||
|
this.revealControls();
|
||||||
switch(source) {
|
|
||||||
case Gdk.InputSource.PEN:
|
|
||||||
case Gdk.InputSource.TOUCHSCREEN:
|
|
||||||
this.revealControls();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_onLongPressed(gesture, x, y)
|
_onLongPressed(gesture, x, y)
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
<child>
|
<child>
|
||||||
<object class="GtkShortcutsShortcut">
|
<object class="GtkShortcutsShortcut">
|
||||||
<property name="title" translatable="yes">Toggle fullscreen</property>
|
<property name="title" translatable="yes">Toggle fullscreen</property>
|
||||||
|
<property name="subtitle" translatable="yes">Double tap | Double click</property>
|
||||||
<property name="accelerator">F11 f</property>
|
<property name="accelerator">F11 f</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
@@ -29,6 +30,7 @@
|
|||||||
<child>
|
<child>
|
||||||
<object class="GtkShortcutsShortcut">
|
<object class="GtkShortcutsShortcut">
|
||||||
<property name="title" translatable="yes">Reveal OSD (fullscreen only)</property>
|
<property name="title" translatable="yes">Reveal OSD (fullscreen only)</property>
|
||||||
|
<property name="subtitle" translatable="yes">Tap</property>
|
||||||
<property name="accelerator">Return</property>
|
<property name="accelerator">Return</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
@@ -63,12 +65,14 @@
|
|||||||
<child>
|
<child>
|
||||||
<object class="GtkShortcutsShortcut">
|
<object class="GtkShortcutsShortcut">
|
||||||
<property name="title" translatable="yes">Next item</property>
|
<property name="title" translatable="yes">Next item</property>
|
||||||
|
<property name="subtitle" translatable="yes">Double tap (right side)</property>
|
||||||
<property name="accelerator"><Ctrl>Right</property>
|
<property name="accelerator"><Ctrl>Right</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkShortcutsShortcut">
|
<object class="GtkShortcutsShortcut">
|
||||||
<property name="title" translatable="yes">Previous item</property>
|
<property name="title" translatable="yes">Previous item</property>
|
||||||
|
<property name="subtitle" translatable="yes">Double tap (left side)</property>
|
||||||
<property name="accelerator"><Ctrl>Left</property>
|
<property name="accelerator"><Ctrl>Left</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
@@ -92,30 +96,35 @@
|
|||||||
<child>
|
<child>
|
||||||
<object class="GtkShortcutsShortcut">
|
<object class="GtkShortcutsShortcut">
|
||||||
<property name="title" translatable="yes">Toggle play</property>
|
<property name="title" translatable="yes">Toggle play</property>
|
||||||
|
<property name="subtitle" translatable="yes">Long press | Right click</property>
|
||||||
<property name="accelerator">space</property>
|
<property name="accelerator">space</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkShortcutsShortcut">
|
<object class="GtkShortcutsShortcut">
|
||||||
<property name="title" translatable="yes">Volume up</property>
|
<property name="title" translatable="yes">Volume up</property>
|
||||||
|
<property name="subtitle" translatable="yes">Swipe up | Scroll up</property>
|
||||||
<property name="accelerator">Up</property>
|
<property name="accelerator">Up</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkShortcutsShortcut">
|
<object class="GtkShortcutsShortcut">
|
||||||
<property name="title" translatable="yes">Volume down</property>
|
<property name="title" translatable="yes">Volume down</property>
|
||||||
|
<property name="subtitle" translatable="yes">Swipe down | Scroll down</property>
|
||||||
<property name="accelerator">Down</property>
|
<property name="accelerator">Down</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkShortcutsShortcut">
|
<object class="GtkShortcutsShortcut">
|
||||||
<property name="title" translatable="yes">Seek forward</property>
|
<property name="title" translatable="yes">Seek forward</property>
|
||||||
|
<property name="subtitle" translatable="yes">Swipe right | Scroll right</property>
|
||||||
<property name="accelerator">Right</property>
|
<property name="accelerator">Right</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkShortcutsShortcut">
|
<object class="GtkShortcutsShortcut">
|
||||||
<property name="title" translatable="yes">Seek backward</property>
|
<property name="title" translatable="yes">Seek backward</property>
|
||||||
|
<property name="subtitle" translatable="yes">Swipe left | Scroll left</property>
|
||||||
<property name="accelerator">Left</property>
|
<property name="accelerator">Left</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
Reference in New Issue
Block a user