diff --git a/ChangeLog b/ChangeLog index be23437518..44e09aa5d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,13 @@ marked for exclusion from "select-all". * accounts/C/acctchrt_business.gnucash-xea: mark this account as "excluded from select-all" + + * src/backend/file/io-example-account.[ch]: add a flag that signifies + that an account-tree should start selected. + * src/gnome/druid-hierarchy.c: when loading the example accounts, go + through the list and 'select' those that are marked as "start selected" + * accounts/C/acctchrt_common.gnucash-xea: mark this account tree as + "start selected" 2003-01-04 David Hampton diff --git a/accounts/C/acctchrt_common.gnucash-xea b/accounts/C/acctchrt_common.gnucash-xea index 327ec704d4..33457d3c9f 100644 --- a/accounts/C/acctchrt_common.gnucash-xea +++ b/accounts/C/acctchrt_common.gnucash-xea @@ -9,6 +9,7 @@ Most users will want to select this set of accounts. It includes most commonly used accounts (checking, savings, cash, credit card, income, common expenses). + 1 Assets 98f262dfab9a2b99ac42919dcf58d304 diff --git a/src/backend/file/io-example-account.c b/src/backend/file/io-example-account.c index fb5a76de7e..75e1b6948b 100644 --- a/src/backend/file/io-example-account.c +++ b/src/backend/file/io-example-account.c @@ -55,6 +55,7 @@ static short module = MOD_IO; #define GNC_ACCOUNT_LONG "gnc-act:long-description" #define GNC_ACCOUNT_TITLE "gnc-act:title" #define GNC_ACCOUNT_EXCLUDEP "gnc-act:exclude-from-select-all" +#define GNC_ACCOUNT_SELECTED "gnc-act:start-selected" void gnc_destroy_example_account(GncExampleAccount *gea) @@ -279,7 +280,7 @@ gnc_excludep_end_handler(gpointer data_for_children, { GncExampleAccount *gea = (GncExampleAccount*)((gxpf_data*)global_data)->parsedata; - gint64 val; + gint64 val = 0; dom_tree_to_integer ((xmlNodePtr)data_for_children, &val); gea->exclude_from_select_all = (dom_tree_to_integer ? TRUE : FALSE); @@ -293,6 +294,28 @@ gnc_excludep_sixtp_parser_create(void) return sixtp_dom_parser_new(gnc_excludep_end_handler, NULL, NULL); } +static gboolean +gnc_selected_end_handler(gpointer data_for_children, + GSList* data_from_children, GSList* sibling_data, + gpointer parent_data, gpointer global_data, + gpointer *result, const gchar *tag) +{ + GncExampleAccount *gea = + (GncExampleAccount*)((gxpf_data*)global_data)->parsedata; + gint64 val = 0; + + dom_tree_to_integer ((xmlNodePtr)data_for_children, &val); + gea->start_selected = (dom_tree_to_integer ? TRUE : FALSE); + + return TRUE; +} + +static sixtp* +gnc_selected_sixtp_parser_create(void) +{ + return sixtp_dom_parser_new(gnc_selected_end_handler, NULL, NULL); +} + static gboolean gnc_title_end_handler(gpointer data_for_children, GSList* data_from_children, GSList* sibling_data, @@ -346,6 +369,7 @@ gnc_read_example_account(GNCBook *book, const gchar *filename) GNC_ACCOUNT_SHORT, gnc_short_descrip_sixtp_parser_create(), GNC_ACCOUNT_LONG, gnc_long_descrip_sixtp_parser_create(), GNC_ACCOUNT_EXCLUDEP, gnc_excludep_sixtp_parser_create(), + GNC_ACCOUNT_SELECTED, gnc_selected_sixtp_parser_create(), "gnc:account", gnc_account_sixtp_parser_create(), NULL, NULL)) { diff --git a/src/backend/file/io-example-account.h b/src/backend/file/io-example-account.h index 2a77fc5aa7..3d30fc102f 100644 --- a/src/backend/file/io-example-account.h +++ b/src/backend/file/io-example-account.h @@ -39,6 +39,7 @@ struct GncExampleAccount_struct gchar *short_description; gchar *long_description; gboolean exclude_from_select_all; + gboolean start_selected; }; typedef struct GncExampleAccount_struct GncExampleAccount; diff --git a/src/gnome/druid-hierarchy.c b/src/gnome/druid-hierarchy.c index e2e5fd9d83..c149344dd9 100644 --- a/src/gnome/druid-hierarchy.c +++ b/src/gnome/druid-hierarchy.c @@ -352,6 +352,18 @@ add_each_gea_to_clist (gpointer data, gpointer user_data) gtk_clist_set_row_data(clist, row, gea); } +static void +select_initial_geas (gpointer data, gpointer user_data) +{ + GncExampleAccount *gea = (GncExampleAccount*)data; + GtkCList *clist = GTK_CLIST (user_data); + + if (gea->start_selected) { + gint row = gtk_clist_find_row_from_data (clist, gea); + gtk_clist_select_row (clist, row, 0); + } +} + static void on_choose_account_types_prepare (GnomeDruidPage *gnomedruidpage, gpointer arg1, @@ -384,6 +396,17 @@ on_choose_account_types_prepare (GnomeDruidPage *gnomedruidpage, gtk_clist_thaw (clist); + g_slist_foreach (list, select_initial_geas, (gpointer)clist); + + /* clear out the description/tree */ + { + GtkLabel *datext = GTK_LABEL (hierarchy_get_widget + ("account_types_description_entry")); + GtkTree *datree = GTK_TREE (hierarchy_get_widget ("account_type_tree")); + gtk_label_set_text (datext, ""); + gtk_tree_clear_items (datree, 0, g_list_length (datree->children)); + } + g_slist_free (list); g_free (locale_dir);