[gnome-maps] search-result: Show "No result found" in popover



commit 406e3f109b666f0ff1fd7d60d40878cf8fa5a508
Author: Elias Entrup <elias-git flump de>
Date:   Sun Jun 18 19:25:12 2017 +0200

    search-result: Show "No result found" in popover
    
    The search result popover now shows a "No results found"
    label if a search is unsuccessful instead of simply
    disappearing.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=764596

 data/ui/place-popover.ui |   12 ++++++++++++
 src/placeEntry.js        |    2 +-
 src/placePopover.js      |   12 +++++++++++-
 src/searchPopover.js     |    6 +++---
 4 files changed, 27 insertions(+), 5 deletions(-)
---
diff --git a/data/ui/place-popover.ui b/data/ui/place-popover.ui
index adf2f89..afb29d5 100644
--- a/data/ui/place-popover.ui
+++ b/data/ui/place-popover.ui
@@ -65,6 +65,18 @@
                 <property name="height_request">16</property>
               </object>
             </child>
+            <child>
+              <object class="GtkLabel" id="noResultsLabel">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">No results found</property>
+                <property name="width_request">16</property>
+                <property name="height_request">16</property>
+                <style>
+                  <class name="dim-label"/>
+                </style>
+              </object>
+            </child>
           </object>
         </child>
       </object>
diff --git a/src/placeEntry.js b/src/placeEntry.js
index eee769f..0cef292 100644
--- a/src/placeEntry.js
+++ b/src/placeEntry.js
@@ -214,7 +214,7 @@ const PlaceEntry = new Lang.Class({
         Application.geocodeService.search(this.text, bbox, this._cancellable, (function(places) {
             if (!places) {
                 this.place = null;
-                this._popover.hide();
+                this._popover.showNoResult();
                 return;
             }
             this._popover.updateResult(places, this.text);
diff --git a/src/placePopover.js b/src/placePopover.js
index 78923d3..fb1acbd 100644
--- a/src/placePopover.js
+++ b/src/placePopover.js
@@ -46,7 +46,8 @@ const PlacePopover = new Lang.Class({
                         'scrolledWindow',
                         'stack',
                         'spinner',
-                        'list' ],
+                        'list',
+                        'noResultsLabel' ],
 
     _init: function(props) {
         let numVisible = props.num_visible;
@@ -122,6 +123,15 @@ const PlacePopover = new Lang.Class({
             this.show();
     },
 
+    showNoResult: function() {
+        this._mode = Mode.IDLE;
+
+        if (this._spinner.active)
+            this._spinner.stop();
+
+        this._stack.visible_child = this._noResultsLabel;
+    },
+
     showCompletion: function() {
         if (this._mode === undefined || this._mode === Mode.ACTIVATED) {
             this._mode = Mode.IDLE;
diff --git a/src/searchPopover.js b/src/searchPopover.js
index 03c47e9..f0a72af 100644
--- a/src/searchPopover.js
+++ b/src/searchPopover.js
@@ -56,9 +56,6 @@ const SearchPopover = new Lang.Class({
         } else
             row = this._list.get_row_at_index(0);
 
-        if (!row)
-            return false;
-
         let length = this._list.get_children().length;
         let keyval = event.get_keyval()[1];
 
@@ -68,6 +65,9 @@ const SearchPopover = new Lang.Class({
             return false;
         }
 
+        if (!row)
+            return false;
+
         // If we get an 'enter' keypress and we have a selected
         // row, we do not want to propagate the event.
         if ((this.visible && row.is_selected()) &&


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