1/* gtkentrycompletion.h
2 * Copyright (C) 2003 Kristian Rietveld <kris@gtk.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __GTK_ENTRY_COMPLETION_H__
19#define __GTK_ENTRY_COMPLETION_H__
20
21#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
22#error "Only <gtk/gtk.h> can be included directly."
23#endif
24
25#include <gdk/gdk.h>
26#include <gtk/gtktreemodel.h>
27#include <gtk/gtkliststore.h>
28#include <gtk/gtkcellarea.h>
29#include <gtk/gtktreeviewcolumn.h>
30#include <gtk/gtktreemodelfilter.h>
31
32G_BEGIN_DECLS
33
34#define GTK_TYPE_ENTRY_COMPLETION (gtk_entry_completion_get_type ())
35#define GTK_ENTRY_COMPLETION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ENTRY_COMPLETION, GtkEntryCompletion))
36#define GTK_IS_ENTRY_COMPLETION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ENTRY_COMPLETION))
37
38typedef struct _GtkEntryCompletion GtkEntryCompletion;
39
40/**
41 * GtkEntryCompletionMatchFunc:
42 * @completion: the `GtkEntryCompletion`
43 * @key: the string to match, normalized and case-folded
44 * @iter: a `GtkTreeIter` indicating the row to match
45 * @user_data: user data given to gtk_entry_completion_set_match_func()
46 *
47 * A function which decides whether the row indicated by @iter matches
48 * a given @key, and should be displayed as a possible completion for @key.
49 *
50 * Note that @key is normalized and case-folded (see g_utf8_normalize()
51 * and g_utf8_casefold()). If this is not appropriate, match functions
52 * have access to the unmodified key via
53 * `gtk_editable_get_text (GTK_EDITABLE (gtk_entry_completion_get_entry ()))`.
54 *
55 * Returns: %TRUE if @iter should be displayed as a possible completion
56 * for @key
57 */
58typedef gboolean (* GtkEntryCompletionMatchFunc) (GtkEntryCompletion *completion,
59 const char *key,
60 GtkTreeIter *iter,
61 gpointer user_data);
62
63
64GDK_AVAILABLE_IN_ALL
65GType gtk_entry_completion_get_type (void) G_GNUC_CONST;
66GDK_AVAILABLE_IN_ALL
67GtkEntryCompletion *gtk_entry_completion_new (void);
68GDK_AVAILABLE_IN_ALL
69GtkEntryCompletion *gtk_entry_completion_new_with_area (GtkCellArea *area);
70
71GDK_AVAILABLE_IN_ALL
72GtkWidget *gtk_entry_completion_get_entry (GtkEntryCompletion *completion);
73
74GDK_AVAILABLE_IN_ALL
75void gtk_entry_completion_set_model (GtkEntryCompletion *completion,
76 GtkTreeModel *model);
77GDK_AVAILABLE_IN_ALL
78GtkTreeModel *gtk_entry_completion_get_model (GtkEntryCompletion *completion);
79
80GDK_AVAILABLE_IN_ALL
81void gtk_entry_completion_set_match_func (GtkEntryCompletion *completion,
82 GtkEntryCompletionMatchFunc func,
83 gpointer func_data,
84 GDestroyNotify func_notify);
85GDK_AVAILABLE_IN_ALL
86void gtk_entry_completion_set_minimum_key_length (GtkEntryCompletion *completion,
87 int length);
88GDK_AVAILABLE_IN_ALL
89int gtk_entry_completion_get_minimum_key_length (GtkEntryCompletion *completion);
90GDK_AVAILABLE_IN_ALL
91char * gtk_entry_completion_compute_prefix (GtkEntryCompletion *completion,
92 const char *key);
93GDK_AVAILABLE_IN_ALL
94void gtk_entry_completion_complete (GtkEntryCompletion *completion);
95GDK_AVAILABLE_IN_ALL
96void gtk_entry_completion_insert_prefix (GtkEntryCompletion *completion);
97
98GDK_AVAILABLE_IN_ALL
99void gtk_entry_completion_set_inline_completion (GtkEntryCompletion *completion,
100 gboolean inline_completion);
101GDK_AVAILABLE_IN_ALL
102gboolean gtk_entry_completion_get_inline_completion (GtkEntryCompletion *completion);
103GDK_AVAILABLE_IN_ALL
104void gtk_entry_completion_set_inline_selection (GtkEntryCompletion *completion,
105 gboolean inline_selection);
106GDK_AVAILABLE_IN_ALL
107gboolean gtk_entry_completion_get_inline_selection (GtkEntryCompletion *completion);
108GDK_AVAILABLE_IN_ALL
109void gtk_entry_completion_set_popup_completion (GtkEntryCompletion *completion,
110 gboolean popup_completion);
111GDK_AVAILABLE_IN_ALL
112gboolean gtk_entry_completion_get_popup_completion (GtkEntryCompletion *completion);
113GDK_AVAILABLE_IN_ALL
114void gtk_entry_completion_set_popup_set_width (GtkEntryCompletion *completion,
115 gboolean popup_set_width);
116GDK_AVAILABLE_IN_ALL
117gboolean gtk_entry_completion_get_popup_set_width (GtkEntryCompletion *completion);
118GDK_AVAILABLE_IN_ALL
119void gtk_entry_completion_set_popup_single_match (GtkEntryCompletion *completion,
120 gboolean popup_single_match);
121GDK_AVAILABLE_IN_ALL
122gboolean gtk_entry_completion_get_popup_single_match (GtkEntryCompletion *completion);
123
124GDK_AVAILABLE_IN_ALL
125const char *gtk_entry_completion_get_completion_prefix (GtkEntryCompletion *completion);
126/* convenience */
127GDK_AVAILABLE_IN_ALL
128void gtk_entry_completion_set_text_column (GtkEntryCompletion *completion,
129 int column);
130GDK_AVAILABLE_IN_ALL
131int gtk_entry_completion_get_text_column (GtkEntryCompletion *completion);
132
133G_END_DECLS
134
135#endif /* __GTK_ENTRY_COMPLETION_H__ */
136

source code of gtk/gtk/gtkentrycompletion.h