diff options
author | Tim Janik <timj@gtk.org> | 1998-09-03 02:38:53 +0000 |
---|---|---|
committer | Tim Janik <timj@src.gnome.org> | 1998-09-03 02:38:53 +0000 |
commit | 698c89e5c4164fdf0014f2608f9ae32594cf0202 (patch) | |
tree | cce60ec913464dae4b88596a73782c73a9eb09b9 /gtk/gtkcontainer.c | |
parent | af9c5dede49caaf6d0dd82853b653eba5fdd7a7e (diff) | |
download | gtk+-698c89e5c4164fdf0014f2608f9ae32594cf0202.tar.gz |
GTK_MENU_DIR_CHILD: check for the existance of
Thu Sep 3 04:22:20 1998 Tim Janik <timj@gtk.org>
* gtk/gtkmenushell.c (gtk_real_menu_shell_move_current):
GTK_MENU_DIR_CHILD: check for the existance of
menu_shell->active_menu_item before accessing its child.
GTK_MENU_DIR_PREV:
GTK_MENU_DIR_NEXT: if we haven't had an active item and still
don't, make a default selection.
Wed Sep 2 00:28:58 1998 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_propagate_state): iterate
the children with _forall for sensitivity changes and with
_foreach on pure state changes. this fixes a lot of the
old inclusions of internal widgets into _foreach calls.
* gtk/gtktree.c: removed gtk_tree_foreach, let gtk_tree_forall
do the work. don't walk the subtrees of first level children.
* gtk/gtktreeitem.c: provide a _forall implementation,
which walks the subtrees as well for include_internals.
* gtk/gtkmenuitem.c: provide a _forall implementation, which walks
the submenus as well for include_internals.
* gtk/gtkscrolledwindow.c: removed gtk_scrolled_window_foreach and
implemented gtk_scrolled_window_forall, which will iterate over
the viewport and the scrollbars for gtk_container_forall or
iterate over the viewports children for gtk_container_foreach.
* gtk/gtktoolbar.c:
* gtk/gtktable.c:
* gtk/gtkpaned.c:
* gtk/gtkpacker.c:
* gtk/gtkmenushell.c:
* gtk/gtklist.c:
* gtk/gtkfixed.c:
* gtk/gtkclist.c:
* gtk/gtkbox.c:
* gtk/gtkbin.c:
* gtk/gtknotebook.c:
removed the old gtk_*_foreach functions and provided gtk_*_forall.
* gtk/gtknotebook.c:
(gtk_notebook_real_switch_page): expose tabs.
(gtk_notebook_page_num): new function to return the page number
of a distinct child.
(gtk_notebook_focus): minor fixups. foxus handling is still screwed
under some circumstances.
* gtk/gtktreeitem.c:
(gtk_real_tree_item_select):
(gtk_real_tree_item_deselect): major fixes.
some general fixups wrt queue_redraw, and tree items not being
NO_WINDOW widgets.
* gtk/gtklistitem.c:
(gtk_real_list_item_select):
(gtk_real_list_item_deselect):
(gtk_real_list_item_toggle):
removed unneccessary queue_redraw calls.
Wed Aug 30 09:42:07 1998 Tim Janik <timj@gtk.org>
* gtk/gtkoptionmenu.c: allow optionmenus to have the focus and
automatically popup the menu on space bar.
Wed Aug 26 06:40:34 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.h:
* gtk/gtkcontainer.c: implemented gtk_container_forall() (as a class
method), which acts similar to gtk_container_foreach(), but iterates
over internal children. the GtkContainer::foreach signal vanished in
favour of a new class method ->forall() that optionally includes
internal widgets.
* gtk/gtkclist.c (gtk_clist_init): provide no _foreach implementation
but a _forall implementation, since all child widgets we have are
internal ones.
(column_button_create): set the parent window prior
to gtk_widget_set_parent().
* gtk/gtkwidget.c:
exchanged all calls to gtk_container_foreach() with
gtk_container_forall().
* gtk/gtkwidget.h:
* gtk/gtkwidget.c: added the GTK_COMPOSITE_CHILD, exported through
the GtkWidget::composite_child argument. to have a widget created
with the flag initially, two new functions got added to wrap a widgets
creation:
gtk_widget_push_composite_flag() and gtk_widget_pop_composite_flag().
Wed Aug 25 23:37:39 1998 Tim Janik <timj@gtk.org>
* gtk/gtktooltips.h:
* gtk/gtktooltips.c: exported gtk_tooltips_create_window() as
gtk_tooltips_force_window(), so tooltips->tip_window can be accessed
prior to the first tip being set.
don't put an extra reference on the window, since it is a toplevel,
it wont get destroyed from anywhere else.
* overall macro and GtkType fixups.
Diffstat (limited to 'gtk/gtkcontainer.c')
-rw-r--r-- | gtk/gtkcontainer.c | 136 |
1 files changed, 70 insertions, 66 deletions
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index 2bcc30b83f..80e770115f 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -28,7 +28,6 @@ enum { ADD, REMOVE, CHECK_RESIZE, - FOREACH, FOCUS, SET_FOCUS_CHILD, LAST_SIGNAL @@ -178,14 +177,6 @@ gtk_container_class_init (GtkContainerClass *class) GTK_SIGNAL_OFFSET (GtkContainerClass, check_resize), gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0); - container_signals[FOREACH] = - gtk_signal_new ("foreach", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (GtkContainerClass, foreach), - gtk_marshal_NONE__C_CALLBACK, - GTK_TYPE_NONE, 1, - GTK_TYPE_C_CALLBACK); container_signals[FOCUS] = gtk_signal_new ("focus", GTK_RUN_LAST, @@ -207,18 +198,14 @@ gtk_container_class_init (GtkContainerClass *class) object_class->get_arg = gtk_container_get_arg; object_class->set_arg = gtk_container_set_arg; object_class->destroy = gtk_container_destroy; - - /* Other container classes should overwrite show_all and hide_all, - * for the purpose of showing internal children also, which are not - * accessable through gtk_container_foreach. - */ + widget_class->show_all = gtk_container_show_all; widget_class->hide_all = gtk_container_hide_all; - + class->add = gtk_container_add_unimplemented; class->remove = gtk_container_remove_unimplemented; class->check_resize = gtk_container_real_check_resize; - class->foreach = NULL; + class->forall = NULL; class->focus = gtk_container_real_focus; class->set_focus_child = gtk_container_real_set_focus_child; class->child_type = NULL; @@ -621,8 +608,7 @@ gtk_container_destroy (GtkObject *object) } gtk_container_clear_resize_widgets (container); - gtk_container_foreach (container, - (GtkCallback) gtk_widget_destroy, NULL); + gtk_container_foreach (container, (GtkCallback) gtk_widget_destroy, NULL); if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); @@ -1103,17 +1089,37 @@ gtk_container_resize_children (GtkContainer *container) } void +gtk_container_forall (GtkContainer *container, + GtkCallback callback, + gpointer callback_data) +{ + GtkContainerClass *class; + + g_return_if_fail (container != NULL); + g_return_if_fail (GTK_IS_CONTAINER (container)); + g_return_if_fail (callback != NULL); + + class = GTK_CONTAINER_CLASS (GTK_OBJECT (container)->klass); + + if (class->forall) + class->forall (container, TRUE, callback, callback_data); +} + +void gtk_container_foreach (GtkContainer *container, GtkCallback callback, gpointer callback_data) { + GtkContainerClass *class; + g_return_if_fail (container != NULL); g_return_if_fail (GTK_IS_CONTAINER (container)); g_return_if_fail (callback != NULL); - gtk_signal_emit (GTK_OBJECT (container), - container_signals[FOREACH], - callback, callback_data); + class = GTK_CONTAINER_CLASS (GTK_OBJECT (container)->klass); + + if (class->forall) + class->forall (container, FALSE, callback, callback_data); } typedef struct _GtkForeachData GtkForeachData; @@ -1292,9 +1298,10 @@ gtk_container_real_focus (GtkContainer *container, g_return_val_if_fail (container != NULL, FALSE); g_return_val_if_fail (GTK_IS_CONTAINER (container), FALSE); - /* Fail if the container is insensitive + /* Fail if the container is inappropriate for focus movement */ - if (!GTK_WIDGET_SENSITIVE (container)) + if (!GTK_WIDGET_DRAWABLE (container) || + !GTK_WIDGET_SENSITIVE (container)) return FALSE; return_val = FALSE; @@ -1308,25 +1315,32 @@ gtk_container_real_focus (GtkContainer *container, { /* Get a list of the containers children */ - children = gtk_container_children (container); + children = NULL; + gtk_container_forall (container, + gtk_container_children_callback, + &children); + children = g_list_reverse (children); + /* children = gtk_container_children (container); */ if (children) { - /* Remove any children which are insensitive + /* Remove any children which are inappropriate for focus movement */ tmp_list = children; while (tmp_list) { - if (!GTK_WIDGET_SENSITIVE (tmp_list->data)) + if (GTK_WIDGET_SENSITIVE (tmp_list->data) && + GTK_WIDGET_DRAWABLE (tmp_list->data) && + (GTK_IS_CONTAINER (tmp_list->data) || GTK_WIDGET_CAN_FOCUS (tmp_list->data))) + tmp_list = tmp_list->next; + else { tmp_list2 = tmp_list; tmp_list = tmp_list->next; - + children = g_list_remove_link (children, tmp_list2); g_list_free_1 (tmp_list2); } - else - tmp_list = tmp_list->next; } switch (direction) @@ -1668,14 +1682,14 @@ gtk_container_focus_move (GtkContainer *container, { focus_child = NULL; - if (GTK_WIDGET_VISIBLE (child) && + if (GTK_WIDGET_DRAWABLE (child) && GTK_IS_CONTAINER (child) && !GTK_WIDGET_HAS_FOCUS (child)) if (gtk_container_focus (GTK_CONTAINER (child), direction)) return TRUE; } } - else if (GTK_WIDGET_VISIBLE (child)) + else if (GTK_WIDGET_DRAWABLE (child)) { if (GTK_IS_CONTAINER (child)) { @@ -1704,41 +1718,6 @@ gtk_container_children_callback (GtkWidget *widget, *children = g_list_prepend (*children, widget); } -static void -gtk_container_show_all (GtkWidget *widget) -{ - GtkContainer *container; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_CONTAINER (widget)); - container = GTK_CONTAINER (widget); - - /* First show children, then self. - This makes sure that toplevel windows get shown as last widget. - Otherwise the user would see the widgets get - visible one after another. - */ - gtk_container_foreach (container, (GtkCallback) gtk_widget_show_all, NULL); - gtk_widget_show (widget); -} - - -static void -gtk_container_hide_all (GtkWidget *widget) -{ - GtkContainer *container; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_CONTAINER (widget)); - container = GTK_CONTAINER (widget); - - /* First hide self, then children. - This is the reverse order of gtk_container_show_all. - */ - gtk_widget_hide (widget); - gtk_container_foreach (container, (GtkCallback) gtk_widget_hide_all, NULL); -} - void gtk_container_set_focus_vadjustment (GtkContainer *container, GtkAdjustment *adjustment) @@ -1774,3 +1753,28 @@ gtk_container_set_focus_hadjustment (GtkContainer *container, adjustment, (GtkDestroyNotify) gtk_object_unref); } + + +static void +gtk_container_show_all (GtkWidget *widget) +{ + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_CONTAINER (widget)); + + gtk_container_foreach (GTK_CONTAINER (widget), + (GtkCallback) gtk_widget_show_all, + NULL); + gtk_widget_show (widget); +} + +static void +gtk_container_hide_all (GtkWidget *widget) +{ + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_CONTAINER (widget)); + + gtk_widget_hide (widget); + gtk_container_foreach (GTK_CONTAINER (widget), + (GtkCallback) gtk_widget_hide_all, + NULL); +} |