diff --git a/src/gnome-utils/dialog-preferences.c b/src/gnome-utils/dialog-preferences.c index eef2fd7d59..cb5e3f44eb 100644 --- a/src/gnome-utils/dialog-preferences.c +++ b/src/gnome-utils/dialog-preferences.c @@ -1391,6 +1391,9 @@ gnc_preferences_dialog_create(void) GHashTable *prefs_table; GDate* gdate; gchar buf[128]; + GtkListStore *store; + GtkTreePath *path; + GtkTreeIter iter; gnc_commodity *locale_currency; const gchar *currency_name; @@ -1406,6 +1409,7 @@ gnc_preferences_dialog_create(void) gnc_builder_add_from_file (builder, "dialog-preferences.glade", "new_search_limit_adj"); gnc_builder_add_from_file (builder, "dialog-preferences.glade", "retain_days_adj"); gnc_builder_add_from_file (builder, "dialog-preferences.glade", "tab_width_adj"); + gnc_builder_add_from_file (builder, "dialog-preferences.glade", "date_formats"); gnc_builder_add_from_file (builder, "dialog-preferences.glade", "GnuCash Preferences"); dialog = GTK_WIDGET(gtk_builder_get_object (builder, "GnuCash Preferences")); @@ -1477,10 +1481,12 @@ gnc_preferences_dialog_create(void) DEBUG("Done with interesting widgets."); /* Other stuff */ - gdate = g_date_new_dmy(31, G_DATE_JULY, 2005); + gdate = g_date_new_dmy(31, G_DATE_JULY, 2013); g_date_strftime(buf, sizeof(buf), "%x", gdate); - label = GTK_WIDGET(gtk_builder_get_object (builder, "locale_date_sample")); - gtk_label_set_text(GTK_LABEL(label), buf); + store = GTK_LIST_STORE(gtk_builder_get_object (builder, "date_formats")); + path = gtk_tree_path_new_from_indices (QOF_DATE_FORMAT_LOCALE, -1); + if (gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path)) + gtk_list_store_set (store, &iter, 1, buf, -1); g_date_free(gdate); locale_currency = gnc_locale_default_currency (); diff --git a/src/gnome-utils/gnc-gnome-utils.c b/src/gnome-utils/gnc-gnome-utils.c index 86d3ebda90..28afd959b8 100644 --- a/src/gnome-utils/gnc-gnome-utils.c +++ b/src/gnome-utils/gnc-gnome-utils.c @@ -127,31 +127,20 @@ gnc_commodity_help_cb (void) static void gnc_configure_date_format (void) { - char *format_code = gnc_gconf_get_string(GCONF_GENERAL, - KEY_DATE_FORMAT, NULL); + QofDateFormat df = gnc_prefs_get_int(GCONF_GENERAL, + GNC_PREF_DATE_FORMAT); - QofDateFormat df; - - if (format_code == NULL) - format_code = g_strdup("locale"); - if (*format_code == '\0') + /* Only a subset of the qof date formats is currently + * supported for date entry. + */ + if ((df > QOF_DATE_FORMAT_LOCALE) + || (df > QOF_DATE_FORMAT_LOCALE)) { - g_free(format_code); - format_code = g_strdup("locale"); - } - - if (gnc_date_string_to_dateformat(format_code, &df)) - { - PERR("Incorrect date format code"); - if (format_code != NULL) - free(format_code); + PERR("Incorrect date format"); return; } qof_date_format_set(df); - - if (format_code != NULL) - free(format_code); } /* gnc_configure_date_completion @@ -643,8 +632,10 @@ gnc_gui_init(void) gnc_configure_date_format(); gnc_configure_date_completion(); - gnc_gconf_general_register_cb( - KEY_DATE_FORMAT, (GncGconfGeneralCb)gnc_configure_date_format, NULL); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, + 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, diff --git a/src/gnome-utils/gnc-period-select.c b/src/gnome-utils/gnc-period-select.c index 83dde2e18e..064d876f87 100644 --- a/src/gnome-utils/gnc-period-select.c +++ b/src/gnome-utils/gnc-period-select.c @@ -35,8 +35,8 @@ #include #include "gnc-date.h" -#include "gnc-gconf-utils.h" #include "gnc-period-select.h" +#include "gnc-prefs.h" #include enum @@ -150,7 +150,7 @@ gnc_period_sample_update_date_label (GncPeriodSelect *period) return; which = gtk_combo_box_get_active (GTK_COMBO_BOX (priv->selector)); if (which == -1) - date = g_date_new_dmy (1, 1, 1970); + date = g_date_new_dmy (31, 7, 2013); else if (priv->start) date = gnc_accounting_period_start_gdate (which, priv->fy_end, @@ -186,17 +186,19 @@ gnc_period_sample_combobox_changed (GtkComboBox *box, GncPeriodSelect *period) /** Handle an application wide change in the date format. This - * function will be called when the GConf key for the date format is + * function will be called when the preference for the date format is * updated. It doesn't really care what the new format is, because * the date string is generated elsewhere. It just needs to know to * update the date label so that it matches the newly selected format. * - * @param unused The new value for the Gnucash date format. + * @param prefs Unused. + * + * @param pref Unused. * * @param period The GncPeriodSelect that needs to be updated. */ static void -gnc_period_sample_new_date_format (GConfEntry *unused, +gnc_period_sample_new_date_format (gpointer prefs, gchar *pref, GncPeriodSelect *period) { gnc_period_sample_update_date_label(period); @@ -639,8 +641,8 @@ gnc_period_select_finalize (GObject *object) priv = GNC_PERIOD_SELECT_GET_PRIVATE(period); /* Stop tracking changes to date formatting */ - gnc_gconf_general_remove_cb(KEY_DATE_FORMAT, - (GncGconfGeneralCb)gnc_period_sample_new_date_format, period); + gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, GNC_PREF_DATE_FORMAT, + gnc_period_sample_new_date_format, period); /* The selector and date_label were added to the hbox. They will be * freed automatically. */ @@ -697,8 +699,8 @@ gnc_period_select_new (gboolean starting_labels) } /* Track changes to date formatting */ - gnc_gconf_general_register_cb(KEY_DATE_FORMAT, - (GncGconfGeneralCb)gnc_period_sample_new_date_format, period); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_DATE_FORMAT, + gnc_period_sample_new_date_format, period); return GTK_WIDGET (period); } diff --git a/src/gnome-utils/gtkbuilder/dialog-preferences.glade b/src/gnome-utils/gtkbuilder/dialog-preferences.glade index ff21b18083..f9db64ad94 100644 --- a/src/gnome-utils/gtkbuilder/dialog-preferences.glade +++ b/src/gnome-utils/gtkbuilder/dialog-preferences.glade @@ -21,6 +21,36 @@ 1 4 + + + + + + + + + + US + 07/31/2013 + + + UK + 31/07/2013 + + + Europe + 31.07.2013 + + + ISO + 2013-07-31 + + + Locale + (dummy) + + + False GnuCash Preferences @@ -942,7 +972,7 @@ True False 6 - 17 + 14 4 @@ -1025,15 +1055,6 @@ - - - - - - - - - False @@ -1043,8 +1064,8 @@ 4 - 10 - 11 + 6 + 7 GTK_FILL @@ -1056,196 +1077,12 @@ 0 - 9 - 10 - GTK_FILL - - - - - - True - False - 0 - 2005-07-31 - - - 1 - 2 - 8 - 9 - GTK_FILL - - - - - - True - False - 0 - 31.07.2005 - - - 1 - 2 - 7 - 8 - GTK_FILL - - - - - - True - False - 0 - 31/07/2005 - - - 1 - 2 - 6 - 7 - GTK_FILL - - - - - - True - False - 0 - 07/31/2005 - - - 1 - 2 5 6 GTK_FILL - - - True - False - 0 - - - 1 - 2 - 4 - 5 - GTK_FILL - - - - - - _ISO: - True - True - False - True - Use the date format specified by the ISO-8601 standard. - Use the date format specified by the ISO-8601 standard. - True - True - True - - - 8 - 9 - GTK_FILL - - 12 - - - - - _Europe: - True - True - False - True - Use the date format common in continental Europe. - Use the date format common in continental Europe. - True - True - gconf/general/date_format/iso - - - 7 - 8 - GTK_FILL - - 12 - - - - - U_K: - True - True - False - True - Use the date format common in the United Kingdom. - Use the date format common in the United Kingdom. - True - True - gconf/general/date_format/iso - - - 6 - 7 - GTK_FILL - - 12 - - - - - _US: - True - True - False - True - Use the date format common in the United States. - Use the date format common in the United States. - True - True - gconf/general/date_format/iso - - - 5 - 6 - GTK_FILL - - 12 - - - - - Loc_ale: - True - True - False - True - Use the date format specified by the system locale. - Use the date format specified by the system locale. - True - True - gconf/general/date_format/iso - - - 4 - 5 - GTK_FILL - - 12 - - True @@ -1318,8 +1155,8 @@ True - 12 - 13 + 8 + 9 GTK_FILL @@ -1334,8 +1171,8 @@ 4 - 13 - 14 + 9 + 10 GTK_FILL @@ -1358,8 +1195,8 @@ 2 - 14 - 15 + 10 + 11 GTK_FILL 12 @@ -1381,8 +1218,8 @@ many months before the current month: 2 - 15 - 16 + 11 + 12 GTK_FILL 12 @@ -1408,12 +1245,40 @@ many months before the current month: 1 - 16 - 17 + 12 + 13 + + + True + False + True + Use the date format specified by the system locale. + Use the date format specified by the system locale. + date_formats + 3 + + + + 0 + + + + + + 1 + + + + + 4 + 5 + GTK_FILL + + 2 @@ -2097,7 +1962,7 @@ many months before the current month: True False 6 - 10 + 5 4 12 @@ -2235,27 +2100,6 @@ many months before the current month: - - - - - - - - - - - - - - - - - - - - - True @@ -2265,7 +2109,6 @@ many months before the current month: True - 4 GTK_FILL @@ -2365,6 +2208,36 @@ many months before the current month: GTK_FILL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4 diff --git a/src/gnome/gschemas/org.gnucash.gschema.xml.in b/src/gnome/gschemas/org.gnucash.gschema.xml.in index 66e8414bf9..986f61bcaf 100644 --- a/src/gnome/gschemas/org.gnucash.gschema.xml.in +++ b/src/gnome/gschemas/org.gnucash.gschema.xml.in @@ -104,8 +104,8 @@ Use 24 hour time format If active, use a 24 hour time format. Otherwise use a 12 hour time format. - - 'locale' + + 4 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. diff --git a/src/libqof/qof/gnc-date.h b/src/libqof/qof/gnc-date.h index b846c28787..a3d1c9a0ae 100644 --- a/src/libqof/qof/gnc-date.h +++ b/src/libqof/qof/gnc-date.h @@ -120,13 +120,13 @@ typedef enum QOF_DATE_FORMAT_UK, /**< Britain: dd/mm/yyyy */ QOF_DATE_FORMAT_CE, /**< Continental Europe: dd.mm.yyyy */ QOF_DATE_FORMAT_ISO, /**< ISO: yyyy-mm-dd */ - QOF_DATE_FORMAT_UTC, /**< UTC: 2004-12-12T23:39:11Z */ QOF_DATE_FORMAT_LOCALE, /**< Take from locale information */ + QOF_DATE_FORMAT_UTC, /**< UTC: 2004-12-12T23:39:11Z */ QOF_DATE_FORMAT_CUSTOM /**< Used by the check printing code */ } QofDateFormat; #define DATE_FORMAT_FIRST QOF_DATE_FORMAT_US -#define DATE_FORMAT_LAST QOF_DATE_FORMAT_LOCALE +#define DATE_FORMAT_LAST QOF_DATE_FORMAT_UTC /** Enum for date completion modes (for dates entered without year) */ typedef enum