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) {
|
||||
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();
|
||||
|
@@ -596,11 +596,10 @@ class ClapperPlayer extends PlayerBase
|
||||
_onCloseRequest(window)
|
||||
{
|
||||
let clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
||||
if(!clapperWidget.fullscreenMode && !clapperWidget.floatingMode) {
|
||||
if(!clapperWidget.fullscreenMode) {
|
||||
let size = window.get_size();
|
||||
if(size[0] > 0 && size[1] > 0) {
|
||||
settings.set_string('window-size', JSON.stringify(size));
|
||||
debug(`saved window dimensions: ${size[0]}x${size[1]}`);
|
||||
clapperWidget._saveWindowSize(size);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -6,6 +6,7 @@ const { Player } = imports.clapper_src.player;
|
||||
const Revealers = imports.clapper_src.revealers;
|
||||
|
||||
let { debug } = Debug;
|
||||
let { settings } = Misc;
|
||||
|
||||
var Widget = GObject.registerClass({
|
||||
Signals: {
|
||||
@@ -35,6 +36,9 @@ var Widget = GObject.registerClass({
|
||||
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.floatingMode = false;
|
||||
this.isSeekable = false;
|
||||
@@ -122,15 +126,32 @@ var Widget = GObject.registerClass({
|
||||
if(this.floatingMode === isFloating)
|
||||
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.revealerBottom.setFloatingClass(isFloating);
|
||||
this._changeControlsPlacement(isFloating);
|
||||
this.controls.setFloatingMode(isFloating);
|
||||
this.controls.unfloatButton.set_visible(isFloating);
|
||||
this.revealerBottom.showChild(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();
|
||||
}
|
||||
|
||||
@@ -146,6 +167,16 @@ var Widget = GObject.registerClass({
|
||||
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)
|
||||
{
|
||||
if(isOnTop) {
|
||||
|
Reference in New Issue
Block a user