mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 16:02:00 +02:00
Remember and restore last window dimensions on launch
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
const { Gio, GObject, Gtk } = imports.gi;
|
||||
const { HeaderBar } = imports.clapper_src.headerbar;
|
||||
const { Widget } = imports.clapper_src.widget;
|
||||
const Debug = imports.clapper_src.debug;
|
||||
const Menu = imports.clapper_src.menu;
|
||||
const Misc = imports.clapper_src.misc;
|
||||
|
||||
let { debug } = Debug;
|
||||
|
||||
const APP_NAME = 'Clapper';
|
||||
const APP_ID = 'com.github.rafostar.Clapper';
|
||||
|
||||
@@ -52,6 +55,20 @@ class ClapperApp extends Gtk.Application
|
||||
window.set_titlebar(headerBar);
|
||||
|
||||
let clapperWidget = new Widget();
|
||||
let size = clapperWidget.player.settings.get_string('window-size');
|
||||
try {
|
||||
size = JSON.parse(size);
|
||||
}
|
||||
catch(err) {
|
||||
debug(err);
|
||||
size = null;
|
||||
}
|
||||
|
||||
if(size) {
|
||||
window.set_default_size(size[0], size[1]);
|
||||
debug(`restored window dimensions: ${size[0]}x${size[1]}`);
|
||||
}
|
||||
|
||||
window.set_child(clapperWidget);
|
||||
}
|
||||
|
||||
|
@@ -605,6 +605,15 @@ class ClapperPlayer extends PlayerBase
|
||||
if(this.state !== GstPlayer.PlayerState.STOPPED)
|
||||
this.stop();
|
||||
|
||||
let clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
||||
if(!clapperWidget.fullscreenMode) {
|
||||
let size = window.get_size();
|
||||
if(size[0] > 0 && size[1] > 0) {
|
||||
this.settings.set_string('window-size', JSON.stringify(size));
|
||||
debug(`saved window dimensions: ${size[0]}x${size[1]}`);
|
||||
}
|
||||
}
|
||||
|
||||
let app = window.get_application();
|
||||
if(app) app.quit();
|
||||
}
|
||||
|
@@ -56,9 +56,6 @@ var Widget = GObject.registerClass({
|
||||
this.mapSignal = this.connect('map', this._onMap.bind(this));
|
||||
|
||||
this.player = new Player();
|
||||
this.player.widget.width_request = 960;
|
||||
this.player.widget.height_request = 540;
|
||||
|
||||
this.player.selfConnect('position-updated', this._onPlayerPositionUpdated.bind(this));
|
||||
this.player.selfConnect('duration-changed', this._onPlayerDurationChanged.bind(this));
|
||||
this.player.selfConnect('volume-changed', this._onPlayerVolumeChanged.bind(this));
|
||||
|
Reference in New Issue
Block a user