mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-29 23:32:04 +02:00
Properly store and restore last volume value on startup
We cannot depend on the value saved by GStreamer, cause it is shared with all GStreamer based apps. Lets save the last value to gsettings instead to make sure this is the volume we used with this app. With this change we can also see the right volume on startup before media file is loaded (previously it was shown always as muted).
This commit is contained in:
11
clapper_src/controls.js
vendored
11
clapper_src/controls.js
vendored
@@ -7,6 +7,7 @@ const CONTROLS_MARGIN = 4;
|
|||||||
const CONTROLS_SPACING = 4;
|
const CONTROLS_SPACING = 4;
|
||||||
|
|
||||||
let { debug } = Debug;
|
let { debug } = Debug;
|
||||||
|
let { settings } = Misc;
|
||||||
|
|
||||||
var Controls = GObject.registerClass(
|
var Controls = GObject.registerClass(
|
||||||
class ClapperControls extends Gtk.Box
|
class ClapperControls extends Gtk.Box
|
||||||
@@ -317,9 +318,6 @@ class ClapperControls extends Gtk.Box
|
|||||||
draw_value: false,
|
draw_value: false,
|
||||||
vexpand: true,
|
vexpand: true,
|
||||||
});
|
});
|
||||||
this.volumeScale.connect(
|
|
||||||
'value-changed', this._onVolumeScaleValueChanged.bind(this)
|
|
||||||
);
|
|
||||||
this.volumeScale.add_css_class('volumescale');
|
this.volumeScale.add_css_class('volumescale');
|
||||||
this.volumeAdjustment = this.volumeScale.get_adjustment();
|
this.volumeAdjustment = this.volumeScale.get_adjustment();
|
||||||
|
|
||||||
@@ -332,6 +330,9 @@ class ClapperControls extends Gtk.Box
|
|||||||
this.volumeScale.add_mark(i, Gtk.PositionType.LEFT, text);
|
this.volumeScale.add_mark(i, Gtk.PositionType.LEFT, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.volumeScale.connect(
|
||||||
|
'value-changed', this._onVolumeScaleValueChanged.bind(this)
|
||||||
|
);
|
||||||
this.volumeButton.popoverBox.append(this.volumeScale);
|
this.volumeButton.popoverBox.append(this.volumeScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,6 +369,10 @@ class ClapperControls extends Gtk.Box
|
|||||||
);
|
);
|
||||||
scrollController.connect('scroll', player._onScroll.bind(player));
|
scrollController.connect('scroll', player._onScroll.bind(player));
|
||||||
this.volumeButton.add_controller(scrollController);
|
this.volumeButton.add_controller(scrollController);
|
||||||
|
|
||||||
|
let lastVolume = settings.get_double('volume-last');
|
||||||
|
let cubicVolume = Misc.getCubicValue(lastVolume);
|
||||||
|
this.volumeScale.set_value(cubicVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onUnfullscreenClicked(button)
|
_onUnfullscreenClicked(button)
|
||||||
|
@@ -628,10 +628,11 @@ class ClapperPlayer extends PlayerBase
|
|||||||
let clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
let clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
||||||
if(!clapperWidget.fullscreenMode) {
|
if(!clapperWidget.fullscreenMode) {
|
||||||
let size = window.get_size();
|
let size = window.get_size();
|
||||||
if(size[0] > 0 && size[1] > 0) {
|
if(size[0] > 0 && size[1] > 0)
|
||||||
clapperWidget._saveWindowSize(size);
|
clapperWidget._saveWindowSize(size);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
settings.set_double('volume-last', this.volume);
|
||||||
|
|
||||||
clapperWidget.controls._onCloseRequest();
|
clapperWidget.controls._onCloseRequest();
|
||||||
|
|
||||||
if(this.state === GstPlayer.PlayerState.STOPPED)
|
if(this.state === GstPlayer.PlayerState.STOPPED)
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
</key>
|
</key>
|
||||||
<key name="volume-value" type="i">
|
<key name="volume-value" type="i">
|
||||||
<default>100</default>
|
<default>100</default>
|
||||||
<summary>Custom initial volume value after startup</summary>
|
<summary>Custom initial volume value in percentage after startup</summary>
|
||||||
</key>
|
</key>
|
||||||
<key name="dark-theme" type="b">
|
<key name="dark-theme" type="b">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
@@ -74,5 +74,9 @@
|
|||||||
<default>'[480, 270]'</default>
|
<default>'[480, 270]'</default>
|
||||||
<summary>Stores floating window size to restore on next launch</summary>
|
<summary>Stores floating window size to restore on next launch</summary>
|
||||||
</key>
|
</key>
|
||||||
|
<key name="volume-last" type="d">
|
||||||
|
<default>1</default>
|
||||||
|
<summary>Stores last linear volume value to apply on startup</summary>
|
||||||
|
</key>
|
||||||
</schema>
|
</schema>
|
||||||
</schemalist>
|
</schemalist>
|
||||||
|
Reference in New Issue
Block a user