[sushi] all: fix underallocations for "floating" widgets



commit 988737b4850130cbadd309519ea6531053c6b4f7
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sat Jul 2 00:42:06 2011 -0400

    all: fix underallocations for "floating" widgets
    
    Something changed in GTK+ or clutter-gtk and we now need to do this in
    order for our widgets to appear. This needs to be further investigated.

 src/js/ui/mainWindow.js  |    7 +++++--
 src/js/ui/utils.js       |    8 ++++++++
 src/js/viewers/audio.js  |   17 +++++++++--------
 src/js/viewers/evince.js |    7 ++++---
 src/js/viewers/gst.js    |   16 ++++++++--------
 src/js/viewers/html.js   |    7 ++++---
 src/js/viewers/image.js  |    7 ++++---
 7 files changed, 42 insertions(+), 27 deletions(-)
---
diff --git a/src/js/ui/mainWindow.js b/src/js/ui/mainWindow.js
index aeda07a..bb8678c 100644
--- a/src/js/ui/mainWindow.js
+++ b/src/js/ui/mainWindow.js
@@ -530,7 +530,7 @@ MainWindow.prototype = {
         this._titleLabel.get_style_context().add_class("np-decoration");
         
         this._titleLabel.show();
-        this._titleActor = new GtkClutter.Actor({ contents: this._titleLabel });
+        this._titleActor = Utils.forcedSizeActor(this._titleLabel);
         this._titleActor.add_constraint(
             new Clutter.AlignConstraint({ source: this._stage,
                                           factor: 0.5 }));
@@ -549,7 +549,7 @@ MainWindow.prototype = {
                                  Lang.bind(this,
                                            this._clearAndQuit));
 
-        this._quitActor = new GtkClutter.Actor({ contents: this._quitButton });
+        this._quitActor = Utils.forcedSizeActor(this._quitButton);
         this._quitActor.set_reactive(true);
         this._quitActor.add_constraint(
             new Clutter.AlignConstraint({ source: this._stage,
@@ -630,6 +630,9 @@ MainWindow.prototype = {
 
     setTitle : function(label) {
         this._titleLabel.set_label(label);
+
+        //FIXME: why is this needed?
+        this._titleActor.set_size(this._titleLabel.get_preferred_width()[1], this._titleLabel.get_preferred_height()[1]);
     },
 
     refreshSize : function() {
diff --git a/src/js/ui/utils.js b/src/js/ui/utils.js
index ad070f0..37db45f 100644
--- a/src/js/ui/utils.js
+++ b/src/js/ui/utils.js
@@ -2,6 +2,14 @@ let Constants = imports.util.constants;
 
 let slowDownFactor = 0;
 
+// FIXME: why is this needed?
+function forcedSizeActor(widget) {
+    let actor = new GtkClutter.Actor({ contents: widget });
+    actor.set_size(widget.get_preferred_width()[1], widget.get_preferred_height()[1]);
+
+    return actor;
+}
+
 function setSlowDownFactor(factor) {
     slowDownFactor = factor;
 }
diff --git a/src/js/viewers/audio.js b/src/js/viewers/audio.js
index 40f10e4..affe6aa 100644
--- a/src/js/viewers/audio.js
+++ b/src/js/viewers/audio.js
@@ -221,14 +221,6 @@ AudioRenderer.prototype = {
         this._mainToolbar = new Gtk.Toolbar();
         this._mainToolbar.get_style_context().add_class("np-toolbar");
         this._mainToolbar.set_icon_size(Gtk.IconSize.MENU);
-        this._mainToolbar.show();
-
-        this._toolbarActor = new GtkClutter.Actor({ contents: this._mainToolbar,
-                                                    opacity: 0});
-        this._toolbarActor.add_constraint(
-            new Clutter.BindConstraint({ source: this._actor,
-                                         coordinate: Clutter.BindCoordinate.WIDTH,
-                                         offset: -50 }));
 
         this._toolbarPlay = new Gtk.ToolButton({ "icon-name": "media-playback-pause-symbolic" });
         this._toolbarPlay.show();
@@ -270,6 +262,15 @@ AudioRenderer.prototype = {
         item.show_all();
         this._mainToolbar.insert(item, 3);
 
+        this._mainToolbar.show();
+
+        this._toolbarActor = Utils.forcedSizeActor(this._mainToolbar);
+        this._toolbarActor.add_constraint(
+            new Clutter.BindConstraint({ source: this._actor,
+                                         coordinate: Clutter.BindCoordinate.WIDTH,
+                                         offset: -50 }));
+
+
         return this._toolbarActor;
     },
 }
diff --git a/src/js/viewers/evince.js b/src/js/viewers/evince.js
index 63a2a60..a891a06 100644
--- a/src/js/viewers/evince.js
+++ b/src/js/viewers/evince.js
@@ -99,9 +99,6 @@ EvinceRenderer.prototype = {
         this._mainToolbar = new Gtk.Toolbar({ "icon-size": Gtk.IconSize.MENU });
         this._mainToolbar.get_style_context().add_class("np-toolbar");
         this._mainToolbar.set_show_arrow(false);
-        this._mainToolbar.show();
-
-        this._toolbarActor = new GtkClutter.Actor({ contents: this._mainToolbar });
 
         this._toolbarZoom = Utils.createFullScreenButton(this._mainWindow);
         this._mainToolbar.insert(this._toolbarZoom, 0);
@@ -135,6 +132,10 @@ EvinceRenderer.prototype = {
 
         this._updatePageLabel();
 
+        this._mainToolbar.show();
+
+        this._toolbarActor = Utils.forcedSizeActor(this._mainToolbar);
+
         return this._toolbarActor;
     },
 
diff --git a/src/js/viewers/gst.js b/src/js/viewers/gst.js
index c6f398e..9dd4be2 100644
--- a/src/js/viewers/gst.js
+++ b/src/js/viewers/gst.js
@@ -116,14 +116,6 @@ GstRenderer.prototype = {
     createToolbar : function () {
         this._mainToolbar = new Gtk.Toolbar({ "icon-size": Gtk.IconSize.MENU });
         this._mainToolbar.get_style_context().add_class("np-toolbar");
-        this._mainToolbar.show();
-
-        this._toolbarActor = new GtkClutter.Actor({ contents: this._mainToolbar,
-                                                    opacity: 0 });
-        this._toolbarActor.add_constraint(
-            new Clutter.BindConstraint({ source: this._video,
-                                         coordinate: Clutter.BindCoordinate.WIDTH,
-                                         offset: -50 }));
 
         this._toolbarPlay = new Gtk.ToolButton({ "icon-name": "media-playback-pause-symbolic" });
         this._toolbarPlay.show();
@@ -169,6 +161,14 @@ GstRenderer.prototype = {
         this._toolbarZoom = Utils.createFullScreenButton(this._mainWindow);
         this._mainToolbar.insert(this._toolbarZoom, 4);
 
+        this._mainToolbar.show();
+
+        this._toolbarActor = Utils.forcedSizeActor(this._mainToolbar);
+        this._toolbarActor.add_constraint(
+            new Clutter.BindConstraint({ source: this._video,
+                                         coordinate: Clutter.BindCoordinate.WIDTH,
+                                         offset: -50 }));
+
         return this._toolbarActor;
     },
 
diff --git a/src/js/viewers/html.js b/src/js/viewers/html.js
index 765e8d5..542d04f 100644
--- a/src/js/viewers/html.js
+++ b/src/js/viewers/html.js
@@ -52,9 +52,6 @@ HTMLRenderer.prototype = {
         this._mainToolbar = new Gtk.Toolbar({ "icon-size": Gtk.IconSize.MENU });
         this._mainToolbar.get_style_context().add_class("np-toolbar");
         this._mainToolbar.set_show_arrow(false);
-        this._mainToolbar.show();
-
-        this._toolbarActor = new GtkClutter.Actor({ contents: this._mainToolbar });
 
         this._toolbarZoom = Utils.createFullScreenButton(this._mainWindow);
         this._mainToolbar.insert(this._toolbarZoom, 0);
@@ -66,6 +63,10 @@ HTMLRenderer.prototype = {
         this._toolbarRun = Utils.createRunButton(this._file);
         this._mainToolbar.insert(this._toolbarRun, 2);
 
+        this._mainToolbar.show();
+
+        this._toolbarActor = Utils.forcedSizeActor(this._mainToolbar);
+
         return this._toolbarActor;
     }
 }
diff --git a/src/js/viewers/image.js b/src/js/viewers/image.js
index 60b7fab..2691e9b 100644
--- a/src/js/viewers/image.js
+++ b/src/js/viewers/image.js
@@ -70,13 +70,14 @@ ImageRenderer.prototype = {
         this._mainToolbar = new Gtk.Toolbar({ "icon-size": Gtk.IconSize.MENU });
         this._mainToolbar.get_style_context().add_class("np-toolbar");
         this._mainToolbar.set_show_arrow(false);
-        this._mainToolbar.show();
-
-        this._toolbarActor = new GtkClutter.Actor({ contents: this._mainToolbar });
 
         this._toolbarZoom = Utils.createFullScreenButton(this._mainWindow);
         this._mainToolbar.insert(this._toolbarZoom, 0);
 
+        this._mainToolbar.show();
+
+        this._toolbarActor = Utils.forcedSizeActor(this._mainToolbar);
+
         return this._toolbarActor;
     },
 }



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