[the-board] [ui] Use action to add things to page instead of MainWindow API



commit 34c829823b1fb269160f413d7775947de60e6394
Author: Lucas Rocha <lucasr gnome org>
Date:   Tue Feb 8 00:03:41 2011 +0000

    [ui] Use action to add things to page instead of MainWindow API
    
    This is more consistent with the rest of the toolbars.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=637710

 src/js/ui/mainToolbar.js   |    4 +---
 src/js/ui/mainWindow.js    |    2 ++
 src/js/ui/toolBoxThings.js |   10 +++-------
 3 files changed, 6 insertions(+), 10 deletions(-)
---
diff --git a/src/js/ui/mainToolbar.js b/src/js/ui/mainToolbar.js
index 31ca38f..ea47f70 100644
--- a/src/js/ui/mainToolbar.js
+++ b/src/js/ui/mainToolbar.js
@@ -33,10 +33,8 @@ MainToolbar.prototype = {
     },
 
     _createToolBoxThings : function() {
-        let mainWindow = this._context.mainWindow;
-
         this._toolBoxThings =
-            new ToolBoxThings.ToolBoxThings({ mainWindow: mainWindow });
+            new ToolBoxThings.ToolBoxThings();
 
         this.addToolBox(this._toolBoxThings);
     },
diff --git a/src/js/ui/mainWindow.js b/src/js/ui/mainWindow.js
index 251bf24..7d52803 100644
--- a/src/js/ui/mainWindow.js
+++ b/src/js/ui/mainWindow.js
@@ -623,6 +623,8 @@ MainWindow.prototype = {
             this._setCurrentPage(actionArgs.pageModel);
         } else if (actionName == "setBackground") {
             this._currentPage.setBackground(actionArgs.backgroundId);
+        } else if (actionName == "addThing") {
+            this._currentPage.addThingFromState({ id: actionArgs.thingId });
         }
     },
 
diff --git a/src/js/ui/toolBoxThings.js b/src/js/ui/toolBoxThings.js
index b62b2e8..58f5230 100644
--- a/src/js/ui/toolBoxThings.js
+++ b/src/js/ui/toolBoxThings.js
@@ -20,12 +20,6 @@ ToolBoxThings.prototype = {
     _init : function(args) {
         args = args || {};
 
-        if ('mainWindow' in args) {
-            this._mainWindow = args.mainWindow;
-        } else {
-            throw new Error("ToolBoxThings mainWindow is required");
-        }
-
         args.title = Gettext.gettext("Add");
 
         ToolBox.ToolBox.prototype._init.apply(this, [args]);
@@ -72,7 +66,9 @@ ToolBoxThings.prototype = {
     },
 
     _onThingButtonClicked : function(button, thing) {
-        this._mainWindow.currentPage.addThingFromState({ id: thing.id });
+        this.emit("action",
+                  "addThing",
+                  { thingId: thing.id });
     },
 
     destroy : function() {



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