[gnome-maps] SearchPopup: Add scrolled window



commit 8ff6d1322b37b930c88c26b01456ca21c453f822
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Fri Aug 23 09:49:55 2013 +0200

    SearchPopup: Add scrolled window
    
    https://bugzilla.gnome.org/show_bug.cgi?id=706636

 src/mainWindow.js   |    2 +-
 src/search-popup.ui |   23 +++++++++++++++--------
 src/searchPopup.js  |   32 ++++++++++++++++++++++----------
 3 files changed, 38 insertions(+), 19 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index a205ee8..ee782f3 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -81,7 +81,7 @@ const MainWindow = new Lang.Class({
     },
 
     _initSearchWidgets: function() {
-        this._searchPopup = new SearchPopup.SearchPopup();
+        this._searchPopup = new SearchPopup.SearchPopup(10);
 
         let model = new Gtk.ListStore();
         model.set_column_types([GObject.TYPE_STRING,
diff --git a/src/search-popup.ui b/src/search-popup.ui
index a56c5a2..7f5377f 100644
--- a/src/search-popup.ui
+++ b/src/search-popup.ui
@@ -8,16 +8,23 @@
       <class name="search-popup" />
     </style>
     <child>
-      <object class="GtkTreeView" id="treeview">
+      <object class="GtkScrolledWindow" id="scrolled-window">
         <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"/>
-        </child>
+        <property name="can_focus">False</property>
+        <property name="hscrollbar_policy">never</property>
+        <child>
+          <object class="GtkTreeView" id="treeview">
+            <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"/>
+            </child>
           </object>
+        </child>
+      </object>
     </child>
   </object>
 </interface>
diff --git a/src/searchPopup.js b/src/searchPopup.js
index 86eb196..2d98da7 100644
--- a/src/searchPopup.js
+++ b/src/searchPopup.js
@@ -31,23 +31,28 @@ const SearchPopup = new Lang.Class({
     Name: 'SearchPopup',
     Extends: Gtk.Bin,
 
-    _init: function() {
-        this.parent({ width_request: 500,
-                      halign: Gtk.Align.CENTER,
-                      valign: Gtk.Align.START,
-                      margin_top: 10,
-                      no_show_all: true,
-                      visible: true });
+    _init: function(numVisible) {
+        this._numVisible = numVisible;
 
         let ui = Utils.getUIObject('search-popup', ['frame',
-                                                    'treeview',
-                                                    'treeview-selection']);
+                                                    'scrolled-window',
+                                                    'treeview']);
+        this._scrolledWindow = ui.scrolledWindow;
         this._treeView = ui.treeview;
-        this._treeViewSelection = ui.treeviewSelection;
         this._treeView.connect('button-press-event',
                                this._onListButtonPress.bind(this));
         this._initList();
 
+        this.height_request = this._cellHeight * this._numVisible;
+        this._scrolledWindow.set_min_content_height(this.height_request);
+
+        this.parent({ width_request: 500,
+                      halign: Gtk.Align.CENTER,
+                      valign: Gtk.Align.START,
+                      margin_top: 10,
+                      no_show_all: true,
+                      visible: true });
+
         this.add(ui.frame);
         this.hide();
     },
@@ -60,6 +65,8 @@ const SearchPopup = new Lang.Class({
         this._treeView.append_column(column);
         column.pack_start(cell, true);
         column.add_attribute(cell, 'markup', Columns.TEXT);
+
+        this._cellHeight = column.cell_get_size(null)[3];
     },
 
     _onListButtonPress: function(widget, event) {
@@ -84,6 +91,11 @@ const SearchPopup = new Lang.Class({
         }
     },
 
+    vfunc_show: function() {
+        this._treeView.columns_autosize();
+        this.parent();
+    },
+
     setModel: function(model) {
         this._treeView.set_model(model);
     },


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