mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 16:02:00 +02:00
Add keybinding to change repeat mode #52
This commit is contained in:
@@ -14,6 +14,7 @@ var actions = {
|
|||||||
volume_up: ['Up'],
|
volume_up: ['Up'],
|
||||||
volume_down: ['Down'],
|
volume_down: ['Down'],
|
||||||
toggle_play: ['space'],
|
toggle_play: ['space'],
|
||||||
|
change_repeat: ['<Ctrl>r'],
|
||||||
reveal_controls: ['Return'],
|
reveal_controls: ['Return'],
|
||||||
toggle_fullscreen: ['F11', 'f'],
|
toggle_fullscreen: ['F11', 'f'],
|
||||||
quit: ['<Ctrl>q', 'q'],
|
quit: ['<Ctrl>q', 'q'],
|
||||||
@@ -72,6 +73,9 @@ function handleAction(action, window)
|
|||||||
case 'toggle_fullscreen':
|
case 'toggle_fullscreen':
|
||||||
clapperWidget.toggleFullscreen();
|
clapperWidget.toggleFullscreen();
|
||||||
break;
|
break;
|
||||||
|
case 'change_repeat':
|
||||||
|
player.playlistWidget.changeRepeatMode();
|
||||||
|
break;
|
||||||
case 'quit':
|
case 'quit':
|
||||||
clapperWidget.root.emit('close-request');
|
clapperWidget.root.emit('close-request');
|
||||||
break;
|
break;
|
||||||
|
@@ -1,4 +1,7 @@
|
|||||||
const { Gdk, GLib, GObject, Gst, Gtk, Pango } = imports.gi;
|
const { Gdk, GLib, GObject, Gst, Gtk, Pango } = imports.gi;
|
||||||
|
const Debug = imports.src.debug;
|
||||||
|
|
||||||
|
const { debug, warn } = Debug;
|
||||||
|
|
||||||
var RepeatMode = {
|
var RepeatMode = {
|
||||||
NONE: 0,
|
NONE: 0,
|
||||||
@@ -90,6 +93,26 @@ class ClapperPlaylistWidget extends Gtk.ListBox
|
|||||||
button.icon_name = 'list-remove-symbolic';
|
button.icon_name = 'list-remove-symbolic';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changeRepeatMode(mode)
|
||||||
|
{
|
||||||
|
const lastMode = Object.keys(RepeatMode).length - 1;
|
||||||
|
|
||||||
|
if(mode < 0 || mode > lastMode) {
|
||||||
|
warn(`ignored invalid repeat mode value: ${mode}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mode >= 0)
|
||||||
|
this.repeatMode = mode;
|
||||||
|
else {
|
||||||
|
this.repeatMode++;
|
||||||
|
if(this.repeatMode > lastMode)
|
||||||
|
this.repeatMode = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
debug(`set repeat mode: ${this.repeatMode}`);
|
||||||
|
}
|
||||||
|
|
||||||
_switchTrack(isPrevious)
|
_switchTrack(isPrevious)
|
||||||
{
|
{
|
||||||
const rowId = (isPrevious)
|
const rowId = (isPrevious)
|
||||||
@@ -134,6 +157,8 @@ class ClapperPlaylistWidget extends Gtk.ListBox
|
|||||||
&& this.activeRowId === 0
|
&& this.activeRowId === 0
|
||||||
&& !this.get_row_at_index(1))
|
&& !this.get_row_at_index(1))
|
||||||
) {
|
) {
|
||||||
|
debug('seeking to beginning');
|
||||||
|
|
||||||
player.seek(0);
|
player.seek(0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user