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 Library 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 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library 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.
20 #include "gtkcontainer.h"
21 #include "gtkprivate.h"
22 #include "gtksignal.h"
42 typedef void (*GtkContainerSignal1) (GtkObject *object,
45 typedef void (*GtkContainerSignal2) (GtkObject *object,
49 typedef gint (*GtkContainerSignal3) (GtkObject *object,
52 typedef gint (*GtkContainerSignal4) (GtkObject *object,
56 static void gtk_container_marshal_signal_1 (GtkObject *object,
60 static void gtk_container_marshal_signal_2 (GtkObject *object,
64 static void gtk_container_marshal_signal_3 (GtkObject *object,
68 static void gtk_container_marshal_signal_4 (GtkObject *object,
74 static void gtk_container_class_init (GtkContainerClass *klass);
75 static void gtk_container_init (GtkContainer *container);
76 static void gtk_container_destroy (GtkObject *object);
77 static void gtk_container_get_arg (GtkContainer *container,
80 static void gtk_container_set_arg (GtkContainer *container,
83 static void gtk_container_add_unimplemented (GtkContainer *container,
85 static void gtk_container_remove_unimplemented (GtkContainer *container,
87 static gint gtk_real_container_need_resize (GtkContainer *container);
88 static gint gtk_real_container_focus (GtkContainer *container,
89 GtkDirectionType direction);
90 static gint gtk_container_focus_tab (GtkContainer *container,
92 GtkDirectionType direction);
93 static gint gtk_container_focus_up_down (GtkContainer *container,
95 GtkDirectionType direction);
96 static gint gtk_container_focus_left_right (GtkContainer *container,
98 GtkDirectionType direction);
99 static gint gtk_container_focus_move (GtkContainer *container,
101 GtkDirectionType direction);
102 static void gtk_container_children_callback (GtkWidget *widget,
103 gpointer client_data);
104 static void gtk_container_show_all (GtkWidget *widget);
105 static void gtk_container_hide_all (GtkWidget *widget);
109 static guint container_signals[LAST_SIGNAL] = { 0 };
111 static GtkWidgetClass *parent_class = NULL;
113 static const gchar *vadjustment_key = "gtk-vadjustment";
114 static guint vadjustment_key_id = 0;
115 static const gchar *hadjustment_key = "gtk-hadjustment";
116 static guint hadjustment_key_id = 0;
119 gtk_container_get_type ()
121 static GtkType container_type = 0;
125 GtkTypeInfo container_info =
128 sizeof (GtkContainer),
129 sizeof (GtkContainerClass),
130 (GtkClassInitFunc) gtk_container_class_init,
131 (GtkObjectInitFunc) gtk_container_init,
132 (GtkArgSetFunc) gtk_container_set_arg,
133 (GtkArgGetFunc) gtk_container_get_arg,
136 container_type = gtk_type_unique (gtk_widget_get_type (), &container_info);
139 return container_type;
143 gtk_container_class_init (GtkContainerClass *class)
145 GtkObjectClass *object_class;
146 GtkWidgetClass *widget_class;
148 object_class = (GtkObjectClass*) class;
149 widget_class = (GtkWidgetClass*) class;
151 parent_class = gtk_type_class (gtk_widget_get_type ());
153 vadjustment_key_id = gtk_object_data_force_id (vadjustment_key);
154 hadjustment_key_id = gtk_object_data_force_id (hadjustment_key);
156 gtk_object_add_arg_type ("GtkContainer::border_width", GTK_TYPE_LONG, GTK_ARG_READWRITE, ARG_BORDER_WIDTH);
157 gtk_object_add_arg_type ("GtkContainer::auto_resize", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_AUTO_RESIZE);
158 gtk_object_add_arg_type ("GtkContainer::block_resize", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_BLOCK_RESIZE);
159 gtk_object_add_arg_type ("GtkContainer::child", GTK_TYPE_WIDGET, GTK_ARG_WRITABLE, ARG_CHILD);
161 container_signals[ADD] =
162 gtk_signal_new ("add",
165 GTK_SIGNAL_OFFSET (GtkContainerClass, add),
166 gtk_container_marshal_signal_1,
169 container_signals[REMOVE] =
170 gtk_signal_new ("remove",
173 GTK_SIGNAL_OFFSET (GtkContainerClass, remove),
174 gtk_container_marshal_signal_1,
177 container_signals[NEED_RESIZE] =
178 gtk_signal_new ("need_resize",
181 GTK_SIGNAL_OFFSET (GtkContainerClass, need_resize),
182 gtk_container_marshal_signal_4,
184 container_signals[FOREACH] =
185 gtk_signal_new ("foreach",
188 GTK_SIGNAL_OFFSET (GtkContainerClass, foreach),
189 gtk_container_marshal_signal_2,
191 GTK_TYPE_C_CALLBACK);
192 container_signals[FOCUS] =
193 gtk_signal_new ("focus",
196 GTK_SIGNAL_OFFSET (GtkContainerClass, focus),
197 gtk_container_marshal_signal_3,
198 GTK_TYPE_DIRECTION_TYPE, 1,
199 GTK_TYPE_DIRECTION_TYPE);
201 gtk_object_class_add_signals (object_class, container_signals, LAST_SIGNAL);
203 object_class->destroy = gtk_container_destroy;
205 /* Other container classes should overwrite show_all and hide_all,
206 * for the purpose of showing internal children also, which are not
207 * accessable through gtk_container_foreach.
209 widget_class->show_all = gtk_container_show_all;
210 widget_class->hide_all = gtk_container_hide_all;
212 class->add = gtk_container_add_unimplemented;
213 class->remove = gtk_container_remove_unimplemented;
214 class->need_resize = gtk_real_container_need_resize;
215 class->foreach = NULL;
216 class->focus = gtk_real_container_focus;
220 gtk_container_add_unimplemented (GtkContainer *container,
223 g_warning ("GtkContainerClass::add not implemented for `%s'", gtk_type_name (GTK_OBJECT_TYPE (container)));
227 gtk_container_remove_unimplemented (GtkContainer *container,
230 g_warning ("GtkContainerClass::remove not implemented for `%s'", gtk_type_name (GTK_OBJECT_TYPE (container)));
234 gtk_container_init (GtkContainer *container)
236 container->focus_child = NULL;
237 container->border_width = 0;
238 container->auto_resize = TRUE;
239 container->need_resize = FALSE;
240 container->block_resize = FALSE;
241 container->resize_widgets = NULL;
245 gtk_container_destroy (GtkObject *object)
249 g_return_if_fail (object != NULL);
250 g_return_if_fail (GTK_IS_CONTAINER (object));
252 for (node = GTK_CONTAINER (object)->resize_widgets; node; node = node->next)
256 child = (GtkWidget*) node->data;
257 GTK_PRIVATE_UNSET_FLAG (child, GTK_RESIZE_NEEDED);
259 g_slist_free (GTK_CONTAINER (object)->resize_widgets);
260 GTK_CONTAINER (object)->resize_widgets = NULL;
262 gtk_container_foreach (GTK_CONTAINER (object),
263 (GtkCallback) gtk_widget_destroy, NULL);
265 if (GTK_OBJECT_CLASS (parent_class)->destroy)
266 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
270 gtk_container_set_arg (GtkContainer *container,
276 case ARG_BORDER_WIDTH:
277 gtk_container_border_width (container, GTK_VALUE_LONG (*arg));
279 case ARG_AUTO_RESIZE:
280 if (GTK_VALUE_BOOL (*arg))
281 gtk_container_enable_resize (container);
283 gtk_container_disable_resize (container);
285 case ARG_BLOCK_RESIZE:
286 if (GTK_VALUE_BOOL (*arg))
287 gtk_container_block_resize (container);
289 gtk_container_unblock_resize (container);
292 gtk_container_add (container, GTK_WIDGET (GTK_VALUE_OBJECT (*arg)));
295 arg->type = GTK_TYPE_INVALID;
301 gtk_container_get_arg (GtkContainer *container,
307 case ARG_BORDER_WIDTH:
308 GTK_VALUE_LONG (*arg) = container->border_width;
310 case ARG_AUTO_RESIZE:
311 GTK_VALUE_BOOL (*arg) = container->auto_resize;
313 case ARG_BLOCK_RESIZE:
314 GTK_VALUE_BOOL (*arg) = container->block_resize;
317 arg->type = GTK_TYPE_INVALID;
323 gtk_container_border_width (GtkContainer *container,
326 g_return_if_fail (container != NULL);
327 g_return_if_fail (GTK_IS_CONTAINER (container));
329 if (container->border_width != border_width)
331 container->border_width = border_width;
333 if (GTK_WIDGET_REALIZED (container))
334 gtk_widget_queue_resize (GTK_WIDGET (container));
339 gtk_container_add (GtkContainer *container,
342 g_return_if_fail (container != NULL);
343 g_return_if_fail (GTK_IS_CONTAINER (container));
344 g_return_if_fail (widget != NULL);
345 g_return_if_fail (GTK_IS_WIDGET (widget));
346 g_return_if_fail (widget->parent == NULL);
348 gtk_signal_emit (GTK_OBJECT (container), container_signals[ADD], widget);
352 gtk_container_remove (GtkContainer *container,
355 g_return_if_fail (container != NULL);
356 g_return_if_fail (GTK_IS_CONTAINER (container));
357 g_return_if_fail (widget != NULL);
358 g_return_if_fail (GTK_IS_WIDGET (widget));
359 g_return_if_fail (widget->parent == GTK_WIDGET (container));
361 gtk_signal_emit (GTK_OBJECT (container), container_signals[REMOVE], widget);
365 gtk_container_disable_resize (GtkContainer *container)
367 g_return_if_fail (container != NULL);
368 g_return_if_fail (GTK_IS_CONTAINER (container));
370 container->auto_resize = FALSE;
374 gtk_container_enable_resize (GtkContainer *container)
376 g_return_if_fail (container != NULL);
377 g_return_if_fail (GTK_IS_CONTAINER (container));
379 container->auto_resize = TRUE;
380 if (container->need_resize)
382 container->need_resize = FALSE;
383 gtk_widget_queue_resize (GTK_WIDGET (container));
388 gtk_container_block_resize (GtkContainer *container)
390 g_return_if_fail (container != NULL);
391 g_return_if_fail (GTK_IS_CONTAINER (container));
393 container->block_resize = TRUE;
397 gtk_container_unblock_resize (GtkContainer *container)
399 g_return_if_fail (container != NULL);
400 g_return_if_fail (GTK_IS_CONTAINER (container));
402 container->block_resize = FALSE;
406 gtk_container_need_resize (GtkContainer *container)
410 g_return_val_if_fail (container != NULL, FALSE);
411 g_return_val_if_fail (GTK_IS_CONTAINER (container), FALSE);
415 if (!container->block_resize)
417 if (container->auto_resize)
418 gtk_signal_emit (GTK_OBJECT (container),
419 container_signals[NEED_RESIZE],
422 container->need_resize = TRUE;
429 gtk_container_foreach (GtkContainer *container,
430 GtkCallback callback,
431 gpointer callback_data)
433 gtk_signal_emit (GTK_OBJECT (container),
434 container_signals[FOREACH],
435 callback, callback_data);
438 typedef struct _GtkForeachData GtkForeachData;
439 struct _GtkForeachData
441 GtkObject *container;
442 GtkCallbackMarshal callback;
443 gpointer callback_data;
447 gtk_container_foreach_unmarshal (GtkWidget *child,
450 GtkForeachData *fdata = (GtkForeachData*) data;
455 args[0].type = GTK_OBJECT(child)->klass->type;
456 GTK_VALUE_OBJECT(args[0]) = GTK_OBJECT (child);
458 /* location for return value */
460 args[1].type = GTK_TYPE_NONE;
462 fdata->callback (fdata->container, fdata->callback_data, 1, args);
466 gtk_container_foreach_interp (GtkContainer *container,
467 GtkCallbackMarshal marshal,
468 gpointer callback_data,
469 GtkDestroyNotify notify)
471 gtk_container_foreach_full (container, NULL, marshal,
472 callback_data, notify);
476 gtk_container_foreach_full (GtkContainer *container,
477 GtkCallback callback,
478 GtkCallbackMarshal marshal,
479 gpointer callback_data,
480 GtkDestroyNotify notify)
484 GtkForeachData fdata;
486 fdata.container = GTK_OBJECT (container);
487 fdata.callback = marshal;
488 fdata.callback_data = callback_data;
490 gtk_container_foreach (container, gtk_container_foreach_unmarshal, &fdata);
493 gtk_container_foreach (container, callback, &callback_data);
495 notify (callback_data);
499 gtk_container_focus (GtkContainer *container,
500 GtkDirectionType direction)
504 gtk_signal_emit (GTK_OBJECT (container),
505 container_signals[FOCUS],
506 direction, &return_val);
512 gtk_container_children (GtkContainer *container)
518 gtk_container_foreach (container,
519 gtk_container_children_callback,
522 return g_list_reverse (children);
526 gtk_container_register_toplevel (GtkContainer *container)
528 gtk_widget_ref (GTK_WIDGET (container));
529 gtk_object_sink (GTK_OBJECT (container));
533 gtk_container_unregister_toplevel (GtkContainer *container)
535 gtk_widget_unref (GTK_WIDGET (container));
539 gtk_container_set_focus_child (GtkContainer *container,
542 g_return_if_fail (container != NULL);
543 g_return_if_fail (GTK_IS_CONTAINER (container));
545 g_return_if_fail (GTK_IS_WIDGET (child));
547 if (child != container->focus_child)
549 if (container->focus_child)
550 gtk_widget_unref (container->focus_child);
551 container->focus_child = child;
552 if (container->focus_child)
553 gtk_widget_ref (container->focus_child);
557 /* check for h/v adjustments
559 if (container->focus_child)
561 GtkAdjustment *adjustment;
563 adjustment = gtk_object_get_data_by_id (GTK_OBJECT (container), vadjustment_key_id);
565 gtk_adjustment_clamp_page (adjustment,
566 container->focus_child->allocation.y,
567 (container->focus_child->allocation.y +
568 container->focus_child->allocation.height));
570 adjustment = gtk_object_get_data_by_id (GTK_OBJECT (container), hadjustment_key_id);
572 gtk_adjustment_clamp_page (adjustment,
573 container->focus_child->allocation.x,
574 (container->focus_child->allocation.x +
575 container->focus_child->allocation.width));
580 gtk_container_marshal_signal_1 (GtkObject *object,
585 GtkContainerSignal1 rfunc;
587 rfunc = (GtkContainerSignal1) func;
589 (* rfunc) (object, GTK_VALUE_OBJECT (args[0]), func_data);
593 gtk_container_marshal_signal_2 (GtkObject *object,
598 GtkContainerSignal2 rfunc;
600 rfunc = (GtkContainerSignal2) func;
603 GTK_VALUE_C_CALLBACK(args[0]).func,
604 GTK_VALUE_C_CALLBACK(args[0]).func_data,
609 gtk_container_marshal_signal_3 (GtkObject *object,
614 GtkContainerSignal3 rfunc;
617 rfunc = (GtkContainerSignal3) func;
618 return_val = GTK_RETLOC_ENUM (args[1]);
620 *return_val = (* rfunc) (object, GTK_VALUE_ENUM(args[0]), func_data);
624 gtk_container_marshal_signal_4 (GtkObject *object,
629 GtkContainerSignal4 rfunc;
632 rfunc = (GtkContainerSignal4) func;
633 return_val = GTK_RETLOC_BOOL (args[0]);
635 *return_val = (* rfunc) (object, func_data);
639 gtk_real_container_need_resize (GtkContainer *container)
641 g_return_val_if_fail (container != NULL, FALSE);
642 g_return_val_if_fail (GTK_IS_CONTAINER (container), FALSE);
644 if (GTK_WIDGET_VISIBLE (container) && container->widget.parent)
645 return gtk_container_need_resize (GTK_CONTAINER (container->widget.parent));
651 gtk_real_container_focus (GtkContainer *container,
652 GtkDirectionType direction)
659 g_return_val_if_fail (container != NULL, FALSE);
660 g_return_val_if_fail (GTK_IS_CONTAINER (container), FALSE);
662 /* Fail if the container is insensitive
664 if (!GTK_WIDGET_SENSITIVE (container))
669 if (GTK_WIDGET_CAN_FOCUS (container))
671 gtk_widget_grab_focus (GTK_WIDGET (container));
676 /* Get a list of the containers children
678 children = gtk_container_children (container);
682 /* Remove any children which are insensitive
687 if (!GTK_WIDGET_SENSITIVE (tmp_list->data))
689 tmp_list2 = tmp_list;
690 tmp_list = tmp_list->next;
692 children = g_list_remove_link (children, tmp_list2);
693 g_list_free_1 (tmp_list2);
696 tmp_list = tmp_list->next;
701 case GTK_DIR_TAB_FORWARD:
702 case GTK_DIR_TAB_BACKWARD:
703 return_val = gtk_container_focus_tab (container, children, direction);
707 return_val = gtk_container_focus_up_down (container, children, direction);
711 return_val = gtk_container_focus_left_right (container, children, direction);
715 g_list_free (children);
723 gtk_container_focus_tab (GtkContainer *container,
725 GtkDirectionType direction)
733 length = g_list_length (children);
735 /* sort the children in the y direction */
736 for (i = 1; i < length; i++)
739 tmp_list = g_list_nth (children, j);
740 child = tmp_list->data;
744 child2 = tmp_list->prev->data;
745 if (child->allocation.y < child2->allocation.y)
747 tmp_list->data = tmp_list->prev->data;
748 tmp_list = tmp_list->prev;
755 tmp_list->data = child;
758 /* sort the children in the x direction while
759 * maintaining the y direction sort.
761 for (i = 1; i < length; i++)
764 tmp_list = g_list_nth (children, j);
765 child = tmp_list->data;
769 child2 = tmp_list->prev->data;
770 if ((child->allocation.x < child2->allocation.x) &&
771 (child->allocation.y == child2->allocation.y))
773 tmp_list->data = tmp_list->prev->data;
774 tmp_list = tmp_list->prev;
781 tmp_list->data = child;
784 /* if we are going backwards then reverse the order
787 if (direction == GTK_DIR_TAB_BACKWARD)
788 children = g_list_reverse (children);
790 return gtk_container_focus_move (container, children, direction);
794 gtk_container_focus_up_down (GtkContainer *container,
796 GtkDirectionType direction)
807 /* return failure if there isn't a focus child */
808 if (container->focus_child)
810 focus_width = container->focus_child->allocation.width / 2;
811 focus_x = container->focus_child->allocation.x + focus_width;
815 focus_width = GTK_WIDGET (container)->allocation.width;
816 if (GTK_WIDGET_NO_WINDOW (container))
817 focus_x = GTK_WIDGET (container)->allocation.x;
822 length = g_list_length (children);
824 /* sort the children in the y direction */
825 for (i = 1; i < length; i++)
828 tmp_list = g_list_nth (children, j);
829 child = tmp_list->data;
833 child2 = tmp_list->prev->data;
834 if (child->allocation.y < child2->allocation.y)
836 tmp_list->data = tmp_list->prev->data;
837 tmp_list = tmp_list->prev;
844 tmp_list->data = child;
847 /* sort the children in distance in the x direction
848 * in distance from the current focus child while maintaining the
849 * sort in the y direction
851 for (i = 1; i < length; i++)
854 tmp_list = g_list_nth (children, j);
855 child = tmp_list->data;
856 dist1 = (child->allocation.x + child->allocation.width / 2) - focus_x;
860 child2 = tmp_list->prev->data;
861 dist2 = (child2->allocation.x + child2->allocation.width / 2) - focus_x;
863 if ((dist1 < dist2) &&
864 (child->allocation.y >= child2->allocation.y))
866 tmp_list->data = tmp_list->prev->data;
867 tmp_list = tmp_list->prev;
874 tmp_list->data = child;
877 /* go and invalidate any widget which is too
878 * far from the focus widget.
880 if (!container->focus_child &&
881 (direction == GTK_DIR_UP))
882 focus_x += focus_width;
887 child = tmp_list->data;
889 dist1 = (child->allocation.x + child->allocation.width / 2) - focus_x;
890 if (((direction == GTK_DIR_DOWN) && (dist1 < 0)) ||
891 ((direction == GTK_DIR_UP) && (dist1 > 0)))
892 tmp_list->data = NULL;
894 tmp_list = tmp_list->next;
897 if (direction == GTK_DIR_UP)
898 children = g_list_reverse (children);
900 return gtk_container_focus_move (container, children, direction);
904 gtk_container_focus_left_right (GtkContainer *container,
906 GtkDirectionType direction)
917 /* return failure if there isn't a focus child */
918 if (container->focus_child)
920 focus_height = container->focus_child->allocation.height / 2;
921 focus_y = container->focus_child->allocation.y + focus_height;
925 focus_height = GTK_WIDGET (container)->allocation.height;
926 if (GTK_WIDGET_NO_WINDOW (container))
927 focus_y = GTK_WIDGET (container)->allocation.y;
932 length = g_list_length (children);
934 /* sort the children in the x direction */
935 for (i = 1; i < length; i++)
938 tmp_list = g_list_nth (children, j);
939 child = tmp_list->data;
943 child2 = tmp_list->prev->data;
944 if (child->allocation.x < child2->allocation.x)
946 tmp_list->data = tmp_list->prev->data;
947 tmp_list = tmp_list->prev;
954 tmp_list->data = child;
957 /* sort the children in distance in the y direction
958 * in distance from the current focus child while maintaining the
959 * sort in the x direction
961 for (i = 1; i < length; i++)
964 tmp_list = g_list_nth (children, j);
965 child = tmp_list->data;
966 dist1 = (child->allocation.y + child->allocation.height / 2) - focus_y;
970 child2 = tmp_list->prev->data;
971 dist2 = (child2->allocation.y + child2->allocation.height / 2) - focus_y;
973 if ((dist1 < dist2) &&
974 (child->allocation.x >= child2->allocation.x))
976 tmp_list->data = tmp_list->prev->data;
977 tmp_list = tmp_list->prev;
984 tmp_list->data = child;
987 /* go and invalidate any widget which is too
988 * far from the focus widget.
990 if (!container->focus_child &&
991 (direction == GTK_DIR_LEFT))
992 focus_y += focus_height;
997 child = tmp_list->data;
999 dist1 = (child->allocation.y + child->allocation.height / 2) - focus_y;
1000 if (((direction == GTK_DIR_RIGHT) && (dist1 < 0)) ||
1001 ((direction == GTK_DIR_LEFT) && (dist1 > 0)))
1002 tmp_list->data = NULL;
1004 tmp_list = tmp_list->next;
1007 if (direction == GTK_DIR_LEFT)
1008 children = g_list_reverse (children);
1010 return gtk_container_focus_move (container, children, direction);
1014 gtk_container_focus_move (GtkContainer *container,
1016 GtkDirectionType direction)
1018 GtkWidget *focus_child;
1021 focus_child = container->focus_child;
1022 gtk_container_set_focus_child (container, NULL);
1026 child = children->data;
1027 children = children->next;
1034 if (focus_child == child)
1038 if (GTK_WIDGET_VISIBLE (child) &&
1039 GTK_IS_CONTAINER (child) &&
1040 !GTK_WIDGET_HAS_FOCUS (child))
1041 if (gtk_container_focus (GTK_CONTAINER (child), direction))
1045 else if (GTK_WIDGET_VISIBLE (child))
1047 if (GTK_WIDGET_CAN_FOCUS (child))
1049 gtk_widget_grab_focus (child);
1052 else if (GTK_IS_CONTAINER (child))
1054 if (gtk_container_focus (GTK_CONTAINER (child), direction))
1065 gtk_container_children_callback (GtkWidget *widget,
1066 gpointer client_data)
1070 children = (GList**) client_data;
1071 *children = g_list_prepend (*children, widget);
1075 gtk_container_show_all (GtkWidget *widget)
1077 GtkContainer *container;
1079 g_return_if_fail (widget != NULL);
1080 g_return_if_fail (GTK_IS_CONTAINER (widget));
1081 container = GTK_CONTAINER (widget);
1083 /* First show children, then self.
1084 This makes sure that toplevel windows get shown as last widget.
1085 Otherwise the user would see the widgets get
1086 visible one after another.
1088 gtk_container_foreach (container, (GtkCallback) gtk_widget_show_all, NULL);
1089 gtk_widget_show (widget);
1094 gtk_container_hide_all (GtkWidget *widget)
1096 GtkContainer *container;
1098 g_return_if_fail (widget != NULL);
1099 g_return_if_fail (GTK_IS_CONTAINER (widget));
1100 container = GTK_CONTAINER (widget);
1102 /* First hide self, then children.
1103 This is the reverse order of gtk_container_show_all.
1105 gtk_widget_hide (widget);
1106 gtk_container_foreach (container, (GtkCallback) gtk_widget_hide_all, NULL);
1110 gtk_container_set_focus_vadjustment (GtkContainer *container,
1111 GtkAdjustment *adjustment)
1113 g_return_if_fail (container != NULL);
1114 g_return_if_fail (GTK_IS_CONTAINER (container));
1116 g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
1119 gtk_object_ref (adjustment);
1121 gtk_object_set_data_by_id_full (GTK_OBJECT (container),
1124 (GtkDestroyNotify) gtk_object_unref);
1128 gtk_container_set_focus_hadjustment (GtkContainer *container,
1129 GtkAdjustment *adjustment)
1131 g_return_if_fail (container != NULL);
1132 g_return_if_fail (GTK_IS_CONTAINER (container));
1134 g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
1137 gtk_object_ref (adjustment);
1139 gtk_object_set_data_by_id_full (GTK_OBJECT (container),
1142 (GtkDestroyNotify) gtk_object_unref);