new function to set the current focus_child of a container, does proper

Sun May  3 16:55:43 1998  Tim Janik  <timj@gtk.org>

        * gtk/gtkcontainer.c (gtk_container_set_focus_child): new function to
                set the current focus_child of a container, does proper referencing and
                        adjusts the vadjustment/hadjustment associated with the focus widget.

                                * gtk/gtkwidget.c (gtk_widget_grab_focus): set the focused child on
                                        containers via gtk_container_set_focus_child.

                                                * gtk/gtknotebook.c: modifications to use gtk_container_set_focus_child
                                                        where appropriate.

                                                                * gtk/gtkcontainer.c (gtk_container_remove): removed unsetting of focus
                                                                        child since not every child removal goes through this function (this
                                                                                showed up after gtk_container_set_focus_child() started to reference the
                                                                                        focus_child of a container).

                                                                                                * gtk/gtkwidget.c (gtk_widget_unparent): moved unsetting the focus_child
                                                                                                        of a container from gtk_container_remove into this place.
This commit is contained in:
Tim Janik 1998-05-03 15:45:08 +00:00 committed by Tim Janik
parent 2ca03393f5
commit 19bbe0557f
11 changed files with 217 additions and 50 deletions

View File

@ -1,3 +1,23 @@
Sun May 3 16:55:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_set_focus_child): new function to
set the current focus_child of a container, does proper referencing and
adjusts the vadjustment/hadjustment associated with the focus widget.
* gtk/gtkwidget.c (gtk_widget_grab_focus): set the focused child on
containers via gtk_container_set_focus_child.
* gtk/gtknotebook.c: modifications to use gtk_container_set_focus_child
where appropriate.
* gtk/gtkcontainer.c (gtk_container_remove): removed unsetting of focus
child since not every child removal goes through this function (this
showed up after gtk_container_set_focus_child() started to reference the
focus_child of a container).
* gtk/gtkwidget.c (gtk_widget_unparent): moved unsetting the focus_child
of a container from gtk_container_remove into this place.
Sat May 2 22:33:45 1998 Tim Janik <timj@gtk.org>
* gtk/gtksignal.c: added new functions to operate on intermediate

View File

@ -1,3 +1,23 @@
Sun May 3 16:55:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_set_focus_child): new function to
set the current focus_child of a container, does proper referencing and
adjusts the vadjustment/hadjustment associated with the focus widget.
* gtk/gtkwidget.c (gtk_widget_grab_focus): set the focused child on
containers via gtk_container_set_focus_child.
* gtk/gtknotebook.c: modifications to use gtk_container_set_focus_child
where appropriate.
* gtk/gtkcontainer.c (gtk_container_remove): removed unsetting of focus
child since not every child removal goes through this function (this
showed up after gtk_container_set_focus_child() started to reference the
focus_child of a container).
* gtk/gtkwidget.c (gtk_widget_unparent): moved unsetting the focus_child
of a container from gtk_container_remove into this place.
Sat May 2 22:33:45 1998 Tim Janik <timj@gtk.org>
* gtk/gtksignal.c: added new functions to operate on intermediate

View File

@ -1,3 +1,23 @@
Sun May 3 16:55:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_set_focus_child): new function to
set the current focus_child of a container, does proper referencing and
adjusts the vadjustment/hadjustment associated with the focus widget.
* gtk/gtkwidget.c (gtk_widget_grab_focus): set the focused child on
containers via gtk_container_set_focus_child.
* gtk/gtknotebook.c: modifications to use gtk_container_set_focus_child
where appropriate.
* gtk/gtkcontainer.c (gtk_container_remove): removed unsetting of focus
child since not every child removal goes through this function (this
showed up after gtk_container_set_focus_child() started to reference the
focus_child of a container).
* gtk/gtkwidget.c (gtk_widget_unparent): moved unsetting the focus_child
of a container from gtk_container_remove into this place.
Sat May 2 22:33:45 1998 Tim Janik <timj@gtk.org>
* gtk/gtksignal.c: added new functions to operate on intermediate

View File

@ -1,3 +1,23 @@
Sun May 3 16:55:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_set_focus_child): new function to
set the current focus_child of a container, does proper referencing and
adjusts the vadjustment/hadjustment associated with the focus widget.
* gtk/gtkwidget.c (gtk_widget_grab_focus): set the focused child on
containers via gtk_container_set_focus_child.
* gtk/gtknotebook.c: modifications to use gtk_container_set_focus_child
where appropriate.
* gtk/gtkcontainer.c (gtk_container_remove): removed unsetting of focus
child since not every child removal goes through this function (this
showed up after gtk_container_set_focus_child() started to reference the
focus_child of a container).
* gtk/gtkwidget.c (gtk_widget_unparent): moved unsetting the focus_child
of a container from gtk_container_remove into this place.
Sat May 2 22:33:45 1998 Tim Janik <timj@gtk.org>
* gtk/gtksignal.c: added new functions to operate on intermediate

View File

@ -1,3 +1,23 @@
Sun May 3 16:55:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_set_focus_child): new function to
set the current focus_child of a container, does proper referencing and
adjusts the vadjustment/hadjustment associated with the focus widget.
* gtk/gtkwidget.c (gtk_widget_grab_focus): set the focused child on
containers via gtk_container_set_focus_child.
* gtk/gtknotebook.c: modifications to use gtk_container_set_focus_child
where appropriate.
* gtk/gtkcontainer.c (gtk_container_remove): removed unsetting of focus
child since not every child removal goes through this function (this
showed up after gtk_container_set_focus_child() started to reference the
focus_child of a container).
* gtk/gtkwidget.c (gtk_widget_unparent): moved unsetting the focus_child
of a container from gtk_container_remove into this place.
Sat May 2 22:33:45 1998 Tim Janik <timj@gtk.org>
* gtk/gtksignal.c: added new functions to operate on intermediate

View File

@ -1,3 +1,23 @@
Sun May 3 16:55:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_set_focus_child): new function to
set the current focus_child of a container, does proper referencing and
adjusts the vadjustment/hadjustment associated with the focus widget.
* gtk/gtkwidget.c (gtk_widget_grab_focus): set the focused child on
containers via gtk_container_set_focus_child.
* gtk/gtknotebook.c: modifications to use gtk_container_set_focus_child
where appropriate.
* gtk/gtkcontainer.c (gtk_container_remove): removed unsetting of focus
child since not every child removal goes through this function (this
showed up after gtk_container_set_focus_child() started to reference the
focus_child of a container).
* gtk/gtkwidget.c (gtk_widget_unparent): moved unsetting the focus_child
of a container from gtk_container_remove into this place.
Sat May 2 22:33:45 1998 Tim Janik <timj@gtk.org>
* gtk/gtksignal.c: added new functions to operate on intermediate

View File

@ -1,3 +1,23 @@
Sun May 3 16:55:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_set_focus_child): new function to
set the current focus_child of a container, does proper referencing and
adjusts the vadjustment/hadjustment associated with the focus widget.
* gtk/gtkwidget.c (gtk_widget_grab_focus): set the focused child on
containers via gtk_container_set_focus_child.
* gtk/gtknotebook.c: modifications to use gtk_container_set_focus_child
where appropriate.
* gtk/gtkcontainer.c (gtk_container_remove): removed unsetting of focus
child since not every child removal goes through this function (this
showed up after gtk_container_set_focus_child() started to reference the
focus_child of a container).
* gtk/gtkwidget.c (gtk_widget_unparent): moved unsetting the focus_child
of a container from gtk_container_remove into this place.
Sat May 2 22:33:45 1998 Tim Janik <timj@gtk.org>
* gtk/gtksignal.c: added new functions to operate on intermediate

View File

@ -359,9 +359,6 @@ gtk_container_remove (GtkContainer *container,
g_return_if_fail (widget->parent == GTK_WIDGET (container));
gtk_signal_emit (GTK_OBJECT (container), container_signals[REMOVE], widget);
if (container->focus_child == widget)
container->focus_child = NULL;
}
void
@ -538,6 +535,47 @@ gtk_container_unregister_toplevel (GtkContainer *container)
gtk_widget_unref (GTK_WIDGET (container));
}
void
gtk_container_set_focus_child (GtkContainer *container,
GtkWidget *child)
{
g_return_if_fail (container != NULL);
g_return_if_fail (GTK_IS_CONTAINER (container));
if (child)
g_return_if_fail (GTK_IS_WIDGET (child));
if (child != container->focus_child)
{
if (container->focus_child)
gtk_widget_unref (container->focus_child);
container->focus_child = child;
if (container->focus_child)
gtk_widget_ref (container->focus_child);
}
/* check for h/v adjustments
*/
if (container->focus_child)
{
GtkAdjustment *adjustment;
adjustment = gtk_object_get_data_by_id (GTK_OBJECT (container), vadjustment_key_id);
if (adjustment)
gtk_adjustment_clamp_page (adjustment,
container->focus_child->allocation.y,
(container->focus_child->allocation.y +
container->focus_child->allocation.height));
adjustment = gtk_object_get_data_by_id (GTK_OBJECT (container), hadjustment_key_id);
if (adjustment)
gtk_adjustment_clamp_page (adjustment,
container->focus_child->allocation.x,
(container->focus_child->allocation.x +
container->focus_child->allocation.width));
}
}
static void
gtk_container_marshal_signal_1 (GtkObject *object,
GtkSignalFunc func,
@ -617,7 +655,6 @@ gtk_real_container_focus (GtkContainer *container,
GList *tmp_list;
GList *tmp_list2;
gint return_val;
GtkAdjustment *adjustment;
g_return_val_if_fail (container != NULL, FALSE);
g_return_val_if_fail (GTK_IS_CONTAINER (container), FALSE);
@ -679,25 +716,6 @@ gtk_real_container_focus (GtkContainer *container,
}
}
/* check for h/v adjustments
*/
if (container->focus_child)
{
adjustment = gtk_object_get_data_by_id (GTK_OBJECT (container), vadjustment_key_id);
if (adjustment)
gtk_adjustment_clamp_page (adjustment,
container->focus_child->allocation.y,
(container->focus_child->allocation.y +
container->focus_child->allocation.height));
adjustment = gtk_object_get_data_by_id (GTK_OBJECT (container), hadjustment_key_id);
if (adjustment)
gtk_adjustment_clamp_page (adjustment,
container->focus_child->allocation.x,
(container->focus_child->allocation.x +
container->focus_child->allocation.width));
}
return return_val;
}
@ -1001,7 +1019,7 @@ gtk_container_focus_move (GtkContainer *container,
GtkWidget *child;
focus_child = container->focus_child;
container->focus_child = NULL;
gtk_container_set_focus_child (container, NULL);
while (children)
{

View File

@ -105,6 +105,8 @@ void gtk_container_register_toplevel (GtkContainer *container);
void gtk_container_unregister_toplevel (GtkContainer *container);
gint gtk_container_focus (GtkContainer *container,
GtkDirectionType direction);
void gtk_container_set_focus_child (GtkContainer *container,
GtkWidget *child);
void gtk_container_set_focus_vadjustment (GtkContainer *container,
GtkAdjustment *adjustment);
void gtk_container_set_focus_hadjustment (GtkContainer *container,
@ -114,7 +116,6 @@ void gtk_container_set_focus_hadjustment (GtkContainer *container,
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -1485,10 +1485,7 @@ gtk_notebook_button_press (GtkWidget *widget,
if (event->window == notebook->panel)
{
if (!GTK_WIDGET_HAS_FOCUS (widget))
{
GTK_CONTAINER (widget)->focus_child = NULL;
gtk_widget_grab_focus (widget);
}
gtk_grab_add (widget);
notebook->button = event->button;
@ -1557,7 +1554,7 @@ gtk_notebook_button_press (GtkWidget *widget,
(event->x <= (page->allocation.x + page->allocation.width)) &&
(event->y <= (page->allocation.y + page->allocation.height)))
{
GTK_CONTAINER (notebook)->focus_child = NULL;
gtk_container_set_focus_child (GTK_CONTAINER (notebook), NULL);
if (page == notebook->cur_page &&
notebook->focus_tab != children &&
@ -2088,7 +2085,7 @@ gtk_notebook_focus_in (GtkWidget *widget,
if (gtk_notebook_page_select (GTK_NOTEBOOK (widget)))
return FALSE;
else
GTK_CONTAINER (widget)->focus_child = NULL;
gtk_container_set_focus_child (GTK_CONTAINER (widget), NULL);
}
GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
@ -2647,7 +2644,7 @@ gtk_notebook_focus (GtkContainer *container,
return FALSE;
focus_child = container->focus_child;
container->focus_child = NULL;
gtk_container_set_focus_child (container, NULL);
if (!notebook->show_tabs)
{

View File

@ -1128,7 +1128,6 @@ void
gtk_widget_unparent (GtkWidget *widget)
{
GtkWidget *toplevel;
GtkWidget *child;
GtkWidget *old_parent;
GSList *tmp_list, *prev_list;
@ -1139,9 +1138,17 @@ gtk_widget_unparent (GtkWidget *widget)
/* keep this function in sync with gtk_menu_detach()
*/
/* unset focused and default children properly
*/
toplevel = gtk_widget_get_toplevel (widget);
if (GTK_CONTAINER (widget->parent)->focus_child == widget)
{
gtk_container_set_focus_child (GTK_CONTAINER (widget->parent), NULL);
if (GTK_IS_WINDOW (toplevel))
{
GtkWidget *child;
child = GTK_WINDOW (toplevel)->focus_widget;
while (child && child != widget)
@ -1149,7 +1156,11 @@ gtk_widget_unparent (GtkWidget *widget)
if (child == widget)
gtk_window_set_focus (GTK_WINDOW (toplevel), NULL);
}
}
if (GTK_IS_WINDOW (toplevel))
{
GtkWidget *child;
child = GTK_WINDOW (toplevel)->default_widget;
@ -2249,25 +2260,25 @@ gtk_widget_grab_focus (GtkWidget *widget)
if (GTK_WIDGET_CAN_FOCUS (widget))
{
GtkWidget *window;
GtkWidget *parent;
GtkWidget *child;
GtkType window_type;
window_type = gtk_window_get_type ();
window = widget->parent;
parent = widget->parent;
child = widget;
while (window && !gtk_type_is_a (GTK_WIDGET_TYPE (window), window_type))
while (parent && !gtk_type_is_a (GTK_WIDGET_TYPE (parent), window_type))
{
GTK_CONTAINER (window)->focus_child = child;
child = window;
window = window->parent;
gtk_container_set_focus_child (GTK_CONTAINER (parent), child);
child = parent;
parent = parent->parent;
}
if (window && gtk_type_is_a (GTK_WIDGET_TYPE (window), window_type))
if (parent && gtk_type_is_a (GTK_WIDGET_TYPE (parent), window_type))
{
GTK_CONTAINER (window)->focus_child = child;
gtk_window_set_focus (GTK_WINDOW (window), widget);
gtk_container_set_focus_child (GTK_CONTAINER (parent), child);
gtk_window_set_focus (GTK_WINDOW (parent), widget);
}
}
}