[polari/wip/fmuellner/drop-target-3-20: 4/6] chatView: Re-enable drop target support
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/drop-target-3-20: 4/6] chatView: Re-enable drop target support
- Date: Fri, 6 May 2016 15:41:28 +0000 (UTC)
commit 40b867b18237dc2d42836a0d0582aafe61c79690
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Feb 12 00:56:43 2016 +0100
chatView: Re-enable drop target support
Drag-n-drop provides an alternative to the clipboard for sharing content
between applications, however our support has been disabled since commit
ea4c7f61840. As we now have everything in place to hook up drops with the
existing paste/upload UI for confirmation, we can finally make the chat
log a drop target again.
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 f441031..eb2196a 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 a7d4ccf..3900581 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 05b2d38..80d161d 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]