[gnome-documents/wip/split-view: 14/14] LoadMoreButton



commit 54ac256c397af8cc99d4318a59afcc4408b0b62b
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Oct 17 15:01:18 2014 +0200

    LoadMoreButton

 src/view.js |   31 ++++++++++++++++++++++++++++---
 1 files changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/src/view.js b/src/view.js
index 929ff98..03b64a7 100644
--- a/src/view.js
+++ b/src/view.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011 Red Hat, Inc.
+ * Copyright (c) 2011, 2014 Red Hat, Inc.
  *
  * Gnome Documents is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by the
@@ -37,13 +37,38 @@ const TrackerUtils = imports.trackerUtils;
 const WindowMode = imports.windowMode;
 const Utils = imports.utils;
 
+function getController(windowMode) {
+    let offsetController;
+    let trackerController;
+
+    switch (windowMode) {
+    case WindowMode.WindowMode.COLLECTIONS:
+        offsetController = Application.offsetCollectionsController;
+        trackerController = Application.trackerCollectionsController;
+        break;
+    case WindowMode.WindowMode.DOCUMENTS:
+        offsetController = Application.offsetDocumentsController;
+        trackerController = Application.trackerDocumentsController;
+        break;
+    case WindowMode.WindowMode.SEARCH:
+        offsetController = Application.offsetSearchController;
+        trackerController = Application.trackerSearchController;
+        break;
+    default:
+        throw(new Error('Not handled'));
+        break;
+    }
+
+    return [ offsetController, trackerController ];
+}
+
 const LoadMoreButton = new Lang.Class({
     Name: 'LoadMoreButton',
 
-    _init: function() {
+    _init: function(mode) {
         this._block = false;
 
-        this._controller = Application.offsetController;
+        this._controller = getController(mode)[0];
         this._controllerId =
             this._controller.connect('item-count-changed',
                                      Lang.bind(this, this._onItemCountChanged));


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