[the-board] [things] Set style on constructor instead of calling set_style()



commit 1c77ee70cd9c79676691c7c5a85fd314d43fee98
Author: Lucas Rocha <lucasr gnome org>
Date:   Sat Apr 2 01:54:23 2011 +0100

    [things] Set style on constructor instead of calling set_style()
    
    Slightly more efficient and cleaner.

 src/js/ui/things/photo.js |    6 ++----
 src/js/ui/things/sound.js |   36 ++++++++++++------------------------
 src/js/ui/things/text.js  |   21 ++++-----------------
 src/js/ui/things/video.js |   30 ++++++++++--------------------
 4 files changed, 28 insertions(+), 65 deletions(-)
---
diff --git a/src/js/ui/things/photo.js b/src/js/ui/things/photo.js
index a73acb5..bb79860 100644
--- a/src/js/ui/things/photo.js
+++ b/src/js/ui/things/photo.js
@@ -81,9 +81,8 @@ PhotoThing.prototype = {
             new TheBoard.Box({ orientation: TheBoard.BoxOrientation.VERTICAL,
                                xAlign: TheBoard.BoxAlignment.FILL,
                                yAlign: TheBoard.BoxAlignment.FILL,
+                               style: this._style,
                                name: "photo-thing-photo-box" });
-
-        this._photoBox.set_style(this._style);
     },
 
     _createPhoto : function() {
@@ -98,10 +97,9 @@ PhotoThing.prototype = {
     _createCaptionText : function() {
         this._captionLabel =
             new Mx.Label({ xAlign: Mx.Align.MIDDLE,
+                           style: this._style,
                            name: "photo-thing-caption-label" });
 
-        this._captionLabel.set_style(this._style);
-
         this._captionLabel.clutterText.lineAlignment = Pango.Alignment.CENTER;
 
         this._captionLabel.connect("key-press-event",
diff --git a/src/js/ui/things/sound.js b/src/js/ui/things/sound.js
index 96a91bd..6b39d28 100644
--- a/src/js/ui/things/sound.js
+++ b/src/js/ui/things/sound.js
@@ -73,10 +73,9 @@ SoundThing.prototype = {
             new TheBoard.Box({ orientation: TheBoard.BoxOrientation.HORIZONTAL,
                                xAlign: TheBoard.BoxAlignment.FILL,
                                yAlign: TheBoard.BoxAlignment.FILL,
+                               style: this._style,
                                name: "sound-thing-sound-box" });
 
-        this._soundBox.set_style(this._style);
-
         this._createCasseteBg();
         this._createContentBox();
     },
@@ -114,10 +113,9 @@ SoundThing.prototype = {
             new TheBoard.Box({ orientation: TheBoard.BoxOrientation.VERTICAL,
                                xAlign: TheBoard.BoxAlignment.FILL,
                                yAlign: TheBoard.BoxAlignment.FILL,
+                               style: this._style,
                                name: "sound-thing-content-box" });
 
-        this._contentBox.set_style(this._style);
-
         this._createControlsBox();
 
         this._soundBox.append(this._contentBox,
@@ -129,10 +127,9 @@ SoundThing.prototype = {
             new TheBoard.Box({ orientation: TheBoard.BoxOrientation.VERTICAL,
                                xAlign: TheBoard.BoxAlignment.FILL,
                                yAlign: TheBoard.BoxAlignment.START,
+                               style: this._style,
                                name: "sound-thing-controls-box" });
 
-        this._controlsBox.set_style(this._style);
-
         this._createPlaybackBox();
         this._createTimeLabel();
 
@@ -151,10 +148,9 @@ SoundThing.prototype = {
                                yAlign: TheBoard.BoxAlignment.CENTER,
                                visible: false,
                                opacity: 0,
+                               style: this._style,
                                name: "sound-thing-playback-box" });
 
-        this._playbackBox.set_style(this._style);
-
         this._createPlayButton();
         this._createProgressBar();
 
@@ -165,10 +161,9 @@ SoundThing.prototype = {
     _createPlayButton : function() {
         this._playButton =
             new Mx.Button({ isToggle: true,
+                            style: this._style,
                             name: "sound-thing-play-button" });
 
-        this._playButton.set_style(this._style);
-
         this._playButton.connect("notify::toggled",
                                  Lang.bind(this,
                                            this._onPlayButtonToggled));
@@ -181,10 +176,9 @@ SoundThing.prototype = {
         this._progressBar =
             new Mx.ProgressBar({ reactive: true,
                                  height: 12,
+                                 style: this._style,
                                  name: "sound-thing-progress-bar" });
 
-        this._progressBar.set_style(this._style);
-
         this._updateProgressBar();
 
         this._progressBar.connect("button-press-event",
@@ -205,10 +199,9 @@ SoundThing.prototype = {
                            anchorY: -2,
                            visible: false,
                            opacity: 0,
+                           style: this._style,
                            name: "sound-thing-time-label" });
 
-        this._timeLabel.set_style(this._style);
-
         this._updateTimeLabel(this._player.duration);
 
         this._controlsBox.append(this._timeLabel,
@@ -224,16 +217,14 @@ SoundThing.prototype = {
             new TheBoard.Box({ orientation: TheBoard.BoxOrientation.HORIZONTAL,
                                xAlign: TheBoard.BoxAlignment.FILL,
                                yAlign: TheBoard.BoxAlignment.FILL,
+                               style: this._style,
                                name: _CAPTION_BOX_STYLE_NORMAL });
 
-        this._captionBox.set_style(this._style);
-
         this._captionLabel =
             new Mx.Label({ xAlign: Mx.Align.MIDDLE,
+                           style: this._style,
                            name: "sound-thing-caption-label" });
 
-        this._captionLabel.set_style(this._style);
-
         this._captionLabel.clutterText.maxLength = 25;
         this._captionLabel.clutterText.lineAlignment = Pango.Alignment.CENTER;
 
@@ -257,18 +248,16 @@ SoundThing.prototype = {
                                y: _SPOOLS_Y,
                                xAlign: TheBoard.BoxAlignment.FILL,
                                yAlign: TheBoard.BoxAlignment.FILL,
+                               style: this._style,
                                name: "sound-thing-spools-box" });
 
-        this._spoolsBox.set_style(this._style);
-
         for (let i = 0; i < 2; i++) {
             let spool = new Mx.Spinner({ width: 27,
                                         height: 27,
                                         animating: false,
+                                        style: this._style,
                                         name: "sound-thing-spool" });
 
-            spool.set_style(this._style);
-
             this._spoolsBox.append(spool,
                                    TheBoard.BoxPackFlags.NONE);
         }
@@ -420,14 +409,13 @@ SoundThing.prototype = {
         this._stopButton =
             new Mx.Button({ label: Gettext.gettext("Stop"),
                             y: _STOP_BUTTON_Y,
+                            style: this._style,
                             name: "sound-thing-stop-button" });
 
         this._stopButton.connect("clicked",
                                  Lang.bind(this,
                                            this._onStopButtonClicked));
 
-        this._stopButton.set_style(this._style);
-
         this._contentBox.append(this._stopButton,
                                 TheBoard.BoxPackFlags.FIXED);
 
diff --git a/src/js/ui/things/text.js b/src/js/ui/things/text.js
index 528d1d1..2fd382f 100644
--- a/src/js/ui/things/text.js
+++ b/src/js/ui/things/text.js
@@ -101,11 +101,8 @@ TextThing.prototype = {
             new TheBoard.Box({ orientation: TheBoard.BoxOrientation.VERTICAL,
                                xAlign: TheBoard.BoxAlignment.FILL,
                                yAlign: TheBoard.BoxAlignment.FILL,
+                               style: this._style,
                                name: "text-thing-bg-box" });
-
-        if (this._style) {
-            this._bgBox.set_style(this._style);
-        }
     },
 
     _createTiledBackground : function() {
@@ -127,6 +124,7 @@ TextThing.prototype = {
     _createScrollView : function() {
         this._scrollView =
             new Mx.ScrollView({ reactive: false,
+                                style: this._style,
                                 name: "text-thing-scroll-view" });
 
         if (this._singleLine) {
@@ -142,10 +140,6 @@ TextThing.prototype = {
 
         this._scrollView.add_action(clickAction);
 
-        if (this._style) {
-            this._scrollView.set_style(this._style);
-        }
-
         this._bgBox.append(this._scrollView,
                            TheBoard.BoxPackFlags.EXPAND);
     },
@@ -153,6 +147,7 @@ TextThing.prototype = {
     _createTextBox : function() {
         this._textBox =
             new Mx.BoxLayout({ orientation: Mx.Orientation.VERTICAL,
+                               style: this._style,
                                name: "text-thing-text-box" });
 
         if (this._singleLine) {
@@ -163,19 +158,11 @@ TextThing.prototype = {
             this._textBox.yAlign = TheBoard.BoxAlignment.START;
         }
 
-        if (this._style) {
-            this._textBox.set_style(this._style);
-        }
-
         this._scrollView.add_actor(this._textBox);
     },
 
     _createText : function() {
-        this._label = new Mx.Label();
-
-        if (this._style) {
-            this._label.set_style(this._style);
-        }
+        this._label = new Mx.Label({ style: this._style });
 
         this._updateFont();
 
diff --git a/src/js/ui/things/video.js b/src/js/ui/things/video.js
index 40b2a42..5d4217b 100644
--- a/src/js/ui/things/video.js
+++ b/src/js/ui/things/video.js
@@ -81,10 +81,9 @@ VideoThing.prototype = {
             new TheBoard.Box({ orientation: TheBoard.BoxOrientation.HORIZONTAL,
                                xAlign: TheBoard.BoxAlignment.FILL,
                                yAlign: TheBoard.BoxAlignment.FILL,
+                               style: this._style,
                                name: "video-thing-video-box" });
 
-        this._videoBox.set_style(this._style);
-
         this._createStrip();
         this._createContentBox();
         this._createStrip();
@@ -95,10 +94,9 @@ VideoThing.prototype = {
             new TheBoard.Box({ orientation: TheBoard.BoxOrientation.VERTICAL,
                                xAlign: TheBoard.BoxAlignment.FILL,
                                yAlign: TheBoard.BoxAlignment.FILL,
+                               style: this._style,
                                name: "video-thing-content-box" });
 
-        this._contentBox.set_style(this._style);
-
         this._videoBox.append(this._contentBox,
                               TheBoard.BoxPackFlags.EXPAND);
     },
@@ -118,10 +116,9 @@ VideoThing.prototype = {
             new TheBoard.Box({ orientation: TheBoard.BoxOrientation.VERTICAL,
                                xAlign: TheBoard.BoxAlignment.FILL,
                                yAlign: TheBoard.BoxAlignment.FILL,
+                               style: this._style,
                                name: "video-thing-playback-box" });
 
-        this._playbackBox.set_style(this._style);
-
         this._createVideo();
         this._createVideoControlsBox();
         this._createVideoBorderBox();
@@ -149,20 +146,18 @@ VideoThing.prototype = {
             new TheBoard.Box({ orientation: TheBoard.BoxOrientation.HORIZONTAL,
                                xAlign: TheBoard.BoxAlignment.FILL,
                                yAlign: TheBoard.BoxAlignment.CENTER,
+                               style: this._style,
                                name: "video-thing-controls-box" });
 
-        controlsBox.set_style(this._style);
-
         this._videoControlsBox =
             new TheBoard.Box({ orientation: TheBoard.BoxOrientation.HORIZONTAL,
                                xAlign: TheBoard.BoxAlignment.FILL,
                                yAlign: TheBoard.BoxAlignment.CENTER,
                                opacity: 0,
                                visible: false,
+                               style: this._style,
                                name: "video-thing-video-controls-box" });
 
-        this._videoControlsBox.set_style(this._style);
-
         this._createPlayButton();
         this._createProgressBar();
         this._createTimeLabel();
@@ -181,10 +176,9 @@ VideoThing.prototype = {
     _createPlayButton : function() {
         this._playButton =
             new Mx.Button({ isToggle: true,
+                            style: this._style,
                             name: "video-thing-play-button" });
 
-        this._playButton.set_style(this._style);
-
         this._playButton.connect("notify::toggled",
                                  Lang.bind(this,
                                            this._onPlayButtonToggled));
@@ -197,10 +191,9 @@ VideoThing.prototype = {
         this._progressBar =
             new Mx.ProgressBar({ reactive: true,
                                  height: 12,
+                                 style: this._style,
                                  name: "video-thing-progress-bar" });
 
-        this._progressBar.set_style(this._style);
-
         this._updateProgressBar();
 
         this._progressBar.connect("button-press-event",
@@ -220,10 +213,9 @@ VideoThing.prototype = {
             new Mx.Label({ yAlign: Mx.Align.MIDDLE,
                            text: "00:12:00",
                            anchorY: -2,
+                           style: this._style,
                            name: "video-thing-time-label" });
 
-        this._timeLabel.set_style(this._style);
-
         this._updateTimeLabel();
 
         this._videoControlsBox.append(this._timeLabel,
@@ -239,10 +231,9 @@ VideoThing.prototype = {
             new TheBoard.Box({ orientation: TheBoard.BoxOrientation.HORIZONTAL,
                                xAlign: TheBoard.BoxAlignment.FILL,
                                yAlign: TheBoard.BoxAlignment.FILL,
+                               style: this._style,
                                name: "video-thing-video-border-box" });
 
-        this._videoBorderBox.set_style(this._style);
-
         this._playbackBox.append(this._videoBorderBox,
                                  TheBoard.BoxPackFlags.FIXED);
 
@@ -254,10 +245,9 @@ VideoThing.prototype = {
     _createCaptionText : function() {
         this._captionLabel =
             new Mx.Label({ xAlign: Mx.Align.MIDDLE,
+                           style: this._style,
                            name: "video-thing-caption-label" });
 
-        this._captionLabel.set_style(this._style);
-
         this._captionLabel.clutterText.lineAlignment = Pango.Alignment.CENTER;
 
         this._captionLabel.connect("key-press-event",



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