gnucash master: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Sun Mar 29 17:50:50 EDT 2020
Updated via https://github.com/Gnucash/gnucash/commit/f74d7c52 (commit)
via https://github.com/Gnucash/gnucash/commit/b73bb0e7 (commit)
via https://github.com/Gnucash/gnucash/commit/a934c41e (commit)
via https://github.com/Gnucash/gnucash/commit/bc8428c8 (commit)
via https://github.com/Gnucash/gnucash/commit/eea20a8d (commit)
via https://github.com/Gnucash/gnucash/commit/4cd059c8 (commit)
from https://github.com/Gnucash/gnucash/commit/f85be03b (commit)
commit f74d7c52da378b126a1a0faffaddfb802b44dd8c
Merge: f85be03bb b73bb0e7c
Author: John Ralls <jralls at ceridwen.us>
Date: Sun Mar 29 14:49:00 2020 -0700
Merge Jean Laroche's 'fix_autocompletion_master' into master.
commit b73bb0e7ce9435cb8ec3518e7d5fbc4e00ecef85
Author: jean <you at example.com>
Date: Sat Mar 28 13:37:00 2020 -0700
run astyle on modified files
diff --git a/gnucash/gnome-utils/account-quickfill.c b/gnucash/gnome-utils/account-quickfill.c
index f7e18dbba..7fb639bb4 100644
--- a/gnucash/gnome-utils/account-quickfill.c
+++ b/gnucash/gnome-utils/account-quickfill.c
@@ -30,8 +30,10 @@
/* This static indicates the debugging module that this .o belongs to. */
static QofLogModule log_module = GNC_MOD_REGISTER;
-static void shared_quickfill_pref_changed (gpointer prefs, gchar *pref, gpointer qfb);
-static void listen_for_account_events (QofInstance *entity, QofEventId event_type,
+static void shared_quickfill_pref_changed (gpointer prefs, gchar* pref,
+ gpointer qfb);
+static void listen_for_account_events (QofInstance* entity,
+ QofEventId event_type,
gpointer user_data, gpointer event_data);
/* Column indices for the list store */
@@ -51,23 +53,23 @@ static void listen_for_account_events (QofInstance *entity, QofEventId event_typ
typedef struct
{
- QuickFill *qf;
+ QuickFill* qf;
gboolean load_list_store;
- GtkListStore *list_store;
+ GtkListStore* list_store;
/* For the type-ahead search, we need two lists, list_store contains the accounts that
match the search. list_store_full contain the original full list of accounts. */
- GtkListStore *list_store_full;
- QofBook *book;
- Account *root;
+ GtkListStore* list_store_full;
+ QofBook* book;
+ Account* root;
gint listener;
AccountBoolCB dont_add_cb;
gpointer dont_add_data;
} QFB;
static void
-shared_quickfill_destroy (QofBook *book, gpointer key, gpointer user_data)
+shared_quickfill_destroy (QofBook* book, gpointer key, gpointer user_data)
{
- QFB *qfb = user_data;
+ QFB* qfb = user_data;
gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
GNC_PREF_ACCOUNT_SEPARATOR,
shared_quickfill_pref_changed,
@@ -86,20 +88,20 @@ shared_quickfill_destroy (QofBook *book, gpointer key, gpointer user_data)
typedef struct find_data
{
- GList *accounts;
- GList *refs;
+ GList* accounts;
+ GList* refs;
} find_data;
static gboolean
-shared_quickfill_find_accounts (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
+shared_quickfill_find_accounts (GtkTreeModel* model,
+ GtkTreePath* path,
+ GtkTreeIter* iter,
gpointer user_data)
{
- Account *account = NULL;
- find_data *data = user_data;
+ Account* account = NULL;
+ find_data* data = user_data;
GtkTreeRowReference* ref;
- GList *tmp;
+ GList* tmp;
gtk_tree_model_get (model, iter, ACCOUNT_POINTER, &account, -1);
for (tmp = data->accounts; tmp; tmp = g_list_next (tmp))
@@ -118,10 +120,10 @@ shared_quickfill_find_accounts (GtkTreeModel *model,
/* Splat the account name into the shared quickfill object */
static void
-load_shared_qf_cb (Account *account, gpointer data)
+load_shared_qf_cb (Account* account, gpointer data)
{
- QFB *qfb = data;
- char *name;
+ QFB* qfb = data;
+ char* name;
GtkTreeIter iter;
if (qfb->dont_add_cb)
@@ -153,9 +155,9 @@ load_shared_qf_cb (Account *account, gpointer data)
static void
-shared_quickfill_pref_changed (gpointer prefs, gchar *pref, gpointer user_data)
+shared_quickfill_pref_changed (gpointer prefs, gchar* pref, gpointer user_data)
{
- QFB *qfb = user_data;
+ QFB* qfb = user_data;
/* Reload the quickfill */
gnc_quickfill_purge (qfb->qf);
@@ -170,14 +172,14 @@ shared_quickfill_pref_changed (gpointer prefs, gchar *pref, gpointer user_data)
/* Build the quickfill list out of account names.
* Essentially same loop as in gnc_load_xfer_cell() above.
*/
-static QFB *
-build_shared_quickfill (QofBook *book, Account *root, const char * key,
+static QFB*
+build_shared_quickfill (QofBook* book, Account* root, const char* key,
AccountBoolCB cb, gpointer data)
{
- QFB *qfb;
+ QFB* qfb;
qfb = g_new0 (QFB, 1);
- qfb->qf = gnc_quickfill_new ();
+ qfb->qf = gnc_quickfill_new();
qfb->book = book;
qfb->root = root;
qfb->listener = 0;
@@ -185,9 +187,9 @@ build_shared_quickfill (QofBook *book, Account *root, const char * key,
qfb->dont_add_data = data;
qfb->load_list_store = TRUE;
qfb->list_store = gtk_list_store_new (NUM_ACCOUNT_COLUMNS,
- G_TYPE_STRING, G_TYPE_POINTER);
+ G_TYPE_STRING, G_TYPE_POINTER);
qfb->list_store_full = gtk_list_store_new (NUM_ACCOUNT_COLUMNS,
- G_TYPE_STRING, G_TYPE_POINTER);
+ G_TYPE_STRING, G_TYPE_POINTER);
gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL,
GNC_PREF_ACCOUNT_SEPARATOR,
@@ -209,12 +211,12 @@ build_shared_quickfill (QofBook *book, Account *root, const char * key,
return qfb;
}
-QuickFill *
-gnc_get_shared_account_name_quickfill (Account *root, const char * key,
+QuickFill*
+gnc_get_shared_account_name_quickfill (Account* root, const char* key,
AccountBoolCB cb, gpointer cb_data)
{
- QFB *qfb;
- QofBook *book;
+ QFB* qfb;
+ QofBook* book;
book = gnc_account_get_book (root);
qfb = qof_book_get_data (book, key);
@@ -226,12 +228,12 @@ gnc_get_shared_account_name_quickfill (Account *root, const char * key,
return qfb->qf;
}
-GtkListStore *
-gnc_get_shared_account_name_list_store (Account *root, const char * key,
+GtkListStore*
+gnc_get_shared_account_name_list_store (Account* root, const char* key,
AccountBoolCB cb, gpointer cb_data)
{
- QFB *qfb;
- QofBook *book;
+ QFB* qfb;
+ QofBook* book;
book = gnc_account_get_book (root);
qfb = qof_book_get_data (book, key);
@@ -243,19 +245,19 @@ gnc_get_shared_account_name_list_store (Account *root, const char * key,
return qfb->list_store;
}
-GtkListStore *
-gnc_get_shared_account_name_list_store_full (Account *root, const char * key,
- AccountBoolCB cb, gpointer cb_data)
+GtkListStore*
+gnc_get_shared_account_name_list_store_full (Account* root, const char* key,
+ AccountBoolCB cb, gpointer cb_data)
{
- QFB *qfb;
- QofBook *book;
-
+ QFB* qfb;
+ QofBook* book;
+
book = gnc_account_get_book (root);
qfb = qof_book_get_data (book, key);
-
+
if (qfb)
return qfb->list_store_full;
-
+
qfb = build_shared_quickfill (book, root, key, cb, cb_data);
return qfb->list_store_full;
}
@@ -265,54 +267,54 @@ gnc_get_shared_account_name_list_store_full (Account *root, const char * key,
* for account modification events, and add new accounts.
*/
static void
-listen_for_account_events (QofInstance *entity, QofEventId event_type,
+listen_for_account_events (QofInstance* entity, QofEventId event_type,
gpointer user_data, gpointer event_data)
{
- QFB *qfb = user_data;
- QuickFill *qf = qfb->qf;
- QuickFill *match;
- char * name;
- const char *match_str;
- Account *account;
+ QFB* qfb = user_data;
+ QuickFill* qf = qfb->qf;
+ QuickFill* match;
+ char* name;
+ const char* match_str;
+ Account* account;
GtkTreeIter iter;
find_data data = { 0 };
- GtkTreePath *path;
- GList *tmp;
+ GtkTreePath* path;
+ GList* tmp;
gboolean valid;
if (0 == (event_type & (QOF_EVENT_MODIFY | QOF_EVENT_ADD | QOF_EVENT_REMOVE)))
return;
- if (!GNC_IS_ACCOUNT(entity))
+ if (!GNC_IS_ACCOUNT (entity))
return;
- account = GNC_ACCOUNT(entity);
+ account = GNC_ACCOUNT (entity);
- ENTER("entity %p, event type %x, user data %p, ecent data %p",
- entity, event_type, user_data, event_data);
+ ENTER ("entity %p, event type %x, user data %p, ecent data %p",
+ entity, event_type, user_data, event_data);
- if (gnc_account_get_root(account) != qfb->root)
+ if (gnc_account_get_root (account) != qfb->root)
{
- LEAVE("root account mismatch");
+ LEAVE ("root account mismatch");
return;
}
name = gnc_get_account_name_for_register (account);
if (NULL == name)
{
- LEAVE("account has no name");
+ LEAVE ("account has no name");
return;
}
switch (event_type)
{
case QOF_EVENT_MODIFY:
- DEBUG("modify %s", name);
+ DEBUG ("modify %s", name);
/* Find the account (and all its descendants) in the model. The
* full name of all these accounts has changed. */
data.accounts = gnc_account_get_descendants (account);
data.accounts = g_list_prepend (data.accounts, account);
- gtk_tree_model_foreach (GTK_TREE_MODEL(qfb->list_store_full),
+ gtk_tree_model_foreach (GTK_TREE_MODEL (qfb->list_store_full),
shared_quickfill_find_accounts, &data);
/* Update the existing items in the list store. Its possible
@@ -321,17 +323,17 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
* store. Otherwise its a simple update of the name string. */
for (tmp = data.refs; tmp; tmp = g_list_next (tmp))
{
- gchar *old_name, *new_name;
+ gchar* old_name, *new_name;
path = gtk_tree_row_reference_get_path (tmp->data);
gtk_tree_row_reference_free (tmp->data);
- if (!gtk_tree_model_get_iter (GTK_TREE_MODEL(qfb->list_store_full),
+ if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (qfb->list_store_full),
&iter, path))
{
gtk_tree_path_free (path);
continue;
}
gtk_tree_path_free (path);
- gtk_tree_model_get (GTK_TREE_MODEL(qfb->list_store_full), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (qfb->list_store_full), &iter,
ACCOUNT_POINTER, &account,
ACCOUNT_NAME, &old_name,
-1);
@@ -344,7 +346,7 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
gnc_quickfill_remove (qf, old_name, QUICKFILL_ALPHA);
if (qfb->dont_add_cb &&
- qfb->dont_add_cb (account, qfb->dont_add_data))
+ qfb->dont_add_cb (account, qfb->dont_add_data))
{
gnc_quickfill_remove (qf, new_name, QUICKFILL_ALPHA);
gtk_list_store_remove (qfb->list_store_full, &iter);
@@ -383,14 +385,14 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
break;
case QOF_EVENT_REMOVE:
- DEBUG("remove %s", name);
+ DEBUG ("remove %s", name);
/* Remove from qf */
gnc_quickfill_remove (qfb->qf, name, QUICKFILL_ALPHA);
/* Does the account exist in the model? */
data.accounts = g_list_append (NULL, account);
- gtk_tree_model_foreach (GTK_TREE_MODEL(qfb->list_store_full),
+ gtk_tree_model_foreach (GTK_TREE_MODEL (qfb->list_store_full),
shared_quickfill_find_accounts, &data);
/* Remove from list store */
@@ -398,7 +400,7 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
{
path = gtk_tree_row_reference_get_path (tmp->data);
gtk_tree_row_reference_free (tmp->data);
- if (gtk_tree_model_get_iter (GTK_TREE_MODEL(qfb->list_store_full),
+ if (gtk_tree_model_get_iter (GTK_TREE_MODEL (qfb->list_store_full),
&iter, path))
{
gtk_list_store_remove (qfb->list_store_full, &iter);
@@ -408,10 +410,10 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
break;
case QOF_EVENT_ADD:
- DEBUG("add %s", name);
+ DEBUG ("add %s", name);
if (qfb->dont_add_cb &&
- qfb->dont_add_cb (account, qfb->dont_add_data))
+ qfb->dont_add_cb (account, qfb->dont_add_data))
break;
match = gnc_quickfill_get_string_match (qf, name);
@@ -435,24 +437,27 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
break;
default:
- DEBUG("other %s", name);
+ DEBUG ("other %s", name);
break;
}
/* Now that qfb->list_store_full has been updated, qfb->list_store also needs to be updated in
case we're using the regular search. */
- gtk_list_store_clear(qfb->list_store);
-
- g_debug("Replicate shared_store_full\n");
- valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(qfb->list_store_full), &iter);
+ gtk_list_store_clear (qfb->list_store);
+
+ g_debug ("Replicate shared_store_full\n");
+ valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (qfb->list_store_full),
+ &iter);
while (valid)
{
- gchar *str_data = NULL;
+ gchar* str_data = NULL;
GtkTreeIter iter2;
- gtk_tree_model_get (GTK_TREE_MODEL(qfb->list_store_full), &iter,0, &str_data,-1);
- gtk_list_store_append(qfb->list_store, &iter2);
- gtk_list_store_set(qfb->list_store, &iter2, 0, str_data, -1);
- valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(qfb->list_store_full), &iter);
- g_free(str_data);
+ gtk_tree_model_get (GTK_TREE_MODEL (qfb->list_store_full), &iter, 0, &str_data,
+ -1);
+ gtk_list_store_append (qfb->list_store, &iter2);
+ gtk_list_store_set (qfb->list_store, &iter2, 0, str_data, -1);
+ valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (qfb->list_store_full),
+ &iter);
+ g_free (str_data);
}
if (data.accounts)
@@ -460,7 +465,7 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
if (data.refs)
g_list_free (data.refs);
g_free (name);
- LEAVE(" ");
+ LEAVE (" ");
}
/* ====================== END OF FILE ================================== */
diff --git a/gnucash/gnome-utils/account-quickfill.h b/gnucash/gnome-utils/account-quickfill.h
index ab6c92d3f..3c8c8250c 100644
--- a/gnucash/gnome-utils/account-quickfill.h
+++ b/gnucash/gnome-utils/account-quickfill.h
@@ -45,7 +45,7 @@
#include "Account.h"
#include "QuickFill.h"
-typedef gboolean (*AccountBoolCB) (Account *, gpointer);
+typedef gboolean (*AccountBoolCB) (Account*, gpointer);
/** Create/fetch a quickfill of account names.
*
@@ -68,15 +68,15 @@ typedef gboolean (*AccountBoolCB) (Account *, gpointer);
* it). This code does not currently listen to account-destroy
* events.
*/
-QuickFill *
-gnc_get_shared_account_name_quickfill (Account *root, const char * key,
+QuickFill*
+gnc_get_shared_account_name_quickfill (Account* root, const char* key,
AccountBoolCB skip_cb, gpointer cb_data);
-GtkListStore *
-gnc_get_shared_account_name_list_store (Account *root, const char * key,
- AccountBoolCB cb, gpointer cb_data);
-GtkListStore *
-gnc_get_shared_account_name_list_store_full (Account *root, const char * key,
+GtkListStore*
+gnc_get_shared_account_name_list_store (Account* root, const char* key,
AccountBoolCB cb, gpointer cb_data);
+GtkListStore*
+gnc_get_shared_account_name_list_store_full (Account* root, const char* key,
+ AccountBoolCB cb, gpointer cb_data);
#endif
diff --git a/gnucash/register/ledger-core/gncEntryLedgerLoad.c b/gnucash/register/ledger-core/gncEntryLedgerLoad.c
index 2372008a1..f62bfaacf 100644
--- a/gnucash/register/ledger-core/gncEntryLedgerLoad.c
+++ b/gnucash/register/ledger-core/gncEntryLedgerLoad.c
@@ -45,43 +45,43 @@
static const QofLogModule log_module = "Business Entry Ledger";
/* XXX: This should go elsewhere */
-const char * gnc_entry_ledger_type_string_getter (char flag)
+const char* gnc_entry_ledger_type_string_getter (char flag)
{
switch (flag)
{
case '1':
- return _("$");
+ return _ ("$");
case '2':
- return _("%");
+ return _ ("%");
default:
break;
};
return "?";
}
-const char * gnc_entry_ledger_how_string_getter (char flag)
+const char* gnc_entry_ledger_how_string_getter (char flag)
{
switch (flag)
{
case '1':
- return _("<");
+ return _ ("<");
case '2':
- return _("=");
+ return _ ("=");
case '3':
- return _(">");
+ return _ (">");
default:
break;
};
- return "?";
+ return "?";
}
-static void load_discount_type_cells (GncEntryLedger *ledger)
+static void load_discount_type_cells (GncEntryLedger* ledger)
{
- RecnCell *cell;
+ RecnCell* cell;
if (!ledger) return;
- cell = (RecnCell *)
+ cell = (RecnCell*)
gnc_table_layout_get_cell (ledger->table->layout, ENTRY_DISTYPE_CELL);
if (!cell) return;
@@ -91,13 +91,13 @@ static void load_discount_type_cells (GncEntryLedger *ledger)
gnc_recn_cell_set_string_getter (cell, gnc_entry_ledger_type_string_getter);
}
-static void load_discount_how_cells (GncEntryLedger *ledger)
+static void load_discount_how_cells (GncEntryLedger* ledger)
{
- RecnCell *cell;
+ RecnCell* cell;
if (!ledger) return;
- cell = (RecnCell *)
+ cell = (RecnCell*)
gnc_table_layout_get_cell (ledger->table->layout, ENTRY_DISHOW_CELL);
if (!cell) return;
@@ -107,14 +107,14 @@ static void load_discount_how_cells (GncEntryLedger *ledger)
gnc_recn_cell_set_string_getter (cell, gnc_entry_ledger_how_string_getter);
}
-static void load_payment_type_cells (GncEntryLedger *ledger)
+static void load_payment_type_cells (GncEntryLedger* ledger)
{
- ComboCell *cell;
- const GncOwner *owner;
- GncEmployee *employee;
+ ComboCell* cell;
+ const GncOwner* owner;
+ GncEmployee* employee;
- cell = (ComboCell *) gnc_table_layout_get_cell (ledger->table->layout,
- ENTRY_PAYMENT_CELL);
+ cell = (ComboCell*) gnc_table_layout_get_cell (ledger->table->layout,
+ ENTRY_PAYMENT_CELL);
if (!cell) return;
if (!ledger->invoice) return;
@@ -127,25 +127,25 @@ static void load_payment_type_cells (GncEntryLedger *ledger)
g_return_if_fail (employee);
gnc_combo_cell_clear_menu (cell);
- gnc_combo_cell_add_menu_item (cell, _("Cash"));
+ gnc_combo_cell_add_menu_item (cell, _ ("Cash"));
if (gncEmployeeGetCCard (employee))
- gnc_combo_cell_add_menu_item (cell, _("Charge"));
+ gnc_combo_cell_add_menu_item (cell, _ ("Charge"));
}
/* ==================================================================== */
/* Return TRUE if we don't want to add this account to the xfer menu */
static gboolean
-skip_expense_acct_cb (Account *account, gpointer user_data)
+skip_expense_acct_cb (Account* account, gpointer user_data)
{
GNCAccountType type;
/* Don't add A/R, A/P, Bank, Cash, or Equity accounts */
type = xaccAccountGetType (account);
if (type == ACCT_TYPE_PAYABLE || type == ACCT_TYPE_RECEIVABLE ||
- type == ACCT_TYPE_CASH || type == ACCT_TYPE_BANK ||
- type == ACCT_TYPE_EQUITY || type == ACCT_TYPE_TRADING)
+ type == ACCT_TYPE_CASH || type == ACCT_TYPE_BANK ||
+ type == ACCT_TYPE_EQUITY || type == ACCT_TYPE_TRADING)
{
return TRUE;
}
@@ -160,15 +160,15 @@ skip_expense_acct_cb (Account *account, gpointer user_data)
}
static gboolean
-skip_income_acct_cb (Account *account, gpointer user_data)
+skip_income_acct_cb (Account* account, gpointer user_data)
{
GNCAccountType type;
/* Don't add A/R, A/P, Bank, Cash, or Equity accounts */
type = xaccAccountGetType (account);
if (type == ACCT_TYPE_PAYABLE || type == ACCT_TYPE_RECEIVABLE ||
- type == ACCT_TYPE_CASH || type == ACCT_TYPE_BANK ||
- type == ACCT_TYPE_EQUITY || type == ACCT_TYPE_TRADING)
+ type == ACCT_TYPE_CASH || type == ACCT_TYPE_BANK ||
+ type == ACCT_TYPE_EQUITY || type == ACCT_TYPE_TRADING)
{
return TRUE;
}
@@ -189,13 +189,13 @@ skip_income_acct_cb (Account *account, gpointer user_data)
#define IKEY "Income Business entry quickfill"
static void
-load_xfer_type_cells (GncEntryLedger *ledger)
+load_xfer_type_cells (GncEntryLedger* ledger)
{
- Account *root;
- ComboCell *cell;
- QuickFill *qf = NULL;
- GtkListStore *store = NULL;
- GtkListStore *store_full = NULL;
+ Account* root;
+ ComboCell* cell;
+ QuickFill* qf = NULL;
+ GtkListStore* store = NULL;
+ GtkListStore* store_full = NULL;
root = gnc_book_get_root_account (ledger->book);
if (root == NULL) return;
@@ -213,11 +213,11 @@ load_xfer_type_cells (GncEntryLedger *ledger)
case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
case GNCENTRY_CUST_CREDIT_NOTE_VIEWER:
qf = gnc_get_shared_account_name_quickfill (root, IKEY,
- skip_expense_acct_cb, NULL);
+ skip_expense_acct_cb, NULL);
store = gnc_get_shared_account_name_list_store (root, IKEY,
- skip_expense_acct_cb, NULL);
+ skip_expense_acct_cb, NULL);
store_full = gnc_get_shared_account_name_list_store_full (root, IKEY,
- skip_expense_acct_cb, NULL);
+ skip_expense_acct_cb, NULL);
break;
case GNCENTRY_BILL_ENTRY:
@@ -230,23 +230,23 @@ load_xfer_type_cells (GncEntryLedger *ledger)
case GNCENTRY_EMPL_CREDIT_NOTE_VIEWER:
case GNCENTRY_NUM_REGISTER_TYPES:
qf = gnc_get_shared_account_name_quickfill (root, EKEY,
- skip_income_acct_cb, NULL);
+ skip_income_acct_cb, NULL);
store = gnc_get_shared_account_name_list_store (root, EKEY,
- skip_income_acct_cb, NULL);
+ skip_income_acct_cb, NULL);
store_full = gnc_get_shared_account_name_list_store_full (root, EKEY,
- skip_income_acct_cb, NULL);
+ skip_income_acct_cb, NULL);
break;
default:
- PWARN ("Bad GncEntryLedgerType");
- break;
+ PWARN ("Bad GncEntryLedgerType");
+ break;
}
- cell = (ComboCell *)
+ cell = (ComboCell*)
gnc_table_layout_get_cell (ledger->table->layout, ENTRY_IACCT_CELL);
gnc_combo_cell_use_quickfill_cache (cell, qf);
gnc_combo_cell_use_list_store_cache (cell, store, store_full);
- cell = (ComboCell *)
+ cell = (ComboCell*)
gnc_table_layout_get_cell (ledger->table->layout, ENTRY_BACCT_CELL);
gnc_combo_cell_use_quickfill_cache (cell, qf);
gnc_combo_cell_use_list_store_cache (cell, store, store_full);
@@ -254,27 +254,27 @@ load_xfer_type_cells (GncEntryLedger *ledger)
/* ===================================================================== */
-static void load_taxtable_type_cells (GncEntryLedger *ledger)
+static void load_taxtable_type_cells (GncEntryLedger* ledger)
{
- GList *list;
- ComboCell *cell;
+ GList* list;
+ ComboCell* cell;
- cell = (ComboCell *)
+ cell = (ComboCell*)
gnc_table_layout_get_cell (ledger->table->layout, ENTRY_TAXTABLE_CELL);
gnc_combo_cell_clear_menu (cell);
list = gncTaxTableGetTables (ledger->book);
- for ( ; list ; list = list->next )
+ for (; list ; list = list->next)
{
- GncTaxTable *table = list->data;
- const char *name = gncTaxTableGetName (table);
+ GncTaxTable* table = list->data;
+ const char* name = gncTaxTableGetName (table);
if (name != NULL)
gnc_combo_cell_add_menu_item (cell, (char*)name);
}
}
static void
-gnc_entry_ledger_show_entry (GncEntryLedger *ledger,
+gnc_entry_ledger_show_entry (GncEntryLedger* ledger,
VirtualCellLocation start_loc)
{
VirtualCellLocation end_loc;
@@ -291,10 +291,10 @@ gnc_entry_ledger_show_entry (GncEntryLedger *ledger,
#define DESC_QF_KEY_BILLS "ENTRY_DESC_CELL_QF_BILLS"
static void
-load_description_cell (GncEntryLedger *ledger)
+load_description_cell (GncEntryLedger* ledger)
{
- QuickFill *shared_quickfill;
- QuickFillCell *cell;
+ QuickFill* shared_quickfill;
+ QuickFillCell* cell;
switch (ledger->type)
{
@@ -302,19 +302,21 @@ load_description_cell (GncEntryLedger *ledger)
case GNCENTRY_INVOICE_VIEWER:
case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
case GNCENTRY_CUST_CREDIT_NOTE_VIEWER:
- shared_quickfill = gnc_get_shared_entry_desc_quickfill(ledger->book, DESC_QF_KEY_INVOICES, TRUE);
+ shared_quickfill = gnc_get_shared_entry_desc_quickfill (ledger->book,
+ DESC_QF_KEY_INVOICES, TRUE);
break;
default:
- shared_quickfill = gnc_get_shared_entry_desc_quickfill(ledger->book, DESC_QF_KEY_BILLS, FALSE);
+ shared_quickfill = gnc_get_shared_entry_desc_quickfill (ledger->book,
+ DESC_QF_KEY_BILLS, FALSE);
break;
};
- cell = (QuickFillCell *)
+ cell = (QuickFillCell*)
gnc_table_layout_get_cell (ledger->table->layout, ENTRY_DESC_CELL);
gnc_quickfill_cell_use_quickfill_cache (cell, shared_quickfill);
}
-void gnc_entry_ledger_load_xfer_cells (GncEntryLedger *ledger)
+void gnc_entry_ledger_load_xfer_cells (GncEntryLedger* ledger)
{
load_xfer_type_cells (ledger);
load_taxtable_type_cells (ledger);
@@ -328,14 +330,14 @@ void gnc_entry_ledger_load_xfer_cells (GncEntryLedger *ledger)
* the split-register should be generalized to the point where a cut-n-paste
* like this isn't required, and this should be trashed.
*/
-void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
+void gnc_entry_ledger_load (GncEntryLedger* ledger, GList* entry_list)
{
- GncEntry *blank_entry, *find_entry;
- CursorBuffer *cursor_buffer;
- Table *table;
+ GncEntry* blank_entry, *find_entry;
+ CursorBuffer* cursor_buffer;
+ Table* table;
- GList *node;
- CellBlock *cursor_header, *cursor;
+ GList* node;
+ CellBlock* cursor_header, *cursor;
VirtualCellLocation vcell_loc;
VirtualLocation save_loc;
gboolean start_primary_color = TRUE;
@@ -366,29 +368,30 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
case GNCENTRY_VEND_CREDIT_NOTE_ENTRY:
case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY:
- gnc_suspend_gui_refresh ();
+ gnc_suspend_gui_refresh();
blank_entry = gncEntryCreate (ledger->book);
gncEntrySetDateGDate (blank_entry, &ledger->last_date_entered);
ledger->blank_entry_guid = *gncEntryGetGUID (blank_entry);
- gnc_resume_gui_refresh ();
+ gnc_resume_gui_refresh();
/* The rest of this does not apply to expense vouchers */
if (ledger->type != GNCENTRY_EXPVOUCHER_ENTRY)
{
- const GncOwner *owner = gncOwnerGetEndOwner (gncInvoiceGetOwner (ledger->invoice));
- GncTaxTable *table = NULL;
+ const GncOwner* owner = gncOwnerGetEndOwner (gncInvoiceGetOwner (
+ ledger->invoice));
+ GncTaxTable* table = NULL;
GncTaxIncluded taxincluded_p = GNC_TAXINCLUDED_USEGLOBAL;
gboolean taxincluded = FALSE;
- gnc_numeric discount = gnc_numeric_zero ();
- gnc_numeric price = gnc_numeric_zero ();
+ gnc_numeric discount = gnc_numeric_zero();
+ gnc_numeric price = gnc_numeric_zero();
/* Determine the Price from Customer's or Vendor's Job */
switch (gncOwnerGetType (gncInvoiceGetOwner (ledger->invoice)))
{
case GNC_OWNER_JOB:
- price = gncJobGetRate( gncOwnerGetJob (gncInvoiceGetOwner (ledger->invoice)));
+ price = gncJobGetRate (gncOwnerGetJob (gncInvoiceGetOwner (ledger->invoice)));
break;
default:
break;
@@ -471,7 +474,7 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
break;
default:
- ledger->blank_entry_guid = *guid_null ();
+ ledger->blank_entry_guid = *guid_null();
break;
}
ledger->blank_entry_edited = FALSE;
@@ -493,16 +496,16 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
}
else
{
- find_entry = gnc_entry_ledger_get_current_entry(ledger);
+ find_entry = gnc_entry_ledger_get_current_entry (ledger);
/* XXX: get current entry (cursor_hint_xxx) */
}
/* If the current cursor has changed we save the values for later
* possible restoration. */
if (gnc_table_current_cursor_changed (table, TRUE) &&
- (find_entry == gnc_entry_ledger_get_current_entry (ledger)))
+ (find_entry == gnc_entry_ledger_get_current_entry (ledger)))
{
- cursor_buffer = gnc_cursor_buffer_new ();
+ cursor_buffer = gnc_cursor_buffer_new();
gnc_table_save_current_cursor (table, cursor_buffer);
}
else
@@ -540,7 +543,7 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
/* Populate the table */
for (node = entry_list; node; node = node->next)
{
- GncEntry *entry = node->data;
+ GncEntry* entry = node->data;
/* Don't load the blank entry */
if (entry == blank_entry)
@@ -604,14 +607,14 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
/* Set completion character */
gnc_combo_cell_set_complete_char
- ((ComboCell *)
+ ((ComboCell*)
gnc_table_layout_get_cell (table->layout, ENTRY_IACCT_CELL),
- gnc_get_account_separator ());
+ gnc_get_account_separator());
gnc_combo_cell_set_complete_char
- ((ComboCell *)
+ ((ComboCell*)
gnc_table_layout_get_cell (table->layout, ENTRY_BACCT_CELL),
- gnc_get_account_separator ());
+ gnc_get_account_separator());
/* enable callback for cursor user-driven moves */
gnc_table_control_allow_move (table->control, TRUE);
diff --git a/gnucash/register/ledger-core/split-register-load.c b/gnucash/register/ledger-core/split-register-load.c
index 5647846e8..d49fc75c5 100644
--- a/gnucash/register/ledger-core/split-register-load.c
+++ b/gnucash/register/ledger-core/split-register-load.c
@@ -46,36 +46,36 @@
static QofLogModule log_module = GNC_MOD_LEDGER;
-static void gnc_split_register_load_xfer_cells (SplitRegister *reg,
- Account *base_account);
+static void gnc_split_register_load_xfer_cells (SplitRegister* reg,
+ Account* base_account);
static void
-gnc_split_register_load_recn_cells (SplitRegister *reg)
+gnc_split_register_load_recn_cells (SplitRegister* reg)
{
- RecnCell *cell;
- const char * s;
+ RecnCell* cell;
+ const char* s;
if (!reg) return;
- cell = (RecnCell *)
+ cell = (RecnCell*)
gnc_table_layout_get_cell (reg->table->layout, RECN_CELL);
if (!cell) return;
- s = gnc_get_reconcile_valid_flags ();
+ s = gnc_get_reconcile_valid_flags();
gnc_recn_cell_set_valid_flags (cell, s, *s);
- gnc_recn_cell_set_flag_order (cell, gnc_get_reconcile_flag_order ());
+ gnc_recn_cell_set_flag_order (cell, gnc_get_reconcile_flag_order());
gnc_recn_cell_set_string_getter (cell, gnc_get_reconcile_str);
}
static void
-gnc_split_register_load_associate_cells (SplitRegister *reg)
+gnc_split_register_load_associate_cells (SplitRegister* reg)
{
- RecnCell *cell;
+ RecnCell* cell;
if (!reg) return;
- cell = (RecnCell *)
+ cell = (RecnCell*)
gnc_table_layout_get_cell (reg->table->layout, ASSOC_CELL);
if (!cell) return;
@@ -87,13 +87,13 @@ gnc_split_register_load_associate_cells (SplitRegister *reg)
}
static void
-gnc_split_register_load_type_cells (SplitRegister *reg)
+gnc_split_register_load_type_cells (SplitRegister* reg)
{
- RecnCell *cell;
+ RecnCell* cell;
if (!reg) return;
- cell = (RecnCell *)
+ cell = (RecnCell*)
gnc_table_layout_get_cell (reg->table->layout, TYPE_CELL);
if (!cell) return;
@@ -166,24 +166,24 @@ gnc_split_register_load_type_cells (SplitRegister *reg)
* will be changed to the row below the last row filled.
*/
static void
-gnc_split_register_add_transaction (SplitRegister *reg,
- Transaction *trans,
- Split *split,
- CellBlock *lead_cursor,
- CellBlock *split_cursor,
+gnc_split_register_add_transaction (SplitRegister* reg,
+ Transaction* trans,
+ Split* split,
+ CellBlock* lead_cursor,
+ CellBlock* split_cursor,
gboolean visible_splits,
gboolean start_primary_color,
gboolean add_empty,
- Transaction *find_trans,
- Split *find_split,
+ Transaction* find_trans,
+ Split* find_split,
CursorClass find_class,
- int *new_split_row,
- VirtualCellLocation *vcell_loc)
+ int* new_split_row,
+ VirtualCellLocation* vcell_loc)
{
- GList *node;
+ GList* node;
- g_return_if_fail(reg);
- g_return_if_fail(vcell_loc);
+ g_return_if_fail (reg);
+ g_return_if_fail (vcell_loc);
if (split == find_split)
*new_split_row = vcell_loc->virt_row;
@@ -197,9 +197,9 @@ gnc_split_register_add_transaction (SplitRegister *reg,
* split in the transaction. */
for (node = xaccTransGetSplitList (trans); node; node = node->next)
{
- Split *secondary = node->data;
+ Split* secondary = node->data;
- if (!xaccTransStillHasSplit(trans, secondary)) continue;
+ if (!xaccTransStillHasSplit (trans, secondary)) continue;
if (secondary == find_split && find_class == CURSOR_CLASS_SPLIT)
*new_split_row = vcell_loc->virt_row;
@@ -213,81 +213,82 @@ gnc_split_register_add_transaction (SplitRegister *reg,
if (add_empty)
{
if (find_trans == trans && find_split == NULL &&
- find_class == CURSOR_CLASS_SPLIT)
+ find_class == CURSOR_CLASS_SPLIT)
*new_split_row = vcell_loc->virt_row;
- gnc_table_set_vcell(reg->table, split_cursor, xaccSplitGetGUID(NULL),
- FALSE, TRUE, *vcell_loc);
+ gnc_table_set_vcell (reg->table, split_cursor, xaccSplitGetGUID (NULL),
+ FALSE, TRUE, *vcell_loc);
vcell_loc->virt_row++;
}
}
static gint
-_find_split_with_parent_txn(gconstpointer a, gconstpointer b)
+_find_split_with_parent_txn (gconstpointer a, gconstpointer b)
{
- Split *split = (Split*)a;
- Transaction *txn = (Transaction*)b;
+ Split* split = (Split*)a;
+ Transaction* txn = (Transaction*)b;
- return xaccSplitGetParent(split) == txn ? 0 : 1;
+ return xaccSplitGetParent (split) == txn ? 0 : 1;
}
-static void add_quickfill_completions(TableLayout *layout, Transaction *trans,
- Split *split, gboolean has_last_num)
+static void add_quickfill_completions (TableLayout* layout, Transaction* trans,
+ Split* split, gboolean has_last_num)
{
- Split *s;
+ Split* s;
int i = 0;
- gnc_quickfill_cell_add_completion(
- (QuickFillCell *) gnc_table_layout_get_cell(layout, DESC_CELL),
- xaccTransGetDescription(trans));
+ gnc_quickfill_cell_add_completion (
+ (QuickFillCell*) gnc_table_layout_get_cell (layout, DESC_CELL),
+ xaccTransGetDescription (trans));
- gnc_quickfill_cell_add_completion(
- (QuickFillCell *) gnc_table_layout_get_cell(layout, NOTES_CELL),
- xaccTransGetNotes(trans));
+ gnc_quickfill_cell_add_completion (
+ (QuickFillCell*) gnc_table_layout_get_cell (layout, NOTES_CELL),
+ xaccTransGetNotes (trans));
if (!has_last_num)
- gnc_num_cell_set_last_num(
- (NumCell *) gnc_table_layout_get_cell(layout, NUM_CELL),
- gnc_get_num_action(trans, split));
+ gnc_num_cell_set_last_num (
+ (NumCell*) gnc_table_layout_get_cell (layout, NUM_CELL),
+ gnc_get_num_action (trans, split));
- while ((s = xaccTransGetSplit(trans, i)) != NULL)
+ while ((s = xaccTransGetSplit (trans, i)) != NULL)
{
- gnc_quickfill_cell_add_completion(
- (QuickFillCell *) gnc_table_layout_get_cell(layout, MEMO_CELL),
- xaccSplitGetMemo(s));
+ gnc_quickfill_cell_add_completion (
+ (QuickFillCell*) gnc_table_layout_get_cell (layout, MEMO_CELL),
+ xaccSplitGetMemo (s));
i++;
}
}
static Split*
-create_blank_split (Account *default_account, SRInfo *info)
+create_blank_split (Account* default_account, SRInfo* info)
{
- Transaction *new_trans;
+ Transaction* new_trans;
gboolean currency_from_account = TRUE;
- Split *blank_split = NULL;
+ Split* blank_split = NULL;
/* Determine the proper currency to use for this transaction.
* if default_account != NULL and default_account->commodity is
* a currency, then use that. Otherwise use the default currency.
*/
- gnc_commodity * currency = gnc_account_or_default_currency(default_account, ¤cy_from_account);
+ gnc_commodity* currency = gnc_account_or_default_currency (default_account,
+ ¤cy_from_account);
if (default_account != NULL && !currency_from_account)
{
- /* If we don't have a currency then pop up a warning dialog */
- gnc_info_dialog(NULL, "%s",
- _("Could not determine the account currency. "
- "Using the default currency provided by your system."));
+ /* If we don't have a currency then pop up a warning dialog */
+ gnc_info_dialog (NULL, "%s",
+ _ ("Could not determine the account currency. "
+ "Using the default currency provided by your system."));
}
- gnc_suspend_gui_refresh ();
+ gnc_suspend_gui_refresh();
- new_trans = xaccMallocTransaction (gnc_get_current_book ());
+ new_trans = xaccMallocTransaction (gnc_get_current_book());
xaccTransBeginEdit (new_trans);
xaccTransSetCurrency (new_trans, currency);
- xaccTransSetDatePostedSecsNormalized(new_trans, info->last_date_entered);
- blank_split = xaccMallocSplit (gnc_get_current_book ());
- xaccSplitSetParent(blank_split, new_trans);
+ xaccTransSetDatePostedSecsNormalized (new_trans, info->last_date_entered);
+ blank_split = xaccMallocSplit (gnc_get_current_book());
+ xaccSplitSetParent (blank_split, new_trans);
/* We don't want to commit this transaction yet, because the split
doesn't even belong to an account yet. But, we don't want to
set this transaction as the pending transaction either, because
@@ -299,34 +300,34 @@ create_blank_split (Account *default_account, SRInfo *info)
info->blank_split_guid = *xaccSplitGetGUID (blank_split);
info->blank_split_edited = FALSE;
info->auto_complete = FALSE;
- DEBUG("created new blank_split=%p", blank_split);
+ DEBUG ("created new blank_split=%p", blank_split);
- gnc_resume_gui_refresh ();
+ gnc_resume_gui_refresh();
return blank_split;
}
static void
-change_account_separator (SRInfo *info, Table *table, SplitRegister *reg)
+change_account_separator (SRInfo* info, Table* table, SplitRegister* reg)
{
info->separator_changed = FALSE;
/* set the completion character for the xfer cells */
- gnc_combo_cell_set_complete_char(
- (ComboCell *) gnc_table_layout_get_cell(table->layout, MXFRM_CELL),
- gnc_get_account_separator());
+ gnc_combo_cell_set_complete_char (
+ (ComboCell*) gnc_table_layout_get_cell (table->layout, MXFRM_CELL),
+ gnc_get_account_separator());
- gnc_combo_cell_set_complete_char(
- (ComboCell *) gnc_table_layout_get_cell(table->layout, XFRM_CELL),
- gnc_get_account_separator());
+ gnc_combo_cell_set_complete_char (
+ (ComboCell*) gnc_table_layout_get_cell (table->layout, XFRM_CELL),
+ gnc_get_account_separator());
/* set the confirmation callback for the reconcile cell */
- gnc_recn_cell_set_confirm_cb(
- (RecnCell *) gnc_table_layout_get_cell(table->layout, RECN_CELL),
- gnc_split_register_recn_cell_confirm, reg);
+ gnc_recn_cell_set_confirm_cb (
+ (RecnCell*) gnc_table_layout_get_cell (table->layout, RECN_CELL),
+ gnc_split_register_recn_cell_confirm, reg);
}
static void
-update_info (SRInfo *info, SplitRegister *reg)
+update_info (SRInfo* info, SplitRegister* reg)
{
/* Set up the hint transaction, split, transaction split, and column. */
info->cursor_hint_trans = gnc_split_register_get_current_trans (reg);
@@ -343,26 +344,26 @@ update_info (SRInfo *info, SplitRegister *reg)
}
void
-gnc_split_register_load (SplitRegister *reg, GList * slist,
- Account *default_account)
+gnc_split_register_load (SplitRegister* reg, GList* slist,
+ Account* default_account)
{
- SRInfo *info;
- Transaction *pending_trans;
- CursorBuffer *cursor_buffer;
- GHashTable *trans_table = NULL;
- CellBlock *cursor_header;
- CellBlock *lead_cursor;
- CellBlock *split_cursor;
- Transaction *blank_trans;
- Transaction *find_trans;
- Transaction *trans;
+ SRInfo* info;
+ Transaction* pending_trans;
+ CursorBuffer* cursor_buffer;
+ GHashTable* trans_table = NULL;
+ CellBlock* cursor_header;
+ CellBlock* lead_cursor;
+ CellBlock* split_cursor;
+ Transaction* blank_trans;
+ Transaction* find_trans;
+ Transaction* trans;
CursorClass find_class;
- Split *find_trans_split;
- Split *blank_split;
- Split *find_split;
- Split *split;
- Table *table;
- GList *node;
+ Split* find_trans_split;
+ Split* blank_split;
+ Split* find_split;
+ Split* split;
+ Table* table;
+ GList* node;
gboolean start_primary_color = TRUE;
gboolean found_pending = FALSE;
@@ -373,9 +374,11 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
gboolean multi_line;
gboolean dynamic;
gboolean we_own_slist = FALSE;
- gboolean use_autoreadonly = qof_book_uses_autoreadonly(gnc_get_current_book());
- gboolean future_after_blank = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL_REGISTER,
- GNC_PREF_FUTURE_AFTER_BLANK);
+ gboolean use_autoreadonly = qof_book_uses_autoreadonly (
+ gnc_get_current_book());
+ gboolean future_after_blank = gnc_prefs_get_bool (
+ GNC_PREFS_GROUP_GENERAL_REGISTER,
+ GNC_PREF_FUTURE_AFTER_BLANK);
gboolean added_blank_trans = FALSE;
VirtualCellLocation vcell_loc;
@@ -386,42 +389,42 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
int new_split_row = -1;
time64 present, autoreadonly_time = 0;
- g_return_if_fail(reg);
+ g_return_if_fail (reg);
table = reg->table;
- g_return_if_fail(table);
+ g_return_if_fail (table);
info = gnc_split_register_get_info (reg);
- g_return_if_fail(info);
+ g_return_if_fail (info);
- ENTER("reg=%p, slist=%p, default_account=%p", reg, slist, default_account);
+ ENTER ("reg=%p, slist=%p, default_account=%p", reg, slist, default_account);
blank_split = xaccSplitLookup (&info->blank_split_guid,
- gnc_get_current_book ());
+ gnc_get_current_book());
pending_trans = xaccTransLookup (&info->pending_trans_guid,
- gnc_get_current_book ());
+ gnc_get_current_book());
/* Bug 742089: Set the debit and credit cells' print_info to the account */
gnc_price_cell_set_print_info
- ((PriceCell *) gnc_table_layout_get_cell (table->layout, DEBT_CELL),
+ ((PriceCell*) gnc_table_layout_get_cell (table->layout, DEBT_CELL),
gnc_account_print_info (default_account, FALSE));
gnc_price_cell_set_print_info
- ((PriceCell *) gnc_table_layout_get_cell (table->layout, CRED_CELL),
+ ((PriceCell*) gnc_table_layout_get_cell (table->layout, CRED_CELL),
gnc_account_print_info (default_account, FALSE));
/* make sure we have a blank split */
if (blank_split == NULL)
{
- /* Wouldn't it be a bug to open the new transaction if there was
- * already a pending transaction?
- */
- g_assert(pending_trans == NULL);
- blank_split = create_blank_split (default_account, info);
+ /* Wouldn't it be a bug to open the new transaction if there was
+ * already a pending transaction?
+ */
+ g_assert (pending_trans == NULL);
+ blank_split = create_blank_split (default_account, info);
}
blank_trans = xaccSplitGetParent (blank_split);
- DEBUG("blank_split=%p, blank_trans=%p, pending_trans=%p",
- blank_split, blank_trans, pending_trans);
+ DEBUG ("blank_split=%p, blank_trans=%p, pending_trans=%p",
+ blank_split, blank_trans, pending_trans);
info->default_account = *xaccAccountGetGUID (default_account);
@@ -454,9 +457,9 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
/* If the current cursor has changed we save the values for later
* possible restoration. */
if (gnc_table_current_cursor_changed (table, TRUE) &&
- (find_split == gnc_split_register_get_current_split (reg)))
+ (find_split == gnc_split_register_get_current_split (reg)))
{
- cursor_buffer = gnc_cursor_buffer_new ();
+ cursor_buffer = gnc_cursor_buffer_new();
gnc_table_save_current_cursor (table, cursor_buffer);
}
else
@@ -470,7 +473,7 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
{
VirtualLocation virt_loc;
- gnc_virtual_location_init(&virt_loc);
+ gnc_virtual_location_init (&virt_loc);
gnc_table_move_cursor_gui (table, virt_loc);
}
@@ -482,26 +485,26 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
vcell_loc.virt_row++;
/* get the current time and reset the dividing row */
- present = gnc_time64_get_today_end ();
+ present = gnc_time64_get_today_end();
if (use_autoreadonly)
{
- GDate *d = qof_book_get_autoreadonly_gdate(gnc_get_current_book());
+ GDate* d = qof_book_get_autoreadonly_gdate (gnc_get_current_book());
// "d" is NULL if use_autoreadonly is FALSE
autoreadonly_time = d ? gdate_to_time64 (*d) : 0;
- g_date_free(d);
+ g_date_free (d);
}
if (info->first_pass)
{
if (default_account)
{
- const char *last_num = xaccAccountGetLastNum (default_account);
+ const char* last_num = xaccAccountGetLastNum (default_account);
if (last_num)
{
- NumCell *cell;
+ NumCell* cell;
- cell = (NumCell *) gnc_table_layout_get_cell(table->layout, NUM_CELL);
+ cell = (NumCell*) gnc_table_layout_get_cell (table->layout, NUM_CELL);
gnc_num_cell_set_last_num (cell, last_num);
has_last_num = TRUE;
}
@@ -515,7 +518,7 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
}
if (info->separator_changed)
- change_account_separator (info, table, reg);
+ change_account_separator (info, table, reg);
table->model->dividing_row_upper = -1;
table->model->dividing_row = -1;
@@ -525,24 +528,24 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
// list we're about to load.
if (pending_trans != NULL)
{
- for (node = xaccTransGetSplitList(pending_trans); node; node = node->next)
+ for (node = xaccTransGetSplitList (pending_trans); node; node = node->next)
{
- Split *pending_split = (Split*)node->data;
- if (!xaccTransStillHasSplit(pending_trans, pending_split)) continue;
- if (g_list_find(slist, pending_split) != NULL)
+ Split* pending_split = (Split*)node->data;
+ if (!xaccTransStillHasSplit (pending_trans, pending_split)) continue;
+ if (g_list_find (slist, pending_split) != NULL)
continue;
- if (g_list_find_custom(slist, pending_trans,
- _find_split_with_parent_txn) != NULL)
+ if (g_list_find_custom (slist, pending_trans,
+ _find_split_with_parent_txn) != NULL)
continue;
if (!we_own_slist)
{
// lazy-copy
- slist = g_list_copy(slist);
+ slist = g_list_copy (slist);
we_own_slist = TRUE;
}
- slist = g_list_append(slist, pending_split);
+ slist = g_list_append (slist, pending_split);
}
}
@@ -555,18 +558,18 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
split = node->data;
trans = xaccSplitGetParent (split);
- if (!xaccTransStillHasSplit(trans, split))
+ if (!xaccTransStillHasSplit (trans, split))
continue;
if (pending_trans == trans)
found_pending = TRUE;
- /* If the transaction has only one split, and it's not our
- * pending_trans, then it's another register's blank split and
- * we don't want to see it.
- */
- else if (xaccTransCountSplits (trans) == 1 &&
- xaccSplitGetAccount (split) == NULL)
- continue;
+ /* If the transaction has only one split, and it's not our
+ * pending_trans, then it's another register's blank split and
+ * we don't want to see it.
+ */
+ else if (xaccTransCountSplits (trans) == 1 &&
+ xaccSplitGetAccount (split) == NULL)
+ continue;
/* Do not load splits from the blank transaction. */
@@ -583,8 +586,8 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
}
if (info->show_present_divider &&
- use_autoreadonly &&
- !found_divider_upper)
+ use_autoreadonly &&
+ !found_divider_upper)
{
if (xaccTransGetDate (trans) >= autoreadonly_time)
{
@@ -598,8 +601,8 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
}
if (info->show_present_divider &&
- !found_divider &&
- (xaccTransGetDate (trans) > present))
+ !found_divider &&
+ (xaccTransGetDate (trans) > present))
{
table->model->dividing_row = vcell_loc.virt_row;
found_divider = TRUE;
@@ -621,13 +624,13 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
}
gnc_split_register_add_transaction (reg,
- blank_trans, blank_split,
- lead_cursor, split_cursor,
- multi_line, start_primary_color,
- info->blank_split_edited,
- find_trans, find_split,
- find_class, &new_split_row,
- &vcell_loc);
+ blank_trans, blank_split,
+ lead_cursor, split_cursor,
+ multi_line, start_primary_color,
+ info->blank_split_edited,
+ find_trans, find_split,
+ find_class, &new_split_row,
+ &vcell_loc);
table->model->dividing_row_lower = vcell_loc.virt_row;
@@ -641,7 +644,7 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
/* If this is the first load of the register,
* fill up the quickfill cells. */
if (info->first_pass)
- add_quickfill_completions(reg->table->layout, trans, split, has_last_num);
+ add_quickfill_completions (reg->table->layout, trans, split, has_last_num);
if (trans == find_trans)
new_trans_row = vcell_loc.virt_row;
@@ -669,8 +672,8 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
/* No upper divider yet? Store it now */
if (info->show_present_divider &&
- use_autoreadonly &&
- !found_divider_upper && need_divider_upper)
+ use_autoreadonly &&
+ !found_divider_upper && need_divider_upper)
{
table->model->dividing_row_upper = vcell_loc.virt_row;
}
@@ -679,7 +682,7 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
* from the account. */
if (!found_pending)
{
- info->pending_trans_guid = *guid_null ();
+ info->pending_trans_guid = *guid_null();
if (xaccTransIsOpen (pending_trans))
xaccTransCommitEdit (pending_trans);
else if (pending_trans)
@@ -740,12 +743,12 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
trans_split_loc = save_loc;
- gnc_split_register_get_trans_split (reg, save_loc.vcell_loc,
- &trans_split_loc.vcell_loc);
+ gnc_split_register_get_trans_split (reg, save_loc.vcell_loc,
+ &trans_split_loc.vcell_loc);
if (dynamic || multi_line || info->trans_expanded)
{
- gnc_table_set_virt_cell_cursor(
+ gnc_table_set_virt_cell_cursor (
table, trans_split_loc.vcell_loc,
gnc_split_register_get_active_cursor (reg));
gnc_split_register_set_trans_visible (reg, trans_split_loc.vcell_loc,
@@ -773,7 +776,7 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
update_info (info, reg);
- gnc_split_register_set_cell_fractions(
+ gnc_split_register_set_cell_fractions (
reg, gnc_split_register_get_current_split (reg));
gnc_table_refresh_gui (table, TRUE);
@@ -784,9 +787,9 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
gnc_table_control_allow_move (table->control, TRUE);
if (we_own_slist)
- g_list_free(slist);
+ g_list_free (slist);
- LEAVE(" ");
+ LEAVE (" ");
}
/* ===================================================================== */
@@ -794,7 +797,7 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
#define QKEY "split_reg_shared_quickfill"
static gboolean
-skip_cb (Account *account, gpointer x)
+skip_cb (Account* account, gpointer x)
{
/* commented out as per Bug#340885 Comments 1 and 2, option (2).
if (xaccAccountIsHidden(account))
@@ -804,16 +807,16 @@ skip_cb (Account *account, gpointer x)
}
static void
-gnc_split_register_load_xfer_cells (SplitRegister *reg, Account *base_account)
+gnc_split_register_load_xfer_cells (SplitRegister* reg, Account* base_account)
{
- Account *root = NULL;
- QuickFill *qf;
- ComboCell *cell;
- GtkListStore *store;
- GtkListStore *store_full;
+ Account* root = NULL;
+ QuickFill* qf;
+ ComboCell* cell;
+ GtkListStore* store;
+ GtkListStore* store_full;
if (base_account)
- root = gnc_account_get_root(base_account);
+ root = gnc_account_get_root (base_account);
if (root == NULL)
root = gnc_get_current_root_account();
if (root == NULL)
@@ -821,14 +824,15 @@ gnc_split_register_load_xfer_cells (SplitRegister *reg, Account *base_account)
qf = gnc_get_shared_account_name_quickfill (root, QKEY, skip_cb, NULL);
store = gnc_get_shared_account_name_list_store (root, QKEY, skip_cb, NULL);
- store_full = gnc_get_shared_account_name_list_store_full (root, QKEY, skip_cb, NULL);
+ store_full = gnc_get_shared_account_name_list_store_full (root, QKEY, skip_cb,
+ NULL);
- cell = (ComboCell *)
+ cell = (ComboCell*)
gnc_table_layout_get_cell (reg->table->layout, XFRM_CELL);
gnc_combo_cell_use_quickfill_cache (cell, qf);
gnc_combo_cell_use_list_store_cache (cell, store, store_full);
- cell = (ComboCell *)
+ cell = (ComboCell*)
gnc_table_layout_get_cell (reg->table->layout, MXFRM_CELL);
gnc_combo_cell_use_quickfill_cache (cell, qf);
gnc_combo_cell_use_list_store_cache (cell, store, store_full);
diff --git a/gnucash/register/register-core/combocell.h b/gnucash/register/register-core/combocell.h
index ddaaf8880..f333aebd3 100644
--- a/gnucash/register/register-core/combocell.h
+++ b/gnucash/register/register-core/combocell.h
@@ -53,41 +53,44 @@ typedef struct
} ComboCell;
-BasicCell * gnc_combo_cell_new (void);
-void gnc_combo_cell_init (ComboCell *cell);
+BasicCell* gnc_combo_cell_new (void);
+void gnc_combo_cell_init (ComboCell* cell);
-void gnc_combo_cell_set_value (ComboCell *cell, const char *value);
+void gnc_combo_cell_set_value (ComboCell* cell, const char* value);
-void gnc_combo_cell_clear_menu (ComboCell *cell);
+void gnc_combo_cell_clear_menu (ComboCell* cell);
/** Add a menu item to the list. */
-void gnc_combo_cell_add_menu_item (ComboCell *cell, const char * menustr);
+void gnc_combo_cell_add_menu_item (ComboCell* cell,
+ const char* menustr);
/** Add a 'account name' menu item to the list. When testing for
* equality with the currently selected item, this function will
* ignore the characters normally used to separate account names. */
-void gnc_combo_cell_add_account_menu_item (ComboCell *cell, char * menustr);
+void gnc_combo_cell_add_account_menu_item (ComboCell* cell,
+ char* menustr);
/** Enable sorting of the menu item's contents. Loading the item is
* much faster with sorting disabled. */
-void gnc_combo_cell_set_sort_enabled (ComboCell *cell, gboolean enabled);
+void gnc_combo_cell_set_sort_enabled (ComboCell* cell,
+ gboolean enabled);
/** Determines whether the cell will accept strings not in the
* menu. Defaults to strict, i.e., only menu items are accepted. */
-void gnc_combo_cell_set_strict (ComboCell *cell, gboolean strict);
+void gnc_combo_cell_set_strict (ComboCell* cell, gboolean strict);
/** Sets a character used for special completion processing. */
-void gnc_combo_cell_set_complete_char (ComboCell *cell,
- gunichar complete_char);
+void gnc_combo_cell_set_complete_char (ComboCell* cell,
+ gunichar complete_char);
/** Add a string to a list of strings which, if the cell has that value,
* will cause the cell to be uneditable on 'enter'. */
-void gnc_combo_cell_add_ignore_string (ComboCell *cell,
- const char *ignore_string);
+void gnc_combo_cell_add_ignore_string (ComboCell* cell,
+ const char* ignore_string);
/** Determines whether the popup list autosizes itself or uses
* all available space. FALSE by default. */
-void gnc_combo_cell_set_autosize (ComboCell *cell, gboolean autosize);
+void gnc_combo_cell_set_autosize (ComboCell* cell, gboolean autosize);
/** Tell the combocell to use a shared QuickFill object. Using this routine
* can dramatically improve performance when creating combocells with a
@@ -98,8 +101,10 @@ void gnc_combo_cell_set_autosize (ComboCell *cell, gboolean autosize);
* nor delete the quickfill; it is the users resonsibility to manage the
* quickfill object. The combocell will *not* make a copy of the quickfill.
*/
-void gnc_combo_cell_use_quickfill_cache (ComboCell *cell, QuickFill *shared_qf);
-void gnc_combo_cell_use_list_store_cache (ComboCell * cell, gpointer data, gpointer data2);
+void gnc_combo_cell_use_quickfill_cache (ComboCell* cell,
+ QuickFill* shared_qf);
+void gnc_combo_cell_use_list_store_cache (ComboCell* cell, gpointer data,
+ gpointer data2);
/** @} */
#endif
diff --git a/gnucash/register/register-gnome/combocell-gnome.c b/gnucash/register/register-gnome/combocell-gnome.c
index 2a6eedcb9..5c0fea753 100644
--- a/gnucash/register/register-gnome/combocell-gnome.c
+++ b/gnucash/register/register-gnome/combocell-gnome.c
@@ -52,10 +52,10 @@
typedef struct _PopBox
{
- GnucashSheet *sheet;
- GncItemEdit *item_edit;
- GncItemList *item_list;
- GtkListStore *tmp_store;
+ GnucashSheet* sheet;
+ GncItemEdit* item_edit;
+ GncItemList* item_list;
+ GtkListStore* tmp_store;
gboolean signals_connected; /* list signals connected? */
@@ -63,7 +63,7 @@ typedef struct _PopBox
gboolean autosize;
- QuickFill *qf;
+ QuickFill* qf;
gboolean use_quickfill_cache; /* If TRUE, we don't own the qf */
gboolean in_list_select;
@@ -72,26 +72,26 @@ typedef struct _PopBox
gunichar complete_char; /* char to be used for auto-completion */
- GList *ignore_strings;
+ GList* ignore_strings;
} PopBox;
-static void gnc_combo_cell_gui_realize (BasicCell *bcell, gpointer w);
-static void gnc_combo_cell_gui_move (BasicCell *bcell);
-static void gnc_combo_cell_gui_destroy (BasicCell *bcell);
-static gboolean gnc_combo_cell_enter (BasicCell *bcell,
- int *cursor_position,
- int *start_selection,
- int *end_selection);
-static void gnc_combo_cell_leave (BasicCell *bcell);
-static void gnc_combo_cell_destroy (BasicCell *bcell);
+static void gnc_combo_cell_gui_realize (BasicCell* bcell, gpointer w);
+static void gnc_combo_cell_gui_move (BasicCell* bcell);
+static void gnc_combo_cell_gui_destroy (BasicCell* bcell);
+static gboolean gnc_combo_cell_enter (BasicCell* bcell,
+ int* cursor_position,
+ int* start_selection,
+ int* end_selection);
+static void gnc_combo_cell_leave (BasicCell* bcell);
+static void gnc_combo_cell_destroy (BasicCell* bcell);
static GOnce auto_pop_init_once = G_ONCE_INIT;
static gboolean auto_pop_combos = FALSE;
static void
-gnc_combo_cell_set_autopop (gpointer prefs, gchar *pref, gpointer user_data)
+gnc_combo_cell_set_autopop (gpointer prefs, gchar* pref, gpointer user_data)
{
auto_pop_combos = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER,
GNC_PREF_AUTO_RAISE_LISTS);
@@ -113,12 +113,12 @@ gnc_combo_cell_autopop_init (gpointer unused)
return NULL;
}
-BasicCell *
+BasicCell*
gnc_combo_cell_new (void)
{
- ComboCell * cell;
+ ComboCell* cell;
- g_once(&auto_pop_init_once, gnc_combo_cell_autopop_init, NULL);
+ g_once (&auto_pop_init_once, gnc_combo_cell_autopop_init, NULL);
cell = g_new0 (ComboCell, 1);
@@ -128,11 +128,11 @@ gnc_combo_cell_new (void)
}
void
-gnc_combo_cell_init (ComboCell *cell)
+gnc_combo_cell_init (ComboCell* cell)
{
- PopBox *box;
+ PopBox* box;
- gnc_basic_cell_init (&(cell->cell));
+ gnc_basic_cell_init (& (cell->cell));
cell->cell.is_popup = TRUE;
@@ -154,7 +154,7 @@ gnc_combo_cell_init (ComboCell *cell)
cell->shared_store_full = NULL;
cell->cell.gui_private = box;
- box->qf = gnc_quickfill_new ();
+ box->qf = gnc_quickfill_new();
box->use_quickfill_cache = FALSE;
box->in_list_select = FALSE;
@@ -167,10 +167,10 @@ gnc_combo_cell_init (ComboCell *cell)
}
static void
-select_item_cb (GncItemList *item_list, char *item_string, gpointer data)
+select_item_cb (GncItemList* item_list, char* item_string, gpointer data)
{
- ComboCell *cell = data;
- PopBox *box = cell->cell.gui_private;
+ ComboCell* cell = data;
+ PopBox* box = cell->cell.gui_private;
box->in_list_select = TRUE;
gnucash_sheet_modify_current_cell (box->sheet, item_string);
@@ -181,10 +181,10 @@ select_item_cb (GncItemList *item_list, char *item_string, gpointer data)
}
static void
-change_item_cb (GncItemList *item_list, char *item_string, gpointer data)
+change_item_cb (GncItemList* item_list, char* item_string, gpointer data)
{
- ComboCell *cell = data;
- PopBox *box = cell->cell.gui_private;
+ ComboCell* cell = data;
+ PopBox* box = cell->cell.gui_private;
box->in_list_select = TRUE;
gnucash_sheet_modify_current_cell (box->sheet, item_string);
@@ -192,20 +192,20 @@ change_item_cb (GncItemList *item_list, char *item_string, gpointer data)
}
static void
-activate_item_cb (GncItemList *item_list, char *item_string, gpointer data)
+activate_item_cb (GncItemList* item_list, char* item_string, gpointer data)
{
- ComboCell *cell = data;
- PopBox *box = cell->cell.gui_private;
+ ComboCell* cell = data;
+ PopBox* box = cell->cell.gui_private;
gnc_item_edit_hide_popup (box->item_edit);
box->list_popped = FALSE;
}
static void
-key_press_item_cb (GncItemList *item_list, GdkEventKey *event, gpointer data)
+key_press_item_cb (GncItemList* item_list, GdkEventKey* event, gpointer data)
{
- ComboCell *cell = data;
- PopBox *box = cell->cell.gui_private;
+ ComboCell* cell = data;
+ PopBox* box = cell->cell.gui_private;
switch (event->keyval)
{
@@ -215,30 +215,31 @@ key_press_item_cb (GncItemList *item_list, GdkEventKey *event, gpointer data)
break;
default:
- gtk_widget_event (GTK_WIDGET(box->sheet),
- (GdkEvent *) event);
+ gtk_widget_event (GTK_WIDGET (box->sheet),
+ (GdkEvent*) event);
break;
}
}
static void
-combo_disconnect_signals (ComboCell *cell)
+combo_disconnect_signals (ComboCell* cell)
{
- PopBox *box = cell->cell.gui_private;
+ PopBox* box = cell->cell.gui_private;
if (!box->signals_connected)
return;
- g_signal_handlers_disconnect_matched (G_OBJECT (box->item_list), G_SIGNAL_MATCH_DATA,
+ g_signal_handlers_disconnect_matched (G_OBJECT (box->item_list),
+ G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, cell);
box->signals_connected = FALSE;
}
static void
-combo_connect_signals (ComboCell *cell)
+combo_connect_signals (ComboCell* cell)
{
- PopBox *box = cell->cell.gui_private;
+ PopBox* box = cell->cell.gui_private;
if (box->signals_connected)
return;
@@ -259,40 +260,42 @@ combo_connect_signals (ComboCell *cell)
}
static void
-block_list_signals (ComboCell *cell)
+block_list_signals (ComboCell* cell)
{
- PopBox *box = cell->cell.gui_private;
+ PopBox* box = cell->cell.gui_private;
if (!box->signals_connected)
return;
- g_signal_handlers_block_matched (G_OBJECT (box->item_list), G_SIGNAL_MATCH_DATA,
+ g_signal_handlers_block_matched (G_OBJECT (box->item_list),
+ G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, cell);
}
static void
-unblock_list_signals (ComboCell *cell)
+unblock_list_signals (ComboCell* cell)
{
- PopBox *box = cell->cell.gui_private;
+ PopBox* box = cell->cell.gui_private;
if (!box->signals_connected)
return;
- g_signal_handlers_unblock_matched (G_OBJECT (box->item_list), G_SIGNAL_MATCH_DATA,
+ g_signal_handlers_unblock_matched (G_OBJECT (box->item_list),
+ G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, cell);
}
static void
-gnc_combo_cell_gui_destroy (BasicCell *bcell)
+gnc_combo_cell_gui_destroy (BasicCell* bcell)
{
- PopBox *box = bcell->gui_private;
- ComboCell *cell = (ComboCell *) bcell;
+ PopBox* box = bcell->gui_private;
+ ComboCell* cell = (ComboCell*) bcell;
if (cell->cell.gui_realize == NULL)
{
if (box != NULL && box->item_list != NULL)
{
- combo_disconnect_signals(cell);
+ combo_disconnect_signals (cell);
g_object_unref (box->item_list);
box->item_list = NULL;
}
@@ -307,16 +310,16 @@ gnc_combo_cell_gui_destroy (BasicCell *bcell)
}
static void
-gnc_combo_cell_destroy (BasicCell *bcell)
+gnc_combo_cell_destroy (BasicCell* bcell)
{
- ComboCell *cell = (ComboCell *) bcell;
- PopBox *box = cell->cell.gui_private;
+ ComboCell* cell = (ComboCell*) bcell;
+ PopBox* box = cell->cell.gui_private;
- gnc_combo_cell_gui_destroy (&(cell->cell));
+ gnc_combo_cell_gui_destroy (& (cell->cell));
if (box != NULL)
{
- GList *node;
+ GList* node;
/* Don't destroy the qf if its not ours to destroy */
if (FALSE == box->use_quickfill_cache)
@@ -343,9 +346,9 @@ gnc_combo_cell_destroy (BasicCell *bcell)
}
void
-gnc_combo_cell_set_sort_enabled (ComboCell *cell, gboolean enabled)
+gnc_combo_cell_set_sort_enabled (ComboCell* cell, gboolean enabled)
{
- PopBox *box;
+ PopBox* box;
if (cell == NULL)
return;
@@ -355,14 +358,14 @@ gnc_combo_cell_set_sort_enabled (ComboCell *cell, gboolean enabled)
return;
block_list_signals (cell);
- gnc_item_list_set_sort_enabled(box->item_list, enabled);
+ gnc_item_list_set_sort_enabled (box->item_list, enabled);
unblock_list_signals (cell);
}
void
-gnc_combo_cell_clear_menu (ComboCell * cell)
+gnc_combo_cell_clear_menu (ComboCell* cell)
{
- PopBox *box;
+ PopBox* box;
if (cell == NULL)
return;
@@ -375,7 +378,7 @@ gnc_combo_cell_clear_menu (ComboCell * cell)
if (FALSE == box->use_quickfill_cache)
{
gnc_quickfill_destroy (box->qf);
- box->qf = gnc_quickfill_new ();
+ box->qf = gnc_quickfill_new();
}
if (box->item_list != NULL)
@@ -391,9 +394,9 @@ gnc_combo_cell_clear_menu (ComboCell * cell)
}
void
-gnc_combo_cell_use_quickfill_cache (ComboCell * cell, QuickFill *shared_qf)
+gnc_combo_cell_use_quickfill_cache (ComboCell* cell, QuickFill* shared_qf)
{
- PopBox *box;
+ PopBox* box;
if (cell == NULL) return;
@@ -409,7 +412,8 @@ gnc_combo_cell_use_quickfill_cache (ComboCell * cell, QuickFill *shared_qf)
}
void
-gnc_combo_cell_use_list_store_cache (ComboCell * cell, gpointer data, gpointer data_full)
+gnc_combo_cell_use_list_store_cache (ComboCell* cell, gpointer data,
+ gpointer data_full)
{
if (cell == NULL) return;
@@ -418,9 +422,9 @@ gnc_combo_cell_use_list_store_cache (ComboCell * cell, gpointer data, gpointer d
}
void
-gnc_combo_cell_add_menu_item (ComboCell *cell, const char * menustr)
+gnc_combo_cell_add_menu_item (ComboCell* cell, const char* menustr)
{
- PopBox *box;
+ PopBox* box;
if (cell == NULL)
return;
@@ -435,7 +439,7 @@ gnc_combo_cell_add_menu_item (ComboCell *cell, const char * menustr)
gnc_item_list_append (box->item_list, menustr);
if (cell->cell.value &&
- (strcmp (menustr, cell->cell.value) == 0))
+ (strcmp (menustr, cell->cell.value) == 0))
gnc_item_list_select (box->item_list, menustr);
unblock_list_signals (cell);
@@ -444,8 +448,8 @@ gnc_combo_cell_add_menu_item (ComboCell *cell, const char * menustr)
{
GtkTreeIter iter;
- gtk_list_store_append(box->tmp_store, &iter);
- gtk_list_store_set(box->tmp_store, &iter, 0, menustr, -1);
+ gtk_list_store_append (box->tmp_store, &iter);
+ gtk_list_store_set (box->tmp_store, &iter, 0, menustr, -1);
}
/* If we're going to be using a pre-fab quickfill,
@@ -457,10 +461,10 @@ gnc_combo_cell_add_menu_item (ComboCell *cell, const char * menustr)
}
void
-gnc_combo_cell_add_account_menu_item (ComboCell *cell, char * menustr)
+gnc_combo_cell_add_account_menu_item (ComboCell* cell, char* menustr)
{
- PopBox *box;
- gchar *menu_copy, *value_copy;
+ PopBox* box;
+ gchar* menu_copy, *value_copy;
if (cell == NULL)
return;
@@ -476,16 +480,16 @@ gnc_combo_cell_add_account_menu_item (ComboCell *cell, char * menustr)
gnc_item_list_append (box->item_list, menustr);
if (cell->cell.value)
{
- menu_copy = g_strdelimit(g_strdup(menustr), "-:/\\.", ' ');
+ menu_copy = g_strdelimit (g_strdup (menustr), "-:/\\.", ' ');
value_copy =
- g_strdelimit(g_strdup(cell->cell.value), "-:/\\.", ' ');
+ g_strdelimit (g_strdup (cell->cell.value), "-:/\\.", ' ');
if (strcmp (menu_copy, value_copy) == 0)
{
gnc_combo_cell_set_value (cell, menustr);
gnc_item_list_select (box->item_list, menustr);
}
- g_free(value_copy);
- g_free(menu_copy);
+ g_free (value_copy);
+ g_free (menu_copy);
}
unblock_list_signals (cell);
}
@@ -499,7 +503,7 @@ gnc_combo_cell_add_account_menu_item (ComboCell *cell, char * menustr)
}
void
-gnc_combo_cell_set_value (ComboCell *cell, const char *str)
+gnc_combo_cell_set_value (ComboCell* cell, const char* str)
{
gnc_basic_cell_set_value (&cell->cell, str);
}
@@ -507,78 +511,80 @@ gnc_combo_cell_set_value (ComboCell *cell, const char *str)
/* This function looks through full_store for a partial match with newval and returns the first
match (which must be subsequently freed). It fills out box->item_list with found matches */
static gchar*
-gnc_combo_cell_type_ahead_search(const gchar* newval, GtkListStore* full_store, PopBox *box)
+gnc_combo_cell_type_ahead_search (const gchar* newval,
+ GtkListStore* full_store, PopBox* box)
{
GtkTreeIter iter;
gboolean valid;
- int num_found=0;
- gchar *first_found = NULL;
- gchar *match_str = NULL;
- GError *gerror = NULL;
- GMatchInfo *match_info = NULL;
- GRegex *regex = NULL;
- gchar *rep_str = NULL;
- gchar *newval_rep = NULL;
- GRegex *regex0 = g_regex_new (gnc_get_account_separator_string(), 0, 0, &gerror);
+ int num_found = 0;
+ gchar* first_found = NULL;
+ gchar* match_str = NULL;
+ GError* gerror = NULL;
+ GMatchInfo* match_info = NULL;
+ GRegex* regex = NULL;
+ gchar* rep_str = NULL;
+ gchar* newval_rep = NULL;
+ GRegex* regex0 = g_regex_new (gnc_get_account_separator_string(), 0, 0,
+ &gerror);
// Replace ":" in newval with ".*:.*" so we can use regexp to match.
newval_rep = g_strconcat (".*", gnc_get_account_separator_string(), ".*",
- NULL);
+ NULL);
rep_str = g_regex_replace (regex0, newval, -1, 0, newval_rep, 0, &gerror);
// Then compile the regular expression based on rep_str.
regex = g_regex_new (rep_str, G_REGEX_CASELESS, 0, &gerror);
- valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(full_store), &iter);
+ valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (full_store), &iter);
// Clear result list.
- gnc_item_list_clear(box->item_list);
+ gnc_item_list_clear (box->item_list);
while (valid)
{
static const gint MAX_NUM_MATCHES = 30;
- gchar *str_data = NULL;
+ gchar* str_data = NULL;
gchar* normalized_str_data = NULL;
- gtk_tree_model_get (GTK_TREE_MODEL(full_store), &iter,0, &str_data,-1);
+ gtk_tree_model_get (GTK_TREE_MODEL (full_store), &iter, 0, &str_data, -1);
normalized_str_data = g_utf8_normalize (str_data, -1, G_NORMALIZE_ALL);
-
- if(g_regex_match (regex, normalized_str_data, 0, NULL))
+
+ if (g_regex_match (regex, normalized_str_data, 0, NULL))
{
- if(!num_found) first_found = g_strdup(str_data);
+ if (!num_found) first_found = g_strdup (str_data);
++num_found;
/* The pop box can be very slow to display if it has too many items and it's not very useful
to have many. So limit that to a reasonable number. */
- if(num_found < MAX_NUM_MATCHES)
+ if (num_found < MAX_NUM_MATCHES)
gnc_item_list_append (box->item_list, str_data);
}
- g_free(str_data);
- g_free(normalized_str_data);
- valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(full_store), &iter);
+ g_free (str_data);
+ g_free (normalized_str_data);
+ valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (full_store), &iter);
}
- if(num_found)
+ if (num_found)
match_str = first_found;
- g_regex_unref(regex);
- g_regex_unref(regex0);
- g_free(rep_str);
- g_free(newval_rep);
+ g_regex_unref (regex);
+ g_regex_unref (regex0);
+ g_free (rep_str);
+ g_free (newval_rep);
return match_str;
}
static void
-gnc_combo_cell_modify_verify (BasicCell *_cell,
- const char *change,
+gnc_combo_cell_modify_verify (BasicCell* _cell,
+ const char* change,
int change_len,
- const char *newval,
+ const char* newval,
int newval_len,
- int *cursor_position,
- int *start_selection,
- int *end_selection)
+ int* cursor_position,
+ int* start_selection,
+ int* end_selection)
{
- ComboCell *cell = (ComboCell *) _cell;
- PopBox *box = cell->cell.gui_private;
- gchar *match_str = NULL;
+ ComboCell* cell = (ComboCell*) _cell;
+ PopBox* box = cell->cell.gui_private;
+ gchar* match_str = NULL;
glong newval_chars;
glong change_chars;
GtkListStore* full_store;
- const gchar *box_str = NULL;
- QuickFill *match = NULL;
+ const gchar* box_str = NULL;
+ QuickFill* match = NULL;
newval_chars = g_utf8_strlen (newval, newval_len);
change_chars = g_utf8_strlen (change, change_len);
@@ -591,11 +597,11 @@ gnc_combo_cell_modify_verify (BasicCell *_cell,
*end_selection = -1;
return;
}
-
+
// Try the start-of-name match using the quickfill
match = gnc_quickfill_get_string_match (box->qf, newval);
- match_str = g_strdup(gnc_quickfill_string (match));
- if(match_str != NULL)
+ match_str = g_strdup (gnc_quickfill_string (match));
+ if (match_str != NULL)
{
// We have a match, but if we were deleting or inserting in the middle, just accept.
if (change == NULL || *cursor_position < _cell->value_chars)
@@ -603,23 +609,23 @@ gnc_combo_cell_modify_verify (BasicCell *_cell,
gnc_basic_cell_set_value_internal (_cell, newval);
return;
}
- *start_selection=newval_chars;
- *end_selection=-1;
- *cursor_position+= change_chars;
- box_str=match_str;
+ *start_selection = newval_chars;
+ *end_selection = -1;
+ *cursor_position += change_chars;
+ box_str = match_str;
}
else
{
// No start-of-name match, try type-ahead search, we match any substring of the account name.
full_store = cell->shared_store_full;
- match_str = gnc_combo_cell_type_ahead_search(newval, full_store, box);
+ match_str = gnc_combo_cell_type_ahead_search (newval, full_store, box);
*start_selection = newval_chars;
*end_selection = -1;
*cursor_position = newval_chars;
// Do not change the string in the type-in box.
box_str = newval;
}
-
+
if (match_str == NULL)
{
// No match. Remove any selection in popup, don't change the type-in box
@@ -641,24 +647,24 @@ gnc_combo_cell_modify_verify (BasicCell *_cell,
unblock_list_signals (cell);
gnc_basic_cell_set_value_internal (_cell, box_str);
- g_free(match_str);
+ g_free (match_str);
}
static gboolean
-gnc_combo_cell_direct_update (BasicCell *bcell,
- int *cursor_position,
- int *start_selection,
- int *end_selection,
- void *gui_data)
-{
- ComboCell *cell = (ComboCell *) bcell;
- PopBox *box = cell->cell.gui_private;
- GdkEventKey *event = gui_data;
+gnc_combo_cell_direct_update (BasicCell* bcell,
+ int* cursor_position,
+ int* start_selection,
+ int* end_selection,
+ void* gui_data)
+{
+ ComboCell* cell = (ComboCell*) bcell;
+ PopBox* box = cell->cell.gui_private;
+ GdkEventKey* event = gui_data;
gboolean keep_on_going = FALSE;
gboolean extra_colon;
gunichar unicode_value;
- QuickFill *match;
- const char *match_str;
+ QuickFill* match;
+ const char* match_str;
int prefix_len;
int find_pos;
int new_pos;
@@ -666,11 +672,11 @@ gnc_combo_cell_direct_update (BasicCell *bcell,
if (event->type != GDK_KEY_PRESS)
return FALSE;
- unicode_value = gdk_keyval_to_unicode(event->keyval);
+ unicode_value = gdk_keyval_to_unicode (event->keyval);
switch (event->keyval)
{
case GDK_KEY_slash:
- if (!(event->state & GDK_MOD1_MASK))
+ if (! (event->state & GDK_MOD1_MASK))
{
if (unicode_value == box->complete_char)
break;
@@ -678,11 +684,11 @@ gnc_combo_cell_direct_update (BasicCell *bcell,
return FALSE;
}
keep_on_going = TRUE;
- /* fall through */
+ /* fall through */
case GDK_KEY_Tab:
case GDK_KEY_ISO_Left_Tab:
- if (!(event->state & GDK_CONTROL_MASK) &&
- !keep_on_going)
+ if (! (event->state & GDK_CONTROL_MASK) &&
+ !keep_on_going)
return FALSE;
match = gnc_quickfill_get_string_len_match
@@ -698,9 +704,9 @@ gnc_combo_cell_direct_update (BasicCell *bcell,
match_str = gnc_quickfill_string (match);
if ((match_str != NULL) &&
- (strncmp (match_str, bcell->value,
- strlen (bcell->value)) == 0) &&
- (strcmp (match_str, bcell->value) != 0))
+ (strncmp (match_str, bcell->value,
+ strlen (bcell->value)) == 0) &&
+ (strcmp (match_str, bcell->value) != 0))
{
gnc_basic_cell_set_value_internal (bcell,
match_str);
@@ -728,20 +734,20 @@ gnc_combo_cell_direct_update (BasicCell *bcell,
return FALSE;
if ((*cursor_position < bcell->value_chars) &&
- ((*end_selection < bcell->value_chars) ||
- (*cursor_position < *start_selection)))
+ ((*end_selection < bcell->value_chars) ||
+ (*cursor_position < *start_selection)))
return FALSE;
if ((*cursor_position == bcell->value_chars) &&
- (*start_selection != *end_selection) &&
- (*end_selection < bcell->value_chars))
+ (*start_selection != *end_selection) &&
+ (*end_selection < bcell->value_chars))
return FALSE;
find_pos = -1;
if (*start_selection < bcell->value_chars)
{
int i = *start_selection;
- const char *c;
+ const char* c;
gunichar uc;
c = g_utf8_offset_to_pointer (bcell->value, i);
@@ -770,7 +776,7 @@ gnc_combo_cell_direct_update (BasicCell *bcell,
}
match = gnc_quickfill_get_string_len_match (box->qf,
- bcell->value, new_pos);
+ bcell->value, new_pos);
if (match == NULL)
return FALSE;
@@ -787,8 +793,8 @@ gnc_combo_cell_direct_update (BasicCell *bcell,
match_str = gnc_quickfill_string (match);
if ((match_str != NULL) &&
- (strncmp (match_str, bcell->value, strlen (bcell->value)) == 0) &&
- (strcmp (match_str, bcell->value) != 0))
+ (strncmp (match_str, bcell->value, strlen (bcell->value)) == 0) &&
+ (strcmp (match_str, bcell->value) != 0))
{
gnc_basic_cell_set_value_internal (bcell, match_str);
@@ -805,12 +811,12 @@ gnc_combo_cell_direct_update (BasicCell *bcell,
}
static void
-gnc_combo_cell_gui_realize (BasicCell *bcell, gpointer data)
+gnc_combo_cell_gui_realize (BasicCell* bcell, gpointer data)
{
- GnucashSheet *sheet = data;
- GncItemEdit *item_edit = gnucash_sheet_get_item_edit (sheet);
- ComboCell *cell = (ComboCell *) bcell;
- PopBox *box = cell->cell.gui_private;
+ GnucashSheet* sheet = data;
+ GncItemEdit* item_edit = gnucash_sheet_get_item_edit (sheet);
+ ComboCell* cell = (ComboCell*) bcell;
+ PopBox* box = cell->cell.gui_private;
/* initialize gui-specific, private data */
box->sheet = sheet;
@@ -819,8 +825,8 @@ gnc_combo_cell_gui_realize (BasicCell *bcell, gpointer data)
box->item_list = GNC_ITEM_LIST (gnc_item_list_new (cell->shared_store));
else
box->item_list = GNC_ITEM_LIST (gnc_item_list_new (box->tmp_store));
- gtk_widget_show_all (GTK_WIDGET(box->item_list));
- g_object_ref_sink(box->item_list);
+ gtk_widget_show_all (GTK_WIDGET (box->item_list));
+ g_object_ref_sink (box->item_list);
/* to mark cell as realized, remove the realize method */
cell->cell.gui_realize = NULL;
@@ -833,11 +839,11 @@ gnc_combo_cell_gui_realize (BasicCell *bcell, gpointer data)
}
static void
-gnc_combo_cell_gui_move (BasicCell *bcell)
+gnc_combo_cell_gui_move (BasicCell* bcell)
{
- PopBox *box = bcell->gui_private;
+ PopBox* box = bcell->gui_private;
- combo_disconnect_signals ((ComboCell *) bcell);
+ combo_disconnect_signals ((ComboCell*) bcell);
gnc_item_edit_set_popup (box->item_edit, NULL, NULL,
NULL, NULL, NULL, NULL, NULL);
@@ -846,24 +852,24 @@ gnc_combo_cell_gui_move (BasicCell *bcell)
}
static int
-popup_get_height (G_GNUC_UNUSED GtkWidget *widget,
+popup_get_height (G_GNUC_UNUSED GtkWidget* widget,
int space_available,
int row_height,
gpointer user_data)
{
- PopBox *box = user_data;
+ PopBox* box = user_data;
int count, pad = 4;
- count = gnc_item_list_num_entries(box->item_list);
- return MIN(space_available, (count * (row_height + pad)) + pad);
+ count = gnc_item_list_num_entries (box->item_list);
+ return MIN (space_available, (count * (row_height + pad)) + pad);
}
static int
-popup_autosize (GtkWidget *widget,
+popup_autosize (GtkWidget* widget,
int max_width,
gpointer user_data)
{
- PopBox *box = user_data;
+ PopBox* box = user_data;
if (!box || !box->autosize)
return max_width;
@@ -872,14 +878,14 @@ popup_autosize (GtkWidget *widget,
}
static void
-popup_set_focus (GtkWidget *widget,
+popup_set_focus (GtkWidget* widget,
G_GNUC_UNUSED gpointer user_data)
{
gtk_widget_grab_focus (GTK_WIDGET (GNC_ITEM_LIST (widget)->tree_view));
}
static void
-popup_post_show (GtkWidget *widget,
+popup_post_show (GtkWidget* widget,
G_GNUC_UNUSED gpointer user_data)
{
gnc_item_list_autosize (GNC_ITEM_LIST (widget));
@@ -887,23 +893,24 @@ popup_post_show (GtkWidget *widget,
}
static int
-popup_get_width (GtkWidget *widget,
+popup_get_width (GtkWidget* widget,
G_GNUC_UNUSED gpointer user_data)
{
GtkAllocation alloc;
- gtk_widget_get_allocation (GTK_WIDGET (GNC_ITEM_LIST (widget)->tree_view), &alloc);
+ gtk_widget_get_allocation (GTK_WIDGET (GNC_ITEM_LIST (widget)->tree_view),
+ &alloc);
return alloc.width;
}
static gboolean
-gnc_combo_cell_enter (BasicCell *bcell,
- int *cursor_position,
- int *start_selection,
- int *end_selection)
+gnc_combo_cell_enter (BasicCell* bcell,
+ int* cursor_position,
+ int* start_selection,
+ int* end_selection)
{
- ComboCell *cell = (ComboCell *) bcell;
- PopBox *box = bcell->gui_private;
- GList *find = NULL;
+ ComboCell* cell = (ComboCell*) bcell;
+ PopBox* box = bcell->gui_private;
+ GList* find = NULL;
if (bcell->value)
find = g_list_find_custom (box->ignore_strings,
@@ -913,7 +920,7 @@ gnc_combo_cell_enter (BasicCell *bcell,
return FALSE;
gnc_item_edit_set_popup (box->item_edit,
- GTK_WIDGET(box->item_list),
+ GTK_WIDGET (box->item_list),
popup_get_height, popup_autosize,
popup_set_focus, popup_post_show,
popup_get_width, box);
@@ -932,11 +939,11 @@ gnc_combo_cell_enter (BasicCell *bcell,
}
static void
-gnc_combo_cell_leave (BasicCell *bcell)
+gnc_combo_cell_leave (BasicCell* bcell)
{
- PopBox *box = bcell->gui_private;
+ PopBox* box = bcell->gui_private;
- combo_disconnect_signals ((ComboCell *) bcell);
+ combo_disconnect_signals ((ComboCell*) bcell);
gnc_item_edit_set_popup (box->item_edit, NULL, NULL,
NULL, NULL, NULL, NULL, NULL);
@@ -960,9 +967,9 @@ gnc_combo_cell_leave (BasicCell *bcell)
}
void
-gnc_combo_cell_set_strict (ComboCell *cell, gboolean strict)
+gnc_combo_cell_set_strict (ComboCell* cell, gboolean strict)
{
- PopBox *box;
+ PopBox* box;
if (cell == NULL)
return;
@@ -973,9 +980,9 @@ gnc_combo_cell_set_strict (ComboCell *cell, gboolean strict)
}
void
-gnc_combo_cell_set_complete_char (ComboCell *cell, gunichar complete_char)
+gnc_combo_cell_set_complete_char (ComboCell* cell, gunichar complete_char)
{
- PopBox *box;
+ PopBox* box;
if (cell == NULL)
return;
@@ -986,10 +993,10 @@ gnc_combo_cell_set_complete_char (ComboCell *cell, gunichar complete_char)
}
void
-gnc_combo_cell_add_ignore_string (ComboCell *cell,
- const char *ignore_string)
+gnc_combo_cell_add_ignore_string (ComboCell* cell,
+ const char* ignore_string)
{
- PopBox *box;
+ PopBox* box;
if (cell == NULL)
return;
@@ -1004,9 +1011,9 @@ gnc_combo_cell_add_ignore_string (ComboCell *cell,
}
void
-gnc_combo_cell_set_autosize (ComboCell *cell, gboolean autosize)
+gnc_combo_cell_set_autosize (ComboCell* cell, gboolean autosize)
{
- PopBox *box;
+ PopBox* box;
if (!cell)
return;
diff --git a/gnucash/register/register-gnome/gnucash-item-list.c b/gnucash/register/register-gnome/gnucash-item-list.c
index 819cfb3cd..734b0ace7 100644
--- a/gnucash/register/register-gnome/gnucash-item-list.c
+++ b/gnucash/register/register-gnome/gnucash-item-list.c
@@ -45,31 +45,32 @@ enum
LAST_SIGNAL
};
-static GtkEventBoxClass *gnc_item_list_parent_class;
+static GtkEventBoxClass* gnc_item_list_parent_class;
static guint gnc_item_list_signals[LAST_SIGNAL];
-gboolean _gnc_item_find_selection(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data);
+gboolean _gnc_item_find_selection (GtkTreeModel* model, GtkTreePath* path,
+ GtkTreeIter* iter, gpointer data);
gint
-gnc_item_list_num_entries (GncItemList *item_list)
+gnc_item_list_num_entries (GncItemList* item_list)
{
- GtkTreeModel *model;
+ GtkTreeModel* model;
- g_return_val_if_fail(item_list != NULL, 0);
- g_return_val_if_fail(IS_GNC_ITEM_LIST(item_list), 0);
+ g_return_val_if_fail (item_list != NULL, 0);
+ g_return_val_if_fail (IS_GNC_ITEM_LIST (item_list), 0);
- model = GTK_TREE_MODEL(item_list->list_store);
- return gtk_tree_model_iter_n_children(model, NULL);
+ model = GTK_TREE_MODEL (item_list->list_store);
+ return gtk_tree_model_iter_n_children (model, NULL);
}
void
-gnc_item_list_clear (GncItemList *item_list)
+gnc_item_list_clear (GncItemList* item_list)
{
GtkTreeSelection* selection;
- g_return_if_fail(IS_GNC_ITEM_LIST(item_list));
- g_return_if_fail(item_list->list_store != NULL);
+ g_return_if_fail (IS_GNC_ITEM_LIST (item_list));
+ g_return_if_fail (item_list->list_store != NULL);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (item_list->tree_view));
@@ -82,20 +83,20 @@ gnc_item_list_clear (GncItemList *item_list)
void
-gnc_item_list_append (GncItemList *item_list, const char *string)
+gnc_item_list_append (GncItemList* item_list, const char* string)
{
GtkTreeIter iter;
- g_return_if_fail(IS_GNC_ITEM_LIST(item_list));
- g_return_if_fail(item_list->list_store != NULL);
- g_return_if_fail(string != NULL);
+ g_return_if_fail (IS_GNC_ITEM_LIST (item_list));
+ g_return_if_fail (item_list->list_store != NULL);
+ g_return_if_fail (string != NULL);
gtk_list_store_append (item_list->list_store, &iter);
gtk_list_store_set (item_list->list_store, &iter, 0, string, -1);
}
void
-gnc_item_list_set_sort_enabled(GncItemList *item_list, gboolean enabled)
+gnc_item_list_set_sort_enabled (GncItemList* item_list, gboolean enabled)
{
if (enabled)
{
@@ -116,99 +117,101 @@ gnc_item_list_set_sort_enabled(GncItemList *item_list, gboolean enabled)
typedef struct _findSelectionData
{
- GncItemList *item_list;
- const char *string_to_find;
- GtkTreePath *found_path;
+ GncItemList* item_list;
+ const char* string_to_find;
+ GtkTreePath* found_path;
} FindSelectionData;
gboolean
-_gnc_item_find_selection(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+_gnc_item_find_selection (GtkTreeModel* model, GtkTreePath* path,
+ GtkTreeIter* iter, gpointer data)
{
- FindSelectionData *to_find = (FindSelectionData*)data;
- gchar *iterStr;
+ FindSelectionData* to_find = (FindSelectionData*)data;
+ gchar* iterStr;
gboolean found;
- gtk_tree_model_get(model, iter, 0, &iterStr, -1);
- found = g_strcmp0(to_find->string_to_find, iterStr) == 0;
- g_free(iterStr);
+ gtk_tree_model_get (model, iter, 0, &iterStr, -1);
+ found = g_strcmp0 (to_find->string_to_find, iterStr) == 0;
+ g_free (iterStr);
if (found)
{
- to_find->found_path = gtk_tree_path_copy(path);
+ to_find->found_path = gtk_tree_path_copy (path);
return TRUE;
}
return FALSE;
}
gboolean
-gnc_item_in_list (GncItemList *item_list, const char *string)
+gnc_item_in_list (GncItemList* item_list, const char* string)
{
- FindSelectionData *to_find_data;
+ FindSelectionData* to_find_data;
gboolean result;
- g_return_val_if_fail(item_list != NULL, FALSE);
- g_return_val_if_fail(IS_GNC_ITEM_LIST(item_list), FALSE);
+ g_return_val_if_fail (item_list != NULL, FALSE);
+ g_return_val_if_fail (IS_GNC_ITEM_LIST (item_list), FALSE);
- to_find_data = (FindSelectionData*)g_new0(FindSelectionData, 1);
+ to_find_data = (FindSelectionData*)g_new0 (FindSelectionData, 1);
to_find_data->item_list = item_list;
to_find_data->string_to_find = string;
- gtk_tree_model_foreach(GTK_TREE_MODEL(item_list->list_store),
- _gnc_item_find_selection,
- to_find_data);
+ gtk_tree_model_foreach (GTK_TREE_MODEL (item_list->list_store),
+ _gnc_item_find_selection,
+ to_find_data);
result = (to_find_data->found_path != NULL);
- g_free(to_find_data);
+ g_free (to_find_data);
return result;
}
void
-gnc_item_list_select (GncItemList *item_list, const char *string)
+gnc_item_list_select (GncItemList* item_list, const char* string)
{
- GtkTreeSelection *tree_sel = NULL;
- FindSelectionData *to_find_data;
+ GtkTreeSelection* tree_sel = NULL;
+ FindSelectionData* to_find_data;
- g_return_if_fail(item_list != NULL);
- g_return_if_fail(IS_GNC_ITEM_LIST(item_list));
+ g_return_if_fail (item_list != NULL);
+ g_return_if_fail (IS_GNC_ITEM_LIST (item_list));
- tree_sel = gtk_tree_view_get_selection(item_list->tree_view);
+ tree_sel = gtk_tree_view_get_selection (item_list->tree_view);
if (string == NULL)
{
- gtk_tree_selection_unselect_all(tree_sel);
+ gtk_tree_selection_unselect_all (tree_sel);
return;
}
- to_find_data = (FindSelectionData*)g_new0(FindSelectionData, 1);
+ to_find_data = (FindSelectionData*)g_new0 (FindSelectionData, 1);
to_find_data->item_list = item_list;
to_find_data->string_to_find = string;
- gtk_tree_model_foreach(GTK_TREE_MODEL(item_list->list_store),
- _gnc_item_find_selection,
- to_find_data);
+ gtk_tree_model_foreach (GTK_TREE_MODEL (item_list->list_store),
+ _gnc_item_find_selection,
+ to_find_data);
if (to_find_data->found_path != NULL)
{
- gtk_tree_view_set_cursor(item_list->tree_view, to_find_data->found_path, NULL, FALSE);
- gtk_tree_path_free(to_find_data->found_path);
+ gtk_tree_view_set_cursor (item_list->tree_view, to_find_data->found_path, NULL,
+ FALSE);
+ gtk_tree_path_free (to_find_data->found_path);
- gnc_item_list_show_selected(item_list);
+ gnc_item_list_show_selected (item_list);
}
- g_free(to_find_data);
+ g_free (to_find_data);
}
void
-gnc_item_list_show_selected (GncItemList *item_list)
+gnc_item_list_show_selected (GncItemList* item_list)
{
- GtkTreeSelection *selection;
+ GtkTreeSelection* selection;
GtkTreeIter iter;
- GtkTreePath *path;
- GtkTreeModel *model;
+ GtkTreePath* path;
+ GtkTreeModel* model;
- g_return_if_fail(item_list != NULL);
- g_return_if_fail(IS_GNC_ITEM_LIST(item_list));
+ g_return_if_fail (item_list != NULL);
+ g_return_if_fail (IS_GNC_ITEM_LIST (item_list));
selection = gtk_tree_view_get_selection (item_list->tree_view);
@@ -222,17 +225,17 @@ gnc_item_list_show_selected (GncItemList *item_list)
}
int
-gnc_item_list_autosize (GncItemList *item_list)
+gnc_item_list_autosize (GncItemList* item_list)
{
- g_return_val_if_fail(item_list != NULL, 0);
- g_return_val_if_fail(IS_GNC_ITEM_LIST(item_list), 0);
+ g_return_val_if_fail (item_list != NULL, 0);
+ g_return_val_if_fail (IS_GNC_ITEM_LIST (item_list), 0);
return 100;
}
static void
-gnc_item_list_init (GncItemList *item_list)
+gnc_item_list_init (GncItemList* item_list)
{
item_list->tree_view = NULL;
item_list->list_store = NULL;
@@ -240,17 +243,17 @@ gnc_item_list_init (GncItemList *item_list)
static gboolean
-gnc_item_list_button_event(GtkWidget *widget, GdkEventButton *event,
- gpointer data)
+gnc_item_list_button_event (GtkWidget* widget, GdkEventButton* event,
+ gpointer data)
{
- GncItemList *item_list;
+ GncItemList* item_list;
GtkTreeIter iter;
- GtkTreePath *path;
- GtkTreeModel *model;
- gchar *string;
+ GtkTreePath* path;
+ GtkTreeModel* model;
+ gchar* string;
gboolean success;
- g_return_val_if_fail(IS_GNC_ITEM_LIST (data), FALSE);
+ g_return_val_if_fail (IS_GNC_ITEM_LIST (data), FALSE);
item_list = GNC_ITEM_LIST (data);
@@ -284,7 +287,7 @@ gnc_item_list_button_event(GtkWidget *widget, GdkEventButton *event,
gnc_item_list_signals[ACTIVATE_ITEM],
0,
string);
- g_free(string);
+ g_free (string);
return TRUE;
default:
return FALSE;
@@ -294,13 +297,13 @@ gnc_item_list_button_event(GtkWidget *widget, GdkEventButton *event,
}
static gboolean
-gnc_item_list_key_event (GtkWidget *widget, GdkEventKey *event, gpointer data)
+gnc_item_list_key_event (GtkWidget* widget, GdkEventKey* event, gpointer data)
{
- GncItemList *item_list = GNC_ITEM_LIST (data);
- GtkTreeSelection *selection = NULL;
+ GncItemList* item_list = GNC_ITEM_LIST (data);
+ GtkTreeSelection* selection = NULL;
GtkTreeIter iter;
- GtkTreeModel *model;
- gchar *string;
+ GtkTreeModel* model;
+ gchar* string;
gboolean retval;
switch (event->keyval)
@@ -316,8 +319,9 @@ gnc_item_list_key_event (GtkWidget *widget, GdkEventKey *event, gpointer data)
gnc_item_list_signals[ACTIVATE_ITEM],
0,
string);
- g_signal_emit (G_OBJECT (item_list), gnc_item_list_signals[CHANGE_ITEM], 0, string);
- g_free(string);
+ g_signal_emit (G_OBJECT (item_list), gnc_item_list_signals[CHANGE_ITEM], 0,
+ string);
+ g_free (string);
return TRUE;
case GDK_KEY_Page_Up:
@@ -331,16 +335,17 @@ gnc_item_list_key_event (GtkWidget *widget, GdkEventKey *event, gpointer data)
/* These go to the sheet */
g_signal_stop_emission_by_name (G_OBJECT (widget), "key_press_event");
- g_signal_emit_by_name (G_OBJECT (item_list), "key_press_event", event, &retval);
+ g_signal_emit_by_name (G_OBJECT (item_list), "key_press_event", event,
+ &retval);
return retval;
}
static void
-gnc_item_list_class_init (GncItemListClass *item_list_class)
+gnc_item_list_class_init (GncItemListClass* item_list_class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (item_list_class);
+ GObjectClass* object_class = G_OBJECT_CLASS (item_list_class);
gnc_item_list_parent_class = g_type_class_peek_parent (item_list_class);
@@ -349,7 +354,7 @@ gnc_item_list_class_init (GncItemListClass *item_list_class)
g_signal_new ("select_item",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GncItemListClass, select_item),
+ G_STRUCT_OFFSET (GncItemListClass, select_item),
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
@@ -359,7 +364,7 @@ gnc_item_list_class_init (GncItemListClass *item_list_class)
g_signal_new ("change_item",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GncItemListClass, change_item),
+ G_STRUCT_OFFSET (GncItemListClass, change_item),
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
@@ -369,7 +374,7 @@ gnc_item_list_class_init (GncItemListClass *item_list_class)
g_signal_new ("activate_item",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GncItemListClass, activate_item),
+ G_STRUCT_OFFSET (GncItemListClass, activate_item),
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
@@ -390,13 +395,13 @@ gnc_item_list_get_type (void)
{
static const GTypeInfo gnc_item_list_info =
{
- sizeof(GncItemListClass),
+ sizeof (GncItemListClass),
NULL,
NULL,
(GClassInitFunc) gnc_item_list_class_init,
NULL,
NULL,
- sizeof(GncItemList),
+ sizeof (GncItemList),
0,
(GInstanceInitFunc) gnc_item_list_init
};
@@ -411,40 +416,41 @@ gnc_item_list_get_type (void)
static void
-tree_view_selection_changed (GtkTreeSelection *selection,
+tree_view_selection_changed (GtkTreeSelection* selection,
gpointer data)
{
- GncItemList *item_list = GNC_ITEM_LIST (data);
- GtkTreeModel *model;
+ GncItemList* item_list = GNC_ITEM_LIST (data);
+ GtkTreeModel* model;
GtkTreeIter iter;
- char *string;
+ char* string;
- g_return_if_fail(data);
- g_return_if_fail(selection);
+ g_return_if_fail (data);
+ g_return_if_fail (selection);
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
return;
gtk_tree_model_get (model, &iter, 0, &string, -1);
- g_signal_emit (G_OBJECT (item_list), gnc_item_list_signals[CHANGE_ITEM], 0, string);
+ g_signal_emit (G_OBJECT (item_list), gnc_item_list_signals[CHANGE_ITEM], 0,
+ string);
g_free (string);
}
-GtkWidget *
-gnc_item_list_new(GtkListStore *list_store)
+GtkWidget*
+gnc_item_list_new (GtkListStore* list_store)
{
- GtkWidget *tree_view;
- GtkWidget *scrollwin;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
+ GtkWidget* tree_view;
+ GtkWidget* scrollwin;
+ GtkCellRenderer* renderer;
+ GtkTreeViewColumn* column;
- GncItemList *item_list =
- GNC_ITEM_LIST(g_object_new (GNC_TYPE_ITEM_LIST,
- NULL));
+ GncItemList* item_list =
+ GNC_ITEM_LIST (g_object_new (GNC_TYPE_ITEM_LIST,
+ NULL));
- scrollwin = gnc_scrolled_window_new ();
+ scrollwin = gnc_scrolled_window_new();
gtk_container_add (GTK_CONTAINER (item_list), scrollwin);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
@@ -454,21 +460,22 @@ gnc_item_list_new(GtkListStore *list_store)
if (NULL == list_store)
list_store = gtk_list_store_new (1, G_TYPE_STRING);
else
- g_object_ref(list_store);
+ g_object_ref (list_store);
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
- g_object_unref(list_store);
+ g_object_unref (list_store);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE);
- gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),
+ gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (
+ tree_view)),
GTK_SELECTION_BROWSE);
- gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(list_store),
- 0, GTK_SORT_ASCENDING);
-
- renderer = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes (_("List"),
- renderer,
- "text", 0,
- NULL);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_store),
+ 0, GTK_SORT_ASCENDING);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes (_ ("List"),
+ renderer,
+ "text", 0,
+ NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
gtk_container_add (GTK_CONTAINER (scrollwin), tree_view);
@@ -476,16 +483,17 @@ gnc_item_list_new(GtkListStore *list_store)
item_list->tree_view = GTK_TREE_VIEW (tree_view);
item_list->list_store = list_store;
- g_signal_connect (G_OBJECT(tree_view), "button_press_event",
+ g_signal_connect (G_OBJECT (tree_view), "button_press_event",
G_CALLBACK (gnc_item_list_button_event), item_list);
g_signal_connect (G_OBJECT (tree_view), "key_press_event",
G_CALLBACK (gnc_item_list_key_event), item_list);
- g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view))), "changed",
+ g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (
+ tree_view))), "changed",
G_CALLBACK (tree_view_selection_changed), item_list);
- return GTK_WIDGET(item_list);
+ return GTK_WIDGET (item_list);
}
commit a934c41ef45ef7551ea4b88cb74f46f9aef4337b
Author: jean <you at example.com>
Date: Sat Mar 28 12:02:14 2020 -0700
Finish removing preference, re-nice the code
diff --git a/gnucash/gnome-utils/account-quickfill.c b/gnucash/gnome-utils/account-quickfill.c
index 8af848b93..f7e18dbba 100644
--- a/gnucash/gnome-utils/account-quickfill.c
+++ b/gnucash/gnome-utils/account-quickfill.c
@@ -54,8 +54,8 @@ typedef struct
QuickFill *qf;
gboolean load_list_store;
GtkListStore *list_store;
- // For the type-ahead search, we need two lists, list_store contains the accounts that
- // match the search. list_store_full contain the original full list of accounts.
+ /* For the type-ahead search, we need two lists, list_store contains the accounts that
+ match the search. list_store_full contain the original full list of accounts. */
GtkListStore *list_store_full;
QofBook *book;
Account *root;
@@ -124,7 +124,6 @@ load_shared_qf_cb (Account *account, gpointer data)
char *name;
GtkTreeIter iter;
- // A callback to disable adding the account
if (qfb->dont_add_cb)
{
gboolean skip = (qfb->dont_add_cb) (account, qfb->dont_add_data);
diff --git a/gnucash/register/ledger-core/gncEntryLedgerLoad.c b/gnucash/register/ledger-core/gncEntryLedgerLoad.c
index cb1dc6f13..2372008a1 100644
--- a/gnucash/register/ledger-core/gncEntryLedgerLoad.c
+++ b/gnucash/register/ledger-core/gncEntryLedgerLoad.c
@@ -217,7 +217,7 @@ load_xfer_type_cells (GncEntryLedger *ledger)
store = gnc_get_shared_account_name_list_store (root, IKEY,
skip_expense_acct_cb, NULL);
store_full = gnc_get_shared_account_name_list_store_full (root, IKEY,
- skip_expense_acct_cb, NULL);
+ skip_expense_acct_cb, NULL);
break;
case GNCENTRY_BILL_ENTRY:
@@ -234,7 +234,7 @@ load_xfer_type_cells (GncEntryLedger *ledger)
store = gnc_get_shared_account_name_list_store (root, EKEY,
skip_income_acct_cb, NULL);
store_full = gnc_get_shared_account_name_list_store_full (root, EKEY,
- skip_income_acct_cb, NULL);
+ skip_income_acct_cb, NULL);
break;
default:
PWARN ("Bad GncEntryLedgerType");
diff --git a/gnucash/register/register-gnome/combocell-gnome.c b/gnucash/register/register-gnome/combocell-gnome.c
index 2cdfd1fa7..2a6eedcb9 100644
--- a/gnucash/register/register-gnome/combocell-gnome.c
+++ b/gnucash/register/register-gnome/combocell-gnome.c
@@ -90,7 +90,6 @@ static GOnce auto_pop_init_once = G_ONCE_INIT;
static gboolean auto_pop_combos = FALSE;
-// Two Callbacks called when the user changes preferences
static void
gnc_combo_cell_set_autopop (gpointer prefs, gchar *pref, gpointer user_data)
{
@@ -104,12 +103,12 @@ gnc_combo_cell_autopop_init (gpointer unused)
gulong id;
auto_pop_combos = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER,
GNC_PREF_AUTO_RAISE_LISTS);
-
- // Register callbacks for when the user changes preferences.
+
id = gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL_REGISTER,
- GNC_PREF_AUTO_RAISE_LISTS,
- gnc_combo_cell_set_autopop,
- NULL);
+ GNC_PREF_AUTO_RAISE_LISTS,
+ gnc_combo_cell_set_autopop,
+ NULL);
+
gnc_prefs_set_reg_auto_raise_lists_id (id);
return NULL;
}
@@ -519,10 +518,13 @@ gnc_combo_cell_type_ahead_search(const gchar* newval, GtkListStore* full_store,
GMatchInfo *match_info = NULL;
GRegex *regex = NULL;
gchar *rep_str = NULL;
+ gchar *newval_rep = NULL;
GRegex *regex0 = g_regex_new (gnc_get_account_separator_string(), 0, 0, &gerror);
// Replace ":" in newval with ".*:.*" so we can use regexp to match.
- rep_str = g_regex_replace (regex0,newval,-1,0,".*:.*",0,&gerror);
+ newval_rep = g_strconcat (".*", gnc_get_account_separator_string(), ".*",
+ NULL);
+ rep_str = g_regex_replace (regex0, newval, -1, 0, newval_rep, 0, &gerror);
// Then compile the regular expression based on rep_str.
regex = g_regex_new (rep_str, G_REGEX_CASELESS, 0, &gerror);
@@ -555,6 +557,7 @@ gnc_combo_cell_type_ahead_search(const gchar* newval, GtkListStore* full_store,
g_regex_unref(regex);
g_regex_unref(regex0);
g_free(rep_str);
+ g_free(newval_rep);
return match_str;
}
@@ -589,8 +592,6 @@ gnc_combo_cell_modify_verify (BasicCell *_cell,
return;
}
- // JEAN: If change == ":" do an autocompletion: if there's only 1 account that is currently matched
-
// Try the start-of-name match using the quickfill
match = gnc_quickfill_get_string_match (box->qf, newval);
match_str = g_strdup(gnc_quickfill_string (match));
@@ -736,7 +737,6 @@ gnc_combo_cell_direct_update (BasicCell *bcell,
(*end_selection < bcell->value_chars))
return FALSE;
- // JEAN: WHERE : IS MATCHED
find_pos = -1;
if (*start_selection < bcell->value_chars)
{
commit bc8428c80ee462b20feb743ab2a6855b015fb5e2
Author: jean <you at example.com>
Date: Thu Mar 26 23:15:12 2020 -0700
Make the two search coexist
Add support for : in type-ahead search
Add gnc_get_account_separator_string
Remove preference
diff --git a/bindings/core-utils.i b/bindings/core-utils.i
index 8b2a796d1..c86977067 100644
--- a/bindings/core-utils.i
+++ b/bindings/core-utils.i
@@ -124,7 +124,6 @@ gchar *gnc_locale_name (void);
SET_ENUM ("GNC-PREF-DATE-BACKMONTHS");
SET_ENUM ("GNC-PREF-SHOW-LEAF-ACCT-NAMES");
SET_ENUM ("GNC-PREF-ENTER-MOVES-TO-END");
- SET_ENUM ("GNC-PREF-TYPE-AHEAD-SEARCH");
SET_ENUM ("GNC-PREF-DRAW-HOR-LINES");
SET_ENUM ("GNC-PREF-DRAW-VERT-LINES");
SET_ENUM ("GNC-PREF-ALT-COLOR-BY-TRANS");
diff --git a/gnucash/gschemas/org.gnucash.gschema.xml.in b/gnucash/gschemas/org.gnucash.gschema.xml.in
index 0430be555..9d95809d5 100644
--- a/gnucash/gschemas/org.gnucash.gschema.xml.in
+++ b/gnucash/gschemas/org.gnucash.gschema.xml.in
@@ -245,11 +245,6 @@
<summary>"Enter" key moves to bottom of register</summary>
<description>If active, pressing the enter key will move to the bottom of the register. Otherwise pressing the enter key will move to the next transaction line.</description>
</key>
- <key name="type-ahead-search" type="b">
- <default>false</default>
- <summary>Ues type-ahead search</summary>
- <description>If active, account name completion matches any substring of the account name.</description>
- </key>
<key name="auto-raise-lists" type="b">
<default>true</default>
<summary>Automatically raise the list of accounts or actions during input</summary>
diff --git a/gnucash/gtkbuilder/dialog-preferences.glade b/gnucash/gtkbuilder/dialog-preferences.glade
index 90c977f8a..4d95fc8da 100644
--- a/gnucash/gtkbuilder/dialog-preferences.glade
+++ b/gnucash/gtkbuilder/dialog-preferences.glade
@@ -2021,25 +2021,6 @@ many months before the current month:</property>
<property name="top_attach">1</property>
</packing>
</child>
- <child>
- <object class="GtkCheckButton" id="pref/general.register/type-ahead-search">
- <property name="label" translatable="yes">_Use type ahead</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="has_tooltip">True</property>
- <property name="tooltip_markup">Use the type-ahead search for accounts: In normal search mode, the typed string has to match the beginning of the full account name (including its parent account names), in time-ahead, the typed string can match any substream of the account name.</property>
- <property name="tooltip_text" translatable="yes">Use the type-ahead search for accounts: In normal search mode, the typed string has to match the beginning of full account name (including its parent account names), in time-ahead, the typed string can match any substream of the account name.</property>
- <property name="halign">start</property>
- <property name="margin_left">12</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
<child>
<object class="GtkCheckButton" id="pref/general.register/auto-raise-lists">
<property name="label" translatable="yes">_Auto-raise lists</property>
@@ -2056,7 +2037,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">2</property>
</packing>
</child>
<child>
@@ -2075,7 +2056,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">3</property>
</packing>
</child>
<child>
@@ -2085,7 +2066,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">5</property>
+ <property name="top_attach">4</property>
</packing>
</child>
<child>
@@ -2098,7 +2079,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">6</property>
+ <property name="top_attach">5</property>
</packing>
</child>
<child>
@@ -2117,7 +2098,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">7</property>
+ <property name="top_attach">6</property>
</packing>
</child>
<child>
@@ -2136,7 +2117,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">8</property>
+ <property name="top_attach">7</property>
</packing>
</child>
<child>
@@ -2155,7 +2136,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">9</property>
+ <property name="top_attach">8</property>
</packing>
</child>
<child>
@@ -2174,7 +2155,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">10</property>
+ <property name="top_attach">9</property>
</packing>
</child>
<child>
@@ -2184,7 +2165,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">11</property>
+ <property name="top_attach">10</property>
</packing>
</child>
<child>
@@ -2197,7 +2178,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">12</property>
+ <property name="top_attach">11</property>
</packing>
</child>
<child>
@@ -2216,7 +2197,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">13</property>
+ <property name="top_attach">12</property>
</packing>
</child>
<child>
@@ -2235,7 +2216,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">14</property>
+ <property name="top_attach">13</property>
</packing>
</child>
<child>
@@ -2254,7 +2235,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">15</property>
+ <property name="top_attach">14</property>
</packing>
</child>
<child>
@@ -2273,7 +2254,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">16</property>
+ <property name="top_attach">15</property>
</packing>
</child>
<child>
@@ -2283,7 +2264,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">17</property>
+ <property name="top_attach">16</property>
</packing>
</child>
<child>
@@ -2296,7 +2277,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">18</property>
+ <property name="top_attach">17</property>
</packing>
</child>
<child>
@@ -2315,7 +2296,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">19</property>
+ <property name="top_attach">18</property>
</packing>
</child>
</object>
diff --git a/gnucash/register/register-gnome/combocell-gnome.c b/gnucash/register/register-gnome/combocell-gnome.c
index d383d6943..2cdfd1fa7 100644
--- a/gnucash/register/register-gnome/combocell-gnome.c
+++ b/gnucash/register/register-gnome/combocell-gnome.c
@@ -46,6 +46,7 @@
#include "gnucash-sheet.h"
#include "gnucash-sheetP.h"
#include "table-allgui.h"
+#include "Account.h"
#define GNC_PREF_AUTO_RAISE_LISTS "auto-raise-lists"
@@ -87,7 +88,6 @@ static void gnc_combo_cell_destroy (BasicCell *bcell);
static GOnce auto_pop_init_once = G_ONCE_INIT;
static gboolean auto_pop_combos = FALSE;
-static gboolean type_ahead_search = FALSE;
// Two Callbacks called when the user changes preferences
@@ -98,13 +98,6 @@ gnc_combo_cell_set_autopop (gpointer prefs, gchar *pref, gpointer user_data)
GNC_PREF_AUTO_RAISE_LISTS);
}
-static void
-gnc_combo_cell_set_type_ahead_search (gpointer prefs, gchar *pref, gpointer user_data)
-{
- type_ahead_search = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER,
- GNC_PREF_TYPE_AHEAD_SEARCH);
-}
-
static gpointer
gnc_combo_cell_autopop_init (gpointer unused)
{
@@ -112,19 +105,12 @@ gnc_combo_cell_autopop_init (gpointer unused)
auto_pop_combos = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER,
GNC_PREF_AUTO_RAISE_LISTS);
- type_ahead_search = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER,
- GNC_PREF_TYPE_AHEAD_SEARCH);
-
// Register callbacks for when the user changes preferences.
id = gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL_REGISTER,
GNC_PREF_AUTO_RAISE_LISTS,
gnc_combo_cell_set_autopop,
NULL);
gnc_prefs_set_reg_auto_raise_lists_id (id);
- gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL_REGISTER,
- GNC_PREF_TYPE_AHEAD_SEARCH,
- gnc_combo_cell_set_type_ahead_search,
- NULL);
return NULL;
}
@@ -524,16 +510,22 @@ gnc_combo_cell_set_value (ComboCell *cell, const char *str)
static gchar*
gnc_combo_cell_type_ahead_search(const gchar* newval, GtkListStore* full_store, PopBox *box)
{
- gchar *case_normalized_newval = NULL;
GtkTreeIter iter;
gboolean valid;
- gchar *normalized_newval = g_utf8_normalize (newval, -1, G_NORMALIZE_ALL);
int num_found=0;
gchar *first_found = NULL;
gchar *match_str = NULL;
+ GError *gerror = NULL;
+ GMatchInfo *match_info = NULL;
+ GRegex *regex = NULL;
+ gchar *rep_str = NULL;
+ GRegex *regex0 = g_regex_new (gnc_get_account_separator_string(), 0, 0, &gerror);
+
+ // Replace ":" in newval with ".*:.*" so we can use regexp to match.
+ rep_str = g_regex_replace (regex0,newval,-1,0,".*:.*",0,&gerror);
+ // Then compile the regular expression based on rep_str.
+ regex = g_regex_new (rep_str, G_REGEX_CASELESS, 0, &gerror);
- if (normalized_newval)
- case_normalized_newval = g_utf8_casefold (normalized_newval, -1);
valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(full_store), &iter);
// Clear result list.
gnc_item_list_clear(box->item_list);
@@ -541,16 +533,11 @@ gnc_combo_cell_type_ahead_search(const gchar* newval, GtkListStore* full_store,
{
static const gint MAX_NUM_MATCHES = 30;
gchar *str_data = NULL;
- gchar* case_normalized_str_data = NULL;
gchar* normalized_str_data = NULL;
- gchar* ret = NULL;
gtk_tree_model_get (GTK_TREE_MODEL(full_store), &iter,0, &str_data,-1);
normalized_str_data = g_utf8_normalize (str_data, -1, G_NORMALIZE_ALL);
- if (normalized_str_data)
- case_normalized_str_data = g_utf8_casefold (normalized_str_data, -1);
- // Does case_normalized_str_data contain case_normalized_newval?
- ret = g_strrstr(case_normalized_str_data, case_normalized_newval);
- if(ret!=NULL)
+
+ if(g_regex_match (regex, normalized_str_data, 0, NULL))
{
if(!num_found) first_found = g_strdup(str_data);
++num_found;
@@ -560,14 +547,14 @@ gnc_combo_cell_type_ahead_search(const gchar* newval, GtkListStore* full_store,
gnc_item_list_append (box->item_list, str_data);
}
g_free(str_data);
- g_free(case_normalized_str_data);
g_free(normalized_str_data);
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(full_store), &iter);
}
if(num_found)
match_str = first_found;
- g_free(case_normalized_newval);
- g_free(normalized_newval);
+ g_regex_unref(regex);
+ g_regex_unref(regex0);
+ g_free(rep_str);
return match_str;
}
@@ -588,6 +575,7 @@ gnc_combo_cell_modify_verify (BasicCell *_cell,
glong change_chars;
GtkListStore* full_store;
const gchar *box_str = NULL;
+ QuickFill *match = NULL;
newval_chars = g_utf8_strlen (newval, newval_len);
change_chars = g_utf8_strlen (change, change_len);
@@ -600,24 +588,28 @@ gnc_combo_cell_modify_verify (BasicCell *_cell,
*end_selection = -1;
return;
}
+
+ // JEAN: If change == ":" do an autocompletion: if there's only 1 account that is currently matched
- /* If deleting, just accept */
- if (change == NULL && !type_ahead_search)
- {
- gnc_basic_cell_set_value_internal (_cell, newval);
- return;
- }
-
- /* If we are inserting in the middle, just accept */
- if (*cursor_position < _cell->value_chars && !type_ahead_search)
+ // Try the start-of-name match using the quickfill
+ match = gnc_quickfill_get_string_match (box->qf, newval);
+ match_str = g_strdup(gnc_quickfill_string (match));
+ if(match_str != NULL)
{
- gnc_basic_cell_set_value_internal (_cell, newval);
- return;
+ // We have a match, but if we were deleting or inserting in the middle, just accept.
+ if (change == NULL || *cursor_position < _cell->value_chars)
+ {
+ gnc_basic_cell_set_value_internal (_cell, newval);
+ return;
+ }
+ *start_selection=newval_chars;
+ *end_selection=-1;
+ *cursor_position+= change_chars;
+ box_str=match_str;
}
-
- if (type_ahead_search)
+ else
{
- // Type-ahead search, we match any substring of the account name.
+ // No start-of-name match, try type-ahead search, we match any substring of the account name.
full_store = cell->shared_store_full;
match_str = gnc_combo_cell_type_ahead_search(newval, full_store, box);
*start_selection = newval_chars;
@@ -626,19 +618,7 @@ gnc_combo_cell_modify_verify (BasicCell *_cell,
// Do not change the string in the type-in box.
box_str = newval;
}
- else
- {
- QuickFill *match = NULL;
- // Match at start of account name using the quickfill
- match = gnc_quickfill_get_string_match (box->qf, newval);
- match_str = g_strdup(gnc_quickfill_string (match));
- *start_selection = newval_chars;
- *end_selection = -1;
- *cursor_position += change_chars;
- // Update the string in the type-in box with the matched string.
- box_str = match_str;
- }
-
+
if (match_str == NULL)
{
// No match. Remove any selection in popup, don't change the type-in box
@@ -646,7 +626,6 @@ gnc_combo_cell_modify_verify (BasicCell *_cell,
block_list_signals (cell);
gnc_item_list_select (box->item_list, NULL);
unblock_list_signals (cell);
- g_free(match_str);
return;
}
@@ -757,6 +736,7 @@ gnc_combo_cell_direct_update (BasicCell *bcell,
(*end_selection < bcell->value_chars))
return FALSE;
+ // JEAN: WHERE : IS MATCHED
find_pos = -1;
if (*start_selection < bcell->value_chars)
{
diff --git a/libgnucash/core-utils/gnc-prefs.h b/libgnucash/core-utils/gnc-prefs.h
index a125a10b1..b18d1e079 100644
--- a/libgnucash/core-utils/gnc-prefs.h
+++ b/libgnucash/core-utils/gnc-prefs.h
@@ -71,7 +71,6 @@
#define GNC_PREF_DATE_BACKMONTHS "date-backmonths"
#define GNC_PREF_SHOW_LEAF_ACCT_NAMES "show-leaf-account-names"
#define GNC_PREF_ENTER_MOVES_TO_END "enter-moves-to-end"
-#define GNC_PREF_TYPE_AHEAD_SEARCH "type-ahead-search"
/* Register preferences */
#define GNC_PREF_DRAW_HOR_LINES "draw-horizontal-lines"
#define GNC_PREF_DRAW_VERT_LINES "draw-vertical-lines"
commit eea20a8da07b494f3f0d2b0a9dcb08540ee64de4
Author: jean <you at example.com>
Date: Sun Mar 22 16:43:26 2020 -0700
Move new search function to an external function
diff --git a/gnucash/gnome-utils/account-quickfill.c b/gnucash/gnome-utils/account-quickfill.c
index 47596ad05..8af848b93 100644
--- a/gnucash/gnome-utils/account-quickfill.c
+++ b/gnucash/gnome-utils/account-quickfill.c
@@ -340,7 +340,6 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
new_name = gnc_get_account_name_for_register (account);
/* check if the name has changed */
-
match = gnc_quickfill_get_string_match (qf, old_name);
if (match && (g_strcmp0 (old_name, new_name) != 0))
gnc_quickfill_remove (qf, old_name, QUICKFILL_ALPHA);
@@ -416,7 +415,6 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
qfb->dont_add_cb (account, qfb->dont_add_data))
break;
-
match = gnc_quickfill_get_string_match (qf, name);
if (match)
{
diff --git a/gnucash/register/ledger-core/split-register-load.c b/gnucash/register/ledger-core/split-register-load.c
index 7ddb930ed..5647846e8 100644
--- a/gnucash/register/ledger-core/split-register-load.c
+++ b/gnucash/register/ledger-core/split-register-load.c
@@ -823,13 +823,11 @@ gnc_split_register_load_xfer_cells (SplitRegister *reg, Account *base_account)
store = gnc_get_shared_account_name_list_store (root, QKEY, skip_cb, NULL);
store_full = gnc_get_shared_account_name_list_store_full (root, QKEY, skip_cb, NULL);
- // The account cell
cell = (ComboCell *)
gnc_table_layout_get_cell (reg->table->layout, XFRM_CELL);
gnc_combo_cell_use_quickfill_cache (cell, qf);
gnc_combo_cell_use_list_store_cache (cell, store, store_full);
- // The transfer cell
cell = (ComboCell *)
gnc_table_layout_get_cell (reg->table->layout, MXFRM_CELL);
gnc_combo_cell_use_quickfill_cache (cell, qf);
diff --git a/gnucash/register/register-gnome/combocell-gnome.c b/gnucash/register/register-gnome/combocell-gnome.c
index 0e8269fcc..d383d6943 100644
--- a/gnucash/register/register-gnome/combocell-gnome.c
+++ b/gnucash/register/register-gnome/combocell-gnome.c
@@ -519,6 +519,58 @@ gnc_combo_cell_set_value (ComboCell *cell, const char *str)
gnc_basic_cell_set_value (&cell->cell, str);
}
+/* This function looks through full_store for a partial match with newval and returns the first
+ match (which must be subsequently freed). It fills out box->item_list with found matches */
+static gchar*
+gnc_combo_cell_type_ahead_search(const gchar* newval, GtkListStore* full_store, PopBox *box)
+{
+ gchar *case_normalized_newval = NULL;
+ GtkTreeIter iter;
+ gboolean valid;
+ gchar *normalized_newval = g_utf8_normalize (newval, -1, G_NORMALIZE_ALL);
+ int num_found=0;
+ gchar *first_found = NULL;
+ gchar *match_str = NULL;
+
+ if (normalized_newval)
+ case_normalized_newval = g_utf8_casefold (normalized_newval, -1);
+ valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(full_store), &iter);
+ // Clear result list.
+ gnc_item_list_clear(box->item_list);
+ while (valid)
+ {
+ static const gint MAX_NUM_MATCHES = 30;
+ gchar *str_data = NULL;
+ gchar* case_normalized_str_data = NULL;
+ gchar* normalized_str_data = NULL;
+ gchar* ret = NULL;
+ gtk_tree_model_get (GTK_TREE_MODEL(full_store), &iter,0, &str_data,-1);
+ normalized_str_data = g_utf8_normalize (str_data, -1, G_NORMALIZE_ALL);
+ if (normalized_str_data)
+ case_normalized_str_data = g_utf8_casefold (normalized_str_data, -1);
+ // Does case_normalized_str_data contain case_normalized_newval?
+ ret = g_strrstr(case_normalized_str_data, case_normalized_newval);
+ if(ret!=NULL)
+ {
+ if(!num_found) first_found = g_strdup(str_data);
+ ++num_found;
+ /* The pop box can be very slow to display if it has too many items and it's not very useful
+ to have many. So limit that to a reasonable number. */
+ if(num_found < MAX_NUM_MATCHES)
+ gnc_item_list_append (box->item_list, str_data);
+ }
+ g_free(str_data);
+ g_free(case_normalized_str_data);
+ g_free(normalized_str_data);
+ valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(full_store), &iter);
+ }
+ if(num_found)
+ match_str = first_found;
+ g_free(case_normalized_newval);
+ g_free(normalized_newval);
+ return match_str;
+}
+
static void
gnc_combo_cell_modify_verify (BasicCell *_cell,
const char *change,
@@ -531,14 +583,11 @@ gnc_combo_cell_modify_verify (BasicCell *_cell,
{
ComboCell *cell = (ComboCell *) _cell;
PopBox *box = cell->cell.gui_private;
- const char *match_str;
- QuickFill *match;
- gboolean pop_list;
+ gchar *match_str = NULL;
glong newval_chars;
glong change_chars;
- GtkListStore* the_store;
- int num_found=0;
- gchar *first_found = NULL;
+ GtkListStore* full_store;
+ const gchar *box_str = NULL;
newval_chars = g_utf8_strlen (newval, newval_len);
change_chars = g_utf8_strlen (change, change_len);
@@ -546,11 +595,9 @@ gnc_combo_cell_modify_verify (BasicCell *_cell,
if (box->in_list_select)
{
gnc_basic_cell_set_value_internal (_cell, newval);
-
*cursor_position = -1;
*start_selection = 0;
*end_selection = -1;
-
return;
}
@@ -567,95 +614,43 @@ gnc_combo_cell_modify_verify (BasicCell *_cell,
gnc_basic_cell_set_value_internal (_cell, newval);
return;
}
- // Legacy account name match.
- match = gnc_quickfill_get_string_match (box->qf, newval);
- match_str = gnc_quickfill_string (match);
- the_store = cell->shared_store_full;
if (type_ahead_search)
{
- // Type ahead account name match code.
- gchar *case_normalized_newval = NULL;
- GtkTreeIter iter;
- gboolean valid;
- gchar *normalized_newval = g_utf8_normalize (newval, -1, G_NORMALIZE_ALL);
- if (normalized_newval)
- case_normalized_newval = g_utf8_casefold (normalized_newval, -1);
- valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(the_store), &iter);
- // Clear result list.
- gnc_item_list_clear(box->item_list);
- while (valid)
- {
- static gint MAX_NUM_MATCHES = 30;
- gchar *str_data = NULL;
- gchar* case_normalized_str_data = NULL;
- gchar* normalized_str_data = NULL;
- gchar* ret = NULL;
- gtk_tree_model_get (GTK_TREE_MODEL(the_store), &iter,0, &str_data,-1);
- normalized_str_data = g_utf8_normalize (str_data, -1, G_NORMALIZE_ALL);
- if (normalized_str_data)
- case_normalized_str_data = g_utf8_casefold (normalized_str_data, -1);
- // Does case_normalized_str_data contain case_normalized_newval?
- ret = g_strrstr(case_normalized_str_data, case_normalized_newval);
- if(ret!=NULL)
- {
- // We have match.
- if(!num_found) first_found = g_strdup(str_data);
- ++num_found ;
- // The pop box can be very slow to display if it has too many items and it's not very useful
- // to have many. So limit that to a reasonable number.
- if(num_found < MAX_NUM_MATCHES)
- gnc_item_list_append (box->item_list, str_data);
- }
- g_free(str_data);
- g_free(case_normalized_str_data);
- g_free(normalized_str_data);
- valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(the_store), &iter);
- }
- if(!num_found)
- {
- match_str = NULL;
- }
- else
- {
- // This is probably wasteful.
- match = gnc_quickfill_get_string_match (box->qf, first_found);
- match_str = first_found;
- }
- g_free(case_normalized_newval);
- g_free(normalized_newval);
- }
-
- if ((!type_ahead_search && match == NULL) || (match_str == NULL))
- {
- gnc_basic_cell_set_value_internal (_cell, newval);
-
- block_list_signals (cell);
- gnc_item_list_select (box->item_list, NULL);
- unblock_list_signals (cell);
- return;
- }
-
- if(type_ahead_search)
- {
+ // Type-ahead search, we match any substring of the account name.
+ full_store = cell->shared_store_full;
+ match_str = gnc_combo_cell_type_ahead_search(newval, full_store, box);
*start_selection = newval_chars;
*end_selection = -1;
*cursor_position = newval_chars;
+ // Do not change the string in the type-in box.
+ box_str = newval;
}
else
{
- // For type-ahead, we let the user type freely.
+ QuickFill *match = NULL;
+ // Match at start of account name using the quickfill
+ match = gnc_quickfill_get_string_match (box->qf, newval);
+ match_str = g_strdup(gnc_quickfill_string (match));
*start_selection = newval_chars;
*end_selection = -1;
*cursor_position += change_chars;
+ // Update the string in the type-in box with the matched string.
+ box_str = match_str;
}
- if (!box->list_popped)
- pop_list = auto_pop_combos;
- else
- pop_list = FALSE;
+ if (match_str == NULL)
+ {
+ // No match. Remove any selection in popup, don't change the type-in box
+ gnc_basic_cell_set_value_internal (_cell, newval);
+ block_list_signals (cell);
+ gnc_item_list_select (box->item_list, NULL);
+ unblock_list_signals (cell);
+ g_free(match_str);
+ return;
+ }
- if (pop_list)
+ if (!box->list_popped && auto_pop_combos)
{
gnc_item_edit_show_popup (box->item_edit);
box->list_popped = TRUE;
@@ -665,16 +660,8 @@ gnc_combo_cell_modify_verify (BasicCell *_cell,
gnc_item_list_select (box->item_list, match_str);
unblock_list_signals (cell);
- if(!type_ahead_search)
- {
- gnc_basic_cell_set_value_internal (_cell, match_str);
- }
- else
- {
- // For type-ahead, don't change what the user typed.
- gnc_basic_cell_set_value_internal (_cell, newval);
- }
- g_free(first_found);
+ gnc_basic_cell_set_value_internal (_cell, box_str);
+ g_free(match_str);
}
static gboolean
commit 4cd059c80bce06c79b36f173d8c075060c34a7d9
Author: Jean Laroche <27791933+jeanlaroche at users.noreply.github.com>
Date: Fri Mar 13 21:03:11 2020 -0700
Implement look-ahead account name completion
Fix coding style etc
Fix travis error
Fix travis error
Remove no longer needed file
Improve the case-normalization to use utf8 functions
Restore mistakenly removed line, fix NULL pointers, improve tooltips
Make search still happen when deleting characters
Fix cosmetic and coding style issues
diff --git a/bindings/core-utils.i b/bindings/core-utils.i
index c86977067..8b2a796d1 100644
--- a/bindings/core-utils.i
+++ b/bindings/core-utils.i
@@ -124,6 +124,7 @@ gchar *gnc_locale_name (void);
SET_ENUM ("GNC-PREF-DATE-BACKMONTHS");
SET_ENUM ("GNC-PREF-SHOW-LEAF-ACCT-NAMES");
SET_ENUM ("GNC-PREF-ENTER-MOVES-TO-END");
+ SET_ENUM ("GNC-PREF-TYPE-AHEAD-SEARCH");
SET_ENUM ("GNC-PREF-DRAW-HOR-LINES");
SET_ENUM ("GNC-PREF-DRAW-VERT-LINES");
SET_ENUM ("GNC-PREF-ALT-COLOR-BY-TRANS");
diff --git a/gnucash/gnome-utils/account-quickfill.c b/gnucash/gnome-utils/account-quickfill.c
index 2d3d808fd..47596ad05 100644
--- a/gnucash/gnome-utils/account-quickfill.c
+++ b/gnucash/gnome-utils/account-quickfill.c
@@ -54,6 +54,9 @@ typedef struct
QuickFill *qf;
gboolean load_list_store;
GtkListStore *list_store;
+ // For the type-ahead search, we need two lists, list_store contains the accounts that
+ // match the search. list_store_full contain the original full list of accounts.
+ GtkListStore *list_store_full;
QofBook *book;
Account *root;
gint listener;
@@ -75,6 +78,7 @@ shared_quickfill_destroy (QofBook *book, gpointer key, gpointer user_data)
qfb);
gnc_quickfill_destroy (qfb->qf);
g_object_unref (qfb->list_store);
+ g_object_unref (qfb->list_store_full);
qof_event_unregister_handler (qfb->listener);
g_free (qfb);
}
@@ -120,6 +124,7 @@ load_shared_qf_cb (Account *account, gpointer data)
char *name;
GtkTreeIter iter;
+ // A callback to disable adding the account
if (qfb->dont_add_cb)
{
gboolean skip = (qfb->dont_add_cb) (account, qfb->dont_add_data);
@@ -138,6 +143,11 @@ load_shared_qf_cb (Account *account, gpointer data)
ACCOUNT_NAME, name,
ACCOUNT_POINTER, account,
-1);
+ gtk_list_store_append (qfb->list_store_full, &iter);
+ gtk_list_store_set (qfb->list_store_full, &iter,
+ ACCOUNT_NAME, name,
+ ACCOUNT_POINTER, account,
+ -1);
}
g_free (name);
}
@@ -151,6 +161,7 @@ shared_quickfill_pref_changed (gpointer prefs, gchar *pref, gpointer user_data)
/* Reload the quickfill */
gnc_quickfill_purge (qfb->qf);
gtk_list_store_clear (qfb->list_store);
+ gtk_list_store_clear (qfb->list_store_full);
qfb->load_list_store = TRUE;
gnc_account_foreach_descendant (qfb->root, load_shared_qf_cb, qfb);
qfb->load_list_store = FALSE;
@@ -174,7 +185,9 @@ build_shared_quickfill (QofBook *book, Account *root, const char * key,
qfb->dont_add_cb = cb;
qfb->dont_add_data = data;
qfb->load_list_store = TRUE;
- qfb->list_store = gtk_list_store_new (NUM_ACCOUNT_COLUMNS,
+ qfb->list_store = gtk_list_store_new (NUM_ACCOUNT_COLUMNS,
+ G_TYPE_STRING, G_TYPE_POINTER);
+ qfb->list_store_full = gtk_list_store_new (NUM_ACCOUNT_COLUMNS,
G_TYPE_STRING, G_TYPE_POINTER);
gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL,
@@ -231,6 +244,23 @@ gnc_get_shared_account_name_list_store (Account *root, const char * key,
return qfb->list_store;
}
+GtkListStore *
+gnc_get_shared_account_name_list_store_full (Account *root, const char * key,
+ AccountBoolCB cb, gpointer cb_data)
+{
+ QFB *qfb;
+ QofBook *book;
+
+ book = gnc_account_get_book (root);
+ qfb = qof_book_get_data (book, key);
+
+ if (qfb)
+ return qfb->list_store_full;
+
+ qfb = build_shared_quickfill (book, root, key, cb, cb_data);
+ return qfb->list_store_full;
+}
+
/* Since we are maintaining a 'global' quickfill list, we need to
* update it whenever the user creates a new account. So listen
* for account modification events, and add new accounts.
@@ -249,6 +279,7 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
find_data data = { 0 };
GtkTreePath *path;
GList *tmp;
+ gboolean valid;
if (0 == (event_type & (QOF_EVENT_MODIFY | QOF_EVENT_ADD | QOF_EVENT_REMOVE)))
return;
@@ -282,7 +313,7 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
* full name of all these accounts has changed. */
data.accounts = gnc_account_get_descendants (account);
data.accounts = g_list_prepend (data.accounts, account);
- gtk_tree_model_foreach (GTK_TREE_MODEL(qfb->list_store),
+ gtk_tree_model_foreach (GTK_TREE_MODEL(qfb->list_store_full),
shared_quickfill_find_accounts, &data);
/* Update the existing items in the list store. Its possible
@@ -294,14 +325,14 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
gchar *old_name, *new_name;
path = gtk_tree_row_reference_get_path (tmp->data);
gtk_tree_row_reference_free (tmp->data);
- if (!gtk_tree_model_get_iter (GTK_TREE_MODEL(qfb->list_store),
+ if (!gtk_tree_model_get_iter (GTK_TREE_MODEL(qfb->list_store_full),
&iter, path))
{
gtk_tree_path_free (path);
continue;
}
gtk_tree_path_free (path);
- gtk_tree_model_get (GTK_TREE_MODEL(qfb->list_store), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL(qfb->list_store_full), &iter,
ACCOUNT_POINTER, &account,
ACCOUNT_NAME, &old_name,
-1);
@@ -309,6 +340,7 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
new_name = gnc_get_account_name_for_register (account);
/* check if the name has changed */
+
match = gnc_quickfill_get_string_match (qf, old_name);
if (match && (g_strcmp0 (old_name, new_name) != 0))
gnc_quickfill_remove (qf, old_name, QUICKFILL_ALPHA);
@@ -317,12 +349,12 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
qfb->dont_add_cb (account, qfb->dont_add_data))
{
gnc_quickfill_remove (qf, new_name, QUICKFILL_ALPHA);
- gtk_list_store_remove (qfb->list_store, &iter);
+ gtk_list_store_remove (qfb->list_store_full, &iter);
}
else
{
gnc_quickfill_insert (qf, new_name, QUICKFILL_ALPHA);
- gtk_list_store_set (qfb->list_store, &iter,
+ gtk_list_store_set (qfb->list_store_full, &iter,
ACCOUNT_NAME, new_name,
-1);
}
@@ -344,8 +376,8 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
}
}
gnc_quickfill_insert (qf, name, QUICKFILL_ALPHA);
- gtk_list_store_append (qfb->list_store, &iter);
- gtk_list_store_set (qfb->list_store, &iter,
+ gtk_list_store_append (qfb->list_store_full, &iter);
+ gtk_list_store_set (qfb->list_store_full, &iter,
ACCOUNT_NAME, name,
ACCOUNT_POINTER, account,
-1);
@@ -360,7 +392,7 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
/* Does the account exist in the model? */
data.accounts = g_list_append (NULL, account);
- gtk_tree_model_foreach (GTK_TREE_MODEL(qfb->list_store),
+ gtk_tree_model_foreach (GTK_TREE_MODEL(qfb->list_store_full),
shared_quickfill_find_accounts, &data);
/* Remove from list store */
@@ -368,10 +400,10 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
{
path = gtk_tree_row_reference_get_path (tmp->data);
gtk_tree_row_reference_free (tmp->data);
- if (gtk_tree_model_get_iter (GTK_TREE_MODEL(qfb->list_store),
+ if (gtk_tree_model_get_iter (GTK_TREE_MODEL(qfb->list_store_full),
&iter, path))
{
- gtk_list_store_remove (qfb->list_store, &iter);
+ gtk_list_store_remove (qfb->list_store_full, &iter);
}
gtk_tree_path_free (path);
}
@@ -384,6 +416,7 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
qfb->dont_add_cb (account, qfb->dont_add_data))
break;
+
match = gnc_quickfill_get_string_match (qf, name);
if (match)
{
@@ -397,8 +430,8 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
PINFO ("insert new account %s into qf=%p", name, qf);
gnc_quickfill_insert (qf, name, QUICKFILL_ALPHA);
- gtk_list_store_append (qfb->list_store, &iter);
- gtk_list_store_set (qfb->list_store, &iter,
+ gtk_list_store_append (qfb->list_store_full, &iter);
+ gtk_list_store_set (qfb->list_store_full, &iter,
ACCOUNT_NAME, name,
ACCOUNT_POINTER, account,
-1);
@@ -408,6 +441,22 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
DEBUG("other %s", name);
break;
}
+ /* Now that qfb->list_store_full has been updated, qfb->list_store also needs to be updated in
+ case we're using the regular search. */
+ gtk_list_store_clear(qfb->list_store);
+
+ g_debug("Replicate shared_store_full\n");
+ valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(qfb->list_store_full), &iter);
+ while (valid)
+ {
+ gchar *str_data = NULL;
+ GtkTreeIter iter2;
+ gtk_tree_model_get (GTK_TREE_MODEL(qfb->list_store_full), &iter,0, &str_data,-1);
+ gtk_list_store_append(qfb->list_store, &iter2);
+ gtk_list_store_set(qfb->list_store, &iter2, 0, str_data, -1);
+ valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(qfb->list_store_full), &iter);
+ g_free(str_data);
+ }
if (data.accounts)
g_list_free (data.accounts);
diff --git a/gnucash/gnome-utils/account-quickfill.h b/gnucash/gnome-utils/account-quickfill.h
index a9a280acd..ab6c92d3f 100644
--- a/gnucash/gnome-utils/account-quickfill.h
+++ b/gnucash/gnome-utils/account-quickfill.h
@@ -74,6 +74,9 @@ gnc_get_shared_account_name_quickfill (Account *root, const char * key,
GtkListStore *
gnc_get_shared_account_name_list_store (Account *root, const char * key,
AccountBoolCB cb, gpointer cb_data);
+GtkListStore *
+gnc_get_shared_account_name_list_store_full (Account *root, const char * key,
+ AccountBoolCB cb, gpointer cb_data);
#endif
diff --git a/gnucash/gschemas/org.gnucash.gschema.xml.in b/gnucash/gschemas/org.gnucash.gschema.xml.in
index 9d95809d5..0430be555 100644
--- a/gnucash/gschemas/org.gnucash.gschema.xml.in
+++ b/gnucash/gschemas/org.gnucash.gschema.xml.in
@@ -245,6 +245,11 @@
<summary>"Enter" key moves to bottom of register</summary>
<description>If active, pressing the enter key will move to the bottom of the register. Otherwise pressing the enter key will move to the next transaction line.</description>
</key>
+ <key name="type-ahead-search" type="b">
+ <default>false</default>
+ <summary>Ues type-ahead search</summary>
+ <description>If active, account name completion matches any substring of the account name.</description>
+ </key>
<key name="auto-raise-lists" type="b">
<default>true</default>
<summary>Automatically raise the list of accounts or actions during input</summary>
diff --git a/gnucash/gtkbuilder/dialog-preferences.glade b/gnucash/gtkbuilder/dialog-preferences.glade
index 4d95fc8da..90c977f8a 100644
--- a/gnucash/gtkbuilder/dialog-preferences.glade
+++ b/gnucash/gtkbuilder/dialog-preferences.glade
@@ -2021,6 +2021,25 @@ many months before the current month:</property>
<property name="top_attach">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="pref/general.register/type-ahead-search">
+ <property name="label" translatable="yes">_Use type ahead</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_markup">Use the type-ahead search for accounts: In normal search mode, the typed string has to match the beginning of the full account name (including its parent account names), in time-ahead, the typed string can match any substream of the account name.</property>
+ <property name="tooltip_text" translatable="yes">Use the type-ahead search for accounts: In normal search mode, the typed string has to match the beginning of full account name (including its parent account names), in time-ahead, the typed string can match any substream of the account name.</property>
+ <property name="halign">start</property>
+ <property name="margin_left">12</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
<child>
<object class="GtkCheckButton" id="pref/general.register/auto-raise-lists">
<property name="label" translatable="yes">_Auto-raise lists</property>
@@ -2037,7 +2056,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
</packing>
</child>
<child>
@@ -2056,7 +2075,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">4</property>
</packing>
</child>
<child>
@@ -2066,7 +2085,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
</packing>
</child>
<child>
@@ -2079,7 +2098,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">5</property>
+ <property name="top_attach">6</property>
</packing>
</child>
<child>
@@ -2098,7 +2117,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">6</property>
+ <property name="top_attach">7</property>
</packing>
</child>
<child>
@@ -2117,7 +2136,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">7</property>
+ <property name="top_attach">8</property>
</packing>
</child>
<child>
@@ -2136,7 +2155,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">8</property>
+ <property name="top_attach">9</property>
</packing>
</child>
<child>
@@ -2155,7 +2174,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">9</property>
+ <property name="top_attach">10</property>
</packing>
</child>
<child>
@@ -2165,7 +2184,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">10</property>
+ <property name="top_attach">11</property>
</packing>
</child>
<child>
@@ -2178,7 +2197,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">11</property>
+ <property name="top_attach">12</property>
</packing>
</child>
<child>
@@ -2197,7 +2216,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">12</property>
+ <property name="top_attach">13</property>
</packing>
</child>
<child>
@@ -2216,7 +2235,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">13</property>
+ <property name="top_attach">14</property>
</packing>
</child>
<child>
@@ -2235,7 +2254,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">14</property>
+ <property name="top_attach">15</property>
</packing>
</child>
<child>
@@ -2254,7 +2273,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">15</property>
+ <property name="top_attach">16</property>
</packing>
</child>
<child>
@@ -2264,7 +2283,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">16</property>
+ <property name="top_attach">17</property>
</packing>
</child>
<child>
@@ -2277,7 +2296,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">17</property>
+ <property name="top_attach">18</property>
</packing>
</child>
<child>
@@ -2296,7 +2315,7 @@ many months before the current month:</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">18</property>
+ <property name="top_attach">19</property>
</packing>
</child>
</object>
diff --git a/gnucash/register/ledger-core/gncEntryLedgerLoad.c b/gnucash/register/ledger-core/gncEntryLedgerLoad.c
index ac8b94cec..cb1dc6f13 100644
--- a/gnucash/register/ledger-core/gncEntryLedgerLoad.c
+++ b/gnucash/register/ledger-core/gncEntryLedgerLoad.c
@@ -195,6 +195,7 @@ load_xfer_type_cells (GncEntryLedger *ledger)
ComboCell *cell;
QuickFill *qf = NULL;
GtkListStore *store = NULL;
+ GtkListStore *store_full = NULL;
root = gnc_book_get_root_account (ledger->book);
if (root == NULL) return;
@@ -215,6 +216,8 @@ load_xfer_type_cells (GncEntryLedger *ledger)
skip_expense_acct_cb, NULL);
store = gnc_get_shared_account_name_list_store (root, IKEY,
skip_expense_acct_cb, NULL);
+ store_full = gnc_get_shared_account_name_list_store_full (root, IKEY,
+ skip_expense_acct_cb, NULL);
break;
case GNCENTRY_BILL_ENTRY:
@@ -230,6 +233,8 @@ load_xfer_type_cells (GncEntryLedger *ledger)
skip_income_acct_cb, NULL);
store = gnc_get_shared_account_name_list_store (root, EKEY,
skip_income_acct_cb, NULL);
+ store_full = gnc_get_shared_account_name_list_store_full (root, EKEY,
+ skip_income_acct_cb, NULL);
break;
default:
PWARN ("Bad GncEntryLedgerType");
@@ -239,12 +244,12 @@ load_xfer_type_cells (GncEntryLedger *ledger)
cell = (ComboCell *)
gnc_table_layout_get_cell (ledger->table->layout, ENTRY_IACCT_CELL);
gnc_combo_cell_use_quickfill_cache (cell, qf);
- gnc_combo_cell_use_list_store_cache (cell, store);
+ gnc_combo_cell_use_list_store_cache (cell, store, store_full);
cell = (ComboCell *)
gnc_table_layout_get_cell (ledger->table->layout, ENTRY_BACCT_CELL);
gnc_combo_cell_use_quickfill_cache (cell, qf);
- gnc_combo_cell_use_list_store_cache (cell, store);
+ gnc_combo_cell_use_list_store_cache (cell, store, store_full);
}
/* ===================================================================== */
diff --git a/gnucash/register/ledger-core/split-register-load.c b/gnucash/register/ledger-core/split-register-load.c
index 37e90fb9b..7ddb930ed 100644
--- a/gnucash/register/ledger-core/split-register-load.c
+++ b/gnucash/register/ledger-core/split-register-load.c
@@ -810,6 +810,7 @@ gnc_split_register_load_xfer_cells (SplitRegister *reg, Account *base_account)
QuickFill *qf;
ComboCell *cell;
GtkListStore *store;
+ GtkListStore *store_full;
if (base_account)
root = gnc_account_get_root(base_account);
@@ -820,16 +821,19 @@ gnc_split_register_load_xfer_cells (SplitRegister *reg, Account *base_account)
qf = gnc_get_shared_account_name_quickfill (root, QKEY, skip_cb, NULL);
store = gnc_get_shared_account_name_list_store (root, QKEY, skip_cb, NULL);
+ store_full = gnc_get_shared_account_name_list_store_full (root, QKEY, skip_cb, NULL);
+ // The account cell
cell = (ComboCell *)
gnc_table_layout_get_cell (reg->table->layout, XFRM_CELL);
gnc_combo_cell_use_quickfill_cache (cell, qf);
- gnc_combo_cell_use_list_store_cache (cell, store);
+ gnc_combo_cell_use_list_store_cache (cell, store, store_full);
+ // The transfer cell
cell = (ComboCell *)
gnc_table_layout_get_cell (reg->table->layout, MXFRM_CELL);
gnc_combo_cell_use_quickfill_cache (cell, qf);
- gnc_combo_cell_use_list_store_cache (cell, store);
+ gnc_combo_cell_use_list_store_cache (cell, store, store_full);
}
/* ====================== END OF FILE ================================== */
diff --git a/gnucash/register/register-core/combocell.h b/gnucash/register/register-core/combocell.h
index 80175293c..ddaaf8880 100644
--- a/gnucash/register/register-core/combocell.h
+++ b/gnucash/register/register-core/combocell.h
@@ -49,6 +49,7 @@ typedef struct
{
BasicCell cell;
gpointer shared_store;
+ gpointer shared_store_full;
} ComboCell;
@@ -98,8 +99,7 @@ void gnc_combo_cell_set_autosize (ComboCell *cell, gboolean autosize);
* quickfill object. The combocell will *not* make a copy of the quickfill.
*/
void gnc_combo_cell_use_quickfill_cache (ComboCell *cell, QuickFill *shared_qf);
-
-void gnc_combo_cell_use_list_store_cache (ComboCell * cell, gpointer data);
+void gnc_combo_cell_use_list_store_cache (ComboCell * cell, gpointer data, gpointer data2);
/** @} */
#endif
diff --git a/gnucash/register/register-gnome/combocell-gnome.c b/gnucash/register/register-gnome/combocell-gnome.c
index ba9505d38..0e8269fcc 100644
--- a/gnucash/register/register-gnome/combocell-gnome.c
+++ b/gnucash/register/register-gnome/combocell-gnome.c
@@ -87,8 +87,10 @@ static void gnc_combo_cell_destroy (BasicCell *bcell);
static GOnce auto_pop_init_once = G_ONCE_INIT;
static gboolean auto_pop_combos = FALSE;
+static gboolean type_ahead_search = FALSE;
+// Two Callbacks called when the user changes preferences
static void
gnc_combo_cell_set_autopop (gpointer prefs, gchar *pref, gpointer user_data)
{
@@ -96,19 +98,33 @@ gnc_combo_cell_set_autopop (gpointer prefs, gchar *pref, gpointer user_data)
GNC_PREF_AUTO_RAISE_LISTS);
}
+static void
+gnc_combo_cell_set_type_ahead_search (gpointer prefs, gchar *pref, gpointer user_data)
+{
+ type_ahead_search = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER,
+ GNC_PREF_TYPE_AHEAD_SEARCH);
+}
+
static gpointer
gnc_combo_cell_autopop_init (gpointer unused)
{
gulong id;
auto_pop_combos = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER,
GNC_PREF_AUTO_RAISE_LISTS);
+
+ type_ahead_search = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER,
+ GNC_PREF_TYPE_AHEAD_SEARCH);
+ // Register callbacks for when the user changes preferences.
id = gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL_REGISTER,
- GNC_PREF_AUTO_RAISE_LISTS,
- gnc_combo_cell_set_autopop,
- NULL);
-
+ GNC_PREF_AUTO_RAISE_LISTS,
+ gnc_combo_cell_set_autopop,
+ NULL);
gnc_prefs_set_reg_auto_raise_lists_id (id);
+ gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL_REGISTER,
+ GNC_PREF_TYPE_AHEAD_SEARCH,
+ gnc_combo_cell_set_type_ahead_search,
+ NULL);
return NULL;
}
@@ -150,6 +166,7 @@ gnc_combo_cell_init (ComboCell *cell)
box->list_popped = FALSE;
box->autosize = FALSE;
+ cell->shared_store_full = NULL;
cell->cell.gui_private = box;
box->qf = gnc_quickfill_new ();
@@ -407,11 +424,12 @@ gnc_combo_cell_use_quickfill_cache (ComboCell * cell, QuickFill *shared_qf)
}
void
-gnc_combo_cell_use_list_store_cache (ComboCell * cell, gpointer data)
+gnc_combo_cell_use_list_store_cache (ComboCell * cell, gpointer data, gpointer data_full)
{
if (cell == NULL) return;
cell->shared_store = data;
+ cell->shared_store_full = data_full;
}
void
@@ -518,6 +536,9 @@ gnc_combo_cell_modify_verify (BasicCell *_cell,
gboolean pop_list;
glong newval_chars;
glong change_chars;
+ GtkListStore* the_store;
+ int num_found=0;
+ gchar *first_found = NULL;
newval_chars = g_utf8_strlen (newval, newval_len);
change_chars = g_utf8_strlen (change, change_len);
@@ -534,37 +555,100 @@ gnc_combo_cell_modify_verify (BasicCell *_cell,
}
/* If deleting, just accept */
- if (change == NULL)
+ if (change == NULL && !type_ahead_search)
{
gnc_basic_cell_set_value_internal (_cell, newval);
return;
}
/* If we are inserting in the middle, just accept */
- if (*cursor_position < _cell->value_chars)
+ if (*cursor_position < _cell->value_chars && !type_ahead_search)
{
gnc_basic_cell_set_value_internal (_cell, newval);
return;
}
-
+ // Legacy account name match.
match = gnc_quickfill_get_string_match (box->qf, newval);
-
match_str = gnc_quickfill_string (match);
+ the_store = cell->shared_store_full;
+
+ if (type_ahead_search)
+ {
+ // Type ahead account name match code.
+ gchar *case_normalized_newval = NULL;
+ GtkTreeIter iter;
+ gboolean valid;
+ gchar *normalized_newval = g_utf8_normalize (newval, -1, G_NORMALIZE_ALL);
+ if (normalized_newval)
+ case_normalized_newval = g_utf8_casefold (normalized_newval, -1);
+ valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(the_store), &iter);
+ // Clear result list.
+ gnc_item_list_clear(box->item_list);
+ while (valid)
+ {
+ static gint MAX_NUM_MATCHES = 30;
+ gchar *str_data = NULL;
+ gchar* case_normalized_str_data = NULL;
+ gchar* normalized_str_data = NULL;
+ gchar* ret = NULL;
+ gtk_tree_model_get (GTK_TREE_MODEL(the_store), &iter,0, &str_data,-1);
+ normalized_str_data = g_utf8_normalize (str_data, -1, G_NORMALIZE_ALL);
+ if (normalized_str_data)
+ case_normalized_str_data = g_utf8_casefold (normalized_str_data, -1);
+ // Does case_normalized_str_data contain case_normalized_newval?
+ ret = g_strrstr(case_normalized_str_data, case_normalized_newval);
+ if(ret!=NULL)
+ {
+ // We have match.
+ if(!num_found) first_found = g_strdup(str_data);
+ ++num_found ;
+ // The pop box can be very slow to display if it has too many items and it's not very useful
+ // to have many. So limit that to a reasonable number.
+ if(num_found < MAX_NUM_MATCHES)
+ gnc_item_list_append (box->item_list, str_data);
+ }
+ g_free(str_data);
+ g_free(case_normalized_str_data);
+ g_free(normalized_str_data);
+ valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(the_store), &iter);
+ }
+ if(!num_found)
+ {
+ match_str = NULL;
+ }
+ else
+ {
+ // This is probably wasteful.
+ match = gnc_quickfill_get_string_match (box->qf, first_found);
+ match_str = first_found;
+ }
+ g_free(case_normalized_newval);
+ g_free(normalized_newval);
+ }
- if ((match == NULL) || (match_str == NULL))
+ if ((!type_ahead_search && match == NULL) || (match_str == NULL))
{
gnc_basic_cell_set_value_internal (_cell, newval);
block_list_signals (cell);
gnc_item_list_select (box->item_list, NULL);
unblock_list_signals (cell);
-
return;
}
- *start_selection = newval_chars;
- *end_selection = -1;
- *cursor_position += change_chars;
+ if(type_ahead_search)
+ {
+ *start_selection = newval_chars;
+ *end_selection = -1;
+ *cursor_position = newval_chars;
+ }
+ else
+ {
+ // For type-ahead, we let the user type freely.
+ *start_selection = newval_chars;
+ *end_selection = -1;
+ *cursor_position += change_chars;
+ }
if (!box->list_popped)
pop_list = auto_pop_combos;
@@ -581,7 +665,16 @@ gnc_combo_cell_modify_verify (BasicCell *_cell,
gnc_item_list_select (box->item_list, match_str);
unblock_list_signals (cell);
- gnc_basic_cell_set_value_internal (_cell, match_str);
+ if(!type_ahead_search)
+ {
+ gnc_basic_cell_set_value_internal (_cell, match_str);
+ }
+ else
+ {
+ // For type-ahead, don't change what the user typed.
+ gnc_basic_cell_set_value_internal (_cell, newval);
+ }
+ g_free(first_found);
}
static gboolean
diff --git a/gnucash/register/register-gnome/gnucash-item-list.c b/gnucash/register/register-gnome/gnucash-item-list.c
index f8834eb03..819cfb3cd 100644
--- a/gnucash/register/register-gnome/gnucash-item-list.c
+++ b/gnucash/register/register-gnome/gnucash-item-list.c
@@ -89,7 +89,6 @@ gnc_item_list_append (GncItemList *item_list, const char *string)
g_return_if_fail(IS_GNC_ITEM_LIST(item_list));
g_return_if_fail(item_list->list_store != NULL);
g_return_if_fail(string != NULL);
-
gtk_list_store_append (item_list->list_store, &iter);
gtk_list_store_set (item_list->list_store, &iter, 0, string, -1);
}
@@ -317,6 +316,7 @@ gnc_item_list_key_event (GtkWidget *widget, GdkEventKey *event, gpointer data)
gnc_item_list_signals[ACTIVATE_ITEM],
0,
string);
+ g_signal_emit (G_OBJECT (item_list), gnc_item_list_signals[CHANGE_ITEM], 0, string);
g_free(string);
return TRUE;
diff --git a/libgnucash/core-utils/gnc-prefs.h b/libgnucash/core-utils/gnc-prefs.h
index b18d1e079..a125a10b1 100644
--- a/libgnucash/core-utils/gnc-prefs.h
+++ b/libgnucash/core-utils/gnc-prefs.h
@@ -71,6 +71,7 @@
#define GNC_PREF_DATE_BACKMONTHS "date-backmonths"
#define GNC_PREF_SHOW_LEAF_ACCT_NAMES "show-leaf-account-names"
#define GNC_PREF_ENTER_MOVES_TO_END "enter-moves-to-end"
+#define GNC_PREF_TYPE_AHEAD_SEARCH "type-ahead-search"
/* Register preferences */
#define GNC_PREF_DRAW_HOR_LINES "draw-horizontal-lines"
#define GNC_PREF_DRAW_VERT_LINES "draw-vertical-lines"
Summary of changes:
gnucash/gnome-utils/account-quickfill.c | 193 +++++----
gnucash/gnome-utils/account-quickfill.h | 13 +-
gnucash/register/ledger-core/gncEntryLedgerLoad.c | 168 ++++----
gnucash/register/ledger-core/split-register-load.c | 348 ++++++++--------
gnucash/register/register-core/combocell.h | 37 +-
gnucash/register/register-gnome/combocell-gnome.c | 441 ++++++++++++---------
.../register/register-gnome/gnucash-item-list.c | 236 +++++------
7 files changed, 792 insertions(+), 644 deletions(-)
More information about the gnucash-changes
mailing list