[gtk/shortcuts-rebased-again: 122/159] Redo default activation in entries



commit e42af285cf0941a869024bf34061f1371abfd936
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 22 00:51:27 2019 +0000

    Redo default activation in entries
    
    Remove the activates-default property in GtkText
    and move this functionality to the entry wrapper
    classes instead. Add an activate action and
    bindings where necessary.
    
    With this, GtkText is completely converted from
    keybinding signals to actions.

 gtk/gtkentry.c           |  56 +++++++++++++++++----
 gtk/gtkentrycompletion.c |   8 ++-
 gtk/gtkentryprivate.h    |   1 +
 gtk/gtkpasswordentry.c   |  47 ++++++++++++++++--
 gtk/gtksearchentry.c     |  44 +++++++++++------
 gtk/gtkspinbutton.c      |  23 ++++++---
 gtk/gtktext.c            | 125 +----------------------------------------------
 gtk/gtktextprivate.h     |   4 --
 8 files changed, 142 insertions(+), 166 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 6928ec3d70..5757020b9f 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -162,6 +162,7 @@ struct _GtkEntryPrivate
   GtkWidget     *progress_widget;
   GtkWidget     *emoji_chooser;
 
+  guint         activates_default       : 1;
   guint         show_emoji_icon         : 1;
   guint         editing_canceled        : 1; /* Only used by GtkCellRendererText */
 };
@@ -288,6 +289,10 @@ static GtkEntryBuffer *get_buffer                      (GtkEntry       *entry);
 static void         set_show_emoji_icon                (GtkEntry       *entry,
                                                         gboolean        value);
 
+static void gtk_entry_activate (GtkWidget  *widget,
+                                const char *action_name,
+                                GVariant   *parameters);
+
 static void     gtk_entry_measure (GtkWidget           *widget,
                                    GtkOrientation       orientation,
                                    int                  for_size,
@@ -344,7 +349,7 @@ gtk_entry_class_init (GtkEntryClass *class)
   widget_class->direction_changed = gtk_entry_direction_changed;
   widget_class->grab_focus = gtk_entry_grab_focus;
   widget_class->mnemonic_activate = gtk_entry_mnemonic_activate;
-  
+
   quark_entry_completion = g_quark_from_static_string ("gtk-entry-completion-key");
 
   entry_props[PROP_BUFFER] =
@@ -849,7 +854,7 @@ gtk_entry_class_init (GtkEntryClass *class)
   signals[ACTIVATE] =
     g_signal_new (I_("activate"),
                   G_OBJECT_CLASS_TYPE (gobject_class),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                  G_SIGNAL_RUN_LAST,
                   G_STRUCT_OFFSET (GtkEntryClass, activate),
                   NULL, NULL,
                   NULL,
@@ -891,6 +896,16 @@ gtk_entry_class_init (GtkEntryClass *class)
                   G_TYPE_NONE, 1,
                   GTK_TYPE_ENTRY_ICON_POSITION);
 
+  gtk_widget_class_install_action (widget_class, "activate", NULL,
+                                   gtk_entry_activate);
+
+  gtk_widget_class_bind_action (widget_class, GDK_KEY_Return, 0,
+                                "activate", NULL);
+  gtk_widget_class_bind_action (widget_class, GDK_KEY_ISO_Enter, 0,
+                                "activate", NULL);
+  gtk_widget_class_bind_action (widget_class, GDK_KEY_KP_Enter, 0,
+                                "activate", NULL);
+
   gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_ENTRY_ACCESSIBLE);
   gtk_widget_class_set_css_name (widget_class, I_("entry"));
 }
@@ -935,7 +950,6 @@ gtk_entry_set_property (GObject         *object,
     case PROP_VISIBILITY:
     case PROP_INVISIBLE_CHAR:
     case PROP_INVISIBLE_CHAR_SET:
-    case PROP_ACTIVATES_DEFAULT:
     case PROP_TRUNCATE_MULTILINE:
     case PROP_OVERWRITE_MODE:
     case PROP_PLACEHOLDER_TEXT:
@@ -948,6 +962,10 @@ gtk_entry_set_property (GObject         *object,
       g_object_set_property (G_OBJECT (priv->text), pspec->name, value);
       break;
 
+    case PROP_ACTIVATES_DEFAULT:
+      gtk_entry_set_activates_default (entry, g_value_get_boolean (value));
+      break;
+
     case PROP_HAS_FRAME:
       gtk_entry_set_has_frame (entry, g_value_get_boolean (value));
       break;
@@ -1090,7 +1108,6 @@ gtk_entry_get_property (GObject         *object,
     case PROP_VISIBILITY:
     case PROP_INVISIBLE_CHAR:
     case PROP_INVISIBLE_CHAR_SET:
-    case PROP_ACTIVATES_DEFAULT:
     case PROP_SCROLL_OFFSET:
     case PROP_TRUNCATE_MULTILINE:
     case PROP_OVERWRITE_MODE:
@@ -1103,6 +1120,10 @@ gtk_entry_get_property (GObject         *object,
       g_object_get_property (G_OBJECT (priv->text), pspec->name, value);
       break;
 
+    case PROP_ACTIVATES_DEFAULT:
+      g_value_set_boolean (value, gtk_entry_get_activates_default (entry));
+      break;
+
     case PROP_HAS_FRAME:
       g_value_set_boolean (value, gtk_entry_get_has_frame (entry));
       break;
@@ -1231,9 +1252,21 @@ gtk_entry_get_property (GObject         *object,
 }
 
 static void
-activate_cb (GtkText *text, GtkEntry  *entry)
+gtk_entry_activate (GtkWidget  *widget,
+                    const char *action_name,
+                    GVariant   *parameters)
 {
-  g_signal_emit (entry, signals[ACTIVATE], 0);
+  GtkEntry *entry = GTK_ENTRY (widget);
+  GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
+  GtkEntryCompletion *completion = gtk_entry_get_completion (entry);
+
+  if (completion && _gtk_entry_completion_accept (completion))
+    return;
+
+  if (priv->activates_default)
+    gtk_widget_activate_default (widget);
+  else
+    g_signal_emit (entry, signals[ACTIVATE], 0);
 }
 
 static void
@@ -1257,7 +1290,6 @@ connect_text_signals (GtkEntry *entry)
 {
   GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
 
-  g_signal_connect (priv->text, "activate", G_CALLBACK (activate_cb), entry);
   g_signal_connect (priv->text, "notify", G_CALLBACK (notify_cb), entry);
 }
 
@@ -1266,7 +1298,6 @@ disconnect_text_signals (GtkEntry *entry)
 {
   GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
 
-  g_signal_handlers_disconnect_by_func (priv->text, activate_cb, entry);
   g_signal_handlers_disconnect_by_func (priv->text, notify_cb, entry);
 }
 
@@ -2141,7 +2172,12 @@ gtk_entry_set_activates_default (GtkEntry *entry,
 
   g_return_if_fail (GTK_IS_ENTRY (entry));
 
-  gtk_text_set_activates_default (GTK_TEXT (priv->text), setting);
+  if (priv->activates_default == setting)
+    return;
+
+  priv->activates_default = setting;
+
+  g_object_notify_by_pspec (G_OBJECT (entry), entry_props[PROP_ACTIVATES_DEFAULT]);
 }
 
 /**
@@ -2159,7 +2195,7 @@ gtk_entry_get_activates_default (GtkEntry *entry)
 
   g_return_val_if_fail (GTK_IS_ENTRY (entry), FALSE);
 
-  return gtk_text_get_activates_default (GTK_TEXT (priv->text));
+  return priv->activates_default;
 }
 
 /**
diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c
index de68a66e43..b2580e5a17 100644
--- a/gtk/gtkentrycompletion.c
+++ b/gtk/gtkentrycompletion.c
@@ -2294,8 +2294,8 @@ clear_completion_callback (GObject            *text,
     completion->priv->has_completion = FALSE;
 }
 
-static gboolean
-accept_completion_callback (GtkEntryCompletion *completion)
+gboolean
+_gtk_entry_completion_accept (GtkEntryCompletion *completion)
 {
   if (!completion->priv->inline_completion)
     return FALSE;
@@ -2313,7 +2313,7 @@ text_focus_out (GtkEntryCompletion *completion)
   if (gtk_widget_get_mapped (completion->priv->popup_window))
     return FALSE;
 
-  return accept_completion_callback (completion);
+  return _gtk_entry_completion_accept (completion);
 }
 
 static void
@@ -2358,7 +2358,6 @@ connect_completion_signals (GtkEntryCompletion *completion)
     completion->priv->insert_text_id =
       g_signal_connect (text, "insert-text", G_CALLBACK (completion_insert_text_callback), completion);
     g_signal_connect (text, "notify", G_CALLBACK (clear_completion_callback), completion);
-    g_signal_connect_swapped (text, "activate", G_CALLBACK (accept_completion_callback), completion);
 }
 
 static void
@@ -2412,7 +2411,6 @@ disconnect_completion_signals (GtkEntryCompletion *completion)
     }
   g_signal_handlers_disconnect_by_func (text, G_CALLBACK (completion_insert_text_callback), completion);
   g_signal_handlers_disconnect_by_func (text, G_CALLBACK (clear_completion_callback), completion);
-  g_signal_handlers_disconnect_by_func (text, G_CALLBACK (accept_completion_callback), completion);
 }
 
 void
diff --git a/gtk/gtkentryprivate.h b/gtk/gtkentryprivate.h
index 14696eb5ca..2b98907de6 100644
--- a/gtk/gtkentryprivate.h
+++ b/gtk/gtkentryprivate.h
@@ -112,6 +112,7 @@ void     _gtk_entry_completion_popdown      (GtkEntryCompletion *completion);
 void     _gtk_entry_completion_connect      (GtkEntryCompletion *completion,
                                              GtkEntry           *entry);
 void     _gtk_entry_completion_disconnect   (GtkEntryCompletion *completion);
+gboolean _gtk_entry_completion_accept       (GtkEntryCompletion *completion);
 
 GtkIMContext* _gtk_entry_get_im_context    (GtkEntry  *entry);
 void     gtk_entry_enter_text              (GtkEntry   *entry,
diff --git a/gtk/gtkpasswordentry.c b/gtk/gtkpasswordentry.c
index 669e3d81e7..c491669c26 100644
--- a/gtk/gtkpasswordentry.c
+++ b/gtk/gtkpasswordentry.c
@@ -58,6 +58,7 @@ typedef struct {
   GtkWidget *peek_icon;
   GdkKeymap *keymap;
   GMenuModel *extra_menu;
+  gboolean activates_default;
 } GtkPasswordEntryPrivate;
 
 struct _GtkPasswordEntryClass
@@ -65,6 +66,11 @@ struct _GtkPasswordEntryClass
   GtkWidgetClass parent_class;
 };
 
+enum {
+  ACTIVATE,
+  LAST_SIGNAL
+};
+
 enum {
   PROP_PLACEHOLDER_TEXT = 1,
   PROP_ACTIVATES_DEFAULT,
@@ -75,12 +81,28 @@ enum {
 
 static GParamSpec *props[NUM_PROPERTIES] = { NULL, };
 
+static guint signals[LAST_SIGNAL] = { 0 };
+
 static void gtk_password_entry_editable_init (GtkEditableInterface *iface);
 
 G_DEFINE_TYPE_WITH_CODE (GtkPasswordEntry, gtk_password_entry, GTK_TYPE_WIDGET,
                          G_ADD_PRIVATE (GtkPasswordEntry)
                          G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE, gtk_password_entry_editable_init))
 
+static void
+gtk_password_entry_activate (GtkWidget  *widget,
+                             const char *action_name,
+                             GVariant   *parameters)
+{
+  GtkPasswordEntry *entry = GTK_PASSWORD_ENTRY (widget);
+  GtkPasswordEntryPrivate *priv = gtk_password_entry_get_instance_private (entry);
+
+  if (priv->activates_default)
+    gtk_widget_activate_default (widget);
+  else
+    g_signal_emit (entry, signals[ACTIVATE], 0);
+}
+
 static void
 keymap_state_changed (GdkKeymap *keymap,
                       GtkWidget *widget)
@@ -216,9 +238,9 @@ gtk_password_entry_set_property (GObject      *object,
       break;
 
     case PROP_ACTIVATES_DEFAULT:
-      if (gtk_text_get_activates_default (GTK_TEXT (priv->entry)) != g_value_get_boolean (value))
+      if (priv->activates_default != g_value_get_boolean (value))
         {
-          gtk_text_set_activates_default (GTK_TEXT (priv->entry), g_value_get_boolean (value));
+          priv->activates_default = g_value_get_boolean (value);
           g_object_notify_by_pspec (object, pspec);
         }
       break;
@@ -256,7 +278,7 @@ gtk_password_entry_get_property (GObject    *object,
       break;
 
     case PROP_ACTIVATES_DEFAULT:
-      g_value_set_boolean (value, gtk_text_get_activates_default (GTK_TEXT (priv->entry)));
+      g_value_set_boolean (value, priv->activates_default);
       break;
 
     case PROP_SHOW_PEEK_ICON:
@@ -426,6 +448,25 @@ gtk_password_entry_class_init (GtkPasswordEntryClass *klass)
   g_object_class_install_properties (object_class, NUM_PROPERTIES, props);
   gtk_editable_install_properties (object_class, NUM_PROPERTIES);
 
+  signals[ACTIVATE] =
+    g_signal_new (I_("activate"),
+                  G_OBJECT_CLASS_TYPE (object_class),
+                  G_SIGNAL_RUN_LAST,
+                  0,
+                  NULL, NULL,
+                  NULL,
+                  G_TYPE_NONE, 0);
+
+  gtk_widget_class_install_action (widget_class, "activate", NULL,
+                                   gtk_password_entry_activate);
+
+  gtk_widget_class_bind_action (widget_class, GDK_KEY_Return, 0,
+                                "activate", NULL);
+  gtk_widget_class_bind_action (widget_class, GDK_KEY_ISO_Enter, 0,
+                                "activate", NULL);
+  gtk_widget_class_bind_action (widget_class, GDK_KEY_KP_Enter, 0,
+                                "activate", NULL);
+
   gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_ENTRY_ACCESSIBLE);
   gtk_widget_class_set_css_name (widget_class, I_("entry"));
 }
diff --git a/gtk/gtksearchentry.c b/gtk/gtksearchentry.c
index 8d285418dc..73f3c16379 100644
--- a/gtk/gtksearchentry.c
+++ b/gtk/gtksearchentry.c
@@ -124,6 +124,7 @@ typedef struct {
   guint delayed_changed_id;
   gboolean content_changed;
   gboolean search_stopped;
+  gboolean activates_default;
 } GtkSearchEntryPrivate;
 
 static void gtk_search_entry_editable_init (GtkEditableInterface *iface);
@@ -136,6 +137,20 @@ G_DEFINE_TYPE_WITH_CODE (GtkSearchEntry, gtk_search_entry, GTK_TYPE_WIDGET,
 /* 150 mseconds of delay */
 #define DELAYED_TIMEOUT_ID 150
 
+static void
+gtk_search_entry_activate (GtkWidget  *widget,
+                           const char *action_name,
+                           GVariant   *parameters)
+{
+  GtkSearchEntry *entry = GTK_SEARCH_ENTRY (widget);
+  GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
+
+  if (priv->activates_default)
+    gtk_widget_activate_default (widget);
+  else
+    g_signal_emit (entry, signals[ACTIVATE], 0);
+}
+
 static void
 text_changed (GtkSearchEntry *entry)
 {
@@ -190,9 +205,9 @@ gtk_search_entry_set_property (GObject      *object,
       break;
 
     case PROP_ACTIVATES_DEFAULT:
-      if (gtk_text_get_activates_default (GTK_TEXT (priv->entry)) != g_value_get_boolean (value))
+      if (priv->activates_default != g_value_get_boolean (value))
         {
-          gtk_text_set_activates_default (GTK_TEXT (priv->entry), g_value_get_boolean (value));
+          priv->activates_default = g_value_get_boolean (value);
           g_object_notify_by_pspec (object, pspec);
         }
       break;
@@ -221,7 +236,7 @@ gtk_search_entry_get_property (GObject    *object,
       break;
 
     case PROP_ACTIVATES_DEFAULT:
-      g_value_set_boolean (value, gtk_text_get_activates_default (GTK_TEXT (priv->entry)));
+      g_value_set_boolean (value, priv->activates_default);
       break;
 
     default:
@@ -358,7 +373,7 @@ gtk_search_entry_class_init (GtkSearchEntryClass *klass)
   signals[ACTIVATE] =
     g_signal_new (I_("activate"),
                   G_OBJECT_CLASS_TYPE (object_class),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                  G_SIGNAL_RUN_LAST,
                   G_STRUCT_OFFSET (GtkSearchEntryClass, activate),
                   NULL, NULL,
                   NULL,
@@ -460,6 +475,16 @@ gtk_search_entry_class_init (GtkSearchEntryClass *klass)
                   NULL,
                   G_TYPE_NONE, 0);
 
+  gtk_widget_class_install_action (widget_class, "activate", NULL,
+                                   gtk_search_entry_activate);
+
+  gtk_widget_class_bind_action (widget_class, GDK_KEY_Return, 0,
+                                "activate", NULL);
+  gtk_widget_class_bind_action (widget_class, GDK_KEY_ISO_Enter, 0,
+                                "activate", NULL);
+  gtk_widget_class_bind_action (widget_class, GDK_KEY_KP_Enter, 0,
+                                "activate", NULL);
+
   gtk_widget_class_add_binding_signal (widget_class,
                                        GDK_KEY_g, GDK_CONTROL_MASK,
                                        "next-match",
@@ -565,18 +590,10 @@ notify_cb (GObject    *object,
            gpointer    data)
 {
   /* The editable interface properties are already forwarded by the editable delegate setup */
-  if (g_str_equal (pspec->name, "placeholder-text") ||
-      g_str_equal (pspec->name, "activates-default"))
+  if (g_str_equal (pspec->name, "placeholder-text"))
     g_object_notify (data, pspec->name);
 }
 
-static void
-activate_cb (GtkText  *text,
-             gpointer  data)
-{
-  g_signal_emit (data, signals[ACTIVATE], 0);
-}
-
 static void
 gtk_search_entry_init (GtkSearchEntry *entry)
 {
@@ -590,7 +607,6 @@ gtk_search_entry_init (GtkSearchEntry *entry)
   g_signal_connect_after (priv->entry, "changed", G_CALLBACK (gtk_search_entry_changed), entry);
   g_signal_connect_swapped (priv->entry, "preedit-changed", G_CALLBACK (text_changed), entry);
   g_signal_connect (priv->entry, "notify", G_CALLBACK (notify_cb), entry);
-  g_signal_connect (priv->entry, "activate", G_CALLBACK (activate_cb), entry);
 
   priv->icon = gtk_image_new_from_icon_name ("edit-clear-symbolic");
   gtk_widget_set_tooltip_text (priv->icon, _("Clear entry"));
diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c
index fc29e2d204..d38314cd43 100644
--- a/gtk/gtkspinbutton.c
+++ b/gtk/gtkspinbutton.c
@@ -292,8 +292,9 @@ static gboolean gtk_spin_button_stop_spinning  (GtkSpinButton      *spin);
 static void gtk_spin_button_value_changed  (GtkAdjustment      *adjustment,
                                             GtkSpinButton      *spin_button);
 
-static void gtk_spin_button_activate       (GtkText            *entry,
-                                            gpointer            user_data);
+static void gtk_spin_button_activate       (GtkWidget  *widget,
+                                            const char *action_name,
+                                            GVariant   *parameters);
 static void gtk_spin_button_unset_adjustment (GtkSpinButton *spin_button);
 static void gtk_spin_button_set_orientation (GtkSpinButton     *spin_button,
                                              GtkOrientation     orientation);
@@ -552,6 +553,16 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
                   G_TYPE_NONE, 1,
                   GTK_TYPE_SCROLL_TYPE);
 
+  gtk_widget_class_install_action (widget_class, "activate", NULL,
+                                   gtk_spin_button_activate);
+
+  gtk_widget_class_bind_action (widget_class, GDK_KEY_Return, 0,
+                                "activate", NULL);
+  gtk_widget_class_bind_action (widget_class, GDK_KEY_ISO_Enter, 0,
+                                "activate", NULL);
+  gtk_widget_class_bind_action (widget_class, GDK_KEY_KP_Enter, 0,
+                                "activate", NULL);
+
   add_spin_binding (widget_class, GDK_KEY_Up, 0, GTK_SCROLL_STEP_UP);
   add_spin_binding (widget_class, GDK_KEY_KP_Up, 0, GTK_SCROLL_STEP_UP);
   add_spin_binding (widget_class, GDK_KEY_Down, 0, GTK_SCROLL_STEP_DOWN);
@@ -895,7 +906,6 @@ gtk_spin_button_init (GtkSpinButton *spin_button)
   gtk_editable_set_max_width_chars (GTK_EDITABLE (priv->entry), 0);
   gtk_widget_set_hexpand (priv->entry, TRUE);
   gtk_widget_set_vexpand (priv->entry, TRUE);
-  g_signal_connect (priv->entry, "activate", G_CALLBACK (gtk_spin_button_activate), spin_button);
   gtk_container_add (GTK_CONTAINER (priv->box), priv->entry);
 
   priv->down_button = gtk_button_new ();
@@ -1358,10 +1368,11 @@ gtk_spin_button_snap (GtkSpinButton *spin_button,
 }
 
 static void
-gtk_spin_button_activate (GtkText *entry,
-                          gpointer  user_data)
+gtk_spin_button_activate (GtkWidget  *widget,
+                          const char *action_name,
+                          GVariant   *parameters)
 {
-  GtkSpinButton *spin_button = user_data;
+  GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
   GtkSpinButtonPrivate *priv = gtk_spin_button_get_instance_private (spin_button);
 
   if (gtk_editable_get_editable (GTK_EDITABLE (priv->entry)))
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index ecfae2de7b..7a69260b39 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -208,7 +208,6 @@ struct _GtkTextPrivate
   guint         overwrite_mode          : 1;
   guint         visible                 : 1;
 
-  guint         activates_default       : 1;
   guint         cache_includes_preedit  : 1;
   guint         change_count            : 8;
   guint         cursor_visible          : 1;
@@ -247,7 +246,6 @@ enum {
   PROP_VISIBILITY,
   PROP_INVISIBLE_CHAR,
   PROP_INVISIBLE_CHAR_SET,
-  PROP_ACTIVATES_DEFAULT,
   PROP_SCROLL_OFFSET,
   PROP_TRUNCATE_MULTILINE,
   PROP_OVERWRITE_MODE,
@@ -394,7 +392,6 @@ static void     gtk_text_paste_clipboard    (GtkText         *self);
 static void     gtk_text_toggle_overwrite   (GtkText         *self);
 static void     gtk_text_insert_emoji       (GtkText         *self);
 static void     gtk_text_select_all         (GtkText         *self);
-static void     gtk_text_real_activate      (GtkText         *self);
  
 static void     keymap_direction_changed    (GdkKeymap       *keymap,
                                              GtkText         *self);
@@ -535,9 +532,6 @@ static void         emit_changed                       (GtkText *self);
 static void         gtk_text_update_clipboard_actions (GtkText *self);
 static void         gtk_text_update_emoji_action      (GtkText *self);
 
-static void gtk_text_activate_default_activate       (GtkWidget  *widget,
-                                                      const char *action_name,
-                                                      GVariant   *parameter);
 static void gtk_text_activate_clipboard_cut          (GtkWidget  *widget,
                                                       const char *action_name,
                                                       GVariant   *parameter);
@@ -714,8 +708,6 @@ gtk_text_class_init (GtkTextClass *class)
   widget_class->drag_data_get = gtk_text_drag_data_get;
   widget_class->drag_data_delete = gtk_text_drag_data_delete;
 
-  class->activate = gtk_text_real_activate;
- 
   quark_password_hint = g_quark_from_static_string ("gtk-entry-password-hint");
   quark_gtk_signal = g_quark_from_static_string ("gtk-signal");
 
@@ -741,13 +733,6 @@ gtk_text_class_init (GtkTextClass *class)
                             '*',
                             GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
 
-  text_props[PROP_ACTIVATES_DEFAULT] =
-      g_param_spec_boolean ("activates-default",
-                            P_("Activates default"),
-                            P_("Whether to activate the default widget (such as the default button in a 
dialog) when Enter is pressed"),
-                            FALSE,
-                            GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
-
   text_props[PROP_SCROLL_OFFSET] =
       g_param_spec_int ("scroll-offset",
                         P_("Scroll offset"),
@@ -923,26 +908,6 @@ gtk_text_class_init (GtkTextClass *class)
 
   gtk_editable_install_properties (gobject_class, NUM_PROPERTIES);
 
- /* Action signals */
-  
-  /**
-   * GtkText::activate:
-   * @self: The self on which the signal is emitted
-   *
-   * The ::activate signal is emitted when the user hits
-   * the Enter key.
-   *
-   * The default bindings for this signal are all forms of the Enter key.
-   */
-  signals[ACTIVATE] =
-    g_signal_new (I_("activate"),
-                  G_OBJECT_CLASS_TYPE (gobject_class),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-                  G_STRUCT_OFFSET (GtkTextClass, activate),
-                  NULL, NULL,
-                  NULL,
-                  G_TYPE_NONE, 0);
-
   /**
    * GtkText::preedit-changed:
    * @self: the object which received the signal
@@ -955,7 +920,7 @@ gtk_text_class_init (GtkTextClass *class)
   signals[PREEDIT_CHANGED] =
     g_signal_new_class_handler (I_("preedit-changed"),
                                 G_OBJECT_CLASS_TYPE (gobject_class),
-                                G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                                G_SIGNAL_RUN_LAST,
                                 NULL,
                                 NULL, NULL,
                                 NULL,
@@ -965,8 +930,6 @@ gtk_text_class_init (GtkTextClass *class)
 
   /* Actions */
 
-  gtk_widget_class_install_action (widget_class, "default.activate",
-                                   gtk_text_activate_default_activate);
   gtk_widget_class_install_action (widget_class, "clipboard.cut", NULL,
                                    gtk_text_activate_clipboard_cut);
   gtk_widget_class_install_action (widget_class, "clipboard.copy", NULL,
@@ -1066,18 +1029,6 @@ gtk_text_class_init (GtkTextClass *class)
                                 "edit.move-cursor",
                                 "(iib)", GTK_MOVEMENT_VISUAL_POSITIONS, 0, FALSE);
 
-  /* Activate
-   */
-  gtk_widget_class_bind_action (widget_class, GDK_KEY_Return, 0,
-                                "default.activate",
-                                NULL);
-  gtk_widget_class_bind_action (widget_class, GDK_KEY_ISO_Enter, 0,
-                                "default.activate",
-                                NULL);
-  gtk_widget_class_bind_action (widget_class, GDK_KEY_KP_Enter, 0,
-                                "default.activate",
-                                NULL);
-  
   /* Deleting text */
   gtk_widget_class_bind_action (widget_class,
                                 GDK_KEY_Delete, 0,
@@ -1282,10 +1233,6 @@ gtk_text_set_property (GObject      *object,
       gtk_text_set_invisible_char (self, g_value_get_uint (value));
       break;
 
-    case PROP_ACTIVATES_DEFAULT:
-      gtk_text_set_activates_default (self, g_value_get_boolean (value));
-      break;
-
     case PROP_TRUNCATE_MULTILINE:
       if (priv->truncate_multiline != g_value_get_boolean (value))
         {
@@ -1413,10 +1360,6 @@ gtk_text_get_property (GObject    *object,
       g_value_set_uint (value, priv->invisible_char);
       break;
 
-    case PROP_ACTIVATES_DEFAULT:
-      g_value_set_boolean (value, priv->activates_default);
-      break;
-
     case PROP_SCROLL_OFFSET:
       g_value_set_int (value, priv->scroll_offset);
       break;
@@ -3711,15 +3654,6 @@ gtk_text_select_all (GtkText *self)
   gtk_text_select_line (self);
 }
 
-static void
-gtk_text_real_activate (GtkText *self)
-{
-  GtkTextPrivate *priv = gtk_text_get_instance_private (self);
-
-  if (priv->activates_default)
-    gtk_widget_activate_default (GTK_WIDGET (self));
-}
-
 static void
 keymap_direction_changed (GdkKeymap *keymap,
                           GtkText   *self)
@@ -5336,51 +5270,6 @@ gtk_text_get_text_length (GtkText *self)
   return gtk_entry_buffer_get_length (get_buffer (self));
 }
 
-/**
- * gtk_text_set_activates_default:
- * @self: a #GtkText
- * @activates: %TRUE to activate window’s default widget on Enter keypress
- *
- * If @activates is %TRUE, pressing Enter in the @self will activate the default
- * widget for the window containing the self. This usually means that
- * the dialog box containing the self will be closed, since the default
- * widget is usually one of the dialog buttons.
- **/
-void
-gtk_text_set_activates_default (GtkText  *self,
-                                gboolean  activates)
-{
-  GtkTextPrivate *priv = gtk_text_get_instance_private (self);
-
-  g_return_if_fail (GTK_IS_TEXT (self));
-
-  activates = activates != FALSE;
-
-  if (priv->activates_default != activates)
-    {
-      priv->activates_default = activates;
-      g_object_notify_by_pspec (G_OBJECT (self), text_props[PROP_ACTIVATES_DEFAULT]);
-    }
-}
-
-/**
- * gtk_text_get_activates_default:
- * @self: a #GtkText
- *
- * Retrieves the value set by gtk_text_set_activates_default().
- *
- * Returns: %TRUE if the self will activate the default widget
- */
-gboolean
-gtk_text_get_activates_default (GtkText *self)
-{
-  GtkTextPrivate *priv = gtk_text_get_instance_private (self);
-
-  g_return_val_if_fail (GTK_IS_TEXT (self), FALSE);
-
-  return priv->activates_default;
-}
-
 static void
 gtk_text_set_width_chars (GtkText *self,
                           int      n_chars)
@@ -5459,18 +5348,6 @@ hide_selection_bubble (GtkText *self)
     gtk_widget_hide (priv->selection_bubble);
 }
 
-static void
-gtk_text_activate_default_activate (GtkWidget  *widget,
-                                    const char *action_name,
-                                    GVariant   *parameter)
-{
-  GtkText *self = GTK_TEXT (widget);
-  GtkTextPrivate *priv = gtk_text_get_instance_private (self);
-
-  if (priv->activates_default)
-    gtk_widget_activate_default (gtk_widget_get_parent (widget));
-}
-
 static void
 gtk_text_activate_clipboard_cut (GtkWidget  *widget,
                                  const char *action_name,
diff --git a/gtk/gtktextprivate.h b/gtk/gtktextprivate.h
index ce9fc7f813..042d068fd1 100644
--- a/gtk/gtktextprivate.h
+++ b/gtk/gtktextprivate.h
@@ -66,10 +66,6 @@ typedef struct _GtkTextClass         GtkTextClass;
 struct _GtkTextClass
 {
   GtkWidgetClass parent_class;
-
-  /* Action signals
-   */
-  void (* activate)           (GtkText         *self);
 };
 
 char *              gtk_text_get_display_text   (GtkText    *entry,


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