Open new file in the same window. Closes #31

This commit is contained in:
Rafostar
2020-12-24 00:23:49 +01:00
parent f2d8d8ad4f
commit 6afbbc767a
6 changed files with 63 additions and 35 deletions

View File

@@ -1,4 +1,4 @@
const { GObject } = imports.gi;
const { Gio, GObject } = imports.gi;
const { AppBase } = imports.clapper_src.appBase;
const { HeaderBar } = imports.clapper_src.headerbar;
const { Widget } = imports.clapper_src.widget;
@@ -9,6 +9,17 @@ let { debug } = Debug;
var App = GObject.registerClass(
class ClapperApp extends AppBase
{
_init()
{
super._init();
this.set_flags(
this.get_flags()
| Gio.ApplicationFlags.HANDLES_OPEN
);
this.playlist = [];
}
vfunc_startup()
{
super.vfunc_startup();
@@ -27,13 +38,22 @@ class ClapperApp extends AppBase
debug(`restored window size: ${size[0]}x${size[1]}`);
}
vfunc_open(files, hint)
{
super.vfunc_open(files, hint);
this.playlist = files;
this._handleAppStart();
}
_onWindowShow(window)
{
super._onWindowShow(window);
if(this.playlist.length) {
let { player } = window.get_child();
player.set_playlist(this.playlist);
}
if(!this.playlist.length)
return;
let { player } = window.get_child();
player.set_playlist(this.playlist);
}
});