[gnome-shell/wip/fmuellner/weather-clocks-refresh: 2/3] dateMenu: Show weather location in section header



commit f1077d5aecd4786caa45fd83f0325a052ec45beb
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Jan 11 17:42:22 2019 +0100

    dateMenu: Show weather location in section header
    
    It is useful information, in particular when the location is set
    automatically via geoclue.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/issues/262

 data/theme/gnome-shell-sass/_common.scss |  5 +++++
 js/ui/dateMenu.js                        | 20 ++++++++++++++++----
 2 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/data/theme/gnome-shell-sass/_common.scss b/data/theme/gnome-shell-sass/_common.scss
index 1d5b12486..4d5da090c 100644
--- a/data/theme/gnome-shell-sass/_common.scss
+++ b/data/theme/gnome-shell-sass/_common.scss
@@ -922,6 +922,11 @@ StScrollBar {
       font-weight: bold;
     }
 
+    .weather-header.location {
+      font-weight: normal;
+      font-size: 0.9em;
+    }
+
     .world-clocks-grid,
     .weather-grid {
       spacing-rows: 0.4em;
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index 9f0ffe4c0..dd73310af 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -226,9 +226,17 @@ var WeatherSection = new Lang.Class({
 
         this.actor.child = box;
 
-        box.add_child(new St.Label({ style_class: 'weather-header',
-                                     x_align: Clutter.ActorAlign.START,
-                                     text: _("Weather") }));
+        let titleBox = new St.BoxLayout();
+        box.add_actor(titleBox);
+
+        titleBox.add_actor(new St.Label({ style_class: 'weather-header',
+                                          x_align: Clutter.ActorAlign.START,
+                                          x_expand: true,
+                                          text: _("Weather") }));
+
+        this._titleLocation = new St.Label({ style_class: 'weather-header location',
+                                             x_align: Clutter.ActorAlign.END });
+        titleBox.add_actor(this._titleLocation);
 
         let layout = new Clutter.GridLayout({ orientation: Clutter.Orientation.VERTICAL });
         this._forecastGrid = new St.Widget({ style_class: 'weather-grid',
@@ -310,12 +318,14 @@ var WeatherSection = new Lang.Class({
             return;
         }
 
+        let info = this._weatherClient.info;
+        this._titleLocation.text = info.get_location().get_name();
+
         if (this._weatherClient.loading) {
             this._addStatusLabel(_("Loading…"));
             return;
         }
 
-        let info = this._weatherClient.info;
         if (info.is_valid()) {
             this._addForecasts();
             return;
@@ -329,6 +339,8 @@ var WeatherSection = new Lang.Class({
 
     _sync() {
         this.actor.visible = this._weatherClient.available;
+        this._titleLocation.visible = this._weatherClient.available &&
+                                      this._weatherClient.hasLocation;
 
         if (!this.actor.visible)
             return;


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