[the-board] [ui] Factor out SelectionToolbar from mainWindow.js
- From: Lucas Rocha <lucasr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [the-board] [ui] Factor out SelectionToolbar from mainWindow.js
- Date: Mon, 7 Feb 2011 23:38:14 +0000 (UTC)
commit a2438f12c0845b84142b987803e4b215c9dd7b62
Author: Lucas Rocha <lucasr gnome org>
Date: Mon Feb 7 23:35:44 2011 +0000
[ui] Factor out SelectionToolbar from mainWindow.js
https://bugzilla.gnome.org/show_bug.cgi?id=640595
src/Makefile-js.am | 1 +
src/js/ui/mainWindow.js | 62 ++-------------------------------
src/js/ui/selectionToolbar.js | 76 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 80 insertions(+), 59 deletions(-)
---
diff --git a/src/Makefile-js.am b/src/Makefile-js.am
index 9854f30..a6da4ca 100644
--- a/src/Makefile-js.am
+++ b/src/Makefile-js.am
@@ -15,6 +15,7 @@ dist_jsui_DATA = \
js/ui/page.js \
js/ui/pageButton.js \
js/ui/thing.js \
+ js/ui/selectionToolbar.js \
js/ui/toolbar.js \
js/ui/toolBox.js \
js/ui/toolBoxBackgrounds.js \
diff --git a/src/js/ui/mainWindow.js b/src/js/ui/mainWindow.js
index c24c0ca..da1dcfa 100644
--- a/src/js/ui/mainWindow.js
+++ b/src/js/ui/mainWindow.js
@@ -17,6 +17,7 @@ const Mx = imports.gi.Mx;
const MainToolbar = imports.ui.mainToolbar;
const Page = imports.ui.page;
const PhotoThing = imports.ui.things.photo;
+const SelectionToolbar = imports.ui.selectionToolbar;
const Thing = imports.ui.thing;
const ToolBox = imports.ui.toolBox;
const Toolbar = imports.ui.toolbar;
@@ -224,15 +225,11 @@ MainWindow.prototype = {
_createSelectionToolbar : function() {
this._selectionToolbar =
- new Toolbar.Toolbar({ title: Gettext.gettext("Selection"),
- visible: false });
+ new SelectionToolbar.SelectionToolbar({ title: Gettext.gettext("Selection"),
+ visible: false });
this._selectionToolbar.actor.depth = _LAYER_TOOLBAR;
- this._createToolBoxAlign();
- this._createToolBoxDistribute();
- this._createToolBoxRemove();
-
this._contentBox.append(this._selectionToolbar.actor,
Tb.BoxPackFlags.FIXED);
@@ -264,59 +261,6 @@ MainWindow.prototype = {
Tb.BoxAlignment.START);
},
- _createToolBoxAlign : function() {
- this._toolBoxAlign =
- new ToolBox.ToolBox({ title: Gettext.gettext("Align") });
-
- this._toolBoxAlign.addButton({ label: Gettext.gettext("Left"),
- actionName: "align",
- actionArgs: { alignment: Page.Alignment.LEFT } });
-
- this._toolBoxAlign.addButton({ label: Gettext.gettext("Right"),
- actionName: "align",
- actionArgs: { alignment: Page.Alignment.RIGHT } });
-
- this._toolBoxAlign.addButton({ label: Gettext.gettext("Top"),
- actionName: "align",
- actionArgs: { alignment: Page.Alignment.TOP } });
-
- this._toolBoxAlign.addButton({ label: Gettext.gettext("Bottom"),
- actionName: "align",
- actionArgs: { alignment: Page.Alignment.BOTTOM } });
-
- this._selectionToolbar.addToolBox(this._toolBoxAlign);
- },
-
- _createToolBoxDistribute : function() {
- this._toolBoxDistribute =
- new ToolBox.ToolBox({ title: Gettext.gettext("Distribute") });
-
- let verticalArgs =
- { label: Gettext.gettext("Vertical"),
- actionName: "distribute",
- actionArgs: { orientation: Page.Orientation.VERTICAL } };
-
- this._toolBoxDistribute.addButton(verticalArgs);
-
- let horizontalArgs =
- { label: Gettext.gettext("Horizontal"),
- actionName: "distribute",
- actionArgs: { orientation: Page.Orientation.HORIZONTAL } };
-
- this._toolBoxDistribute.addButton(horizontalArgs);
-
- this._selectionToolbar.addToolBox(this._toolBoxDistribute);
- },
-
- _createToolBoxRemove : function() {
- this._toolBoxRemove = new ToolBox.ToolBox();
-
- this._toolBoxRemove.addButton({ label: Gettext.gettext("Remove"),
- actionName: "remove" });
-
- this._selectionToolbar.addToolBox(this._toolBoxRemove);
- },
-
_createContext : function() {
this._context = { application: this._application,
gtkWindow: this._gtkWindow,
diff --git a/src/js/ui/selectionToolbar.js b/src/js/ui/selectionToolbar.js
new file mode 100644
index 0000000..6798f7c
--- /dev/null
+++ b/src/js/ui/selectionToolbar.js
@@ -0,0 +1,76 @@
+// standard imports
+const Gettext = imports.gettext.domain("the-board");
+
+// ui imports
+const Page = imports.ui.page;
+const Toolbar = imports.ui.toolbar;
+const ToolBox = imports.ui.toolBox;
+
+function SelectionToolbar(args) {
+ this._init(args);
+}
+
+SelectionToolbar.prototype = {
+ __proto__: Toolbar.Toolbar.prototype,
+
+ _init : function(args) {
+ Toolbar.Toolbar.prototype._init.apply(this, [args]);
+
+ this._createToolBoxAlign();
+ this._createToolBoxDistribute();
+ this._createToolBoxRemove();
+ },
+
+ _createToolBoxAlign : function() {
+ this._toolBoxAlign =
+ new ToolBox.ToolBox({ title: Gettext.gettext("Align") });
+
+ this._toolBoxAlign.addButton({ label: Gettext.gettext("Left"),
+ actionName: "align",
+ actionArgs: { alignment: Page.Alignment.LEFT } });
+
+ this._toolBoxAlign.addButton({ label: Gettext.gettext("Right"),
+ actionName: "align",
+ actionArgs: { alignment: Page.Alignment.RIGHT } });
+
+ this._toolBoxAlign.addButton({ label: Gettext.gettext("Top"),
+ actionName: "align",
+ actionArgs: { alignment: Page.Alignment.TOP } });
+
+ this._toolBoxAlign.addButton({ label: Gettext.gettext("Bottom"),
+ actionName: "align",
+ actionArgs: { alignment: Page.Alignment.BOTTOM } });
+
+ this.addToolBox(this._toolBoxAlign);
+ },
+
+ _createToolBoxDistribute : function() {
+ this._toolBoxDistribute =
+ new ToolBox.ToolBox({ title: Gettext.gettext("Distribute") });
+
+ let verticalArgs =
+ { label: Gettext.gettext("Vertical"),
+ actionName: "distribute",
+ actionArgs: { orientation: Page.Orientation.VERTICAL } };
+
+ this._toolBoxDistribute.addButton(verticalArgs);
+
+ let horizontalArgs =
+ { label: Gettext.gettext("Horizontal"),
+ actionName: "distribute",
+ actionArgs: { orientation: Page.Orientation.HORIZONTAL } };
+
+ this._toolBoxDistribute.addButton(horizontalArgs);
+
+ this.addToolBox(this._toolBoxDistribute);
+ },
+
+ _createToolBoxRemove : function() {
+ this._toolBoxRemove = new ToolBox.ToolBox();
+
+ this._toolBoxRemove.addButton({ label: Gettext.gettext("Remove"),
+ actionName: "remove" });
+
+ this.addToolBox(this._toolBoxRemove);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]