mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Change some spacing in source files account-quickfill.*
This commit is contained in:
parent
936e2bf371
commit
5bfef54d6d
@ -31,8 +31,8 @@
|
||||
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,
|
||||
gpointer user_data, gpointer event_data);
|
||||
static void listen_for_account_events (QofInstance *entity, QofEventId event_type,
|
||||
gpointer user_data, gpointer event_data);
|
||||
|
||||
/* Column indices for the list store */
|
||||
#define ACCOUNT_NAME 0
|
||||
@ -74,7 +74,7 @@ shared_quickfill_destroy (QofBook *book, gpointer key, gpointer user_data)
|
||||
shared_quickfill_pref_changed,
|
||||
qfb);
|
||||
gnc_quickfill_destroy (qfb->qf);
|
||||
g_object_unref(qfb->list_store);
|
||||
g_object_unref (qfb->list_store);
|
||||
qof_event_unregister_handler (qfb->listener);
|
||||
g_free (qfb);
|
||||
}
|
||||
@ -97,18 +97,17 @@ shared_quickfill_find_accounts (GtkTreeModel *model,
|
||||
GtkTreeRowReference* ref;
|
||||
GList *tmp;
|
||||
|
||||
gtk_tree_model_get(model, iter, ACCOUNT_POINTER, &account, -1);
|
||||
for (tmp = data->accounts; tmp; tmp = g_list_next(tmp))
|
||||
gtk_tree_model_get (model, iter, ACCOUNT_POINTER, &account, -1);
|
||||
for (tmp = data->accounts; tmp; tmp = g_list_next (tmp))
|
||||
{
|
||||
if (tmp->data == account)
|
||||
{
|
||||
ref = gtk_tree_row_reference_new(model, path);
|
||||
data->refs = g_list_append(data->refs, ref);
|
||||
data->accounts = g_list_remove_link(data->accounts, tmp);
|
||||
ref = gtk_tree_row_reference_new (model, path);
|
||||
data->refs = g_list_append (data->refs, ref);
|
||||
data->accounts = g_list_remove_link (data->accounts, tmp);
|
||||
return (data->accounts == NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -124,11 +123,13 @@ load_shared_qf_cb (Account *account, gpointer data)
|
||||
if (qfb->dont_add_cb)
|
||||
{
|
||||
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);
|
||||
if (NULL == name) return;
|
||||
if (NULL == name)
|
||||
return;
|
||||
gnc_quickfill_insert (qfb->qf, name, QUICKFILL_ALPHA);
|
||||
if (qfb->load_list_store)
|
||||
{
|
||||
@ -138,7 +139,7 @@ load_shared_qf_cb (Account *account, gpointer data)
|
||||
ACCOUNT_POINTER, account,
|
||||
-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;
|
||||
|
||||
/* Reload the quickfill */
|
||||
gnc_quickfill_purge(qfb->qf);
|
||||
gtk_list_store_clear(qfb->list_store);
|
||||
gnc_quickfill_purge (qfb->qf);
|
||||
gtk_list_store_clear (qfb->list_store);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -165,7 +166,7 @@ build_shared_quickfill (QofBook *book, Account *root, const char * key,
|
||||
{
|
||||
QFB *qfb;
|
||||
|
||||
qfb = g_new0(QFB, 1);
|
||||
qfb = g_new0 (QFB, 1);
|
||||
qfb->qf = gnc_quickfill_new ();
|
||||
qfb->book = book;
|
||||
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_data = data;
|
||||
qfb->load_list_store = TRUE;
|
||||
qfb->list_store =
|
||||
gtk_list_store_new (NUM_ACCOUNT_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER);
|
||||
qfb->list_store = gtk_list_store_new (NUM_ACCOUNT_COLUMNS,
|
||||
G_TYPE_STRING, G_TYPE_POINTER);
|
||||
|
||||
gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL,
|
||||
GNC_PREF_ACCOUNT_SEPARATOR,
|
||||
@ -186,11 +187,10 @@ build_shared_quickfill (QofBook *book, Account *root, const char * key,
|
||||
shared_quickfill_pref_changed,
|
||||
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->listener =
|
||||
qof_event_register_handler (listen_for_account_events, qfb);
|
||||
qfb->listener = qof_event_register_handler (listen_for_account_events, qfb);
|
||||
|
||||
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 *
|
||||
gnc_get_shared_account_name_quickfill (Account *root,
|
||||
const char * key,
|
||||
gnc_get_shared_account_name_quickfill (Account *root, const char * key,
|
||||
AccountBoolCB cb, gpointer cb_data)
|
||||
{
|
||||
QFB *qfb;
|
||||
@ -208,15 +207,15 @@ gnc_get_shared_account_name_quickfill (Account *root,
|
||||
book = gnc_account_get_book (root);
|
||||
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);
|
||||
return qfb->qf;
|
||||
}
|
||||
|
||||
GtkListStore *
|
||||
gnc_get_shared_account_name_list_store (Account *root,
|
||||
const char * key,
|
||||
gnc_get_shared_account_name_list_store (Account *root, const char * key,
|
||||
AccountBoolCB cb, gpointer cb_data)
|
||||
{
|
||||
QFB *qfb;
|
||||
@ -225,7 +224,8 @@ gnc_get_shared_account_name_list_store (Account *root,
|
||||
book = gnc_account_get_book (root);
|
||||
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);
|
||||
return qfb->list_store;
|
||||
@ -236,8 +236,8 @@ gnc_get_shared_account_name_list_store (Account *root,
|
||||
* for account modification events, and add new accounts.
|
||||
*/
|
||||
static void
|
||||
listen_for_account_events (QofInstance *entity, QofEventId event_type,
|
||||
gpointer user_data, gpointer event_data)
|
||||
listen_for_account_events (QofInstance *entity, QofEventId event_type,
|
||||
gpointer user_data, gpointer event_data)
|
||||
{
|
||||
QFB *qfb = user_data;
|
||||
QuickFill *qf = qfb->qf;
|
||||
@ -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)))
|
||||
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);
|
||||
@ -266,7 +266,7 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
|
||||
return;
|
||||
}
|
||||
|
||||
name = gnc_get_account_name_for_register(account);
|
||||
name = gnc_get_account_name_for_register (account);
|
||||
if (NULL == 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
|
||||
* 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),
|
||||
shared_quickfill_find_accounts, &data);
|
||||
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),
|
||||
shared_quickfill_find_accounts, &data);
|
||||
|
||||
/* Update the existing items in the list store. Its possible
|
||||
* that the change has caused an existing item to now become
|
||||
* hidden, in which case it needs to be removed from the list
|
||||
* 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;
|
||||
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),
|
||||
&iter, path))
|
||||
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),
|
||||
&iter, path))
|
||||
{
|
||||
gtk_tree_path_free(path);
|
||||
gtk_tree_path_free (path);
|
||||
continue;
|
||||
}
|
||||
gtk_tree_path_free(path);
|
||||
gtk_tree_model_get(GTK_TREE_MODEL(qfb->list_store), &iter,
|
||||
ACCOUNT_POINTER, &account,
|
||||
ACCOUNT_NAME, &old_name,
|
||||
-1);
|
||||
gtk_tree_path_free (path);
|
||||
gtk_tree_model_get (GTK_TREE_MODEL(qfb->list_store), &iter,
|
||||
ACCOUNT_POINTER, &account,
|
||||
ACCOUNT_NAME, &old_name,
|
||||
-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 */
|
||||
match = gnc_quickfill_get_string_match (qf, old_name);
|
||||
@ -314,17 +314,17 @@ 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, &iter);
|
||||
gtk_list_store_remove (qfb->list_store, &iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
gnc_quickfill_insert (qf, new_name, QUICKFILL_ALPHA);
|
||||
gtk_list_store_set(qfb->list_store, &iter,
|
||||
ACCOUNT_NAME, new_name,
|
||||
-1);
|
||||
gtk_list_store_set (qfb->list_store, &iter,
|
||||
ACCOUNT_NAME, new_name,
|
||||
-1);
|
||||
}
|
||||
g_free (old_name);
|
||||
g_free (new_name);
|
||||
@ -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
|
||||
* were hidden but have now become visible. Add them to the list
|
||||
* store. */
|
||||
for (tmp = data.accounts; tmp; tmp = g_list_next(tmp))
|
||||
for (tmp = data.accounts; tmp; tmp = g_list_next (tmp))
|
||||
{
|
||||
account = tmp->data;
|
||||
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;
|
||||
}
|
||||
@ -356,24 +356,24 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
|
||||
DEBUG("remove %s", name);
|
||||
|
||||
/* 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? */
|
||||
data.accounts = g_list_append(NULL, account);
|
||||
gtk_tree_model_foreach(GTK_TREE_MODEL(qfb->list_store),
|
||||
shared_quickfill_find_accounts, &data);
|
||||
data.accounts = g_list_append (NULL, account);
|
||||
gtk_tree_model_foreach (GTK_TREE_MODEL(qfb->list_store),
|
||||
shared_quickfill_find_accounts, &data);
|
||||
|
||||
/* 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);
|
||||
gtk_tree_row_reference_free (tmp->data);
|
||||
if (gtk_tree_model_get_iter(GTK_TREE_MODEL(qfb->list_store),
|
||||
&iter, path))
|
||||
if (gtk_tree_model_get_iter (GTK_TREE_MODEL(qfb->list_store),
|
||||
&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;
|
||||
|
||||
@ -381,14 +381,14 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
|
||||
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);
|
||||
if (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);
|
||||
break;
|
||||
@ -410,10 +410,10 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
|
||||
}
|
||||
|
||||
if (data.accounts)
|
||||
g_list_free(data.accounts);
|
||||
g_list_free (data.accounts);
|
||||
if (data.refs)
|
||||
g_list_free(data.refs);
|
||||
g_free(name);
|
||||
g_list_free (data.refs);
|
||||
g_free (name);
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
|
@ -68,13 +68,11 @@ 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,
|
||||
AccountBoolCB skip_cb,
|
||||
gpointer cb_data);
|
||||
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,
|
||||
gnc_get_shared_account_name_list_store (Account *root, const char * key,
|
||||
AccountBoolCB cb, gpointer cb_data);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user