[gnome-panel/16x16] Make notification icons be 16x16



commit 49d1346d15a92967aa221049599bac7385caecbc
Author: Ryan Lortie <desrt desrt ca>
Date:   Tue Mar 29 09:57:08 2011 +0530

    Make notification icons be 16x16
    
    Don't land this patch.  It has 16 hardcoded and it breaks Fitt's law.

 applets/notification_area/na-tray-child.c |   55 ++++++++++++++++------------
 1 files changed, 31 insertions(+), 24 deletions(-)
---
diff --git a/applets/notification_area/na-tray-child.c b/applets/notification_area/na-tray-child.c
index 1042940..bbc2126 100644
--- a/applets/notification_area/na-tray-child.c
+++ b/applets/notification_area/na-tray-child.c
@@ -97,34 +97,27 @@ 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,
+                                   gint           *natural)
 {
-  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, natural);
 
-  /*
-   * 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;
-    }
+  *minimal = *natural = 16;
+}
+
+static void
+na_tray_child_get_preferred_height (GtkWidget      *widget,
+                                    gint           *minimal,
+                                    gint           *natural)
+{
+  GTK_WIDGET_CLASS (na_tray_child_parent_class)
+    ->get_preferred_height (widget, minimal, natural);
+
+  *minimal = *natural = 16;
 }
-#endif
 
 static void
 na_tray_child_size_allocate (GtkWidget      *widget,
@@ -134,6 +127,18 @@ na_tray_child_size_allocate (GtkWidget      *widget,
   GtkAllocation widget_allocation;
   gboolean moved, resized;
 
+  if (allocation->width > 16)
+    {
+      allocation->x += (allocation->width - 16) / 2;
+      allocation->width = 16;
+    }
+
+  if (allocation->height > 16)
+    {
+      allocation->y += (allocation->height - 16) / 2;
+      allocation->height = 16;
+    }
+
   gtk_widget_get_allocation (widget, &widget_allocation);
 
   moved = (allocation->x != widget_allocation.x ||
@@ -234,6 +239,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]