From 8064bab6a2b4273f7390a1a8b34fca40195692ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Sat, 13 Feb 2021 20:19:08 +0100 Subject: [PATCH] Remove old floating mode leftovers Clapper has now much simpler floating mode. This overcomplicated code is not needed anymore. --- css/styles.css | 40 ----------- data/com.github.rafostar.Clapper.gschema.xml | 4 -- src/buttons.js | 48 ++------------ src/controls.js | 23 +------ src/player.js | 11 +-- src/revealers.js | 21 ------ src/widget.js | 70 +------------------- 7 files changed, 11 insertions(+), 206 deletions(-) diff --git a/css/styles.css b/css/styles.css index 3d3acc6d..8a17a6ca 100644 --- a/css/styles.css +++ b/css/styles.css @@ -205,41 +205,6 @@ radio { min-height: 6px; } -/* Floating Mode */ -.floatingwindow { - border-radius: 8px; -} -.osd.floatingcontrols .playercontrols { - -gtk-icon-size: 16px; -} -.osd.floatingcontrols .playbackicon { - -gtk-icon-size: 20px; -} -.osd.floatingcontrols button { - border-radius: 10px; - min-width: 24px; - min-height: 24px; -} -.osd.floatingcontrols .positionscale { - margin-top: -2px; -} -.osd.floatingcontrols .positionscale trough highlight { - border-radius: 3px; - min-height: 12px; -} -.osd.floatingcontrols .positionscale.fine-tune trough highlight { - border-radius: 3px; - min-height: 12px; -} -.osd.floatingcontrols .positionscale mark indicator { - min-height: 5px; - min-width: 1px; -} -.osd.floatingcontrols .positionscale.fine-tune mark indicator { - min-height: 5px; - min-width: 1px; -} - .narrowbutton { min-width: 8px; } @@ -265,11 +230,6 @@ radio { font-size: 21px; font-weight: 500; } -.osd.floatingcontrols .chapterlabel { - font: inherit; - font-size: 100%; - min-width: 32px; -} /* Preferences */ .prefsnotebook grid { diff --git a/data/com.github.rafostar.Clapper.gschema.xml b/data/com.github.rafostar.Clapper.gschema.xml index 93c3e91a..18a823ff 100644 --- a/data/com.github.rafostar.Clapper.gschema.xml +++ b/data/com.github.rafostar.Clapper.gschema.xml @@ -104,10 +104,6 @@ '[960, 583]' Stores window size to restore on next launch - - '[480, 270]' - Stores floating window size to restore on next launch - 1 Stores last linear volume value to apply on startup diff --git a/src/buttons.js b/src/buttons.js index 8a7014f6..9a48d78c 100644 --- a/src/buttons.js +++ b/src/buttons.js @@ -18,11 +18,7 @@ class ClapperCustomButton extends Gtk.Button super._init(opts); - this.floatUnaffected = false; - this.wantedVisible = true; this.isFullscreen = false; - this.isFloating = false; - this.add_css_class('flat'); } @@ -43,32 +39,6 @@ class ClapperCustomButton extends Gtk.Button this.isFullscreen = isFullscreen; } - setFloatingMode(isFloating) - { - if(this.isFloating === isFloating) - return; - - this.isFloating = isFloating; - - if(this.floatUnaffected) - return; - - if(isFloating) - super.set_visible(false); - else - super.set_visible(this.wantedVisible); - } - - set_visible(isVisible) - { - this.wantedVisible = isVisible; - - if(this.isFloating && !this.floatUnaffected) - super.set_visible(false); - else - super.set_visible(isVisible); - } - vfunc_clicked() { if(!this.isFullscreen) @@ -79,24 +49,14 @@ class ClapperCustomButton extends Gtk.Button } }); -var IconButton = GObject.registerClass( -class ClapperIconButton extends CustomButton -{ - _init(icon) - { - super._init({ - icon_name: icon, - }); - this.floatUnaffected = true; - } -}); - var IconToggleButton = GObject.registerClass( -class ClapperIconToggleButton extends IconButton +class ClapperIconToggleButton extends CustomButton { _init(primaryIcon, secondaryIcon) { - super._init(primaryIcon); + super._init({ + icon_name: primaryIcon, + }); this.primaryIcon = primaryIcon; this.secondaryIcon = secondaryIcon; diff --git a/src/controls.js b/src/controls.js index cb576469..447ac2fa 100644 --- a/src/controls.js +++ b/src/controls.js @@ -47,7 +47,6 @@ class ClapperControls extends Gtk.Box 'go-previous-symbolic', 'go-next-symbolic' ); - revealTracksButton.floatUnaffected = false; revealTracksButton.add_css_class('narrowbutton'); this.buttonsArr.push(revealTracksButton); const tracksRevealer = new Revealers.ButtonsRevealer( @@ -90,12 +89,6 @@ class ClapperControls extends Gtk.Box this.unfullscreenButton.connect('clicked', this._onUnfullscreenClicked.bind(this)); this.unfullscreenButton.set_visible(false); - this.unfloatButton = this.addButton( - 'preferences-desktop-remote-desktop-symbolic' - ); - this.unfloatButton.connect('clicked', this._onUnfloatClicked.bind(this)); - this.unfloatButton.set_visible(false); - const keyController = new Gtk.EventControllerKey(); keyController.connect('key-pressed', this._onControlsKeyPressed.bind(this)); keyController.connect('key-released', this._onControlsKeyReleased.bind(this)); @@ -117,14 +110,6 @@ class ClapperControls extends Gtk.Box this.set_can_focus(isFullscreen); } - setFloatingMode(isFloating) - { - this.isMobile = null; - - for(let button of this.buttonsArr) - button.setFloatingMode(isFloating); - } - setLiveMode(isLive, isSeekable) { if(isLive) @@ -147,7 +132,7 @@ class ClapperControls extends Gtk.Box { const button = (buttonIcon instanceof Gtk.Button) ? buttonIcon - : new Buttons.IconButton(buttonIcon); + : new Buttons.CustomButton({ icon_name: buttonIcon }); if(!revealer) this.append(button); @@ -528,12 +513,6 @@ class ClapperControls extends Gtk.Box root.unfullscreen(); } - _onUnfloatClicked(button) - { - const clapperWidget = this.get_ancestor(Gtk.Grid); - clapperWidget.setFloatingMode(false); - } - _onCheckButtonToggled(checkButton) { if(!checkButton.get_active()) diff --git a/src/player.js b/src/player.js index 2a7aeb98..f1b0578f 100644 --- a/src/player.js +++ b/src/player.js @@ -342,7 +342,7 @@ class ClapperPlayer extends PlayerBase if(this.cursorInPlayer) { const clapperWidget = this.widget.get_ancestor(Gtk.Grid); - if(clapperWidget.fullscreenMode || clapperWidget.floatingMode) { + if(clapperWidget.fullscreenMode) { this._clearTimeout('updateTime'); clapperWidget.revealControls(false); } @@ -644,7 +644,7 @@ class ClapperPlayer extends PlayerBase this._setHideCursorTimeout(); const clapperWidget = this.widget.get_ancestor(Gtk.Grid); - if(clapperWidget.fullscreenMode || clapperWidget.floatingMode) + if(clapperWidget.fullscreenMode) this._setHideControlsTimeout(); } @@ -676,12 +676,7 @@ class ClapperPlayer extends PlayerBase clapperWidget.revealerTop.set_cursor(defaultCursor); this._setHideCursorTimeout(); - if(clapperWidget.floatingMode && !clapperWidget.fullscreenMode) { - clapperWidget.revealerBottom.set_can_focus(false); - clapperWidget.revealerBottom.revealChild(true); - this._setHideControlsTimeout(); - } - else if(clapperWidget.fullscreenMode) { + if(clapperWidget.fullscreenMode) { if(!this._updateTimeTimeout) this._setUpdateTimeInterval(); diff --git a/src/revealers.js b/src/revealers.js index 21b60b94..6f5e53a0 100644 --- a/src/revealers.js +++ b/src/revealers.js @@ -198,15 +198,6 @@ class ClapperRevealerBottom extends CustomRevealer this.revealerBox.remove(widget); } - setFloatingClass(isFloating) - { - if(isFloating === this.revealerBox.has_css_class('floatingcontrols')) - return; - - const action = (isFloating) ? 'add' : 'remove'; - this.revealerBox[`${action}_css_class`]('floatingcontrols'); - } - set_visible(isVisible) { const isChange = super.set_visible(isVisible); @@ -322,18 +313,6 @@ class ClapperButtonsRevealer extends Gtk.Revealer } } - set_reveal_child(isReveal) - { - if(this.reveal_child === isReveal) - return; - - const grandson = this.child.get_first_child(); - if(grandson && grandson.isFloating && !grandson.isFullscreen) - return; - - super.set_reveal_child(isReveal); - } - append(widget) { this.get_child().append(widget); diff --git a/src/widget.js b/src/widget.js index 0898f799..2530f990 100644 --- a/src/widget.js +++ b/src/widget.js @@ -21,11 +21,9 @@ class ClapperWidget extends Gtk.Grid Misc.loadCustomCss(); this.windowSize = JSON.parse(settings.get_string('window-size')); - this.floatSize = JSON.parse(settings.get_string('float-size')); this.layoutWidth = 0; this.fullscreenMode = false; - this.floatingMode = false; this.isSeekable = false; this.isMobileMonitor = false; @@ -120,14 +118,7 @@ class ClapperWidget extends Gtk.Grid if(!this.isMobileMonitor) root[action + '_css_class']('tvmode'); - if(!this.floatingMode) - this._changeControlsPlacement(isFullscreen); - else { - this._setWindowFloating(!isFullscreen); - this.revealerBottom.setFloatingClass(!isFullscreen); - this.controls.setFloatingMode(!isFullscreen); - this.controls.unfloatButton.set_visible(!isFullscreen); - } + this._changeControlsPlacement(isFullscreen); this.controls.setFullscreenMode(isFullscreen); this.showControls(isFullscreen); @@ -143,64 +134,10 @@ class ClapperWidget extends Gtk.Grid } } - setFloatingMode(isFloating) - { - if(this.floatingMode === isFloating) - return; - - const root = this.get_root(); - const size = root.get_default_size(); - - this._saveWindowSize(size); - - if(isFloating) { - this.windowSize = size; - this.player.widget.set_size_request(192, 108); - } - else { - this.floatSize = size; - this.player.widget.set_size_request(-1, -1); - } - - this.floatingMode = isFloating; - - this.revealerBottom.setFloatingClass(isFloating); - this._changeControlsPlacement(isFloating); - this.controls.setFloatingMode(isFloating); - this.controls.unfloatButton.set_visible(isFloating); - this._setWindowFloating(isFloating); - - const resize = (isFloating) - ? this.floatSize - : this.windowSize; - - root.set_default_size(resize[0], resize[1]); - debug(`resized window: ${resize[0]}x${resize[1]}`); - - this.revealerBottom.showChild(false); - this.player.widget.grab_focus(); - } - - _setWindowFloating(isFloating) - { - const root = this.get_root(); - const cssClass = 'floatingwindow'; - - if(isFloating === root.has_css_class(cssClass)) - return; - - const action = (isFloating) ? 'add' : 'remove'; - root[action + '_css_class'](cssClass); - } - _saveWindowSize(size) { - const rootName = (this.floatingMode) - ? 'float' - : 'window'; - - settings.set_string(`${rootName}-size`, JSON.stringify(size)); - debug(`saved ${rootName} size: ${size[0]}x${size[1]}`); + settings.set_string('window-size', JSON.stringify(size)); + debug(`saved window size: ${size[0]}x${size[1]}`); } _changeControlsPlacement(isOnTop) @@ -599,7 +536,6 @@ class ClapperWidget extends Gtk.Grid { if( this.fullscreenMode - || !this.floatingMode || this.player.isWidgetDragging ) return;