[gnome-weather] window: improve selection mode style



commit b6acc00f7e479c5d5fd43bb51b1ce7c4e8acbc88
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Mar 5 12:54:08 2013 -0500

    window: improve selection mode style
    
    - don't use a toggle button for selection mode
    - add/remove the style class to the header
    - add a descriptive text as title header
    - hide the New button in selection mode
    
    https://bugzilla.gnome.org/show_bug.cgi?id=695241

 libgd         |    2 +-
 src/window.js |   48 ++++++++++++++++++++++++++++++++++++++++--------
 2 files changed, 41 insertions(+), 9 deletions(-)
---
diff --git a/libgd b/libgd
index 006f5c8..33561ee 160000
--- a/libgd
+++ b/libgd
@@ -1 +1 @@
-Subproject commit 006f5c8619e98394c03e755ec1b72e2d5d908e35
+Subproject commit 33561eea68af66209af8426c9ff55cc3143f0ab5
diff --git a/src/window.js b/src/window.js
index f5efb55..5c3920e 100644
--- a/src/window.js
+++ b/src/window.js
@@ -76,10 +76,16 @@ const MainWindow = new Lang.Class({
         this._header.pack_end(refresh);
         this._pageWidgets[Page.CITY].push(refresh);
 
-        let select = new Gd.HeaderToggleButton({ symbolic_icon_name: 'object-select-symbolic' });
+        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);
+        this._pageWidgets[Page.WORLD].push(selectDone);
+
         this._stack = new Gd.Stack();
 
         this._cityView = new City.WeatherView({ hexpand: true,
@@ -89,13 +95,36 @@ const MainWindow = new Lang.Class({
         this._worldView = new Gd.MainView({ view_type: Gd.MainViewType.ICON });
         this._worldView.model = this._model;
         this._worldView.connect('item-activated', Lang.bind(this, this._itemActivated));
-        this._worldView.connect('selection-mode-request', function() {
-            select.active = true;
-        });
-        select.bind_property('active', this._worldView, 'selection-mode',
-                             GObject.BindingFlags.DEFAULT);
+        this._worldView.connect('selection-mode-request', Lang.bind(this, function() {
+            this._worldView.selection_mode = true;
+        }));
         this._stack.add(this._worldView);
 
+        select.connect('clicked', Lang.bind(this, function() {
+            this._worldView.selection_mode = true;
+        }));
+        selectDone.connect('clicked', Lang.bind(this, function() {
+            this._worldView.selection_mode = false;
+        }));
+        this._worldView.connect('notify::selection-mode', Lang.bind(this, function() {
+            let mode = this._worldView.selection_mode;
+
+            if (mode) {
+                this._header.get_style_context().add_class('selection-mode');
+                this._header.set_title(_("Click on locations to select them"));
+            } else {
+                this._header.get_style_context().remove_class('selection-mode');
+                this._header.set_title(null);
+            }
+        }));
+
+        this._worldView.bind_property('selection-mode', newButton, 'visible',
+                                      GObject.BindingFlags.INVERT_BOOLEAN);
+        this._worldView.bind_property('selection-mode', select, 'visible',
+                                      GObject.BindingFlags.INVERT_BOOLEAN);
+        this._worldView.bind_property('selection-mode', selectDone, 'visible',
+                                      GObject.BindingFlags.SYNC_CREATE);
+
         this._stack.set_visible_child(this._worldView);
         grid.add(this._stack);
 
@@ -137,8 +166,11 @@ const MainWindow = new Lang.Class({
         for (let i = 0; i < this._pageWidgets[this._currentPage].length; i++)
             this._pageWidgets[this._currentPage][i].hide();
 
-        for (let i = 0; i < this._pageWidgets[page].length; i++)
-            this._pageWidgets[page][i].show();
+        for (let i = 0; i < this._pageWidgets[page].length; i++) {
+            let widget = this._pageWidgets[page][i];
+            if (!widget.no_show_all)
+                this._pageWidgets[page][i].show();
+        }
 
         this._currentPage = page;
         this._header.title = this._getTitle();


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