[the-board] [ui] Use action to set page background instead of MainWindow API



commit 70f24a9f8478fcac4da1fb51e49607ecdcd3cb53
Author: Lucas Rocha <lucasr gnome org>
Date:   Mon Feb 7 23:56:27 2011 +0000

    [ui] Use action to set page background instead of MainWindow API
    
    This is more consistent with the rest of the toolbars.

 src/js/ui/mainToolbar.js        |    4 +---
 src/js/ui/mainWindow.js         |    2 ++
 src/js/ui/toolBoxBackgrounds.js |   11 +++--------
 3 files changed, 6 insertions(+), 11 deletions(-)
---
diff --git a/src/js/ui/mainToolbar.js b/src/js/ui/mainToolbar.js
index 6b87de3..31ca38f 100644
--- a/src/js/ui/mainToolbar.js
+++ b/src/js/ui/mainToolbar.js
@@ -42,10 +42,8 @@ MainToolbar.prototype = {
     },
 
     _createToolBoxBackgrounds : function() {
-        let mainWindow = this._context.mainWindow;
-
         this._toolBoxBackgrounds =
-            new ToolBoxBackgrounds.ToolBoxBackgrounds({ mainWindow: mainWindow });
+            new ToolBoxBackgrounds.ToolBoxBackgrounds();
 
         this.addToolBox(this._toolBoxBackgrounds);
     },
diff --git a/src/js/ui/mainWindow.js b/src/js/ui/mainWindow.js
index b65273d..251bf24 100644
--- a/src/js/ui/mainWindow.js
+++ b/src/js/ui/mainWindow.js
@@ -621,6 +621,8 @@ MainWindow.prototype = {
     _doAction : function(actionName, actionArgs) {
         if (actionName == "setCurrentPage") {
             this._setCurrentPage(actionArgs.pageModel);
+        } else if (actionName == "setBackground") {
+            this._currentPage.setBackground(actionArgs.backgroundId);
         }
     },
 
diff --git a/src/js/ui/toolBoxBackgrounds.js b/src/js/ui/toolBoxBackgrounds.js
index cc88ef8..a2968cb 100644
--- a/src/js/ui/toolBoxBackgrounds.js
+++ b/src/js/ui/toolBoxBackgrounds.js
@@ -20,12 +20,6 @@ ToolBoxBackgrounds.prototype = {
     _init : function(args) {
         args = args || {};
 
-        if ('mainWindow' in args) {
-            this._mainWindow = args.mainWindow;
-        } else {
-            throw new Error("ToolBoxBackgrounds mainWindow is required");
-        }
-
         args.title = Gettext.gettext("Background");
         args.isButtonGroup = true;
 
@@ -69,8 +63,9 @@ ToolBoxBackgrounds.prototype = {
     _onBgButtonClicked : function(button, backgroundId) {
         button.set_toggled(true);
 
-        let page = this._mainWindow.currentPage;
-        page.setBackground(backgroundId);
+        this.emit("action",
+                  "setBackground",
+                  { backgroundId: backgroundId });
     },
 
     setCurrentBackground : function(backgroundId) {



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