diff --git a/clapper_src/app.js b/clapper_src/app.js index fb6cd21b..7ac6a64a 100644 --- a/clapper_src/app.js +++ b/clapper_src/app.js @@ -52,11 +52,9 @@ var App = GObject.registerClass({ this.windowRealizeSignal = this.window.connect( 'realize', this._onWindowRealize.bind(this) ); -/* - this.window.connect( - 'key-press-event', this._onWindowKeyPressEvent.bind(this) + this.window.keyController.connect( + 'key-pressed', this._onWindowKeyPressEvent.bind(this) ); -*/ this.window.connect( 'fullscreen-changed', this._onWindowFullscreenChanged.bind(this) ); @@ -173,9 +171,6 @@ var App = GObject.registerClass({ ); */ this.interface.addPlayer(this.player); - - this.player.connect('warning', this._onPlayerWarning.bind(this)); - this.player.connect('error', this._onPlayerError.bind(this)); this.player.connect('state-changed', this._onPlayerStateChanged.bind(this)); /* this.player.connectWidget( @@ -213,15 +208,11 @@ var App = GObject.registerClass({ this.interface.setFullscreenMode(isFullscreen); } - _onWindowKeyPressEvent(self, event) + _onWindowKeyPressEvent(self, keyval, keycode, state) { - let [res, key] = event.get_keyval(); - if(!res) return; - - //let keyName = Gdk.keyval_name(key); let bool = false; - switch(key) { + switch(keyval) { case Gdk.KEY_space: case Gdk.KEY_Return: this.player.toggle_play(); @@ -294,6 +285,7 @@ var App = GObject.registerClass({ if(state === GstPlayer.PlayerState.BUFFERING) return; + let isInhibited = false; let flags = Gtk.ApplicationInhibitFlags.SUSPEND | Gtk.ApplicationInhibitFlags.IDLE; @@ -306,6 +298,10 @@ var App = GObject.registerClass({ flags, 'video is playing' ); + if(!this.inhibitCookie) + debug(new Error('could not inhibit session!')); + + isInhibited = (this.inhibitCookie > 0); } else { if(!this.inhibitCookie) @@ -315,7 +311,7 @@ var App = GObject.registerClass({ this.inhibitCookie = null; } - //debug('set prevent suspend to: ' + this.is_inhibited(flags)); + debug(`set prevent suspend to: ${isInhibited}`); } _onPlayerButtonPressEvent(self, event) @@ -414,16 +410,6 @@ var App = GObject.registerClass({ ); } - _onPlayerWarning(self, error) - { - debug(error.message, 'LEVEL_WARNING'); - } - - _onPlayerError(self, error) - { - debug(error); - } - _onWindowCloseRequest() { this.window.destroy(); diff --git a/clapper_src/interface.js b/clapper_src/interface.js index 985c79f3..a39611c9 100644 --- a/clapper_src/interface.js +++ b/clapper_src/interface.js @@ -453,16 +453,12 @@ class ClapperInterface extends Gtk.Grid : 'overamplified'; let iconName = `audio-volume-${icon}-symbolic`; -/* - if(this.controls.volumeButton.image.icon_name !== iconName) + if(this.controls.volumeButton.icon_name !== iconName) { debug(`set volume icon: ${icon}`); - this.controls.volumeButton.image.set_from_icon_name( - iconName, - this.controls.volumeButton.image.icon_size - ); + this.controls.volumeButton.set_icon_name(iconName); } -*/ + if(volume === this.lastVolumeValue) return; diff --git a/clapper_src/player.js b/clapper_src/player.js index bfe8510f..d0f4259d 100644 --- a/clapper_src/player.js +++ b/clapper_src/player.js @@ -68,9 +68,6 @@ class ClapperPlayer extends GstPlayer.Player this.set_config(config); this.set_mute(false); - - /* FIXME: remove once GUI buttons are back */ - this.set_volume(0.5); this.set_plugin_rank('vah264dec', 300); this.loop = GLib.MainLoop.new(null, false); @@ -86,6 +83,8 @@ class ClapperPlayer extends GstPlayer.Player this.connect('state-changed', this._onStateChanged.bind(this)); this.connect('uri-loaded', this._onUriLoaded.bind(this)); this.connect('end-of-stream', this._onStreamEnded.bind(this)); + this.connect('warning', this._onPlayerWarning.bind(this)); + this.connect('error', this._onPlayerError.bind(this)); this.connectWidget('destroy', this._onWidgetDestroy.bind(this)); } @@ -253,6 +252,16 @@ class ClapperPlayer extends GstPlayer.Player this.loop.run(); } + _onPlayerWarning(self, error) + { + debug(error.message, 'LEVEL_WARNING'); + } + + _onPlayerError(self, error) + { + debug(error); + } + _onWidgetDestroy() { while(this._widgetSignals.length) diff --git a/clapper_src/window.js b/clapper_src/window.js index 5ca1d546..0b8b011b 100644 --- a/clapper_src/window.js +++ b/clapper_src/window.js @@ -17,6 +17,10 @@ var Window = GObject.registerClass({ destroy_with_parent: true, }); this.isFullscreen = false; + + this.keyController = new Gtk.EventControllerKey(); + this.add_controller(this.keyController); + this.mapSignal = this.connect('map', this._onMap.bind(this)); }