Remove old floating mode leftovers

Clapper has now much simpler floating mode. This overcomplicated code is not needed anymore.
This commit is contained in:
Rafał Dzięgiel
2021-02-13 20:19:08 +01:00
parent 892e8b55f3
commit 8064bab6a2
7 changed files with 11 additions and 206 deletions

View File

@@ -205,41 +205,6 @@ radio {
min-height: 6px; 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 { .narrowbutton {
min-width: 8px; min-width: 8px;
} }
@@ -265,11 +230,6 @@ radio {
font-size: 21px; font-size: 21px;
font-weight: 500; font-weight: 500;
} }
.osd.floatingcontrols .chapterlabel {
font: inherit;
font-size: 100%;
min-width: 32px;
}
/* Preferences */ /* Preferences */
.prefsnotebook grid { .prefsnotebook grid {

View File

@@ -104,10 +104,6 @@
<default>'[960, 583]'</default> <default>'[960, 583]'</default>
<summary>Stores window size to restore on next launch</summary> <summary>Stores window size to restore on next launch</summary>
</key> </key>
<key name="float-size" type="s">
<default>'[480, 270]'</default>
<summary>Stores floating window size to restore on next launch</summary>
</key>
<key name="volume-last" type="d"> <key name="volume-last" type="d">
<default>1</default> <default>1</default>
<summary>Stores last linear volume value to apply on startup</summary> <summary>Stores last linear volume value to apply on startup</summary>

View File

@@ -18,11 +18,7 @@ class ClapperCustomButton extends Gtk.Button
super._init(opts); super._init(opts);
this.floatUnaffected = false;
this.wantedVisible = true;
this.isFullscreen = false; this.isFullscreen = false;
this.isFloating = false;
this.add_css_class('flat'); this.add_css_class('flat');
} }
@@ -43,32 +39,6 @@ class ClapperCustomButton extends Gtk.Button
this.isFullscreen = isFullscreen; 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() vfunc_clicked()
{ {
if(!this.isFullscreen) 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( var IconToggleButton = GObject.registerClass(
class ClapperIconToggleButton extends IconButton class ClapperIconToggleButton extends CustomButton
{ {
_init(primaryIcon, secondaryIcon) _init(primaryIcon, secondaryIcon)
{ {
super._init(primaryIcon); super._init({
icon_name: primaryIcon,
});
this.primaryIcon = primaryIcon; this.primaryIcon = primaryIcon;
this.secondaryIcon = secondaryIcon; this.secondaryIcon = secondaryIcon;

23
src/controls.js vendored
View File

@@ -47,7 +47,6 @@ class ClapperControls extends Gtk.Box
'go-previous-symbolic', 'go-previous-symbolic',
'go-next-symbolic' 'go-next-symbolic'
); );
revealTracksButton.floatUnaffected = false;
revealTracksButton.add_css_class('narrowbutton'); revealTracksButton.add_css_class('narrowbutton');
this.buttonsArr.push(revealTracksButton); this.buttonsArr.push(revealTracksButton);
const tracksRevealer = new Revealers.ButtonsRevealer( const tracksRevealer = new Revealers.ButtonsRevealer(
@@ -90,12 +89,6 @@ class ClapperControls extends Gtk.Box
this.unfullscreenButton.connect('clicked', this._onUnfullscreenClicked.bind(this)); this.unfullscreenButton.connect('clicked', this._onUnfullscreenClicked.bind(this));
this.unfullscreenButton.set_visible(false); 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(); const keyController = new Gtk.EventControllerKey();
keyController.connect('key-pressed', this._onControlsKeyPressed.bind(this)); keyController.connect('key-pressed', this._onControlsKeyPressed.bind(this));
keyController.connect('key-released', this._onControlsKeyReleased.bind(this)); keyController.connect('key-released', this._onControlsKeyReleased.bind(this));
@@ -117,14 +110,6 @@ class ClapperControls extends Gtk.Box
this.set_can_focus(isFullscreen); this.set_can_focus(isFullscreen);
} }
setFloatingMode(isFloating)
{
this.isMobile = null;
for(let button of this.buttonsArr)
button.setFloatingMode(isFloating);
}
setLiveMode(isLive, isSeekable) setLiveMode(isLive, isSeekable)
{ {
if(isLive) if(isLive)
@@ -147,7 +132,7 @@ class ClapperControls extends Gtk.Box
{ {
const button = (buttonIcon instanceof Gtk.Button) const button = (buttonIcon instanceof Gtk.Button)
? buttonIcon ? buttonIcon
: new Buttons.IconButton(buttonIcon); : new Buttons.CustomButton({ icon_name: buttonIcon });
if(!revealer) if(!revealer)
this.append(button); this.append(button);
@@ -528,12 +513,6 @@ class ClapperControls extends Gtk.Box
root.unfullscreen(); root.unfullscreen();
} }
_onUnfloatClicked(button)
{
const clapperWidget = this.get_ancestor(Gtk.Grid);
clapperWidget.setFloatingMode(false);
}
_onCheckButtonToggled(checkButton) _onCheckButtonToggled(checkButton)
{ {
if(!checkButton.get_active()) if(!checkButton.get_active())

View File

@@ -342,7 +342,7 @@ class ClapperPlayer extends PlayerBase
if(this.cursorInPlayer) { if(this.cursorInPlayer) {
const clapperWidget = this.widget.get_ancestor(Gtk.Grid); const clapperWidget = this.widget.get_ancestor(Gtk.Grid);
if(clapperWidget.fullscreenMode || clapperWidget.floatingMode) { if(clapperWidget.fullscreenMode) {
this._clearTimeout('updateTime'); this._clearTimeout('updateTime');
clapperWidget.revealControls(false); clapperWidget.revealControls(false);
} }
@@ -644,7 +644,7 @@ class ClapperPlayer extends PlayerBase
this._setHideCursorTimeout(); this._setHideCursorTimeout();
const clapperWidget = this.widget.get_ancestor(Gtk.Grid); const clapperWidget = this.widget.get_ancestor(Gtk.Grid);
if(clapperWidget.fullscreenMode || clapperWidget.floatingMode) if(clapperWidget.fullscreenMode)
this._setHideControlsTimeout(); this._setHideControlsTimeout();
} }
@@ -676,12 +676,7 @@ class ClapperPlayer extends PlayerBase
clapperWidget.revealerTop.set_cursor(defaultCursor); clapperWidget.revealerTop.set_cursor(defaultCursor);
this._setHideCursorTimeout(); this._setHideCursorTimeout();
if(clapperWidget.floatingMode && !clapperWidget.fullscreenMode) { if(clapperWidget.fullscreenMode) {
clapperWidget.revealerBottom.set_can_focus(false);
clapperWidget.revealerBottom.revealChild(true);
this._setHideControlsTimeout();
}
else if(clapperWidget.fullscreenMode) {
if(!this._updateTimeTimeout) if(!this._updateTimeTimeout)
this._setUpdateTimeInterval(); this._setUpdateTimeInterval();

View File

@@ -198,15 +198,6 @@ class ClapperRevealerBottom extends CustomRevealer
this.revealerBox.remove(widget); 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) set_visible(isVisible)
{ {
const isChange = super.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) append(widget)
{ {
this.get_child().append(widget); this.get_child().append(widget);

View File

@@ -21,11 +21,9 @@ class ClapperWidget extends Gtk.Grid
Misc.loadCustomCss(); Misc.loadCustomCss();
this.windowSize = JSON.parse(settings.get_string('window-size')); this.windowSize = JSON.parse(settings.get_string('window-size'));
this.floatSize = JSON.parse(settings.get_string('float-size'));
this.layoutWidth = 0; this.layoutWidth = 0;
this.fullscreenMode = false; this.fullscreenMode = false;
this.floatingMode = false;
this.isSeekable = false; this.isSeekable = false;
this.isMobileMonitor = false; this.isMobileMonitor = false;
@@ -120,14 +118,7 @@ class ClapperWidget extends Gtk.Grid
if(!this.isMobileMonitor) if(!this.isMobileMonitor)
root[action + '_css_class']('tvmode'); root[action + '_css_class']('tvmode');
if(!this.floatingMode)
this._changeControlsPlacement(isFullscreen); this._changeControlsPlacement(isFullscreen);
else {
this._setWindowFloating(!isFullscreen);
this.revealerBottom.setFloatingClass(!isFullscreen);
this.controls.setFloatingMode(!isFullscreen);
this.controls.unfloatButton.set_visible(!isFullscreen);
}
this.controls.setFullscreenMode(isFullscreen); this.controls.setFullscreenMode(isFullscreen);
this.showControls(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) _saveWindowSize(size)
{ {
const rootName = (this.floatingMode) settings.set_string('window-size', JSON.stringify(size));
? 'float' debug(`saved window size: ${size[0]}x${size[1]}`);
: 'window';
settings.set_string(`${rootName}-size`, JSON.stringify(size));
debug(`saved ${rootName} size: ${size[0]}x${size[1]}`);
} }
_changeControlsPlacement(isOnTop) _changeControlsPlacement(isOnTop)
@@ -599,7 +536,6 @@ class ClapperWidget extends Gtk.Grid
{ {
if( if(
this.fullscreenMode this.fullscreenMode
|| !this.floatingMode
|| this.player.isWidgetDragging || this.player.isWidgetDragging
) )
return; return;