From d9d21f38de54637ea0713406beb5cfd93598369c Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Mon, 18 May 2009 04:09:13 +0000 Subject: [PATCH] 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/branches/glabels-2_2@848 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/ChangeLog | 6 ++++++ glabels2/src/prefs-model.c | 28 +++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index 464f90fb..b19045ba 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 * Makefile.am: diff --git a/glabels2/src/prefs-model.c b/glabels2/src/prefs-model.c index 72b61792..1d5c2199 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" @@ -76,8 +77,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 @@ -385,6 +389,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; @@ -394,11 +399,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); @@ -409,7 +427,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); @@ -543,7 +561,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; -- 2.39.5