From 4932ed52b70b540bd58e6405550ea2e758c1d003 Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Thu, 11 Feb 2016 07:47:44 +0100 Subject: GTK+3 notification-area: set minimum size for icon Fix for following warning from GtkStatusIcon: gtk_widget_size_allocate(): attempt to allocate widget with width -3 and height 26. https://bugzilla.gnome.org/show_bug.cgi?id=755129 taken from: https://git.gnome.org/browse/gnome-panel/commit/?id=e2bd90e --- applets/notification_area/na-tray-child.c | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/applets/notification_area/na-tray-child.c b/applets/notification_area/na-tray-child.c index 9ff5c739..76a360f5 100644 --- a/applets/notification_area/na-tray-child.c +++ b/applets/notification_area/na-tray-child.c @@ -113,6 +113,39 @@ na_tray_child_style_set (GtkWidget *widget, */ } +#if GTK_CHECK_VERSION (3, 0, 0) +static void +na_tray_child_get_preferred_width (GtkWidget *widget, + gint *minimal_width, + gint *natural_width) +{ + GTK_WIDGET_CLASS (na_tray_child_parent_class)->get_preferred_width (widget, + minimal_width, + natural_width); + + if (*minimal_width < 16) + *minimal_width = 16; + + if (*natural_width < 16) + *natural_width = 16; +} + +static void +na_tray_child_get_preferred_height (GtkWidget *widget, + gint *minimal_height, + gint *natural_height) +{ + GTK_WIDGET_CLASS (na_tray_child_parent_class)->get_preferred_height (widget, + minimal_height, + natural_height); + + if (*minimal_height < 16) + *minimal_height = 16; + + if (*natural_height < 16) + *natural_height = 16; +} +#else #if 0 /* This is adapted from code that was commented out in na-tray-manager.c; the * code in na-tray-manager.c wouldn't have worked reliably, this will. So maybe @@ -141,6 +174,7 @@ na_tray_child_size_request (GtkWidget *widget, } } #endif +#endif static void na_tray_child_size_allocate (GtkWidget *widget, @@ -272,6 +306,10 @@ na_tray_child_class_init (NaTrayChildClass *klass) gobject_class->finalize = na_tray_child_finalize; widget_class->style_set = na_tray_child_style_set; widget_class->realize = na_tray_child_realize; +#if GTK_CHECK_VERSION (3, 0, 0) + widget_class->get_preferred_width = na_tray_child_get_preferred_width; + widget_class->get_preferred_height = na_tray_child_get_preferred_height; +#endif widget_class->size_allocate = na_tray_child_size_allocate; #if GTK_CHECK_VERSION (3, 0, 0) widget_class->draw = na_tray_child_draw; -- cgit v1.2.1