[gtk/default-handling: 16/25] entry: Activate default via action



commit 218d635ca29ebb8d75f3022a4c43d4832a948cbe
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Apr 28 18:12:53 2019 +0000

    entry: Activate default via action
    
    Switch to the new way of activating default.

 gtk/gtkentry.c       |  4 ----
 gtk/gtkentry.h       |  3 +--
 gtk/gtktext.c        | 23 +----------------------
 gtk/gtktextprivate.h |  3 +--
 4 files changed, 3 insertions(+), 30 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 03b7271fd7..04d955cea0 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -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,
diff --git a/gtk/gtkentry.h b/gtk/gtkentry.h
index 66da3da822..d6948686d4 100644
--- a/gtk/gtkentry.h
+++ b/gtk/gtkentry.h
@@ -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 entry’s 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.
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index f93293a342..75e17e11aa 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -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
diff --git a/gtk/gtktextprivate.h b/gtk/gtktextprivate.h
index 60be0035d8..ec1d0af6d2 100644
--- a/gtk/gtktextprivate.h
+++ b/gtk/gtktextprivate.h
@@ -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 entry’s 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.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]