[gnome-shell/wip/hadess/welcome-tour: 34/34] WIP: Try to use texture cache directly




commit f97d3cfc3db0b1982ef07926b6e175e92aa498ed
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Feb 1 16:21:33 2021 +0100

    WIP: Try to use texture cache directly
    
    See https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3652

 js/ui/main.js          |  3 +++
 js/ui/welcomeDialog.js | 65 ++++++++++++++++++++------------------------------
 2 files changed, 29 insertions(+), 39 deletions(-)
---
diff --git a/js/ui/main.js b/js/ui/main.js
index ea59c2e619..795083517e 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -324,6 +324,9 @@ function _handleShowWelcomeScreen() {
     if (_shellSettings.get_boolean(SHOW_WELCOME_TOUR)) {
         openWelcomeDialog();
         _shellSettings.set_boolean(SHOW_WELCOME_TOUR, false);
+    } else {
+       print ('WELCOME TOUR DISABLED');
+           openWelcomeDialog();
     }
 }
 
diff --git a/js/ui/welcomeDialog.js b/js/ui/welcomeDialog.js
index a5d3f5d31f..3ce2258371 100644
--- a/js/ui/welcomeDialog.js
+++ b/js/ui/welcomeDialog.js
@@ -29,15 +29,10 @@ class WelcomeDialog extends ModalDialog.ModalDialog {
     }
 
     _buildLayout() {
-        const file = Gio.File.new_for_uri(
-            'resource:///org/gnome/shell/theme/gnome-shell-start.svg');
-        let icon = new Gio.FileIcon({ file });
+        let icon_uri = 'resource:///org/gnome/shell/theme/gnome-shell-start.svg';
         let title = _("Welcome to GNOME %s".format(Config.PACKAGE_VERSION));
         let description = _('If you want to learn your way around, check out the tour.');
-        let content = new WelcomeDialogContent({ title, description, icon });
-        content._icon.icon_size = 600;
-        content._icon.height = 400;
-        content._icon.width = 600;
+        let content = new WelcomeDialogContent({ title, description, icon_uri });
         this.contentLayout.add_actor(content);
 
         this.addButton({ label: _("Maybe Later"),
@@ -79,17 +74,20 @@ var WelcomeDialogContent = GObject.registerClass({
             GObject.ParamFlags.READWRITE |
             GObject.ParamFlags.CONSTRUCT,
             null),
-        'icon': GObject.ParamSpec.object(
-            'icon', 'icon', 'icon',
+        'icon-uri': GObject.ParamSpec.string(
+            'icon-uri', 'icon-uri', 'icon-uri',
             GObject.ParamFlags.READWRITE |
             GObject.ParamFlags.CONSTRUCT,
-            Gio.Icon.$gtype),
+            null),
     },
 }, class WelcomeDialogContent extends St.BoxLayout {
     _init(params) {
         this._title = new St.Label({ style_class: 'message-dialog-title' });
         this._description = new St.Label({ style_class: 'message-dialog-description' });
-        this._icon = new St.Icon({ style_class: 'welcome-dialog-icon' });
+        let iconLayoutManager = new Clutter.BinLayout({ x_align: Clutter.BinAlignment.FILL,
+                                                        y_align: Clutter.BinAlignment.FILL });
+        this._iconBin = new St.Widget({ style_class: 'login-dialog-logo-bin',
+                                        layout_manager: iconLayoutManager});
 
         this._description.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
         this._description.clutter_text.line_wrap = true;
@@ -101,10 +99,9 @@ var WelcomeDialogContent = GObject.registerClass({
         };
         super._init(Object.assign(defaultParams, params));
 
-        this.connect('notify::size', this._updateTitleStyle.bind(this));
         this.connect('destroy', this._onDestroy.bind(this));
 
-        this.add_child(this._icon);
+        this.add_child(this._iconBin);
         this.add_child(this._title);
         this.add_child(this._description);
     }
@@ -124,27 +121,8 @@ var WelcomeDialogContent = GObject.registerClass({
         return this._description.text;
     }
 
-    get icon() {
-        return this._icon.icon_name;
-    }
-
-    _updateTitleStyle() {
-        if (!this._title.mapped)
-            return;
-
-        this._title.ensure_style();
-        const [, titleNatWidth] = this._title.get_preferred_width(-1);
-
-        if (titleNatWidth > this.width) {
-            if (this._updateTitleStyleLater)
-                return;
-
-            this._updateTitleStyleLater = Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
-                this._updateTitleStyleLater = 0;
-                this._title.add_style_class_name('lightweight');
-                return GLib.SOURCE_REMOVE;
-            });
-        }
+    get icon_uri() {
+        return this._iconFile.get_uri();
     }
 
     set title(title) {
@@ -153,9 +131,6 @@ var WelcomeDialogContent = GObject.registerClass({
 
         _setLabel(this._title, title);
 
-        this._title.remove_style_class_name('lightweight');
-        this._updateTitleStyle();
-
         this.notify('title');
     }
 
@@ -167,8 +142,20 @@ var WelcomeDialogContent = GObject.registerClass({
         this.notify('description');
     }
 
-    set icon(icon) {
-        this._icon.gicon = icon;
+    set icon_uri(icon_uri) {
+        this._iconBin.destroy_all_children();
+
+        const resourceScale = this._iconBin.get_resource_scale();
+        let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
+        this._iconFile = Gio.File.new_for_uri(icon_uri);
+        let texture = St.TextureCache.get_default().load_file_async(this._iconFile,
+                                                                    -1, -1,
+                                                                    scaleFactor,
+                                                                    resourceScale);
+        texture.x_align = Clutter.ActorAlign.CENTER;
+        texture.y_align = Clutter.ActorAlign.CENTER;
+        this._iconBin.add_child(texture);
+        this.notify('icon-uri');
     }
 });
 


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