diff --git a/src/Grid/VAutoHider.vala b/src/Grid/VAutoHider.vala index f8ea73b8f..8b985e2b8 100644 --- a/src/Grid/VAutoHider.vala +++ b/src/Grid/VAutoHider.vala @@ -7,10 +7,13 @@ */ public class Maya.View.VAutoHider : Gtk.Bin { + private List children; private Gtk.Label more_label; private Gtk.Box main_box; construct { + children = new List (); + more_label = new Gtk.Label ("") { valign = END }; @@ -22,14 +25,10 @@ public class Maya.View.VAutoHider : Gtk.Bin { } public override void add (Gtk.Widget widget) { - var children = main_box.get_children (); children.append (widget); - - children.sort (compare_children); - - int index = children.index (widget); main_box.add (widget); - main_box.reorder_child (widget, index); + + update (widget); widget.destroy.connect (() => { queue_resize (); @@ -39,8 +38,6 @@ public class Maya.View.VAutoHider : Gtk.Bin { } public void update (Gtk.Widget widget) { - var children = main_box.get_children (); - children.sort (compare_children); int index = children.index (widget); @@ -50,7 +47,7 @@ public class Maya.View.VAutoHider : Gtk.Bin { public override void size_allocate (Gtk.Allocation allocation) { base.size_allocate (allocation); - int children_length = (int) main_box.get_children ().length () - 1; + int children_length = (int) children.length (); if (children_length == 0) { more_label.hide (); return; @@ -64,7 +61,7 @@ public class Maya.View.VAutoHider : Gtk.Bin { int shown_children = 0; int shown_children_height = 0; - foreach (var child in main_box.get_children ()) { + foreach (var child in children) { if (child == more_label) { continue; } @@ -97,15 +94,17 @@ public class Maya.View.VAutoHider : Gtk.Bin { public override void get_preferred_width (out int minimum_width, out int natural_width) { base.get_preferred_width (out minimum_width, out natural_width); more_label.get_preferred_width (out minimum_width, null); - if (minimum_width > natural_width) + if (minimum_width > natural_width) { natural_width = minimum_width; + } } public override void get_preferred_height (out int minimum_height, out int natural_height) { base.get_preferred_height (out minimum_height, out natural_height); more_label.get_preferred_height (out minimum_height, null); - if (minimum_height > natural_height) + if (minimum_height > natural_height) { natural_height = minimum_height; + } } public static GLib.CompareFunc compare_children = (a, b) => {