+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
+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
+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
+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
+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
+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
+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
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
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,
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);
}
}
- /* 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;
}
GtkWidget *child;
focus_child = container->focus_child;
- container->focus_child = NULL;
+ gtk_container_set_focus_child (container, NULL);
while (children)
{
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,
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
if (event->window == notebook->panel)
{
if (!GTK_WIDGET_HAS_FOCUS (widget))
- {
- GTK_CONTAINER (widget)->focus_child = NULL;
- gtk_widget_grab_focus (widget);
- }
+ gtk_widget_grab_focus (widget);
gtk_grab_add (widget);
notebook->button = event->button;
(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 &&
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);
return FALSE;
focus_child = container->focus_child;
- container->focus_child = NULL;
+ gtk_container_set_focus_child (container, NULL);
if (!notebook->show_tabs)
{
gtk_widget_unparent (GtkWidget *widget)
{
GtkWidget *toplevel;
- GtkWidget *child;
GtkWidget *old_parent;
GSList *tmp_list, *prev_list;
/* keep this function in sync with gtk_menu_detach()
*/
+ /* unset focused and default children properly
+ */
toplevel = gtk_widget_get_toplevel (widget);
- if (GTK_IS_WINDOW (toplevel))
+ if (GTK_CONTAINER (widget->parent)->focus_child == widget)
{
- child = GTK_WINDOW (toplevel)->focus_widget;
+ gtk_container_set_focus_child (GTK_CONTAINER (widget->parent), NULL);
+
+ if (GTK_IS_WINDOW (toplevel))
+ {
+ GtkWidget *child;
- while (child && child != widget)
- child = child->parent;
+ child = GTK_WINDOW (toplevel)->focus_widget;
+
+ while (child && child != widget)
+ child = child->parent;
+
+ if (child == widget)
+ gtk_window_set_focus (GTK_WINDOW (toplevel), NULL);
+ }
+ }
+ if (GTK_IS_WINDOW (toplevel))
+ {
+ GtkWidget *child;
- if (child == widget)
- gtk_window_set_focus (GTK_WINDOW (toplevel), NULL);
-
-
child = GTK_WINDOW (toplevel)->default_widget;
while (child && child != 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);
}
}
}