[polari/wip/fmuellner/paste-confirmation: 16/16] entryArea: Does pasting files make sense?



commit 6a9ea1fac058371ee88d2bfad1966a0502b29bf5
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Feb 12 18:49:23 2016 +0100

    entryArea: Does pasting files make sense?

 src/entryArea.js |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/src/entryArea.js b/src/entryArea.js
index fe51b79..d67d445 100644
--- a/src/entryArea.js
+++ b/src/entryArea.js
@@ -23,7 +23,8 @@ const ChatEntry = new Lang.Class({
     Extends: Gtk.Entry,
     Signals: { 'text-pasted': { param_types: [GObject.TYPE_STRING,
                                               GObject.TYPE_INT] },
-               'image-pasted': { param_types: [GdkPixbuf.Pixbuf.$gtype] } },
+               'image-pasted': { param_types: [GdkPixbuf.Pixbuf.$gtype] },
+               'file-pasted': { param_types: [Gio.File.$gtype] } },
 
     _init: function(params) {
         this.parent(params);
@@ -61,6 +62,13 @@ const ChatEntry = new Lang.Class({
                     return;
                 this.emit('image-pasted', pixbuf);
             }));
+
+        clipboard.request_uris(Lang.bind(this,
+            function(clipboard, uris) {
+                if (!uris.length)
+                    return;
+                this.emit('file-pasted', Gio.File.new_for_uri(uris[0]));
+            }));
     },
 });
 
@@ -124,6 +132,10 @@ const EntryArea = new Lang.Class({
             function(entry, image) {
                 this.pasteImage(image);
             }));
+        this._chatEntry.connect('file-pasted', Lang.bind(this,
+            function(entry, file) {
+                this.pasteFile(file);
+            }));
         this._chatEntry.connect('changed', Lang.bind(this, this._onEntryChanged));
 
         this._chatEntry.connect('activate', Lang.bind(this,


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