[gnome-maps] Add spinner to search popup



commit 79809286c0e65e5f43b75f44960ede512b71685e
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Tue Aug 27 16:01:33 2013 +0200

    Add spinner to search popup
    
    https://bugzilla.gnome.org/show_bug.cgi?id=706891

 data/gnome-maps.css |    1 +
 src/mainWindow.js   |   12 ++++++++++--
 src/mapView.js      |    3 +--
 src/search-popup.ui |   31 ++++++++++++++++++++++++-------
 src/searchPopup.js  |   29 ++++++++++++++++++++++++++++-
 5 files changed, 64 insertions(+), 12 deletions(-)
---
diff --git a/data/gnome-maps.css b/data/gnome-maps.css
index 187f442..9a1745d 100644
--- a/data/gnome-maps.css
+++ b/data/gnome-maps.css
@@ -11,6 +11,7 @@
        border-width: 5px;
        border-color: black;
        border-radius: 6px 6px 6px 6px;
+       background-color: white;
 }
 
 .zoom-control {
diff --git a/src/mainWindow.js b/src/mainWindow.js
index e755f40..89a1ea4 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -233,6 +233,10 @@ const MainWindow = new Lang.Class({
         let searchString = this._searchEntry.get_text();
 
         if (searchString.length > 0) {
+            let model = this._searchPopup.getModel();
+
+            model.clear();
+            this._searchPopup.showSpinner();
             this.mapView.geocodeSearch(searchString,
                                        this._showSearchResults.bind(this));
         }
@@ -241,7 +245,11 @@ const MainWindow = new Lang.Class({
     _showSearchResults: function(places) {
         let model = this._searchPopup.getModel();
 
-        model.clear();
+        if (places === null) {
+            this._searchPopup.hide();
+            return;
+        }
+
         places.forEach(function(place) {
             let iter = model.append();
             let location = place.get_location();
@@ -267,7 +275,7 @@ const MainWindow = new Lang.Class({
                 });
             }
         });
-        this._searchPopup.show();
+        this._searchPopup.showResult();
     },
 
     _quit: function() {
diff --git a/src/mapView.js b/src/mapView.js
index 7e63eab..c52b45b 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -107,8 +107,7 @@ const MapView = new Lang.Class({
             } catch (e) {
                 places = null;
             }
-            if (places !== null)
-                searchCompleteCallback(places);
+            searchCompleteCallback(places);
         }).bind(this));
     },
 
diff --git a/src/search-popup.ui b/src/search-popup.ui
index 7f5377f..5547c7d 100644
--- a/src/search-popup.ui
+++ b/src/search-popup.ui
@@ -13,14 +13,31 @@
         <property name="can_focus">False</property>
         <property name="hscrollbar_policy">never</property>
         <child>
-          <object class="GtkTreeView" id="treeview">
+          <object class="GtkStack" id="stack">
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="expand">True</property>
-            <property name="headers-visible">False</property>
-            <property name="hover-selection">True</property>
-            <child internal-child="selection">
-              <object class="GtkTreeSelection" id="treeview-selection"/>
+            <property name="can_focus">False</property>
+            <property name="transition-type">crossfade</property>
+            <child>
+              <object class="GtkTreeView" id="treeview">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="expand">True</property>
+                <property name="headers-visible">False</property>
+                <property name="hover-selection">True</property>
+                <child internal-child="selection">
+                  <object class="GtkTreeSelection" id="treeview-selection"/>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkSpinner" id="spinner">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">center</property>
+                <property name="valign">center</property>
+                <property name="width_request">16</property>
+                <property name="height_request">16</property>
+              </object>
             </child>
           </object>
         </child>
diff --git a/src/searchPopup.js b/src/searchPopup.js
index 618a7c9..da269a1 100644
--- a/src/searchPopup.js
+++ b/src/searchPopup.js
@@ -37,9 +37,15 @@ const SearchPopup = new Lang.Class({
 
         let ui = Utils.getUIObject('search-popup', ['frame',
                                                     'scrolled-window',
+                                                    'stack',
+                                                    'spinner',
                                                     'treeview']);
+
+        this._stack = ui.stack;
         this._scrolledWindow = ui.scrolledWindow;
+        this._spinner = ui.spinner;
         this._treeView = ui.treeview;
+
         this._treeView.connect('button-press-event',
                                this._onListButtonPress.bind(this));
         this._initList();
@@ -98,8 +104,29 @@ const SearchPopup = new Lang.Class({
         }
     },
 
-    vfunc_show: function() {
+    showSpinner: function() {
+        this._spinner.start();
+        this._stack.set_visible_child(this._spinner);
+
+        if (!this.get_visible())
+            this.show();
+    },
+
+    showResult: function() {
+        if (this._spinner.active)
+            this._spinner.stop();
+
         this._treeView.columns_autosize();
+        this._stack.set_visible_child(this._treeView);
+
+        if (!this.get_visible())
+            this.show();
+    },
+
+    vfunc_hide: function() {
+        if (this._spinner.active)
+            this._spinner.stop();
+
         this.parent();
     },
 


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