mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-31 08:21:59 +02:00
The "clapper_src" directory name was unusual. This was done to make it work as a widget for other apps. Now that this functionality got removed it can be named simply "src" as recommended by guidelines.
67 lines
1.6 KiB
JavaScript
67 lines
1.6 KiB
JavaScript
const { Gio, GObject } = imports.gi;
|
|
const { AppBase } = imports.src.appBase;
|
|
const { HeaderBar } = imports.src.headerbar;
|
|
const { Widget } = imports.src.widget;
|
|
const Debug = imports.src.debug;
|
|
|
|
const { debug } = Debug;
|
|
|
|
var App = GObject.registerClass(
|
|
class ClapperApp extends AppBase
|
|
{
|
|
_init()
|
|
{
|
|
super._init();
|
|
|
|
this.set_flags(
|
|
this.get_flags()
|
|
| Gio.ApplicationFlags.HANDLES_OPEN
|
|
);
|
|
}
|
|
|
|
vfunc_startup()
|
|
{
|
|
super.vfunc_startup();
|
|
|
|
this.active_window.isClapperApp = true;
|
|
this.active_window.add_css_class('nobackground');
|
|
|
|
const clapperWidget = new Widget();
|
|
this.active_window.set_child(clapperWidget);
|
|
|
|
const headerBar = new HeaderBar(this.active_window);
|
|
this.active_window.set_titlebar(headerBar);
|
|
|
|
const size = clapperWidget.windowSize;
|
|
this.active_window.set_default_size(size[0], size[1]);
|
|
debug(`restored window size: ${size[0]}x${size[1]}`);
|
|
}
|
|
|
|
vfunc_open(files, hint)
|
|
{
|
|
super.vfunc_open(files, hint);
|
|
|
|
const { player } = this.active_window.get_child();
|
|
|
|
if(!this.doneFirstActivate)
|
|
player._preparePlaylist(files);
|
|
else
|
|
player.set_playlist(files);
|
|
|
|
this.activate();
|
|
}
|
|
|
|
_onWindowShow(window)
|
|
{
|
|
super._onWindowShow(window);
|
|
|
|
const { player } = this.active_window.get_child();
|
|
const success = player.playlistWidget.nextTrack();
|
|
|
|
if(!success)
|
|
debug('playlist is empty');
|
|
|
|
player.widget.grab_focus();
|
|
}
|
|
});
|