Commit fa3d1940 authored by Matthias Clasen's avatar Matthias Clasen
Browse files

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.
parent 667ea2dd
......@@ -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);
}
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment