From: Jim Evins Date: Mon, 18 May 2009 04:15:44 +0000 (+0000) Subject: 2009-05-18 Jim Evins X-Git-Tag: glabels-2_3_0~219 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fac890372fff6be2410f3d0bac332fac8aba3c76;p=glabels 2009-05-18 Jim Evins * src/prefs-model.c: (gl_prefs_model_load_settings): Make an educated guess at locale settings when run for the first time. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@849 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index d6cc2f5d..7b3b1c02 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,9 @@ +2009-05-18 Jim Evins + + * src/prefs-model.c: (gl_prefs_model_load_settings): + Make an educated guess at locale settings when run for the + first time. + 2009-05-17 Jim Evins * help/de/de.po: diff --git a/glabels2/src/prefs-model.c b/glabels2/src/prefs-model.c index c106d30a..fdd429cb 100644 --- a/glabels2/src/prefs-model.c +++ b/glabels2/src/prefs-model.c @@ -27,6 +27,7 @@ #include #include +#include #include "marshal.h" #include "util.h" @@ -73,8 +74,11 @@ #define PREF_MAX_RECENT_TEMPLATES "/max-recent-templates" /* Default values */ -#define DEFAULT_UNITS_STRING units_to_string (LGL_UNITS_INCH) -#define DEFAULT_PAGE_SIZE "US-Letter" +#define DEFAULT_UNITS_STRING_US units_to_string (LGL_UNITS_INCH) +#define DEFAULT_PAGE_SIZE_US "US-Letter" + +#define DEFAULT_UNITS_STRING_METRIC units_to_string (LGL_UNITS_MM) +#define DEFAULT_PAGE_SIZE_METRIC "A4" #define DEFAULT_FONT_FAMILY "Sans" #define DEFAULT_FONT_SIZE 14.0 @@ -367,6 +371,7 @@ gl_prefs_model_save_settings (glPrefsModel *prefs_model) void gl_prefs_model_load_settings (glPrefsModel *prefs_model) { + const gchar *pgsize, *default_units_string, *default_page_size; gchar *string; lglPaper *paper; GSList *p, *p_next; @@ -376,11 +381,24 @@ gl_prefs_model_load_settings (glPrefsModel *prefs_model) g_return_if_fail (prefs_model && GL_IS_PREFS_MODEL(prefs_model)); g_return_if_fail (prefs_model->gconf_client != NULL); + /* Make educated guess about locale defaults. */ + pgsize = gtk_paper_size_get_default (); + if ( strcmp (pgsize,GTK_PAPER_NAME_LETTER) == 0 ) + { + default_units_string = DEFAULT_UNITS_STRING_US; + default_page_size = DEFAULT_PAGE_SIZE_US; + } + else + { + default_units_string = DEFAULT_UNITS_STRING_METRIC; + default_page_size = DEFAULT_PAGE_SIZE_METRIC; + } + /* Units */ string = get_string (prefs_model->gconf_client, BASE_KEY PREF_UNITS, - DEFAULT_UNITS_STRING); + default_units_string); prefs_model->units = string_to_units( string ); g_free( string ); lgl_xml_set_default_units (prefs_model->units); @@ -391,7 +409,7 @@ gl_prefs_model_load_settings (glPrefsModel *prefs_model) prefs_model->default_page_size = get_string (prefs_model->gconf_client, BASE_KEY PREF_DEFAULT_PAGE_SIZE, - DEFAULT_PAGE_SIZE); + default_page_size); /* Text properties */ g_free (prefs_model->default_font_family); @@ -509,7 +527,7 @@ gl_prefs_model_load_settings (glPrefsModel *prefs_model) /* (For compatability with older versions.) */ paper = lgl_db_lookup_paper_from_id (prefs_model->default_page_size); if ( paper == NULL ) { - prefs_model->default_page_size = g_strdup (DEFAULT_PAGE_SIZE); + prefs_model->default_page_size = g_strdup (DEFAULT_PAGE_SIZE_US); } else { lgl_paper_free (paper); paper = NULL;