From 92e21c3f1c8e452eeac9cacc40100360409ca1a6 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 28 Apr 2019 23:28:39 +0000 Subject: [PATCH] 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. --- demos/gtk-demo/menus.c | 1 - demos/gtk-demo/password_entry.c | 1 - demos/gtk-demo/tagged_entry.c | 1 - demos/widget-factory/widget-factory.ui | 3 -- docs/reference/gtk/gtk4-sections.txt | 2 - gtk/gtkdialog.c | 3 -- gtk/gtkfilechooserwidget.c | 1 - gtk/gtkinfobar.c | 2 - gtk/gtkplacessidebar.c | 1 - gtk/gtkpopover.c | 1 - gtk/gtkwidget.c | 70 +------------------------- gtk/gtkwidget.h | 6 --- gtk/gtkwidgetprivate.h | 1 - gtk/gtkwindow.c | 7 +-- gtk/ui/gtkappchooserdialog.ui | 1 - gtk/ui/gtkassistant.ui | 3 -- gtk/ui/gtkcolorchooserdialog.ui | 1 - gtk/ui/gtkfilechooserwidget.ui | 2 - gtk/ui/gtkfontchooserdialog.ui | 1 - tests/dialog.ui | 1 - tests/mydialog.ui | 1 - tests/testcalendar.c | 1 - tests/testgtk.c | 14 ------ testsuite/gtk/builder.c | 1 - testsuite/gtk/ui/dialog1.ui | 1 - testsuite/gtk/ui/dialog2.ui | 1 - testsuite/gtk/ui/dialog3.ui | 1 - testsuite/gtk/ui/dialog4.ui | 1 - testsuite/gtk/ui/dialog5.ui | 1 - testsuite/gtk/ui/dialog7.ui | 1 - testsuite/gtk/ui/infobar1.ui | 1 - 31 files changed, 2 insertions(+), 131 deletions(-) diff --git a/demos/gtk-demo/menus.c b/demos/gtk-demo/menus.c index d4bf0b93d7..83aef5d069 100644 --- a/demos/gtk-demo/menus.c +++ b/demos/gtk-demo/menus.c @@ -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); } diff --git a/demos/gtk-demo/password_entry.c b/demos/gtk-demo/password_entry.c index 8040692950..e92e625876 100644 --- a/demos/gtk-demo/password_entry.c +++ b/demos/gtk-demo/password_entry.c @@ -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); } diff --git a/demos/gtk-demo/tagged_entry.c b/demos/gtk-demo/tagged_entry.c index b9b8915aa0..6c3ec44de8 100644 --- a/demos/gtk-demo/tagged_entry.c +++ b/demos/gtk-demo/tagged_entry.c @@ -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); } diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui index 21796c5f9b..d974ba6f21 100644 --- a/demos/widget-factory/widget-factory.ui +++ b/demos/widget-factory/widget-factory.ui @@ -3176,7 +3176,6 @@ bad things might happen. - 1 _Act 1 @@ -3336,7 +3335,6 @@ bad things might happen. - 1 _Select 1 @@ -3450,7 +3448,6 @@ bad things might happen. _Open 1 0 - 1 diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index 231242108e..f41587c176 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -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 diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c index ec8fbe1f6a..41f71a233a 100644 --- a/gtk/gtkdialog.c +++ b/gtk/gtkdialog.c @@ -156,7 +156,6 @@ * * * - * True * * * @@ -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); diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index 0a8a17fb63..350b11db67 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -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); } diff --git a/gtk/gtkinfobar.c b/gtk/gtkinfobar.c index 20555b6654..625883a71d 100644 --- a/gtk/gtkinfobar.c +++ b/gtk/gtkinfobar.c @@ -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); diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c index 91d7179161..c71d5a43ca 100644 --- a/gtk/gtkplacessidebar.c +++ b/gtk/gtkplacessidebar.c @@ -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 (""); diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c index 65670f66b2..70632e8eac 100644 --- a/gtk/gtkpopover.c +++ b/gtk/gtkpopover.c @@ -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; diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 3195d78b5b..a458e8aca3 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -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, diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 1c14b63de4..808ddc5ebf 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -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); diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h index 5d1c04e779..8d8b656be0 100644 --- a/gtk/gtkwidgetprivate.h +++ b/gtk/gtkwidgetprivate.h @@ -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; diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 4ffcd6cc08..0fdb869bc7 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -2563,9 +2563,7 @@ gtk_window_set_startup_id (GtkWindow *window, * * The default widget is the widget that’s 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 you’d 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; diff --git a/gtk/ui/gtkappchooserdialog.ui b/gtk/ui/gtkappchooserdialog.ui index c04757ec03..7cd4692373 100644 --- a/gtk/ui/gtkappchooserdialog.ui +++ b/gtk/ui/gtkappchooserdialog.ui @@ -50,7 +50,6 @@ _Select 1 - 1 diff --git a/gtk/ui/gtkassistant.ui b/gtk/ui/gtkassistant.ui index d3f760e2e1..621906bfef 100644 --- a/gtk/ui/gtkassistant.ui +++ b/gtk/ui/gtkassistant.ui @@ -36,7 +36,6 @@ 0 _Close 1 - 1 1 1