mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 16:02:00 +02:00
Store and restore floating window size
This commit is contained in:
@@ -55,7 +55,7 @@ class ClapperApp extends Gtk.Application
|
|||||||
}
|
}
|
||||||
if(size) {
|
if(size) {
|
||||||
window.set_default_size(size[0], size[1]);
|
window.set_default_size(size[0], size[1]);
|
||||||
debug(`restored window dimensions: ${size[0]}x${size[1]}`);
|
debug(`restored window size: ${size[0]}x${size[1]}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
let clapperPath = Misc.getClapperPath();
|
let clapperPath = Misc.getClapperPath();
|
||||||
|
@@ -596,11 +596,10 @@ class ClapperPlayer extends PlayerBase
|
|||||||
_onCloseRequest(window)
|
_onCloseRequest(window)
|
||||||
{
|
{
|
||||||
let clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
let clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
||||||
if(!clapperWidget.fullscreenMode && !clapperWidget.floatingMode) {
|
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) {
|
||||||
settings.set_string('window-size', JSON.stringify(size));
|
clapperWidget._saveWindowSize(size);
|
||||||
debug(`saved window dimensions: ${size[0]}x${size[1]}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,6 +6,7 @@ const { Player } = imports.clapper_src.player;
|
|||||||
const Revealers = imports.clapper_src.revealers;
|
const Revealers = imports.clapper_src.revealers;
|
||||||
|
|
||||||
let { debug } = Debug;
|
let { debug } = Debug;
|
||||||
|
let { settings } = Misc;
|
||||||
|
|
||||||
var Widget = GObject.registerClass({
|
var Widget = GObject.registerClass({
|
||||||
Signals: {
|
Signals: {
|
||||||
@@ -35,6 +36,9 @@ var Widget = GObject.registerClass({
|
|||||||
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
|
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.windowSize = JSON.parse(settings.get_string('window-size'));
|
||||||
|
this.floatSize = JSON.parse(settings.get_string('float-size'));
|
||||||
|
|
||||||
this.fullscreenMode = false;
|
this.fullscreenMode = false;
|
||||||
this.floatingMode = false;
|
this.floatingMode = false;
|
||||||
this.isSeekable = false;
|
this.isSeekable = false;
|
||||||
@@ -122,15 +126,32 @@ var Widget = GObject.registerClass({
|
|||||||
if(this.floatingMode === isFloating)
|
if(this.floatingMode === isFloating)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
let root = this.get_root();
|
||||||
|
let size = root.get_size();
|
||||||
|
|
||||||
|
this._saveWindowSize(size);
|
||||||
|
|
||||||
|
if(isFloating)
|
||||||
|
this.windowSize = size;
|
||||||
|
else
|
||||||
|
this.floatSize = size;
|
||||||
|
|
||||||
this.floatingMode = isFloating;
|
this.floatingMode = isFloating;
|
||||||
|
|
||||||
this.revealerBottom.setFloatingClass(isFloating);
|
this.revealerBottom.setFloatingClass(isFloating);
|
||||||
this._changeControlsPlacement(isFloating);
|
this._changeControlsPlacement(isFloating);
|
||||||
this.controls.setFloatingMode(isFloating);
|
this.controls.setFloatingMode(isFloating);
|
||||||
this.controls.unfloatButton.set_visible(isFloating);
|
this.controls.unfloatButton.set_visible(isFloating);
|
||||||
this.revealerBottom.showChild(isFloating);
|
|
||||||
this._setWindowFloating(isFloating);
|
this._setWindowFloating(isFloating);
|
||||||
|
|
||||||
|
let resize = (isFloating)
|
||||||
|
? this.floatSize
|
||||||
|
: this.windowSize;
|
||||||
|
|
||||||
|
root.resize(resize[0], resize[1]);
|
||||||
|
debug(`resized window: ${resize[0]}x${resize[1]}`);
|
||||||
|
|
||||||
|
this.revealerBottom.showChild(false);
|
||||||
this.player.widget.grab_focus();
|
this.player.widget.grab_focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,6 +167,16 @@ var Widget = GObject.registerClass({
|
|||||||
root[action + '_css_class'](cssClass);
|
root[action + '_css_class'](cssClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_saveWindowSize(size)
|
||||||
|
{
|
||||||
|
let rootName = (this.floatingMode)
|
||||||
|
? 'float'
|
||||||
|
: 'window';
|
||||||
|
|
||||||
|
settings.set_string(`${rootName}-size`, JSON.stringify(size));
|
||||||
|
debug(`saved ${rootName} size: ${size[0]}x${size[1]}`);
|
||||||
|
}
|
||||||
|
|
||||||
_changeControlsPlacement(isOnTop)
|
_changeControlsPlacement(isOnTop)
|
||||||
{
|
{
|
||||||
if(isOnTop) {
|
if(isOnTop) {
|
||||||
|
@@ -40,5 +40,9 @@
|
|||||||
<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>
|
||||||
</schema>
|
</schema>
|
||||||
</schemalist>
|
</schemalist>
|
||||||
|
Reference in New Issue
Block a user