[gtk/text: 14/26] search bar: Work with the new GtkSearchEntry



commit b3fa0f318b6b017d9973e983404c358df2a380b1
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Feb 16 23:58:06 2019 -0500

    search bar: Work with the new GtkSearchEntry
    
    Don't assume a search entry is an entry, and use
    the editable api as far as possible.

 gtk/gtksearchbar.c | 24 ++++++++++++------------
 gtk/gtksearchbar.h |  2 +-
 2 files changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtksearchbar.c b/gtk/gtksearchbar.c
index 93594d15f2..2db666cc47 100644
--- a/gtk/gtksearchbar.c
+++ b/gtk/gtksearchbar.c
@@ -148,9 +148,9 @@ gtk_search_bar_handle_event_for_entry (GtkSearchBar *bar,
   preedit_change_id = g_signal_connect (priv->entry, "preedit-changed",
                                         G_CALLBACK (preedit_changed_cb), &preedit_changed);
 
-  old_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->entry)));
+  old_text = g_strdup (gtk_editable_get_text (GTK_EDITABLE (priv->entry)));
   res = gtk_widget_event (priv->entry, event);
-  new_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->entry)));
+  new_text = g_strdup (gtk_editable_get_text (GTK_EDITABLE (priv->entry)));
 
   g_signal_handler_disconnect (priv->entry, preedit_change_id);
 
@@ -255,10 +255,10 @@ reveal_child_changed_cb (GObject      *object,
 
   if (priv->entry)
     {
-      if (reveal_child)
+      if (reveal_child && GTK_IS_ENTRY (priv->entry))
         gtk_entry_grab_focus_without_selecting (GTK_ENTRY (priv->entry));
       else
-        gtk_entry_set_text (GTK_ENTRY (priv->entry), "");
+        gtk_editable_set_text (GTK_EDITABLE (priv->entry), "");
     }
 
   g_object_notify (G_OBJECT (bar), "search-mode-enabled");
@@ -284,8 +284,8 @@ gtk_search_bar_add (GtkContainer *container,
   /* If an entry is the only child, save the developer a couple of
    * lines of code
    */
-  if (GTK_IS_ENTRY (child))
-    gtk_search_bar_connect_entry (bar, GTK_ENTRY (child));
+  if (GTK_IS_EDITABLE (child))
+    gtk_search_bar_connect_entry (bar, GTK_EDITABLE (child));
 
   _gtk_bin_set_child (GTK_BIN (container), child);
 }
@@ -297,7 +297,7 @@ gtk_search_bar_remove (GtkContainer *container,
   GtkSearchBar *bar = GTK_SEARCH_BAR (container);
   GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar);
 
-  if (GTK_IS_ENTRY (child))
+  if (GTK_IS_EDITABLE (child))
     gtk_search_bar_connect_entry (bar, NULL);
 
   gtk_center_box_set_center_widget (GTK_CENTER_BOX (priv->box_center), NULL);
@@ -350,7 +350,7 @@ gtk_search_bar_get_property (GObject    *object,
 }
 
 static void gtk_search_bar_set_entry (GtkSearchBar *bar,
-                                      GtkEntry     *entry);
+                                      GtkEditable  *editable);
 
 static void
 gtk_search_bar_dispose (GObject *object)
@@ -494,7 +494,7 @@ gtk_search_bar_new (void)
 
 static void
 gtk_search_bar_set_entry (GtkSearchBar *bar,
-                          GtkEntry     *entry)
+                          GtkEditable  *entry)
 {
   GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar);
 
@@ -527,7 +527,7 @@ gtk_search_bar_set_entry (GtkSearchBar *bar,
 /**
  * gtk_search_bar_connect_entry:
  * @bar: a #GtkSearchBar
- * @entry: a #GtkEntry
+ * @entry: a #GtkEditable
  *
  * Connects the #GtkEntry widget passed as the one to be used in
  * this search bar. The entry should be a descendant of the search bar.
@@ -536,10 +536,10 @@ gtk_search_bar_set_entry (GtkSearchBar *bar,
  */
 void
 gtk_search_bar_connect_entry (GtkSearchBar *bar,
-                              GtkEntry     *entry)
+                              GtkEditable  *entry)
 {
   g_return_if_fail (GTK_IS_SEARCH_BAR (bar));
-  g_return_if_fail (entry == NULL || GTK_IS_ENTRY (entry));
+  g_return_if_fail (entry == NULL || GTK_IS_EDITABLE (entry));
 
   gtk_search_bar_set_entry (bar, entry);
 }
diff --git a/gtk/gtksearchbar.h b/gtk/gtksearchbar.h
index e06e181f7d..ebf31e3bcc 100644
--- a/gtk/gtksearchbar.h
+++ b/gtk/gtksearchbar.h
@@ -78,7 +78,7 @@ GtkWidget*  gtk_search_bar_new             (void);
 
 GDK_AVAILABLE_IN_ALL
 void        gtk_search_bar_connect_entry   (GtkSearchBar *bar,
-                                            GtkEntry     *entry);
+                                            GtkEditable  *entry);
 
 GDK_AVAILABLE_IN_ALL
 gboolean    gtk_search_bar_get_search_mode (GtkSearchBar *bar);


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