summaryrefslogtreecommitdiff
path: root/gtk/gtksearchbar.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-02-16 23:58:06 -0500
committerMatthias Clasen <mclasen@redhat.com>2019-02-19 00:25:59 -0500
commitfa3d1940bf2b36c165164584f12ef37c0a1c6206 (patch)
treeae87f067d7037ec3e1146133e1f94e98c3fc0636 /gtk/gtksearchbar.c
parent667ea2dd4229307ddacb1d32f18259a15047575f (diff)
downloadgtk+-fa3d1940bf2b36c165164584f12ef37c0a1c6206.tar.gz
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.
Diffstat (limited to 'gtk/gtksearchbar.c')
-rw-r--r--gtk/gtksearchbar.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/gtk/gtksearchbar.c b/gtk/gtksearchbar.c
index 93594d15f2..0b3f916344 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,12 @@ 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 if (GTK_IS_SEARCH_ENTRY (priv->entry))
+ gtk_widget_grab_focus (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 +286,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 +299,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 +352,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 +496,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 +529,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 +538,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);
}