[gnome-shell/wip/paging-release2: 9/23] appDisplay: Makes key navigation works with pagination
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/paging-release2: 9/23] appDisplay: Makes key navigation works with pagination
- Date: Wed, 28 Aug 2013 15:34:55 +0000 (UTC)
commit 51b1a32bf6fd16673d4ad5b18f9c5fd41b728435
Author: Carlos Soriano <carlos soriano89 gmail com>
Date: Fri Aug 23 20:06:47 2013 +0200
appDisplay: Makes key navigation works with pagination
We have to rewrite the ensureIconVisibility function
to change pages when we reach an item inside another
page than the current
https://bugzilla.gnome.org/show_bug.cgi?id=706081
js/ui/appDisplay.js | 15 +++++++++++++--
js/ui/iconGrid.js | 19 +++++++++++++++++++
2 files changed, 32 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 7300c85..0449518 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -246,11 +246,17 @@ const AllView = new Lang.Class({
},
addApp: function(app) {
- this._addItem(app);
+ let appIcon = this._addItem(app);
+ if (appIcon)
+ appIcon.actor.connect('key-focus-in',
+ Lang.bind(this, this._ensureIconVisible));
},
addFolder: function(dir) {
- this._addItem(dir);
+ let folderIcon = this._addItem(dir);
+ if (folderIcon)
+ folderIcon.actor.connect('key-focus-in',
+ Lang.bind(this, this._ensureIconVisible));
},
addFolderPopup: function(popup) {
@@ -263,6 +269,11 @@ const AllView = new Lang.Class({
}));
},
+ _ensureIconVisible: function(icon) {
+ let itemPage = this._grid.getItemPage(icon);
+ this.goToPage(itemPage);
+ },
+
updateAdjustment: function(availHeight) {
this._verticalAdjustment.page_size = availHeight;
this._verticalAdjustment.upper = this._stack.height;
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index ce00787..494400b 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -535,5 +535,24 @@ const PaginatedIconGrid = new Lang.Class({
let firstPageItem = pageNumber * this._childrenPerPage
let childBox = this._getVisibleChildren()[firstPageItem].get_allocation_box();
return childBox.y1;
+ },
+
+ getItemPage: function(item) {
+ let found = false;
+ let children = this._getVisibleChildren();
+ pageNumber = 0;
+ let index = 0;
+ while(!found && index < children.length) {
+ if(item == children[index])
+ found = true;
+ if(index % this._childrenPerPage == 0 && index != 0)
+ pageNumber++;
+ index++;
+ }
+ if(!found) {
+ throw new Error('Invalid item position requested');
+ return 0;
+ }
+ return pageNumber;
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]