Move notification of "has_default" to here, so it is safe to call

Fri Nov 16 19:44:35 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkwindow.c (gtk_window_set_default): Move
	notification of "has_default" to here, so it
	is safe to call gtk_window_set_default() instead
	of gtk_widget_grab_default().

	* gtk/gtkwindow.c (gtk_window_set_focus): Make it call
	gtk_widget_grab_focus(), which then calls
	_gtk_widget_internal_set_focus(). This makes
	gtk_window_set_focus() a safe way of both setting
	and unsetting the focus widget.

	* gtk/gtkwidget.c (gtk_widget_propagate_state): Use
	gtk_widget_get_toplevel(), instead of gtk_widget_ancestor
	to find the toplevel.

	* gtk/gtkwindow.h: Move gtk_window_set_focus/default
	from the "internal functions" section.
This commit is contained in:
Owen Taylor 2001-11-17 01:18:49 +00:00 committed by Owen Taylor
parent f2d5aec4cb
commit 61b2f259e5
14 changed files with 229 additions and 36 deletions

View File

@ -1,3 +1,23 @@
Fri Nov 16 19:44:35 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_set_default): Move
notification of "has_default" to here, so it
is safe to call gtk_window_set_default() instead
of gtk_widget_grab_default().
* gtk/gtkwindow.c (gtk_window_set_focus): Make it call
gtk_widget_grab_focus(), which then calls
_gtk_widget_internal_set_focus(). This makes
gtk_window_set_focus() a safe way of both setting
and unsetting the focus widget.
* gtk/gtkwidget.c (gtk_widget_propagate_state): Use
gtk_widget_get_toplevel(), instead of gtk_widget_ancestor
to find the toplevel.
* gtk/gtkwindow.h: Move gtk_window_set_focus/default
from the "internal functions" section.
2001-11-16 jacob berkman <jacob@ximian.com>
* tests/testgtk.c (create_radio_buttons): add some no-indicator

View File

@ -1,3 +1,23 @@
Fri Nov 16 19:44:35 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_set_default): Move
notification of "has_default" to here, so it
is safe to call gtk_window_set_default() instead
of gtk_widget_grab_default().
* gtk/gtkwindow.c (gtk_window_set_focus): Make it call
gtk_widget_grab_focus(), which then calls
_gtk_widget_internal_set_focus(). This makes
gtk_window_set_focus() a safe way of both setting
and unsetting the focus widget.
* gtk/gtkwidget.c (gtk_widget_propagate_state): Use
gtk_widget_get_toplevel(), instead of gtk_widget_ancestor
to find the toplevel.
* gtk/gtkwindow.h: Move gtk_window_set_focus/default
from the "internal functions" section.
2001-11-16 jacob berkman <jacob@ximian.com>
* tests/testgtk.c (create_radio_buttons): add some no-indicator

View File

@ -1,3 +1,23 @@
Fri Nov 16 19:44:35 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_set_default): Move
notification of "has_default" to here, so it
is safe to call gtk_window_set_default() instead
of gtk_widget_grab_default().
* gtk/gtkwindow.c (gtk_window_set_focus): Make it call
gtk_widget_grab_focus(), which then calls
_gtk_widget_internal_set_focus(). This makes
gtk_window_set_focus() a safe way of both setting
and unsetting the focus widget.
* gtk/gtkwidget.c (gtk_widget_propagate_state): Use
gtk_widget_get_toplevel(), instead of gtk_widget_ancestor
to find the toplevel.
* gtk/gtkwindow.h: Move gtk_window_set_focus/default
from the "internal functions" section.
2001-11-16 jacob berkman <jacob@ximian.com>
* tests/testgtk.c (create_radio_buttons): add some no-indicator

View File

@ -1,3 +1,23 @@
Fri Nov 16 19:44:35 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_set_default): Move
notification of "has_default" to here, so it
is safe to call gtk_window_set_default() instead
of gtk_widget_grab_default().
* gtk/gtkwindow.c (gtk_window_set_focus): Make it call
gtk_widget_grab_focus(), which then calls
_gtk_widget_internal_set_focus(). This makes
gtk_window_set_focus() a safe way of both setting
and unsetting the focus widget.
* gtk/gtkwidget.c (gtk_widget_propagate_state): Use
gtk_widget_get_toplevel(), instead of gtk_widget_ancestor
to find the toplevel.
* gtk/gtkwindow.h: Move gtk_window_set_focus/default
from the "internal functions" section.
2001-11-16 jacob berkman <jacob@ximian.com>
* tests/testgtk.c (create_radio_buttons): add some no-indicator

View File

@ -1,3 +1,23 @@
Fri Nov 16 19:44:35 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_set_default): Move
notification of "has_default" to here, so it
is safe to call gtk_window_set_default() instead
of gtk_widget_grab_default().
* gtk/gtkwindow.c (gtk_window_set_focus): Make it call
gtk_widget_grab_focus(), which then calls
_gtk_widget_internal_set_focus(). This makes
gtk_window_set_focus() a safe way of both setting
and unsetting the focus widget.
* gtk/gtkwidget.c (gtk_widget_propagate_state): Use
gtk_widget_get_toplevel(), instead of gtk_widget_ancestor
to find the toplevel.
* gtk/gtkwindow.h: Move gtk_window_set_focus/default
from the "internal functions" section.
2001-11-16 jacob berkman <jacob@ximian.com>
* tests/testgtk.c (create_radio_buttons): add some no-indicator

View File

@ -1,3 +1,23 @@
Fri Nov 16 19:44:35 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_set_default): Move
notification of "has_default" to here, so it
is safe to call gtk_window_set_default() instead
of gtk_widget_grab_default().
* gtk/gtkwindow.c (gtk_window_set_focus): Make it call
gtk_widget_grab_focus(), which then calls
_gtk_widget_internal_set_focus(). This makes
gtk_window_set_focus() a safe way of both setting
and unsetting the focus widget.
* gtk/gtkwidget.c (gtk_widget_propagate_state): Use
gtk_widget_get_toplevel(), instead of gtk_widget_ancestor
to find the toplevel.
* gtk/gtkwindow.h: Move gtk_window_set_focus/default
from the "internal functions" section.
2001-11-16 jacob berkman <jacob@ximian.com>
* tests/testgtk.c (create_radio_buttons): add some no-indicator

View File

@ -1,3 +1,23 @@
Fri Nov 16 19:44:35 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_set_default): Move
notification of "has_default" to here, so it
is safe to call gtk_window_set_default() instead
of gtk_widget_grab_default().
* gtk/gtkwindow.c (gtk_window_set_focus): Make it call
gtk_widget_grab_focus(), which then calls
_gtk_widget_internal_set_focus(). This makes
gtk_window_set_focus() a safe way of both setting
and unsetting the focus widget.
* gtk/gtkwidget.c (gtk_widget_propagate_state): Use
gtk_widget_get_toplevel(), instead of gtk_widget_ancestor
to find the toplevel.
* gtk/gtkwindow.h: Move gtk_window_set_focus/default
from the "internal functions" section.
2001-11-16 jacob berkman <jacob@ximian.com>
* tests/testgtk.c (create_radio_buttons): add some no-indicator

View File

@ -141,6 +141,8 @@ Application-driven progressive image loading.
fetch the partially-loaded pixbuf.
</para>
@gdkpixbufloader: the object which received the signal.
<!-- # Unused Parameters # -->
@loader: Loader which emitted the signal.
<!-- ##### SIGNAL GdkPixbufLoader::area-updated ##### -->
@ -152,6 +154,12 @@ Application-driven progressive image loading.
areas of an image that is being loaded.
</para>
@gdkpixbufloader: the object which received the signal.
@arg1:
@arg2:
@arg3:
@arg4:
<!-- # Unused Parameters # -->
@loader: Loader which emitted the signal.
@x: X offset of upper-left corner of the updated area.
@y: Y offset of upper-left corner of the updated area.
@ -166,6 +174,8 @@ Application-driven progressive image loading.
drives it.
</para>
@gdkpixbufloader: the object which received the signal.
<!-- # Unused Parameters # -->
@loader: Loader which emitted the signal.
<!--

View File

@ -102,3 +102,13 @@ then call gtk_dialog_add_buttons().
@Returns:
<!-- ##### ARG GtkMessageDialog:message-type ##### -->
<para>
</para>
<!-- ##### ARG GtkMessageDialog:buttons ##### -->
<para>
</para>

View File

@ -402,6 +402,14 @@ gtk_notebook_set_current_page() instead.
@page_num:
<!-- ##### SIGNAL GtkNotebook::change-current-page ##### -->
<para>
</para>
@notebook: the object which received the signal.
@arg1:
<!-- ##### SIGNAL GtkNotebook::focus-tab ##### -->
<para>

View File

@ -475,7 +475,6 @@ GtkTreeView
</para>
@tree_view:
@window:
@x:
@y:
@path:
@ -483,6 +482,8 @@ GtkTreeView
@cell_x:
@cell_y:
@Returns:
<!-- # Unused Parameters # -->
@window:
<!-- ##### FUNCTION gtk_tree_view_get_cell_area ##### -->

View File

@ -3345,12 +3345,12 @@ gtk_widget_real_grab_focus (GtkWidget *focus_widget)
if (widget == focus_widget)
{
/* We call gtk_window_set_focus() here so that the
/* We call _gtk_window_internal_set_focus() here so that the
* toplevel window can request the focus if necessary.
* This is needed when the toplevel is a GtkPlug
*/
if (!GTK_WIDGET_HAS_FOCUS (widget))
gtk_window_set_focus (GTK_WINDOW (toplevel), focus_widget);
_gtk_window_internal_set_focus (GTK_WINDOW (toplevel), focus_widget);
return;
}
@ -3385,7 +3385,7 @@ gtk_widget_real_grab_focus (GtkWidget *focus_widget)
widget = widget->parent;
}
if (GTK_IS_WINDOW (widget))
gtk_window_set_focus (GTK_WINDOW (widget), focus_widget);
_gtk_window_internal_set_focus (GTK_WINDOW (widget), focus_widget);
}
}
@ -3455,22 +3455,14 @@ void
gtk_widget_grab_default (GtkWidget *widget)
{
GtkWidget *window;
GtkType window_type;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (GTK_WIDGET_CAN_DEFAULT (widget));
window_type = GTK_TYPE_WINDOW;
window = widget->parent;
window = gtk_widget_get_toplevel (widget);
while (window && !gtk_type_is_a (GTK_WIDGET_TYPE (window), window_type))
window = window->parent;
if (window && gtk_type_is_a (GTK_WIDGET_TYPE (window), window_type))
{
gtk_window_set_default (GTK_WINDOW (window), widget);
g_object_notify (G_OBJECT (widget), "has_default");
}
if (window && GTK_WIDGET_TOPLEVEL (window))
gtk_window_set_default (GTK_WINDOW (window), widget);
else
g_warning (G_STRLOC ": widget not within a GtkWindow");
}
@ -5775,8 +5767,8 @@ gtk_widget_propagate_state (GtkWidget *widget,
{
GtkWidget *window;
window = gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW);
if (window)
window = gtk_widget_get_toplevel (widget);
if (window && GTK_WIDGET_TOPLEVEL (window))
gtk_window_set_focus (GTK_WINDOW (window), NULL);
}

View File

@ -922,14 +922,14 @@ gtk_window_get_role (GtkWindow *window)
/**
* gtk_window_set_focus:
* @window: a #GtkWindow
* @focus: widget to be the new focus widget
* @focus: widget to be the new focus widget, or %NULL to unset
* any focus widget for the toplevel window.
*
* If @focus is not the current focus widget, and is focusable, emits
* the "set_focus" signal to set @focus as the focus widget for the
* window. This function is more or less GTK-internal; to focus an
* entry widget or the like, you should use gtk_widget_grab_focus()
* instead of this function.
*
* If @focus is not the current focus widget, and is focusable, sets
* it as the focus widget for the window. If @focus is %NULL, unsets
* the focus widget for this window. To set the focus to a particular
* widget in the toplevel, it is usually more convenient to use
* gtk_widget_grab_focus() instead of this function.
**/
void
gtk_window_set_focus (GtkWindow *window,
@ -942,6 +942,18 @@ gtk_window_set_focus (GtkWindow *window,
g_return_if_fail (GTK_WIDGET_CAN_FOCUS (focus));
}
if (focus)
gtk_widget_grab_focus (focus);
else
_gtk_window_internal_set_focus (window, NULL);
}
void
_gtk_window_internal_set_focus (GtkWindow *window,
GtkWidget *focus)
{
g_return_if_fail (GTK_IS_WINDOW (window));
if ((window->focus_widget != focus) ||
(focus && !GTK_WIDGET_HAS_FOCUS (focus)))
gtk_signal_emit (GTK_OBJECT (window), window_signals[SET_FOCUS], focus);
@ -950,30 +962,39 @@ gtk_window_set_focus (GtkWindow *window,
/**
* gtk_window_set_default:
* @window: a #GtkWindow
* @default_widget: widget to be the default
* @default_widget: widget to be the default, or %NULL to unset the
* default widget for the toplevel.
*
* The default widget is the widget that's activated when the user
* presses Enter in a dialog (for example). This function tells a
* #GtkWindow about the current default widget; it's really a GTK
* internal function and you shouldn't need it. Instead, to change the
* default widget, first set the #GTK_CAN_DEFAULT flag on the widget
* you'd like to make the default using GTK_WIDGET_SET_FLAGS(), then
* call gtk_widget_grab_default() to move the default.
*
* presses Enter in a dialog (for example). This function sets or
* unsets the default widget for a #GtkWindow about. When setting
* (rather than unsetting) the default widget it's generally easier to
* call gtk_widget_grab_focus() on the widget. Before making a widget
* the default widget, you must set the #GTK_CAN_DEFAULT flag on the
* widget you'd like to make the default using GTK_WIDGET_SET_FLAGS().
**/
void
gtk_window_set_default (GtkWindow *window,
GtkWidget *default_widget)
{
GtkWidget *old_default;
g_return_if_fail (GTK_IS_WINDOW (window));
if (default_widget)
g_return_if_fail (GTK_WIDGET_CAN_DEFAULT (default_widget));
if (window->default_widget != default_widget)
{
GtkWidget *old_default_widget = NULL;
if (default_widget)
g_object_ref (default_widget);
if (window->default_widget)
{
old_default_widget = window->default_widget;
if (window->focus_widget != window->default_widget ||
!GTK_WIDGET_RECEIVES_DEFAULT (window->default_widget))
GTK_WIDGET_UNSET_FLAGS (window->default_widget, GTK_HAS_DEFAULT);
@ -989,6 +1010,15 @@ gtk_window_set_default (GtkWindow *window,
GTK_WIDGET_SET_FLAGS (window->default_widget, GTK_HAS_DEFAULT);
gtk_widget_queue_draw (window->default_widget);
}
if (old_default_widget)
g_object_notify (G_OBJECT (old_default_widget), "has_default");
if (default_widget)
{
g_object_notify (G_OBJECT (default_widget), "has_default");
g_object_unref (default_widget);
}
}
}

View File

@ -166,7 +166,11 @@ void gtk_window_remove_accel_group (GtkWindow *window,
void gtk_window_set_position (GtkWindow *window,
GtkWindowPosition position);
gboolean gtk_window_activate_focus (GtkWindow *window);
void gtk_window_set_focus (GtkWindow *window,
GtkWidget *focus);
GtkWidget *gtk_window_get_focus (GtkWindow *window);
void gtk_window_set_default (GtkWindow *window,
GtkWidget *default_widget);
gboolean gtk_window_activate_default (GtkWindow *window);
void gtk_window_set_transient_for (GtkWindow *window,
@ -305,10 +309,8 @@ void gtk_window_group_remove_window (GtkWindowGroup *window_grou
GtkWindow *window);
/* --- internal functions --- */
void gtk_window_set_focus (GtkWindow *window,
void _gtk_window_internal_set_focus (GtkWindow *window,
GtkWidget *focus);
void gtk_window_set_default (GtkWindow *window,
GtkWidget *defaultw);
void gtk_window_remove_embedded_xid (GtkWindow *window,
guint xid);
void gtk_window_add_embedded_xid (GtkWindow *window,