[the-board] [ui] Factor new page action from toolbox into a main toolbar action



commit 9c7b3311eb982b8ad8448e28af054fbad801a63d
Author: Lucas Rocha <lucasr gnome org>
Date:   Sat Apr 2 22:54:33 2011 +0100

    [ui] Factor new page action from toolbox into a main toolbar action
    
    This way we can add different triggers to same action.

 src/js/ui/mainWindow.js   |    9 ++++++++-
 src/js/ui/toolBoxPages.js |   16 +++++-----------
 2 files changed, 13 insertions(+), 12 deletions(-)
---
diff --git a/src/js/ui/mainWindow.js b/src/js/ui/mainWindow.js
index 045a8e5..321dcbb 100644
--- a/src/js/ui/mainWindow.js
+++ b/src/js/ui/mainWindow.js
@@ -606,7 +606,9 @@ MainWindow.prototype = {
     },
 
     _doAction : function(actionName, actionArgs) {
-        if (actionName == "setCurrentPage") {
+        if (actionName == "addNewPage") {
+            this._addNewPage();
+        } else if (actionName == "setCurrentPage") {
             this._setCurrentPage(actionArgs.pageModel);
         } else if (actionName == "setBackground") {
             this._currentPage.setBackground(actionArgs.backgroundId);
@@ -615,6 +617,11 @@ MainWindow.prototype = {
         }
     },
 
+    _addNewPage : function() {
+        let newPageModel = this._pageManager.addPageModel();
+        this._setCurrentPage(newPageModel);
+    },
+
     _setCurrentPage : function(pageModel) {
         if (this._currentPage &&
             this._currentPage.model.id == pageModel.id) {
diff --git a/src/js/ui/toolBoxPages.js b/src/js/ui/toolBoxPages.js
index e756e91..ca228b6 100644
--- a/src/js/ui/toolBoxPages.js
+++ b/src/js/ui/toolBoxPages.js
@@ -347,17 +347,7 @@ ToolBoxPages.prototype = {
     },
 
     _onNewPageButtonClicked : function() {
-        let pageManager = this._context.pageManager;
-
-        let newPageModel = pageManager.addPageModel();
-
-        this.emit("action",
-                  "setCurrentPage",
-                  { pageModel: newPageModel });
-
-        this.setCurrentPage(newPageModel);
-
-        this._startEditingTitle();
+        this.emit("action", "addNewPage");
     },
 
     _onPageButtonClicked : function(pageButton) {
@@ -457,6 +447,10 @@ ToolBoxPages.prototype = {
             let pageButton = this._pageButtons[i];
             this._updateButtonVisibility(pageButton);
         }
+
+        if (pageModel.isNew()) {
+            this._startEditingTitle();
+        }
     },
 
     destroy : function() {



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