diff options
author | Thibaut Girka <thib@sitedethib.com> | 2018-04-08 20:08:30 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2020-02-22 02:47:08 +0100 |
commit | f5e0ecafae87c73d4d2959976849306011b65d85 (patch) | |
tree | cfa03826852c82f7ec7374a769f7ae8865c7a5ad /main | |
parent | b9125b7e3e080caa2c5f233a22f62136322eb077 (diff) | |
download | dino-f5e0ecafae87c73d4d2959976849306011b65d85.tar.gz dino-f5e0ecafae87c73d4d2959976849306011b65d85.zip |
Basic drag'n'drop support on main conversation view (fixes #175)
Diffstat (limited to 'main')
-rw-r--r-- | main/src/ui/conversation_summary/conversation_view.vala | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/main/src/ui/conversation_summary/conversation_view.vala b/main/src/ui/conversation_summary/conversation_view.vala index 4cde3668..33980c09 100644 --- a/main/src/ui/conversation_summary/conversation_view.vala +++ b/main/src/ui/conversation_summary/conversation_view.vala @@ -4,6 +4,15 @@ using Pango; using Dino.Entities; +enum Target { + URI_LIST, + STRING +} + +const TargetEntry[] target_list = { + { "text/uri-list", 0, Target.URI_LIST }, +}; + namespace Dino.Ui.ConversationSummary { [GtkTemplate (ui = "/im/dino/Dino/conversation_summary/view.ui")] @@ -58,6 +67,10 @@ public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins return true; }); + drag_dest_unset(main); + drag_dest_set(scrolled, DestDefaults.ALL, target_list, Gdk.DragAction.COPY); + scrolled.drag_data_received.connect(this.on_drag_data_received); + return this; } @@ -172,6 +185,28 @@ public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins do_insert_item(item); } + public void on_drag_data_received(Widget widget, Gdk.DragContext context, + int x, int y, + SelectionData selection_data, + uint target_type, uint time) { + if ((selection_data != null) && (selection_data.get_length() >= 0)) { + switch (target_type) { + case Target.URI_LIST: + string[] uris = selection_data.get_uris(); + for (int i = 0; i < uris.length; i++) { + try { + string filename = Filename.from_uri(uris[i]); + stream_interactor.get_module(FileManager.IDENTITY).send_file(filename, conversation); + } catch (Error err) { + } + } + break; + default: + break; + } + } + } + public void do_insert_item(Plugins.MetaConversationItem item) { lock (meta_items) { insert_new(item); |