Skip to content

Commit

Permalink
Add a function to combocell to set the search behaviour
Browse files Browse the repository at this point in the history
When searching for entered text, the combocell search starts from the
front till the entered text is not found and then changes to find the
entered text any where.

This function sets the combocell to use only the second option, type
ahead search.
  • Loading branch information
Bob-IT committed Oct 10, 2022
1 parent 46c2e44 commit 91486a7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions gnucash/register/ledger-core/split-register-load.c
Expand Up @@ -862,6 +862,8 @@ gnc_split_register_load_desc_cells (SplitRegister* reg)
cell = (ComboCell*)
gnc_table_layout_get_cell (reg->table->layout, DESC_CELL);

gnc_combo_cell_use_type_ahead_only (cell);

gnc_combo_cell_use_list_store_cache (cell, store);
}
/* ====================== END OF FILE ================================== */
4 changes: 4 additions & 0 deletions gnucash/register/register-core/combocell.h
Expand Up @@ -108,5 +108,9 @@ void gnc_combo_cell_use_quickfill_cache (ComboCell* cell,
QuickFill* shared_qf);
void gnc_combo_cell_use_list_store_cache (ComboCell* cell, gpointer data);

/** Set the combocell to use only type ahead search. This will make the
* search to be more like a modified entry completion. */
void gnc_combo_cell_use_type_ahead_only (ComboCell* cell);

/** @} */
#endif
19 changes: 18 additions & 1 deletion gnucash/register/register-gnome/combocell-gnome.c
Expand Up @@ -75,6 +75,8 @@ typedef struct _PopBox
GList* ignore_strings;

GHashTable *item_hash;

gboolean use_type_ahead_only;
} PopBox;


Expand Down Expand Up @@ -167,6 +169,8 @@ gnc_combo_cell_init (ComboCell* cell)
box->ignore_strings = NULL;

box->item_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);

box->use_type_ahead_only = FALSE;
}

static void
Expand Down Expand Up @@ -694,7 +698,7 @@ gnc_combo_cell_modify_verify (BasicCell* _cell,
/* If item_list is using temp then we're already partly matched by
* type-ahead and a quickfill_match won't work.
*/
if (!gnc_item_list_using_temp (box->item_list))
if (!gnc_item_list_using_temp (box->item_list) && !box->use_type_ahead_only)
{
// If we were deleting or inserting in the middle, just accept.
if (change == NULL || *cursor_position < _cell->value_chars)
Expand Down Expand Up @@ -926,6 +930,19 @@ gnc_combo_cell_direct_update (BasicCell* bcell,
return TRUE;
}

void
gnc_combo_cell_use_type_ahead_only (ComboCell* cell)
{
PopBox* box;

if (cell == NULL) return;

box = cell->cell.gui_private;

box->use_type_ahead_only = TRUE;

}

static void
gnc_combo_cell_gui_realize (BasicCell* bcell, gpointer data)
{
Expand Down

0 comments on commit 91486a7

Please sign in to comment.