[polari] messageInfoBar: Replace markup with typography styles



commit c5ffb4bea7b7d8c8064aaf9b9474a828a540685f
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Mar 19 00:09:53 2022 +0100

    messageInfoBar: Replace markup with typography styles
    
    libadwaita defines a set of style classes as part of its API, including
    a set of typography styles for labels. Use those instead of pango markup
    for better platform consistency.
    
    As a bonus, we can drop the custom setters as we no longer add markup
    to the title, so we can simply bind the property.
    
    Part-of: <https://gitlab.gnome.org/GNOME/polari/-/merge_requests/250>

 src/appNotifications.js | 41 ++++++++---------------------------------
 1 file changed, 8 insertions(+), 33 deletions(-)
---
diff --git a/src/appNotifications.js b/src/appNotifications.js
index 0c26aecf..9b40559c 100644
--- a/src/appNotifications.js
+++ b/src/appNotifications.js
@@ -171,10 +171,9 @@ class MessageInfoBar extends Gtk.InfoBar {
         this.add_child(box);
 
         this._titleLabel = new Gtk.Label({
+            css_classes: ['heading'],
             halign: Gtk.Align.START,
             valign: Gtk.Align.CENTER,
-            label: `<b>${this._title}</b>`,
-            use_markup: true,
             wrap: true,
         });
         box.append(this._titleLabel);
@@ -182,41 +181,17 @@ class MessageInfoBar extends Gtk.InfoBar {
         this._subtitleLabel = new Gtk.Label({
             halign: Gtk.Align.START,
             valign: Gtk.Align.CENTER,
-            label: this._subtitle,
             ellipsize: Pango.EllipsizeMode.END,
         });
         box.append(this._subtitleLabel);
 
-        this.connect('response', () => (this.revealed = false));
-    }
-
-    get title() {
-        return this._title;
-    }
+        this.bind_property('title',
+            this._titleLabel, 'label',
+            GObject.BindingFlags.SYNC_CREATE);
+        this.bind_property('subtitle',
+            this._subtitleLabel, 'label',
+            GObject.BindingFlags.SYNC_CREATE);
 
-    set title(title) {
-        if (this._title === title)
-            return;
-
-        this._title = title;
-        this.notify('title');
-
-        if (this._titleLabel)
-            this._titleLabel.label = `<b>${title}</b>`;
-    }
-
-    get subtitle() {
-        return this._subtitle;
-    }
-
-    set subtitle(subtitle) {
-        if (this._subtitle === subtitle)
-            return;
-
-        this._subtitle = subtitle;
-        this.notify('subtitle');
-
-        if (this._subtitleLabel)
-            this._subtitleLabel.label = subtitle;
+        this.connect('response', () => (this.revealed = false));
     }
 });


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