]> Pileus Git - ~andy/gtk/commitdiff
Only shorten the label if it actually overlaps the resize grip.
authorMatthias Clasen <mclasen@redhat.com>
Wed, 10 Nov 2004 16:33:33 +0000 (16:33 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Wed, 10 Nov 2004 16:33:33 +0000 (16:33 +0000)
2004-11-10  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtkstatusbar.c (gtk_statusbar_size_allocate): Only
shorten the label if it actually overlaps the resize grip.
(gtk_statusbar_size_allocate): Handle extra children
by leaving room for the resize grip.  (#157778, Christian Persch)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkstatusbar.c

index 37313d3fbe88c795eed11b5f788f3dc116e7d6d8..8ff34d80b61cd9ac3ced9aba8d045d06bd670311 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
 
        * gtk/gtkstatusbar.c (gtk_statusbar_size_allocate): Only
        shorten the label if it actually overlaps the resize grip.
+       (gtk_statusbar_size_allocate): Handle extra children
+       by leaving room for the resize grip.  (#157778, Christian Persch)
 
        * gdk/linux-fb/*: Fix many sparse warnings.  (#157253,
        Kjartan Maraas.
index 37313d3fbe88c795eed11b5f788f3dc116e7d6d8..8ff34d80b61cd9ac3ced9aba8d045d06bd670311 100644 (file)
@@ -2,6 +2,8 @@
 
        * gtk/gtkstatusbar.c (gtk_statusbar_size_allocate): Only
        shorten the label if it actually overlaps the resize grip.
+       (gtk_statusbar_size_allocate): Handle extra children
+       by leaving room for the resize grip.  (#157778, Christian Persch)
 
        * gdk/linux-fb/*: Fix many sparse warnings.  (#157253,
        Kjartan Maraas.
index 37313d3fbe88c795eed11b5f788f3dc116e7d6d8..8ff34d80b61cd9ac3ced9aba8d045d06bd670311 100644 (file)
@@ -2,6 +2,8 @@
 
        * gtk/gtkstatusbar.c (gtk_statusbar_size_allocate): Only
        shorten the label if it actually overlaps the resize grip.
+       (gtk_statusbar_size_allocate): Handle extra children
+       by leaving room for the resize grip.  (#157778, Christian Persch)
 
        * gdk/linux-fb/*: Fix many sparse warnings.  (#157253,
        Kjartan Maraas.
index 37313d3fbe88c795eed11b5f788f3dc116e7d6d8..8ff34d80b61cd9ac3ced9aba8d045d06bd670311 100644 (file)
@@ -2,6 +2,8 @@
 
        * gtk/gtkstatusbar.c (gtk_statusbar_size_allocate): Only
        shorten the label if it actually overlaps the resize grip.
+       (gtk_statusbar_size_allocate): Handle extra children
+       by leaving room for the resize grip.  (#157778, Christian Persch)
 
        * gdk/linux-fb/*: Fix many sparse warnings.  (#157253,
        Kjartan Maraas.
index 0844335f6c6c6a342e8ec747dee57024b0b01f66..8c29f93fff9a9209d5c53d6d864af535d62328f8 100644 (file)
@@ -763,38 +763,96 @@ gtk_statusbar_size_request   (GtkWidget      *widget,
   GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
 }
 
+/* look for extra children between the frame containing
+ * the label and where we want to draw the resize grip 
+ */
+static gboolean
+has_extra_children (GtkStatusbar *statusbar)
+{
+  GList *l;
+  GtkBoxChild *child, *frame;
+
+  frame = NULL;
+  for (l = GTK_BOX (statusbar)->children; l; l = l->next)
+    {
+      frame = l->data;
+
+      if (frame->widget == statusbar->frame)
+       break;
+    }
+  
+  for (l = l->next; l; l = l->next)
+    {
+      child = l->data;
+
+      if (!GTK_WIDGET_VISIBLE (child->widget))
+       continue;
+
+      if (frame->pack == GTK_PACK_START || child->pack == GTK_PACK_END)
+       return TRUE;
+    }
+
+  return FALSE;
+}
+
 static void
 gtk_statusbar_size_allocate  (GtkWidget     *widget,
                               GtkAllocation *allocation)
 {
-  GtkStatusbar *statusbar;
-  
-  statusbar = GTK_STATUSBAR (widget);
+  GtkStatusbar *statusbar = GTK_STATUSBAR (widget);
+  gboolean extra_children;
+  GdkRectangle rect, overlap;
 
+  if (statusbar->has_resize_grip && statusbar->grip_window)
+    {
+      widget->allocation = *allocation;
+      get_grip_rect (statusbar, &rect);    
+      
+      extra_children = has_extra_children (statusbar);
+      
+      /* If there are extra children, we don't want them to occupy
+       * the space where we draw the resize grip, so we temporarily
+       * shrink the allocation.
+       * If there are no extra children, we want the frame to get
+       * the full allocation, and we fix up the allocation of the
+       * label afterwards to make room for the grip.
+       */
+      if (extra_children)
+       {
+         allocation->width -= rect.width;
+         if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) 
+           allocation->x += rect.width;
+       }
+    }
+      
   /* chain up normally */
   GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
 
   if (statusbar->has_resize_grip && statusbar->grip_window)
     {
-      GdkRectangle rect, overlap;
-      GtkAllocation allocation;
-      
-      get_grip_rect (statusbar, &rect);
-      
       gdk_window_raise (statusbar->grip_window);
       gdk_window_move_resize (statusbar->grip_window,
                              rect.x, rect.y,
                              rect.width, rect.height);
-      
-      allocation = statusbar->label->allocation;
-      if (gdk_rectangle_intersect (&rect, &allocation, &overlap))
-      {
-       allocation.width -= rect.width;
-       if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) 
-         allocation.x += rect.width;
-       
-       gtk_widget_size_allocate (statusbar->label, &allocation);
-      }
+
+      if (extra_children) 
+       {
+         allocation->width += rect.width;
+         if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) 
+           allocation->x -= rect.width;
+         
+         widget->allocation = *allocation;
+       }
+      else
+       {
+         /* shrink the label to make room for the grip */
+         *allocation = statusbar->label->allocation;
+         allocation->width -= rect.width;
+         if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) 
+           allocation->x += rect.width;
+         
+         gtk_widget_size_allocate (statusbar->label, allocation);
+       }
     }
 }