mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-31 16:31:58 +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 { Gio, GObject, Gtk } = imports.gi;
|
||||||
const { HeaderBar } = imports.clapper_src.headerbar;
|
const { HeaderBar } = imports.clapper_src.headerbar;
|
||||||
const { Widget } = imports.clapper_src.widget;
|
const { Widget } = imports.clapper_src.widget;
|
||||||
|
const Debug = imports.clapper_src.debug;
|
||||||
const Menu = imports.clapper_src.menu;
|
const Menu = imports.clapper_src.menu;
|
||||||
const Misc = imports.clapper_src.misc;
|
const Misc = imports.clapper_src.misc;
|
||||||
|
|
||||||
|
let { debug } = Debug;
|
||||||
|
|
||||||
const APP_NAME = 'Clapper';
|
const APP_NAME = 'Clapper';
|
||||||
const APP_ID = 'com.github.rafostar.Clapper';
|
const APP_ID = 'com.github.rafostar.Clapper';
|
||||||
|
|
||||||
@@ -52,6 +55,20 @@ class ClapperApp extends Gtk.Application
|
|||||||
window.set_titlebar(headerBar);
|
window.set_titlebar(headerBar);
|
||||||
|
|
||||||
let clapperWidget = new Widget();
|
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);
|
window.set_child(clapperWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -605,6 +605,15 @@ class ClapperPlayer extends PlayerBase
|
|||||||
if(this.state !== GstPlayer.PlayerState.STOPPED)
|
if(this.state !== GstPlayer.PlayerState.STOPPED)
|
||||||
this.stop();
|
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();
|
let app = window.get_application();
|
||||||
if(app) app.quit();
|
if(app) app.quit();
|
||||||
}
|
}
|
||||||
|
@@ -56,9 +56,6 @@ var Widget = GObject.registerClass({
|
|||||||
this.mapSignal = this.connect('map', this._onMap.bind(this));
|
this.mapSignal = this.connect('map', this._onMap.bind(this));
|
||||||
|
|
||||||
this.player = new Player();
|
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('position-updated', this._onPlayerPositionUpdated.bind(this));
|
||||||
this.player.selfConnect('duration-changed', this._onPlayerDurationChanged.bind(this));
|
this.player.selfConnect('duration-changed', this._onPlayerDurationChanged.bind(this));
|
||||||
this.player.selfConnect('volume-changed', this._onPlayerVolumeChanged.bind(this));
|
this.player.selfConnect('volume-changed', this._onPlayerVolumeChanged.bind(this));
|
||||||
|
@@ -34,5 +34,11 @@
|
|||||||
<default>'[{"apply":false,"name":"vah264dec","rank":300}]'</default>
|
<default>'[{"apply":false,"name":"vah264dec","rank":300}]'</default>
|
||||||
<summary>Custom values for GStreamer plugin ranking</summary>
|
<summary>Custom values for GStreamer plugin ranking</summary>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
|
<!-- Other -->
|
||||||
|
<key name="window-size" type="s">
|
||||||
|
<default>'[960, 583]'</default>
|
||||||
|
<summary>Stores window size to restore on next launch</summary>
|
||||||
|
</key>
|
||||||
</schema>
|
</schema>
|
||||||
</schemalist>
|
</schemalist>
|
||||||
|
Reference in New Issue
Block a user