[gtk/wip/otte/css: 44/48] cellrenderertoggle: size based on -gtk-icon-size



commit aff25212df78271b71db543f4d61947f1d4b6d68
Author: Benjamin Otte <otte redhat com>
Date:   Mon Jan 27 17:13:04 2020 +0100

    cellrenderertoggle: size based on -gtk-icon-size
    
    Instead of hardcoding 16px.

 gtk/gtkcellrenderertoggle.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)
---
diff --git a/gtk/gtkcellrenderertoggle.c b/gtk/gtkcellrenderertoggle.c
index f1658cee3f..224022f56c 100644
--- a/gtk/gtkcellrenderertoggle.c
+++ b/gtk/gtkcellrenderertoggle.c
@@ -19,6 +19,7 @@
 
 #include "gtkcellrenderertoggle.h"
 
+#include "gtkcssnumbervalueprivate.h"
 #include "gtkintl.h"
 #include "gtkmarshalers.h"
 #include "gtkprivate.h"
@@ -86,8 +87,6 @@ enum {
   PROP_INCONSISTENT
 };
 
-#define TOGGLE_WIDTH 16
-
 static guint toggle_cell_signals[LAST_SIGNAL] = { 0 };
 
 typedef struct _GtkCellRendererTogglePrivate       GtkCellRendererTogglePrivate;
@@ -316,20 +315,11 @@ gtk_cell_renderer_toggle_save_context (GtkCellRenderer *cell,
   return context;
 }
  
-static void
-calc_indicator_size (GtkStyleContext *context,
-                     gint            *width,
-                     gint            *height)
+static int
+calc_indicator_size (GtkStyleContext *context)
 {
-  gtk_style_context_get (context, 
-                         "min-width", width,
-                         "min-height", height,
-                         NULL);
-
-  if (*width == 0)
-    *width = TOGGLE_WIDTH;
-  if (*height == 0)
-    *height = TOGGLE_WIDTH;
+  GtkCssStyle *style = gtk_style_context_lookup_style (context);
+  return _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ICON_SIZE), 100);
 }
 
 static void
@@ -353,7 +343,7 @@ gtk_cell_renderer_toggle_get_size (GtkCellRenderer    *cell,
   gtk_style_context_get_padding (context, &padding);
   gtk_style_context_get_border (context, &border);
 
-  calc_indicator_size (context, &calc_width, &calc_height);
+  calc_width = calc_height = calc_indicator_size (context);
   calc_width += xpad * 2 + padding.left + padding.right + border.left + border.right;
   calc_height += ypad * 2 + padding.top + padding.bottom + border.top + border.bottom;
 


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