From 59555c103b2ac26167dcfea39fdb7b08ae86ed18 Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Fri, 8 Jan 2021 18:07:24 +0100 Subject: [PATCH] Open file(s) by Drag & Drop --- clapper_src/player.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/clapper_src/player.js b/clapper_src/player.js index 42c1f5d1..f20242b9 100644 --- a/clapper_src/player.js +++ b/clapper_src/player.js @@ -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);