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