[the-board] [things] Add video-specific ToolBoxGroup to VideoThing



commit 9d2f5d690778ebdf616957ab9b5094441734cdcc
Author: Lucas Rocha <lucasr gnome org>
Date:   Sun Nov 7 20:02:57 2010 +0000

    [things] Add video-specific ToolBoxGroup to VideoThing

 data/style/style.css      |    5 --
 src/js/ui/things/video.js |  148 ++++++++-------------------------------------
 2 files changed, 25 insertions(+), 128 deletions(-)
---
diff --git a/data/style/style.css b/data/style/style.css
index 166dc39..479e678 100644
--- a/data/style/style.css
+++ b/data/style/style.css
@@ -175,11 +175,6 @@ MxButton#tool-box-button {
     border-image: none;
 }
 
-TbBox#thing-tool-box-main-box {
-    background-color: #DDDDDD;
-    padding: 0px 0px 0px 12px;
-}
-
 MxButton#tool-box-button:checked {
     border-image: url("tool-box-button-selected.png") 4 4 4 4;
 }
diff --git a/src/js/ui/things/video.js b/src/js/ui/things/video.js
index cb87adb..fed9b11 100644
--- a/src/js/ui/things/video.js
+++ b/src/js/ui/things/video.js
@@ -15,6 +15,8 @@ const Pango = imports.gi.Pango;
 
 // ui imports
 const Thing = imports.ui.thing;
+const ToolBox = imports.ui.toolBox;
+const ToolBoxGroup = imports.ui.toolBoxGroup;
 
 // util imports
 const Path = imports.util.path;
@@ -66,25 +68,12 @@ VideoThing.prototype = {
             this._minHeight = 260;
         }
 
-        if ('showFileSelectionButton' in args) {
-            this._showFileSelectionButton = args.showFileSelectionButton;
-        } else {
-            this._showFileSelectionButton = true;
-        }
-
-        if ('showWebcamButton' in args) {
-            this._showWebcamButton = args.showWebcamButton;
-        } else {
-            this._showWebcamButton = false;
-        }
-
         this._style = new Mx.Style();
         this._style.load_from_file(STYLE);
 
         this._createVideoBox();
         this._createPlaybackBox();
         this._createCaptionText();
-        this._createButtonBox();
 
         Thing.Thing.prototype._init.apply(this, [args]);
     },
@@ -284,57 +273,6 @@ VideoThing.prototype = {
                                 Tb.BoxPackFlags.NONE);
     },
 
-    _createButtonBox : function() {
-        this._buttonBox =
-            new Tb.Box({ orientation: Tb.BoxOrientation.HORIZONTAL,
-                         xAlign: Tb.BoxAlignment.CENTER,
-                         yAlign: Tb.BoxAlignment.CENTER,
-                         opacity: 0,
-                         visible: false,
-                         name: "video-thing-button-box" });
-
-        this._buttonBox.set_style(this._style);
-
-        if (this._showFileSelectionButton) {
-            this._createFileSelectionButton();
-        }
-
-        if (this._showWebcamButton) {
-            this._createWebcamButton();
-        }
-
-        this._contentBox.append(this._buttonBox,
-                                Tb.BoxPackFlags.FIXED);
-
-        this._contentBox.set_fixed_child_align(this._buttonBox,
-                                               Tb.BoxAlignment.CENTER,
-                                               Tb.BoxAlignment.CENTER);
-    },
-
-    _createFileSelectionButton : function() {
-        this._fileSelectionButton =
-            new Mx.Button({ label: "File" });
-
-        this._fileSelectionButtonClickedId =
-            this._fileSelectionButton.connect("clicked",
-                                      Lang.bind(this, this._onFileSelectionButtonClicked));
-
-        this._buttonBox.append(this._fileSelectionButton,
-                               Tb.BoxPackFlags.NONE);
-    },
-
-    _createWebcamButton : function() {
-        this._webcamButton =
-            new Mx.Button({ label: "Webcam" });
-
-        this._webcamButtonClickedId =
-            this._webcamButton.connect("clicked",
-                                      Lang.bind(this, this._onWebcamButtonClicked));
-
-        this._buttonBox.append(this._webcamButton,
-                               Tb.BoxPackFlags.NONE);
-    },
-
     _connectVideoSignals : function(fromState) {
         this._disconnectVideoSignals();
 
@@ -387,7 +325,6 @@ VideoThing.prototype = {
         if (this._videoFilename) {
             this._connectVideoSignals(fromState);
             this._updateSpinner();
-            this._hideButtonBox();
 
             // hide video while loading the new video file
             this._video.opacity = 0;
@@ -454,28 +391,6 @@ VideoThing.prototype = {
                            }});
     },
 
-    _showButtonBox : function() {
-        if (!this._showFileSelectionButton && !this._showWebcamButton) {
-            return;
-        }
-
-        Tweener.addTween(this._buttonBox,
-                         { opacity: 255,
-                           time: _SHOW_BUTTON_BOX_TIME,
-                           onStart: function() {
-                               this.show();
-                           }});
-    },
-
-    _hideButtonBox : function() {
-        Tweener.addTween(this._buttonBox,
-                         { opacity: 0,
-                           time: _SHOW_BUTTON_BOX_TIME,
-                           onComplete: function() {
-                               this.hide();
-                           }});
-    },
-
     _updateVideoWithFileChooser : function() {
         let chooser = new Gtk.FileChooserDialog();
 
@@ -518,10 +433,6 @@ VideoThing.prototype = {
         this._disconnectVideoSignals();
         this._updateSpinner();
 
-        if (!fromState) {
-            this._showButtonBox();
-        }
-
         [minTextHeight, naturalTextHeight] =
             this._captionLabel.get_preferred_height(-1);
 
@@ -580,9 +491,7 @@ VideoThing.prototype = {
 
         switch (key) {
         case Clutter.Return:
-            if (this._showFileSelectionButton) {
-                this._updateVideoWithFileChooser();
-            }
+            this._updateVideoWithFileChooser();
             return true;
         case Clutter.Escape:
             this.emit("deactivate");
@@ -612,13 +521,6 @@ VideoThing.prototype = {
         return false;
     },
 
-    _onFileSelectionButtonClicked : function() {
-        this._updateVideoWithFileChooser();
-    },
-
-    _onWebcamButtonClicked : function() {
-    },
-
     _onPlayButtonToggled : function() {
         this._video.playing = this._playButton.toggled;
     },
@@ -668,12 +570,10 @@ VideoThing.prototype = {
     activate : function() {
         this._captionLabel.clutterText.editable = true;
         this._captionLabel.clutterText.grab_key_focus();
-        this._showButtonBox();
     },
 
     deactivate : function() {
         this._captionLabel.clutterText.editable = false;
-        this._hideButtonBox();
     },
 
     loadState : function(state) {
@@ -692,6 +592,12 @@ VideoThing.prototype = {
                  text: this._captionLabel.text };
     },
 
+    doAction : function(actionName, actionArgs) {
+        if (actionName == "chooseFile") {
+            this._updateVideoWithFileChooser();
+        }
+    },
+
     validateSize : function(width, height) {
         // minWidth and minHeight always have a valid aspect
         // ratio once the video is loaded (see _onVideoLoadFinished)
@@ -707,31 +613,11 @@ VideoThing.prototype = {
     },
 
     destroy : function() {
-        if (this._fileSelectionButtonClickedId) {
-            this._fileSelectionButton.disconnect(this._fileSelectionButtonClickedId);
-            delete this._fileSelectionButtonClickedId;
-        }
-
-        if (this._webcamButtonClickedId) {
-            this._webcamButton.disconnect(this._webcamButtonClickedId);
-            delete this._webcamButtonClickedId;
-        }
-
         if (this._playButtonClickedId) {
             this._playButton.disconnect(this._playButtonClickedId);
             delete this._playButtonClickedId;
         }
 
-        if (this._fileSelectionButton) {
-            this._fileSelectionButton.destroy();
-            delete this._fileSelectionButton;
-        }
-
-        if (this._webcamButton) {
-            this._webcamButton.destroy();
-            delete this._webcamButton;
-        }
-
         this._disconnectVideoSignals();
 
         if (this._saveTextTimeoutId) {
@@ -769,3 +655,19 @@ VideoThing.prototype = {
 function create(args) {
     return new VideoThing(args);
 }
+
+function createToolBoxGroup(args) {
+    let toolBoxGroup =
+        new ToolBoxGroup.ToolBoxGroup({ visible: false });
+
+    let toolBox =
+        new ToolBox.ToolBox({ title: Gettext.gettext("Load from"),
+                              isThingToolBox: true });
+
+    toolBox.addButton({ label: Gettext.gettext("File"),
+                        actionName: "chooseFile" });
+
+    toolBoxGroup.addToolBox(toolBox);
+
+    return toolBoxGroup;
+}



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