1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
31 #include "gtkcontainer.h"
32 #include "gtkprivate.h"
33 #include "gtksignal.h"
35 #include "gtkwindow.h"
50 ARG_REALLOCATE_REDRAWS
53 typedef struct _GtkChildArgInfo GtkChildArgInfo;
54 struct _GtkChildArgInfo
64 static void gtk_container_base_class_init (GtkContainerClass *klass);
65 static void gtk_container_class_init (GtkContainerClass *klass);
66 static void gtk_container_init (GtkContainer *container);
67 static void gtk_container_destroy (GtkObject *object);
68 static void gtk_container_get_arg (GtkObject *object,
71 static void gtk_container_set_arg (GtkObject *object,
74 static void gtk_container_add_unimplemented (GtkContainer *container,
76 static void gtk_container_remove_unimplemented (GtkContainer *container,
78 static void gtk_container_real_check_resize (GtkContainer *container);
79 static gboolean gtk_container_real_focus (GtkContainer *container,
80 GtkDirectionType direction);
81 static void gtk_container_real_set_focus_child (GtkContainer *container,
83 static gboolean gtk_container_focus_tab (GtkContainer *container,
85 GtkDirectionType direction);
86 static gboolean gtk_container_focus_up_down (GtkContainer *container,
88 GtkDirectionType direction);
89 static gboolean gtk_container_focus_left_right (GtkContainer *container,
91 GtkDirectionType direction);
92 static gboolean gtk_container_focus_move (GtkContainer *container,
94 GtkDirectionType direction);
95 static void gtk_container_children_callback (GtkWidget *widget,
96 gpointer client_data);
97 static void gtk_container_show_all (GtkWidget *widget);
98 static void gtk_container_hide_all (GtkWidget *widget);
101 static gchar* gtk_container_child_default_composite_name (GtkContainer *container,
106 static guint container_signals[LAST_SIGNAL] = { 0 };
107 static GHashTable *container_child_arg_info_ht = NULL;
109 static GtkWidgetClass *parent_class = NULL;
111 static const gchar *vadjustment_key = "gtk-vadjustment";
112 static guint vadjustment_key_id = 0;
113 static const gchar *hadjustment_key = "gtk-hadjustment";
114 static guint hadjustment_key_id = 0;
115 static GSList *container_resize_queue = NULL;
118 gtk_container_get_type (void)
120 static GtkType container_type = 0;
124 static const GtkTypeInfo container_info =
127 sizeof (GtkContainer),
128 sizeof (GtkContainerClass),
129 (GtkClassInitFunc) gtk_container_class_init,
130 (GtkObjectInitFunc) gtk_container_init,
131 /* reserved_1 */ NULL,
132 /* reserved_2 */ NULL,
133 (GtkClassInitFunc) gtk_container_base_class_init,
136 container_type = gtk_type_unique (gtk_widget_get_type (), &container_info);
139 return container_type;
143 gtk_container_base_class_init (GtkContainerClass *class)
145 /* reset instance specifc class fields that don't get inherited */
146 class->n_child_args = 0;
147 class->set_child_arg = NULL;
148 class->get_child_arg = NULL;
152 gtk_container_class_init (GtkContainerClass *class)
154 GtkObjectClass *object_class;
155 GtkWidgetClass *widget_class;
157 object_class = (GtkObjectClass*) class;
158 widget_class = (GtkWidgetClass*) class;
160 parent_class = gtk_type_class (gtk_widget_get_type ());
162 container_child_arg_info_ht = g_hash_table_new (gtk_arg_info_hash,
165 vadjustment_key_id = g_quark_from_static_string (vadjustment_key);
166 hadjustment_key_id = g_quark_from_static_string (hadjustment_key);
168 gtk_object_add_arg_type ("GtkContainer::border_width", GTK_TYPE_ULONG, GTK_ARG_READWRITE, ARG_BORDER_WIDTH);
169 gtk_object_add_arg_type ("GtkContainer::resize_mode", GTK_TYPE_RESIZE_MODE, GTK_ARG_READWRITE, ARG_RESIZE_MODE);
170 gtk_object_add_arg_type ("GtkContainer::child", GTK_TYPE_WIDGET, GTK_ARG_WRITABLE, ARG_CHILD);
171 gtk_object_add_arg_type ("GtkContainer::reallocate_redraws", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_REALLOCATE_REDRAWS);
173 container_signals[ADD] =
174 gtk_signal_new ("add",
176 GTK_CLASS_TYPE (object_class),
177 GTK_SIGNAL_OFFSET (GtkContainerClass, add),
178 gtk_marshal_VOID__POINTER,
181 container_signals[REMOVE] =
182 gtk_signal_new ("remove",
184 GTK_CLASS_TYPE (object_class),
185 GTK_SIGNAL_OFFSET (GtkContainerClass, remove),
186 gtk_marshal_VOID__POINTER,
189 container_signals[CHECK_RESIZE] =
190 gtk_signal_new ("check_resize",
192 GTK_CLASS_TYPE (object_class),
193 GTK_SIGNAL_OFFSET (GtkContainerClass, check_resize),
194 gtk_marshal_VOID__VOID,
196 container_signals[FOCUS] =
197 gtk_signal_new ("focus",
199 GTK_CLASS_TYPE (object_class),
200 GTK_SIGNAL_OFFSET (GtkContainerClass, focus),
201 gtk_marshal_ENUM__ENUM,
202 GTK_TYPE_DIRECTION_TYPE, 1,
203 GTK_TYPE_DIRECTION_TYPE);
204 container_signals[SET_FOCUS_CHILD] =
205 gtk_signal_new ("set-focus-child",
207 GTK_CLASS_TYPE (object_class),
208 GTK_SIGNAL_OFFSET (GtkContainerClass, set_focus_child),
209 gtk_marshal_VOID__POINTER,
212 gtk_object_class_add_signals (object_class, container_signals, LAST_SIGNAL);
214 object_class->get_arg = gtk_container_get_arg;
215 object_class->set_arg = gtk_container_set_arg;
216 object_class->destroy = gtk_container_destroy;
218 widget_class->show_all = gtk_container_show_all;
219 widget_class->hide_all = gtk_container_hide_all;
221 class->add = gtk_container_add_unimplemented;
222 class->remove = gtk_container_remove_unimplemented;
223 class->check_resize = gtk_container_real_check_resize;
224 class->forall = NULL;
225 class->focus = gtk_container_real_focus;
226 class->set_focus_child = gtk_container_real_set_focus_child;
227 class->child_type = NULL;
228 class->composite_name = gtk_container_child_default_composite_name;
232 gtk_container_child_type (GtkContainer *container)
235 GtkContainerClass *class;
237 g_return_val_if_fail (container != NULL, 0);
238 g_return_val_if_fail (GTK_IS_CONTAINER (container), 0);
240 class = GTK_CONTAINER_GET_CLASS (container);
241 if (class->child_type)
242 slot = class->child_type (container);
244 slot = GTK_TYPE_NONE;
249 /****************************************************
250 * GtkContainer child argument mechanism
252 ****************************************************/
255 gtk_container_add_with_args (GtkContainer *container,
257 const gchar *first_arg_name,
260 g_return_if_fail (container != NULL);
261 g_return_if_fail (GTK_IS_CONTAINER (container));
262 g_return_if_fail (widget != NULL);
263 g_return_if_fail (GTK_IS_WIDGET (widget));
264 g_return_if_fail (widget->parent == NULL);
266 gtk_widget_ref (GTK_WIDGET (container));
267 gtk_widget_ref (widget);
269 if (!GTK_OBJECT_CONSTRUCTED (widget))
270 gtk_object_default_construct (GTK_OBJECT (widget));
271 gtk_signal_emit (GTK_OBJECT (container), container_signals[ADD], widget);
276 GSList *arg_list = NULL;
277 GSList *info_list = NULL;
280 va_start (var_args, first_arg_name);
281 error = gtk_container_child_args_collect (GTK_OBJECT_TYPE (container),
290 g_warning ("gtk_container_add_with_args(): %s", error);
298 slist_arg = arg_list;
299 slist_info = info_list;
302 gtk_container_arg_set (container, widget, slist_arg->data, slist_info->data);
303 slist_arg = slist_arg->next;
304 slist_info = slist_info->next;
306 gtk_args_collect_cleanup (arg_list, info_list);
310 gtk_widget_unref (widget);
311 gtk_widget_unref (GTK_WIDGET (container));
315 gtk_container_addv (GtkContainer *container,
320 g_return_if_fail (container != NULL);
321 g_return_if_fail (GTK_IS_CONTAINER (container));
322 g_return_if_fail (widget != NULL);
323 g_return_if_fail (GTK_IS_WIDGET (widget));
324 g_return_if_fail (widget->parent == NULL);
326 gtk_widget_ref (GTK_WIDGET (container));
327 gtk_widget_ref (widget);
329 if (!GTK_OBJECT_CONSTRUCTED (widget))
330 gtk_object_default_construct (GTK_OBJECT (widget));
331 gtk_signal_emit (GTK_OBJECT (container), container_signals[ADD], widget);
337 for (max_args = args + n_args; args < max_args; args++)
338 gtk_container_arg_set (container, widget, args, NULL);
341 gtk_widget_unref (widget);
342 gtk_widget_unref (GTK_WIDGET (container));
346 gtk_container_child_setv (GtkContainer *container,
353 g_return_if_fail (container != NULL);
354 g_return_if_fail (GTK_IS_CONTAINER (container));
355 g_return_if_fail (child != NULL);
356 g_return_if_fail (GTK_IS_WIDGET (child));
357 g_return_if_fail (child->parent != NULL);
359 g_return_if_fail (args != NULL);
361 for (max_args = args + n_args; args < max_args; args++)
362 gtk_container_arg_set (container, child, args, NULL);
366 gtk_container_child_getv (GtkContainer *container,
373 g_return_if_fail (container != NULL);
374 g_return_if_fail (GTK_IS_CONTAINER (container));
375 g_return_if_fail (child != NULL);
376 g_return_if_fail (GTK_IS_WIDGET (child));
377 g_return_if_fail (child->parent != NULL);
379 g_return_if_fail (args != NULL);
381 for (max_args = args + n_args; args < max_args; args++)
382 gtk_container_arg_get (container, child, args, NULL);
386 gtk_container_child_set (GtkContainer *container,
388 const gchar *first_arg_name,
392 GSList *arg_list = NULL;
393 GSList *info_list = NULL;
396 g_return_if_fail (container != NULL);
397 g_return_if_fail (GTK_IS_CONTAINER (container));
398 g_return_if_fail (child != NULL);
399 g_return_if_fail (GTK_IS_WIDGET (child));
400 g_return_if_fail (child->parent != NULL);
402 va_start (var_args, first_arg_name);
403 error = gtk_container_child_args_collect (GTK_OBJECT_TYPE (container),
412 g_warning ("gtk_container_child_set(): %s", error);
420 slist_arg = arg_list;
421 slist_info = info_list;
424 gtk_container_arg_set (container, child, slist_arg->data, slist_info->data);
425 slist_arg = slist_arg->next;
426 slist_info = slist_info->next;
428 gtk_args_collect_cleanup (arg_list, info_list);
433 gtk_container_arg_set (GtkContainer *container,
438 GtkContainerClass *class;
440 g_return_if_fail (container != NULL);
441 g_return_if_fail (GTK_IS_CONTAINER (container));
442 g_return_if_fail (child != NULL);
443 g_return_if_fail (GTK_IS_WIDGET (child));
444 g_return_if_fail (arg != NULL);
450 error = gtk_arg_get_info (GTK_OBJECT_TYPE (container),
451 container_child_arg_info_ht,
456 g_warning ("gtk_container_arg_set(): %s", error);
461 g_return_if_fail (info->arg_flags & GTK_ARG_CHILD_ARG);
463 if (! (info->arg_flags & GTK_ARG_WRITABLE))
465 g_warning ("gtk_container_arg_set(): argument \"%s\" is not writable",
469 if (info->type != arg->type)
471 g_warning ("gtk_container_arg_set(): argument \"%s\" has invalid type `%s'",
473 gtk_type_name (arg->type));
477 class = gtk_type_class (info->class_type);
478 g_assert (class->set_child_arg != NULL);
479 class->set_child_arg (container, child, arg, info->arg_id);
483 gtk_container_arg_get (GtkContainer *container,
488 GtkContainerClass *class;
490 g_return_if_fail (container != NULL);
491 g_return_if_fail (GTK_IS_CONTAINER (container));
492 g_return_if_fail (child != NULL);
493 g_return_if_fail (GTK_IS_WIDGET (child));
494 g_return_if_fail (arg != NULL);
500 error = gtk_arg_get_info (GTK_OBJECT_TYPE (container),
501 container_child_arg_info_ht,
506 g_warning ("gtk_container_arg_get(): %s", error);
508 arg->type = GTK_TYPE_INVALID;
512 g_return_if_fail (info->arg_flags & GTK_ARG_CHILD_ARG);
514 if (! (info->arg_flags & GTK_ARG_READABLE))
516 g_warning ("gtk_container_arg_get(): argument \"%s\" is not readable",
518 arg->type = GTK_TYPE_INVALID;
522 class = gtk_type_class (info->class_type);
523 g_assert (class->get_child_arg != NULL);
524 arg->type = info->type;
525 class->get_child_arg (container, child, arg, info->arg_id);
529 gtk_container_add_child_arg_type (const gchar *arg_name,
534 g_return_if_fail (arg_name != NULL);
535 g_return_if_fail (arg_type > GTK_TYPE_NONE);
536 g_return_if_fail (arg_id > 0);
537 g_return_if_fail ((arg_flags & GTK_ARG_READWRITE) == GTK_ARG_READWRITE);
538 /* g_return_if_fail ((arg_flags & GTK_ARG_CHILD_ARG) != 0); */
540 arg_flags |= GTK_ARG_CHILD_ARG;
541 arg_flags &= GTK_ARG_MASK;
543 gtk_arg_type_new_static (GTK_TYPE_CONTAINER,
545 GTK_STRUCT_OFFSET (GtkContainerClass, n_child_args),
546 container_child_arg_info_ht,
553 gtk_container_child_args_collect (GtkType object_type,
555 GSList **info_list_p,
556 const gchar *first_arg_name,
559 return gtk_args_collect (object_type,
560 container_child_arg_info_ht,
568 gtk_container_child_arg_get_info (GtkType object_type,
569 const gchar *arg_name,
572 return gtk_arg_get_info (object_type,
573 container_child_arg_info_ht,
579 gtk_container_query_child_args (GtkType class_type,
583 g_return_val_if_fail (n_args != NULL, NULL);
585 g_return_val_if_fail (gtk_type_is_a (class_type, GTK_TYPE_CONTAINER), NULL);
587 return gtk_args_query (class_type, container_child_arg_info_ht, arg_flags, n_args);
592 gtk_container_add_unimplemented (GtkContainer *container,
595 g_warning ("GtkContainerClass::add not implemented for `%s'", gtk_type_name (GTK_OBJECT_TYPE (container)));
599 gtk_container_remove_unimplemented (GtkContainer *container,
602 g_warning ("GtkContainerClass::remove not implemented for `%s'", gtk_type_name (GTK_OBJECT_TYPE (container)));
606 gtk_container_init (GtkContainer *container)
608 container->focus_child = NULL;
609 container->border_width = 0;
610 container->need_resize = FALSE;
611 container->resize_mode = GTK_RESIZE_PARENT;
612 container->reallocate_redraws = FALSE;
613 container->resize_widgets = NULL;
617 gtk_container_destroy (GtkObject *object)
619 GtkContainer *container;
621 g_return_if_fail (object != NULL);
622 g_return_if_fail (GTK_IS_CONTAINER (object));
624 container = GTK_CONTAINER (object);
626 if (GTK_CONTAINER_RESIZE_PENDING (container))
627 gtk_container_dequeue_resize_handler (container);
628 if (container->resize_widgets)
629 gtk_container_clear_resize_widgets (container);
631 gtk_container_foreach (container, (GtkCallback) gtk_widget_destroy, NULL);
633 if (GTK_OBJECT_CLASS (parent_class)->destroy)
634 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
638 gtk_container_set_arg (GtkObject *object,
642 GtkContainer *container;
644 container = GTK_CONTAINER (object);
648 case ARG_BORDER_WIDTH:
649 gtk_container_set_border_width (container, GTK_VALUE_ULONG (*arg));
651 case ARG_RESIZE_MODE:
652 gtk_container_set_resize_mode (container, GTK_VALUE_ENUM (*arg));
654 case ARG_REALLOCATE_REDRAWS:
655 gtk_container_set_reallocate_redraws (container, GTK_VALUE_BOOL (*arg));
658 gtk_container_add (container, GTK_WIDGET (GTK_VALUE_OBJECT (*arg)));
666 gtk_container_get_arg (GtkObject *object,
670 GtkContainer *container;
672 container = GTK_CONTAINER (object);
676 case ARG_BORDER_WIDTH:
677 GTK_VALUE_ULONG (*arg) = container->border_width;
679 case ARG_RESIZE_MODE:
680 GTK_VALUE_ENUM (*arg) = container->resize_mode;
682 case ARG_REALLOCATE_REDRAWS:
683 GTK_VALUE_BOOL (*arg) = container->reallocate_redraws;
686 arg->type = GTK_TYPE_INVALID;
692 gtk_container_set_border_width (GtkContainer *container,
695 g_return_if_fail (container != NULL);
696 g_return_if_fail (GTK_IS_CONTAINER (container));
698 if (container->border_width != border_width)
700 container->border_width = border_width;
702 if (GTK_WIDGET_REALIZED (container))
703 gtk_widget_queue_resize (GTK_WIDGET (container));
708 gtk_container_add (GtkContainer *container,
711 g_return_if_fail (container != NULL);
712 g_return_if_fail (GTK_IS_CONTAINER (container));
713 g_return_if_fail (widget != NULL);
714 g_return_if_fail (GTK_IS_WIDGET (widget));
715 g_return_if_fail (widget->parent == NULL);
717 if (!GTK_OBJECT_CONSTRUCTED (widget))
718 gtk_object_default_construct (GTK_OBJECT (widget));
719 gtk_signal_emit (GTK_OBJECT (container), container_signals[ADD], widget);
723 gtk_container_remove (GtkContainer *container,
726 g_return_if_fail (container != NULL);
727 g_return_if_fail (GTK_IS_CONTAINER (container));
728 g_return_if_fail (widget != NULL);
729 g_return_if_fail (GTK_IS_WIDGET (widget));
730 g_return_if_fail (widget->parent == GTK_WIDGET (container));
732 gtk_signal_emit (GTK_OBJECT (container), container_signals[REMOVE], widget);
736 gtk_container_dequeue_resize_handler (GtkContainer *container)
738 g_return_if_fail (GTK_IS_CONTAINER (container));
739 g_return_if_fail (GTK_CONTAINER_RESIZE_PENDING (container));
741 container_resize_queue = g_slist_remove (container_resize_queue, container);
742 GTK_PRIVATE_UNSET_FLAG (container, GTK_RESIZE_PENDING);
746 gtk_container_clear_resize_widgets (GtkContainer *container)
750 g_return_if_fail (container != NULL);
751 g_return_if_fail (GTK_IS_CONTAINER (container));
753 node = container->resize_widgets;
757 GtkWidget *widget = node->data;
759 GTK_PRIVATE_UNSET_FLAG (widget, GTK_RESIZE_NEEDED);
763 g_slist_free (container->resize_widgets);
764 container->resize_widgets = NULL;
768 gtk_container_set_resize_mode (GtkContainer *container,
769 GtkResizeMode resize_mode)
771 g_return_if_fail (container != NULL);
772 g_return_if_fail (GTK_IS_CONTAINER (container));
773 g_return_if_fail (resize_mode <= GTK_RESIZE_IMMEDIATE);
775 if (GTK_WIDGET_TOPLEVEL (container) &&
776 resize_mode == GTK_RESIZE_PARENT)
777 resize_mode = GTK_RESIZE_QUEUE;
779 if (container->resize_mode != resize_mode)
781 container->resize_mode = resize_mode;
783 if (resize_mode == GTK_RESIZE_IMMEDIATE)
784 gtk_container_check_resize (container);
787 gtk_container_clear_resize_widgets (container);
788 gtk_widget_queue_resize (GTK_WIDGET (container));
794 gtk_container_set_reallocate_redraws (GtkContainer *container,
795 gboolean needs_redraws)
797 g_return_if_fail (GTK_IS_CONTAINER (container));
799 needs_redraws = needs_redraws ? TRUE : FALSE;
800 if (needs_redraws != container->reallocate_redraws)
802 container->reallocate_redraws = needs_redraws;
803 if (container->reallocate_redraws)
804 gtk_widget_queue_draw (GTK_WIDGET (container));
809 gtk_container_get_resize_container (GtkContainer *container)
813 widget = GTK_WIDGET (container);
815 while (widget->parent)
817 widget = widget->parent;
818 if (GTK_IS_RESIZE_CONTAINER (widget) && !GTK_WIDGET_RESIZE_NEEDED (widget))
822 return GTK_IS_RESIZE_CONTAINER (widget) ? (GtkContainer*) widget : NULL;
826 gtk_container_idle_sizer (gpointer data)
828 GDK_THREADS_ENTER ();
830 /* we may be invoked with a container_resize_queue of NULL, because
831 * queue_resize could have been adding an extra idle function while
832 * the queue still got processed. we better just ignore such case
833 * than trying to explicitely work around them with some extra flags,
834 * since it doesn't cause any actual harm.
836 while (container_resize_queue)
841 slist = container_resize_queue;
842 container_resize_queue = slist->next;
843 widget = slist->data;
844 g_slist_free_1 (slist);
846 GTK_PRIVATE_UNSET_FLAG (widget, GTK_RESIZE_PENDING);
847 gtk_container_check_resize (GTK_CONTAINER (widget));
850 gdk_window_process_all_updates ();
852 GDK_THREADS_LEAVE ();
858 gtk_container_queue_resize (GtkContainer *container)
860 GtkContainer *resize_container;
862 g_return_if_fail (container != NULL);
863 g_return_if_fail (GTK_IS_CONTAINER (container));
865 /* clear resize widgets for resize containers
866 * before aborting prematurely. this is especially
867 * important for toplevels which may need imemdiate
868 * processing or their resize handler to be queued.
870 if (GTK_IS_RESIZE_CONTAINER (container))
871 gtk_container_clear_resize_widgets (container);
872 if (GTK_OBJECT_DESTROYED (container) ||
873 GTK_WIDGET_RESIZE_NEEDED (container))
876 resize_container = gtk_container_get_resize_container (container);
878 if (resize_container)
880 if (GTK_WIDGET_VISIBLE (resize_container) &&
881 (GTK_WIDGET_TOPLEVEL (resize_container) || GTK_WIDGET_DRAWABLE (resize_container)))
883 switch (resize_container->resize_mode)
885 case GTK_RESIZE_QUEUE:
886 if (!GTK_CONTAINER_RESIZE_PENDING (resize_container))
888 GTK_PRIVATE_SET_FLAG (resize_container, GTK_RESIZE_PENDING);
889 if (container_resize_queue == NULL)
890 gtk_idle_add_priority (GTK_PRIORITY_RESIZE,
891 gtk_container_idle_sizer,
893 container_resize_queue = g_slist_prepend (container_resize_queue, resize_container);
896 GTK_PRIVATE_SET_FLAG (container, GTK_RESIZE_NEEDED);
897 resize_container->resize_widgets =
898 g_slist_prepend (resize_container->resize_widgets, container);
901 case GTK_RESIZE_IMMEDIATE:
902 GTK_PRIVATE_SET_FLAG (container, GTK_RESIZE_NEEDED);
903 resize_container->resize_widgets =
904 g_slist_prepend (resize_container->resize_widgets, container);
905 gtk_container_check_resize (resize_container);
908 case GTK_RESIZE_PARENT:
909 /* Ignore, should not be reached */
915 /* we need to let hidden resize containers know that something
916 * changed while they where hidden (currently only evaluated by
919 resize_container->need_resize = TRUE;
925 gtk_container_check_resize (GtkContainer *container)
927 g_return_if_fail (container != NULL);
928 g_return_if_fail (GTK_IS_CONTAINER (container));
930 gtk_signal_emit (GTK_OBJECT (container), container_signals[CHECK_RESIZE]);
934 gtk_container_real_check_resize (GtkContainer *container)
937 GtkRequisition requisition;
939 g_return_if_fail (container != NULL);
940 g_return_if_fail (GTK_IS_CONTAINER (container));
942 widget = GTK_WIDGET (container);
944 gtk_widget_size_request (widget, &requisition);
946 if (requisition.width > widget->allocation.width ||
947 requisition.height > widget->allocation.height)
949 if (GTK_IS_RESIZE_CONTAINER (container))
950 gtk_widget_size_allocate (GTK_WIDGET (container),
951 >K_WIDGET (container)->allocation);
953 gtk_widget_queue_resize (widget);
957 gtk_container_resize_children (container);
961 /* The container hasn't changed size but one of its children
962 * queued a resize request. Which means that the allocation
963 * is not sufficient for the requisition of some child.
964 * We've already performed a size request at this point,
965 * so we simply need to run through the list of resize
966 * widgets and reallocate their sizes appropriately. We
967 * make the optimization of not performing reallocation
968 * for a widget who also has a parent in the resize widgets
969 * list. GTK_RESIZE_NEEDED is used for flagging those
970 * parents inside this function.
973 gtk_container_resize_children (GtkContainer *container)
976 GtkWidget *resize_container;
977 GSList *resize_widgets;
978 GSList *resize_containers;
981 /* resizing invariants:
982 * toplevels have *always* resize_mode != GTK_RESIZE_PARENT set.
983 * containers with resize_mode==GTK_RESIZE_PARENT have to have resize_widgets
985 * containers that are flagged RESIZE_NEEDED must have resize_widgets set to
986 * NULL, or are toplevels (thus have ->parent set to NULL).
987 * widgets that are in some container->resize_widgets list must be flagged with
989 * widgets that have RESIZE_NEEDED set must be referenced in some
990 * GTK_IS_RESIZE_CONTAINER (container)->resize_widgets list.
991 * containers that have an idle sizer pending must be flagged with
995 g_return_if_fail (container != NULL);
996 g_return_if_fail (GTK_IS_CONTAINER (container));
998 /* we first check out if we actually need to perform a resize,
999 * which is not the case if we got another container queued for
1000 * a resize in our anchestry. also we can skip the whole
1001 * resize_widgets checks if we are a toplevel and NEED_RESIZE.
1002 * this code assumes that our allocation is sufficient for our
1003 * requisition, since otherwise we would NEED_RESIZE.
1005 resize_container = GTK_WIDGET (container);
1006 while (resize_container)
1008 if (GTK_WIDGET_RESIZE_NEEDED (resize_container))
1010 resize_container = resize_container->parent;
1012 if (resize_container)
1014 /* queue_resize and size_allocate both clear our
1015 * resize_widgets list.
1017 if (resize_container->parent)
1018 gtk_container_queue_resize (container);
1020 gtk_widget_size_allocate (GTK_WIDGET (container),
1021 >K_WIDGET (container)->allocation);
1025 resize_container = GTK_WIDGET (container);
1027 /* we now walk the anchestry for all resize widgets as long
1028 * as they are our children and as long as their allocation
1029 * is insufficient, since we don't need to reallocate below that.
1031 resize_widgets = container->resize_widgets;
1032 container->resize_widgets = NULL;
1033 for (node = resize_widgets; node; node = node->next)
1035 widget = node->data;
1037 GTK_PRIVATE_UNSET_FLAG (widget, GTK_RESIZE_NEEDED);
1039 while (widget->parent != resize_container &&
1040 ((widget->allocation.width < widget->requisition.width) ||
1041 (widget->allocation.height < widget->requisition.height)))
1042 widget = widget->parent;
1044 GTK_PRIVATE_SET_FLAG (widget, GTK_RESIZE_NEEDED);
1045 node->data = widget;
1048 /* for the newly setup resize_widgets list, we now walk each widget's
1049 * anchestry to sort those widgets out that have RESIZE_NEEDED parents.
1050 * we can safely stop the walk if we are the parent, since we checked
1051 * our own anchestry already.
1053 resize_containers = NULL;
1054 for (node = resize_widgets; node; node = node->next)
1058 widget = node->data;
1060 if (!GTK_WIDGET_RESIZE_NEEDED (widget))
1063 parent = widget->parent;
1065 while (parent != resize_container)
1067 if (GTK_WIDGET_RESIZE_NEEDED (parent))
1069 GTK_PRIVATE_UNSET_FLAG (widget, GTK_RESIZE_NEEDED);
1072 parent = parent->parent;
1075 if (!g_slist_find (resize_containers, widget))
1077 resize_containers = g_slist_prepend (resize_containers, widget);
1078 gtk_widget_ref (widget);
1081 g_slist_free (resize_widgets);
1083 for (node = resize_containers; node; node = node->next)
1085 widget = node->data;
1087 GTK_PRIVATE_UNSET_FLAG (widget, GTK_RESIZE_NEEDED);
1089 gtk_widget_size_allocate (widget, &widget->allocation);
1091 gtk_widget_unref (widget);
1093 g_slist_free (resize_containers);
1097 gtk_container_forall (GtkContainer *container,
1098 GtkCallback callback,
1099 gpointer callback_data)
1101 GtkContainerClass *class;
1103 g_return_if_fail (container != NULL);
1104 g_return_if_fail (GTK_IS_CONTAINER (container));
1105 g_return_if_fail (callback != NULL);
1107 class = GTK_CONTAINER_GET_CLASS (container);
1110 class->forall (container, TRUE, callback, callback_data);
1114 gtk_container_foreach (GtkContainer *container,
1115 GtkCallback callback,
1116 gpointer callback_data)
1118 GtkContainerClass *class;
1120 g_return_if_fail (container != NULL);
1121 g_return_if_fail (GTK_IS_CONTAINER (container));
1122 g_return_if_fail (callback != NULL);
1124 class = GTK_CONTAINER_GET_CLASS (container);
1127 class->forall (container, FALSE, callback, callback_data);
1130 typedef struct _GtkForeachData GtkForeachData;
1131 struct _GtkForeachData
1133 GtkObject *container;
1134 GtkCallbackMarshal callback;
1135 gpointer callback_data;
1139 gtk_container_foreach_unmarshal (GtkWidget *child,
1142 GtkForeachData *fdata = (GtkForeachData*) data;
1145 /* first argument */
1146 args[0].name = NULL;
1147 args[0].type = GTK_OBJECT_TYPE (child);
1148 GTK_VALUE_OBJECT (args[0]) = GTK_OBJECT (child);
1150 /* location for return value */
1151 args[1].name = NULL;
1152 args[1].type = GTK_TYPE_NONE;
1154 fdata->callback (fdata->container, fdata->callback_data, 1, args);
1158 gtk_container_foreach_full (GtkContainer *container,
1159 GtkCallback callback,
1160 GtkCallbackMarshal marshal,
1161 gpointer callback_data,
1162 GtkDestroyNotify notify)
1164 g_return_if_fail (container != NULL);
1165 g_return_if_fail (GTK_IS_CONTAINER (container));
1169 GtkForeachData fdata;
1171 fdata.container = GTK_OBJECT (container);
1172 fdata.callback = marshal;
1173 fdata.callback_data = callback_data;
1175 gtk_container_foreach (container, gtk_container_foreach_unmarshal, &fdata);
1179 g_return_if_fail (callback != NULL);
1181 gtk_container_foreach (container, callback, &callback_data);
1185 notify (callback_data);
1189 gtk_container_focus (GtkContainer *container,
1190 GtkDirectionType direction)
1194 g_return_val_if_fail (container != NULL, FALSE);
1195 g_return_val_if_fail (GTK_IS_CONTAINER (container), FALSE);
1197 gtk_signal_emit (GTK_OBJECT (container),
1198 container_signals[FOCUS],
1199 direction, &return_val);
1205 gtk_container_set_focus_child (GtkContainer *container,
1208 g_return_if_fail (container != NULL);
1209 g_return_if_fail (GTK_IS_CONTAINER (container));
1211 g_return_if_fail (GTK_IS_WIDGET (widget));
1213 gtk_signal_emit (GTK_OBJECT (container), container_signals[SET_FOCUS_CHILD], widget);
1217 gtk_container_children (GtkContainer *container)
1223 gtk_container_foreach (container,
1224 gtk_container_children_callback,
1227 return g_list_reverse (children);
1231 gtk_container_child_position_callback (GtkWidget *widget,
1232 gpointer client_data)
1238 } *data = client_data;
1241 if (data->child == widget)
1242 data->index = data->i;
1246 gtk_container_child_default_composite_name (GtkContainer *container,
1256 /* fallback implementation */
1260 gtk_container_forall (container,
1261 gtk_container_child_position_callback,
1264 name = g_strdup_printf ("%s-%u",
1265 gtk_type_name (GTK_OBJECT_TYPE (child)),
1272 gtk_container_child_composite_name (GtkContainer *container,
1275 g_return_val_if_fail (container != NULL, NULL);
1276 g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
1277 g_return_val_if_fail (child != NULL, NULL);
1278 g_return_val_if_fail (GTK_IS_WIDGET (child), NULL);
1279 g_return_val_if_fail (child->parent == GTK_WIDGET (container), NULL);
1281 if (GTK_WIDGET_COMPOSITE_CHILD (child))
1283 static GQuark quark_composite_name = 0;
1286 if (!quark_composite_name)
1287 quark_composite_name = g_quark_from_static_string ("gtk-composite-name");
1289 name = gtk_object_get_data_by_id (GTK_OBJECT (child), quark_composite_name);
1292 GtkContainerClass *class;
1294 class = GTK_CONTAINER_GET_CLASS (container);
1295 if (class->composite_name)
1296 name = class->composite_name (container, child);
1299 name = g_strdup (name);
1308 gtk_container_real_set_focus_child (GtkContainer *container,
1311 g_return_if_fail (container != NULL);
1312 g_return_if_fail (GTK_IS_CONTAINER (container));
1314 g_return_if_fail (GTK_IS_WIDGET (child));
1316 if (child != container->focus_child)
1318 if (container->focus_child)
1319 gtk_widget_unref (container->focus_child);
1320 container->focus_child = child;
1321 if (container->focus_child)
1322 gtk_widget_ref (container->focus_child);
1326 /* check for h/v adjustments
1328 if (container->focus_child)
1330 GtkAdjustment *adjustment;
1332 adjustment = gtk_object_get_data_by_id (GTK_OBJECT (container), vadjustment_key_id);
1334 gtk_adjustment_clamp_page (adjustment,
1335 container->focus_child->allocation.y,
1336 (container->focus_child->allocation.y +
1337 container->focus_child->allocation.height));
1339 adjustment = gtk_object_get_data_by_id (GTK_OBJECT (container), hadjustment_key_id);
1341 gtk_adjustment_clamp_page (adjustment,
1342 container->focus_child->allocation.x,
1343 (container->focus_child->allocation.x +
1344 container->focus_child->allocation.width));
1349 gtk_container_real_focus (GtkContainer *container,
1350 GtkDirectionType direction)
1357 g_return_val_if_fail (container != NULL, FALSE);
1358 g_return_val_if_fail (GTK_IS_CONTAINER (container), FALSE);
1360 /* Fail if the container is inappropriate for focus movement
1362 if (!GTK_WIDGET_DRAWABLE (container) ||
1363 !GTK_WIDGET_IS_SENSITIVE (container))
1368 if (GTK_WIDGET_CAN_FOCUS (container))
1370 if (!GTK_WIDGET_HAS_FOCUS (container))
1372 gtk_widget_grab_focus (GTK_WIDGET (container));
1378 /* Get a list of the containers children
1381 gtk_container_forall (container,
1382 gtk_container_children_callback,
1384 children = g_list_reverse (children);
1385 /* children = gtk_container_children (container); */
1389 /* Remove any children which are inappropriate for focus movement
1391 tmp_list = children;
1394 if (GTK_WIDGET_IS_SENSITIVE (tmp_list->data) &&
1395 GTK_WIDGET_DRAWABLE (tmp_list->data) &&
1396 (GTK_IS_CONTAINER (tmp_list->data) || GTK_WIDGET_CAN_FOCUS (tmp_list->data)))
1397 tmp_list = tmp_list->next;
1400 tmp_list2 = tmp_list;
1401 tmp_list = tmp_list->next;
1403 children = g_list_remove_link (children, tmp_list2);
1404 g_list_free_1 (tmp_list2);
1410 case GTK_DIR_TAB_FORWARD:
1411 case GTK_DIR_TAB_BACKWARD:
1412 return_val = gtk_container_focus_tab (container, children, direction);
1416 return_val = gtk_container_focus_up_down (container, &children, direction);
1420 return_val = gtk_container_focus_left_right (container, &children, direction);
1424 g_list_free (children);
1432 gtk_container_focus_tab (GtkContainer *container,
1434 GtkDirectionType direction)
1442 length = g_list_length (children);
1444 /* sort the children in the y direction */
1445 for (i = 1; i < length; i++)
1448 tmp_list = g_list_nth (children, j);
1449 child = tmp_list->data;
1453 child2 = tmp_list->prev->data;
1454 if (child->allocation.y < child2->allocation.y)
1456 tmp_list->data = tmp_list->prev->data;
1457 tmp_list = tmp_list->prev;
1464 tmp_list->data = child;
1467 /* sort the children in the x direction while
1468 * maintaining the y direction sort.
1470 for (i = 1; i < length; i++)
1473 tmp_list = g_list_nth (children, j);
1474 child = tmp_list->data;
1478 child2 = tmp_list->prev->data;
1479 if ((child->allocation.x < child2->allocation.x) &&
1480 (child->allocation.y == child2->allocation.y))
1482 tmp_list->data = tmp_list->prev->data;
1483 tmp_list = tmp_list->prev;
1490 tmp_list->data = child;
1493 /* if we are going backwards then reverse the order
1496 if (direction == GTK_DIR_TAB_BACKWARD)
1497 children = g_list_reverse (children);
1499 return gtk_container_focus_move (container, children, direction);
1503 old_focus_coords (GtkContainer *container, GdkRectangle *old_focus_rect)
1505 GtkWidget *widget = GTK_WIDGET (container);
1506 GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
1509 GTK_IS_WINDOW (toplevel) && GTK_WINDOW (toplevel)->focus_widget &&
1510 GTK_WIDGET_REALIZED (container) &&
1511 GTK_WIDGET_REALIZED (GTK_WINDOW (toplevel)->focus_widget))
1513 GtkWidget *old_focus = GTK_WINDOW (toplevel)->focus_widget;
1514 GdkWindow *old_parent_window = old_focus->parent ? old_focus->parent->window : old_focus->window;
1515 GdkWindow *new_parent_window = widget->window;
1516 GdkWindow *toplevel_window = toplevel->window;
1518 *old_focus_rect = old_focus->allocation;
1520 /* Translate coordinates to the toplevel */
1522 while (old_parent_window != toplevel_window)
1526 gdk_window_get_position (old_parent_window, &dx, &dy);
1528 old_focus_rect->x += dx;
1529 old_focus_rect->y += dy;
1531 old_parent_window = gdk_window_get_parent (old_parent_window);
1534 /* Translate coordinates back to the new container */
1536 while (new_parent_window != toplevel_window)
1540 gdk_window_get_position (new_parent_window, &dx, &dy);
1542 old_focus_rect->x -= dx;
1543 old_focus_rect->y -= dy;
1545 new_parent_window = gdk_window_get_parent (new_parent_window);
1554 typedef struct _CompareInfo CompareInfo;
1563 up_down_compare (gconstpointer a,
1567 const GtkWidget *child1 = a;
1568 const GtkWidget *child2 = b;
1569 CompareInfo *compare = data;
1571 gint y1 = child1->allocation.y + child1->allocation.height / 2;
1572 gint y2 = child2->allocation.y + child2->allocation.height / 2;
1576 gint x1 = abs (child1->allocation.x + child1->allocation.width / 2 - compare->x);
1577 gint x2 = abs (child2->allocation.x + child2->allocation.width / 2 - compare->x);
1579 if (compare->y < y1)
1580 return (x1 < x2) ? -1 : ((x1 == x2) ? 0 : 1);
1582 return (x1 < x2) ? 1 : ((x1 == x2) ? 0 : -1);
1585 return (y1 < y2) ? -1 : 1;
1589 gtk_container_focus_up_down (GtkContainer *container,
1591 GtkDirectionType direction)
1593 CompareInfo compare;
1596 if (container->focus_child)
1602 /* Delete widgets from list that don't match minimum criteria */
1604 compare_x1 = container->focus_child->allocation.x;
1605 compare_x2 = container->focus_child->allocation.x + container->focus_child->allocation.width;
1607 if (direction == GTK_DIR_UP)
1608 compare_y = container->focus_child->allocation.y;
1610 compare_y = container->focus_child->allocation.y + container->focus_child->allocation.height;
1612 tmp_list = *children;
1615 GtkWidget *child = tmp_list->data;
1616 GList *next = tmp_list->next;
1617 gint child_x1, child_x2;
1619 if (child != container->focus_child)
1621 child_x1 = child->allocation.x;
1622 child_x2 = child->allocation.x + child->allocation.width;
1624 if ((child_x2 <= compare_x1 || child_x1 >= compare_x2) /* No horizontal overlap */ ||
1625 (direction == GTK_DIR_DOWN && child->allocation.y + child->allocation.height < compare_y) || /* Not below */
1626 (direction == GTK_DIR_UP && child->allocation.y > compare_y)) /* Not above */
1628 *children = g_list_delete_link (*children, tmp_list);
1635 compare.x = (compare_x1 + compare_x2) / 2;
1636 compare.y = container->focus_child->allocation.y + container->focus_child->allocation.height / 2;
1640 /* No old focus widget, need to figure out starting x,y some other way
1642 GtkWidget *widget = GTK_WIDGET (container);
1643 GdkRectangle old_focus_rect;
1645 if (old_focus_coords (container, &old_focus_rect))
1647 compare.x = old_focus_rect.x + old_focus_rect.width / 2;
1651 if (GTK_WIDGET_NO_WINDOW (widget))
1652 compare.x = widget->allocation.x + widget->allocation.width / 2;
1654 compare.x = widget->allocation.width / 2;
1657 if (GTK_WIDGET_NO_WINDOW (widget))
1658 compare.y = (direction == GTK_DIR_DOWN) ? widget->allocation.y : widget->allocation.y + widget->allocation.height;
1660 compare.y = (direction == GTK_DIR_DOWN) ? 0 : + widget->allocation.height;
1663 *children = g_list_sort_with_data (*children, up_down_compare, &compare);
1665 if (direction == GTK_DIR_UP)
1666 *children = g_list_reverse (*children);
1668 return gtk_container_focus_move (container, *children, direction);
1672 left_right_compare (gconstpointer a,
1676 const GtkWidget *child1 = a;
1677 const GtkWidget *child2 = b;
1678 CompareInfo *compare = data;
1680 gint x1 = child1->allocation.x + child1->allocation.width / 2;
1681 gint x2 = child2->allocation.x + child2->allocation.width / 2;
1685 gint y1 = abs (child1->allocation.y + child1->allocation.height / 2 - compare->y);
1686 gint y2 = abs (child2->allocation.y + child2->allocation.height / 2 - compare->y);
1688 if (compare->x < x1)
1689 return (y1 < y2) ? -1 : ((y1 == y2) ? 0 : 1);
1691 return (y1 < y2) ? 1 : ((y1 == y2) ? 0 : -1);
1694 return (x1 < x2) ? -1 : 1;
1698 gtk_container_focus_left_right (GtkContainer *container,
1700 GtkDirectionType direction)
1702 CompareInfo compare;
1705 if (container->focus_child)
1711 /* Delete widgets from list that don't match minimum criteria */
1713 compare_y1 = container->focus_child->allocation.y;
1714 compare_y2 = container->focus_child->allocation.y + container->focus_child->allocation.height;
1716 if (direction == GTK_DIR_LEFT)
1717 compare_x = container->focus_child->allocation.x;
1719 compare_x = container->focus_child->allocation.x + container->focus_child->allocation.width;
1721 tmp_list = *children;
1724 GtkWidget *child = tmp_list->data;
1725 GList *next = tmp_list->next;
1726 gint child_y1, child_y2;
1728 if (child != container->focus_child)
1730 child_y1 = child->allocation.y;
1731 child_y2 = child->allocation.y + child->allocation.height;
1733 if ((child_y2 <= compare_y1 || child_y1 >= compare_y2) /* No vertical overlap */ ||
1734 (direction == GTK_DIR_RIGHT && child->allocation.x + child->allocation.width < compare_x) || /* Not to left */
1735 (direction == GTK_DIR_LEFT && child->allocation.x > compare_x)) /* Not to right */
1737 *children = g_list_delete_link (*children, tmp_list);
1744 compare.y = (compare_y1 + compare_y2) / 2;
1745 compare.x = container->focus_child->allocation.x + container->focus_child->allocation.width / 2;
1749 /* No old focus widget, need to figure out starting x,y some other way
1751 GtkWidget *widget = GTK_WIDGET (container);
1752 GdkRectangle old_focus_rect;
1754 if (old_focus_coords (container, &old_focus_rect))
1756 compare.y = old_focus_rect.y + old_focus_rect.height / 2;
1760 if (GTK_WIDGET_NO_WINDOW (widget))
1761 compare.y = widget->allocation.y + widget->allocation.height / 2;
1763 compare.y = widget->allocation.height / 2;
1766 if (GTK_WIDGET_NO_WINDOW (widget))
1767 compare.x = (direction == GTK_DIR_RIGHT) ? widget->allocation.x : widget->allocation.x + widget->allocation.width;
1769 compare.x = (direction == GTK_DIR_RIGHT) ? 0 : widget->allocation.width;
1772 *children = g_list_sort_with_data (*children, left_right_compare, &compare);
1774 if (direction == GTK_DIR_LEFT)
1775 *children = g_list_reverse (*children);
1777 return gtk_container_focus_move (container, *children, direction);
1781 gtk_container_focus_move (GtkContainer *container,
1783 GtkDirectionType direction)
1785 GtkWidget *focus_child;
1788 focus_child = container->focus_child;
1792 child = children->data;
1793 children = children->next;
1800 if (focus_child == child)
1804 if (GTK_WIDGET_DRAWABLE (child) &&
1805 GTK_IS_CONTAINER (child))
1806 if (gtk_container_focus (GTK_CONTAINER (child), direction))
1810 else if (GTK_WIDGET_DRAWABLE (child))
1812 if (GTK_IS_CONTAINER (child))
1814 if (gtk_container_focus (GTK_CONTAINER (child), direction))
1817 else if (GTK_WIDGET_CAN_FOCUS (child))
1819 gtk_widget_grab_focus (child);
1830 gtk_container_children_callback (GtkWidget *widget,
1831 gpointer client_data)
1835 children = (GList**) client_data;
1836 *children = g_list_prepend (*children, widget);
1840 gtk_container_set_focus_vadjustment (GtkContainer *container,
1841 GtkAdjustment *adjustment)
1843 g_return_if_fail (container != NULL);
1844 g_return_if_fail (GTK_IS_CONTAINER (container));
1846 g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
1849 gtk_object_ref (GTK_OBJECT(adjustment));
1851 gtk_object_set_data_by_id_full (GTK_OBJECT (container),
1854 (GtkDestroyNotify) gtk_object_unref);
1858 gtk_container_set_focus_hadjustment (GtkContainer *container,
1859 GtkAdjustment *adjustment)
1861 g_return_if_fail (container != NULL);
1862 g_return_if_fail (GTK_IS_CONTAINER (container));
1864 g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
1867 gtk_object_ref (GTK_OBJECT (adjustment));
1869 gtk_object_set_data_by_id_full (GTK_OBJECT (container),
1872 (GtkDestroyNotify) gtk_object_unref);
1877 gtk_container_show_all (GtkWidget *widget)
1879 g_return_if_fail (widget != NULL);
1880 g_return_if_fail (GTK_IS_CONTAINER (widget));
1882 gtk_container_foreach (GTK_CONTAINER (widget),
1883 (GtkCallback) gtk_widget_show_all,
1885 gtk_widget_show (widget);
1889 gtk_container_hide_all (GtkWidget *widget)
1891 g_return_if_fail (widget != NULL);
1892 g_return_if_fail (GTK_IS_CONTAINER (widget));
1894 gtk_widget_hide (widget);
1895 gtk_container_foreach (GTK_CONTAINER (widget),
1896 (GtkCallback) gtk_widget_hide_all,