[polari/wip/fmuellner/paste-confirmation: 9/16] entryArea: Insert paste URL instead of sending it directly



commit e1466587bf61f69dfcb8b61bef4af41cb5e69899
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Feb 11 21:35:21 2016 +0100

    entryArea: Insert paste URL instead of sending it directly
    
    It usually makes sense to provide some context when sending a paste
    URL, so allow that by inserting the returned paste URL into the
    entry instead of sending it directly. Pasting content as URL is
    now a two-step operation - confirming the upload and sending the
    message - but hopefully that'll just be minor annoyance compared
    to the usefulness of the feature.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=760315

 src/entryArea.js |   21 +++++----------------
 1 files changed, 5 insertions(+), 16 deletions(-)
---
diff --git a/src/entryArea.js b/src/entryArea.js
index e1fd6b0..30046f0 100644
--- a/src/entryArea.js
+++ b/src/entryArea.js
@@ -1,5 +1,6 @@
 const Gdk = imports.gi.Gdk;
 const GdkPixbuf = imports.gi.GdkPixbuf;
+const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
 const GObject = imports.gi.GObject;
 const Gtk = imports.gi.Gtk;
@@ -223,7 +224,6 @@ const EntryArea = new Lang.Class({
             this._pasteButton.grab_focus();
             this.visible_child_name = 'paste-confirmation';
         } else {
-            this._chatEntry.text = '';
             this._chatEntry.grab_focus_without_selecting();
             this.visible_child_name = 'default';
         }
@@ -255,27 +255,16 @@ const EntryArea = new Lang.Class({
         try {
             app.pasteManager.pasteContent(this._pasteContent, title,
                 Lang.bind(this, function(url) {
-                    if (!url)
-                        return;
-
-                    let type = Tp.ChannelTextMessageType.NORMAL;
-                    let message = Tp.ClientMessage.new_text(type, url);
-                    this._room.channel.send_message_async(message, 0,
-                        Lang.bind(this, function(c, res) {
-                            try {
-                                 c.send_message_finish(res);
-                            } catch(e) {
-                                 logError(e, 'Failed to send message')
-                            }
-                        }));
+                    // TODO: handle errors
+                    this._setPasteContent(null);
+                    if (url)
+                        this._chatEntry.emit('insert-at-cursor', url);
                 }));
         } catch(e) {
             let type = typeof this._pasteContent;
             Utils.debug('Failed to paste content of type ' +
                         (type == 'object' ? this._pasteContent.toString() : type));
         }
-
-        this._setPasteContent(null);
     },
 
     _onCancelClicked: function() {


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