[gnome-music] Fix the visibility of the back button when exiting selection mode
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] Fix the visibility of the back button when exiting selection mode
- Date: Sun, 16 Jun 2013 09:19:00 +0000 (UTC)
commit 9a882ef378b09b93aac08c507c01bf881becce26
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Sun Jun 16 03:24:16 2013 +0200
Fix the visibility of the back button when exiting selection mode
Unconditionally showing the back button on exit is wrong, it needs
to take the toolbar state into account. While we're there, let's
restructure the code more logically, and implement the selection-mode
styling.
https://bugzilla.gnome.org/show_bug.cgi?id=702378
src/toolbar.js | 42 ++++++++++++++++++++++++++++++++----------
src/view.js | 7 +++++--
src/widgets.js | 4 ++--
3 files changed, 39 insertions(+), 14 deletions(-)
---
diff --git a/src/toolbar.js b/src/toolbar.js
index 40a14bb..e8c0f70 100644
--- a/src/toolbar.js
+++ b/src/toolbar.js
@@ -37,7 +37,8 @@ const ToolbarState = {
ALBUMS: 1,
ARTISTS: 2,
PLAYLISTS: 3,
- SONGS: 4};
+ SONGS: 4,
+};
const Toolbar = new Lang.Class({
Name: 'MainToolbar',
@@ -60,17 +61,38 @@ const Toolbar = new Lang.Class({
return this._stack_switcher.get_stack();
},
- setState: function (state) {
- if (state == ToolbarState.SINGLE) {
- this.custom_title = null
- this._backButton.show()
- }
- else {
- this.title = ""
+ setSelectionMode: function(selectionMode) {
+ this._selectionMode = selectionMode;
+
+ if (selectionMode)
+ this.get_style_context().add_class('selection-mode');
+ else
+ this.get_style_context().remove_class('selection-mode');
+
+ this._update();
+ },
+
+ setState: function(state) {
+ this._state = state;
+ this._update();
+
+ this.emit('state-changed');
+ },
+
+ _update: function() {
+ if (this._state == ToolbarState.SINGLE ||
+ this._selectionMode) {
+ this.custom_title = null;
+ } else {
+ this.title = "";
this.custom_title = this._stack_switcher;
- this._backButton.hide()
}
- this.emit ("state-changed")
+
+ if (this._state == ToolbarState.SINGLE &&
+ !this._selectionMode)
+ this._backButton.show();
+ else
+ this._backButton.hide();
},
_addBackButton: function() {
diff --git a/src/view.js b/src/view.js
index aac99f5..ee4a21d 100644
--- a/src/view.js
+++ b/src/view.js
@@ -107,10 +107,13 @@ const ViewContainer = new Lang.Class({
this._cursor = null;
this.header_bar = header_bar;
this.header_bar._selectButton.connect('toggled',Lang.bind(this,function (button) {
- if(button.get_active())
+ if (button.get_active()) {
this.view.set_selection_mode(true);
- else
+ this.header_bar.setSelectionMode(true);
+ } else {
this.view.set_selection_mode(false);
+ this.header_bar.setSelectionMode(false);
+ }
}));
this.title = title;
this.add(this._grid)
diff --git a/src/widgets.js b/src/widgets.js
index 9039487..5c3b2ba 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -269,10 +269,10 @@ const AlbumWidget = new Lang.Class({
header_bar._selectButton.connect('toggled',Lang.bind(this,function (button) {
if(button.get_active()){
this.view.set_selection_mode(true);
- header_bar._backButton.hide()
+ header_bar.setSelectionMode(true);
}else{
this.view.set_selection_mode(false);
- header_bar._backButton.show();
+ header_bar.setSelectionMode(false);
}
}));
this.view.set_model(this.model);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]