[gtk/wip/carlosg/drop-search-handle-event: 7/7] gtk: Drop gtk_search_[entry|bar]_handle_event()



commit b842bf7bf5aa9f8425c399901f471ff15702384b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Apr 3 13:21:51 2019 +0200

    gtk: Drop gtk_search_[entry|bar]_handle_event()
    
    This is now unused, and unrecommended.

 docs/reference/gtk/gtk4-sections.txt |   2 -
 gtk/gtksearchbar.c                   | 118 -----------------------------------
 gtk/gtksearchbar.h                   |   4 --
 gtk/gtksearchentry.c                 |  48 --------------
 gtk/gtksearchentry.h                 |   4 --
 5 files changed, 176 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index b2098ded5c..918794d10b 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -2493,7 +2493,6 @@ gtk_search_bar_get_search_mode
 gtk_search_bar_set_search_mode
 gtk_search_bar_get_show_close_button
 gtk_search_bar_set_show_close_button
-gtk_search_bar_handle_event
 gtk_search_bar_set_key_capture_widget
 gtk_search_bar_get_key_capture_widget
 <SUBSECTION Standard>
@@ -2512,7 +2511,6 @@ gtk_search_bar_get_type
 <TITLE>GtkSearchEntry</TITLE>
 GtkSearchEntry
 gtk_search_entry_new
-gtk_search_entry_handle_event
 gtk_search_entry_set_key_capture_widget
 gtk_search_entry_get_key_capture_widget
 <SUBSECTION Standard>
diff --git a/gtk/gtksearchbar.c b/gtk/gtksearchbar.c
index e774955d3f..ea6e134c5b 100644
--- a/gtk/gtksearchbar.c
+++ b/gtk/gtksearchbar.c
@@ -121,124 +121,6 @@ preedit_changed_cb (GtkEntry  *entry,
   *preedit_changed = TRUE;
 }
 
-static gboolean
-gtk_search_bar_handle_event_for_entry (GtkSearchBar *bar,
-                                       GdkEvent     *event)
-{
-  GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar);
-  gboolean handled;
-  gboolean preedit_changed;
-  guint preedit_change_id;
-  gboolean res;
-  char *old_text, *new_text;
-  guint keyval, state;
-
-  gdk_event_get_keyval (event, &keyval);
-  gdk_event_get_state (event, &state);
-
-  if (gtk_search_entry_is_keynav (keyval, state) ||
-      keyval == GDK_KEY_space ||
-      keyval == GDK_KEY_Menu)
-    return GDK_EVENT_PROPAGATE;
-
-  if (!gtk_widget_get_realized (priv->entry))
-    gtk_widget_realize (priv->entry);
-
-  handled = GDK_EVENT_PROPAGATE;
-  preedit_changed = FALSE;
-  preedit_change_id = g_signal_connect (priv->entry, "preedit-changed",
-                                        G_CALLBACK (preedit_changed_cb), &preedit_changed);
-
-  old_text = g_strdup (gtk_editable_get_text (GTK_EDITABLE (priv->entry)));
-  res = gtk_widget_event (priv->entry, event);
-  new_text = g_strdup (gtk_editable_get_text (GTK_EDITABLE (priv->entry)));
-
-  g_signal_handler_disconnect (priv->entry, preedit_change_id);
-
-  if ((res && g_strcmp0 (new_text, old_text) != 0) || preedit_changed)
-    handled = GDK_EVENT_STOP;
-
-  g_free (old_text);
-  g_free (new_text);
-
-  return handled;
-}
-
-/**
- * gtk_search_bar_handle_event:
- * @bar: a #GtkSearchBar
- * @event: a #GdkEvent containing key press events
- *
- * This function should be called when the top-level
- * window which contains the search bar received a key event.
- *
- * If the key event is handled by the search bar, the bar will
- * be shown, the entry populated with the entered text and %GDK_EVENT_STOP
- * will be returned. The caller should ensure that events are
- * not propagated further.
- *
- * If no entry has been connected to the search bar, using
- * gtk_search_bar_connect_entry(), this function will return
- * immediately with a warning.
- *
- * ## Showing the search bar on key presses
- *
- * |[<!-- language="C" -->
- * static gboolean
- * on_key_press_event (GtkWidget *widget,
- *                     GdkEvent  *event,
- *                     gpointer   user_data)
- * {
- *   GtkSearchBar *bar = GTK_SEARCH_BAR (user_data);
- *   return gtk_search_bar_handle_event (bar, event);
- * }
- *
- * static void
- * create_toplevel (void)
- * {
- *   GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- *   GtkWindow *search_bar = gtk_search_bar_new ();
- *
- *  // Add more widgets to the window...
- *
- *   g_signal_connect (window,
- *                    "key-press-event",
- *                     G_CALLBACK (on_key_press_event),
- *                     search_bar);
- * }
- * ]|
- *
- * Returns: %GDK_EVENT_STOP if the key press event resulted
- *     in text being entered in the search entry (and revealing
- *     the search bar if necessary), %GDK_EVENT_PROPAGATE otherwise.
- */
-gboolean
-gtk_search_bar_handle_event (GtkSearchBar *bar,
-                             GdkEvent     *event)
-{
-  GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar);
-  gboolean handled;
-
-  if (priv->reveal_child)
-    return GDK_EVENT_PROPAGATE;
-
-  if (priv->entry == NULL)
-    {
-      g_warning ("The search bar does not have an entry connected to it. Call gtk_search_bar_connect_entry() 
to connect one.");
-      return GDK_EVENT_PROPAGATE;
-    }
-
-  if (GTK_IS_SEARCH_ENTRY (priv->entry))
-    handled = gtk_search_entry_handle_event (GTK_SEARCH_ENTRY (priv->entry), event);
-  else
-    handled = gtk_search_bar_handle_event_for_entry (bar, event);
-
-  if (handled == GDK_EVENT_STOP)
-    gtk_revealer_set_reveal_child (GTK_REVEALER (priv->revealer), TRUE);
-
-  return handled;
-}
-
 static void
 reveal_child_changed_cb (GObject      *object,
                          GParamSpec   *pspec,
diff --git a/gtk/gtksearchbar.h b/gtk/gtksearchbar.h
index ebf31e3bcc..3bd9a69b85 100644
--- a/gtk/gtksearchbar.h
+++ b/gtk/gtksearchbar.h
@@ -92,10 +92,6 @@ GDK_AVAILABLE_IN_ALL
 void        gtk_search_bar_set_show_close_button (GtkSearchBar *bar,
                                                   gboolean      visible);
 
-GDK_AVAILABLE_IN_ALL
-gboolean    gtk_search_bar_handle_event    (GtkSearchBar *bar,
-                                            GdkEvent     *event);
-
 GDK_AVAILABLE_IN_ALL
 void        gtk_search_bar_set_key_capture_widget (GtkSearchBar *bar,
                                                    GtkWidget    *widget);
diff --git a/gtk/gtksearchentry.c b/gtk/gtksearchentry.c
index b9b1e6d764..281a99fb61 100644
--- a/gtk/gtksearchentry.c
+++ b/gtk/gtksearchentry.c
@@ -614,54 +614,6 @@ gtk_search_entry_is_keynav (guint           keyval,
   return FALSE;
 }
 
-/**
- * gtk_search_entry_handle_event:
- * @entry: a #GtkSearchEntry
- * @event: a key event
- *
- * This function should be called when the top-level window
- * which contains the search entry received a key event. If
- * the entry is part of a #GtkSearchBar, it is preferable
- * to call gtk_search_bar_handle_event() instead, which will
- * reveal the entry in addition to passing the event to this
- * function.
- *
- * If the key event is handled by the search entry and starts
- * or continues a search, %GDK_EVENT_STOP will be returned.
- * The caller should ensure that the entry is shown in this
- * case, and not propagate the event further.
- *
- * Returns: %GDK_EVENT_STOP if the key press event resulted
- *     in a search beginning or continuing, %GDK_EVENT_PROPAGATE
- *     otherwise.
- */
-gboolean
-gtk_search_entry_handle_event (GtkSearchEntry *entry,
-                               GdkEvent       *event)
-{
-  GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
-  gboolean handled;
-  guint keyval, state;
-
-  if (!gtk_widget_get_realized (GTK_WIDGET (entry)))
-    gtk_widget_realize (GTK_WIDGET (entry));
-
-  gdk_event_get_keyval (event, &keyval);
-  gdk_event_get_state (event, &state);
-
-  if (gtk_search_entry_is_keynav (keyval, state) ||
-      keyval == GDK_KEY_space ||
-      keyval == GDK_KEY_Menu)
-    return GDK_EVENT_PROPAGATE;
-
-  priv->content_changed = FALSE;
-  priv->search_stopped = FALSE;
-
-  handled = gtk_widget_event (GTK_WIDGET (entry), event);
-
-  return handled && priv->content_changed && !priv->search_stopped ? GDK_EVENT_STOP : GDK_EVENT_PROPAGATE;
-}
-
 static gboolean
 capture_widget_key_handled (GtkEventControllerKey *controller,
                             guint                  keyval,
diff --git a/gtk/gtksearchentry.h b/gtk/gtksearchentry.h
index 5d65fc2e83..04ca00967a 100644
--- a/gtk/gtksearchentry.h
+++ b/gtk/gtksearchentry.h
@@ -68,10 +68,6 @@ GType           gtk_search_entry_get_type       (void) G_GNUC_CONST;
 GDK_AVAILABLE_IN_ALL
 GtkWidget*      gtk_search_entry_new            (void);
 
-GDK_AVAILABLE_IN_ALL
-gboolean        gtk_search_entry_handle_event   (GtkSearchEntry *entry,
-                                                 GdkEvent       *event);
-
 GDK_AVAILABLE_IN_ALL
 void            gtk_search_entry_set_key_capture_widget (GtkSearchEntry *entry,
                                                          GtkWidget      *widget);


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