1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>Automatic String Completion</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
7 <link rel="home" href="index.html" title="GLib Reference Manual">
8 <link rel="up" href="glib-utilities.html" title="GLib Utilities">
9 <link rel="prev" href="glib-Lexical-Scanner.html" title="Lexical Scanner">
10 <link rel="next" href="glib-Timers.html" title="Timers">
11 <meta name="generator" content="GTK-Doc V1.13 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 <link rel="chapter" href="glib.html" title="GLib Overview">
14 <link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals">
15 <link rel="chapter" href="glib-core.html" title="GLib Core Application Support">
16 <link rel="chapter" href="glib-utilities.html" title="GLib Utilities">
17 <link rel="chapter" href="glib-data-types.html" title="GLib Data Types">
18 <link rel="chapter" href="tools.html" title="GLib Tools">
19 <link rel="index" href="api-index-full.html" title="Index">
20 <link rel="index" href="api-index-deprecated.html" title="Index of deprecated symbols">
21 <link rel="index" href="api-index-2-2.html" title="Index of new symbols in 2.2">
22 <link rel="index" href="api-index-2-4.html" title="Index of new symbols in 2.4">
23 <link rel="index" href="api-index-2-6.html" title="Index of new symbols in 2.6">
24 <link rel="index" href="api-index-2-8.html" title="Index of new symbols in 2.8">
25 <link rel="index" href="api-index-2-10.html" title="Index of new symbols in 2.10">
26 <link rel="index" href="api-index-2-12.html" title="Index of new symbols in 2.12">
27 <link rel="index" href="api-index-2-14.html" title="Index of new symbols in 2.14">
28 <link rel="index" href="api-index-2-16.html" title="Index of new symbols in 2.16">
29 <link rel="index" href="api-index-2-18.html" title="Index of new symbols in 2.18">
30 <link rel="index" href="api-index-2-20.html" title="Index of new symbols in 2.20">
31 <link rel="index" href="api-index-2-22.html" title="Index of new symbols in 2.22">
32 <link rel="index" href="api-index-2-24.html" title="Index of new symbols in 2.24">
34 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
35 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
37 <td><a accesskey="p" href="glib-Lexical-Scanner.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
38 <td><a accesskey="u" href="glib-utilities.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
39 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
40 <th width="100%" align="center">GLib Reference Manual</th>
41 <td><a accesskey="n" href="glib-Timers.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
43 <tr><td colspan="5" class="shortcuts">
44 <a href="#glib-Automatic-String-Completion.synopsis" class="shortcut">Top</a>
46 <a href="#glib-Automatic-String-Completion.description" class="shortcut">Description</a>
49 <div class="refentry" title="Automatic String Completion">
50 <a name="glib-Automatic-String-Completion"></a><div class="titlepage"></div>
51 <div class="refnamediv"><table width="100%"><tr>
53 <h2><span class="refentrytitle"><a name="glib-Automatic-String-Completion.top_of_page"></a>Automatic String Completion</span></h2>
54 <p>Automatic String Completion — support for automatic completion using a group
57 <td valign="top" align="right"></td>
59 <div class="refsynopsisdiv" title="Synopsis">
60 <a name="glib-Automatic-String-Completion.synopsis"></a><h2>Synopsis</h2>
61 <pre class="synopsis">
62 #include <glib.h>
64 <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion">GCompletion</a>;
65 <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="returnvalue">GCompletion</span></a>* <a class="link" href="glib-Automatic-String-Completion.html#g-completion-new" title="g_completion_new ()">g_completion_new</a> (<a class="link" href="glib-Automatic-String-Completion.html#GCompletionFunc" title="GCompletionFunc ()"><span class="returnvalue">GCompletionFunc</span></a> func);
66 <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> * (<a class="link" href="glib-Automatic-String-Completion.html#GCompletionFunc" title="GCompletionFunc ()">*GCompletionFunc</a>) (<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a> );
67 <span class="returnvalue">void</span> <a class="link" href="glib-Automatic-String-Completion.html#g-completion-add-items" title="g_completion_add_items ()">g_completion_add_items</a> (<a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="returnvalue">GCompletion</span></a> *cmp,
68 <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="GList"><span class="returnvalue">GList</span></a> *items);
69 <span class="returnvalue">void</span> <a class="link" href="glib-Automatic-String-Completion.html#g-completion-remove-items" title="g_completion_remove_items ()">g_completion_remove_items</a> (<a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="returnvalue">GCompletion</span></a> *cmp,
70 <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="GList"><span class="returnvalue">GList</span></a> *items);
71 <span class="returnvalue">void</span> <a class="link" href="glib-Automatic-String-Completion.html#g-completion-clear-items" title="g_completion_clear_items ()">g_completion_clear_items</a> (<a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="returnvalue">GCompletion</span></a> *cmp);
72 <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="GList"><span class="returnvalue">GList</span></a>* <a class="link" href="glib-Automatic-String-Completion.html#g-completion-complete" title="g_completion_complete ()">g_completion_complete</a> (<a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="returnvalue">GCompletion</span></a> *cmp,
73 const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *prefix,
74 <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **new_prefix);
75 <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="GList"><span class="returnvalue">GList</span></a>* <a class="link" href="glib-Automatic-String-Completion.html#g-completion-complete-utf8" title="g_completion_complete_utf8 ()">g_completion_complete_utf8</a> (<a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="returnvalue">GCompletion</span></a> *cmp,
76 const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *prefix,
77 <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **new_prefix);
78 <span class="returnvalue">void</span> <a class="link" href="glib-Automatic-String-Completion.html#g-completion-set-compare" title="g_completion_set_compare ()">g_completion_set_compare</a> (<a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="returnvalue">GCompletion</span></a> *cmp,
79 <a class="link" href="glib-Automatic-String-Completion.html#GCompletionStrncmpFunc" title="GCompletionStrncmpFunc ()"><span class="returnvalue">GCompletionStrncmpFunc</span></a> strncmp_func);
80 <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a> (<a class="link" href="glib-Automatic-String-Completion.html#GCompletionStrncmpFunc" title="GCompletionStrncmpFunc ()">*GCompletionStrncmpFunc</a>) (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *s1,
81 const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *s2,
82 <a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="returnvalue">gsize</span></a> n);
83 <span class="returnvalue">void</span> <a class="link" href="glib-Automatic-String-Completion.html#g-completion-free" title="g_completion_free ()">g_completion_free</a> (<a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="returnvalue">GCompletion</span></a> *cmp);
86 <div class="refsect1" title="Description">
87 <a name="glib-Automatic-String-Completion.description"></a><h2>Description</h2>
89 <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a> provides support for automatic completion of a string
90 using any group of target strings. It is typically used for file
91 name completion as is common in many UNIX shells.
94 A <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a> is created using <a class="link" href="glib-Automatic-String-Completion.html#g-completion-new" title="g_completion_new ()"><code class="function">g_completion_new()</code></a>. Target items are
95 added and removed with <a class="link" href="glib-Automatic-String-Completion.html#g-completion-add-items" title="g_completion_add_items ()"><code class="function">g_completion_add_items()</code></a>,
96 <a class="link" href="glib-Automatic-String-Completion.html#g-completion-remove-items" title="g_completion_remove_items ()"><code class="function">g_completion_remove_items()</code></a> and <a class="link" href="glib-Automatic-String-Completion.html#g-completion-clear-items" title="g_completion_clear_items ()"><code class="function">g_completion_clear_items()</code></a>. A
97 completion attempt is requested with <a class="link" href="glib-Automatic-String-Completion.html#g-completion-complete" title="g_completion_complete ()"><code class="function">g_completion_complete()</code></a> or
98 <a class="link" href="glib-Automatic-String-Completion.html#g-completion-complete-utf8" title="g_completion_complete_utf8 ()"><code class="function">g_completion_complete_utf8()</code></a>. When no longer needed, the
99 <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a> is freed with <a class="link" href="glib-Automatic-String-Completion.html#g-completion-free" title="g_completion_free ()"><code class="function">g_completion_free()</code></a>.
102 Items in the completion can be simple strings (e.g. filenames), or
103 pointers to arbitrary data structures. If data structures are used
104 you must provide a <a class="link" href="glib-Automatic-String-Completion.html#GCompletionFunc" title="GCompletionFunc ()"><span class="type">GCompletionFunc</span></a> in <a class="link" href="glib-Automatic-String-Completion.html#g-completion-new" title="g_completion_new ()"><code class="function">g_completion_new()</code></a>, which
105 retrieves the item's string from the data structure. You can change
106 the way in which strings are compared by setting a different
107 <a class="link" href="glib-Automatic-String-Completion.html#GCompletionStrncmpFunc" title="GCompletionStrncmpFunc ()"><span class="type">GCompletionStrncmpFunc</span></a> in <a class="link" href="glib-Automatic-String-Completion.html#g-completion-set-compare" title="g_completion_set_compare ()"><code class="function">g_completion_set_compare()</code></a>.</p>
109 <div class="refsect1" title="Details">
110 <a name="glib-Automatic-String-Completion.details"></a><h2>Details</h2>
111 <div class="refsect2" title="GCompletion">
112 <a name="GCompletion"></a><h3>GCompletion</h3>
113 <pre class="programlisting">typedef struct {
115 GCompletionFunc func;
119 GCompletionStrncmpFunc strncmp_func;
123 The data structure used for automatic completion.</p>
124 <div class="variablelist"><table border="0">
125 <col align="left" valign="top">
128 <td><p><span class="term"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="GList"><span class="type">GList</span></a> *<em class="structfield"><code><a name="GCompletion.items"></a>items</code></em>;</span></p></td>
129 <td> list of target items (strings or data structures).
133 <td><p><span class="term"><a class="link" href="glib-Automatic-String-Completion.html#GCompletionFunc" title="GCompletionFunc ()"><span class="type">GCompletionFunc</span></a> <em class="structfield"><code><a name="GCompletion.func"></a>func</code></em>;</span></p></td>
134 <td> function which is called to get the string associated with a
135 target item. It is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if the target items are strings.
139 <td><p><span class="term"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *<em class="structfield"><code><a name="GCompletion.prefix"></a>prefix</code></em>;</span></p></td>
140 <td> the last prefix passed to <a class="link" href="glib-Automatic-String-Completion.html#g-completion-complete" title="g_completion_complete ()"><code class="function">g_completion_complete()</code></a> or
141 <a class="link" href="glib-Automatic-String-Completion.html#g-completion-complete-utf8" title="g_completion_complete_utf8 ()"><code class="function">g_completion_complete_utf8()</code></a>.
145 <td><p><span class="term"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="GList"><span class="type">GList</span></a> *<em class="structfield"><code><a name="GCompletion.cache"></a>cache</code></em>;</span></p></td>
146 <td> the list of items which begin with <em class="parameter"><code>prefix</code></em>.
150 <td><p><span class="term"><a class="link" href="glib-Automatic-String-Completion.html#GCompletionStrncmpFunc" title="GCompletionStrncmpFunc ()"><span class="type">GCompletionStrncmpFunc</span></a> <em class="structfield"><code><a name="GCompletion.strncmp-func"></a>strncmp_func</code></em>;</span></p></td>
151 <td> The function to use when comparing strings. Use
152 <a class="link" href="glib-Automatic-String-Completion.html#g-completion-set-compare" title="g_completion_set_compare ()"><code class="function">g_completion_set_compare()</code></a> to modify this function.
159 <div class="refsect2" title="g_completion_new ()">
160 <a name="g-completion-new"></a><h3>g_completion_new ()</h3>
161 <pre class="programlisting"><a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="returnvalue">GCompletion</span></a>* g_completion_new (<a class="link" href="glib-Automatic-String-Completion.html#GCompletionFunc" title="GCompletionFunc ()"><span class="returnvalue">GCompletionFunc</span></a> func);</pre>
163 Creates a new <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a>.</p>
164 <div class="variablelist"><table border="0">
165 <col align="left" valign="top">
168 <td><p><span class="term"><em class="parameter"><code>func</code></em> :</span></p></td>
169 <td> the function to be called to return the string representing
170 an item in the <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if strings are going to
171 be used as the <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a> items.
175 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
176 <td> the new <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a>.
183 <div class="refsect2" title="GCompletionFunc ()">
184 <a name="GCompletionFunc"></a><h3>GCompletionFunc ()</h3>
185 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> * (*GCompletionFunc) (<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a> );</pre>
187 Specifies the type of the function passed to <a class="link" href="glib-Automatic-String-Completion.html#g-completion-new" title="g_completion_new ()"><code class="function">g_completion_new()</code></a>. It
188 should return the string corresponding to the given target item.
189 This is used when you use data structures as <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a> items.</p>
190 <div class="variablelist"><table border="0">
191 <col align="left" valign="top">
194 <td><p><span class="term"><em class="parameter"><code>Param1</code></em> :</span></p></td>
195 <td> the completion item.
199 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
200 <td> the string corresponding to the item.
207 <div class="refsect2" title="g_completion_add_items ()">
208 <a name="g-completion-add-items"></a><h3>g_completion_add_items ()</h3>
209 <pre class="programlisting"><span class="returnvalue">void</span> g_completion_add_items (<a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="returnvalue">GCompletion</span></a> *cmp,
210 <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="GList"><span class="returnvalue">GList</span></a> *items);</pre>
212 Adds items to the <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a>.</p>
213 <div class="variablelist"><table border="0">
214 <col align="left" valign="top">
217 <td><p><span class="term"><em class="parameter"><code>cmp</code></em> :</span></p></td>
218 <td> the <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a>.
222 <td><p><span class="term"><em class="parameter"><code>items</code></em> :</span></p></td>
223 <td> the list of items to add.
230 <div class="refsect2" title="g_completion_remove_items ()">
231 <a name="g-completion-remove-items"></a><h3>g_completion_remove_items ()</h3>
232 <pre class="programlisting"><span class="returnvalue">void</span> g_completion_remove_items (<a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="returnvalue">GCompletion</span></a> *cmp,
233 <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="GList"><span class="returnvalue">GList</span></a> *items);</pre>
235 Removes items from a <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a>.</p>
236 <div class="variablelist"><table border="0">
237 <col align="left" valign="top">
240 <td><p><span class="term"><em class="parameter"><code>cmp</code></em> :</span></p></td>
241 <td> the <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a>.
245 <td><p><span class="term"><em class="parameter"><code>items</code></em> :</span></p></td>
246 <td> the items to remove.
253 <div class="refsect2" title="g_completion_clear_items ()">
254 <a name="g-completion-clear-items"></a><h3>g_completion_clear_items ()</h3>
255 <pre class="programlisting"><span class="returnvalue">void</span> g_completion_clear_items (<a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="returnvalue">GCompletion</span></a> *cmp);</pre>
257 Removes all items from the <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a>.</p>
258 <div class="variablelist"><table border="0">
259 <col align="left" valign="top">
261 <td><p><span class="term"><em class="parameter"><code>cmp</code></em> :</span></p></td>
262 <td> the <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a>.
268 <div class="refsect2" title="g_completion_complete ()">
269 <a name="g-completion-complete"></a><h3>g_completion_complete ()</h3>
270 <pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="GList"><span class="returnvalue">GList</span></a>* g_completion_complete (<a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="returnvalue">GCompletion</span></a> *cmp,
271 const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *prefix,
272 <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **new_prefix);</pre>
274 Attempts to complete the string <em class="parameter"><code>prefix</code></em> using the <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a>
276 <div class="variablelist"><table border="0">
277 <col align="left" valign="top">
280 <td><p><span class="term"><em class="parameter"><code>cmp</code></em> :</span></p></td>
281 <td> the <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a>.
285 <td><p><span class="term"><em class="parameter"><code>prefix</code></em> :</span></p></td>
286 <td> the prefix string, typically typed by the user, which is
287 compared with each of the items.
291 <td><p><span class="term"><em class="parameter"><code>new_prefix</code></em> :</span></p></td>
292 <td> if non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, returns the longest prefix which is
293 common to all items that matched <em class="parameter"><code>prefix</code></em>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if
294 no items matched <em class="parameter"><code>prefix</code></em>. This string should be freed
295 when no longer needed.
299 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
300 <td> the list of items whose strings begin with <em class="parameter"><code>prefix</code></em>. This
301 should not be changed.
308 <div class="refsect2" title="g_completion_complete_utf8 ()">
309 <a name="g-completion-complete-utf8"></a><h3>g_completion_complete_utf8 ()</h3>
310 <pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="GList"><span class="returnvalue">GList</span></a>* g_completion_complete_utf8 (<a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="returnvalue">GCompletion</span></a> *cmp,
311 const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *prefix,
312 <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **new_prefix);</pre>
314 Attempts to complete the string <em class="parameter"><code>prefix</code></em> using the <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a> target items.
315 In contrast to <a class="link" href="glib-Automatic-String-Completion.html#g-completion-complete" title="g_completion_complete ()"><code class="function">g_completion_complete()</code></a>, this function returns the largest common
316 prefix that is a valid UTF-8 string, omitting a possible common partial
320 You should use this function instead of <a class="link" href="glib-Automatic-String-Completion.html#g-completion-complete" title="g_completion_complete ()"><code class="function">g_completion_complete()</code></a> if your
321 items are UTF-8 strings.</p>
322 <div class="variablelist"><table border="0">
323 <col align="left" valign="top">
326 <td><p><span class="term"><em class="parameter"><code>cmp</code></em> :</span></p></td>
327 <td> the <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a>
331 <td><p><span class="term"><em class="parameter"><code>prefix</code></em> :</span></p></td>
332 <td> the prefix string, typically used by the user, which is compared
333 with each of the items
337 <td><p><span class="term"><em class="parameter"><code>new_prefix</code></em> :</span></p></td>
338 <td> if non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, returns the longest prefix which is common to all
339 items that matched <em class="parameter"><code>prefix</code></em>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if no items matched <em class="parameter"><code>prefix</code></em>.
340 This string should be freed when no longer needed.
344 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
345 <td> the list of items whose strings begin with <em class="parameter"><code>prefix</code></em>. This should
352 <p class="since">Since 2.4</p>
355 <div class="refsect2" title="g_completion_set_compare ()">
356 <a name="g-completion-set-compare"></a><h3>g_completion_set_compare ()</h3>
357 <pre class="programlisting"><span class="returnvalue">void</span> g_completion_set_compare (<a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="returnvalue">GCompletion</span></a> *cmp,
358 <a class="link" href="glib-Automatic-String-Completion.html#GCompletionStrncmpFunc" title="GCompletionStrncmpFunc ()"><span class="returnvalue">GCompletionStrncmpFunc</span></a> strncmp_func);</pre>
360 Sets the function to use for string comparisons. The default string
361 comparison function is <code class="function">strncmp()</code>.</p>
362 <div class="variablelist"><table border="0">
363 <col align="left" valign="top">
366 <td><p><span class="term"><em class="parameter"><code>cmp</code></em> :</span></p></td>
367 <td> a <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a>.
371 <td><p><span class="term"><em class="parameter"><code>strncmp_func</code></em> :</span></p></td>
372 <td> the string comparison function.
379 <div class="refsect2" title="GCompletionStrncmpFunc ()">
380 <a name="GCompletionStrncmpFunc"></a><h3>GCompletionStrncmpFunc ()</h3>
381 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a> (*GCompletionStrncmpFunc) (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *s1,
382 const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *s2,
383 <a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="returnvalue">gsize</span></a> n);</pre>
385 Specifies the type of the function passed to
386 <a class="link" href="glib-Automatic-String-Completion.html#g-completion-set-compare" title="g_completion_set_compare ()"><code class="function">g_completion_set_compare()</code></a>. This is used when you use strings as
387 <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a> items.</p>
388 <div class="variablelist"><table border="0">
389 <col align="left" valign="top">
392 <td><p><span class="term"><em class="parameter"><code>s1</code></em> :</span></p></td>
393 <td> string to compare with <em class="parameter"><code>s2</code></em>.
397 <td><p><span class="term"><em class="parameter"><code>s2</code></em> :</span></p></td>
398 <td> string to compare with <em class="parameter"><code>s1</code></em>.
402 <td><p><span class="term"><em class="parameter"><code>n</code></em> :</span></p></td>
403 <td> maximal number of bytes to compare.
407 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
408 <td> an integer less than, equal to, or greater than zero if
409 the first <em class="parameter"><code>n</code></em> bytes of <em class="parameter"><code>s1</code></em> is found, respectively, to be
410 less than, to match, or to be greater than the first <em class="parameter"><code>n</code></em>
411 bytes of <em class="parameter"><code>s2</code></em>.
418 <div class="refsect2" title="g_completion_free ()">
419 <a name="g-completion-free"></a><h3>g_completion_free ()</h3>
420 <pre class="programlisting"><span class="returnvalue">void</span> g_completion_free (<a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="returnvalue">GCompletion</span></a> *cmp);</pre>
422 Frees all memory used by the <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a>.</p>
423 <div class="variablelist"><table border="0">
424 <col align="left" valign="top">
426 <td><p><span class="term"><em class="parameter"><code>cmp</code></em> :</span></p></td>
427 <td> the <a class="link" href="glib-Automatic-String-Completion.html#GCompletion" title="GCompletion"><span class="type">GCompletion</span></a>.
436 Generated by GTK-Doc V1.13</div>