[gitg] Correctly implement get_preferred_width



commit db31d577f9a6ba0ef53e8d99dd0ba98d7ab6a59e
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Sat Jan 4 23:26:07 2014 +0100

    Correctly implement get_preferred_width

 libgitg/gitg-cell-renderer-lanes.vala |   18 ++++++++++--------
 libgitg/gitg-sidebar.vala             |   12 ++++++++----
 2 files changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/libgitg/gitg-cell-renderer-lanes.vala b/libgitg/gitg-cell-renderer-lanes.vala
index 8783ca7..9f09d05 100644
--- a/libgitg/gitg-cell-renderer-lanes.vala
+++ b/libgitg/gitg-cell-renderer-lanes.vala
@@ -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,
diff --git a/libgitg/gitg-sidebar.vala b/libgitg/gitg-sidebar.vala
index 4646e72..8c46ccc 100644
--- a/libgitg/gitg-sidebar.vala
+++ b/libgitg/gitg-sidebar.vala
@@ -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;
+                       }
                }
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]