The previous code would include CSS padding/margin/border in the
measurement and that is wrong.
Until commit
a96c75ff02 this was not actually visible, but afterwards
listitems were allocated 16px too wide.
Test included
}
/* step 1: determine width of the list */
- gtk_widget_measure (widget, opposite_orientation,
- -1,
- &min, &nat, NULL, NULL);
+ gtk_list_view_measure_across (widget, opposite_orientation,
+ -1,
+ &min, &nat);
self->list_width = orientation == GTK_ORIENTATION_VERTICAL ? width : height;
if (opposite_scroll_policy == GTK_SCROLL_MINIMUM)
self->list_width = MAX (min, self->list_width);
--- /dev/null
+listview, box {
+ margin: 50px;
+ padding: 50px;
+}
+
+row {
+ all: unset;
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <object class="GtkWindow">
+ <property name="decorated">0</property>
+ <property name="child">
+ <object class="GtkBox">
+ <style>
+ <class name="view"/>
+ </style>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="xalign">1</property>
+ <property name="label">One</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="xalign">1</property>
+ <property name="label">Two</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="xalign">1</property>
+ <property name="label">Three</property>
+ </object>
+ </child>
+ </object>
+ </property>
+ </object>
+</interface>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <object class="GtkWindow">
+ <property name="decorated">0</property>
+ <property name="child">
+ <object class="GtkListView">
+ <property name="model">
+ <object class="GtkNoSelection">
+ <property name="model">
+ <object class="GtkStringList">
+ <items>
+ <item translatable="yes">One</item>
+ <item translatable="yes">Two</item>
+ <item translatable="yes">Three</item>
+ </items>
+ </object>
+ </property>
+ </object>
+ </property>
+ <property name="factory">
+ <object class="GtkBuilderListItemFactory">
+ <property name="bytes"><![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="GtkListItem">
+ <property name="child">
+ <object class="GtkLabel">
+ <property name="xalign">1</property>
+ <binding name="label">
+ <lookup name="string" type="GtkStringObject">
+ <lookup name="item">GtkListItem</lookup>
+ </lookup>
+ </binding>
+ </object>
+ </property>
+ </template>
+</interface>
+ ]]></property>
+ </object>
+ </property>
+ </object>
+ </property>
+ </object>
+</interface>
'link-coloring.css',
'link-coloring.ref.ui',
'link-coloring.ui',
+ 'listview-margin.css',
+ 'listview-margin.ref.ui',
+ 'listview-margin.ui',
'listview-with-wrapped-labels.ref.ui',
'listview-with-wrapped-labels.ui',
'marble.xpm',