You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This new attribute functions like the css_classes built-in property of a
Gtk.Widget, except it doesn't overwrite existing properties on an
object. This allows classes like Gtk.Box—which adds a .vertical CSS
class if it's oriented vertically—to function properly while setting CSS
classes in the constructor.
Copy file name to clipboardExpand all lines: LuaGObject/override/Gtk4.lua
+16Lines changed: 16 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,7 @@ Gtk.Widget._attribute = {
27
27
width= { get=Gtk.Widget.get_allocated_width },
28
28
height= { get=Gtk.Widget.get_allocated_height },
29
29
children= {},
30
+
extra_css_classes= {},
30
31
}
31
32
32
33
-- Allow to query a widget's currently-allocated dimensions by indexing .width or .height, and set the requested dimensions by assigning these pseudo-properties.
@@ -70,6 +71,21 @@ function Gtk.Widget._attribute.children:get()
Copy file name to clipboardExpand all lines: tests/gtk.lua
+11Lines changed: 11 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -134,3 +134,14 @@ function gtk.notebook_container()
134
134
check(notebook:get_nth_page(1) ==label2)
135
135
check(notebook:get_nth_page(2) ==label3)
136
136
end
137
+
138
+
functiongtk.extra_css_classes()
139
+
localGtk=LuaGObject.Gtk
140
+
localbox=Gtk.Box {
141
+
orientation="VERTICAL",
142
+
extra_css_classes= { "linked" },
143
+
}
144
+
check(box:has_css_class"linked")
145
+
-- The .vertical CSS class comes from setting the orientation to vertical. By checking it here, the test ensures that the existing class isn't overwritten by extra_css_classes.
0 commit comments