Merge branch 'default-handling' into 'master'

Default handling

See merge request GNOME/gtk!786
This commit is contained in:
Matthias Clasen 2019-04-28 23:51:17 +00:00
commit 6c472ed2b8
46 changed files with 185 additions and 467 deletions

View File

@ -101,51 +101,41 @@ do_menus (GtkWidget *do_widget)
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_add (GTK_CONTAINER (window), box);
gtk_widget_show (box);
box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (box), box1);
gtk_widget_show (box1);
menubar = gtk_menu_bar_new ();
gtk_widget_set_hexpand (menubar, TRUE);
gtk_container_add (GTK_CONTAINER (box1), menubar);
gtk_widget_show (menubar);
menu = create_menu (2);
menuitem = gtk_menu_item_new_with_label ("test\nline2");
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
gtk_widget_show (menuitem);
menuitem = gtk_menu_item_new_with_label ("foo");
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (3));
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
gtk_widget_show (menuitem);
menuitem = gtk_menu_item_new_with_label ("bar");
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (4));
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
gtk_widget_show (menuitem);
box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
gtk_container_add (GTK_CONTAINER (box1), box2);
gtk_widget_show (box2);
button = gtk_button_new_with_label ("Flip");
g_signal_connect (button, "clicked",
G_CALLBACK (change_orientation), menubar);
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_widget_show (button);
button = gtk_button_new_with_label ("Close");
g_signal_connect_swapped (button, "clicked",
G_CALLBACK(gtk_widget_destroy), window);
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_widget_set_can_default (button, TRUE);
gtk_widget_grab_default (button);
gtk_widget_show (button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
}
if (!gtk_widget_get_visible (window))

View File

@ -76,8 +76,7 @@ do_password_entry (GtkWidget *do_widget)
gtk_widget_set_sensitive (button, FALSE);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
gtk_widget_set_can_default (button, TRUE);
gtk_window_set_default (GTK_WINDOW (window), button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
}
if (!gtk_widget_get_visible (window))

View File

@ -99,8 +99,7 @@ do_tagged_entry (GtkWidget *do_widget)
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
gtk_widget_set_can_default (button, TRUE);
gtk_window_set_default (GTK_WINDOW (window), button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
}
if (!gtk_widget_get_visible (window))

View File

@ -3154,6 +3154,7 @@ bad things might happen.</property>
<property name="use-header-bar">1</property>
<property name="title" translatable="yes">Zelda</property>
<property name="hide-on-close">1</property>
<property name="default-widget">act_action_dialog</property>
<child internal-child="content_area">
<object class="GtkBox">
<child>
@ -3175,8 +3176,6 @@ bad things might happen.</property>
</child>
<child type="action">
<object class="GtkButton" id="act_action_dialog">
<property name="can-default">1</property>
<property name="has-default">1</property>
<property name="label" translatable="yes">_Act</property>
<property name="use-underline">1</property>
</object>
@ -3314,6 +3313,7 @@ bad things might happen.</property>
<property name="use-header-bar">1</property>
<property name="title" translatable="yes">Choose one</property>
<property name="hide-on-close">1</property>
<property name="default-widget">select_selection_dialog</property>
<child internal-child="content_area">
<object class="GtkBox">
<child>
@ -3335,8 +3335,6 @@ bad things might happen.</property>
</child>
<child type="action">
<object class="GtkButton" id="select_selection_dialog">
<property name="can-default">1</property>
<property name="has-default">1</property>
<property name="label" translatable="yes">_Select</property>
<property name="use-underline">1</property>
</object>
@ -3450,7 +3448,6 @@ bad things might happen.</property>
<property name="label">_Open</property>
<property name="use-underline">1</property>
<property name="sensitive">0</property>
<property name="can-default">1</property>
<style>
<class name="suggested-action"/>
</style>

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
@ -4504,8 +4503,6 @@ gtk_widget_compute_point
gtk_widget_contains
GtkPickFlags
gtk_widget_pick
gtk_widget_get_can_default
gtk_widget_set_can_default
gtk_widget_get_can_focus
gtk_widget_set_can_focus
gtk_widget_get_focus_on_click
@ -4546,6 +4543,7 @@ gtk_widget_insert_action_group
gtk_widget_list_action_prefixes
gtk_widget_get_action_group
gtk_widget_activate_action
gtk_widget_activate_default
gtk_widget_measure
gtk_widget_snapshot_child
gtk_widget_get_next_sibling
@ -4648,7 +4646,6 @@ gtk_window_set_resizable
gtk_window_get_resizable
gtk_window_add_accel_group
gtk_window_remove_accel_group
gtk_window_activate_default
gtk_window_set_modal
gtk_window_set_default_size
gtk_window_set_hide_on_close
@ -4671,7 +4668,7 @@ gtk_window_propagate_key_event
gtk_window_get_focus
gtk_window_set_focus
gtk_window_get_default_widget
gtk_window_set_default
gtk_window_set_default_widget
gtk_window_present
gtk_window_present_with_time
gtk_window_close

View File

@ -432,7 +432,7 @@ add_action_widgets (GtkAssistant *assistant)
if (has_default)
{
gtk_widget_grab_default (child);
gtk_window_set_default_widget (GTK_WINDOW (assistant), child);
gtk_style_context_add_class (gtk_widget_get_style_context (child), GTK_STYLE_CLASS_SUGGESTED_ACTION);
}
}
@ -807,7 +807,7 @@ update_buttons_state (GtkAssistant *assistant)
case GTK_ASSISTANT_PAGE_INTRO:
gtk_widget_set_sensitive (priv->cancel, TRUE);
gtk_widget_set_sensitive (priv->forward, priv->current_page->complete);
gtk_widget_grab_default (priv->forward);
gtk_window_set_default_widget (GTK_WINDOW (assistant), priv->forward);
gtk_widget_show (priv->forward);
gtk_widget_hide (priv->back);
gtk_widget_hide (priv->apply);
@ -818,7 +818,7 @@ update_buttons_state (GtkAssistant *assistant)
gtk_widget_set_sensitive (priv->cancel, TRUE);
gtk_widget_set_sensitive (priv->back, TRUE);
gtk_widget_set_sensitive (priv->apply, priv->current_page->complete);
gtk_widget_grab_default (priv->apply);
gtk_window_set_default_widget (GTK_WINDOW (assistant), priv->apply);
gtk_widget_show (priv->back);
gtk_widget_show (priv->apply);
gtk_widget_hide (priv->forward);
@ -829,7 +829,7 @@ update_buttons_state (GtkAssistant *assistant)
gtk_widget_set_sensitive (priv->cancel, TRUE);
gtk_widget_set_sensitive (priv->back, TRUE);
gtk_widget_set_sensitive (priv->forward, priv->current_page->complete);
gtk_widget_grab_default (priv->forward);
gtk_window_set_default_widget (GTK_WINDOW (assistant), priv->forward);
gtk_widget_show (priv->back);
gtk_widget_show (priv->forward);
gtk_widget_hide (priv->apply);
@ -838,7 +838,7 @@ update_buttons_state (GtkAssistant *assistant)
break;
case GTK_ASSISTANT_PAGE_SUMMARY:
gtk_widget_set_sensitive (priv->close, priv->current_page->complete);
gtk_widget_grab_default (priv->close);
gtk_window_set_default_widget (GTK_WINDOW (assistant), priv->close);
gtk_widget_show (priv->close);
gtk_widget_hide (priv->back);
gtk_widget_hide (priv->forward);
@ -849,7 +849,7 @@ update_buttons_state (GtkAssistant *assistant)
gtk_widget_set_sensitive (priv->cancel, priv->current_page->complete);
gtk_widget_set_sensitive (priv->back, priv->current_page->complete);
gtk_widget_set_sensitive (priv->forward, priv->current_page->complete);
gtk_widget_grab_default (priv->forward);
gtk_window_set_default_widget (GTK_WINDOW (assistant), priv->forward);
gtk_widget_show (priv->back);
gtk_widget_hide (priv->apply);
gtk_widget_hide (priv->close);

View File

@ -156,7 +156,6 @@
* </child>
* <child type="action">
* <object class="GtkButton" id="button_ok">
* <property name="can-default">True</property>
* </object>
* </child>
* <action-widgets>
@ -456,7 +455,7 @@ gtk_dialog_constructed (GObject *object)
g_object_unref (child);
if (has_default)
gtk_widget_grab_default (child);
gtk_window_set_default_widget (GTK_WINDOW (dialog), child);
}
g_list_free (children);
@ -865,7 +864,7 @@ gtk_dialog_add_action_widget (GtkDialog *dialog,
if (gtk_widget_has_default (child))
{
gtk_widget_grab_default (child);
gtk_window_set_default_widget (GTK_WINDOW (dialog), child);
update_suggested_action (dialog);
}
}
@ -900,8 +899,6 @@ gtk_dialog_add_button (GtkDialog *dialog,
button = gtk_button_new_with_label (button_text);
gtk_button_set_use_underline (GTK_BUTTON (button), TRUE);
gtk_widget_set_can_default (button, TRUE);
gtk_widget_show (button);
gtk_dialog_add_action_widget (dialog, button, response_id);
@ -1028,7 +1025,7 @@ gtk_dialog_set_default_response (GtkDialog *dialog,
ResponseData *rd = get_response_data (widget, FALSE);
if (rd && rd->response_id == response_id)
gtk_widget_grab_default (widget);
gtk_window_set_default_widget (GTK_WINDOW (dialog), widget);
tmp_list = tmp_list->next;
}
@ -1528,7 +1525,7 @@ gtk_dialog_buildable_custom_finished (GtkBuildable *buildable,
}
if (item->is_default)
gtk_widget_grab_default (GTK_WIDGET (object));
gtk_window_set_default_widget (GTK_WINDOW (dialog), GTK_WIDGET (object));
}
g_slist_free_full (data->items, free_action_widget_info);

View File

@ -2120,10 +2120,6 @@ gtk_entry_get_text_length (GtkEntry *entry)
* widget for the window containing the entry. This usually means that
* the dialog box containing the entry will be closed, since the default
* widget is usually one of the dialog buttons.
*
* (For experts: if @setting is %TRUE, the entry calls
* gtk_window_activate_default() on the window containing the entry, in
* the default handler for the #GtkEntry::activate signal.)
**/
void
gtk_entry_set_activates_default (GtkEntry *entry,

View File

@ -82,8 +82,7 @@ struct _GtkEntry
* non-%NULL, this will be called to add additional entries to the context
* menu when it is displayed.
* @activate: Class handler for the #GtkEntry::activate signal. The default
* implementation calls gtk_window_activate_default() on the entrys top-level
* window.
* implementation activates the gtk.activate-default action.
* @move_cursor: Class handler for the #GtkEntry::move-cursor signal. The
* default implementation specifies the standard #GtkEntry cursor movement
* behavior.

View File

@ -341,17 +341,7 @@ static void
file_chooser_widget_file_activated (GtkFileChooser *chooser,
GtkFileChooserDialog *dialog)
{
GtkWidget *widget;
if (gtk_window_activate_default (GTK_WINDOW (dialog)))
return;
/* There probably isn't a default widget, so make things easier for the
* programmer by looking for a reasonable button on our own.
*/
widget = get_accept_action_widget (GTK_DIALOG (dialog), TRUE);
if (widget)
gtk_widget_activate (widget);
gtk_widget_activate_default (GTK_WIDGET (chooser));
}
static void
@ -405,22 +395,9 @@ static void
file_chooser_widget_response_requested (GtkWidget *widget,
GtkFileChooserDialog *dialog)
{
GtkWidget *button;
dialog->priv->response_requested = TRUE;
if (gtk_window_activate_default (GTK_WINDOW (dialog)))
return;
/* There probably isn't a default widget, so make things easier for the
* programmer by looking for a reasonable button on our own.
*/
button = get_accept_action_widget (GTK_DIALOG (dialog), TRUE);
if (button)
{
gtk_widget_activate (button);
return;
}
gtk_widget_activate_default (widget);
dialog->priv->response_requested = FALSE;
}
@ -563,7 +540,7 @@ ensure_default_response (GtkFileChooserDialog *dialog)
widget = get_accept_action_widget (GTK_DIALOG (dialog), TRUE);
if (widget)
gtk_widget_grab_default (widget);
gtk_window_set_default_widget (GTK_WINDOW (dialog), widget);
}
static void

View File

@ -1347,26 +1347,9 @@ key_press_cb (GtkEventControllerKey *controller,
&& !(priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER))
{
GtkWidget *widget = GTK_WIDGET (impl);
GtkWindow *window;
window = get_toplevel (widget);
if (window)
{
GtkWidget *default_widget, *focus_widget;
default_widget = gtk_window_get_default_widget (window);
focus_widget = gtk_root_get_focus (GTK_ROOT (window));
if (widget != default_widget &&
!(widget == focus_widget && (!default_widget || !gtk_widget_get_sensitive (default_widget))))
{
gtk_window_activate_default (window);
gtk_widget_activate_default (GTK_WIDGET (impl));
return GDK_EVENT_STOP;
}
}
}
if (keyval == GDK_KEY_Escape &&
priv->operation_mode == OPERATION_MODE_SEARCH)
@ -6192,7 +6175,6 @@ add_custom_button_to_dialog (GtkDialog *dialog,
GtkWidget *button;
button = gtk_button_new_with_mnemonic (mnemonic_label);
gtk_widget_set_can_default (button, TRUE);
gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, response_id);
}

View File

@ -576,8 +576,6 @@ gtk_info_bar_add_button (GtkInfoBar *info_bar,
button = gtk_button_new_with_label (button_text);
gtk_button_set_use_underline (GTK_BUTTON (button), TRUE);
gtk_widget_set_can_default (button, TRUE);
gtk_widget_show (button);
gtk_info_bar_add_action_widget (info_bar, button, response_id);
@ -744,7 +742,12 @@ gtk_info_bar_set_default_response (GtkInfoBar *info_bar,
ResponseData *rd = get_response_data (widget, FALSE);
if (rd && rd->response_id == response_id)
gtk_widget_grab_default (widget);
{
GtkWidget *window;
window = gtk_widget_get_ancestor (GTK_WIDGET (info_bar), GTK_TYPE_WINDOW);
gtk_window_set_default_widget (GTK_WINDOW (window), widget);
}
}
g_list_free (children);

View File

@ -6203,31 +6203,9 @@ gtk_label_activate_current_link (GtkLabel *label)
link = gtk_label_get_focus_link (label);
if (link)
{
emit_activate_link (label, link);
}
else
{
GtkWidget *toplevel;
GtkWindow *window;
GtkWidget *default_widget, *focus_widget;
toplevel = gtk_widget_get_toplevel (widget);
if (GTK_IS_WINDOW (toplevel))
{
window = GTK_WINDOW (toplevel);
if (window)
{
default_widget = gtk_window_get_default_widget (window);
focus_widget = gtk_root_get_focus (GTK_ROOT (window));
if (default_widget != widget &&
!(widget == focus_widget && (!default_widget || !gtk_widget_is_sensitive (default_widget))))
gtk_window_activate_default (window);
}
}
}
gtk_widget_activate_default (widget);
}
static GtkLabelLink *

View File

@ -455,7 +455,7 @@ pw_dialog_cycle_focus (GtkWidget *widget,
if (next_widget)
gtk_widget_grab_focus (next_widget);
else if (pw_dialog_input_is_valid (operation))
gtk_window_activate_default (GTK_WINDOW (priv->dialog));
gtk_widget_activate_default (widget);
}
static GtkWidget *

View File

@ -2688,7 +2688,6 @@ create_rename_popover (GtkPlacesSidebar *sidebar)
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
g_free (str);
button = gtk_button_new_with_mnemonic (_("_Rename"));
gtk_widget_set_can_default (button, TRUE);
gtk_style_context_add_class (gtk_widget_get_style_context (button), "suggested-action");
g_signal_connect (button, "clicked", G_CALLBACK (do_rename), sidebar);
error = gtk_label_new ("");

View File

@ -155,6 +155,7 @@ enum {
PROP_POSITION,
PROP_MODAL,
PROP_CONSTRAIN_TO,
PROP_DEFAULT_WIDGET,
NUM_PROPERTIES
};
@ -345,6 +346,40 @@ gesture_released (GtkGestureMultiPress *gesture,
gtk_popover_popdown (popover);
}
static void
activate_default_cb (GSimpleAction *action,
GVariant *parameter,
gpointer data)
{
GtkPopover *popover = data;
GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
GtkWidget *focus_widget;
focus_widget = gtk_window_get_focus (GTK_WINDOW (gtk_widget_get_root (priv->widget)));
if (priv->default_widget && gtk_widget_is_sensitive (priv->default_widget) &&
(!focus_widget || !gtk_widget_get_receives_default (focus_widget)))
gtk_widget_activate (priv->default_widget);
else if (focus_widget && gtk_widget_is_sensitive (focus_widget))
gtk_widget_activate (focus_widget);
}
static void
add_actions (GtkPopover *popover)
{
GActionEntry entries[] = {
{ "activate", activate_default_cb, NULL, NULL, NULL },
};
GActionGroup *actions;
actions = G_ACTION_GROUP (g_simple_action_group_new ());
g_action_map_add_action_entries (G_ACTION_MAP (actions),
entries, G_N_ELEMENTS (entries),
popover);
gtk_widget_insert_action_group (GTK_WIDGET (popover), "default", actions);
g_object_unref (actions);
}
static void
gtk_popover_init (GtkPopover *popover)
{
@ -389,6 +424,8 @@ gtk_popover_init (GtkPopover *popover)
g_signal_connect (controller, "released",
G_CALLBACK (gesture_released), popover);
gtk_widget_add_controller (widget, controller);
add_actions (popover);
}
static void
@ -419,6 +456,10 @@ gtk_popover_set_property (GObject *object,
gtk_popover_set_constrain_to (GTK_POPOVER (object),
g_value_get_enum (value));
break;
case PROP_DEFAULT_WIDGET:
gtk_popover_set_default_widget (GTK_POPOVER (object),
g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@ -449,6 +490,9 @@ gtk_popover_get_property (GObject *object,
case PROP_CONSTRAIN_TO:
g_value_set_enum (value, priv->constraint);
break;
case PROP_DEFAULT_WIDGET:
g_value_set_object (value, priv->default_widget);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@ -818,7 +862,7 @@ gtk_popover_map (GtkWidget *widget)
gdk_surface_show (gtk_widget_get_surface (widget));
gtk_popover_update_position (GTK_POPOVER (widget));
gtk_window_set_default (priv->window, priv->default_widget);
gtk_window_set_default_widget (priv->window, priv->default_widget);
}
static void
@ -832,7 +876,7 @@ gtk_popover_unmap (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_popover_parent_class)->unmap (widget);
if (gtk_window_get_default_widget (priv->window) == priv->default_widget)
gtk_window_set_default (priv->window, priv->prev_default);
gtk_window_set_default_widget (priv->window, priv->prev_default);
g_clear_object (&priv->prev_default);
}
@ -1645,6 +1689,13 @@ gtk_popover_class_init (GtkPopoverClass *klass)
GTK_TYPE_POPOVER_CONSTRAINT, GTK_POPOVER_CONSTRAINT_WINDOW,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
properties[PROP_DEFAULT_WIDGET] =
g_param_spec_object ("default-widget",
P_("Default widget"),
P_("The default widget"),
GTK_TYPE_WIDGET,
GTK_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
/**
@ -2378,7 +2429,6 @@ gtk_popover_set_default_widget (GtkPopover *popover,
GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
g_return_if_fail (GTK_IS_POPOVER (popover));
g_return_if_fail (widget == NULL || gtk_widget_get_can_default (widget));
if (priv->default_widget == widget)
return;
@ -2392,7 +2442,9 @@ gtk_popover_set_default_widget (GtkPopover *popover,
g_object_ref (priv->default_widget);
if (gtk_widget_get_mapped (GTK_WIDGET (popover)))
gtk_window_set_default (priv->window, priv->default_widget);
gtk_window_set_default_widget (priv->window, priv->default_widget);
g_object_notify_by_pspec (G_OBJECT (popover), properties[PROP_DEFAULT_WIDGET]);
}
/**

View File

@ -3839,30 +3839,9 @@ static void
gtk_text_real_activate (GtkText *self)
{
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
GtkWindow *window;
GtkWidget *default_widget, *focus_widget;
GtkWidget *toplevel;
GtkWidget *widget;
widget = GTK_WIDGET (self);
if (priv->activates_default)
{
toplevel = gtk_widget_get_toplevel (widget);
if (GTK_IS_WINDOW (toplevel))
{
window = GTK_WINDOW (toplevel);
if (window)
{
default_widget = gtk_window_get_default_widget (window);
focus_widget = gtk_root_get_focus (GTK_ROOT (window));
if (widget != default_widget &&
!(widget == focus_widget && (!default_widget || !gtk_widget_get_sensitive (default_widget))))
gtk_window_activate_default (window);
}
}
}
gtk_widget_activate_default (GTK_WIDGET (self));
}
static void

View File

@ -38,8 +38,7 @@ typedef struct _GtkTextClass GtkTextClass;
* non-%NULL, this will be called to add additional entries to the context
* menu when it is displayed.
* @activate: Class handler for the #GtkText::activate signal. The default
* implementation calls gtk_window_activate_default() on the entrys top-level
* window.
* implementation activates the gtk.activate-default action.
* @move_cursor: Class handler for the #GtkText::move-cursor signal. The
* default implementation specifies the standard #GtkText cursor movement
* behavior.

View File

@ -548,7 +548,6 @@ enum {
PROP_IS_FOCUS,
PROP_CAN_TARGET,
PROP_FOCUS_ON_CLICK,
PROP_CAN_DEFAULT,
PROP_HAS_DEFAULT,
PROP_RECEIVES_DEFAULT,
PROP_CURSOR,
@ -676,10 +675,6 @@ static const gchar * gtk_widget_buildable_get_name (GtkBuildable
static GObject * gtk_widget_buildable_get_internal_child (GtkBuildable *buildable,
GtkBuilder *builder,
const gchar *childname);
static void gtk_widget_buildable_set_buildable_property (GtkBuildable *buildable,
GtkBuilder *builder,
const gchar *name,
const GValue *value);
static gboolean gtk_widget_buildable_custom_tag_start (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
@ -1037,19 +1032,12 @@ gtk_widget_class_init (GtkWidgetClass *klass)
TRUE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
widget_props[PROP_CAN_DEFAULT] =
g_param_spec_boolean ("can-default",
P_("Can default"),
P_("Whether the widget can be the default widget"),
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
widget_props[PROP_HAS_DEFAULT] =
g_param_spec_boolean ("has-default",
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",
@ -2194,13 +2182,6 @@ gtk_widget_set_property (GObject *object,
case PROP_FOCUS_ON_CLICK:
gtk_widget_set_focus_on_click (widget, g_value_get_boolean (value));
break;
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;
@ -2375,9 +2356,6 @@ gtk_widget_get_property (GObject *object,
case PROP_FOCUS_ON_CLICK:
g_value_set_boolean (value, gtk_widget_get_focus_on_click (widget));
break;
case PROP_CAN_DEFAULT:
g_value_set_boolean (value, gtk_widget_get_can_default (widget));
break;
case PROP_HAS_DEFAULT:
g_value_set_boolean (value, gtk_widget_has_default (widget));
break;
@ -5819,58 +5797,12 @@ gtk_widget_get_focus_on_click (GtkWidget *widget)
return priv->focus_on_click;
}
/**
* gtk_widget_set_can_default:
* @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.
**/
void
gtk_widget_set_can_default (GtkWidget *widget,
gboolean can_default)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
g_return_if_fail (GTK_IS_WIDGET (widget));
if (priv->can_default != can_default)
{
priv->can_default = can_default;
gtk_widget_queue_resize (widget);
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_CAN_DEFAULT]);
}
}
/**
* gtk_widget_get_can_default:
* @widget: a #GtkWidget
*
* Determines whether @widget can be a default widget. See
* gtk_widget_set_can_default().
*
* Returns: %TRUE if @widget can be a default widget, %FALSE otherwise
**/
gboolean
gtk_widget_get_can_default (GtkWidget *widget)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
return priv->can_default;
}
/**
* gtk_widget_has_default:
* @widget: a #GtkWidget
*
* Determines whether @widget is the current default widget within its
* toplevel. See gtk_widget_set_can_default().
* toplevel.
*
* Returns: %TRUE if @widget is the current default widget within
* its toplevel, %FALSE otherwise
@ -5902,47 +5834,14 @@ _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 (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.
*
* See gtk_widget_grab_default() for details about the meaning of
* 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.
**/
void
gtk_widget_set_receives_default (GtkWidget *widget,
@ -9590,7 +9489,6 @@ gtk_widget_set_vexpand_set (GtkWidget *widget,
/*
* GtkBuildable implementation
*/
static GQuark quark_builder_has_default = 0;
static GQuark quark_builder_atk_relations = 0;
static GQuark quark_builder_set_name = 0;
@ -9622,14 +9520,12 @@ gtk_widget_buildable_add_child (GtkBuildable *buildable,
static void
gtk_widget_buildable_interface_init (GtkBuildableIface *iface)
{
quark_builder_has_default = g_quark_from_static_string ("gtk-builder-has-default");
quark_builder_atk_relations = g_quark_from_static_string ("gtk-builder-atk-relations");
quark_builder_set_name = g_quark_from_static_string ("gtk-builder-set-name");
iface->set_name = gtk_widget_buildable_set_name;
iface->get_name = gtk_widget_buildable_get_name;
iface->get_internal_child = gtk_widget_buildable_get_internal_child;
iface->set_buildable_property = gtk_widget_buildable_set_buildable_property;
iface->parser_finished = gtk_widget_buildable_parser_finished;
iface->custom_tag_start = gtk_widget_buildable_custom_tag_start;
iface->custom_tag_end = gtk_widget_buildable_custom_tag_end;
@ -9694,19 +9590,6 @@ gtk_widget_buildable_get_internal_child (GtkBuildable *buildable,
return NULL;
}
static void
gtk_widget_buildable_set_buildable_property (GtkBuildable *buildable,
GtkBuilder *builder,
const gchar *name,
const GValue *value)
{
if (strcmp (name, "has-default") == 0 && g_value_get_boolean (value))
g_object_set_qdata (G_OBJECT (buildable), quark_builder_has_default,
GINT_TO_POINTER (TRUE));
else
g_object_set_property (G_OBJECT (buildable), name, value);
}
typedef struct
{
gchar *action_name;
@ -9745,12 +9628,6 @@ gtk_widget_buildable_parser_finished (GtkBuildable *buildable,
{
GSList *atk_relations;
if (g_object_get_qdata (G_OBJECT (buildable), quark_builder_has_default))
{
gtk_widget_grab_default (GTK_WIDGET (buildable));
g_object_steal_qdata (G_OBJECT (buildable), quark_builder_has_default);
}
atk_relations = g_object_get_qdata (G_OBJECT (buildable),
quark_builder_atk_relations);
if (atk_relations)
@ -12920,6 +12797,18 @@ gtk_widget_activate_action (GtkWidget *widget,
parameter);
}
/**
* gtk_widget_activate_default:
* @widget: a #GtkWidget
*
* Activate the default.activate action from @widget.
*/
void
gtk_widget_activate_default (GtkWidget *widget)
{
gtk_widget_activate_action (widget, "default.activate", NULL);
}
void
gtk_widget_cancel_event_sequence (GtkWidget *widget,
GtkGesture *gesture,

View File

@ -474,16 +474,8 @@ void gtk_widget_set_can_target (GtkWidget *widget,
GDK_AVAILABLE_IN_ALL
gboolean gtk_widget_get_can_target (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_widget_set_can_default (GtkWidget *widget,
gboolean can_default);
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,
@ -1016,6 +1008,9 @@ void gtk_widget_activate_action (GtkWidget *widget,
const char *name,
GVariant *parameter);
GDK_AVAILABLE_IN_ALL
void gtk_widget_activate_default (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_widget_set_font_map (GtkWidget *widget,
PangoFontMap *font_map);

View File

@ -81,7 +81,6 @@ struct _GtkWidgetPrivate
guint can_focus : 1;
guint has_focus : 1;
guint focus_on_click : 1;
guint can_default : 1;
guint has_default : 1;
guint receives_default : 1;
guint has_grab : 1;

View File

@ -325,6 +325,8 @@ enum {
PROP_TRANSIENT_FOR,
PROP_ATTACHED_TO,
PROP_APPLICATION,
PROP_DEFAULT_WIDGET,
/* Readonly properties */
PROP_IS_ACTIVE,
@ -1055,6 +1057,13 @@ gtk_window_class_init (GtkWindowClass *klass)
GTK_TYPE_APPLICATION,
GTK_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
window_props[PROP_DEFAULT_WIDGET] =
g_param_spec_object ("default-widget",
P_("Default widget"),
P_("The default widget"),
GTK_TYPE_WIDGET,
GTK_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (gobject_class, LAST_ARG, window_props);
gtk_root_install_properties (gobject_class, LAST_ARG);
@ -1764,6 +1773,31 @@ gtk_window_capture_motion (GtkWidget *widget,
gtk_widget_set_cursor (widget, NULL);
}
static void
activate_default_cb (GSimpleAction *action,
GVariant *parameter,
gpointer data)
{
gtk_window_real_activate_default (GTK_WINDOW (data));
}
static void
add_actions (GtkWindow *window)
{
GActionEntry entries[] = {
{ "activate", activate_default_cb, NULL, NULL, NULL },
};
GActionGroup *actions;
actions = G_ACTION_GROUP (g_simple_action_group_new ());
g_action_map_add_action_entries (G_ACTION_MAP (actions),
entries, G_N_ELEMENTS (entries),
window);
gtk_widget_insert_action_group (GTK_WIDGET (window), "default", actions);
g_object_unref (actions);
}
static void
gtk_window_init (GtkWindow *window)
{
@ -1857,6 +1891,8 @@ gtk_window_init (GtkWindow *window)
g_signal_connect_swapped (priv->key_controller, "focus-out",
G_CALLBACK (gtk_window_focus_out), window);
gtk_widget_add_controller (widget, priv->key_controller);
add_actions (window);
}
static GtkGesture *
@ -1983,6 +2019,9 @@ gtk_window_set_property (GObject *object,
case PROP_APPLICATION:
gtk_window_set_application (window, g_value_get_object (value));
break;
case PROP_DEFAULT_WIDGET:
gtk_window_set_default_widget (window, g_value_get_object (value));
break;
case PROP_MNEMONICS_VISIBLE:
gtk_window_set_mnemonics_visible (window, g_value_get_boolean (value));
break;
@ -2080,6 +2119,9 @@ gtk_window_get_property (GObject *object,
case PROP_APPLICATION:
g_value_set_object (value, gtk_window_get_application (window));
break;
case PROP_DEFAULT_WIDGET:
g_value_set_object (value, gtk_window_get_default_widget (window));
break;
case PROP_MNEMONICS_VISIBLE:
g_value_set_boolean (value, priv->mnemonics_visible);
break;
@ -2514,30 +2556,23 @@ gtk_window_set_startup_id (GtkWindow *window,
}
/**
* gtk_window_set_default:
* gtk_window_set_default_widget:
* @window: a #GtkWindow
* @default_widget: (allow-none): widget to be the default, or %NULL
* to unset the default widget for the toplevel
*
* The default widget is the widget thats activated when the user
* presses Enter in a dialog (for example). This function sets or
* unsets the default widget for a #GtkWindow. When setting (rather
* than unsetting) the default widget its generally easier to call
* gtk_widget_grab_default() on the widget. Before making a widget
* the default widget, you must call gtk_widget_set_can_default() on
* the widget youd like to make the default.
* unsets the default widget for a #GtkWindow.
*/
void
gtk_window_set_default (GtkWindow *window,
gtk_window_set_default_widget (GtkWindow *window,
GtkWidget *default_widget)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
g_return_if_fail (GTK_IS_WINDOW (window));
if (default_widget)
g_return_if_fail (gtk_widget_get_can_default (default_widget));
if (priv->default_widget != default_widget)
{
GtkWidget *old_default_widget = NULL;
@ -2575,6 +2610,8 @@ gtk_window_set_default (GtkWindow *window,
g_object_notify (G_OBJECT (default_widget), "has-default");
g_object_unref (default_widget);
}
g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_DEFAULT_WIDGET]);
}
}
@ -2862,31 +2899,16 @@ gtk_window_get_focus (GtkWindow *window)
return priv->focus_widget;
}
/**
* gtk_window_activate_default:
* @window: a #GtkWindow
*
* Activates the default widget for the window, unless the current
* focused widget has been configured to receive the default action
* (see gtk_widget_set_receives_default()), in which case the
* focused widget is activated.
*
* Returns: %TRUE if a widget got activated.
**/
gboolean
gtk_window_activate_default (GtkWindow *window)
static void
gtk_window_real_activate_default (GtkWindow *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
if (priv->default_widget && gtk_widget_is_sensitive (priv->default_widget) &&
(!priv->focus_widget || !gtk_widget_get_receives_default (priv->focus_widget)))
return gtk_widget_activate (priv->default_widget);
gtk_widget_activate (priv->default_widget);
else if (priv->focus_widget && gtk_widget_is_sensitive (priv->focus_widget))
return gtk_widget_activate (priv->focus_widget);
return FALSE;
gtk_widget_activate (priv->focus_widget);
}
/**
@ -3029,7 +3051,7 @@ gtk_window_dispose (GObject *object)
priv->foci = NULL;
gtk_window_set_focus (window, NULL);
gtk_window_set_default (window, NULL);
gtk_window_set_default_widget (window, NULL);
remove_attach_widget (window);
G_OBJECT_CLASS (gtk_window_parent_class)->dispose (object);
@ -6208,12 +6230,6 @@ get_active_region_type (GtkWindow *window, gint x, gint y)
return GTK_WINDOW_REGION_CONTENT;
}
static void
gtk_window_real_activate_default (GtkWindow *window)
{
gtk_window_activate_default (window);
}
static void
do_focus_change (GtkWidget *widget,
gboolean in)
@ -6601,7 +6617,7 @@ _gtk_window_unset_focus_and_default (GtkWindow *window,
child = _gtk_widget_get_parent (child);
if (child == widget)
gtk_window_set_default (window, NULL);
gtk_window_set_default_widget (window, NULL);
g_object_unref (widget);
g_object_unref (window);

View File

@ -163,12 +163,10 @@ void gtk_window_set_focus (GtkWindow *window,
GDK_AVAILABLE_IN_ALL
GtkWidget *gtk_window_get_focus (GtkWindow *window);
GDK_AVAILABLE_IN_ALL
void gtk_window_set_default (GtkWindow *window,
void gtk_window_set_default_widget (GtkWindow *window,
GtkWidget *default_widget);
GDK_AVAILABLE_IN_ALL
GtkWidget *gtk_window_get_default_widget (GtkWindow *window);
GDK_AVAILABLE_IN_ALL
gboolean gtk_window_activate_default (GtkWindow *window);
GDK_AVAILABLE_IN_ALL
void gtk_window_set_transient_for (GtkWindow *window,

View File

@ -47,9 +47,6 @@ struct _GtkInspectorMiscInfoPrivate {
GtkWidget *state;
GtkWidget *buildable_id_row;
GtkWidget *buildable_id;
GtkWidget *default_widget_row;
GtkWidget *default_widget;
GtkWidget *default_widget_button;
GtkWidget *mnemonic_label_row;
GtkWidget *mnemonic_label;
GtkWidget *request_mode_row;
@ -186,38 +183,6 @@ show_object (GtkInspectorMiscInfo *sl,
gtk_inspector_object_tree_select_object (sl->priv->object_tree, object);
}
static void
update_default_widget (GtkInspectorMiscInfo *sl)
{
GtkWidget *widget;
widget = gtk_window_get_default_widget (GTK_WINDOW (sl->priv->object));
if (widget)
{
gchar *tmp;
tmp = g_strdup_printf ("%p", widget);
gtk_label_set_label (GTK_LABEL (sl->priv->default_widget), tmp);
g_free (tmp);
gtk_widget_set_sensitive (sl->priv->default_widget_button, TRUE);
}
else
{
gtk_label_set_label (GTK_LABEL (sl->priv->default_widget), "NULL");
gtk_widget_set_sensitive (sl->priv->default_widget_button, FALSE);
}
}
static void
show_default_widget (GtkWidget *button, GtkInspectorMiscInfo *sl)
{
GtkWidget *widget;
update_default_widget (sl);
widget = gtk_window_get_default_widget (GTK_WINDOW (sl->priv->object));
if (widget)
show_object (sl, G_OBJECT (widget), "properties");
}
static void
show_mnemonic_label (GtkWidget *button, GtkInspectorMiscInfo *sl)
{
@ -326,11 +291,6 @@ update_info (gpointer data)
gtk_buildable_get_name (GTK_BUILDABLE (sl->priv->object)));
}
if (GTK_IS_WINDOW (sl->priv->object))
{
update_default_widget (sl);
}
if (GDK_IS_FRAME_CLOCK (sl->priv->object))
{
GdkFrameClock *clock;
@ -441,15 +401,6 @@ gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl,
gtk_widget_hide (sl->priv->buildable_id_row);
}
if (GTK_IS_WINDOW (object))
{
gtk_widget_show (sl->priv->default_widget_row);
}
else
{
gtk_widget_hide (sl->priv->default_widget_row);
}
if (GDK_IS_FRAME_CLOCK (object))
{
gtk_widget_show (sl->priv->framecount_row);
@ -563,9 +514,6 @@ gtk_inspector_misc_info_class_init (GtkInspectorMiscInfoClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, state);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, buildable_id_row);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, buildable_id);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, default_widget_row);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, default_widget);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, default_widget_button);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, mnemonic_label_row);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, mnemonic_label);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, request_mode_row);
@ -598,7 +546,6 @@ gtk_inspector_misc_info_class_init (GtkInspectorMiscInfoClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, child_visible_row);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, child_visible);
gtk_widget_class_bind_template_callback (widget_class, show_default_widget);
gtk_widget_class_bind_template_callback (widget_class, show_frame_clock);
}

View File

@ -148,41 +148,6 @@
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="default_widget_row">
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="spacing">40</property>
<child>
<object class="GtkLabel" id="default_widget_label">
<property name="label" translatable="yes">Default Widget</property>
<property name="halign">start</property>
<property name="valign">baseline</property>
<property name="xalign">0.0</property>
<property name="hexpand">1</property>
</object>
</child>
<child>
<object class="GtkLabel" id="default_widget">
<property name="selectable">1</property>
<property name="halign">end</property>
<property name="valign">baseline</property>
</object>
</child>
<child>
<object class="GtkButton" id="default_widget_button">
<property name="halign">end</property>
<property name="valign">baseline</property>
<property name="label" translatable="yes">Properties</property>
<signal name="clicked" handler="show_default_widget"/>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="mnemonic_label_row">
<property name="activatable">0</property>
@ -605,7 +570,6 @@
<widget name="refcount_label"/>
<widget name="state_label"/>
<widget name="buildable_id_label"/>
<widget name="default_widget_label"/>
<widget name="frame_clock_label"/>
</widgets>
</object>

View File

@ -50,7 +50,6 @@
<object class="GtkButton" id="ok_button">
<property name="label" translatable="yes">_Select</property>
<property name="use-underline">1</property>
<property name="can-default">1</property>
</object>
</child>
<action-widgets>

View File

@ -36,7 +36,6 @@
<property name="visible">0</property>
<property name="label" translatable="yes">_Close</property>
<property name="can-focus">1</property>
<property name="can-default">1</property>
<property name="receives-default">1</property>
<property name="use-underline">1</property>
<style>
@ -87,7 +86,6 @@
<object class="GtkButton" id="forward">
<property name="label" translatable="yes">_Next</property>
<property name="can-focus">1</property>
<property name="can-default">1</property>
<property name="receives-default">1</property>
<property name="use-underline">1</property>
<style>
@ -101,7 +99,6 @@
<property name="visible">0</property>
<property name="label" translatable="yes">_Apply</property>
<property name="can-focus">1</property>
<property name="can-default">1</property>
<property name="receives-default">1</property>
<property name="use-underline">1</property>
<style>

View File

@ -32,7 +32,6 @@
<object class="GtkButton" id="ok_button">
<property name="label" translatable="yes">_Select</property>
<property name="use-underline">1</property>
<property name="can-default">1</property>
</object>
</child>
<action-widgets>

View File

@ -412,7 +412,6 @@
<property name="sensitive">0</property>
<property name="label" translatable="yes">_Create</property>
<property name="use-underline">1</property>
<property name="can-default">1</property>
<signal name="clicked" handler="new_folder_create_clicked"/>
<style>
<class name="suggested-action"/>
@ -471,7 +470,6 @@
<property name="sensitive">0</property>
<property name="label" translatable="yes">_Rename</property>
<property name="use-underline">1</property>
<property name="can-default">1</property>
<signal name="clicked" handler="rename_file_rename_clicked"/>
<style>
<class name="suggested-action"/>

View File

@ -26,7 +26,6 @@
<object class="GtkButton" id="select_button">
<property name="label" translatable="yes">_Select</property>
<property name="use-underline">1</property>
<property name="can-default">1</property>
</object>
</child>
<child>

View File

@ -44,7 +44,6 @@
<object class="GtkButton" id="confirm_button">
<property name="label" translatable="yes">_Join</property>
<property name="can_focus">1</property>
<property name="can_default">1</property>
<property name="has_default">1</property>
<property name="receives_default">1</property>
<property name="use_underline">1</property>

View File

@ -12,7 +12,6 @@
<property name="visible">True</property>
<property name="label">_Go</property>
<property name="use_underline">True</property>
<property name="can_default">True</property>
</object>
</child>
<action-widgets>

View File

@ -680,8 +680,7 @@ create_calendar(void)
gtk_container_add (GTK_CONTAINER (window), vbox);
gtk_widget_set_can_default (button, TRUE);
gtk_widget_grab_default (button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
gtk_window_set_default_size (GTK_WINDOW (window), 600, 0);
gtk_widget_show (window);

View File

@ -317,8 +317,7 @@ create_buttons (GtkWidget *widget)
G_CALLBACK (gtk_widget_destroy),
window);
gtk_container_add (GTK_CONTAINER (box2), button[9]);
gtk_widget_set_can_default (button[9], TRUE);
gtk_widget_grab_default (button[9]);
gtk_window_set_default_widget (GTK_WINDOW (window), button[9]);
}
if (!gtk_widget_get_visible (window))
@ -378,8 +377,7 @@ create_toggle_buttons (GtkWidget *widget)
G_CALLBACK (gtk_widget_destroy),
window);
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_widget_set_can_default (button, TRUE);
gtk_widget_grab_default (button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
}
if (!gtk_widget_get_visible (window))
@ -787,8 +785,7 @@ create_statusbar (GtkWidget *widget)
G_CALLBACK (gtk_widget_destroy),
window);
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_widget_set_can_default (button, TRUE);
gtk_widget_grab_default (button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
}
if (!gtk_widget_get_visible (window))
@ -1282,8 +1279,7 @@ create_pixbuf (GtkWidget *widget)
G_CALLBACK (gtk_widget_destroy),
window);
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_widget_set_can_default (button, TRUE);
gtk_widget_grab_default (button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
}
if (!gtk_widget_get_visible (window))
@ -1372,8 +1368,7 @@ create_tooltips (GtkWidget *widget)
G_CALLBACK (gtk_widget_destroy),
window);
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_widget_set_can_default (button, TRUE);
gtk_widget_grab_default (button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
gtk_widget_set_tooltip_text (button, "Push this button to close window");
}
@ -1806,8 +1801,7 @@ create_menus (GtkWidget *widget)
G_CALLBACK (gtk_widget_destroy),
window);
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_widget_set_can_default (button, TRUE);
gtk_widget_grab_default (button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
gtk_widget_show (button);
}
@ -2409,8 +2403,7 @@ create_entry (GtkWidget *widget)
G_CALLBACK (gtk_widget_destroy),
window);
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_widget_set_can_default (button, TRUE);
gtk_widget_grab_default (button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
}
if (!gtk_widget_get_visible (window))
@ -3925,8 +3918,7 @@ create_range_controls (GtkWidget *widget)
G_CALLBACK (gtk_widget_destroy),
window);
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_widget_set_can_default (button, TRUE);
gtk_widget_grab_default (button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
gtk_widget_show (button);
}
@ -4303,8 +4295,7 @@ create_notebook (GtkWidget *widget)
G_CALLBACK (gtk_widget_destroy),
window);
gtk_container_add (GTK_CONTAINER (box1), button);
gtk_widget_set_can_default (button, TRUE);
gtk_widget_grab_default (button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
}
if (!gtk_widget_get_visible (window))
@ -4928,8 +4919,7 @@ create_wmhints (GtkWidget *widget)
window);
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_widget_set_can_default (button, TRUE);
gtk_widget_grab_default (button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
gtk_widget_show (button);
}
@ -5914,16 +5904,14 @@ create_timeout_test (GtkWidget *widget)
g_signal_connect_swapped (button, "clicked",
G_CALLBACK (gtk_widget_destroy),
window);
gtk_widget_set_can_default (button, TRUE);
gtk_container_add (GTK_CONTAINER (action_area), button);
gtk_widget_grab_default (button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
gtk_widget_show (button);
button = gtk_button_new_with_label ("start");
g_signal_connect (button, "clicked",
G_CALLBACK(start_timeout_test),
label);
gtk_widget_set_can_default (button, TRUE);
gtk_container_add (GTK_CONTAINER (action_area), button);
gtk_widget_show (button);
@ -5931,7 +5919,6 @@ create_timeout_test (GtkWidget *widget)
g_signal_connect (button, "clicked",
G_CALLBACK (stop_timeout_test),
NULL);
gtk_widget_set_can_default (button, TRUE);
gtk_container_add (GTK_CONTAINER (action_area), button);
gtk_widget_show (button);
}
@ -6510,8 +6497,7 @@ create_main_window (void)
G_CALLBACK (do_exit),
window);
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_widget_set_can_default (button, TRUE);
gtk_widget_grab_default (button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
gtk_widget_show (window);
}

View File

@ -1468,8 +1468,7 @@ test_widget (void)
" <object class=\"GtkWindow\" id=\"window1\">"
" <child>"
" <object class=\"GtkButton\" id=\"button1\">"
" <property name=\"can-default\">True</property>"
" <property name=\"has-default\">True</property>"
" <property name=\"receives-default\">True</property>"
" </object>"
" </child>"
" </object>"

View File

@ -6,7 +6,6 @@
</child>
<child type="action">
<object class="GtkButton" id="button_ok">
<property name="can-default">True</property>
</object>
</child>
<action-widgets>

View File

@ -1,2 +1,2 @@
ERROR: g-markup-error-quark 6
.:10:23 element 'action-widget' requires attribute 'response'
.:9:23 element 'action-widget' requires attribute 'response'

View File

@ -3,7 +3,6 @@
<object class="GtkDialog">
<child type="action">
<object class="GtkButton" id="button_ok">
<property name="can-default">True</property>
</object>
</child>
<action-widgets>

View File

@ -1,2 +1,2 @@
ERROR: gtk-builder-error-quark 6
.:10:40 Could not parse enum: 'warbl'
.:9:40 Could not parse enum: 'warbl'

View File

@ -3,7 +3,6 @@
<object class="GtkDialog">
<child type="action">
<object class="GtkButton" id="button_ok">
<property name="can-default">True</property>
</object>
</child>
<action-widgets>

View File

@ -1,2 +1,2 @@
ERROR: gtk-builder-error-quark 1
.:10:15 Unsupported tag for GtkDialog: <warbl>
.:9:15 Unsupported tag for GtkDialog: <warbl>

View File

@ -3,7 +3,6 @@
<object class="GtkDialog">
<child type="action">
<object class="GtkButton" id="button_ok">
<property name="can-default">True</property>
</object>
</child>
<action-widgets>

View File

@ -1,2 +1,2 @@
ERROR: gtk-builder-error-quark 1
<input>:11:13 Unhandled tag: <warbl>
<input>:10:13 Unhandled tag: <warbl>

View File

@ -3,7 +3,6 @@
<object class="GtkDialog">
<child type="action">
<object class="GtkButton" id="button_ok">
<property name="can-default">True</property>
</object>
</child>
<action-widgets>

View File

@ -3,7 +3,6 @@
<object class="GtkDialog">
<child type="action">
<object class="GtkButton" id="button_ok">
<property name="can_default">1</property>
</object>
</child>
</object>

View File

@ -6,7 +6,6 @@
</child>
<child>
<object class="GtkButton" id="button_ok">
<property name="can-default">True</property>
</object>
</child>
<action-widgets>