[gtk/suggestion-entry: 27/29] suggestionentry: Handle no-model situations
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/suggestion-entry: 27/29] suggestionentry: Handle no-model situations
- Date: Fri, 10 Jul 2020 18:01:25 +0000 (UTC)
commit affa829ac29192e74df4d5e92f76bd8f0e83e026
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jul 9 20:53:42 2020 -0400
suggestionentry: Handle no-model situations
We shouldn't throw criticals when there is no
model. Just act like a plain entry.
gtk/gtksuggestionentry.c | 7 +++++++
1 file changed, 7 insertions(+)
---
diff --git a/gtk/gtksuggestionentry.c b/gtk/gtksuggestionentry.c
index f521d94914..7ed76d0c13 100644
--- a/gtk/gtksuggestionentry.c
+++ b/gtk/gtksuggestionentry.c
@@ -564,6 +564,9 @@ text_changed_idle (gpointer data)
guint matches;
GtkFilter *filter;
+ if (!self->filter_model)
+ return G_SOURCE_REMOVE;
+
text = gtk_editable_get_text (GTK_EDITABLE (self->entry));
len = g_utf8_strlen (text, -1);
filter = gtk_filter_list_model_get_filter (self->filter_model);
@@ -868,6 +871,8 @@ gtk_suggestion_entry_init (GtkSuggestionEntry *self)
self->insert_prefix = FALSE;
self->show_button = FALSE;
+ gtk_widget_action_set_enabled (GTK_WIDGET (self), "popup.show", FALSE);
+
self->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_add_css_class (self->box, "linked");
gtk_widget_set_hexpand (self->box, TRUE);
@@ -1241,6 +1246,8 @@ gtk_suggestion_entry_set_model (GtkSuggestionEntry *self,
g_signal_connect (self->selection, "items-changed",
G_CALLBACK (items_changed), self);
}
+ else
+ gtk_widget_action_set_enabled (GTK_WIDGET (self), "popup.show", FALSE);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODEL]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]