[gnome-weather] Add accessible names throughout the UI
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-weather] Add accessible names throughout the UI
- Date: Mon, 3 Feb 2014 16:09:58 +0000 (UTC)
commit 3fb8a21e227718ca1cc8108b8d8c3444c7384e67
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Mon Feb 3 16:51:28 2014 +0100
Add accessible names throughout the UI
Improves the accessibility and makes the application scriptable
through dogtail.
data/city.ui | 11 +++++++++++
data/window.ui | 17 ++++++++++++++++-
src/city.js | 29 ++++++++++++++++++-----------
src/forecast.js | 1 +
src/world.js | 2 ++
5 files changed, 48 insertions(+), 12 deletions(-)
---
diff --git a/data/city.ui b/data/city.ui
index 4931464..b930b6a 100644
--- a/data/city.ui
+++ b/data/city.ui
@@ -29,6 +29,11 @@
<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="conditions-image">
<property name="name">conditions-image</property>
@@ -110,6 +115,12 @@
<class name="image-button"/>
<class name="osd"/>
</style>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="reveal-button-a11y">
+ <property name="accessible-name" translatable="yes">Detailed forecast</property>
+ <property name="accessible-role">7</property><!-- check_box -->
+ </object>
+ </child>
<child>
<object class="GtkImage" id="reveal-button-image">
<property name="visible">True</property>
diff --git a/data/window.ui b/data/window.ui
index 4c41ca5..e374305 100644
--- a/data/window.ui
+++ b/data/window.ui
@@ -81,6 +81,11 @@
<style>
<class name="image-button"/>
</style>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="world-button-a11y">
+ <property name="accessible-name" translatable="yes">Back</property>
+ </object>
+ </child>
<child>
<object class="GtkImage" id="world-button-image">
<property name="visible">True</property>
@@ -103,6 +108,11 @@
<style>
<class name="image-button"/>
</style>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="select-button-a11y">
+ <property name="accessible-name" translatable="yes">Select</property>
+ </object>
+ </child>
<child>
<object class="GtkImage" id="select-button-image">
<property name="visible">True</property>
@@ -140,8 +150,13 @@
<property name="action-name">win.refresh</property>
<property name="valign">center</property>
<style>
- <class name="image-button"/>
+ <class name="image-button"/>
</style>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="refresh-button-a11y">
+ <property name="accessible-name" translatable="yes">Refresh</property>
+ </object>
+ </child>
<child>
<object class="GtkImage" id="refresh-button-image">
<property name="visible">True</property>
diff --git a/src/city.js b/src/city.js
index e890133..e98e393 100644
--- a/src/city.js
+++ b/src/city.js
@@ -16,6 +16,8 @@
// with Gnome Weather; if not, write to the Free Software Foundation,
// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+const Atk = imports.gi.Atk;
+const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
@@ -39,8 +41,6 @@ const WeatherWidget = new Lang.Class({
let builder = new Gtk.Builder();
builder.add_from_resource('/org/gnome/Weather/Application/city.ui');
- let rtl = this.get_direction() == Gtk.TextDirection.RTL;
-
let outerBox = builder.get_object('outer-box');
this._contentFrame = builder.get_object('content-frame');
let outerGrid = builder.get_object('outer-grid');
@@ -50,8 +50,6 @@ const WeatherWidget = new Lang.Class({
this._revealButton = builder.get_object('reveal-button');
this._revealer = builder.get_object('revealer');
- this._revealButton.get_child().icon_name = rtl ? 'go-previous-rtl-symbolic' : 'go-previous-symbolic';
-
this._forecasts = new Forecast.ForecastBox({ hexpand: true });
outerGrid.attach(this._forecasts, 0, 1, 1, 1);
@@ -60,18 +58,26 @@ const WeatherWidget = new Lang.Class({
this._revealer.child = this._today;
this._revealButton.connect('clicked', Lang.bind(this, function() {
- if (this._revealer.reveal_child) {
- this._revealer.reveal_child = false;
- this._revealButton.get_child().icon_name = rtl ? 'go-previous-rtl-symbolic' :
'go-previous-symbolic';
- } else {
- this._revealer.reveal_child = true;
- this._revealButton.get_child().icon_name = rtl ? 'go-next-rtl-symbolic' : 'go-next-symbolic';
- }
+ this._revealer.reveal_child = !this._revealer.reveal_child;
+ this._syncRevealButton();
}));
+ this._syncRevealButton();
this.add(outerBox);
},
+ _syncRevealButton: function() {
+ let rtl = this.get_direction() == Gtk.TextDirection.RTL;
+
+ if (this._revealer.reveal_child) {
+ this._revealButton.get_child().icon_name = rtl ? 'go-next-rtl-symbolic' : 'go-next-symbolic';
+ this._revealButton.get_accessible().ref_state_set().add_state(Atk.StateType.CHECKED);
+ } else {
+ this._revealButton.get_child().icon_name = rtl ? 'go-previous-rtl-symbolic' :
'go-previous-symbolic';
+ this._revealButton.get_accessible().ref_state_set().remove_state(Atk.StateType.CHECKED);
+ }
+ },
+
clear: function() {
this._forecasts.clear();
this._today.clear();
@@ -116,6 +122,7 @@ const WeatherView = new Lang.Class({
_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,
diff --git a/src/forecast.js b/src/forecast.js
index 7b1ff37..9aebca1 100644
--- a/src/forecast.js
+++ b/src/forecast.js
@@ -38,6 +38,7 @@ const ForecastBox = new Lang.Class({
_init: function(params) {
params = Params.fill(params, { shadow_type: Gtk.ShadowType.NONE });
this.parent(params);
+ this.get_accessible().accessible_name = _("Forecast");
this._grid = new Gtk.Grid({ orientation: Gtk.Orientation.HORIZONTAL,
column_spacing: 24,
diff --git a/src/world.js b/src/world.js
index b56305b..20c07e7 100644
--- a/src/world.js
+++ b/src/world.js
@@ -211,6 +211,7 @@ const WorldIconView = new Lang.Class({
_init: function(params) {
params = Params.fill(params, { view_type: Gd.MainViewType.ICON });
this.parent(params);
+ this.get_accessible().accessible_name = _("Cities");
this.connect('selection-mode-request', Lang.bind(this, function() {
this.selection_mode = true;
@@ -227,6 +228,7 @@ const WorldContentView = new Lang.Class({
params = Params.fill(params, { hexpand: true, vexpand: true,
halign: Gtk.Align.FILL, valign: Gtk.Align.FILL });
this.parent(params);
+ this.get_accessible().accessible_name = _("World view");
this.iconView = new WorldIconView({ model: model, visible: true });
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]