Gnc-Prefs: migrate most preferences found in app-utils

This required  changes in dependent modules as well. And obviously
the gnc-gconf-utils.[ch] files are not removed yet. Too many
other files still require those.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@23228 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Geert Janssens
2013-10-07 14:08:17 +00:00
parent ac1003cc4e
commit 8984c78f94
18 changed files with 109 additions and 112 deletions

View File

@@ -26,6 +26,7 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
#include <libguile.h>
#include <ctype.h>
#include <errno.h>
@@ -43,7 +44,7 @@
#include "qof.h"
#include "guile-mappings.h"
#include "gnc-gconf-utils.h"
#include "gnc-prefs.h"
#include "gnc-module/gnc-module.h"
#include "engine/Account.h"
#include "engine/Transaction.h"
@@ -57,9 +58,9 @@
#include "gnc-features.h"
#include "gnc-guile-utils.h"
#define KEY_CURRENCY_CHOICE "currency_choice"
#define KEY_CURRENCY_OTHER "currency_other"
#define KEY_REVERSED_ACCOUNTS "reversed_accounts"
#define GNC_PREF_CURRENCY_CHOICE "currency_choice"
#define GNC_PREF_CURRENCY_OTHER "currency_other"
#define GNC_PREF_REVERSED_ACCOUNTS "reversed_accounts"
static QofLogModule log_module = GNC_MOD_GUI;
@@ -69,7 +70,7 @@ static int auto_decimal_places = 2; /* default, can be changed */
static gboolean reverse_balance_inited = FALSE;
static gboolean reverse_type[NUM_ACCOUNT_TYPES];
/* Cache currency ISO codes and only look them up in gconf when
/* Cache currency ISO codes and only look them up in the settings when
* absolutely necessary. Can't cache a pointer to the data structure
* as that will change any time the book changes. */
static gchar *user_default_currency = NULL;
@@ -87,7 +88,7 @@ gnc_configure_account_separator (void)
const gchar *separator;
char *string;
string = gnc_gconf_get_string(GCONF_GENERAL, KEY_ACCOUNT_SEPARATOR, NULL);
string = gnc_prefs_get_string(GNC_PREFS_GROUP_GENERAL, GNC_PREF_ACCOUNT_SEPARATOR);
if (!string || !*string || g_strcmp0(string, "colon") == 0)
separator = ":";
@@ -118,7 +119,7 @@ gnc_configure_reverse_balance (void)
for (i = 0; i < NUM_ACCOUNT_TYPES; i++)
reverse_type[i] = FALSE;
choice = gnc_gconf_get_string(GCONF_GENERAL, KEY_REVERSED_ACCOUNTS, NULL);
choice = gnc_prefs_get_string(GNC_PREFS_GROUP_GENERAL, GNC_PREF_REVERSED_ACCOUNTS);
if (g_strcmp0 (choice, "none") == 0)
{
@@ -170,11 +171,11 @@ gnc_reverse_balance (const Account *account)
gchar *
gnc_get_default_directory (const gchar *gconf_section)
gnc_get_default_directory (const gchar *section)
{
gchar *dir;
dir = gnc_gconf_get_string (gconf_section, KEY_LAST_PATH, NULL);
dir = gnc_prefs_get_string (section, GNC_PREF_LAST_PATH);
if (!dir)
#ifdef G_OS_WIN32
dir = g_strdup (g_get_user_data_dir ()); /* equivalent of "My Documents" */
@@ -186,9 +187,9 @@ gnc_get_default_directory (const gchar *gconf_section)
}
void
gnc_set_default_directory (const gchar *gconf_section, const gchar *directory)
gnc_set_default_directory (const gchar *section, const gchar *directory)
{
gnc_gconf_set_string(gconf_section, KEY_LAST_PATH, directory, NULL);
gnc_prefs_set_string(section, GNC_PREF_LAST_PATH, directory);
}
QofBook *
@@ -279,8 +280,8 @@ gchar *
gnc_get_account_name_for_register(const Account *account)
{
gboolean show_leaf_accounts;
show_leaf_accounts = gnc_gconf_get_bool(GCONF_GENERAL_REGISTER,
KEY_SHOW_LEAF_ACCOUNT_NAMES, NULL);
show_leaf_accounts = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL_REGISTER,
GNC_PREF_SHOW_LEAF_ACCT_NAMES);
if (show_leaf_accounts)
return g_strdup (xaccAccountGetName (account));
@@ -292,8 +293,8 @@ Account *
gnc_account_lookup_for_register(const Account *base_account, const char *name)
{
gboolean show_leaf_accounts;
show_leaf_accounts = gnc_gconf_get_bool(GCONF_GENERAL_REGISTER,
KEY_SHOW_LEAF_ACCOUNT_NAMES, NULL);
show_leaf_accounts = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL_REGISTER,
GNC_PREF_SHOW_LEAF_ACCT_NAMES);
if (show_leaf_accounts)
return gnc_account_lookup_by_name (base_account, name);
@@ -881,7 +882,7 @@ gnc_locale_default_currency_nodefault (void)
/* Some very old locales (notably on win32) still announce a euro
currency as default, although it has been replaced by EUR in
2001. We use EUR as default in that case, but the user can always
override from gconf. */
override from gsettings. */
if (gnc_is_euro_currency (currency))
currency = gnc_get_euro();
@@ -901,7 +902,7 @@ gnc_locale_default_currency (void)
static gnc_commodity *
gnc_default_currency_common (gchar *requested_currency,
const gchar *gconf_section)
const gchar *section)
{
gnc_commodity *currency = NULL;
gchar *choice, *mnemonic;
@@ -911,10 +912,10 @@ gnc_default_currency_common (gchar *requested_currency,
GNC_COMMODITY_NS_CURRENCY,
requested_currency);
choice = gnc_gconf_get_string(gconf_section, KEY_CURRENCY_CHOICE, NULL);
choice = gnc_prefs_get_string(section, GNC_PREF_CURRENCY_CHOICE);
if (g_strcmp0(choice, "other") == 0)
{
mnemonic = gnc_gconf_get_string(gconf_section, KEY_CURRENCY_OTHER, NULL);
mnemonic = gnc_prefs_get_string(section, GNC_PREF_CURRENCY_OTHER);
currency = gnc_commodity_table_lookup(gnc_get_current_commodities(),
GNC_COMMODITY_NS_CURRENCY, mnemonic);
DEBUG("mnemonic %s, result %p", mnemonic ? mnemonic : "(null)", currency);
@@ -937,7 +938,7 @@ gnc_default_currency_common (gchar *requested_currency,
gnc_commodity *
gnc_default_currency (void)
{
return gnc_default_currency_common (user_default_currency, GCONF_GENERAL);
return gnc_default_currency_common (user_default_currency, GNC_PREFS_GROUP_GENERAL);
}
gnc_commodity * gnc_account_or_default_currency(const Account* account, gboolean * currency_from_account_found)
@@ -970,11 +971,11 @@ gnc_commodity * gnc_account_or_default_currency(const Account* account, gboolean
gnc_commodity *
gnc_default_report_currency (void)
{
return gnc_default_currency_common (user_report_currency, GCONF_GENERAL_REPORT);
return gnc_default_currency_common (user_report_currency, GNC_PREFS_GROUP_GENERAL_REPORT);
}
static void
gnc_currency_changed_cb (GConfEntry *entry, gpointer user_data)
gnc_currency_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
user_default_currency = NULL;
user_report_currency = NULL;
@@ -2278,31 +2279,25 @@ xaccParseAmountExtended (const char * in_str, gboolean monetary,
/* enable/disable the auto_decimal_enabled option */
static void
gnc_set_auto_decimal_enabled (GConfEntry *entry, gpointer user_data)
gnc_set_auto_decimal_enabled (GSettings *settings, gchar *key, gpointer user_data)
{
GConfValue *value;
value = gconf_entry_get_value(entry);
auto_decimal_enabled = gconf_value_get_bool(value);
auto_decimal_enabled = g_settings_get_boolean (settings, key);
}
/* set the number of auto decimal places to use */
static void
gnc_set_auto_decimal_places (GConfEntry *entry, gpointer user_data)
gnc_set_auto_decimal_places (GSettings *settings, gchar *key, gpointer user_data)
{
GConfValue *value;
value = gconf_entry_get_value(entry);
auto_decimal_places = gconf_value_get_float(value);
auto_decimal_places = g_settings_get_int (settings, key);
}
static void
gnc_auto_decimal_init (void)
{
auto_decimal_enabled =
gnc_gconf_get_bool(GCONF_GENERAL, "auto_decimal_point", NULL);
gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_AUTO_DECIMAL_POINT);
auto_decimal_places =
(int)gnc_gconf_get_float(GCONF_GENERAL, "auto_decimal_places", NULL);
gnc_prefs_get_float (GNC_PREFS_GROUP_GENERAL, GNC_PREF_AUTO_DECIMAL_PLACES);
}
void
@@ -2311,21 +2306,17 @@ gnc_ui_util_init (void)
gnc_configure_account_separator ();
gnc_auto_decimal_init();
gnc_gconf_general_register_cb(KEY_ACCOUNT_SEPARATOR,
(GncGconfGeneralCb)gnc_configure_account_separator,
NULL);
gnc_gconf_general_register_cb(KEY_REVERSED_ACCOUNTS,
(GncGconfGeneralCb)gnc_configure_reverse_balance,
NULL);
gnc_gconf_general_register_cb(KEY_CURRENCY_CHOICE,
gnc_currency_changed_cb, NULL);
gnc_gconf_general_register_cb(KEY_CURRENCY_OTHER,
gnc_currency_changed_cb, NULL);
gnc_gconf_general_register_cb("auto_decimal_point",
gnc_set_auto_decimal_enabled,
NULL);
gnc_gconf_general_register_cb("auto_decimal_places",
gnc_set_auto_decimal_places,
NULL);
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_configure_reverse_balance, NULL);
gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_CURRENCY_CHOICE,
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, GNC_PREF_AUTO_DECIMAL_POINT,
gnc_set_auto_decimal_enabled, NULL);
gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_AUTO_DECIMAL_PLACES,
gnc_set_auto_decimal_places, NULL);
}