[gnome-documents] view: ensure selection is remembered across view mode switches
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] view: ensure selection is remembered across view mode switches
- Date: Thu, 25 Aug 2011 14:25:58 +0000 (UTC)
commit eefb2c16b8acc137c48e238e3bf0fc182c8a8693
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Thu Aug 25 10:24:42 2011 -0400
view: ensure selection is remembered across view mode switches
src/iconView.js | 9 +++++++--
src/listView.js | 13 ++++++++-----
src/view.js | 4 +++-
3 files changed, 18 insertions(+), 8 deletions(-)
---
diff --git a/src/iconView.js b/src/iconView.js
index 110a9e4..2851148 100644
--- a/src/iconView.js
+++ b/src/iconView.js
@@ -53,9 +53,14 @@ IconView.prototype = {
this.widget.show();
+ // chain up to the parent
View.View.prototype._init.call(this);
- this.widget.connect('selection-changed',
- Lang.bind(this, this.onSelectionChanged));
+
+ // now listen to selection changes
+ },
+
+ connectToSelectionChanged: function(callback) {
+ this.getSelectionObject().connect('selection-changed', callback);
},
getSelection: function() {
diff --git a/src/listView.js b/src/listView.js
index d6d76fe..0fc9e58 100644
--- a/src/listView.js
+++ b/src/listView.js
@@ -44,18 +44,21 @@ ListView.prototype = {
this.widget.show();
- View.View.prototype._init.call(this);
-
let selection = this.widget.get_selection();
selection.set_mode(Gtk.SelectionMode.MULTIPLE);
- selection.connect('changed',
- Lang.bind(this, this.onSelectionChanged));
+
+ // chain up to the parent
+ View.View.prototype._init.call(this);
},
_onItemActivated: function(view, path, column) {
this.activateItem(path);
},
+ connectToSelectionChanged: function(callback) {
+ this.getSelectionObject().connect('changed', callback);
+ },
+
getSelectionObject: function() {
return this.widget.get_selection();
},
@@ -89,4 +92,4 @@ ListView.prototype = {
col.add_attribute(textRenderer,
'line-two', TrackerModel.ModelColumns.AUTHOR);
}
-}
\ No newline at end of file
+};
diff --git a/src/view.js b/src/view.js
index 3bf752b..d3a3e74 100644
--- a/src/view.js
+++ b/src/view.js
@@ -52,6 +52,8 @@ View.prototype = {
Lang.bind(this, this._updateSelection));
this._updateSelection();
+
+ this.connectToSelectionChanged(Lang.bind(this, this._onSelectionChanged));
},
_updateSelection: function() {
@@ -78,7 +80,7 @@ View.prototype = {
}));
},
- onSelectionChanged: function() {
+ _onSelectionChanged: function() {
let selectedURNs = Utils.getURNsFromPaths(this.getSelection(),
this._treeModel);
Global.selectionController.setSelection(selectedURNs);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]