diff --git a/src/app-utils/gnc-accounting-period.c b/src/app-utils/gnc-accounting-period.c index d6e6eb31ce..076a17d65e 100644 --- a/src/app-utils/gnc-accounting-period.c +++ b/src/app-utils/gnc-accounting-period.c @@ -52,12 +52,14 @@ /* TODO: This should probably be changed eventually. */ #define GNC_PREFS_GROUP "window.pages.account_tree.summary" -#define GNC_PREF_START_CHOICE "start_choice" -#define GNC_PREF_START_DATE "start_date" -#define GNC_PREF_START_PERIOD "start_period" -#define GNC_PREF_END_CHOICE "end_choice" -#define GNC_PREF_END_DATE "end_date" -#define GNC_PREF_END_PERIOD "end_period" +#define GNC_PREF_START_CHOICE_ABS "start_choice-absolute" +#define GNC_PREF_START_CHOICE_REL "start_choice-relative" +#define GNC_PREF_START_DATE "start_date" +#define GNC_PREF_START_PERIOD "start_period" +#define GNC_PREF_END_CHOICE_ABS "end_choice-absolute" +#define GNC_PREF_END_CHOICE_REL "end_choice-relative" +#define GNC_PREF_END_DATE "end_date" +#define GNC_PREF_END_PERIOD "end_period" static time64 gnc_accounting_period_start_time64 (GncAccountingPeriod which, const GDate *fy_end, @@ -67,27 +69,22 @@ static time64 gnc_accounting_period_end_time64 (GncAccountingPeriod which, const GDate *contains); static time64 -lookup_start_date_option(const gchar *section, - const gchar *key_choice, - const gchar *key_absolute, - const gchar *key_relative, - GDate *fy_end) +lookup_start_date_option(GDate *fy_end) { gchar *choice; time64 time; int which; - choice = gnc_prefs_get_string(section, key_choice); - if (choice && strcmp(choice, "absolute") == 0) + + if (gnc_prefs_get_bool (GNC_PREFS_GROUP, GNC_PREF_START_CHOICE_ABS)) { - time = gnc_prefs_get_int(section, key_absolute); + time = gnc_prefs_get_int(GNC_PREFS_GROUP, GNC_PREF_START_DATE); } else { - which = gnc_prefs_get_int(section, key_relative); + which = gnc_prefs_get_int(GNC_PREFS_GROUP, GNC_PREF_START_PERIOD); time = gnc_accounting_period_start_time64(which, fy_end, NULL); } - g_free(choice); /* we will need the balance of the last transaction before the start date, so subtract 1 from start date */ /* CAS: we don't actually do what this comment says. I think that's @@ -96,28 +93,21 @@ lookup_start_date_option(const gchar *section, } static time64 -lookup_end_date_option(const gchar *section, - const gchar *key_choice, - const gchar *key_absolute, - const gchar *key_relative, - GDate *fy_end) +lookup_end_date_option(GDate *fy_end) { - gchar *choice; time64 time; int which; - choice = gnc_prefs_get_string(section, key_choice); - if (choice && strcmp(choice, "absolute") == 0) + if (gnc_prefs_get_bool (GNC_PREFS_GROUP, GNC_PREF_END_CHOICE_ABS)) { - time = gnc_prefs_get_int(section, key_absolute); + time = gnc_prefs_get_int(GNC_PREFS_GROUP, GNC_PREF_END_DATE); time = gnc_time64_get_day_end(time); } else { - which = gnc_prefs_get_int(section, key_relative); + which = gnc_prefs_get_int(GNC_PREFS_GROUP, GNC_PREF_END_PERIOD); time = gnc_accounting_period_end_time64(which, fy_end, NULL); } - g_free(choice); if (time == 0) time = -1; return time; @@ -144,9 +134,7 @@ gnc_accounting_period_fiscal_start(void) { time64 t; GDate *fy_end = get_fy_end(); - t = lookup_start_date_option(GNC_PREFS_GROUP, GNC_PREF_START_CHOICE, - GNC_PREF_START_DATE, GNC_PREF_START_PERIOD, - fy_end); + t = lookup_start_date_option(fy_end); if (fy_end) g_date_free(fy_end); return t; @@ -158,9 +146,7 @@ gnc_accounting_period_fiscal_end(void) time64 t; GDate *fy_end = get_fy_end(); - t = lookup_end_date_option(GNC_PREFS_GROUP, GNC_PREF_END_CHOICE, - GNC_PREF_END_DATE, GNC_PREF_END_PERIOD, - fy_end); + t = lookup_end_date_option(fy_end); if (fy_end) g_date_free(fy_end); return t; diff --git a/src/app-utils/gnc-prefs-utils.c b/src/app-utils/gnc-prefs-utils.c index 28f390c0ef..d511162f31 100644 --- a/src/app-utils/gnc-prefs-utils.c +++ b/src/app-utils/gnc-prefs-utils.c @@ -32,9 +32,11 @@ static QofLogModule log_module = G_LOG_DOMAIN; /* Keys used for core preferences */ -#define GNC_PREF_FILE_COMPRESSION "file_compression" -#define GNC_PREF_RETAIN_TYPE "retain_type" -#define GNC_PREF_RETAIN_DAYS "retain_days" +#define GNC_PREF_FILE_COMPRESSION "file_compression" +#define GNC_PREF_RETAIN_TYPE_NEVER "retain_type-never" +#define GNC_PREF_RETAIN_TYPE_DAYS "retain_type-days" +#define GNC_PREF_RETAIN_TYPE_FOREVER "retain_type-forever" +#define GNC_PREF_RETAIN_DAYS "retain_days" /*************************************************************** * Initialization * @@ -47,26 +49,18 @@ file_retain_changed_cb(gpointer gsettings, gchar *key, gpointer user_data) } static void -file_retain_type_changed_cb(GConfEntry *entry, gpointer user_data) +file_retain_type_changed_cb(gpointer gsettings, gchar *key, gpointer user_data) { - XMLFileRetentionType type; - gchar *choice = gnc_gconf_get_string(GCONF_GENERAL, KEY_RETAIN_TYPE, NULL); - if (!choice) - choice = g_strdup("days"); + XMLFileRetentionType type = XML_RETAIN_ALL; - if (g_strcmp0 (choice, "never") == 0) + if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_TYPE_NEVER)) type = XML_RETAIN_NONE; - else if (g_strcmp0 (choice, "forever") == 0) - type = XML_RETAIN_ALL; - else - { - if (g_strcmp0 (choice, "days") != 0) - PERR("bad value '%s'", choice ? choice : "(null)"); + else if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_TYPE_DAYS)) type = XML_RETAIN_DAYS; - } - gnc_prefs_set_file_retention_policy (type); + else if (!gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_TYPE_FOREVER)) + PWARN("no file retention policy was set, assuming conservative policy 'forever'"); - g_free (choice); + gnc_prefs_set_file_retention_policy (type); } static void @@ -81,27 +75,39 @@ void gnc_prefs_init (void) { gnc_gsettings_load_backend(); - /* Add hooks to update core preferences whenever the associated gconf key changes */ - gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_DAYS, - (GCallback) file_retain_changed_cb, NULL); - gnc_gconf_general_register_cb(KEY_RETAIN_TYPE, file_retain_type_changed_cb, NULL); - gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_FILE_COMPRESSION, - (GCallback) file_compression_changed_cb, NULL); - - /* Call the hooks once manually to initialize the core preferences */ - file_retain_changed_cb (NULL, NULL, NULL); - file_retain_type_changed_cb (NULL, NULL); - file_compression_changed_cb (NULL, NULL, NULL); - - /* Backwards compatibility code. Pre 2.3.15, 0 retain_days meant + /* Check for invalid retain_type (days)/retain_days (0) combo. + * This can happen either because a user changed the preferences + * manually outside of GnuCash, or because the user upgraded from + * gnucash version 2.3.15 or older. Back then, 0 retain_days meant * "keep forever". From 2.3.15 on this is controlled via a multiple - * choice ("retain_type"). So if we find a 0 retain_days value with - * a "days" retain_type, we should interpret it as if we got a - * "forever" retain_type. + * choice ("retain_type"). + * So if we find a 0 retain_days value with a "days" retain_type, + * we will silently and conservatively interpret is as meaning + * retain forever ("forever" retain_type). */ if ( (gnc_prefs_get_file_retention_policy () == XML_RETAIN_DAYS) && (gnc_prefs_get_file_retention_days () == 0 ) ) { - gnc_gconf_set_string (GCONF_GENERAL, KEY_RETAIN_TYPE, "forever", NULL); + gnc_prefs_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_TYPE_FOREVER, TRUE); + gnc_prefs_set_float (GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_DAYS, 30); + PWARN("retain 0 days policy was set, but this is probably not what the user wanted,\n" + "assuming conservative policy 'forever'"); } + + /* Add hooks to update core preferences whenever the associated preference changes */ + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_DAYS, + file_retain_changed_cb, NULL); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_TYPE_NEVER, + file_retain_type_changed_cb, NULL); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_TYPE_DAYS, + file_retain_type_changed_cb, NULL); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_TYPE_FOREVER, + file_retain_type_changed_cb, NULL); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_FILE_COMPRESSION, + file_compression_changed_cb, NULL); + + /* Call the hooks once manually to initialize the core preferences */ + file_retain_changed_cb (NULL, NULL, NULL); + file_retain_type_changed_cb (NULL, NULL, NULL); + file_compression_changed_cb (NULL, NULL, NULL); } diff --git a/src/app-utils/gnc-ui-util.c b/src/app-utils/gnc-ui-util.c index 58ac5275ef..8a6a357372 100644 --- a/src/app-utils/gnc-ui-util.c +++ b/src/app-utils/gnc-ui-util.c @@ -58,9 +58,12 @@ #include "gnc-features.h" #include "gnc-guile-utils.h" -#define GNC_PREF_CURRENCY_CHOICE "currency_choice" -#define GNC_PREF_CURRENCY_OTHER "currency_other" -#define GNC_PREF_REVERSED_ACCOUNTS "reversed_accounts" +#define GNC_PREF_CURRENCY_CHOICE_LOCALE "currency_choice-locale" +#define GNC_PREF_CURRENCY_CHOICE_OTHER "currency_choice-other" +#define GNC_PREF_CURRENCY_OTHER "currency_other" +#define GNC_PREF_REVERSED_ACCTS_NONE "reversed_accounts-none" +#define GNC_PREF_REVERSED_ACCTS_CREDIT "reversed_accounts-credit" +#define GNC_PREF_REVERSED_ACCTS_INC_EXP "reversed_accounts-incomeexpense" static QofLogModule log_module = GNC_MOD_GUI; @@ -120,35 +123,27 @@ gnc_configure_account_separator (void) static void gnc_configure_reverse_balance (void) { - gchar *choice; gint i; for (i = 0; i < NUM_ACCOUNT_TYPES; i++) reverse_type[i] = FALSE; - choice = gnc_prefs_get_string(GNC_PREFS_GROUP_GENERAL, GNC_PREF_REVERSED_ACCOUNTS); - - if (g_strcmp0 (choice, "none") == 0) - { - } - else if (g_strcmp0 (choice, "income_expense") == 0) + if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_REVERSED_ACCTS_INC_EXP)) { reverse_type[ACCT_TYPE_INCOME] = TRUE; reverse_type[ACCT_TYPE_EXPENSE] = TRUE; } - else + else if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_REVERSED_ACCTS_CREDIT)) { - if (g_strcmp0 (choice, "credit") != 0) - PERR("bad value '%s'", choice ? choice : "(null)"); reverse_type[ACCT_TYPE_LIABILITY] = TRUE; reverse_type[ACCT_TYPE_PAYABLE] = TRUE; reverse_type[ACCT_TYPE_EQUITY] = TRUE; reverse_type[ACCT_TYPE_INCOME] = TRUE; reverse_type[ACCT_TYPE_CREDIT] = TRUE; } + else if (!gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_REVERSED_ACCTS_NONE)) + PWARN("no reversed account preference set, using none"); - if (choice != NULL) - free (choice); } static void @@ -912,15 +907,14 @@ gnc_default_currency_common (gchar *requested_currency, const gchar *section) { gnc_commodity *currency = NULL; - gchar *choice, *mnemonic; + gchar *mnemonic; if (requested_currency) return gnc_commodity_table_lookup(gnc_get_current_commodities(), GNC_COMMODITY_NS_CURRENCY, requested_currency); - choice = gnc_prefs_get_string(section, GNC_PREF_CURRENCY_CHOICE); - if (g_strcmp0(choice, "other") == 0) + if (gnc_prefs_get_bool (section, GNC_PREF_CURRENCY_CHOICE_OTHER)) { mnemonic = gnc_prefs_get_string(section, GNC_PREF_CURRENCY_OTHER); currency = gnc_commodity_table_lookup(gnc_get_current_commodities(), @@ -928,7 +922,6 @@ gnc_default_currency_common (gchar *requested_currency, DEBUG("mnemonic %s, result %p", mnemonic ? mnemonic : "(null)", currency); g_free(mnemonic); } - g_free(choice); if (!currency) currency = gnc_locale_default_currency (); @@ -2317,12 +2310,24 @@ gnc_ui_util_init (void) gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_ACCOUNT_SEPARATOR, gnc_configure_account_separator, NULL); - gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_REVERSED_ACCOUNTS, + gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_REVERSED_ACCTS_NONE, gnc_configure_reverse_balance, NULL); - gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_CURRENCY_CHOICE, + gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_REVERSED_ACCTS_CREDIT, + gnc_configure_reverse_balance, NULL); + gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_REVERSED_ACCTS_INC_EXP, + gnc_configure_reverse_balance, NULL); + gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_CURRENCY_CHOICE_LOCALE, + gnc_currency_changed_cb, NULL); + gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_CURRENCY_CHOICE_OTHER, gnc_currency_changed_cb, NULL); gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_CURRENCY_OTHER, gnc_currency_changed_cb, NULL); + gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL_REPORT, GNC_PREF_CURRENCY_CHOICE_LOCALE, + gnc_currency_changed_cb, NULL); + gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL_REPORT, GNC_PREF_CURRENCY_CHOICE_OTHER, + gnc_currency_changed_cb, NULL); + gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL_REPORT, GNC_PREF_CURRENCY_OTHER, + gnc_currency_changed_cb, NULL); gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_AUTO_DECIMAL_POINT, gnc_set_auto_decimal_enabled, NULL); gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_AUTO_DECIMAL_PLACES, diff --git a/src/business/business-gnome/gnc-plugin-page-invoice.c b/src/business/business-gnome/gnc-plugin-page-invoice.c index 437313cd87..a2f9536540 100644 --- a/src/business/business-gnome/gnc-plugin-page-invoice.c +++ b/src/business/business-gnome/gnc-plugin-page-invoice.c @@ -33,7 +33,6 @@ #include "dialog-account.h" #include "gnc-component-manager.h" -#include "gnc-gconf-utils.h" #include "gnc-gobject-utils.h" #include "gnc-gnome-utils.h" #include "gnc-icons.h" @@ -55,7 +54,7 @@ static void gnc_plugin_page_invoice_save_page (GncPluginPage *plugin_page, GKeyF static GncPluginPage *gnc_plugin_page_invoice_recreate_page (GtkWidget *window, GKeyFile *file, const gchar *group); static void gnc_plugin_page_invoice_window_changed (GncPluginPage *plugin_page, GtkWidget *window); -static void gnc_plugin_page_invoice_summarybar_position_changed(GConfEntry *entry, gpointer user_data); +static void gnc_plugin_page_invoice_summarybar_position_changed(gpointer prefs, gchar* pref, gpointer user_data); /* Command callbacks */ static void gnc_plugin_page_invoice_cmd_new_invoice (GtkAction *action, GncPluginPageInvoice *plugin_page); @@ -469,9 +468,15 @@ gnc_plugin_page_invoice_create_widget (GncPluginPage *plugin_page) plugin_page->summarybar = gnc_invoice_window_create_summary_bar(priv->iw); gtk_box_pack_start(GTK_BOX (priv->widget), plugin_page->summarybar, FALSE, FALSE, 0); - gnc_plugin_page_invoice_summarybar_position_changed(NULL, page); - gnc_gconf_general_register_cb(KEY_SUMMARYBAR_POSITION, - gnc_plugin_page_invoice_summarybar_position_changed, page); + gnc_plugin_page_invoice_summarybar_position_changed(NULL, NULL, page); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_SUMMARYBAR_POSITION_TOP, + gnc_plugin_page_invoice_summarybar_position_changed, + page); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_SUMMARYBAR_POSITION_BOTTOM, + gnc_plugin_page_invoice_summarybar_position_changed, + page); regWidget = gnc_invoice_get_register(priv->iw); if (regWidget) @@ -499,8 +504,14 @@ gnc_plugin_page_invoice_destroy_widget (GncPluginPage *plugin_page) page = GNC_PLUGIN_PAGE_INVOICE (plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(page); - gnc_gconf_general_remove_cb(KEY_SUMMARYBAR_POSITION, - gnc_plugin_page_invoice_summarybar_position_changed, page); + gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_SUMMARYBAR_POSITION_TOP, + gnc_plugin_page_invoice_summarybar_position_changed, + page); + gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_SUMMARYBAR_POSITION_BOTTOM, + gnc_plugin_page_invoice_summarybar_position_changed, + page); if (priv->widget == NULL) { @@ -599,14 +610,12 @@ gnc_plugin_page_invoice_window_changed (GncPluginPage *plugin_page, static void -gnc_plugin_page_invoice_summarybar_position_changed(GConfEntry *entry, - gpointer user_data) +gnc_plugin_page_invoice_summarybar_position_changed(gpointer prefs, gchar *pref, gpointer user_data) { GncPluginPage *plugin_page; GncPluginPageInvoice *page; GncPluginPageInvoicePrivate *priv; GtkPositionType position = GTK_POS_BOTTOM; - gchar *conf_string; g_return_if_fail(user_data != NULL); @@ -614,14 +623,8 @@ gnc_plugin_page_invoice_summarybar_position_changed(GConfEntry *entry, page = GNC_PLUGIN_PAGE_INVOICE (user_data); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(page); - conf_string = gnc_gconf_get_string (GCONF_GENERAL, - KEY_SUMMARYBAR_POSITION, NULL); - if (conf_string) - { - position = gnc_enum_from_nick (GTK_TYPE_POSITION_TYPE, - conf_string, GTK_POS_BOTTOM); - g_free (conf_string); - } + if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_SUMMARYBAR_POSITION_TOP)) + position = GTK_POS_TOP; gtk_box_reorder_child(GTK_BOX(priv->widget), plugin_page->summarybar, diff --git a/src/core-utils/gnc-prefs.h b/src/core-utils/gnc-prefs.h index ed5d792fb6..e6d715303c 100644 --- a/src/core-utils/gnc-prefs.h +++ b/src/core-utils/gnc-prefs.h @@ -66,7 +66,8 @@ #define GNC_PREF_NEGATIVE_IN_RED "negative_in_red" #define GNC_PREF_NUM_SOURCE "num_source" #define GNC_PREF_DATE_FORMAT "date_format" -#define GNC_PREF_DATE_COMPLETION "date_completion" +#define GNC_PREF_DATE_COMPL_THISYEAR "date_completion-thisyear" +#define GNC_PREF_DATE_COMPL_SLIDING "date_completion-sliding" #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" diff --git a/src/gnome-utils/dialog-preferences.c b/src/gnome-utils/dialog-preferences.c index cb5e3f44eb..c93781c5d9 100644 --- a/src/gnome-utils/dialog-preferences.c +++ b/src/gnome-utils/dialog-preferences.c @@ -679,112 +679,6 @@ gnc_prefs_split_widget_name (const gchar *name, gchar **group, gchar **pref) /* FIXME to remove when gconf conversion of preferences is complete */ /****************************************************************************/ -/** The user clicked on a radio button. Update gconf. Radio button - * group choices are stored as a string. The last component of the - * widget name is the string that will be stored. I.E. The widget name - * must be in this form "gconf//value". - * - * @internal - * - * @param button A pointer to the radio button that was clicked. - * - * @param user_data Unused. - */ -static void -gnc_prefs_radio_button_user_cb_gconf (GtkRadioButton *button, - gpointer user_data) -{ - gchar *key, *button_name; - gboolean active; - - g_return_if_fail(GTK_IS_RADIO_BUTTON(button)); - active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); - if (!active) - return; - - /* Copy the widget name and split into gconf key and button value parts */ - key = g_strdup(gtk_buildable_get_name(GTK_BUILDABLE(button)) + PREFIX_LEN); - button_name = strrchr(key, '/'); - *button_name++ = '\0'; - - DEBUG("Radio button group %s now set to %s", key, button_name); - gnc_gconf_set_string(key, NULL, button_name, NULL); - g_free(key); -} - - -/** A radio button group choice was updated in gconf. Update the user - * visible dialog. - * - * @internal - * - * @param button A pointer to the radio button that should be shown - * as selected. - */ -static void -gnc_prefs_radio_button_gconf_cb_gconf (GtkRadioButton *button) -{ - g_return_if_fail(GTK_IS_RADIO_BUTTON(button)); - ENTER("button %p", button); - g_signal_handlers_block_by_func(G_OBJECT(button), - G_CALLBACK(gnc_prefs_radio_button_user_cb_gconf), NULL); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); - g_signal_handlers_unblock_by_func(G_OBJECT(button), - G_CALLBACK(gnc_prefs_radio_button_user_cb_gconf), NULL); - LEAVE(" "); -} - - -/** Connect a radio button widget to the user callback function. Set - * the starting state of the radio button group from its value in - * gconf. - * - * @internal - * - * @param button A pointer to the radio button that should be - * connected. - */ -static void -gnc_prefs_connect_radio_button_gconf (GtkRadioButton *button) -{ - gchar *key, *button_name, *value; - gboolean active; - GSList *group; - - g_return_if_fail(GTK_IS_RADIO_BUTTON(button)); - - /* Copy the widget name and split into gconf key and button name parts */ - key = g_strdup(gtk_buildable_get_name(GTK_BUILDABLE(button)) + PREFIX_LEN); - button_name = strrchr(key, '/'); - *button_name++ = '\0'; - - /* Get the current value. */ - value = gnc_gconf_get_string(key, NULL, NULL); - if (value) - { - active = (g_utf8_collate(value, button_name) == 0); - } - else - { - /* Sigh. There's no gconf default for this key. Use the first - * button in the dialog, which is the last button in the list. */ - group = gtk_radio_button_get_group(button); - active = (button != g_slist_nth_data(group, g_slist_length(group))); - } - DEBUG(" Radio set %s, button %s initially set to %d", key, button_name, active); - - /* Wire up the button */ - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active); - g_signal_connect(G_OBJECT(button), "toggled", - G_CALLBACK(gnc_prefs_radio_button_user_cb_gconf), NULL); - g_free(value); - g_free(key); -} - -/****************************************************************************/ - -/****************************************************************************/ - /** The user changed a currency_edit. Update gconf. Currency_edit * choices are stored as an int. * @@ -1100,6 +994,35 @@ gnc_prefs_connect_font_button (GtkFontButton *fb) /****************************************************************************/ +/** Connect a GtkRadioButton widget to its stored value in the preferences database. + * + * @internal + * + * @param button A pointer to the radio button that should be + * connected. + */ +static void +gnc_prefs_connect_radio_button (GtkRadioButton *button) +{ + gchar *group, *pref; + gboolean active; + + g_return_if_fail(GTK_IS_RADIO_BUTTON(button)); + + gnc_prefs_split_widget_name (gtk_buildable_get_name(GTK_BUILDABLE(button)), &group, &pref); + +// active = gnc_prefs_get_bool (group, pref); +// DEBUG(" Checkbox %s/%s initially %sactive", group, pref, active ? "" : "in"); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active); + + gnc_prefs_bind (group, pref, G_OBJECT (button), "active"); + + g_free(group); + g_free(pref); +} + +/****************************************************************************/ + /** Connect a GtkCheckButton widget to its stored value in the preferences database. * * @internal @@ -1279,12 +1202,7 @@ gnc_prefs_connect_one_gconf (const gchar *name, /* These tests must be ordered from more specific widget to less * specific widget. */ - if (GTK_IS_RADIO_BUTTON(widget)) - { - DEBUG(" %s - radio button", name); - gnc_prefs_connect_radio_button_gconf(GTK_RADIO_BUTTON(widget)); - } - else if (GTK_IS_HBOX(widget)) + if (GTK_IS_HBOX(widget)) { /* Test custom widgets are all children of a hbox */ GtkWidget *widget_child; @@ -1342,6 +1260,11 @@ gnc_prefs_connect_one (const gchar *name, DEBUG(" %s - entry", name); gnc_prefs_connect_font_button(GTK_FONT_BUTTON(widget)); } + else if (GTK_IS_RADIO_BUTTON(widget)) + { + DEBUG(" %s - radio button", name); + gnc_prefs_connect_radio_button(GTK_RADIO_BUTTON(widget)); + } else if (GTK_IS_CHECK_BUTTON(widget)) { DEBUG(" %s - check button", name); @@ -1614,12 +1537,7 @@ gnc_preferences_gconf_changed (GConfClient *client, /* These tests must be ordered from more specific widget to less * specific widget. */ - if (GTK_IS_RADIO_BUTTON(widget)) - { - DEBUG("widget %p - radio button", widget); - gnc_prefs_radio_button_gconf_cb_gconf(GTK_RADIO_BUTTON(widget)); - } - else if (GTK_IS_HBOX(widget)) + if (GTK_IS_HBOX(widget)) { /* Test custom widgets are all children of a hbox */ GtkWidget *widget_child; diff --git a/src/gnome-utils/gnc-gnome-utils.c b/src/gnome-utils/gnc-gnome-utils.c index 28afd959b8..9c488faa34 100644 --- a/src/gnome-utils/gnc-gnome-utils.c +++ b/src/gnome-utils/gnc-gnome-utils.c @@ -155,44 +155,19 @@ gnc_configure_date_format (void) static void gnc_configure_date_completion (void) { - char *date_completion = gnc_gconf_get_string(GCONF_GENERAL, - KEY_DATE_COMPLETION, NULL); + QofDateCompletion dc = QOF_DATE_COMPLETION_THISYEAR; int backmonths = gnc_prefs_get_float(GNC_PREFS_GROUP_GENERAL, GNC_PREF_DATE_BACKMONTHS); - QofDateCompletion dc; if (backmonths < 0) - { backmonths = 0; - } else if (backmonths > 11) - { backmonths = 11; - } - if (date_completion && strcmp(date_completion, "sliding") == 0) - { + if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_DATE_COMPL_SLIDING)) dc = QOF_DATE_COMPLETION_SLIDING; - } - else if (date_completion && strcmp(date_completion, "thisyear") == 0) - { - dc = QOF_DATE_COMPLETION_THISYEAR; - } - else - { - /* No preference has been set yet */ - PINFO("Incorrect date completion code, using defaults"); - dc = QOF_DATE_COMPLETION_THISYEAR; - backmonths = 6; - gnc_gconf_set_string (GCONF_GENERAL, KEY_DATE_COMPLETION, "thisyear", NULL); - gnc_prefs_set_float (GNC_PREFS_GROUP_GENERAL, GNC_PREF_DATE_BACKMONTHS, 6.0); - } - qof_date_completion_set(dc, backmonths); - if (date_completion != NULL) - { - free(date_completion); - } + qof_date_completion_set(dc, backmonths); } void @@ -636,8 +611,14 @@ gnc_gui_init(void) GNC_PREF_DATE_FORMAT, gnc_configure_date_format, NULL); - gnc_gconf_general_register_cb( - KEY_DATE_COMPLETION, (GncGconfGeneralCb)gnc_configure_date_completion, NULL); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_DATE_COMPL_THISYEAR, + gnc_configure_date_completion, + NULL); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_DATE_COMPL_SLIDING, + gnc_configure_date_completion, + NULL); gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_DATE_BACKMONTHS, gnc_configure_date_completion, diff --git a/src/gnome-utils/gnc-main-window.c b/src/gnome-utils/gnc-main-window.c index 6234f88649..cc05a03edc 100644 --- a/src/gnome-utils/gnc-main-window.c +++ b/src/gnome-utils/gnc-main-window.c @@ -94,7 +94,10 @@ enum #define GNC_PREF_SHOW_CLOSE_BUTTON "tab_close_buttons" #define GNC_PREF_TAB_NEXT_RECENT "tab_next_recent" -#define KEY_TAB_POSITION "tab_position" +#define GNC_PREF_TAB_POSITION_TOP "tab_position-top" +#define GNC_PREF_TAB_POSITION_BOTTOM "tab_position-bottom" +#define GNC_PREF_TAB_POSITION_LEFT "tab_position-left" +#define GNC_PREF_TAB_POSITION_RIGHT "tab_position-right" #define GNC_PREF_TAB_WIDTH "tab_width" #define GNC_PREF_TAB_COLOR "show_account_color_tabs" @@ -3182,21 +3185,21 @@ gnc_main_window_get_action_group (GncMainWindow *window, } static void -gnc_main_window_update_tab_position (GncMainWindow *window) +gnc_main_window_update_tab_position (gpointer prefs, gchar *pref, gpointer user_data) { + GncMainWindow *window; GtkPositionType position = GTK_POS_TOP; - gchar *conf_string; GncMainWindowPrivate *priv; + window = GNC_MAIN_WINDOW(user_data); + ENTER ("window %p", window); - conf_string = gnc_gconf_get_string (GCONF_GENERAL, - KEY_TAB_POSITION, NULL); - if (conf_string) - { - position = gnc_enum_from_nick (GTK_TYPE_POSITION_TYPE, - conf_string, GTK_POS_TOP); - g_free (conf_string); - } + if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_BOTTOM)) + position = GTK_POS_BOTTOM; + else if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_LEFT)) + position = GTK_POS_LEFT; + else if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_RIGHT)) + position = GTK_POS_RIGHT; priv = GNC_MAIN_WINDOW_GET_PRIVATE (window); gtk_notebook_set_tab_pos (GTK_NOTEBOOK (priv->notebook), position); @@ -3316,32 +3319,6 @@ gnc_main_window_init_menu_updaters (GncMainWindow *window) G_CALLBACK (gnc_main_window_edit_menu_hide_cb), window); } -static void -gnc_main_window_gconf_changed (GConfClient *client, - guint cnxn_id, - GConfEntry *entry, - gpointer user_data) -{ - GncMainWindow *window; - GConfValue *value; - const gchar *key, *key_tail; - - window = GNC_MAIN_WINDOW(user_data); - - key = gconf_entry_get_key(entry); - value = gconf_entry_get_value(entry); - if (!key || !value) - return; - - key_tail = strrchr(key, '/'); - if (key_tail != NULL) - key_tail++; - if (strcmp(key_tail, KEY_TAB_POSITION) == 0) - { - gnc_main_window_update_tab_position(window); - } -} - /* CS: This callback functions will set the statusbar text to the * "tooltip" property of the currently selected GtkAction. * @@ -3565,10 +3542,23 @@ gnc_main_window_setup_window (GncMainWindow *window) } g_free(filename); gnc_main_window_window_menu(window); - gnc_gconf_add_notification(G_OBJECT(window), GCONF_GENERAL, - gnc_main_window_gconf_changed, - GNC_MAIN_WINDOW_NAME); - gnc_main_window_update_tab_position(window); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_TAB_POSITION_TOP, + gnc_main_window_update_tab_position, + window); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_TAB_POSITION_BOTTOM, + gnc_main_window_update_tab_position, + window); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_TAB_POSITION_LEFT, + gnc_main_window_update_tab_position, + window); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_TAB_POSITION_RIGHT, + gnc_main_window_update_tab_position, + window); + //gnc_main_window_update_tab_position(NULL, NULL, window); gnc_main_window_init_menu_updaters(window); diff --git a/src/gnome-utils/gnc-plugin-page.h b/src/gnome-utils/gnc-plugin-page.h index 1e5e4b8694..9c90ad74e5 100644 --- a/src/gnome-utils/gnc-plugin-page.h +++ b/src/gnome-utils/gnc-plugin-page.h @@ -41,7 +41,8 @@ G_BEGIN_DECLS -#define KEY_SUMMARYBAR_POSITION "summarybar_position" +#define GNC_PREF_SUMMARYBAR_POSITION_TOP "summarybar_position-top" +#define GNC_PREF_SUMMARYBAR_POSITION_BOTTOM "summarybar_position-bottom" /* type macros */ #define GNC_TYPE_PLUGIN_PAGE (gnc_plugin_page_get_type ()) diff --git a/src/gnome-utils/gtkbuilder/dialog-preferences.glade b/src/gnome-utils/gtkbuilder/dialog-preferences.glade index f63ec5022c..5fd490feaf 100644 --- a/src/gnome-utils/gtkbuilder/dialog-preferences.glade +++ b/src/gnome-utils/gtkbuilder/dialog-preferences.glade @@ -225,7 +225,7 @@ - + _Relative: True True @@ -246,7 +246,7 @@ - + _Absolute: True True @@ -256,7 +256,7 @@ Use the specified absolute starting date for profit/loss calculations. True True - gconf/window/pages/account_tree/summary/start_choice/relative + pref/window.pages.account_tree.summary/start_choice-relative 2 @@ -267,7 +267,7 @@ - + Re_lative: True True @@ -288,7 +288,7 @@ - + Ab_solute: True True @@ -298,7 +298,7 @@ Use the specified absolute ending date for profit/loss calculations. Also use this date for net assets calculations. True True - gconf/window/pages/account_tree/summary/end_choice/relative + pref/window.pages.account_tree.summary/end_choice-relative 6 @@ -565,7 +565,7 @@ - + _None True True @@ -587,7 +587,7 @@ - + C_redit accounts True True @@ -597,7 +597,7 @@ Sign reverse balances on the following: Credit Card, Payable, Liability, Equity, and Income. True True - gconf/general/reversed_accounts/none + pref/general/reversed_accounts-none 2 @@ -609,7 +609,7 @@ - + _Income & expense True True @@ -619,7 +619,7 @@ Sign reverse balances on income and expense accounts. True True - gconf/general/reversed_accounts/none + pref/general/reversed_accounts-none 2 @@ -709,7 +709,7 @@ False 12 - + Loc_ale: True True @@ -736,7 +736,7 @@ False 12 - + Ch_oose: True True @@ -746,7 +746,7 @@ Use the specified currency for all newly created accounts. True True - gconf/general/currency_choice/locale + pref/general/currency_choice-locale @@ -1181,7 +1181,7 @@ - + In the current calendar year True True @@ -1203,7 +1203,7 @@ - + In a sliding 12-month window starting this many months before the current month: True @@ -1214,7 +1214,7 @@ many months before the current month: Dates will be completed so that they are close to the current date. Enter the maximum number of months to go backwards in time when completing dates. True True - gconf/general/date_completion/thisyear + pref/general/date_completion-thisyear 2 @@ -1887,7 +1887,7 @@ many months before the current month: - + Never True True @@ -1896,7 +1896,7 @@ many months before the current month: Do not create log/backup files. Do not create log/backup files. True - gconf/general/retain_type/days + pref/general/retain_type-days 16 @@ -1905,7 +1905,7 @@ many months before the current month: - + For: True True @@ -1923,7 +1923,7 @@ many months before the current month: - + Forever True True @@ -1932,7 +1932,7 @@ many months before the current month: Do not delete log/backup files. Do not delete log/backup files. True - gconf/general/retain_type/days + pref/general/retain_type-days 18 @@ -2592,7 +2592,7 @@ many months before the current month: - + _Basic ledger True True @@ -2614,7 +2614,7 @@ many months before the current month: - + _Auto-split ledger True True @@ -2624,7 +2624,7 @@ many months before the current month: Automatically expand the current transaction to show all splits. All other transactions are shown on one line. (Two in double line mode.) True True - gconf/general/register/default_style/ledger + pref/general.register/default_style-ledger 4 @@ -2636,7 +2636,7 @@ many months before the current month: - + Transaction _Journal True True @@ -2646,7 +2646,7 @@ many months before the current month: All transactions are expanded to show all splits. True True - gconf/general/register/default_style/ledger + pref/general.register/default_style-ledger 4 @@ -2957,7 +2957,7 @@ many months before the current month: False 12 - + Ch_oose: True True @@ -2984,7 +2984,7 @@ many months before the current month: False 12 - + Loc_ale: True True @@ -2994,7 +2994,7 @@ many months before the current month: Use the system locale currency for all newly created reports. True True - gconf/general/report/currency_choice/other + pref/general.report/currency_choice-other @@ -3222,7 +3222,7 @@ many months before the current month: - + To_p True True @@ -3244,7 +3244,7 @@ many months before the current month: - + B_ottom True True @@ -3254,7 +3254,7 @@ many months before the current month: Display the notebook tabs at the bottom of the window. True True - gconf/general/tab_position/top + pref/general/tab_position-top 2 @@ -3266,7 +3266,7 @@ many months before the current month: - + _Left True True @@ -3276,7 +3276,7 @@ many months before the current month: Display the notebook tabs at the left of the window. True True - gconf/general/tab_position/top + pref/general/tab_position-top 2 @@ -3288,7 +3288,7 @@ many months before the current month: - + _Right True True @@ -3298,7 +3298,7 @@ many months before the current month: Display the notebook tabs at the right of the window. True True - gconf/general/tab_position/top + pref/general/tab_position-top 2 @@ -3327,7 +3327,7 @@ many months before the current month: - + Top True True @@ -3350,7 +3350,7 @@ many months before the current month: - + Bottom True True @@ -3360,7 +3360,7 @@ many months before the current month: Display the summary bar at the bottom of the page. True True - gconf/general/summarybar_position/top + pref/general/summarybar_position-top 2 diff --git a/src/gnome/gnc-plugin-page-account-tree.c b/src/gnome/gnc-plugin-page-account-tree.c index f66fed0db5..5640ddd973 100644 --- a/src/gnome/gnc-plugin-page-account-tree.c +++ b/src/gnome/gnc-plugin-page-account-tree.c @@ -55,6 +55,7 @@ #include "gnc-gobject-utils.h" #include "gnc-icons.h" #include "gnc-plugin-account-tree.h" +#include "gnc-prefs.h" #include "gnc-session.h" #include "gnc-split-reg.h" #include "gnc-tree-view-account.h" @@ -114,8 +115,7 @@ static void gnc_plugin_page_account_tree_save_page (GncPluginPage *plugin_page, static GncPluginPage *gnc_plugin_page_account_tree_recreate_page (GtkWidget *window, GKeyFile *file, const gchar *group); /* Callbacks */ -static void gnc_plugin_page_account_tree_summarybar_position_changed(GConfEntry *entry, - gpointer user_data); +static void gnc_plugin_page_account_tree_summarybar_position_changed(gpointer prefs, gchar* pref, gpointer user_data); static gboolean gnc_plugin_page_account_tree_button_press_cb (GtkWidget *widget, GdkEventButton *event, GncPluginPage *page); @@ -579,10 +579,15 @@ gnc_plugin_page_account_tree_create_widget (GncPluginPage *plugin_page) gtk_box_pack_start (GTK_BOX (priv->widget), plugin_page->summarybar, FALSE, FALSE, 0); gtk_widget_show(plugin_page->summarybar); - gnc_plugin_page_account_tree_summarybar_position_changed(NULL, page); - gnc_gconf_general_register_cb(KEY_SUMMARYBAR_POSITION, - gnc_plugin_page_account_tree_summarybar_position_changed, - page); + gnc_plugin_page_account_tree_summarybar_position_changed(NULL, NULL, page); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_SUMMARYBAR_POSITION_TOP, + gnc_plugin_page_account_tree_summarybar_position_changed, + page); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_SUMMARYBAR_POSITION_BOTTOM, + gnc_plugin_page_account_tree_summarybar_position_changed, + page); LEAVE("widget = %p", priv->widget); return priv->widget; @@ -598,9 +603,14 @@ gnc_plugin_page_account_tree_destroy_widget (GncPluginPage *plugin_page) page = GNC_PLUGIN_PAGE_ACCOUNT_TREE (plugin_page); priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page); - gnc_gconf_general_remove_cb(KEY_SUMMARYBAR_POSITION, - gnc_plugin_page_account_tree_summarybar_position_changed, - page); + gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_SUMMARYBAR_POSITION_TOP, + gnc_plugin_page_account_tree_summarybar_position_changed, + page); + gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_SUMMARYBAR_POSITION_BOTTOM, + gnc_plugin_page_account_tree_summarybar_position_changed, + page); if (priv->widget) { @@ -720,14 +730,12 @@ gnc_plugin_page_account_tree_recreate_page (GtkWidget *window, /* Callbacks */ static void -gnc_plugin_page_account_tree_summarybar_position_changed(GConfEntry *entry, - gpointer user_data) +gnc_plugin_page_account_tree_summarybar_position_changed(gpointer prefs, gchar* pref, gpointer user_data) { GncPluginPage *plugin_page; GncPluginPageAccountTree *page; GncPluginPageAccountTreePrivate *priv; GtkPositionType position = GTK_POS_BOTTOM; - gchar *conf_string; g_return_if_fail(user_data != NULL); @@ -735,14 +743,8 @@ gnc_plugin_page_account_tree_summarybar_position_changed(GConfEntry *entry, page = GNC_PLUGIN_PAGE_ACCOUNT_TREE (user_data); priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page); - conf_string = gnc_gconf_get_string (GCONF_GENERAL, - KEY_SUMMARYBAR_POSITION, NULL); - if (conf_string) - { - position = gnc_enum_from_nick (GTK_TYPE_POSITION_TYPE, - conf_string, GTK_POS_BOTTOM); - g_free (conf_string); - } + if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_SUMMARYBAR_POSITION_TOP)) + position = GTK_POS_TOP; gtk_box_reorder_child(GTK_BOX(priv->widget), plugin_page->summarybar, diff --git a/src/gnome/gnc-plugin-page-register.c b/src/gnome/gnc-plugin-page-register.c index 670df2cbe0..1e2e3d70d6 100644 --- a/src/gnome/gnc-plugin-page-register.c +++ b/src/gnome/gnc-plugin-page-register.c @@ -55,13 +55,11 @@ #include "dialog-transfer.h" #include "dialog-utils.h" #include "assistant-stock-split.h" -#include "gnc-gconf-utils.h" #include "gnc-component-manager.h" #include "gnc-date.h" #include "gnc-date-edit.h" #include "gnc-engine.h" #include "gnc-event.h" -#include "gnc-gconf-utils.h" #include "gnc-gnome-utils.h" #include "gnc-gobject-utils.h" #include "gnc-gui-query.h" @@ -105,7 +103,7 @@ static gchar *gnc_plugin_page_register_get_tab_name (GncPluginPage *plugin_page) static gchar *gnc_plugin_page_register_get_tab_color (GncPluginPage *plugin_page); static gchar *gnc_plugin_page_register_get_long_name (GncPluginPage *plugin_page); -static void gnc_plugin_page_register_summarybar_position_changed(GConfEntry *entry, gpointer user_data); +static void gnc_plugin_page_register_summarybar_position_changed(gpointer prefs, gchar* pref, gpointer user_data); /* Callbacks for the "Sort By" dialog */ void gnc_plugin_page_register_sort_button_cb(GtkToggleButton *button, GncPluginPageRegister *page); @@ -1117,9 +1115,15 @@ gnc_plugin_page_register_create_widget (GncPluginPage *plugin_page) gtk_widget_show_all(plugin_page->summarybar); gtk_box_pack_start(GTK_BOX (priv->widget), plugin_page->summarybar, FALSE, FALSE, 0); - gnc_plugin_page_register_summarybar_position_changed(NULL, page); - gnc_gconf_general_register_cb(KEY_SUMMARYBAR_POSITION, - gnc_plugin_page_register_summarybar_position_changed, page); + gnc_plugin_page_register_summarybar_position_changed(NULL, NULL, page); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_SUMMARYBAR_POSITION_TOP, + gnc_plugin_page_register_summarybar_position_changed, + page); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_SUMMARYBAR_POSITION_BOTTOM, + gnc_plugin_page_register_summarybar_position_changed, + page); } priv->event_handler_id = qof_event_register_handler @@ -1155,8 +1159,14 @@ gnc_plugin_page_register_destroy_widget (GncPluginPage *plugin_page) page = GNC_PLUGIN_PAGE_REGISTER (plugin_page); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(plugin_page); - gnc_gconf_general_remove_cb(KEY_SUMMARYBAR_POSITION, - gnc_plugin_page_register_summarybar_position_changed, page); + gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_SUMMARYBAR_POSITION_TOP, + gnc_plugin_page_register_summarybar_position_changed, + page); + gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_SUMMARYBAR_POSITION_BOTTOM, + gnc_plugin_page_register_summarybar_position_changed, + page); if (priv->widget == NULL) return; @@ -1721,14 +1731,12 @@ gnc_plugin_page_register_get_long_name (GncPluginPage *plugin_page) } static void -gnc_plugin_page_register_summarybar_position_changed(GConfEntry *entry, - gpointer user_data) +gnc_plugin_page_register_summarybar_position_changed(gpointer prefs, gchar* pref, gpointer user_data) { GncPluginPage *plugin_page; GncPluginPageRegister *page; GncPluginPageRegisterPrivate *priv; GtkPositionType position = GTK_POS_BOTTOM; - gchar *conf_string; g_return_if_fail(user_data != NULL); @@ -1736,14 +1744,8 @@ gnc_plugin_page_register_summarybar_position_changed(GConfEntry *entry, page = GNC_PLUGIN_PAGE_REGISTER (user_data); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(page); - conf_string = gnc_gconf_get_string (GCONF_GENERAL, - KEY_SUMMARYBAR_POSITION, NULL); - if (conf_string) - { - position = gnc_enum_from_nick (GTK_TYPE_POSITION_TYPE, - conf_string, GTK_POS_BOTTOM); - g_free (conf_string); - } + if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_SUMMARYBAR_POSITION_TOP)) + position = GTK_POS_TOP; gtk_box_reorder_child(GTK_BOX(priv->widget), plugin_page->summarybar, diff --git a/src/gnome/gnc-plugin-page-register2.c b/src/gnome/gnc-plugin-page-register2.c index bf6422a5b7..3ed4f91ac4 100644 --- a/src/gnome/gnc-plugin-page-register2.c +++ b/src/gnome/gnc-plugin-page-register2.c @@ -66,13 +66,11 @@ /*################## Added for Reg2 #################*/ #include "dialog-sx-from-trans.h" #include "assistant-stock-split.h" -#include "gnc-gconf-utils.h" #include "gnc-component-manager.h" #include "gnc-date.h" #include "gnc-date-edit.h" #include "gnc-engine.h" #include "gnc-event.h" -#include "gnc-gconf-utils.h" #include "gnc-gnome-utils.h" #include "gnc-gobject-utils.h" #include "gnc-gui-query.h" @@ -113,7 +111,7 @@ static gchar *gnc_plugin_page_register2_get_tab_name (GncPluginPage *plugin_page static gchar *gnc_plugin_page_register2_get_tab_color (GncPluginPage *plugin_page); static gchar *gnc_plugin_page_register2_get_long_name (GncPluginPage *plugin_page); -static void gnc_plugin_page_register2_summarybar_position_changed (GConfEntry *entry, gpointer user_data); +static void gnc_plugin_page_register2_summarybar_position_changed (gpointer prefs, gchar* pref, gpointer user_data); /* Callbacks for the "Filter By" dialog */ void gnc_plugin_page_register2_filter_select_range_cb (GtkRadioButton *button, GncPluginPageRegister2 *page); @@ -1176,9 +1174,15 @@ gnc_plugin_page_register2_create_widget (GncPluginPage *plugin_page) gtk_widget_show_all (plugin_page->summarybar); gtk_box_pack_start (GTK_BOX (priv->widget), plugin_page->summarybar, FALSE, FALSE, 0); - gnc_plugin_page_register2_summarybar_position_changed (NULL, page); - gnc_gconf_general_register_cb (KEY_SUMMARYBAR_POSITION, - gnc_plugin_page_register2_summarybar_position_changed, page); + gnc_plugin_page_register2_summarybar_position_changed (NULL, NULL, page); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_SUMMARYBAR_POSITION_TOP, + gnc_plugin_page_register2_summarybar_position_changed, + page); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_SUMMARYBAR_POSITION_BOTTOM, + gnc_plugin_page_register2_summarybar_position_changed, + page); } priv->event_handler_id = qof_event_register_handler @@ -1242,8 +1246,14 @@ gnc_plugin_page_register2_destroy_widget (GncPluginPage *plugin_page) page = GNC_PLUGIN_PAGE_REGISTER2 (plugin_page); priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page); - gnc_gconf_general_remove_cb (KEY_SUMMARYBAR_POSITION, - gnc_plugin_page_register2_summarybar_position_changed, page); + gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_SUMMARYBAR_POSITION_TOP, + gnc_plugin_page_register2_summarybar_position_changed, + page); + gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_SUMMARYBAR_POSITION_BOTTOM, + gnc_plugin_page_register2_summarybar_position_changed, + page); if (priv->widget == NULL) { @@ -1787,14 +1797,12 @@ gnc_plugin_page_register2_get_long_name (GncPluginPage *plugin_page) } static void -gnc_plugin_page_register2_summarybar_position_changed (GConfEntry *entry, - gpointer user_data) +gnc_plugin_page_register2_summarybar_position_changed (gpointer prefs, gchar* pref, gpointer user_data) { GncPluginPage *plugin_page; GncPluginPageRegister2 *page; GncPluginPageRegister2Private *priv; GtkPositionType position = GTK_POS_BOTTOM; - gchar *conf_string; g_return_if_fail(user_data != NULL); @@ -1802,16 +1810,10 @@ gnc_plugin_page_register2_summarybar_position_changed (GConfEntry *entry, page = GNC_PLUGIN_PAGE_REGISTER2 (user_data); priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page); - conf_string = gnc_gconf_get_string (GCONF_GENERAL, - KEY_SUMMARYBAR_POSITION, NULL); - if (conf_string) - { - position = gnc_enum_from_nick (GTK_TYPE_POSITION_TYPE, - conf_string, GTK_POS_BOTTOM); - g_free (conf_string); - } + if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_SUMMARYBAR_POSITION_TOP)) + position = GTK_POS_TOP; - gtk_box_reorder_child (GTK_BOX (priv->widget), + gtk_box_reorder_child(GTK_BOX(priv->widget), plugin_page->summarybar, (position == GTK_POS_TOP ? 0 : -1) ); } diff --git a/src/gnome/gschemas/org.gnucash.gschema.xml.in b/src/gnome/gschemas/org.gnucash.gschema.xml.in index c814ae73f4..8ff122a5b6 100644 --- a/src/gnome/gschemas/org.gnucash.gschema.xml.in +++ b/src/gnome/gschemas/org.gnucash.gschema.xml.in @@ -44,9 +44,19 @@ Number of automatic decimal places This field specifies the number of automatic decimal places that will be filled in. - - 'days' - Keep all old log/backup files, no files or for a number of days + + false + Do not create log/backup files. + This setting specifies what to do with old log/backups files. "forever" means keep all old files. "never" means no old log/backup files are kept. Each time you save, older versions of the file are removed. "days" means keep old files for a number of days. How many days is defined in key 'retain_days' + + + true + Delete old log/backup files after this many days (0 = never). + This setting specifies what to do with old log/backups files. "forever" means keep all old files. "never" means no old log/backup files are kept. Each time you save, older versions of the file are removed. "days" means keep old files for a number of days. How many days is defined in key 'retain_days' + + + false + Do not delete log/backup files. This setting specifies what to do with old log/backups files. "forever" means keep all old files. "never" means no old log/backup files are kept. Each time you save, older versions of the file are removed. "days" means keep old files for a number of days. How many days is defined in key 'retain_days' @@ -54,9 +64,19 @@ Delete old log/backup files after this many days (0 = never) This setting specifies the number of days after which old log/backup files will be deleted (0 = never). - - 'credit' - Accounts to reverse the balance + + false + Don't sign reverse any accounts. + This setting allows certain accounts to have their balances reversed in sign from positive to negative, or vice versa. The setting "income_expense" is for users who like to see negative expenses and positive income. The setting of "credit" is for users who want to see balances reflect the debit/credit status of the account. The setting "none" doesn't reverse the sign on any balances. + + + true + Sign reverse balances on the following: Credit Card, Payable, Liability, Equity, and Income. + This setting allows certain accounts to have their balances reversed in sign from positive to negative, or vice versa. The setting "income_expense" is for users who like to see negative expenses and positive income. The setting of "credit" is for users who want to see balances reflect the debit/credit status of the account. The setting "none" doesn't reverse the sign on any balances. + + + false + Sign reverse balances on income and expense accounts. This setting allows certain accounts to have their balances reversed in sign from positive to negative, or vice versa. The setting "income_expense" is for users who like to see negative expenses and positive income. The setting of "credit" is for users who want to see balances reflect the debit/credit status of the account. The setting "none" doesn't reverse the sign on any balances. @@ -84,9 +104,14 @@ Width of notebook tabs This key specifies the maximum width of notebook tabs. If the text in the tab is longer than this value (the test is approximate) then the tab label will have the middle cut and replaced with an ellipsis. - - 'locale' - Source of default account currency + + true + Use the system locale currency for all newly created accounts. + This setting controls the source of the default currency for new accounts. If set to "locale" then GnuCash will retrieve the default currency from the user's locale setting. If set to "other", GnuCash will use the setting specified by the currency_other key. + + + false + Use the specified currency for all newly created accounts. This setting controls the source of the default currency for new accounts. If set to "locale" then GnuCash will retrieve the default currency from the user's locale setting. If set to "other", GnuCash will use the setting specified by the currency_other key. @@ -104,9 +129,14 @@ Date format choice This setting chooses the way dates are displayed in GnuCash. Possible values for this setting are "locale" to use the system locale setting, "ce" for Continental Europe style dates, "iso" for ISO 8601 standard dates , "uk" for United Kingdom style dates, and "us" for United States style dates. - - 'thisyear' - How to interpret dates without a year + + true + In the current calendar year + When a date is entered without year it can be completed so that it will be within the current calendar year or close to the current date based on a sliding window starting a set number of months backwards in time. + + + false + In a sliding 12-month window starting a configurable number of months before the current month When a date is entered without year it can be completed so that it will be within the current calendar year or close to the current date based on a sliding window starting a set number of months backwards in time. @@ -119,14 +149,34 @@ Show splash screen If active, a splash screen will be shown at startup. Otherwise no splash screen will be shown. - - 'top' - Position of the notebook tabs + + true + Display the notebook tabs at the top of the window. This setting determines the edge at which the tabs for switching pages in notebooks are drawn. Possible values are "top", "left", "bottom" and "right". It defaults to "top". - - 'bottom' - Position of the summary bar + + false + Display the notebook tabs at the bottom of the window. + This setting determines the edge at which the tabs for switching pages in notebooks are drawn. Possible values are "top", "left", "bottom" and "right". It defaults to "top". + + + false + Display the notebook tabs at the left of the window. + This setting determines the edge at which the tabs for switching pages in notebooks are drawn. Possible values are "top", "left", "bottom" and "right". It defaults to "top". + + + false + Display the notebook tabs at the right of the window. + This setting determines the edge at which the tabs for switching pages in notebooks are drawn. Possible values are "top", "left", "bottom" and "right". It defaults to "top". + + + false + Display the summary bar at the top of the page. + This setting determines the edge at which the summary bar for various pages is drawn. Possible values are "top" and "bottom". It defaults to "bottom". + + + true + Display the summary bar at the bottom of the page. This setting determines the edge at which the summary bar for various pages is drawn. Possible values are "top" and "bottom". It defaults to "bottom". @@ -184,9 +234,19 @@ Show vertical borders in a register Show vertical borders between columns in a register. If active the border between cells will be indicated with a heavy line. Otherwise the border between cells will not be marked. - - 'ledger' - Default view style for new register + + true + Show all transactions on one line. (Two in double line mode.) + This field specifies the default view style when opening a new register window. Possible values are "ledger", "auto-ledger" and "journal". The "ledger" setting says to show each transaction on one or two lines. The "auto-ledger" setting does the same, but also expands only the current transaction to show all splits. The "journal" setting shows all transactions in expanded form. + + + false + Automatically expand the current transaction to show all splits. All other transactions are shown on one line. (Two in double line mode.) + This field specifies the default view style when opening a new register window. Possible values are "ledger", "auto-ledger" and "journal". The "ledger" setting says to show each transaction on one or two lines. The "auto-ledger" setting does the same, but also expands only the current transaction to show all splits. The "journal" setting shows all transactions in expanded form. + + + false + All transactions are expanded to show all splits. This field specifies the default view style when opening a new register window. Possible values are "ledger", "auto-ledger" and "journal". The "ledger" setting says to show each transaction on one or two lines. The "auto-ledger" setting does the same, but also expands only the current transaction to show all splits. The "journal" setting shows all transactions in expanded form. @@ -242,10 +302,20 @@ Source of default report currency This setting controls the default currency used for reports. If set to "locale" then GnuCash will retrieve the default currency from the user's locale setting. If set to "other", GnuCash will use the setting specified by the currency_other key. + + true + Use the system locale currency for all newly created reports. + This setting controls the default currency used for reports. If set to "locale" then GnuCash will retrieve the default currency from the user's locale setting. If set to "other", GnuCash will use the setting specified by the currency_other key. + + + false + Use the specified currency for all newly created reports. + This setting controls the source of the default currency for new accounts. If set to "locale" then GnuCash will retrieve the default currency from the user's locale setting. If set to "other", GnuCash will use the setting specified by the currency_other key. + '' Default currency for new reports - This setting specifies the default currency used for reports if the currency_choice setting is set to "other". This field must contain the three letter ISO 4217 code for a currency (e.g. USD, GBP, RUB). + This setting controls the default currency used for reports. If set to "locale" then GnuCash will retrieve the default currency from the user's locale setting. If set to "other", GnuCash will use the setting specified by the currency_other key. diff --git a/src/gnome/gschemas/org.gnucash.window.pages.account.tree.gschema.xml.in b/src/gnome/gschemas/org.gnucash.window.pages.account.tree.gschema.xml.in index 33f160d753..8c1dbb1969 100644 --- a/src/gnome/gschemas/org.gnucash.window.pages.account.tree.gschema.xml.in +++ b/src/gnome/gschemas/org.gnucash.window.pages.account.tree.gschema.xml.in @@ -10,9 +10,14 @@ Show non currency commodities If active, non currency commodities (stocks) will be shown. Otherwise they will be hidden. - - 'relative' - Profit/loss starting date type + + true + Use relative profit/loss starting date + This setting controls the type of starting date used in profit/loss calculations. If set to "absolute" then GnuCash will retrieve the starting date specified by the start_date key. If set to anything else, GnuCash will retrieve the starting date specified by the start_period key. + + + false + Use absolute profit/loss starting date This setting controls the type of starting date used in profit/loss calculations. If set to "absolute" then GnuCash will retrieve the starting date specified by the start_date key. If set to anything else, GnuCash will retrieve the starting date specified by the start_period key. @@ -25,9 +30,14 @@ Starting time period identifier This setting controls the starting date set in profit/loss calculations if the start_choice setting is set to anything other than "absolute". This field should contain a value between 0 and 8. - - 'relative' - Profit/loss ending date type + + true + Use relative profit/loss ending date + This setting controls the type of ending date used in profit/loss calculations. If set to "absolute" then GnuCash will retrieve the ending date specified by the end_date key. If set to anything else, GnuCash will retrieve the ending date specified by the end_period key. + + + false + Use absolute profit/loss ending date This setting controls the type of ending date used in profit/loss calculations. If set to "absolute" then GnuCash will retrieve the ending date specified by the end_date key. If set to anything else, GnuCash will retrieve the ending date specified by the end_period key. diff --git a/src/import-export/qif-import/assistant-qif-import.c b/src/import-export/qif-import/assistant-qif-import.c index 558a85a355..89c6d0eba1 100644 --- a/src/import-export/qif-import/assistant-qif-import.c +++ b/src/import-export/qif-import/assistant-qif-import.c @@ -48,7 +48,6 @@ #include "gnc-guile-utils.h" #include "gnc-currency-edit.h" #include "gnc-ui-util.h" -#include "gnc-gconf-utils.h" #include "gnc-gtk-utils.h" #include "gnc-main-window.h" #include "gnc-plugin-page-account-tree.h" @@ -59,10 +58,11 @@ #include "swig-runtime.h" #define ASSISTANT_QIF_IMPORT_CM_CLASS "assistant-qif-import" -#define GCONF_SECTION "dialogs/import/qif" #define GNC_PREFS_GROUP "dialogs.import.qif" #define GNC_PREF_SHOW_DOC "show_doc" -#define GCONF_NAME_DEFAULT_TRANSACTION_STATUS "default_status" +#define GNC_PREF_DEFAULT_TRANS_STATUS_CLEARED "default_status-cleared" +#define GNC_PREF_DEFAULT_TRANS_STATUS_NOTCLEARED "default_status-notcleared" +#define GNC_PREF_DEFAULT_TRANS_STATUS_RECONCILED "default_status-reconciled" #define PREV_ROW "prev_row" @@ -1372,8 +1372,6 @@ gnc_ui_qif_import_assistant_get_mappings(QIFImportWindow * w) static void get_preferences(QIFImportWindow *wind) { - GError * err = NULL; - gchar *status_pref = NULL; gchar tmp_transaction_status = 'n'; g_return_if_fail(wind); @@ -1383,27 +1381,11 @@ get_preferences(QIFImportWindow *wind) gnc_prefs_get_bool (GNC_PREFS_GROUP, GNC_PREF_SHOW_DOC); /* Clear / Reconcile transaction if not specified in QIF file. */ - status_pref = gnc_gconf_get_string( - GCONF_SECTION, GCONF_NAME_DEFAULT_TRANSACTION_STATUS, &err); - if (err != NULL) - { - g_warning("QIF import: gnc_gconf_get_string error: %s", err->message); - g_error_free(err); - g_warning("QIF import: Couldn't get %s setting from gconf.", - GCONF_NAME_DEFAULT_TRANSACTION_STATUS); - } - else - { - if (g_strcmp0(status_pref, "cleared") == 0) - { - tmp_transaction_status = 'c'; - } - else if (g_strcmp0(status_pref, "reconciled") == 0) - { - tmp_transaction_status = 'y'; - } - } - g_free(status_pref); + if (gnc_prefs_get_bool (GNC_PREFS_GROUP, GNC_PREF_DEFAULT_TRANS_STATUS_CLEARED)) + tmp_transaction_status = 'c'; + else if (gnc_prefs_get_bool (GNC_PREFS_GROUP, GNC_PREF_DEFAULT_TRANS_STATUS_RECONCILED)) + tmp_transaction_status = 'y'; + wind->transaction_status = SCM_MAKE_CHAR(tmp_transaction_status); } diff --git a/src/import-export/qif-import/dialog-account-picker.glade b/src/import-export/qif-import/dialog-account-picker.glade index 974d85ba4c..96ea73434b 100644 --- a/src/import-export/qif-import/dialog-account-picker.glade +++ b/src/import-export/qif-import/dialog-account-picker.glade @@ -48,7 +48,7 @@ - + _Reconciled True True @@ -70,7 +70,7 @@ - + _Cleared True True @@ -81,7 +81,7 @@ False True True - gconf/dialogs/import/qif/default_status/reconciled + pref/dialogs.import.qif/default_status-reconciled 5 @@ -92,7 +92,7 @@ - + _Not cleared True True @@ -103,7 +103,7 @@ False True True - gconf/dialogs/import/qif/default_status/reconciled + pref/dialogs.import.qif/default_status-reconciled 4 diff --git a/src/import-export/qif-import/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in b/src/import-export/qif-import/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in index f68e0f12c2..dc0f7a06c2 100644 --- a/src/import-export/qif-import/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in +++ b/src/import-export/qif-import/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in @@ -1,10 +1,20 @@ - - 'not_cleared' + + true Default QIF transaction status Default status for QIF transaction when not specified in QIF file. + + false + Default QIF transaction status + Default status for QIF transaction when not specified in QIF file. + + + false + When the status is not specified in a QIF file, the transactions are marked as reconciled. + Default status for QIF transaction when not specified in QIF file. + (-1,-1,-1,-1) Last window position and size diff --git a/src/register/ledger-core/gnc-ledger-display.c b/src/register/ledger-core/gnc-ledger-display.c index 66aa19101d..c41067b09c 100644 --- a/src/register/ledger-core/gnc-ledger-display.c +++ b/src/register/ledger-core/gnc-ledger-display.c @@ -34,7 +34,6 @@ #include "gnc-date.h" #include "gnc-engine.h" #include "gnc-event.h" -#include "gnc-gconf-utils.h" #include "gnc-ledger-display.h" #include "gnc-prefs.h" #include "gnc-ui-util.h" @@ -47,8 +46,11 @@ #define REGISTER_GL_CM_CLASS "register-gl" #define REGISTER_TEMPLATE_CM_CLASS "register-template" -#define GNC_PREF_DOUBLE_LINE_MODE "double_line_mode" -#define GNC_PREF_MAX_TRANS "max_transactions" +#define GNC_PREF_DOUBLE_LINE_MODE "double_line_mode" +#define GNC_PREF_MAX_TRANS "max_transactions" +#define GNC_PREF_DEFAULT_STYLE_LEDGER "default_style-ledger" +#define GNC_PREF_DEFAULT_STYLE_AUTOLEDGER "default_style-autoledger" +#define GNC_PREF_DEFAULT_STYLE_JOURNAL "default_style-journal" struct gnc_ledger_display @@ -197,32 +199,13 @@ static SplitRegisterStyle gnc_get_default_register_style (GNCAccountType type) { SplitRegisterStyle new_style = REG_STYLE_LEDGER; - gchar *style_string; - switch (type) - { -#if 0 - case ACCT_TYPE_PAYABLE: - case ACCT_TYPE_RECEIVABLE: - new_style = REG_STYLE_LEDGER; - break; -#endif - - default: - style_string = gnc_gconf_get_string(GCONF_GENERAL_REGISTER, - "default_style", NULL); - if (g_strcmp0(style_string, "journal") == 0) - new_style = REG_STYLE_JOURNAL; - else if (g_strcmp0(style_string, "auto_ledger") == 0) - new_style = REG_STYLE_AUTO_LEDGER; - else - new_style = REG_STYLE_LEDGER; - - if (style_string != NULL) - g_free(style_string); - - break; - } + if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER, + GNC_PREF_DEFAULT_STYLE_JOURNAL)) + new_style = REG_STYLE_JOURNAL; + else if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER, + GNC_PREF_DEFAULT_STYLE_AUTOLEDGER)) + new_style = REG_STYLE_AUTO_LEDGER; return new_style; } diff --git a/src/register/ledger-core/gnc-ledger-display2.c b/src/register/ledger-core/gnc-ledger-display2.c index feeb63ca13..585ced3895 100644 --- a/src/register/ledger-core/gnc-ledger-display2.c +++ b/src/register/ledger-core/gnc-ledger-display2.c @@ -35,7 +35,6 @@ #include "gnc-date.h" #include "gnc-engine.h" #include "gnc-event.h" -#include "gnc-gconf-utils.h" #include "gnc-ledger-display2.h" #include "gnc-prefs.h" #include "gnc-ui-util.h" @@ -51,8 +50,11 @@ #define REGISTER_GL_CM_CLASS "register-gl" #define REGISTER_TEMPLATE_CM_CLASS "register-template" -#define GNC_PREF_DOUBLE_LINE_MODE "double_line_mode" -#define GNC_PREF_MAX_TRANS "max_transactions" +#define GNC_PREF_DOUBLE_LINE_MODE "double_line_mode" +#define GNC_PREF_MAX_TRANS "max_transactions" +#define GNC_PREF_DEFAULT_STYLE_LEDGER "default_style-ledger" +#define GNC_PREF_DEFAULT_STYLE_AUTOLEDGER "default_style-autoledger" +#define GNC_PREF_DEFAULT_STYLE_JOURNAL "default_style-journal" struct gnc_ledger_display2 @@ -202,37 +204,17 @@ find_by_reg (gpointer find_data, gpointer user_data) return ld->model == model; } - -static SplitRegisterStyle2 +static SplitRegisterStyle gnc_get_default_register_style (GNCAccountType type) { - SplitRegisterStyle2 new_style = REG2_STYLE_LEDGER; - gchar *style_string; + SplitRegisterStyle new_style = REG2_STYLE_LEDGER; - switch (type) - { -#if 0 - case ACCT_TYPE_PAYABLE: - case ACCT_TYPE_RECEIVABLE: - new_style = REG_STYLE_LEDGER; - break; -#endif - - default: - style_string = gnc_gconf_get_string(GCONF_GENERAL_REGISTER, - "default_style", NULL); - if (g_strcmp0(style_string, "journal") == 0) - new_style = REG2_STYLE_JOURNAL; - else if (g_strcmp0(style_string, "auto_ledger") == 0) - new_style = REG2_STYLE_AUTO_LEDGER; - else - new_style = REG2_STYLE_LEDGER; - - if (style_string != NULL) - g_free(style_string); - - break; - } + if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER, + GNC_PREF_DEFAULT_STYLE_JOURNAL)) + new_style = REG2_STYLE_JOURNAL; + else if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER, + GNC_PREF_DEFAULT_STYLE_AUTOLEDGER)) + new_style = REG2_STYLE_AUTO_LEDGER; return new_style; } @@ -607,7 +589,7 @@ refresh_handler (GHashTable *changes, gpointer user_data) //FIXME Not Needed ? gnc_ledger_display2_set_watches (ld, splits); // gnc_ledger_display2_set_watches (ld, splits); - //gconf changes come this way + //preference changes come this way gnc_ledger_display2_refresh_internal (ld, splits); LEAVE(" ");