1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 * GtkStatusbar Copyright (C) 1998 Shawn T. Amundson
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
23 * file for a list of people on the GTK+ Team. See the ChangeLog
24 * files for a list of changes. These files are distributed with
25 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
31 #include "gtkmarshalers.h"
32 #include "gtkstatusbar.h"
33 #include "gtkwindow.h"
34 #include "gtkprivate.h"
36 #include "gtkbuildable.h"
39 typedef struct _GtkStatusbarMsg GtkStatusbarMsg;
41 struct _GtkStatusbarMsg
61 static void gtk_statusbar_buildable_interface_init (GtkBuildableIface *iface);
62 static GObject *gtk_statusbar_buildable_get_internal_child (GtkBuildable *buildable,
64 const gchar *childname);
65 static void gtk_statusbar_destroy (GtkObject *object);
66 static void gtk_statusbar_update (GtkStatusbar *statusbar,
69 static void gtk_statusbar_size_allocate (GtkWidget *widget,
70 GtkAllocation *allocation);
71 static void gtk_statusbar_realize (GtkWidget *widget);
72 static void gtk_statusbar_unrealize (GtkWidget *widget);
73 static void gtk_statusbar_map (GtkWidget *widget);
74 static void gtk_statusbar_unmap (GtkWidget *widget);
75 static gboolean gtk_statusbar_button_press (GtkWidget *widget,
76 GdkEventButton *event);
77 static gboolean gtk_statusbar_expose_event (GtkWidget *widget,
78 GdkEventExpose *event);
79 static void gtk_statusbar_size_request (GtkWidget *widget,
80 GtkRequisition *requisition);
81 static void gtk_statusbar_size_allocate (GtkWidget *widget,
82 GtkAllocation *allocation);
83 static void gtk_statusbar_direction_changed (GtkWidget *widget,
84 GtkTextDirection prev_dir);
85 static void gtk_statusbar_state_changed (GtkWidget *widget,
86 GtkStateType previous_state);
87 static void gtk_statusbar_create_window (GtkStatusbar *statusbar);
88 static void gtk_statusbar_destroy_window (GtkStatusbar *statusbar);
89 static void gtk_statusbar_get_property (GObject *object,
93 static void gtk_statusbar_set_property (GObject *object,
97 static void label_selectable_changed (GtkWidget *label,
102 static guint statusbar_signals[SIGNAL_LAST] = { 0 };
104 G_DEFINE_TYPE_WITH_CODE (GtkStatusbar, gtk_statusbar, GTK_TYPE_HBOX,
105 G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
106 gtk_statusbar_buildable_interface_init));
109 gtk_statusbar_class_init (GtkStatusbarClass *class)
111 GObjectClass *gobject_class;
112 GtkObjectClass *object_class;
113 GtkWidgetClass *widget_class;
115 gobject_class = (GObjectClass *) class;
116 object_class = (GtkObjectClass *) class;
117 widget_class = (GtkWidgetClass *) class;
119 gobject_class->set_property = gtk_statusbar_set_property;
120 gobject_class->get_property = gtk_statusbar_get_property;
122 object_class->destroy = gtk_statusbar_destroy;
124 widget_class->realize = gtk_statusbar_realize;
125 widget_class->unrealize = gtk_statusbar_unrealize;
126 widget_class->map = gtk_statusbar_map;
127 widget_class->unmap = gtk_statusbar_unmap;
128 widget_class->button_press_event = gtk_statusbar_button_press;
129 widget_class->expose_event = gtk_statusbar_expose_event;
130 widget_class->size_request = gtk_statusbar_size_request;
131 widget_class->size_allocate = gtk_statusbar_size_allocate;
132 widget_class->direction_changed = gtk_statusbar_direction_changed;
133 widget_class->state_changed = gtk_statusbar_state_changed;
135 class->text_pushed = gtk_statusbar_update;
136 class->text_popped = gtk_statusbar_update;
139 * GtkStatusbar:has-resize-grip:
141 * Whether the statusbar has a grip for resizing the toplevel window.
145 g_object_class_install_property (gobject_class,
146 PROP_HAS_RESIZE_GRIP,
147 g_param_spec_boolean ("has-resize-grip",
148 P_("Has Resize Grip"),
149 P_("Whether the statusbar has a grip for resizing the toplevel"),
151 GTK_PARAM_READWRITE));
154 * GtkStatusbar::text-pushed:
155 * @statusbar: the object which received the signal.
156 * @context_id: the context id of the relevant message/statusbar.
157 * @text: the message that was pushed.
159 * Is emitted whenever a new message gets pushed onto a statusbar's stack.
161 statusbar_signals[SIGNAL_TEXT_PUSHED] =
162 g_signal_new (I_("text-pushed"),
163 G_OBJECT_CLASS_TYPE (class),
165 G_STRUCT_OFFSET (GtkStatusbarClass, text_pushed),
167 _gtk_marshal_VOID__UINT_STRING,
173 * GtkStatusbar::text-popped:
174 * @statusbar: the object which received the signal.
175 * @context_id: the context id of the relevant message/statusbar.
176 * @text: the message that was just popped.
178 * Is emitted whenever a new message is popped off a statusbar's stack.
180 statusbar_signals[SIGNAL_TEXT_POPPED] =
181 g_signal_new (I_("text-popped"),
182 G_OBJECT_CLASS_TYPE (class),
184 G_STRUCT_OFFSET (GtkStatusbarClass, text_popped),
186 _gtk_marshal_VOID__UINT_STRING,
191 gtk_widget_class_install_style_property (widget_class,
192 g_param_spec_enum ("shadow-type",
194 P_("Style of bevel around the statusbar text"),
195 GTK_TYPE_SHADOW_TYPE,
197 GTK_PARAM_READABLE));
201 gtk_statusbar_init (GtkStatusbar *statusbar)
204 GtkWidget *message_area;
205 GtkShadowType shadow_type;
207 box = GTK_BOX (statusbar);
209 gtk_widget_set_redraw_on_allocate (GTK_WIDGET (box), TRUE);
212 box->homogeneous = FALSE;
214 statusbar->has_resize_grip = TRUE;
216 gtk_widget_style_get (GTK_WIDGET (statusbar), "shadow-type", &shadow_type, NULL);
218 statusbar->frame = gtk_frame_new (NULL);
219 gtk_frame_set_shadow_type (GTK_FRAME (statusbar->frame), shadow_type);
220 gtk_box_pack_start (box, statusbar->frame, TRUE, TRUE, 0);
221 gtk_widget_show (statusbar->frame);
223 message_area = gtk_hbox_new (FALSE, 4);
224 gtk_container_add (GTK_CONTAINER (statusbar->frame), message_area);
225 gtk_widget_show (message_area);
227 statusbar->label = gtk_label_new ("");
228 gtk_label_set_single_line_mode (GTK_LABEL (statusbar->label), TRUE);
229 gtk_misc_set_alignment (GTK_MISC (statusbar->label), 0.0, 0.5);
230 g_signal_connect (statusbar->label, "notify::selectable",
231 G_CALLBACK (label_selectable_changed), statusbar);
232 gtk_label_set_ellipsize (GTK_LABEL (statusbar->label), PANGO_ELLIPSIZE_END);
233 gtk_container_add (GTK_CONTAINER (message_area), statusbar->label);
234 gtk_widget_show (statusbar->label);
236 statusbar->seq_context_id = 1;
237 statusbar->seq_message_id = 1;
238 statusbar->messages = NULL;
239 statusbar->keys = NULL;
242 static GtkBuildableIface *parent_buildable_iface;
245 gtk_statusbar_buildable_interface_init (GtkBuildableIface *iface)
247 parent_buildable_iface = g_type_interface_peek_parent (iface);
248 iface->get_internal_child = gtk_statusbar_buildable_get_internal_child;
252 gtk_statusbar_buildable_get_internal_child (GtkBuildable *buildable,
254 const gchar *childname)
256 if (strcmp (childname, "message_area") == 0)
257 return G_OBJECT (gtk_bin_get_child (GTK_BIN (GTK_STATUSBAR (buildable)->frame)));
259 return parent_buildable_iface->get_internal_child (buildable,
267 * Creates a new #GtkStatusbar ready for messages.
269 * Returns: the new #GtkStatusbar
272 gtk_statusbar_new (void)
274 return g_object_new (GTK_TYPE_STATUSBAR, NULL);
278 gtk_statusbar_update (GtkStatusbar *statusbar,
282 g_return_if_fail (GTK_IS_STATUSBAR (statusbar));
287 gtk_label_set_text (GTK_LABEL (statusbar->label), text);
291 * gtk_statusbar_get_context_id:
292 * @statusbar: a #GtkStatusbar
293 * @context_description: textual description of what context
294 * the new message is being used in
296 * Returns a new context identifier, given a description
297 * of the actual context. Note that the description is
298 * <emphasis>not</emphasis> shown in the UI.
300 * Returns: an integer id
303 gtk_statusbar_get_context_id (GtkStatusbar *statusbar,
304 const gchar *context_description)
309 g_return_val_if_fail (GTK_IS_STATUSBAR (statusbar), 0);
310 g_return_val_if_fail (context_description != NULL, 0);
312 /* we need to preserve namespaces on object datas */
313 string = g_strconcat ("gtk-status-bar-context:", context_description, NULL);
315 id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (statusbar), string));
318 id = statusbar->seq_context_id++;
319 g_object_set_data_full (G_OBJECT (statusbar), string, GUINT_TO_POINTER (id), NULL);
320 statusbar->keys = g_slist_prepend (statusbar->keys, string);
329 * gtk_statusbar_push:
330 * @statusbar: a #GtkStatusbar
331 * @context_id: the message's context id, as returned by
332 * gtk_statusbar_get_context_id()
333 * @text: the message to add to the statusbar
335 * Pushes a new message onto a statusbar's stack.
337 * Returns: a message id that can be used with
338 * gtk_statusbar_remove().
341 gtk_statusbar_push (GtkStatusbar *statusbar,
345 GtkStatusbarMsg *msg;
347 g_return_val_if_fail (GTK_IS_STATUSBAR (statusbar), 0);
348 g_return_val_if_fail (text != NULL, 0);
350 msg = g_slice_new (GtkStatusbarMsg);
351 msg->text = g_strdup (text);
352 msg->context_id = context_id;
353 msg->message_id = statusbar->seq_message_id++;
355 statusbar->messages = g_slist_prepend (statusbar->messages, msg);
357 g_signal_emit (statusbar,
358 statusbar_signals[SIGNAL_TEXT_PUSHED],
363 return msg->message_id;
368 * @statusbar: a #GtkStatusBar
369 * @context_id: a context identifier
371 * Removes the first message in the #GtkStatusBar's stack
372 * with the given context id.
374 * Note that this may not change the displayed message, if
375 * the message at the top of the stack has a different
379 gtk_statusbar_pop (GtkStatusbar *statusbar,
382 GtkStatusbarMsg *msg;
384 g_return_if_fail (GTK_IS_STATUSBAR (statusbar));
386 if (statusbar->messages)
390 for (list = statusbar->messages; list; list = list->next)
394 if (msg->context_id == context_id)
396 statusbar->messages = g_slist_remove_link (statusbar->messages,
399 g_slice_free (GtkStatusbarMsg, msg);
400 g_slist_free_1 (list);
406 msg = statusbar->messages ? statusbar->messages->data : NULL;
408 g_signal_emit (statusbar,
409 statusbar_signals[SIGNAL_TEXT_POPPED],
411 (guint) (msg ? msg->context_id : 0),
412 msg ? msg->text : NULL);
416 * gtk_statusbar_remove:
417 * @statusbar: a #GtkStatusBar
418 * @context_id: a context identifier
419 * @message_id: a message identifier, as returned by gtk_statusbar_push()
421 * Forces the removal of a message from a statusbar's stack.
422 * The exact @context_id and @message_id must be specified.
425 gtk_statusbar_remove (GtkStatusbar *statusbar,
429 GtkStatusbarMsg *msg;
431 g_return_if_fail (GTK_IS_STATUSBAR (statusbar));
432 g_return_if_fail (message_id > 0);
434 msg = statusbar->messages ? statusbar->messages->data : NULL;
439 /* care about signal emission if the topmost item is removed */
440 if (msg->context_id == context_id &&
441 msg->message_id == message_id)
443 gtk_statusbar_pop (statusbar, context_id);
447 for (list = statusbar->messages; list; list = list->next)
451 if (msg->context_id == context_id &&
452 msg->message_id == message_id)
454 statusbar->messages = g_slist_remove_link (statusbar->messages, list);
456 g_slice_free (GtkStatusbarMsg, msg);
457 g_slist_free_1 (list);
466 * gtk_statusbar_set_has_resize_grip:
467 * @statusbar: a #GtkStatusBar
468 * @setting: %TRUE to have a resize grip
470 * Sets whether the statusbar has a resize grip.
474 gtk_statusbar_set_has_resize_grip (GtkStatusbar *statusbar,
477 g_return_if_fail (GTK_IS_STATUSBAR (statusbar));
479 setting = setting != FALSE;
481 if (setting != statusbar->has_resize_grip)
483 statusbar->has_resize_grip = setting;
484 gtk_widget_queue_resize (statusbar->label);
485 gtk_widget_queue_draw (GTK_WIDGET (statusbar));
487 if (GTK_WIDGET_REALIZED (statusbar))
489 if (statusbar->has_resize_grip && statusbar->grip_window == NULL)
491 gtk_statusbar_create_window (statusbar);
492 if (GTK_WIDGET_MAPPED (statusbar))
493 gdk_window_show (statusbar->grip_window);
495 else if (!statusbar->has_resize_grip && statusbar->grip_window != NULL)
496 gtk_statusbar_destroy_window (statusbar);
499 g_object_notify (G_OBJECT (statusbar), "has-resize-grip");
504 * gtk_statusbar_get_has_resize_grip:
505 * @statusbar: a #GtkStatusBar
507 * Returns whether the statusbar has a resize grip.
509 * Returns: %TRUE if the statusbar has a resize grip.
512 gtk_statusbar_get_has_resize_grip (GtkStatusbar *statusbar)
514 g_return_val_if_fail (GTK_IS_STATUSBAR (statusbar), FALSE);
516 return statusbar->has_resize_grip;
520 * gtk_statusbar_get_message_area:
521 * @statusbar: a #GtkStatusBar
523 * Retrieves the box containing the label widget.
530 gtk_statusbar_get_message_area (GtkStatusbar *statusbar)
532 g_return_val_if_fail (GTK_IS_STATUSBAR (statusbar), NULL);
534 return gtk_bin_get_child (GTK_BIN (statusbar->frame));
538 gtk_statusbar_destroy (GtkObject *object)
540 GtkStatusbar *statusbar = GTK_STATUSBAR (object);
543 for (list = statusbar->messages; list; list = list->next)
545 GtkStatusbarMsg *msg;
549 g_slice_free (GtkStatusbarMsg, msg);
551 g_slist_free (statusbar->messages);
552 statusbar->messages = NULL;
554 for (list = statusbar->keys; list; list = list->next)
556 g_slist_free (statusbar->keys);
557 statusbar->keys = NULL;
559 GTK_OBJECT_CLASS (gtk_statusbar_parent_class)->destroy (object);
563 gtk_statusbar_set_property (GObject *object,
568 GtkStatusbar *statusbar = GTK_STATUSBAR (object);
572 case PROP_HAS_RESIZE_GRIP:
573 gtk_statusbar_set_has_resize_grip (statusbar, g_value_get_boolean (value));
576 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
582 gtk_statusbar_get_property (GObject *object,
587 GtkStatusbar *statusbar = GTK_STATUSBAR (object);
591 case PROP_HAS_RESIZE_GRIP:
592 g_value_set_boolean (value, statusbar->has_resize_grip);
595 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
601 get_grip_edge (GtkStatusbar *statusbar)
603 GtkWidget *widget = GTK_WIDGET (statusbar);
605 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
606 return GDK_WINDOW_EDGE_SOUTH_EAST;
608 return GDK_WINDOW_EDGE_SOUTH_WEST;
612 get_grip_rect (GtkStatusbar *statusbar,
618 widget = GTK_WIDGET (statusbar);
620 /* These are in effect the max/default size of the grip. */
624 if (w > widget->allocation.width)
625 w = widget->allocation.width;
627 if (h > widget->allocation.height - widget->style->ythickness)
628 h = widget->allocation.height - widget->style->ythickness;
632 rect->y = widget->allocation.y + widget->allocation.height - h;
634 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
635 rect->x = widget->allocation.x + widget->allocation.width - w;
637 rect->x = widget->allocation.x + widget->style->xthickness;
641 set_grip_cursor (GtkStatusbar *statusbar)
643 if (statusbar->has_resize_grip && statusbar->grip_window != NULL)
645 GtkWidget *widget = GTK_WIDGET (statusbar);
646 GdkDisplay *display = gtk_widget_get_display (widget);
647 GdkCursorType cursor_type;
650 if (gtk_widget_is_sensitive (widget))
652 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
653 cursor_type = GDK_BOTTOM_RIGHT_CORNER;
655 cursor_type = GDK_BOTTOM_LEFT_CORNER;
657 cursor = gdk_cursor_new_for_display (display, cursor_type);
658 gdk_window_set_cursor (statusbar->grip_window, cursor);
659 gdk_cursor_unref (cursor);
662 gdk_window_set_cursor (statusbar->grip_window, NULL);
667 gtk_statusbar_create_window (GtkStatusbar *statusbar)
670 GdkWindowAttr attributes;
671 gint attributes_mask;
674 g_return_if_fail (GTK_WIDGET_REALIZED (statusbar));
675 g_return_if_fail (statusbar->has_resize_grip);
677 widget = GTK_WIDGET (statusbar);
679 get_grip_rect (statusbar, &rect);
681 attributes.x = rect.x;
682 attributes.y = rect.y;
683 attributes.width = rect.width;
684 attributes.height = rect.height;
685 attributes.window_type = GDK_WINDOW_CHILD;
686 attributes.wclass = GDK_INPUT_ONLY;
687 attributes.event_mask = gtk_widget_get_events (widget) |
688 GDK_BUTTON_PRESS_MASK;
690 attributes_mask = GDK_WA_X | GDK_WA_Y;
692 statusbar->grip_window = gdk_window_new (widget->window,
693 &attributes, attributes_mask);
695 gdk_window_set_user_data (statusbar->grip_window, widget);
697 gdk_window_raise (statusbar->grip_window);
699 set_grip_cursor (statusbar);
703 gtk_statusbar_direction_changed (GtkWidget *widget,
704 GtkTextDirection prev_dir)
706 GtkStatusbar *statusbar = GTK_STATUSBAR (widget);
708 set_grip_cursor (statusbar);
712 gtk_statusbar_state_changed (GtkWidget *widget,
713 GtkStateType previous_state)
715 GtkStatusbar *statusbar = GTK_STATUSBAR (widget);
717 set_grip_cursor (statusbar);
721 gtk_statusbar_destroy_window (GtkStatusbar *statusbar)
723 gdk_window_set_user_data (statusbar->grip_window, NULL);
724 gdk_window_destroy (statusbar->grip_window);
725 statusbar->grip_window = NULL;
729 gtk_statusbar_realize (GtkWidget *widget)
731 GtkStatusbar *statusbar;
733 statusbar = GTK_STATUSBAR (widget);
735 GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->realize (widget);
737 if (statusbar->has_resize_grip)
738 gtk_statusbar_create_window (statusbar);
742 gtk_statusbar_unrealize (GtkWidget *widget)
744 GtkStatusbar *statusbar;
746 statusbar = GTK_STATUSBAR (widget);
748 if (statusbar->grip_window)
749 gtk_statusbar_destroy_window (statusbar);
751 GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->unrealize (widget);
755 gtk_statusbar_map (GtkWidget *widget)
757 GtkStatusbar *statusbar;
759 statusbar = GTK_STATUSBAR (widget);
761 GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->map (widget);
763 if (statusbar->grip_window)
764 gdk_window_show (statusbar->grip_window);
768 gtk_statusbar_unmap (GtkWidget *widget)
770 GtkStatusbar *statusbar;
772 statusbar = GTK_STATUSBAR (widget);
774 if (statusbar->grip_window)
775 gdk_window_hide (statusbar->grip_window);
777 GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->unmap (widget);
781 gtk_statusbar_button_press (GtkWidget *widget,
782 GdkEventButton *event)
784 GtkStatusbar *statusbar;
788 statusbar = GTK_STATUSBAR (widget);
790 if (!statusbar->has_resize_grip ||
791 event->type != GDK_BUTTON_PRESS ||
792 event->window != statusbar->grip_window)
795 ancestor = gtk_widget_get_toplevel (widget);
797 if (!GTK_IS_WINDOW (ancestor))
800 edge = get_grip_edge (statusbar);
802 if (event->button == 1)
803 gtk_window_begin_resize_drag (GTK_WINDOW (ancestor),
806 event->x_root, event->y_root,
808 else if (event->button == 2)
809 gtk_window_begin_move_drag (GTK_WINDOW (ancestor),
811 event->x_root, event->y_root,
820 gtk_statusbar_expose_event (GtkWidget *widget,
821 GdkEventExpose *event)
823 GtkStatusbar *statusbar;
826 statusbar = GTK_STATUSBAR (widget);
828 GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->expose_event (widget, event);
830 if (statusbar->has_resize_grip)
834 edge = get_grip_edge (statusbar);
836 get_grip_rect (statusbar, &rect);
838 gtk_paint_resize_grip (widget->style,
840 GTK_WIDGET_STATE (widget),
846 /* don't draw grip over the frame, though you
847 * can click on the frame.
849 rect.width - widget->style->xthickness,
850 rect.height - widget->style->ythickness);
857 gtk_statusbar_size_request (GtkWidget *widget,
858 GtkRequisition *requisition)
860 GtkStatusbar *statusbar;
861 GtkShadowType shadow_type;
863 statusbar = GTK_STATUSBAR (widget);
865 gtk_widget_style_get (GTK_WIDGET (statusbar), "shadow-type", &shadow_type, NULL);
866 gtk_frame_set_shadow_type (GTK_FRAME (statusbar->frame), shadow_type);
868 GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->size_request (widget, requisition);
871 /* look for extra children between the frame containing
872 * the label and where we want to draw the resize grip
875 has_extra_children (GtkStatusbar *statusbar)
878 GtkBoxChild *child, *frame;
880 /* If the internal frame has been modified assume we have extra children */
881 if (gtk_bin_get_child (GTK_BIN (statusbar->frame)) != statusbar->label)
885 for (l = GTK_BOX (statusbar)->children; l; l = l->next)
889 if (frame->widget == statusbar->frame)
893 for (l = l->next; l; l = l->next)
897 if (!GTK_WIDGET_VISIBLE (child->widget))
900 if (frame->pack == GTK_PACK_START || child->pack == GTK_PACK_END)
908 gtk_statusbar_size_allocate (GtkWidget *widget,
909 GtkAllocation *allocation)
911 GtkStatusbar *statusbar = GTK_STATUSBAR (widget);
912 gboolean extra_children = FALSE;
915 if (statusbar->has_resize_grip)
917 get_grip_rect (statusbar, &rect);
919 extra_children = has_extra_children (statusbar);
921 /* If there are extra children, we don't want them to occupy
922 * the space where we draw the resize grip, so we temporarily
923 * shrink the allocation.
924 * If there are no extra children, we want the frame to get
925 * the full allocation, and we fix up the allocation of the
926 * label afterwards to make room for the grip.
930 allocation->width -= rect.width;
931 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
932 allocation->x += rect.width;
936 /* chain up normally */
937 GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->size_allocate (widget, allocation);
939 if (statusbar->has_resize_grip)
943 allocation->width += rect.width;
944 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
945 allocation->x -= rect.width;
947 widget->allocation = *allocation;
953 /* Use the frame's child instead of statusbar->label directly, in case
954 * the label has been replaced by a container as the frame's child
955 * (and the label reparented into that container).
957 child = gtk_bin_get_child (GTK_BIN (statusbar->frame));
959 if (child->allocation.width + rect.width > statusbar->frame->allocation.width)
961 /* shrink the label to make room for the grip */
962 *allocation = child->allocation;
963 allocation->width = MAX (1, allocation->width - rect.width);
964 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
965 allocation->x += child->allocation.width - allocation->width;
967 gtk_widget_size_allocate (child, allocation);
971 if (statusbar->grip_window)
973 get_grip_rect (statusbar, &rect);
975 gdk_window_raise (statusbar->grip_window);
976 gdk_window_move_resize (statusbar->grip_window,
978 rect.width, rect.height);
985 label_selectable_changed (GtkWidget *label,
989 GtkStatusbar *statusbar = GTK_STATUSBAR (data);
992 statusbar->has_resize_grip && statusbar->grip_window)
993 gdk_window_raise (statusbar->grip_window);
996 #define __GTK_STATUSBAR_C__
997 #include "gtkaliasdef.c"