Change some spacing in source files account-quickfill.*

This commit is contained in:
Robert Fewell 2020-01-09 14:49:25 +00:00
parent 936e2bf371
commit 5bfef54d6d
2 changed files with 73 additions and 75 deletions

View File

@ -74,7 +74,7 @@ shared_quickfill_destroy (QofBook *book, gpointer key, gpointer user_data)
shared_quickfill_pref_changed, shared_quickfill_pref_changed,
qfb); qfb);
gnc_quickfill_destroy (qfb->qf); gnc_quickfill_destroy (qfb->qf);
g_object_unref(qfb->list_store); g_object_unref (qfb->list_store);
qof_event_unregister_handler (qfb->listener); qof_event_unregister_handler (qfb->listener);
g_free (qfb); g_free (qfb);
} }
@ -97,18 +97,17 @@ shared_quickfill_find_accounts (GtkTreeModel *model,
GtkTreeRowReference* ref; GtkTreeRowReference* ref;
GList *tmp; GList *tmp;
gtk_tree_model_get(model, iter, ACCOUNT_POINTER, &account, -1); gtk_tree_model_get (model, iter, ACCOUNT_POINTER, &account, -1);
for (tmp = data->accounts; tmp; tmp = g_list_next(tmp)) for (tmp = data->accounts; tmp; tmp = g_list_next (tmp))
{ {
if (tmp->data == account) if (tmp->data == account)
{ {
ref = gtk_tree_row_reference_new(model, path); ref = gtk_tree_row_reference_new (model, path);
data->refs = g_list_append(data->refs, ref); data->refs = g_list_append (data->refs, ref);
data->accounts = g_list_remove_link(data->accounts, tmp); data->accounts = g_list_remove_link (data->accounts, tmp);
return (data->accounts == NULL); return (data->accounts == NULL);
} }
} }
return FALSE; return FALSE;
} }
@ -124,11 +123,13 @@ load_shared_qf_cb (Account *account, gpointer data)
if (qfb->dont_add_cb) if (qfb->dont_add_cb)
{ {
gboolean skip = (qfb->dont_add_cb) (account, qfb->dont_add_data); gboolean skip = (qfb->dont_add_cb) (account, qfb->dont_add_data);
if (skip) return; if (skip)
return;
} }
name = gnc_get_account_name_for_register (account); name = gnc_get_account_name_for_register (account);
if (NULL == name) return; if (NULL == name)
return;
gnc_quickfill_insert (qfb->qf, name, QUICKFILL_ALPHA); gnc_quickfill_insert (qfb->qf, name, QUICKFILL_ALPHA);
if (qfb->load_list_store) if (qfb->load_list_store)
{ {
@ -138,7 +139,7 @@ load_shared_qf_cb (Account *account, gpointer data)
ACCOUNT_POINTER, account, ACCOUNT_POINTER, account,
-1); -1);
} }
g_free(name); g_free (name);
} }
@ -148,10 +149,10 @@ shared_quickfill_pref_changed (gpointer prefs, gchar *pref, gpointer user_data)
QFB *qfb = user_data; QFB *qfb = user_data;
/* Reload the quickfill */ /* Reload the quickfill */
gnc_quickfill_purge(qfb->qf); gnc_quickfill_purge (qfb->qf);
gtk_list_store_clear(qfb->list_store); gtk_list_store_clear (qfb->list_store);
qfb->load_list_store = TRUE; qfb->load_list_store = TRUE;
gnc_account_foreach_descendant(qfb->root, load_shared_qf_cb, qfb); gnc_account_foreach_descendant (qfb->root, load_shared_qf_cb, qfb);
qfb->load_list_store = FALSE; qfb->load_list_store = FALSE;
} }
@ -165,7 +166,7 @@ build_shared_quickfill (QofBook *book, Account *root, const char * key,
{ {
QFB *qfb; QFB *qfb;
qfb = g_new0(QFB, 1); qfb = g_new0 (QFB, 1);
qfb->qf = gnc_quickfill_new (); qfb->qf = gnc_quickfill_new ();
qfb->book = book; qfb->book = book;
qfb->root = root; qfb->root = root;
@ -173,8 +174,8 @@ build_shared_quickfill (QofBook *book, Account *root, const char * key,
qfb->dont_add_cb = cb; qfb->dont_add_cb = cb;
qfb->dont_add_data = data; qfb->dont_add_data = data;
qfb->load_list_store = TRUE; qfb->load_list_store = TRUE;
qfb->list_store = qfb->list_store = gtk_list_store_new (NUM_ACCOUNT_COLUMNS,
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_prefs_register_cb (GNC_PREFS_GROUP_GENERAL,
GNC_PREF_ACCOUNT_SEPARATOR, GNC_PREF_ACCOUNT_SEPARATOR,
@ -186,11 +187,10 @@ build_shared_quickfill (QofBook *book, Account *root, const char * key,
shared_quickfill_pref_changed, shared_quickfill_pref_changed,
qfb); qfb);
gnc_account_foreach_descendant(root, load_shared_qf_cb, qfb); gnc_account_foreach_descendant (root, load_shared_qf_cb, qfb);
qfb->load_list_store = FALSE; qfb->load_list_store = FALSE;
qfb->listener = qfb->listener = qof_event_register_handler (listen_for_account_events, qfb);
qof_event_register_handler (listen_for_account_events, qfb);
qof_book_set_data_fin (book, key, qfb, shared_quickfill_destroy); qof_book_set_data_fin (book, key, qfb, shared_quickfill_destroy);
@ -198,8 +198,7 @@ build_shared_quickfill (QofBook *book, Account *root, const char * key,
} }
QuickFill * QuickFill *
gnc_get_shared_account_name_quickfill (Account *root, gnc_get_shared_account_name_quickfill (Account *root, const char * key,
const char * key,
AccountBoolCB cb, gpointer cb_data) AccountBoolCB cb, gpointer cb_data)
{ {
QFB *qfb; QFB *qfb;
@ -208,15 +207,15 @@ gnc_get_shared_account_name_quickfill (Account *root,
book = gnc_account_get_book (root); book = gnc_account_get_book (root);
qfb = qof_book_get_data (book, key); qfb = qof_book_get_data (book, key);
if (qfb) return qfb->qf; if (qfb)
return qfb->qf;
qfb = build_shared_quickfill (book, root, key, cb, cb_data); qfb = build_shared_quickfill (book, root, key, cb, cb_data);
return qfb->qf; return qfb->qf;
} }
GtkListStore * GtkListStore *
gnc_get_shared_account_name_list_store (Account *root, gnc_get_shared_account_name_list_store (Account *root, const char * key,
const char * key,
AccountBoolCB cb, gpointer cb_data) AccountBoolCB cb, gpointer cb_data)
{ {
QFB *qfb; QFB *qfb;
@ -225,7 +224,8 @@ gnc_get_shared_account_name_list_store (Account *root,
book = gnc_account_get_book (root); book = gnc_account_get_book (root);
qfb = qof_book_get_data (book, key); qfb = qof_book_get_data (book, key);
if (qfb) return qfb->list_store; if (qfb)
return qfb->list_store;
qfb = build_shared_quickfill (book, root, key, cb, cb_data); qfb = build_shared_quickfill (book, root, key, cb, cb_data);
return qfb->list_store; return qfb->list_store;
@ -253,9 +253,9 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
if (0 == (event_type & (QOF_EVENT_MODIFY | QOF_EVENT_ADD | QOF_EVENT_REMOVE))) if (0 == (event_type & (QOF_EVENT_MODIFY | QOF_EVENT_ADD | QOF_EVENT_REMOVE)))
return; return;
if (!GNC_IS_ACCOUNT (entity)) if (!GNC_IS_ACCOUNT(entity))
return; return;
account = GNC_ACCOUNT (entity); account = GNC_ACCOUNT(entity);
ENTER("entity %p, event type %x, user data %p, ecent data %p", ENTER("entity %p, event type %x, user data %p, ecent data %p",
entity, event_type, user_data, event_data); entity, event_type, user_data, event_data);
@ -266,7 +266,7 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
return; return;
} }
name = gnc_get_account_name_for_register(account); name = gnc_get_account_name_for_register (account);
if (NULL == name) if (NULL == name)
{ {
LEAVE("account has no name"); LEAVE("account has no name");
@ -280,33 +280,33 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
/* Find the account (and all its descendants) in the model. The /* Find the account (and all its descendants) in the model. The
* full name of all these accounts has changed. */ * full name of all these accounts has changed. */
data.accounts = gnc_account_get_descendants(account); data.accounts = gnc_account_get_descendants (account);
data.accounts = g_list_prepend(data.accounts, 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),
shared_quickfill_find_accounts, &data); shared_quickfill_find_accounts, &data);
/* Update the existing items in the list store. Its possible /* Update the existing items in the list store. Its possible
* that the change has caused an existing item to now become * that the change has caused an existing item to now become
* hidden, in which case it needs to be removed from the list * hidden, in which case it needs to be removed from the list
* store. Otherwise its a simple update of the name string. */ * store. Otherwise its a simple update of the name string. */
for (tmp = data.refs; tmp; tmp = g_list_next(tmp)) 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); path = gtk_tree_row_reference_get_path (tmp->data);
gtk_tree_row_reference_free(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),
&iter, path)) &iter, path))
{ {
gtk_tree_path_free(path); gtk_tree_path_free (path);
continue; continue;
} }
gtk_tree_path_free(path); 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), &iter,
ACCOUNT_POINTER, &account, ACCOUNT_POINTER, &account,
ACCOUNT_NAME, &old_name, ACCOUNT_NAME, &old_name,
-1); -1);
new_name = gnc_get_account_name_for_register(account); new_name = gnc_get_account_name_for_register (account);
/* check if the name has changed */ /* check if the name has changed */
match = gnc_quickfill_get_string_match (qf, old_name); match = gnc_quickfill_get_string_match (qf, old_name);
@ -314,15 +314,15 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
gnc_quickfill_remove (qf, old_name, QUICKFILL_ALPHA); gnc_quickfill_remove (qf, old_name, QUICKFILL_ALPHA);
if (qfb->dont_add_cb && 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); gnc_quickfill_remove (qf, new_name, QUICKFILL_ALPHA);
gtk_list_store_remove(qfb->list_store, &iter); gtk_list_store_remove (qfb->list_store, &iter);
} }
else else
{ {
gnc_quickfill_insert (qf, new_name, QUICKFILL_ALPHA); gnc_quickfill_insert (qf, new_name, QUICKFILL_ALPHA);
gtk_list_store_set(qfb->list_store, &iter, gtk_list_store_set (qfb->list_store, &iter,
ACCOUNT_NAME, new_name, ACCOUNT_NAME, new_name,
-1); -1);
} }
@ -333,12 +333,12 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
/* Any accounts that weren't found in the tree are accounts that /* Any accounts that weren't found in the tree are accounts that
* were hidden but have now become visible. Add them to the list * were hidden but have now become visible. Add them to the list
* store. */ * store. */
for (tmp = data.accounts; tmp; tmp = g_list_next(tmp)) for (tmp = data.accounts; tmp; tmp = g_list_next (tmp))
{ {
account = tmp->data; account = tmp->data;
if (qfb->dont_add_cb) if (qfb->dont_add_cb)
{ {
if (qfb->dont_add_cb(account, qfb->dont_add_data)) if (qfb->dont_add_cb (account, qfb->dont_add_data))
{ {
continue; continue;
} }
@ -356,24 +356,24 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
DEBUG("remove %s", name); DEBUG("remove %s", name);
/* Remove from qf */ /* Remove from qf */
gnc_quickfill_remove(qfb->qf, name, QUICKFILL_ALPHA); gnc_quickfill_remove (qfb->qf, name, QUICKFILL_ALPHA);
/* Does the account exist in the model? */ /* Does the account exist in the model? */
data.accounts = g_list_append(NULL, account); 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),
shared_quickfill_find_accounts, &data); shared_quickfill_find_accounts, &data);
/* Remove from list store */ /* Remove from list store */
for (tmp = data.refs; tmp; tmp = g_list_next(tmp)) for (tmp = data.refs; tmp; tmp = g_list_next (tmp))
{ {
path = gtk_tree_row_reference_get_path (tmp->data); path = gtk_tree_row_reference_get_path (tmp->data);
gtk_tree_row_reference_free (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),
&iter, path)) &iter, path))
{ {
gtk_list_store_remove(qfb->list_store, &iter); gtk_list_store_remove (qfb->list_store, &iter);
} }
gtk_tree_path_free(path); gtk_tree_path_free (path);
} }
break; break;
@ -381,14 +381,14 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
DEBUG("add %s", name); DEBUG("add %s", name);
if (qfb->dont_add_cb && if (qfb->dont_add_cb &&
qfb->dont_add_cb(account, qfb->dont_add_data)) qfb->dont_add_cb (account, qfb->dont_add_data))
break; break;
match = gnc_quickfill_get_string_match (qf, name); match = gnc_quickfill_get_string_match (qf, name);
if (match) if (match)
{ {
match_str = gnc_quickfill_string (match); match_str = gnc_quickfill_string (match);
if (match_str && (g_strcmp0(match_str, name) != 0)) if (match_str && (g_strcmp0 (match_str, name) != 0))
{ {
PINFO ("got match for %s", name); PINFO ("got match for %s", name);
break; break;
@ -410,10 +410,10 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
} }
if (data.accounts) if (data.accounts)
g_list_free(data.accounts); g_list_free (data.accounts);
if (data.refs) if (data.refs)
g_list_free(data.refs); g_list_free (data.refs);
g_free(name); g_free (name);
LEAVE(" "); LEAVE(" ");
} }

View File

@ -68,13 +68,11 @@ typedef gboolean (*AccountBoolCB) (Account *, gpointer);
* it). This code does not currently listen to account-destroy * it). This code does not currently listen to account-destroy
* events. * events.
*/ */
QuickFill * gnc_get_shared_account_name_quickfill (Account *root, QuickFill *
const char * key, gnc_get_shared_account_name_quickfill (Account *root, const char * key,
AccountBoolCB skip_cb, AccountBoolCB skip_cb, gpointer cb_data);
gpointer cb_data);
GtkListStore * GtkListStore *
gnc_get_shared_account_name_list_store (Account *root, gnc_get_shared_account_name_list_store (Account *root, const char * key,
const char * key,
AccountBoolCB cb, gpointer cb_data); AccountBoolCB cb, gpointer cb_data);
#endif #endif