48 static void gnc_quickfill_cell_set_original (
QuickFillCell *cell,
49 const char *original);
53 gnc_quickfill_cell_set_value_internal (BasicCell *_cell,
62 gnc_quickfill_cell_enter (BasicCell *_cell,
69 *cursor_position = -1;
73 gnc_quickfill_cell_set_original (cell, NULL);
79 utf8_caseequal (
const char *s1,
const char *s2)
83 gboolean equal = FALSE;
91 s1new = g_utf8_casefold(s1, -1);
92 s2new = g_utf8_casefold(s2, -1);
94 if (g_utf8_collate(s1new, s2new) == 0)
104 utf8_caseequal_len (
const char *s1,
const char *s2, guint len)
108 const gchar *s1_offset;
109 const gchar *s2_offset;
114 gboolean equal = FALSE;
126 s1_offset = g_utf8_offset_to_pointer (s1, len);
127 s2_offset = g_utf8_offset_to_pointer (s2, len);
128 s1_bytes_len = s1_offset - s1;
129 s2_bytes_len = s2_offset - s2;
133 s1chars = g_utf8_strlen (s1, s1_bytes_len);
134 s2chars = g_utf8_strlen (s2, s2_bytes_len);
135 if ( (s1chars < len) || (s2chars < len) )
139 s1new = g_utf8_casefold (s1, s1_bytes_len);
140 s2new = g_utf8_casefold (s2, s2_bytes_len);
147 if (g_utf8_collate(s1new, s2new) == 0)
157 gnc_quickfill_cell_modify_verify (BasicCell *_cell,
162 int *cursor_position,
163 int *start_selection,
167 const char *match_str;
171 newval_chars = g_utf8_strlen(newval, newval_len);
179 if ((*cursor_position >= newval_chars) &&
181 (g_utf8_strlen (cell->
original, -1) >= newval_chars) &&
182 utf8_caseequal_len (cell->
original, newval, newval_chars))
184 gchar *temp = g_strndup (cell->
original, newval_len);
185 gnc_quickfill_cell_set_original (cell, temp);
189 gnc_quickfill_cell_set_original (cell, NULL);
191 gnc_basic_cell_set_value_internal (&cell->cell, newval);
193 *end_selection = *start_selection = *cursor_position;
198 if (*cursor_position < newval_chars)
200 gnc_basic_cell_set_value_internal (&cell->cell, newval);
201 gnc_quickfill_cell_set_original (cell, NULL);
207 else if (utf8_caseequal (cell->
original, _cell->value))
211 original = g_string_new (cell->
original);
212 g_string_append (original, change);
215 cell->
original = g_strdup (original->str);
216 g_string_free (original, TRUE);
228 if (match_str == NULL)
233 gnc_basic_cell_set_value_internal (&cell->cell, newval);
237 *start_selection = newval_chars;
240 gnc_basic_cell_set_value_internal (&cell->cell, match_str);
246 gnc_quickfill_cell_leave (BasicCell * _cell)
254 gnc_quickfill_cell_destroy (BasicCell *bcell)
260 gnc_quickfill_destroy (cell->qf);
267 cell->cell.enter_cell = NULL;
268 cell->cell.modify_verify = NULL;
269 cell->cell.leave_cell = NULL;
270 cell->cell.set_value = NULL;
276 gnc_basic_cell_init (&(cell->cell));
278 cell->qf = gnc_quickfill_new ();
280 cell->
sort = QUICKFILL_LIFO;
283 cell->cell.destroy = gnc_quickfill_cell_destroy;
285 cell->cell.enter_cell = gnc_quickfill_cell_enter;
286 cell->cell.modify_verify = gnc_quickfill_cell_modify_verify;
287 cell->cell.leave_cell = gnc_quickfill_cell_leave;
288 cell->cell.set_value = gnc_quickfill_cell_set_value_internal;
292 gnc_quickfill_cell_new (
void)
298 gnc_quickfill_cell_init (cell);
309 gnc_basic_cell_set_value_internal (&cell->cell, value);
314 gnc_quickfill_cell_set_sort (
QuickFillCell *cell, QuickFillSort sort)
323 gnc_quickfill_cell_set_original (
QuickFillCell *cell,
const char *original)
330 if ((original != NULL) && (*original != 0))
337 gnc_quickfill_cell_add_completion (
QuickFillCell *cell,
const char *completion)
354 gnc_quickfill_destroy (cell->qf);
356 cell->qf = shared_qf;
void gnc_quickfill_insert(QuickFill *qf, const char *text, QuickFillSort sort)
Add the string "text" to the collection of searchable strings.
utility functions for the GnuCash UI
The QuickFillCell implements a text cell with quick-fill capabilities.
gboolean use_quickfill_cache
original string entered in original case
void gnc_quickfill_cell_set_value(QuickFillCell *cell, const char *value)
sets the current cell value to the indicated string, simultaneously adding the string to the quick-fi...
QuickFillSort sort
quickfill-tree handled by this cell
void gnc_quickfill_cell_use_quickfill_cache(QuickFillCell *cell, QuickFill *shared_qf)
Lets the cell use the given shared quickfill object instead of the one it owns internally.
QuickFill * gnc_quickfill_get_string_match(QuickFill *qf, const char *str)
Return a subnode in the tree whose strings all match the string 'str' as the next substring...
char * original
determines order of strings matched.
const char * gnc_quickfill_string(QuickFill *qf)
For the given node 'qf', return the best-guess matching string.