[gnome-weather] Switch more widgets to templates
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-weather] Switch more widgets to templates
- Date: Sat, 7 Mar 2015 04:40:56 +0000 (UTC)
commit c472112e2eab0e119321c2e09336f7ab4f295b6a
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Fri Mar 6 20:36:41 2015 -0800
Switch more widgets to templates
So much better
data/city.ui | 307 ++------------------
...rg.gnome.Weather.Application.data.gresource.xml | 3 +-
data/weather-widget.ui | 300 +++++++++++++++++++
src/app/city.js | 16 +-
4 files changed, 328 insertions(+), 298 deletions(-)
---
diff --git a/data/city.ui b/data/city.ui
index 88b6598..f9d25b0 100644
--- a/data/city.ui
+++ b/data/city.ui
@@ -2,299 +2,38 @@
<!-- Generated with glade 3.16.1 -->
<interface>
<requires lib="gtk+" version="3.0"/>
- <template class="Gjs_WeatherWidget" parent="GtkFrame">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
+ <template class="Gjs_WeatherView" parent="GtkStack">
+ <child internal-child="accessible">
+ <object class="AtkObject" id="weather-view-accessible">
+ <property name="accessible-name" translatable="yes">City view</property>
+ </object>
+ </child>
<child>
- <object class="GtkFrame" id="contentFrame">
- <property name="name">weather-page-content-view</property>
+ <object class="GtkGrid" id="loading-grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
+ <property name="orientation">vertical</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
<child>
- <object class="GtkGrid" id="outerGrid">
+ <object class="GtkSpinner" id="spinner">
<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">start</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="margin-top">50</property>
- <property name="margin-start">50</property>
- <property name="margin-end">20</property>
- <property name="row_spacing">32</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 internal-child="accessible">
- <object class="AtkObject" id="conditions-grid-a11y">
- <property name="accessible-name" translatable="yes">Current conditions</property>
- </object>
- </child>
- <child>
- <object class="GtkImage" id="conditionsImage">
- <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="temperatureLabel">
- <property name="name">temperature-label</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="valign">start</property>
- <property name="halign">start</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="conditionsLabel">
- <property name="name">conditions-label</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="valign">start</property>
- <property name="vexpand">True</property>
- <property name="halign">start</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>
- </packing>
- </child>
- <child>
- <object class="GtkGrid" id="stack-grid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkStackSwitcher" id="day-stack-switcher">
- <property name="visible">True</property>
- <property name="stack">forecastStack</property>
- <style>
- <class name="osd"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkGrid" id="forecast-parent-grid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkStack" id="forecastStack">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <child>
- <object class="GtkScrolledWindow" id="forecast-today">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="vscrollbar_policy">never</property>
- <property name="min_content_width">332</property>
- <property name="margin-start">32</property>
- <property name="margin-end">32</property>
- <child>
- <object class="GtkViewport" id="forecast-today-viewport">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hscroll_policy">natural</property>
- <property name="vscroll_policy">natural</property>
- <child>
- <object class="GtkGrid" id="forecast-today-grid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="name">today</property>
- <property name="title" translatable="yes">Today</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="forecast-tomorrow">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="vscrollbar_policy">never</property>
- <property name="min_content_width">332</property>
- <property name="margin-start">32</property>
- <property name="margin-end">32</property>
- <child>
- <object class="GtkViewport" id="forecast-tomorrow-viewport">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hscroll_policy">natural</property>
- <property name="vscroll_policy">natural</property>
- <child>
- <object class="GtkGrid" id="forecast-tomorrow-grid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="name">tomorrow</property>
- <property name="title" translatable="yes">Tomorrow</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="leftButton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="valign">center</property>
- <style>
- <class name="osd"/>
- </style>
- <child>
- <object class="GtkImage" id="left-image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon-name">go-previous-symbolic</property>
- <property name="icon_size">1</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="rightButton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="valign">center</property>
- <style>
- <class name="osd"/>
- </style>
- <child>
- <object class="GtkImage" id="right-image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon-name">go-next-symbolic</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">2</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>
- <child>
- <object class="GtkGrid" id="timeGrid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">end</property>
- <property name="margin-end">20</property>
- <child>
- <object class="GtkImage" id="clock-image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="margin-start">10</property>
- <property name="margin-end">10</property>
- <property name="margin-top">15</property>
- <property name="margin-bottom">15</property>
- <property name="icon_name">document-open-recent-symbolic</property>
- </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="GtkLabel" id="timeLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin-top">15</property>
- <property name="margin-bottom">15</property>
- <property name="label">label</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>
- </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>
+ <property name="height_request">128</property>
+ <property name="width_request">128</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Loading…</property>
</object>
</child>
</object>
+ <packing>
+ <property name="name">loading</property>
+ </packing>
</child>
</template>
</interface>
diff --git a/data/org.gnome.Weather.Application.data.gresource.xml
b/data/org.gnome.Weather.Application.data.gresource.xml
index 22d1ea4..c83a910 100644
--- a/data/org.gnome.Weather.Application.data.gresource.xml
+++ b/data/org.gnome.Weather.Application.data.gresource.xml
@@ -2,9 +2,10 @@
<gresources>
<gresource prefix="/org/gnome/Weather/Application">
<file preprocess="xml-stripblanks">app-menu.ui</file>
- <file preprocess="xml-stripblanks">window.ui</file>
<file preprocess="xml-stripblanks">city.ui</file>
<file preprocess="xml-stripblanks">places-popover.ui</file>
+ <file preprocess="xml-stripblanks">weather-widget.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/weather-widget.ui b/data/weather-widget.ui
new file mode 100644
index 0000000..88b6598
--- /dev/null
+++ b/data/weather-widget.ui
@@ -0,0 +1,300 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.16.1 -->
+<interface>
+ <requires lib="gtk+" version="3.0"/>
+ <template class="Gjs_WeatherWidget" parent="GtkFrame">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkFrame" id="contentFrame">
+ <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="outerGrid">
+ <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">start</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="margin-top">50</property>
+ <property name="margin-start">50</property>
+ <property name="margin-end">20</property>
+ <property name="row_spacing">32</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 internal-child="accessible">
+ <object class="AtkObject" id="conditions-grid-a11y">
+ <property name="accessible-name" translatable="yes">Current conditions</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage" id="conditionsImage">
+ <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="temperatureLabel">
+ <property name="name">temperature-label</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
+ <property name="halign">start</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="conditionsLabel">
+ <property name="name">conditions-label</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
+ <property name="vexpand">True</property>
+ <property name="halign">start</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>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="stack-grid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkStackSwitcher" id="day-stack-switcher">
+ <property name="visible">True</property>
+ <property name="stack">forecastStack</property>
+ <style>
+ <class name="osd"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="forecast-parent-grid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkStack" id="forecastStack">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <child>
+ <object class="GtkScrolledWindow" id="forecast-today">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="vscrollbar_policy">never</property>
+ <property name="min_content_width">332</property>
+ <property name="margin-start">32</property>
+ <property name="margin-end">32</property>
+ <child>
+ <object class="GtkViewport" id="forecast-today-viewport">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hscroll_policy">natural</property>
+ <property name="vscroll_policy">natural</property>
+ <child>
+ <object class="GtkGrid" id="forecast-today-grid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="name">today</property>
+ <property name="title" translatable="yes">Today</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="forecast-tomorrow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="vscrollbar_policy">never</property>
+ <property name="min_content_width">332</property>
+ <property name="margin-start">32</property>
+ <property name="margin-end">32</property>
+ <child>
+ <object class="GtkViewport" id="forecast-tomorrow-viewport">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hscroll_policy">natural</property>
+ <property name="vscroll_policy">natural</property>
+ <child>
+ <object class="GtkGrid" id="forecast-tomorrow-grid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="name">tomorrow</property>
+ <property name="title" translatable="yes">Tomorrow</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="leftButton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="valign">center</property>
+ <style>
+ <class name="osd"/>
+ </style>
+ <child>
+ <object class="GtkImage" id="left-image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon-name">go-previous-symbolic</property>
+ <property name="icon_size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="rightButton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="valign">center</property>
+ <style>
+ <class name="osd"/>
+ </style>
+ <child>
+ <object class="GtkImage" id="right-image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon-name">go-next-symbolic</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</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>
+ <child>
+ <object class="GtkGrid" id="timeGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="margin-end">20</property>
+ <child>
+ <object class="GtkImage" id="clock-image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="margin-start">10</property>
+ <property name="margin-end">10</property>
+ <property name="margin-top">15</property>
+ <property name="margin-bottom">15</property>
+ <property name="icon_name">document-open-recent-symbolic</property>
+ </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="GtkLabel" id="timeLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin-top">15</property>
+ <property name="margin-bottom">15</property>
+ <property name="label">label</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>
+ </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>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/app/city.js b/src/app/city.js
index d8c11c2..d803b69 100644
--- a/src/app/city.js
+++ b/src/app/city.js
@@ -33,7 +33,7 @@ const SCROLLING_ANIMATION_TIME = 400000; //us
const WeatherWidget = new Lang.Class({
Name: 'WeatherWidget',
Extends: Gtk.Frame,
- Template: 'resource:///org/gnome/Weather/Application/city.ui',
+ Template: 'resource:///org/gnome/Weather/Application/weather-widget.ui',
InternalChildren: ['contentFrame', 'outerGrid', 'conditionsImage',
'temperatureLabel', 'conditionsLabel',
'timeLabel', 'timeGrid', 'forecastStack',
@@ -201,21 +201,11 @@ const WeatherWidget = new Lang.Class({
const WeatherView = new Lang.Class({
Name: 'WeatherView',
Extends: Gtk.Stack,
+ Template: 'resource:///org/gnome/Weather/Application/city.ui',
+ InternalChildren: ['spinner'],
_init: function(params) {
this.parent(params);
- this.get_accessible().accessible_name = _("City view");
-
- let loadingPage = new Gtk.Grid({ orientation: Gtk.Orientation.VERTICAL,
- halign: Gtk.Align.CENTER,
- valign: Gtk.Align.CENTER });
-
- this._spinner = new Gtk.Spinner({ height_request: SPINNER_SIZE,
- width_request: SPINNER_SIZE });
- loadingPage.add(this._spinner);
- loadingPage.add(new Gtk.Label({ label: _("Loading…"),
- name: "loading-label" }));
- this.add_named(loadingPage, 'loading');
this._infoPage = new WeatherWidget();
this.add_named(this._infoPage, 'info');
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]