[gnome-characters/bilelmoussaoui/gtk4: 33/71] sidebar row: cleanup accessibility stuff




commit 2ae717c652723778ae6a4d24b283420943496508
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date:   Mon Nov 22 08:42:50 2021 +0100

    sidebar row: cleanup accessibility stuff

 src/sidebarRow.js | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/src/sidebarRow.js b/src/sidebarRow.js
index 9c37008..e79e41f 100644
--- a/src/sidebarRow.js
+++ b/src/sidebarRow.js
@@ -43,24 +43,34 @@ var SidebarRow = GObject.registerClass({
     },
 }, class SidebarRow extends Gtk.ListBoxRow {
     _init() {
-        super._init();
-        /* this.get_accessible().accessible_name =
-            _('%s Category List Row').format(category.title);*/
+        super._init({
+            accessible_role: Gtk.AccessibleRole.ROW,
+        });
 
         let hbox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL });
-        this.set_child(hbox);
+
         let image = Gtk.Image.new();
         this.bind_property('icon-name', image, 'icon-name',
-            GObject.BindingFlags.DEFAULT | GObject.BindingFlags.SYNC_CREATE);
+            GObject.BindingFlags.DEFAULT | GObject.BindingFlags.SYNC_CREATE,
+        );
         image.set_icon_size(Gtk.IconSize.LARGE_TOOLBAR);
         image.add_css_class('category-icon');
         hbox.append(image);
 
         let label = new Gtk.Label({ halign: Gtk.Align.START });
-        this.bind_property('title', label, 'label', GObject.BindingFlags.DEFAULT | 
GObject.BindingFlags.SYNC_CREATE);
+        this.bind_property('title', label, 'label',
+            GObject.BindingFlags.DEFAULT | GObject.BindingFlags.SYNC_CREATE,
+        );
+        // Because bind_property doesn't work with transform functions
+        // TODO: is this really needed?
+        this.connect('notify::title', (row) => {
+            row.tooltip_text = _('%s Sidebar Row').format(row.title);
+        });
+
         label.add_css_class('category-label');
         hbox.append(label);
 
+        this.set_child(hbox);
         this.add_css_class('category');
     }
 


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