Correctly implement get_preferred_width

This commit is contained in:
Jesse van den Kieboom 2014-01-04 23:26:07 +01:00
parent 9a8a4687fb
commit db31d577f9
2 changed files with 18 additions and 12 deletions

View file

@ -42,16 +42,18 @@ namespace Gitg
LabelRenderer.width(widget, font_desc, labels);
}
public override void get_size(Gtk.Widget widget,
Gdk.Rectangle? area,
out int xoffset,
out int yoffset,
out int width,
out int height)
public override void get_preferred_width(Gtk.Widget widget,
out int minimum_width,
out int natural_width)
{
base.get_size(widget, area, out xoffset, out yoffset, out width, out height);
base.get_preferred_width(widget, out minimum_width, out natural_width);
width += (int)total_width(widget);
var w = (int)total_width(widget);
if (w > minimum_width)
{
minimum_width = w;
}
}
private void draw_arrow(Cairo.Context context,

View file

@ -282,17 +282,21 @@ public class SidebarRendererText : Gtk.CellRendererText
protected override void get_preferred_width(Gtk.Widget widget,
out int minimum_width,
out int minimum_height)
out int natural_width)
{
ensure_pixbuf(widget.get_style_context());
// Size of text
base.get_preferred_width(widget, out minimum_width, out minimum_height);
base.get_preferred_width(widget, out minimum_width, out natural_width);
if (d_pixbuf != null)
{
minimum_width += d_pixbuf.get_width() + 3;
minimum_height += d_pixbuf.get_height();
var w = d_pixbuf.get_width() + 3;
if (w > minimum_width)
{
minimum_width = w;
}
}
}