From 6950cf1bbb2766d401b655fa787f233b06c7605a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Mon, 22 Feb 2021 16:34:08 +0100 Subject: [PATCH] Do not import GstClapper for remote app No need to import and initialize whole GStreamer for web application if the only thing needed there is a single enum. --- src/menu.js | 2 +- src/misc.js | 6 +++--- src/player.js | 5 +++-- src/playerRemote.js | 7 +++++++ src/widgetRemote.js | 10 +++++----- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/menu.js b/src/menu.js index 601022c0..38b00323 100644 --- a/src/menu.js +++ b/src/menu.js @@ -1,4 +1,4 @@ -const { GObject, Gst, Gtk } = imports.gi; +const { GObject, Gtk } = imports.gi; const Dialogs = imports.src.dialogs; var actions = { diff --git a/src/misc.js b/src/misc.js index f8d5458f..8bc98aed 100644 --- a/src/misc.js +++ b/src/misc.js @@ -1,4 +1,4 @@ -const { Gio, GstAudio, GstClapper, Gdk, Gtk } = imports.gi; +const { Gio, GstAudio, Gdk, Gtk } = imports.gi; const Debug = imports.src.debug; const { debug } = Debug; @@ -48,11 +48,11 @@ function loadCustomCss() ); } -function inhibitForState(state, window) +function setAppInhibit(isInhibit, window) { let isInhibited = false; - if(state === GstClapper.ClapperState.PLAYING) { + if(isInhibit) { if(inhibitCookie) return; diff --git a/src/player.js b/src/player.js index e7c078d2..f6b7f6f2 100644 --- a/src/player.js +++ b/src/player.js @@ -1,4 +1,4 @@ -const { Gdk, Gio, GLib, GObject, Gst, GstClapper, Gtk } = imports.gi; +const { Gdk, Gio, GObject, Gst, GstClapper, Gtk } = imports.gi; const ByteArray = imports.byteArray; const Debug = imports.src.debug; const Misc = imports.src.misc; @@ -320,7 +320,8 @@ class ClapperPlayer extends PlayerBase return; } - Misc.inhibitForState(state, root); + const isInhibit = (state === GstClapper.ClapperState.PLAYING); + Misc.setAppInhibit(isInhibit, root); } const clapperWidget = player.widget.get_ancestor(Gtk.Grid); diff --git a/src/playerRemote.js b/src/playerRemote.js index 40fda0f2..e9098d9c 100644 --- a/src/playerRemote.js +++ b/src/playerRemote.js @@ -1,6 +1,13 @@ const { GObject } = imports.gi; const { WebClient } = imports.src.webClient; +var ClapperState = { + STOPPED: 0, + BUFFERING: 1, + PAUSED: 2, + PLAYING: 3, +}; + var PlayerRemote = GObject.registerClass( class ClapperPlayerRemote extends GObject.Object { diff --git a/src/widgetRemote.js b/src/widgetRemote.js index 8bf3288f..4ad3191e 100644 --- a/src/widgetRemote.js +++ b/src/widgetRemote.js @@ -1,7 +1,7 @@ -const { GObject, Gtk, GstClapper } = imports.gi; +const { GObject, Gtk } = imports.gi; const Buttons = imports.src.buttons; const Misc = imports.src.misc; -const { PlayerRemote } = imports.src.playerRemote; +const { PlayerRemote, ClapperState } = imports.src.playerRemote; var WidgetRemote = GObject.registerClass( class ClapperWidgetRemote extends Gtk.Grid @@ -50,11 +50,11 @@ class ClapperWidgetRemote extends Gtk.Grid switch(action) { case 'state_changed': switch(value) { - case GstClapper.ClapperState.STOPPED: - case GstClapper.ClapperState.PAUSED: + case ClapperState.STOPPED: + case ClapperState.PAUSED: this.togglePlayButton.setPrimaryIcon(); break; - case GstClapper.ClapperState.PLAYING: + case ClapperState.PLAYING: this.togglePlayButton.setSecondaryIcon(); break; default: