From b68a28fbb02adc716eb6c00ad1338fc514fd39b5 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 9 Jul 2014 20:44:06 -0400 Subject: [PATCH] GtkColorSwatch: Respect an explicitly set size This will let us use a suitably sized color swatch in the color button. --- gtk/gtkcolorswatch.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c index ccee3ea122..2f97f94fc7 100644 --- a/gtk/gtkcolorswatch.c +++ b/gtk/gtkcolorswatch.c @@ -353,7 +353,14 @@ swatch_get_preferred_width (GtkWidget *widget, gint *min, gint *nat) { - *min = *nat = 48; + gint w, h; + + gtk_widget_get_size_request (widget, &w, &h); + + if (w < 0) + w = 48; + + *min = *nat = w; } static void @@ -361,7 +368,14 @@ swatch_get_preferred_height (GtkWidget *widget, gint *min, gint *nat) { - *min = *nat = 32; + gint w, h; + + gtk_widget_get_size_request (widget, &w, &h); + + if (h < 0) + h = 32; + + *min = *nat = h; } static gboolean