[gnome-maps/wip/templates: 4/5] searchPopup: Convert to template
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/templates: 4/5] searchPopup: Convert to template
- Date: Mon, 10 Nov 2014 14:24:17 +0000 (UTC)
commit f0047a9b25c9d6c15e940eba21ec8ee0dd6e8466
Author: Jonas Danielsson <jonas danielsson threetimestwo org>
Date: Mon Nov 10 09:19:50 2014 -0500
searchPopup: Convert to template
src/search-popup.ui | 94 +++++++++++++++++++++++++++-----------------------
src/searchPopup.js | 23 ++++--------
2 files changed, 59 insertions(+), 58 deletions(-)
---
diff --git a/src/search-popup.ui b/src/search-popup.ui
index 1ddfb17..12e07e3 100644
--- a/src/search-popup.ui
+++ b/src/search-popup.ui
@@ -1,68 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.10 -->
- <object class="GtkStack" id="stack">
+ <template class="Gjs_SearchPopup" parent="GtkPopover">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="transition-type">crossfade</property>
<style>
- <class name="maps-stack"/>
+ <class name="maps-popover"/>
</style>
<child>
- <object class="GtkScrolledWindow" id="scrolled-window">
+ <object class="GtkStack" id="stack">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="hscrollbar_policy">never</property>
- <property name="shadow_type">in</property>
+ <property name="transition-type">crossfade</property>
+ <style>
+ <class name="maps-stack"/>
+ </style>
<child>
- <object class="GtkTreeView" id="treeview">
+ <object class="GtkScrolledWindow" id="scrolledWindow">
<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>
- <property name="activate-on-single-click">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>
+ <property name="shadow_type">in</property>
<child>
- <object class="GtkTreeViewColumn" id="icon-column">
+ <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>
+ <property name="activate-on-single-click">True</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview-selection"/>
+ </child>
<child>
- <object class="GtkCellRendererPixbuf" id="icon-cell">
- <property name="xpad">2</property>
+ <object class="GtkTreeViewColumn" id="iconColumn">
+ <child>
+ <object class="GtkCellRendererPixbuf" id="icon-cell">
+ <property name="xpad">2</property>
+ </object>
+ <attributes>
+ <attribute name="pixbuf">0</attribute>
+ </attributes>
+ </child>
</object>
- <attributes>
- <attribute name="pixbuf">0</attribute>
- </attributes>
</child>
- </object>
- </child>
- <child>
- <object class="GtkTreeViewColumn" id="text-column">
<child>
- <object class="GtkCellRendererText" id="text-cell">
- <property name="xpad">4</property>
- <property name="ypad">4</property>
+ <object class="GtkTreeViewColumn" id="textColumn">
+ <child>
+ <object class="GtkCellRendererText" id="text-cell">
+ <property name="xpad">4</property>
+ <property name="ypad">4</property>
+ </object>
+ <attributes>
+ <attribute name="markup">2</attribute>
+ </attributes>
+ </child>
</object>
- <attributes>
- <attribute name="markup">2</attribute>
- </attributes>
</child>
</object>
</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>
- <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>
+ </template>
</interface>
diff --git a/src/searchPopup.js b/src/searchPopup.js
index 3517622..21f8a31 100644
--- a/src/searchPopup.js
+++ b/src/searchPopup.js
@@ -40,20 +40,18 @@ const SearchPopup = new Lang.Class({
Signals : {
'selected' : { param_types: [ GObject.TYPE_OBJECT ] }
},
+ Template: 'resource:///org/gnome/maps/search-popup.ui',
+ InternalChildren: [ 'scrolledWindow',
+ 'stack',
+ 'spinner',
+ 'treeView',
+ 'textColumn' ],
_init: function(props) {
this._numVisible = props.num_visible;
delete props.num_visible;
- let ui = Utils.getUIObject('search-popup', ['scrolled-window',
- 'stack',
- 'spinner',
- 'treeview',
- 'text-column',]);
- this._stack = ui.stack;
- this._scrolledWindow = ui.scrolledWindow;
- this._spinner = ui.spinner;
- this._treeView = ui.treeview;
+ this.parent(props);
let model = new Gtk.ListStore();
model.set_column_types([GdkPixbuf.Pixbuf,
@@ -63,14 +61,10 @@ const SearchPopup = new Lang.Class({
this._treeView.connect('row-activated',
this._onRowActivated.bind(this));
- let cellHeight = ui.textColumn.cell_get_size(null)[3];
+ let cellHeight = this._textColumn.cell_get_size(null)[3];
this.height_request = cellHeight * this._numVisible;
this._scrolledWindow.set_min_content_height(this.height_request);
- this.parent(props);
-
- this.get_style_context().add_class('maps-popover');
- this.add(this._stack);
this.hide();
},
@@ -109,7 +103,6 @@ const SearchPopup = new Lang.Class({
},
vfunc_show: function() {
- this._treeView.columns_autosize();
this.parent();
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]