summaryrefslogtreecommitdiff
path: root/demos/gtk-demo/entry_completion.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-06-24 22:26:24 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-06-25 08:24:05 -0400
commit0b8092a2ba9558879ae1b5adb68a86399a6869ef (patch)
tree46f5e52c6628d4d2e06f57c47a2a0bea8f008020 /demos/gtk-demo/entry_completion.c
parentab3b1d9d2a9321d50c56eb3dc32fc8dbfd52cad4 (diff)
downloadgtk+-port-entry-completion.tar.gz
entrycompletion: port to list modelsport-entry-completion
Replace tree models and cell renderers with list models and factories, in the entry completion api. The new apis are gtk_entry_completion_set_model gtk_entry_completion_set_expression gtk_entry_completion_set_factory Port all internal uses of GtkEntryCompletion. testentrycompletion has an example of using a custom model, factory and expression.
Diffstat (limited to 'demos/gtk-demo/entry_completion.c')
-rw-r--r--demos/gtk-demo/entry_completion.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/demos/gtk-demo/entry_completion.c b/demos/gtk-demo/entry_completion.c
index 40d64bd8b6..3d48ae6cd9 100644
--- a/demos/gtk-demo/entry_completion.c
+++ b/demos/gtk-demo/entry_completion.c
@@ -8,8 +8,8 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-/* Creates a tree model containing the completions */
-static GtkTreeModel *
+/* Creates a list model containing the completions */
+static GListModel *
create_completion_model (void)
{
const char *strings[] = {
@@ -42,20 +42,8 @@ create_completion_model (void)
"aæz",
NULL
};
- int i;
- GtkListStore *store;
- GtkTreeIter iter;
- store = gtk_list_store_new (1, G_TYPE_STRING);
-
- for (i = 0; strings[i]; i++)
- {
- /* Append one word */
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter, 0, strings[i], -1);
- }
-
- return GTK_TREE_MODEL (store);
+ return G_LIST_MODEL (gtk_string_list_new (strings));
}
@@ -67,7 +55,7 @@ do_entry_completion (GtkWidget *do_widget)
GtkWidget *label;
GtkWidget *entry;
GtkEntryCompletion *completion;
- GtkTreeModel *completion_model;
+ GListModel *completion_model;
if (!window)
{
@@ -105,9 +93,6 @@ do_entry_completion (GtkWidget *do_widget)
gtk_entry_completion_set_model (completion, completion_model);
g_object_unref (completion_model);
- /* Use model column 0 as the text column */
- gtk_entry_completion_set_text_column (completion, 0);
-
gtk_entry_completion_set_inline_completion (completion, TRUE);
gtk_entry_completion_set_inline_selection (completion, TRUE);
}