[gnome-weather] Use an .ui file for the city view
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-weather] Use an .ui file for the city view
- Date: Tue, 2 Apr 2013 16:59:31 +0000 (UTC)
commit bf1e29cfb41ad4b92103b91b4a480957021aca5e
Author: Paolo Borelli <pborelli gnome org>
Date: Sun Mar 31 18:39:31 2013 +0200
Use an .ui file for the city view
https://bugzilla.gnome.org/show_bug.cgi?id=696982
data/application.css | 6 +-
data/city.ui | 135 ++++++++++++++++++++++++++++++++++++++
data/gnome-weather.gresource.xml | 1 +
po/POTFILES.in | 1 +
src/city.js | 57 +++-------------
5 files changed, 152 insertions(+), 48 deletions(-)
---
diff --git a/data/application.css b/data/application.css
index 1a17a2a..80fcfe9 100644
--- a/data/application.css
+++ b/data/application.css
@@ -63,10 +63,12 @@
#temperature-label {
font-size: 4em;
}
-#condition-label {
+
+#conditions-label {
font-size: 2.5em;
padding-bottom: 12px; /* keep in sync with conditions-image */
}
+
#attribution-label {
font-size: small;
}
@@ -81,4 +83,4 @@
.content-view.cell {
font-weight: bold;
-}
\ No newline at end of file
+}
diff --git a/data/city.ui b/data/city.ui
new file mode 100644
index 0000000..20698a0
--- /dev/null
+++ b/data/city.ui
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkBox" id="outer-box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkFrame" id="content-frame">
+ <property name="name">weather-page-content-view</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkGrid" id="outer-grid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkGrid" id="alignment">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <child>
+ <object class="GtkGrid" id="inner-grid">
+ <property name="name">conditions-grid</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="column_spacing">20</property>
+ <child>
+ <object class="GtkImage" id="conditions-image">
+ <property name="name">conditions-image</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="pixel_size">172</property>
+ <property name="icon-size">2</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="temperature-label">
+ <property name="name">temperature-label</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">end</property>
+ <property name="vexpand">True</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="conditions-label">
+ <property name="name">conditions-label</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">end</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</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">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="GdHeaderSimpleButton" id="reveal-button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="margin_right">20</property>
+ <property name="symbolic_icon_name">go-previous-symbolic</property>
+ <style>
+ <class name="osd"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GdRevealer" id="revealer">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="reveal-child">false</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+</interface>
diff --git a/data/gnome-weather.gresource.xml b/data/gnome-weather.gresource.xml
index d080d36..4fdc02b 100644
--- a/data/gnome-weather.gresource.xml
+++ b/data/gnome-weather.gresource.xml
@@ -4,6 +4,7 @@
<file preprocess="xml-stripblanks">app-menu.ui</file>
<file preprocess="xml-stripblanks">window.ui</file>
<file preprocess="xml-stripblanks">new-location-dialog.ui</file>
+ <file preprocess="xml-stripblanks">city.ui</file>
<file preprocess="xml-stripblanks">preferences.ui</file>
<file>application.css</file>
<file>weather-clear.jpg</file>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1c111c0..4afac78 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,6 +2,7 @@
data/gnome-weather.desktop.in
[type: gettext/glade]data/new-location-dialog.ui
data/org.gnome.Weather.Application.gschema.xml
+[type: gettext/glade]data/city.ui
[type: gettext/glade]data/preferences.ui
[type: gettext/glade]data/window.ui
src/city.js
diff --git a/src/city.js b/src/city.js
index 467bc5f..5a2d442 100644
--- a/src/city.js
+++ b/src/city.js
@@ -30,61 +30,26 @@ const WeatherWidget = new Lang.Class({
name: 'weather-page' });
this.parent(params);
- let outerBox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL });
-
this._currentStyle = null;
- this._contentFrame = new Gtk.Frame({ shadow_type: Gtk.ShadowType.NONE,
- name: 'weather-page-content-view' });
- outerBox.add(this._contentFrame);
-
- let outerGrid = new Gtk.Grid();
- this._contentFrame.add(outerGrid);
-
- let alignment = new Gtk.Grid({ hexpand: true, vexpand: true,
- halign: Gtk.Align.CENTER,
- valign: Gtk.Align.CENTER });
-
- let innerGrid = new Gtk.Grid({ name: 'conditions-grid',
- column_spacing: 20,
- hexpand: false,
- vexpand: false });
- this._icon = new Gtk.Image({ pixel_size: 172,
- use_fallback: true,
- name: 'conditions-image' });
- innerGrid.attach(this._icon, 0, 0, 1, 2);
-
- this._temperature = new Gtk.Label({ xalign: 0.0,
- name: 'temperature-label',
- vexpand: true,
- valign: Gtk.Align.END });
- innerGrid.attach(this._temperature, 1, 0, 1, 1);
-
- this._conditions = new Gtk.Label({ xalign: 0.0,
- name: 'condition-label',
- valign: Gtk.Align.END });
- innerGrid.attach(this._conditions, 1, 1, 1, 1);
-
- alignment.add(innerGrid);
- outerGrid.attach(alignment, 0, 0, 1, 1);
- this._forecasts = new Forecast.ForecastBox({ hexpand: true });
- outerGrid.attach(this._forecasts, 0, 1, 2, 1);
+ let builder = new Gtk.Builder();
+ builder.add_from_resource('/org/gnome/weather/city.ui');
- this._revealButton = new Gd.HeaderSimpleButton({ symbolic_icon_name: 'go-previous-symbolic',
- margin_right: 20,
- halign: Gtk.Align.CENTER,
- valign: Gtk.Align.CENTER });
- let context = this._revealButton.get_style_context();
- context.add_class('osd');
+ let outerBox = builder.get_object('outer-box');
+ this._contentFrame = builder.get_object('content-frame');
+ let outerGrid = builder.get_object('outer-grid');
+ this._icon = builder.get_object('conditions-image');
+ this._temperature = builder.get_object('temperature-label');
+ this._conditions = builder.get_object('conditions-label');
+ this._revealButton = builder.get_object('reveal-button');
+ this._revealer = builder.get_object('revealer');
- outerGrid.attach(this._revealButton, 1, 0, 1, 2);
+ this._forecasts = new Forecast.ForecastBox({ hexpand: true });
+ outerGrid.attach(this._forecasts, 0, 1, 2, 1);
this._today = new Forecast.TodaySidebar({ vexpand: true,
name: 'today-sidebar' });
- this._revealer = new Gd.Revealer({ child: this._today,
- reveal_child: false,
- orientation: Gtk.Orientation.VERTICAL });
- outerBox.add(this._revealer);
+ this._revealer.child = this._today;
this._revealButton.connect('clicked', Lang.bind(this, function() {
if (this._revealer.reveal_child) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]