Drop the can-default property

It was added at a time when default buttons
had a very large external border that would disrupt
aligment. Not a problem nowadays.
This commit is contained in:
Matthias Clasen 2019-04-28 23:28:39 +00:00
parent 8880d27460
commit 92e21c3f1c
31 changed files with 2 additions and 131 deletions

View File

@ -135,7 +135,6 @@ do_menus (GtkWidget *do_widget)
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_window_set_default_widget (GTK_WINDOW (window), button);
}

View File

@ -76,7 +76,6 @@ 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_widget (GTK_WINDOW (window), button);
}

View File

@ -99,7 +99,6 @@ 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_widget (GTK_WINDOW (window), button);
}

View File

@ -3176,7 +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="label" translatable="yes">_Act</property>
<property name="use-underline">1</property>
</object>
@ -3336,7 +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="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

@ -4503,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

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>
@ -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);

View File

@ -6175,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);

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

@ -2429,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;

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,
@ -1033,13 +1032,6 @@ 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"),
@ -2190,9 +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_RECEIVES_DEFAULT:
gtk_widget_set_receives_default (widget, g_value_get_boolean (value));
break;
@ -2367,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;
@ -5811,63 +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.
*
* 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,
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
@ -5907,9 +5842,6 @@ _gtk_widget_set_has_default (GtkWidget *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_set_can_default() for details about the
* meaning of default.
**/
void
gtk_widget_set_receives_default (GtkWidget *widget,

View File

@ -474,12 +474,6 @@ 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);

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

@ -2563,9 +2563,7 @@ gtk_window_set_startup_id (GtkWindow *window,
*
* 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. 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_widget (GtkWindow *window,
@ -2575,9 +2573,6 @@ gtk_window_set_default_widget (GtkWindow *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;

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,7 +680,6 @@ create_calendar(void)
gtk_container_add (GTK_CONTAINER (window), vbox);
gtk_widget_set_can_default (button, TRUE);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
gtk_window_set_default_size (GTK_WINDOW (window), 600, 0);

View File

@ -317,7 +317,6 @@ 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_window_set_default_widget (GTK_WINDOW (window), button[9]);
}
@ -378,7 +377,6 @@ 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_window_set_default_widget (GTK_WINDOW (window), button);
}
@ -787,7 +785,6 @@ 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_window_set_default_widget (GTK_WINDOW (window), button);
}
@ -1282,7 +1279,6 @@ 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_window_set_default_widget (GTK_WINDOW (window), button);
}
@ -1372,7 +1368,6 @@ 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_window_set_default_widget (GTK_WINDOW (window), button);
gtk_widget_set_tooltip_text (button, "Push this button to close window");
@ -1806,7 +1801,6 @@ 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_window_set_default_widget (GTK_WINDOW (window), button);
gtk_widget_show (button);
}
@ -2409,7 +2403,6 @@ 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_window_set_default_widget (GTK_WINDOW (window), button);
}
@ -3925,7 +3918,6 @@ 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_window_set_default_widget (GTK_WINDOW (window), button);
gtk_widget_show (button);
}
@ -4303,7 +4295,6 @@ 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_window_set_default_widget (GTK_WINDOW (window), button);
}
@ -4928,7 +4919,6 @@ create_wmhints (GtkWidget *widget)
window);
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_widget_set_can_default (button, TRUE);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
gtk_widget_show (button);
}
@ -5914,7 +5904,6 @@ 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_window_set_default_widget (GTK_WINDOW (window), button);
gtk_widget_show (button);
@ -5923,7 +5912,6 @@ create_timeout_test (GtkWidget *widget)
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,7 +6497,6 @@ create_main_window (void)
G_CALLBACK (do_exit),
window);
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_widget_set_can_default (button, TRUE);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
gtk_widget_show (window);

View File

@ -1468,7 +1468,6 @@ 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>"
" </object>"
" </child>"

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

@ -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">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">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">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>