Open file(s) by Drag & Drop

This commit is contained in:
Rafostar
2021-01-08 18:07:24 +01:00
parent 2cbabe2887
commit 59555c103b

View File

@@ -62,6 +62,13 @@ class ClapperPlayer extends PlayerBase
motionController.connect('motion', this._onWidgetMotion.bind(this));
this.widget.add_controller(motionController);
const dropTarget = new Gtk.DropTarget({
actions: Gdk.DragAction.COPY,
});
dropTarget.set_gtypes([GObject.TYPE_STRING]);
dropTarget.connect('drop', this._onDataDrop.bind(this));
this.widget.add_controller(dropTarget);
this.connect('state-changed', this._onStateChanged.bind(this));
this.connect('uri-loaded', this._onUriLoaded.bind(this));
this.connect('end-of-stream', this._onStreamEnded.bind(this));
@@ -675,6 +682,20 @@ class ClapperPlayer extends PlayerBase
return true;
}
_onDataDrop(dropTarget, value, x, y)
{
const playlist = value.split(/\r?\n/).filter(uri => {
return Gst.uri_is_valid(uri);
});
if(!playlist.length)
return false;
this.set_playlist(playlist);
return true;
}
_onCloseRequest(window)
{
this._performCloseCleanup(window);