[gtk+/wip/baedert/drawing: 183/188] checkbutton: Don't use parent button's gadget



commit 33370e15632bc22ca52e1ad12e21a117cb0a2c98
Author: Timm Bäder <mail baedert org>
Date:   Thu May 4 09:03:04 2017 +0200

    checkbutton: Don't use parent button's gadget
    
    check buttons showing their indicator still use the internal boxgadget
    and have therefore the wrong size, but this gets us closer.

 gtk/gtkcheckbutton.c |   55 +++++++++++++++++++++++++------------------------
 1 files changed, 28 insertions(+), 27 deletions(-)
---
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index c0fd793..1320170 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -197,18 +197,21 @@ gtk_check_button_measure (GtkWidget      *widget,
                           int            *natural_baseline)
 {
   GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (GTK_CHECK_BUTTON (widget));
-  GtkCssGadget *gadget;
 
   if (priv->draw_indicator)
-    gadget = priv->gadget;
+    {
+      gtk_css_gadget_get_preferred_size (priv->gadget,
+                                         orientation,
+                                         for_size,
+                                         minimum, natural,
+                                         minimum_baseline, natural_baseline);
+    }
   else
-    gadget = GTK_BUTTON (widget)->priv->gadget;
-
-  gtk_css_gadget_get_preferred_size (gadget,
-                                     orientation,
-                                     for_size,
-                                     minimum, natural,
-                                     minimum_baseline, natural_baseline);
+    {
+      GTK_WIDGET_CLASS (gtk_check_button_parent_class)->measure (widget, orientation, for_size,
+                                                                 minimum, natural,
+                                                                 minimum_baseline, natural_baseline);
+    }
 }
 
 static void
@@ -412,32 +415,30 @@ gtk_check_button_size_allocate (GtkWidget     *widget,
                                GtkAllocation *allocation)
 {
   GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (GTK_CHECK_BUTTON (widget));
-  GtkButton *button = GTK_BUTTON (widget);
-  GtkCssGadget *gadget;
   GdkRectangle clip;
 
   if (priv->draw_indicator)
-    gadget = priv->gadget;
+    {
+      gtk_css_gadget_allocate (priv->gadget,
+                               allocation,
+                               gtk_widget_get_allocated_baseline (widget),
+                               &clip);
+      gtk_widget_set_clip (widget, &clip);
+    }
   else
-    gadget = button->priv->gadget;
-
-  gtk_widget_set_allocation (widget, allocation);
-  gtk_css_gadget_allocate (gadget,
-                           allocation,
-                           gtk_widget_get_allocated_baseline (widget),
-                           &clip);
-
-  gtk_widget_set_clip (widget, &clip);
+    {
+      GTK_WIDGET_CLASS (gtk_check_button_parent_class)->size_allocate (widget, allocation);
+    }
 
   if (gtk_widget_get_realized (widget))
     {
-      GtkAllocation border_allocation;
-      gtk_css_gadget_get_border_allocation (gadget, &border_allocation, NULL);
+      GtkAllocation widget_allocation;
+      gtk_widget_get_allocation (widget, &widget_allocation);
       gdk_window_move_resize (GTK_BUTTON (widget)->priv->event_window,
-                              border_allocation.x,
-                              border_allocation.y,
-                              border_allocation.width,
-                              border_allocation.height);
+                              widget_allocation.x,
+                              widget_allocation.y,
+                              widget_allocation.width,
+                              widget_allocation.height);
     }
 }
 


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