File tree Expand file tree Collapse file tree 1 file changed +35
-1
lines changed
Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Original file line number Diff line number Diff line change 99 * @since 7.7.0
1010 */
1111[Version (since = " 7.7.0" )]
12- public class Granite.ListItem : Granite . Bin {
12+ public class Granite.ListItem : Gtk . Widget {
1313 /**
1414 * The main label for #this
1515 */
@@ -20,8 +20,36 @@ public class Granite.ListItem : Granite.Bin {
2020 */
2121 public string ? description { get ; set ; }
2222
23+ private Gtk . Widget ? _child;
24+ /**
25+ * The child widget of #this
26+ */
27+ public Gtk . Widget ? child {
28+ get {
29+ return _child;
30+ }
31+
32+ set {
33+ if (value != null && value . get_parent () != null ) {
34+ critical (" Tried to set a widget as child that already has a parent." );
35+ return ;
36+ }
37+
38+ if (_child != null ) {
39+ _child. unparent ();
40+ }
41+
42+ _child = value ;
43+
44+ if (_child != null ) {
45+ _child. set_parent (this );
46+ }
47+ }
48+ }
49+
2350 class construct {
2451 set_css_name ("granite -listitem ");
52+ set_layout_manager_type (typeof (Gtk .BinLayout ));
2553 }
2654
2755 construct {
@@ -59,4 +87,10 @@ public class Granite.ListItem : Granite.Bin {
5987 }
6088 });
6189 }
90+
91+ ~ListItem () {
92+ if (child != null ) {
93+ child. unparent ();
94+ }
95+ }
6296}
You can’t perform that action at this time.
0 commit comments