[gnome-weather/gnome-3-8] Use a .ui file for the main window



commit 324cb996d7ff764a7002476860a7a0615f00e006
Author: Paolo Borelli <pborelli gnome org>
Date:   Mon Mar 11 21:25:07 2013 +0100

    Use a .ui file for the main window
    
    As a first step use it to create the header bar.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=695457

 data/gnome-weather.gresource.xml |    1 +
 data/window.ui                   |   75 ++++++++++++++++++++++++++++++++++++++
 src/window.js                    |   28 ++++++---------
 3 files changed, 87 insertions(+), 17 deletions(-)
---
diff --git a/data/gnome-weather.gresource.xml b/data/gnome-weather.gresource.xml
index fc4ce31..1a64e59 100644
--- a/data/gnome-weather.gresource.xml
+++ b/data/gnome-weather.gresource.xml
@@ -2,6 +2,7 @@
 <gresources>
   <gresource prefix="/org/gnome/weather">
     <file preprocess="xml-stripblanks">app-menu.ui</file>
+    <file preprocess="xml-stripblanks">window.ui</file>
     <file>application.css</file>
     <file>weather-clear.jpg</file>
     <file>weather-clear-night.jpg</file>
diff --git a/data/window.ui b/data/window.ui
new file mode 100644
index 0000000..d07d5ff
--- /dev/null
+++ b/data/window.ui
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkGrid" id="main-panel">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="orientation">vertical</property>
+    <child>
+      <object class="GdHeaderBar" id="header-bar">
+        <property name="visible">True</property>
+        <property name="vexpand">False</property>
+        <child>
+          <object class="GdHeaderSimpleButton" id="new-button">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="label" translatable="yes">New</property>
+          </object>
+          <packing>
+            <property name="pack_type">start</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GdHeaderSimpleButton" id="world-button">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="label" translatable="yes">World Weather</property>
+          </object>
+          <packing>
+            <property name="pack_type">start</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GdHeaderSimpleButton" id="select-button">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="symbolic-icon-name">object-select-symbolic</property>
+          </object>
+          <packing>
+            <property name="pack_type">end</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GdHeaderSimpleButton" id="done-button">
+            <property name="visible">True</property>
+            <property name="no_show_all">True</property>
+            <property name="can_focus">True</property>
+            <property name="label" translatable="yes">Done</property>
+            <style>
+              <class name="suggested-action"/>
+            </style>
+          </object>
+          <packing>
+            <property name="pack_type">end</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GdHeaderSimpleButton" id="refresh-button">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="symbolic-icon-name">view-refresh-symbolic</property>
+          </object>
+          <packing>
+            <property name="pack_type">end</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>
+  </object>
+</interface>
diff --git a/src/window.js b/src/window.js
index 825a87b..1f8aabd 100644
--- a/src/window.js
+++ b/src/window.js
@@ -107,34 +107,28 @@ const MainWindow = new Lang.Class({
                           { name: 'about',
                             callback: this._showAbout }]);
 
-        let grid = new Gtk.Grid({ orientation: Gtk.Orientation.VERTICAL });
+        let builder = new Gtk.Builder();
+        builder.add_from_resource('/org/gnome/weather/window.ui');
 
-        this._header = new Gd.HeaderBar({ hexpand: true });
-        grid.add(this._header);
+        let grid = builder.get_object('main-panel');
+        this._header = builder.get_object('header-bar');
 
-        let newButton = new Gd.HeaderSimpleButton({ label: _("New") });
+        let newButton = builder.get_object('new-button');
         newButton.connect('clicked', Lang.bind(this, this._newLocation));
-        this._header.pack_start(newButton);
         this._pageWidgets[Page.WORLD].push(newButton);
 
-        let goWorldButton = new Gd.HeaderSimpleButton({ label: _("World Weather") });
+        let goWorldButton = builder.get_object('world-button');
         goWorldButton.connect('clicked', Lang.bind(this, this._goWorld));
-        this._header.pack_start(goWorldButton);
         this._pageWidgets[Page.CITY].push(goWorldButton);
 
-        let refresh = new Gd.HeaderSimpleButton({ symbolic_icon_name: 'view-refresh-symbolic' });
+        let select = builder.get_object('select-button');
+        this._pageWidgets[Page.WORLD].push(select);
+
+        let refresh = builder.get_object('refresh-button');
         refresh.connect('clicked', Lang.bind(this, this.update));
-        this._header.pack_end(refresh);
         this._pageWidgets[Page.CITY].push(refresh);
 
-        let select = new Gd.HeaderSimpleButton({ symbolic_icon_name: 'object-select-symbolic' });
-        this._header.pack_end(select);
-        this._pageWidgets[Page.WORLD].push(select);
-
-        let selectDone = new Gd.HeaderSimpleButton({ label: _("Done"),
-                                                     no_show_all: true });
-        selectDone.get_style_context().add_class('suggested-action');
-        this._header.pack_end(selectDone);
+        let selectDone = builder.get_object('done-button');
         this._pageWidgets[Page.WORLD].push(selectDone);
 
         this._stack = new Gd.Stack({ transition_type: Gd.StackTransitionType.CROSSFADE });


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