[polari/wip/fmuellner/paste-confirmation: 15/16] chatView: Re-enable drop target support



commit 02353ad0a837cd738eeaf04613f96d718768736d
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Feb 12 00:56:43 2016 +0100

    chatView: Re-enable drop target support

 src/chatView.js     |    9 ++++++++-
 src/pasteManager.js |    5 -----
 src/roomStack.js    |   13 +++++++++++++
 3 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 8e0a0b2..ac71063 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -11,6 +11,7 @@ const Tpl = imports.gi.TelepathyLogger;
 
 const Lang = imports.lang;
 const Mainloop = imports.mainloop;
+const PasteManager = imports.pasteManager;
 const Signals = imports.signals;
 const Utils = imports.utils;
 
@@ -220,7 +221,9 @@ const ButtonTag = new Lang.Class({
 const ChatView = new Lang.Class({
     Name: 'ChatView',
     Extends: Gtk.ScrolledWindow,
+    Implements: [PasteManager.DropTargetIface],
     Properties: {
+        'can-drop': GObject.ParamSpec.override('can-drop', PasteManager.DropTargetIface),
         'max-nick-chars': GObject.ParamSpec.uint('max-nick-chars',
                                                  'max-nick-chars',
                                                  'max-nick-chars',
@@ -308,7 +311,7 @@ const ChatView = new Lang.Class({
         this._scrollBottom = adj.upper - adj.page_size;
 
         this._app = Gio.Application.get_default();
-        this._app.pasteManager.addWidget(this._view);
+        PasteManager.DropTargetIface.addTargets(this, this._view);
 
         this._hoverCursor = Gdk.Cursor.new(Gdk.CursorType.HAND1);
 
@@ -516,6 +519,10 @@ const ChatView = new Lang.Class({
         return this._maxNickChars;
     },
 
+    get can_drop() {
+        return this._channel != null;
+    },
+
     _updateMaxNickChars: function(length) {
         if (length <= this._maxNickChars)
             return;
diff --git a/src/pasteManager.js b/src/pasteManager.js
index 15f6a5a..044be7a 100644
--- a/src/pasteManager.js
+++ b/src/pasteManager.js
@@ -35,11 +35,6 @@ const PasteManager = new Lang.Class({
     _init: function() {
     },
 
-    addWidget: function(widget) {
-        // auto-paste needs some design; disable for now
-        return;
-    },
-
     pasteContent: function(content, title, callback) {
         if (typeof content == 'string') {
             Utils.gpaste(content, title, callback);
diff --git a/src/roomStack.js b/src/roomStack.js
index 5a49f5e..485e7c3 100644
--- a/src/roomStack.js
+++ b/src/roomStack.js
@@ -135,6 +135,19 @@ const RoomView = new Lang.Class({
                                  GObject.BindingFlags.SYNC_CREATE);
         sizeGroup.add_widget(this._entryArea);
 
+        this._view.connect('text-dropped', Lang.bind(this,
+            function(view, text) {
+               this._entryArea.pasteText(text, text.split('\n').length);
+            }));
+        this._view.connect('image-dropped', Lang.bind(this,
+            function(view, image) {
+               this._entryArea.pasteImage(image);
+            }));
+        this._view.connect('file-dropped', Lang.bind(this,
+            function(view, file) {
+               this._entryArea.pasteFile(file);
+            }));
+
         this.show_all();
     },
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]