mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 07:42:23 +02:00
Open file(s) by Drag & Drop
This commit is contained in:
@@ -62,6 +62,13 @@ class ClapperPlayer extends PlayerBase
|
|||||||
motionController.connect('motion', this._onWidgetMotion.bind(this));
|
motionController.connect('motion', this._onWidgetMotion.bind(this));
|
||||||
this.widget.add_controller(motionController);
|
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('state-changed', this._onStateChanged.bind(this));
|
||||||
this.connect('uri-loaded', this._onUriLoaded.bind(this));
|
this.connect('uri-loaded', this._onUriLoaded.bind(this));
|
||||||
this.connect('end-of-stream', this._onStreamEnded.bind(this));
|
this.connect('end-of-stream', this._onStreamEnded.bind(this));
|
||||||
@@ -675,6 +682,20 @@ class ClapperPlayer extends PlayerBase
|
|||||||
return true;
|
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)
|
_onCloseRequest(window)
|
||||||
{
|
{
|
||||||
this._performCloseCleanup(window);
|
this._performCloseCleanup(window);
|
||||||
|
Reference in New Issue
Block a user