[gnome-maps/wip/mattiasb/templates: 1/5] LayersPopover: Use templates



commit 7dfa40d7e90cdb2996b6787590c8794264003013
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Wed Mar 11 12:05:39 2015 +0100

    LayersPopover: Use templates

 data/ui/layers-popover.ui |   97 +++++++++++++++++++++++++--------------------
 src/layersPopover.js      |   18 +++------
 2 files changed, 60 insertions(+), 55 deletions(-)
---
diff --git a/data/ui/layers-popover.ui b/data/ui/layers-popover.ui
index c90f241..f20d0bf 100644
--- a/data/ui/layers-popover.ui
+++ b/data/ui/layers-popover.ui
@@ -1,59 +1,70 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.10 -->
-  <object class="GtkGrid" id="grid">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="halign">center</property>
-    <property name="valign">center</property>
-    <property name="row_spacing">5</property>
+  <template class="Gjs_LayersPopover" parent="GtkPopover">
+    <property name="width_request">200</property>
+    <property name="no_show_all">true</property>
+    <property name="transitions_enabled">false</property>
+    <property name="visible">false</property>
+    <style>
+      <class name="maps-popover"/>
+    </style>
     <child>
-      <object class="GtkRadioButton" id="street-layer-button">
+      <object class="GtkGrid" id="grid">
         <property name="visible">True</property>
-        <property name="can-focus">True</property>
-        <property name="action-name">win.map-type</property>
-        <property name="action-target">"STREET"</property>
-        <property name="draw-indicator">False</property>
-        <style>
-          <class name="layer-radio-button"/>
-        </style>
+        <property name="can_focus">False</property>
+        <property name="halign">center</property>
+        <property name="valign">center</property>
+        <property name="row_spacing">5</property>
         <child>
-          <object class="GtkImage" id="street-layer-image">
+          <object class="GtkRadioButton" id="streetLayerButton">
             <property name="visible">True</property>
-            <property name="pixbuf">maptype-street.png</property>
+            <property name="can-focus">True</property>
+            <property name="action-name">win.map-type</property>
+            <property name="action-target">"STREET"</property>
+            <property name="draw-indicator">False</property>
+            <style>
+              <class name="layer-radio-button"/>
+            </style>
+            <child>
+              <object class="GtkImage" id="street-layer-image">
+                <property name="visible">True</property>
+                <property name="resource">/org/gnome/Maps/ui/maptype-street.png</property>
+              </object>
+            </child>
           </object>
+          <packing>
+            <property name="left-attach">0</property>
+            <property name="top-attach">0</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
         </child>
-      </object>
-      <packing>
-        <property name="left-attach">0</property>
-        <property name="top-attach">0</property>
-        <property name="width">1</property>
-        <property name="height">1</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkRadioButton" id="aerial-layer-button">
-        <property name="visible">True</property>
-        <property name="can-focus">True</property>
-        <property name="action-name">win.map-type</property>
-        <property name="action-target">"AERIAL"</property>
-        <property name="draw-indicator">False</property>
-        <style>
-          <class name="layer-radio-button"/>
-        </style>
         <child>
-          <object class="GtkImage" id="aerial-layer-image">
+          <object class="GtkRadioButton" id="aerialLayerButton">
             <property name="visible">True</property>
-            <property name="pixbuf">maptype-aerial.png</property>
+            <property name="can-focus">True</property>
+            <property name="action-name">win.map-type</property>
+            <property name="action-target">"AERIAL"</property>
+            <property name="draw-indicator">False</property>
+            <style>
+              <class name="layer-radio-button"/>
+            </style>
+            <child>
+              <object class="GtkImage" id="aerial-layer-image">
+                <property name="visible">True</property>
+                <property name="resource">/org/gnome/Maps/ui/maptype-aerial.png</property>
+              </object>
+            </child>
           </object>
+          <packing>
+            <property name="left-attach">0</property>
+            <property name="top-attach">1</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
         </child>
       </object>
-      <packing>
-        <property name="left-attach">0</property>
-        <property name="top-attach">1</property>
-        <property name="width">1</property>
-        <property name="height">1</property>
-      </packing>
     </child>
-  </object>
+  </template>
 </interface>
diff --git a/src/layersPopover.js b/src/layersPopover.js
index 4d71d08..5544358 100644
--- a/src/layersPopover.js
+++ b/src/layersPopover.js
@@ -16,6 +16,7 @@
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
  * Author: Dario Di Nucci <linkin88mail gmail com>
+ *         Mattias Bengtsson <mattias jc bengtsson gmail com>
  */
 
 const Gtk = imports.gi.Gtk;
@@ -26,20 +27,13 @@ const Utils = imports.utils;
 const LayersPopover = new Lang.Class({
     Name: 'LayersPopover',
     Extends: Gtk.Popover,
+    Template: 'resource:///org/gnome/Maps/ui/layers-popover.ui',
+    InternalChildren: [ 'streetLayerButton',
+                        'aerialLayerButton' ],
 
     _init: function() {
-        let ui = Utils.getUIObject('layers-popover', [ 'grid',
-                                                       'street-layer-button',
-                                                       'aerial-layer-button' ]);
+        this.parent();
 
-        this.parent({ width_request: 200,
-                      no_show_all: true,
-                      transitions_enabled: false,
-                      visible: false });
-
-        ui.aerialLayerButton.join_group(ui.streetLayerButton);
-
-        this.get_style_context().add_class('maps-popover');
-        this.add(ui.grid);
+        this._aerialLayerButton.join_group(this._streetLayerButton);
     }
 });


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