diff options
author | Matthias Clasen <mclasen@redhat.com> | 2004-11-10 16:33:33 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2004-11-10 16:33:33 +0000 |
commit | b1941d1233d2a445814c927651076b35b67003d1 (patch) | |
tree | caba2be2300324ef0177bd5257d7eb58fc3af725 | |
parent | 06d507703db1778c6ebae2120b3e6295e60bc7bd (diff) | |
download | gtk+-b1941d1233d2a445814c927651076b35b67003d1.tar.gz |
Only shorten the label if it actually overlaps the resize grip.
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)
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 2 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 2 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 2 | ||||
-rw-r--r-- | gtk/gtkstatusbar.c | 94 |
5 files changed, 84 insertions, 18 deletions
@@ -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. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 37313d3fbe..8ff34d80b6 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -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. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 37313d3fbe..8ff34d80b6 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -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. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 37313d3fbe..8ff34d80b6 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -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. diff --git a/gtk/gtkstatusbar.c b/gtk/gtkstatusbar.c index 0844335f6c..8c29f93fff 100644 --- a/gtk/gtkstatusbar.c +++ b/gtk/gtkstatusbar.c @@ -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); + } } } |