Files
clapper/src/app.js
Rafał Dzięgiel 2e892c923b Support opening folders with media files
D&D folder with videos onto Clapper window to play them as video playlist. If folder contains exactly one video and subtitle file, then that video will be played with subtitles automatically applied.
2021-04-20 18:44:53 +02:00

52 lines
1.2 KiB
JavaScript

const { Gio, GObject, Gtk } = imports.gi;
const { AppBase } = imports.src.appBase;
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.flags |= Gio.ApplicationFlags.HANDLES_OPEN;
}
vfunc_startup()
{
super.vfunc_startup();
const window = this.active_window;
const clapperWidget = new Widget();
const dummyHeaderbar = new Gtk.Box({
can_focus: false,
focusable: false,
visible: false,
});
window.add_css_class('nobackground');
window.set_child(clapperWidget);
window.set_titlebar(dummyHeaderbar);
this.mapSignal = window.connect('map', this._onWindowMap.bind(this));
}
vfunc_open(files, hint)
{
super.vfunc_open(files, hint);
this._openFilesAsync(files).then(() => this.activate()).catch(debug);
}
_onWindowMap(window)
{
window.disconnect(this.mapSignal);
this.mapSignal = null;
window.child._onWindowMap(window);
}
});