[gnome-shell/wip/paging-release2: 8/20] appDisplay: Makes key navigation works with pagination



commit 157cf95a2284e239c5d4a6e85707ce2b1e3bff50
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

 js/ui/appDisplay.js |   15 +++++++++++++--
 js/ui/iconGrid.js   |   15 +++++++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 2bfdb2d..c769b73 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -261,11 +261,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) {
@@ -278,6 +284,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 186321b..70cace4 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -538,6 +538,21 @@ 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++;
+        }
+        return pageNumber;
     }
 });
 Signals.addSignalMethods(PaginatedIconGrid.prototype);


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