[gnome-panel] notification-area: set minimum size for icon



commit e2bd90ecfd9ea2c66f87a967652b4743f694789c
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Mon Oct 12 22:29:24 2015 +0300

    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

 applets/notification_area/na-tray-child.c |   53 ++++++++++++++++-------------
 1 files changed, 29 insertions(+), 24 deletions(-)
---
diff --git a/applets/notification_area/na-tray-child.c b/applets/notification_area/na-tray-child.c
index 5502b7e..8684d39 100644
--- a/applets/notification_area/na-tray-child.c
+++ b/applets/notification_area/na-tray-child.c
@@ -95,34 +95,37 @@ na_tray_child_style_set (GtkWidget *widget,
    */
 }
 
-#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
- * it can be reenabled. On other hand, things seem to be working fine without
- * it.
- *
- * If reenabling, you need to hook it up in na_tray_child_class_init().
- */
 static void
-na_tray_child_size_request (GtkWidget      *widget,
-                            GtkRequisition *request)
+na_tray_child_get_preferred_width (GtkWidget *widget,
+                                   gint      *minimal_width,
+                                   gint      *natural_width)
 {
-  GTK_WIDGET_CLASS (na_tray_child_parent_class)->size_request (widget, request);
+  GTK_WIDGET_CLASS (na_tray_child_parent_class)->get_preferred_width (widget,
+                                                                      minimal_width,
+                                                                      natural_width);
 
-  /*
-   * Make sure the icons have a meaningful size ..
-   */ 
-  if ((request->width < 16) || (request->height < 16))
-    {
-      gint nw = MAX (24, request->width);
-      gint nh = MAX (24, request->height);
-      g_warning ("Tray icon has requested a size of (%ix%i), resizing to (%ix%i)", 
-                 req.width, req.height, nw, nh);
-      request->width = nw;
-      request->height = nh;
-    }
+  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;
 }
-#endif
 
 static void
 na_tray_child_size_allocate (GtkWidget      *widget,
@@ -232,6 +235,8 @@ 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;
+  widget_class->get_preferred_width = na_tray_child_get_preferred_width;
+  widget_class->get_preferred_height = na_tray_child_get_preferred_height;
   widget_class->size_allocate = na_tray_child_size_allocate;
   widget_class->draw = na_tray_child_draw;
 }


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