widget: Drop gtk_widget_grab_default

The default widget is mostly a dialog concept,
and does not really need this generic api.

If you need to mark a widget as default,
use gtk_window_set_default() directly.
This commit is contained in:
Matthias Clasen 2019-04-27 03:57:13 +00:00
parent 6d73443131
commit 59d50be737
3 changed files with 14 additions and 46 deletions

View File

@ -4433,7 +4433,6 @@ gtk_widget_event
gtk_widget_activate
gtk_widget_is_focus
gtk_widget_grab_focus
gtk_widget_grab_default
gtk_widget_set_name
gtk_widget_get_name
gtk_widget_set_sensitive

View File

@ -1045,7 +1045,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
P_("Has default"),
P_("Whether the widget is the default widget"),
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
GTK_PARAM_READABLE|G_PARAM_EXPLICIT_NOTIFY);
widget_props[PROP_RECEIVES_DEFAULT] =
g_param_spec_boolean ("receives-default",
@ -2193,10 +2193,6 @@ gtk_widget_set_property (GObject *object,
case PROP_CAN_DEFAULT:
gtk_widget_set_can_default (widget, g_value_get_boolean (value));
break;
case PROP_HAS_DEFAULT:
if (g_value_get_boolean (value))
gtk_widget_grab_default (widget);
break;
case PROP_RECEIVES_DEFAULT:
gtk_widget_set_receives_default (widget, g_value_get_boolean (value));
break;
@ -5821,9 +5817,14 @@ gtk_widget_get_focus_on_click (GtkWidget *widget)
* @widget: a #GtkWidget
* @can_default: whether or not @widget can be a default widget.
*
* Specifies whether @widget can be a default widget. See
* gtk_widget_grab_default() for details about the meaning of
* default.
* Specifies whether @widget can be a default widget.
*
* The default widget is activated when the user presses
* Enter in a window. Default widgets must be activatable,
* that is, gtk_widget_activate() should affect them. Note
* that #GtkEntry widgets require the activates-default
* property set to %TRUE before they activate the default
* widget when Enter is pressed and the #GtkEntry is focused.
**/
void
gtk_widget_set_can_default (GtkWidget *widget,
@ -5898,47 +5899,17 @@ _gtk_widget_set_has_default (GtkWidget *widget,
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_DEFAULT);
}
/**
* gtk_widget_grab_default:
* @widget: a #GtkWidget
*
* Causes @widget to become the default widget. @widget must be able to be
* a default widget; typically you would ensure this yourself
* by calling gtk_widget_set_can_default() with a %TRUE value.
* The default widget is activated when
* the user presses Enter in a window. Default widgets must be
* activatable, that is, gtk_widget_activate() should affect them. Note
* that #GtkEntry widgets require the activates-default property
* set to %TRUE before they activate the default widget when Enter
* is pressed and the #GtkEntry is focused.
**/
void
gtk_widget_grab_default (GtkWidget *widget)
{
GtkWidget *window;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (gtk_widget_get_can_default (widget));
window = _gtk_widget_get_toplevel (widget);
if (window && _gtk_widget_is_toplevel (window))
gtk_window_set_default_widget (GTK_WINDOW (window), widget);
else
g_warning (G_STRLOC ": widget not within a GtkWindow");
}
/**
* gtk_widget_set_receives_default:
* @widget: a #GtkWidget
* @receives_default: whether or not @widget can be a default widget.
*
* Specifies whether @widget will be treated as the default widget
* within its toplevel when it has the focus, even if another widget
* is the default.
* Specifies whether @widget will be treated as the default
* widget within its toplevel when it has the focus, even if
* another widget is the default.
*
* See gtk_widget_grab_default() for details about the meaning of
* default.
* See gtk_widget_set_can_default() for details about the
* meaning of default.
**/
void
gtk_widget_set_receives_default (GtkWidget *widget,

View File

@ -482,8 +482,6 @@ GDK_AVAILABLE_IN_ALL
gboolean gtk_widget_get_can_default (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
gboolean gtk_widget_has_default (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_widget_grab_default (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_widget_set_receives_default (GtkWidget *widget,