[gnome-maps/wip/mattiasb/templates: 2/5] ZoomControl: Use Templates
- From: Mattias Bengtsson <mattiasb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mattiasb/templates: 2/5] ZoomControl: Use Templates
- Date: Thu, 12 Mar 2015 22:12:58 +0000 (UTC)
commit 4e5a0b59332be90c1c973219aa2da6811cf4fde4
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date: Thu Mar 12 18:39:56 2015 +0100
ZoomControl: Use Templates
data/ui/zoom-control.ui | 79 ++++++++++++++++++++++++++---------------------
src/zoomControl.js | 15 ++------
2 files changed, 48 insertions(+), 46 deletions(-)
---
diff --git a/data/ui/zoom-control.ui b/data/ui/zoom-control.ui
index c8f46c4..4c3da7c 100644
--- a/data/ui/zoom-control.ui
+++ b/data/ui/zoom-control.ui
@@ -1,54 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.10 -->
- <object class= "GtkBox" id="zoom-control">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <style>
- <class name="linked" />
- </style>
+ <template class="Gjs_ZoomControl" parent="GtkBin">
+ <property name="halign">start</property>
+ <property name="valign">start</property>
+ <property name="margin_top">6</property>
+ <property name="margin_start">6</property>
+ <property name="visible">true</property>
<child>
- <object class="GtkButton" id="zoom-in-button">
- <property name="name">zoom-in-button</property>
+ <object class= "GtkBox" id="zoomControl">
<property name="visible">True</property>
- <property name="width-request">34</property>
- <property name="height-request">34</property>
<property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <style>
+ <class name="linked" />
+ </style>
<child>
- <object class="GtkLabel" id="zoom-in-label">
- <attributes>
- <attribute name="weight" value="bold" />
- <attribute name="scale" value="1.2" />
- </attributes>
+ <object class="GtkButton" id="zoomInButton">
+ <property name="name">zoom-in-button</property>
<property name="visible">True</property>
+ <property name="width-request">34</property>
+ <property name="height-request">34</property>
<property name="can_focus">False</property>
- <property name="margin">0</property>
- <property name="label">+</property>
+ <child>
+ <object class="GtkLabel" id="zoom-in-label">
+ <attributes>
+ <attribute name="weight" value="bold" />
+ <attribute name="scale" value="1.2" />
+ </attributes>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin">0</property>
+ <property name="label">+</property>
+ </object>
+ </child>
</object>
</child>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="zoom-out-button">
- <property name="name">zoom-out-button</property>
- <property name="visible">True</property>
- <property name="width-request">34</property>
- <property name="height-request">34</property>
- <property name="can_focus">False</property>
<child>
- <object class="GtkLabel" id="zoom-out-label">
- <attributes>
- <attribute name="weight" value="bold" />
- <attribute name="scale" value="1.2" />
- </attributes>
+ <object class="GtkButton" id="zoomOutButton">
+ <property name="name">zoom-out-button</property>
<property name="visible">True</property>
+ <property name="width-request">34</property>
+ <property name="height-request">34</property>
<property name="can_focus">False</property>
- <property name="margin">0</property>
- <property name="label">−</property>
+ <child>
+ <object class="GtkLabel" id="zoom-out-label">
+ <attributes>
+ <attribute name="weight" value="bold" />
+ <attribute name="scale" value="1.2" />
+ </attributes>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin">0</property>
+ <property name="label">−</property>
+ </object>
+ </child>
</object>
</child>
</object>
</child>
- </object>
+ </template>
</interface>
diff --git a/src/zoomControl.js b/src/zoomControl.js
index 0f98121..985a665 100644
--- a/src/zoomControl.js
+++ b/src/zoomControl.js
@@ -27,19 +27,13 @@ const Utils = imports.utils;
const ZoomControl = new Lang.Class({
Name: 'ZoomControl',
Extends: Gtk.Bin,
+ Template: 'resource:///org/gnome/Maps/ui/zoom-control.ui',
+ InternalChildren: [ 'zoomInButton',
+ 'zoomOutButton' ],
_init: function (mapView) {
- this.parent({ halign: Gtk.Align.START,
- valign: Gtk.Align.START,
- margin_top: 6,
- margin_start: 6,
- visible: true });
+ this.parent();
- let ui = Utils.getUIObject('zoom-control', ['zoom-control',
- 'zoom-in-button',
- 'zoom-out-button']);
- this._zoomInButton = ui.zoomInButton;
- this._zoomOutButton = ui.zoomOutButton;
this._view = mapView.view;
this._zoomInButton.connect('clicked',
@@ -53,7 +47,6 @@ const ZoomControl = new Lang.Class({
this._updateSensitive.bind(this));
this._view.connect('notify::min-zoom-level',
this._updateSensitive.bind(this));
- this.add(ui.zoomControl);
},
_updateSensitive: function () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]