[polari] entryArea: Use paste-confirmation area to indicate upload progress



commit cad0a7333dd4306158b58fe02eee18d35049219e
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Feb 11 22:24:17 2016 +0100

    entryArea: Use paste-confirmation area to indicate upload progress
    
    Now that we insert paste URL into the entry rather than sending them
    directly, we don't want the current entry text to change while the
    upload is in progress - we'd just end up with situations where the
    insertion interferes with what the user is currently typing.
    
    To prevent this, we only switch back to the entry after the upload
    has finished, which makes the paste-confirmation area available for
    replacing the old upload notification we removed earlier.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=760315

 data/resources/entry-area.ui |   64 ++++++++++++++++++++++++++++++++---------
 src/entryArea.js             |    8 +++++
 2 files changed, 58 insertions(+), 14 deletions(-)
---
diff --git a/data/resources/entry-area.ui b/data/resources/entry-area.ui
index af10152..6fb045a 100644
--- a/data/resources/entry-area.ui
+++ b/data/resources/entry-area.ui
@@ -100,10 +100,19 @@
             <property name="visible">True</property>
             <property name="spacing">6</property>
             <property name="margin">6</property>
-            <property name="margin-end">14</property>
+            <property name="margin-end">0</property>
             <child>
-              <object class="GtkLabel" id="confirmLabel">
+              <object class="GtkSpinner">
                 <property name="visible">True</property>
+                <property name="active" bind-source="uploadLabel"
+                          bind-property="visible" bind-flags="sync-create" />
+              </object>
+            </child>
+            <child>
+              <object class="GtkLabel" id="uploadLabel">
+                <property name="visible" bind-source="confirmLabel"
+                          bind-property="visible"
+                          bind-flags="sync-create|invert-boolean" />
                 <property name="halign">start</property>
                 <property name="hexpand">True</property>
                 <property name="ellipsize">end</property>
@@ -111,22 +120,49 @@
               </object>
             </child>
             <child>
-              <object class="GtkButton" id="cancelButton">
-                <property name="label" translatable="yes">_Cancel</property>
-                <property name="visible">True</property>
-                <property name="receives-default">True</property>
-                <property name="use-underline">True</property>
+              <object class="GtkLabel" id="confirmLabel">
+                <property name="halign">start</property>
+                <property name="hexpand">True</property>
+                <property name="ellipsize">end</property>
+                <property name="xalign">0</property>
               </object>
             </child>
             <child>
-              <object class="GtkButton" id="pasteButton">
-                <property name="label" translatable="yes">_Paste</property>
+              <object class="GtkRevealer">
                 <property name="visible">True</property>
-                <property name="receives-default">True</property>
-                <property name="use-underline">True</property>
-                <style>
-                  <class name="suggested-action"/>
-                </style>
+                <property name="transition-type">slide-left</property>
+                <property name="reveal-child" bind-source="confirmLabel"
+                          bind-property="visible" bind-flags="sync-create" />
+                <child>
+                  <object class="GtkBox">
+                    <property name="visible">True</property>
+                    <property name="spacing">6</property>
+                    <property name="margin-end">14</property>
+                    <child>
+                      <object class="GtkButton" id="cancelButton">
+                        <property name="label" translatable="yes">_Cancel</property>
+                        <property name="visible">True</property>
+                        <property name="receives-default">True</property>
+                        <property name="use-underline">True</property>
+                        <property name="sensitive" bind-source="confirmLabel"
+                                  bind-property="visible" bind-flags="sync-create" />
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="pasteButton">
+                        <property name="label" translatable="yes">_Paste</property>
+                        <property name="visible">True</property>
+                        <property name="receives-default">True</property>
+                        <property name="use-underline">True</property>
+                        <property name="sensitive" bind-source="confirmLabel"
+                                  bind-property="visible" bind-flags="sync-create" />
+                        <style>
+                          <class name="suggested-action"/>
+                        </style>
+                      </object>
+                    </child>
+                  </object>
+                </child>
               </object>
             </child>
           </object>
diff --git a/src/entryArea.js b/src/entryArea.js
index 43a89f0..bd4b7c5 100644
--- a/src/entryArea.js
+++ b/src/entryArea.js
@@ -76,6 +76,7 @@ const EntryArea = new Lang.Class({
                        'changeButton',
                        'pasteBox',
                        'confirmLabel',
+                       'uploadLabel',
                        'cancelButton',
                        'pasteButton'],
     Properties: {
@@ -221,6 +222,7 @@ const EntryArea = new Lang.Class({
         this._pasteContent = content;
 
         if (content) {
+            this._confirmLabel.show();
             this.visible_child_name = 'paste-confirmation';
             this._pasteButton.grab_focus();
         } else {
@@ -234,11 +236,16 @@ const EntryArea = new Lang.Class({
             ngettext("Paste %s line of text to public paste service?",
                      "Paste %s lines of text to public paste service?",
                      nLines).format(nLines);
+        this._uploadLabel.label =
+            ngettext("Uploading %s line of text to public paste service …",
+                     "Uploading %s lines of text to public paste service …",
+                     nLines).format(nLines);
         this._setPasteContent(text);
     },
 
     _onImagePasted: function(entry, pixbuf) {
         this._confirmLabel.label = _("Upload image to public paste service?");
+        this._uploadLabel.label = _("Uploading image to public paste service …");
         this._setPasteContent(pixbuf);
     },
 
@@ -265,6 +272,7 @@ const EntryArea = new Lang.Class({
             Utils.debug('Failed to paste content of type ' +
                         (type == 'object' ? this._pasteContent.toString() : type));
         }
+        this._confirmLabel.hide();
     },
 
     _onCancelClicked: function() {


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