From 655bf3a3917cdf16f99fcbb680d2bf3159126a93 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Tue, 30 May 2006 12:01:33 +0000 Subject: [PATCH] Internationalisation. Removed dependence on glib2.10 Tidy up some files. --- Smake | 1 + lib/gtksheet/ChangeLog | 4 + lib/gtksheet/gtksheet.c | 101 +++++++++--------- lib/gtksheet/gtksheet.h | 2 +- src/data/ChangeLog | 4 + src/data/settings.c | 3 + src/libpspp/ChangeLog | 4 + src/libpspp/automake.mk | 2 + src/libpspp/i18n.c | 176 ++++++++++++++++++++++++++++++++ src/libpspp/i18n.h | 42 ++++++++ src/ui/gui/ChangeLog | 13 +++ src/ui/gui/helper.c | 21 +--- src/ui/gui/menu-actions.c | 36 +++---- src/ui/gui/menu-actions.h | 6 +- src/ui/gui/psppire-data-store.c | 5 +- src/ui/gui/psppire-var-store.c | 2 +- src/ui/gui/psppire-var-store.h | 4 +- src/ui/gui/psppire.c | 45 ++++---- tests/bugs/alpha-freq.sh | 2 + tests/command/autorecod.sh | 2 + tests/command/beg-data.sh | 2 + tests/command/count.sh | 2 + tests/command/file-label.sh | 2 + tests/command/flip.sh | 2 + tests/command/lag.sh | 2 + tests/command/list.sh | 2 + tests/command/loop.sh | 3 + tests/command/print.sh | 2 + tests/command/split-file.sh | 3 + tests/command/sysfile-info.sh | 2 + tests/expressions/variables.sh | 2 + tests/expressions/vectors.sh | 3 + tests/stats/descript-basic.sh | 4 +- tests/stats/descript-missing.sh | 2 + 34 files changed, 391 insertions(+), 117 deletions(-) create mode 100644 src/libpspp/i18n.c create mode 100644 src/libpspp/i18n.h diff --git a/Smake b/Smake index a13ce6b5..d20b5da8 100644 --- a/Smake +++ b/Smake @@ -20,6 +20,7 @@ GNULIB_MODULES = \ gettext \ intprops \ linebreak \ + localcharset \ memcasecmp \ memchr \ memcmp \ diff --git a/lib/gtksheet/ChangeLog b/lib/gtksheet/ChangeLog index eea30daa..0ccbb0e3 100644 --- a/lib/gtksheet/ChangeLog +++ b/lib/gtksheet/ChangeLog @@ -1,3 +1,7 @@ +Di Mai 30 19:51:19 WST 2006 John Darrington + + * gtksheet.c gtksheet.h: constness. Removed dependence on glib2.10 + Sat May 27 16:29:36 WST 2006 John Darrington * gtksheet.c: Removed call to gtk_entry_set_text, which caused warnings diff --git a/lib/gtksheet/gtksheet.c b/lib/gtksheet/gtksheet.c index ff7ab3b0..6d47cfb9 100644 --- a/lib/gtksheet/gtksheet.c +++ b/lib/gtksheet/gtksheet.c @@ -104,6 +104,7 @@ enum #define DEFAULT_COLUMN_WIDTH 80 + static gboolean gtk_sheet_cell_empty (const GtkSheet *sheet, gint row, gint col); static inline @@ -720,7 +721,7 @@ static void gtk_sheet_button_size_request (GtkSheet *sheet, GtkRequisition *requisition); /* Attributes routines */ -static void init_attributes (GtkSheet *sheet, gint col, +static void init_attributes (const GtkSheet *sheet, gint col, GtkSheetCellAttr *attributes); @@ -3959,11 +3960,12 @@ gtk_sheet_entry_changed(GtkWidget *widget, gpointer data) GTK_SHEET_SET_FLAGS(sheet, GTK_SHEET_IS_FROZEN); - if(text && strlen(text) > 0){ - gtk_sheet_get_attributes(sheet, row, col, &attributes); - justification=attributes.justification; - gtk_sheet_set_cell(sheet, row, col, justification, text); - } + if(text && strlen(text) > 0) + { + gtk_sheet_get_attributes(sheet, row, col, &attributes); + justification = attributes.justification; + gtk_sheet_set_cell(sheet, row, col, justification, text); + } if(sheet->freeze_count == 0) GTK_SHEET_UNSET_FLAGS(sheet, GTK_SHEET_IS_FROZEN); @@ -6135,7 +6137,7 @@ static void gtk_sheet_size_allocate_entry(GtkSheet *sheet) { GtkAllocation shentry_allocation; - GtkSheetCellAttr attributes; + GtkSheetCellAttr attributes = { 0 }; GtkEntry *sheet_entry; GtkStyle *style = NULL, *previous_style = NULL; gint row, col; @@ -6147,40 +6149,41 @@ gtk_sheet_size_allocate_entry(GtkSheet *sheet) sheet_entry = GTK_ENTRY(gtk_sheet_get_entry(sheet)); - gtk_sheet_get_attributes(sheet, sheet->active_cell.row, sheet->active_cell.col, &attributes); + gtk_sheet_get_attributes(sheet, sheet->active_cell.row, sheet->active_cell.col, &attributes); - if(GTK_WIDGET_REALIZED(sheet->sheet_entry)){ + if(GTK_WIDGET_REALIZED(sheet->sheet_entry)) + { - if(!GTK_WIDGET(sheet_entry)->style) + if(!GTK_WIDGET(sheet_entry)->style) gtk_widget_ensure_style(GTK_WIDGET(sheet_entry)); - previous_style = GTK_WIDGET(sheet_entry)->style; - - style = gtk_style_copy(previous_style); - style->bg[GTK_STATE_NORMAL] = attributes.background; - style->fg[GTK_STATE_NORMAL] = attributes.foreground; - style->text[GTK_STATE_NORMAL] = attributes.foreground; - style->bg[GTK_STATE_ACTIVE] = attributes.background; - style->fg[GTK_STATE_ACTIVE] = attributes.foreground; - style->text[GTK_STATE_ACTIVE] = attributes.foreground; - - pango_font_description_free(style->font_desc); - style->font_desc = pango_font_description_copy(attributes.font_desc); - - GTK_WIDGET(sheet_entry)->style = style; - gtk_widget_size_request(sheet->sheet_entry, NULL); - GTK_WIDGET(sheet_entry)->style = previous_style; - - if(style != previous_style){ - if(!GTK_IS_ITEM_ENTRY(sheet->sheet_entry)){ - style->bg[GTK_STATE_NORMAL] = previous_style->bg[GTK_STATE_NORMAL]; - style->fg[GTK_STATE_NORMAL] = previous_style->fg[GTK_STATE_NORMAL]; - style->bg[GTK_STATE_ACTIVE] = previous_style->bg[GTK_STATE_ACTIVE]; - style->fg[GTK_STATE_ACTIVE] = previous_style->fg[GTK_STATE_ACTIVE]; + previous_style = GTK_WIDGET(sheet_entry)->style; + + style = gtk_style_copy(previous_style); + style->bg[GTK_STATE_NORMAL] = attributes.background; + style->fg[GTK_STATE_NORMAL] = attributes.foreground; + style->text[GTK_STATE_NORMAL] = attributes.foreground; + style->bg[GTK_STATE_ACTIVE] = attributes.background; + style->fg[GTK_STATE_ACTIVE] = attributes.foreground; + style->text[GTK_STATE_ACTIVE] = attributes.foreground; + + pango_font_description_free(style->font_desc); + style->font_desc = pango_font_description_copy(attributes.font_desc); + + GTK_WIDGET(sheet_entry)->style = style; + gtk_widget_size_request(sheet->sheet_entry, NULL); + GTK_WIDGET(sheet_entry)->style = previous_style; + + if(style != previous_style){ + if(!GTK_IS_ITEM_ENTRY(sheet->sheet_entry)){ + style->bg[GTK_STATE_NORMAL] = previous_style->bg[GTK_STATE_NORMAL]; + style->fg[GTK_STATE_NORMAL] = previous_style->fg[GTK_STATE_NORMAL]; + style->bg[GTK_STATE_ACTIVE] = previous_style->bg[GTK_STATE_ACTIVE]; + style->fg[GTK_STATE_ACTIVE] = previous_style->fg[GTK_STATE_ACTIVE]; + } + gtk_widget_set_style(GTK_WIDGET(sheet_entry), style); + } } - gtk_widget_set_style(GTK_WIDGET(sheet_entry), style); - } - } if(GTK_IS_ITEM_ENTRY(sheet_entry)) max_size = GTK_ITEM_ENTRY(sheet_entry)->text_max_size; @@ -6230,12 +6233,13 @@ gtk_sheet_size_allocate_entry(GtkSheet *sheet) } - if(!GTK_IS_ITEM_ENTRY(sheet->sheet_entry)){ - shentry_allocation.x += 2; - shentry_allocation.y += 2; - shentry_allocation.width -= MIN(shentry_allocation.width, 3); - shentry_allocation.height -= MIN(shentry_allocation.height, 3); - } + if(!GTK_IS_ITEM_ENTRY(sheet->sheet_entry)) + { + shentry_allocation.x += 2; + shentry_allocation.y += 2; + shentry_allocation.width -= MIN(shentry_allocation.width, 3); + shentry_allocation.height -= MIN(shentry_allocation.height, 3); + } gtk_widget_size_allocate(sheet->sheet_entry, &shentry_allocation); @@ -7213,7 +7217,8 @@ gtk_sheet_set_row_height (GtkSheet * sheet, gboolean -gtk_sheet_get_attributes(GtkSheet *sheet, gint row, gint col, GtkSheetCellAttr *attributes) +gtk_sheet_get_attributes(const GtkSheet *sheet, gint row, gint col, + GtkSheetCellAttr *attributes) { const GdkColor *fg, *bg; const GtkJustification *j ; @@ -7228,7 +7233,7 @@ gtk_sheet_get_attributes(GtkSheet *sheet, gint row, gint col, GtkSheetCellAttr * init_attributes(sheet, col, attributes); if ( !sheet->model) - return FALSE; + return FALSE; attributes->is_editable = g_sheet_model_is_editable(sheet->model, row, col); attributes->is_visible = g_sheet_model_is_visible(sheet->model, row, col); @@ -7255,7 +7260,7 @@ gtk_sheet_get_attributes(GtkSheet *sheet, gint row, gint col, GtkSheetCellAttr * } static void -init_attributes(GtkSheet *sheet, gint col, GtkSheetCellAttr *attributes) +init_attributes(const GtkSheet *sheet, gint col, GtkSheetCellAttr *attributes) { /* DEFAULT VALUES */ attributes->foreground = GTK_WIDGET(sheet)->style->black; @@ -7276,9 +7281,7 @@ init_attributes(GtkSheet *sheet, gint col, GtkSheetCellAttr *attributes) attributes->is_editable = TRUE; attributes->is_visible = TRUE; attributes->font_desc = GTK_WIDGET(sheet)->style->font_desc; - } - /******************************************************************** @@ -7913,7 +7916,7 @@ gtk_sheet_get_model(const GtkSheet *sheet) GtkSheetButton * gtk_sheet_button_new(void) { - GtkSheetButton *button = g_slice_new(GtkSheetButton); + GtkSheetButton *button = g_malloc(sizeof(GtkSheetButton)); button->state = GTK_STATE_NORMAL; button->label = NULL; @@ -7929,5 +7932,5 @@ inline void gtk_sheet_button_free(GtkSheetButton *button) { g_free(button->label); - g_slice_free(GtkSheetButton, button); + g_free(button); } diff --git a/lib/gtksheet/gtksheet.h b/lib/gtksheet/gtksheet.h index ed6cd31e..d8db6c40 100644 --- a/lib/gtksheet/gtksheet.h +++ b/lib/gtksheet/gtksheet.h @@ -659,7 +659,7 @@ gtk_sheet_range_set_font (GtkSheet *sheet, /* get cell attributes of the given cell */ /* TRUE means that the cell is currently allocated */ gboolean -gtk_sheet_get_attributes (GtkSheet *sheet, +gtk_sheet_get_attributes (const GtkSheet *sheet, gint row, gint col, GtkSheetCellAttr *attributes); diff --git a/src/data/ChangeLog b/src/data/ChangeLog index 87fb23ee..329c688b 100644 --- a/src/data/ChangeLog +++ b/src/data/ChangeLog @@ -1,3 +1,7 @@ +Tue May 30 19:52:33 WST 2006 John Darrington + + * settings.c: Added call to i18n{done, init}. + Tue May 9 21:09:17 2006 Ben Pfaff * procedure.h: Add WARN_UNUSED_RESULT to procedure function diff --git a/src/data/settings.c b/src/data/settings.c index 64f037ed..37fda600 100644 --- a/src/data/settings.c +++ b/src/data/settings.c @@ -25,6 +25,7 @@ #include "format.h" #include "value.h" #include "xalloc.h" +#include static int viewlength = 24; static int viewwidth = 79; @@ -87,11 +88,13 @@ void settings_init (void) { init_viewport (); + i18n_init (); } void settings_done (void) { + i18n_done (); } /* Screen length in lines. */ diff --git a/src/libpspp/ChangeLog b/src/libpspp/ChangeLog index 34f95e39..852b71b1 100644 --- a/src/libpspp/ChangeLog +++ b/src/libpspp/ChangeLog @@ -1,3 +1,7 @@ +Tue May 30 19:45:12 WST 2006 John Darrington + + * i18n.c i18n.h: New files. + Tue May 16 06:50:35 2006 Ben Pfaff * automake.mk (src/libpspp/version.c): Removed groff_font_path, diff --git a/src/libpspp/automake.mk b/src/libpspp/automake.mk index 8f1b096b..b428672d 100644 --- a/src/libpspp/automake.mk +++ b/src/libpspp/automake.mk @@ -16,6 +16,8 @@ src_libpspp_libpspp_a_SOURCES = \ src/libpspp/freaderror.h \ src/libpspp/hash.c \ src/libpspp/hash.h \ + src/libpspp/i18n.c \ + src/libpspp/i18n.h \ src/libpspp/magic.c \ src/libpspp/magic.h \ src/libpspp/misc.c \ diff --git a/src/libpspp/i18n.c b/src/libpspp/i18n.c new file mode 100644 index 00000000..bcac52cf --- /dev/null +++ b/src/libpspp/i18n.c @@ -0,0 +1,176 @@ +/* PSPP - computes sample statistics. + Copyright (C) 2006 Free Software Foundation, Inc. + Written by John Darrington + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#include +#include +#include +#include +#include +#include +#include + +#include "i18n.h" + +#include + + +static char *locale = 0; +static const char *charset; + + +static iconv_t convertor[n_CONV]; + +/* Return a string based on TEXT converted according to HOW. + If length is not -1, then it must be the number of bytes in TEXT. + The returned string must be freed when no longer required. +*/ +char * +recode_string(enum conv_id how, const char *text, int length) +{ + char *outbuf = 0; + size_t outbufferlength; + size_t result; + char *ip ; + char *op ; + size_t inbytes = 0; + size_t outbytes ; + + /* FIXME: Need to ensure that this char is valid in the target encoding */ + const char fallbackchar = '?'; + + if ( length == -1 ) + length = strlen(text); + + assert(how < n_CONV); + + for ( outbufferlength = 1 ; outbufferlength != 0; outbufferlength <<= 1 ) + if ( outbufferlength > length) + break; + + outbuf = xmalloc(outbufferlength); + op = outbuf; + ip = (char *) text; + + outbytes = outbufferlength; + inbytes = length; + + do { + + + result = iconv(convertor[how], &ip, &inbytes, + &op, &outbytes); + + if ( -1 == result ) + { + int the_error = errno; + + switch ( the_error) + { + case EILSEQ: + case EINVAL: + if ( outbytes > 0 ) + { + *op++ = fallbackchar; + outbytes--; + ip++; + inbytes--; + break; + } + /* Fall through */ + case E2BIG: + free(outbuf); + outbufferlength <<= 1; + outbuf = xmalloc(outbufferlength); + op = outbuf; + ip = (char *) text; + outbytes = outbufferlength; + inbytes = length; + break; + default: + /* should never happen */ + break; + } + + } + + } while ( -1 == result ); + + *op = '\0'; + + + return outbuf; +} + + +/* Returns the current PSPP locale */ +const char * +get_pspp_locale(void) +{ + assert ( locale); + return locale; +} + +/* Set the PSPP locale */ +void +set_pspp_locale(const char *l) +{ + char *current_locale; + const char *current_charset; + + free(locale); + locale = strdup(l); + + current_locale = setlocale(LC_CTYPE, 0); + current_charset = locale_charset(); + setlocale(LC_CTYPE, locale); + + charset = locale_charset(); + setlocale(LC_CTYPE, current_locale); + + iconv_close(convertor[CONV_PSPP_TO_UTF8]); + convertor[CONV_PSPP_TO_UTF8] = iconv_open("UTF-8", charset); + + iconv_close(convertor[CONV_SYSTEM_TO_PSPP]); + convertor[CONV_SYSTEM_TO_PSPP] = iconv_open(charset, current_charset); +} + +void +i18n_init(void) +{ + assert ( ! locale) ; + locale = strdup(setlocale(LC_CTYPE, NULL)); + + setlocale(LC_CTYPE, locale); + charset = locale_charset(); + + convertor[CONV_PSPP_TO_UTF8] = iconv_open("UTF-8", charset); + convertor[CONV_SYSTEM_TO_PSPP] = iconv_open(charset, charset); +} + + +void +i18n_done(void) +{ + int i; + free(locale); + locale = 0; + + for(i = 0 ; i < n_CONV; ++i ) + iconv_close(convertor[i]); +} diff --git a/src/libpspp/i18n.h b/src/libpspp/i18n.h new file mode 100644 index 00000000..6bb2a86e --- /dev/null +++ b/src/libpspp/i18n.h @@ -0,0 +1,42 @@ +/* PSPP - computes sample statistics. + Copyright (C) 2006 Free Software Foundation, Inc. + Written by John Darrington + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#ifndef I18N_H +#define I18N_H + +const char * get_pspp_locale(void); +void set_pspp_locale(const char *locale); +const char * get_pspp_charset(void); + +void i18n_done(void); +void i18n_init(void); + +enum conv_id + { + CONV_PSPP_TO_UTF8, + CONV_SYSTEM_TO_PSPP, + n_CONV + }; + + +char * recode_string(enum conv_id how, const char *text, int len); + + + +#endif /* i18n.h */ diff --git a/src/ui/gui/ChangeLog b/src/ui/gui/ChangeLog index 5a875b32..d4e34e39 100644 --- a/src/ui/gui/ChangeLog +++ b/src/ui/gui/ChangeLog @@ -1,3 +1,16 @@ + +Tue May 30 19:53:35 WST 2006 John Darringotn + + * menu-actions.c menu-actions.h psppire.c: Fixed up load/new + interactions with startup. + + * psppire-data-store.c: Fixed bad i18n call. + + * pspppire-var-store.c, psppire-var-store.h: constness. + + * helper.c: Implemented proper way to convert from PSPP to UTF8 encoding. + + Sat May 27 16:25:38 WST 2006 John Darrington * customentry.c data-sheet.c menu-actions.c message-dialog.c diff --git a/src/ui/gui/helper.c b/src/ui/gui/helper.c index d2defd69..841bda5a 100644 --- a/src/ui/gui/helper.c +++ b/src/ui/gui/helper.c @@ -1,10 +1,12 @@ - #include "helper.h" #include #include +#include + #include #include +#include /* Formats a value according to FORMAT The returned string must be freed when no longer required */ @@ -80,21 +82,6 @@ get_widget_assert(GladeXML *xml, const gchar *name) char * pspp_locale_to_utf8(const gchar *text, gssize len, GError **err) { - GError *tmp_error = 0; - - gchar *s; - - if ( ! text ) - return 0; - - s = g_locale_to_utf8(text, len, 0, 0, &tmp_error); - - if ( tmp_error) - { - g_warning("Error converting to UTF8: %s", tmp_error->message); - g_propagate_error (err, tmp_error); - } - - return s; + return recode_string(CONV_PSPP_TO_UTF8, text, len); } diff --git a/src/ui/gui/menu-actions.c b/src/ui/gui/menu-actions.c index bd56691d..f031ea70 100644 --- a/src/ui/gui/menu-actions.c +++ b/src/ui/gui/menu-actions.c @@ -62,6 +62,7 @@ static const gchar untitled[] = N_("Untitled"); static const gchar window_title[] = N_("PSPP Data Editor"); +/* Sets the title bar to TEXT */ static void psppire_set_window_title(const gchar *text) { @@ -70,13 +71,11 @@ psppire_set_window_title(const gchar *text) gchar *title = g_strdup_printf("%s --- %s", text, gettext(window_title)); gtk_window_set_title(GTK_WINDOW(data_editor), title); - - g_free(title); } -void -on_new1_activate (GtkMenuItem *menuitem, - gpointer user_data) + +gboolean +clear_file(void) { GtkWidget *data_sheet = get_widget_assert(xml, "data_sheet"); GtkWidget *var_sheet = get_widget_assert(xml, "variable_sheet"); @@ -93,8 +92,18 @@ on_new1_activate (GtkMenuItem *menuitem, if (psppire_handle) fh_free(psppire_handle); psppire_handle = 0 ; + + return TRUE; } +void +on_new1_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + clear_file(); +} + + static gboolean populate_case_from_reader(struct ccase *c, gpointer aux) @@ -593,8 +602,10 @@ data_var_select(GtkNotebook *notebook, switch_menus(page_num); } -static void -var_data_selection_init() + +/* Initialised things on the variable sheet */ +void +var_data_selection_init(void) { notebook = GTK_NOTEBOOK(get_widget_assert(xml, "notebook1")); menuitems[PAGE_DATA_SHEET] = get_widget_assert(xml, "data1"); @@ -626,14 +637,3 @@ on_variables1_activate(GtkMenuItem *menuitem, select_sheet(PAGE_VAR_SHEET); } - -/* Callback which occurs when gtk_main is entered */ -gboolean -callbacks_on_init(gpointer data) -{ - psppire_set_window_title(gettext(untitled)); - - var_data_selection_init(); - - return FALSE; -} diff --git a/src/ui/gui/menu-actions.h b/src/ui/gui/menu-actions.h index f4ed5c00..46cb85f2 100644 --- a/src/ui/gui/menu-actions.h +++ b/src/ui/gui/menu-actions.h @@ -77,15 +77,15 @@ psppire_variable_sheet_create (gchar *widget_name, gchar *string1, gchar *string gint int1, gint int2); -gboolean callbacks_on_init(gpointer data) ; - - /* Switch between the VAR SHEET and the DATA SHEET */ enum {PAGE_DATA_SHEET = 0, PAGE_VAR_SHEET}; gboolean load_system_file(const gchar *file_name); +gboolean clear_file(void); void select_sheet(gint page); +void var_data_selection_init(void); + #endif diff --git a/src/ui/gui/psppire-data-store.c b/src/ui/gui/psppire-data-store.c index 62bbfef9..df36d083 100644 --- a/src/ui/gui/psppire-data-store.c +++ b/src/ui/gui/psppire-data-store.c @@ -401,7 +401,6 @@ psppire_data_store_get_string(GSheetModel *model, gint row, gint column) FP. No null terminator is appended to the buffer. */ data_out (s->str, fp, v); - text = pspp_locale_to_utf8(s->str, fp->w, 0); g_string_free(s, TRUE); @@ -579,7 +578,7 @@ geometry_get_column_count(const GSheetColumn *geom) /* Return the width that an 'M' character would occupy when typeset at row, col */ static guint -M_width(GtkSheet *sheet, gint row, gint col) +M_width(const GtkSheet *sheet, gint row, gint col) { GtkSheetCellAttr attributes; PangoRectangle rect; @@ -673,7 +672,7 @@ geometry_get_button_label(const GSheetColumn *geom, gint unit) PsppireDataStore *ds = PSPPIRE_DATA_STORE(geom); if ( unit >= psppire_dict_get_var_cnt(ds->dict) ) - return pspp_locale_to_utf8(null_var_name, -1, 0); + return g_locale_to_utf8(null_var_name, -1, 0, 0, 0); pv = psppire_dict_get_variable(ds->dict, unit); diff --git a/src/ui/gui/psppire-var-store.c b/src/ui/gui/psppire-var-store.c index 36538723..9abf8653 100644 --- a/src/ui/gui/psppire-var-store.c +++ b/src/ui/gui/psppire-var-store.c @@ -640,7 +640,7 @@ psppire_var_store_get_var_cnt(PsppireVarStore *store) void -psppire_var_store_set_font(PsppireVarStore *store, PangoFontDescription *fd) +psppire_var_store_set_font(PsppireVarStore *store, const PangoFontDescription *fd) { g_return_if_fail (store); g_return_if_fail (PSPPIRE_IS_VAR_STORE (store)); diff --git a/src/ui/gui/psppire-var-store.h b/src/ui/gui/psppire-var-store.h index 7a4eee8e..792db1f1 100644 --- a/src/ui/gui/psppire-var-store.h +++ b/src/ui/gui/psppire-var-store.h @@ -59,7 +59,7 @@ struct _PsppireVarStore /*< private >*/ PsppireDict *dict; GdkColor disabled; - PangoFontDescription *font_desc; + const PangoFontDescription *font_desc; }; struct _PsppireVarStoreClass @@ -86,7 +86,7 @@ void psppire_var_store_set_dictionary(PsppireVarStore *var_store, PsppireDict *d /* Return the number of variables */ gint psppire_var_store_get_var_cnt(PsppireVarStore *var_store); -void psppire_var_store_set_font(PsppireVarStore *store, PangoFontDescription *fd); +void psppire_var_store_set_font(PsppireVarStore *store, const PangoFontDescription *fd); #ifdef __cplusplus diff --git a/src/ui/gui/psppire.c b/src/ui/gui/psppire.c index 4d77cb3d..3560dbf6 100644 --- a/src/ui/gui/psppire.c +++ b/src/ui/gui/psppire.c @@ -18,16 +18,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* - * Initial main.c file generated by Glade. Edit as required. - * Glade will not overwrite this file. - */ #include #include #include #include +#include + #include #include #include @@ -56,20 +54,6 @@ PsppireDataStore *data_store = 0; static bool parse_command_line (int *argc, char ***argv, gchar **filename, GError **err); -static void -i18n_init (void) -{ -#if ENABLE_NLS -#if HAVE_LC_MESSAGES - setlocale (LC_MESSAGES, ""); -#endif - setlocale (LC_MONETARY, ""); - bindtextdomain (PACKAGE, locale_dir); - textdomain (PACKAGE); -#endif /* ENABLE_NLS */ -} - - int main(int argc, char *argv[]) { @@ -83,16 +67,29 @@ main(int argc, char *argv[]) gtk_init(&argc, &argv); + /* gtk_init messes with the locale. + So unset the bits we want to control ourselves */ + setlocale (LC_NUMERIC, "C"); + + bindtextdomain (PACKAGE, locale_dir); + textdomain (PACKAGE); + if ( ! parse_command_line(&argc, &argv, &filename, &err) ) { g_clear_error(&err); return 1; } - glade_init(); - i18n_init(); + + settings_init(); + + + + /* + set_pspp_locale("da_DK"); + */ message_dialog_init(); @@ -125,16 +122,20 @@ main(int argc, char *argv[]) gtk_sheet_set_model(data_sheet, G_SHEET_MODEL(data_store)); - gtk_init_add(callbacks_on_init, 0); - if (filename) gtk_init_add((GtkFunction)load_system_file, filename); + else + gtk_init_add((GtkFunction)clear_file, 0); + + var_data_selection_init(); /* start the event loop */ gtk_main(); message_dialog_done(); + settings_done(); + return 0; } diff --git a/tests/bugs/alpha-freq.sh b/tests/bugs/alpha-freq.sh index d964057b..68799305 100755 --- a/tests/bugs/alpha-freq.sh +++ b/tests/bugs/alpha-freq.sh @@ -18,6 +18,8 @@ top_srcdir=`cd $top_srcdir; pwd` STAT_CONFIG_PATH=$top_srcdir/config export STAT_CONFIG_PATH +LANG=C +export LANG cleanup() { diff --git a/tests/command/autorecod.sh b/tests/command/autorecod.sh index b33fe15c..57b2dc82 100755 --- a/tests/command/autorecod.sh +++ b/tests/command/autorecod.sh @@ -18,6 +18,8 @@ top_srcdir=`cd $top_srcdir; pwd` STAT_CONFIG_PATH=$top_srcdir/config export STAT_CONFIG_PATH +LANG=C +export LANG cleanup() { diff --git a/tests/command/beg-data.sh b/tests/command/beg-data.sh index 5b9e9384..35f937b5 100755 --- a/tests/command/beg-data.sh +++ b/tests/command/beg-data.sh @@ -17,6 +17,8 @@ top_srcdir=`cd $top_srcdir; pwd` STAT_CONFIG_PATH=$top_srcdir/config export STAT_CONFIG_PATH +LANG=C +export LANG cleanup() { diff --git a/tests/command/count.sh b/tests/command/count.sh index 7b3e8e4b..7fa56cc4 100755 --- a/tests/command/count.sh +++ b/tests/command/count.sh @@ -17,6 +17,8 @@ top_srcdir=`cd $top_srcdir; pwd` STAT_CONFIG_PATH=$top_srcdir/config export STAT_CONFIG_PATH +LANG=C +export LANG cleanup() { diff --git a/tests/command/file-label.sh b/tests/command/file-label.sh index ca9da9cd..72da8029 100755 --- a/tests/command/file-label.sh +++ b/tests/command/file-label.sh @@ -17,6 +17,8 @@ top_srcdir=`cd $top_srcdir; pwd` STAT_CONFIG_PATH=$top_srcdir/config export STAT_CONFIG_PATH +LANG=C +export LANG cleanup() { diff --git a/tests/command/flip.sh b/tests/command/flip.sh index c7429b32..29caa142 100755 --- a/tests/command/flip.sh +++ b/tests/command/flip.sh @@ -17,6 +17,8 @@ top_srcdir=`cd $top_srcdir; pwd` STAT_CONFIG_PATH=$top_srcdir/config export STAT_CONFIG_PATH +LANG=C +export LANG cleanup() { diff --git a/tests/command/lag.sh b/tests/command/lag.sh index d5eadb0e..4221fb7b 100755 --- a/tests/command/lag.sh +++ b/tests/command/lag.sh @@ -17,6 +17,8 @@ top_srcdir=`cd $top_srcdir; pwd` STAT_CONFIG_PATH=$top_srcdir/config export STAT_CONFIG_PATH +LANG=C +export LANG cleanup() { diff --git a/tests/command/list.sh b/tests/command/list.sh index dc8d1313..a11ea78d 100755 --- a/tests/command/list.sh +++ b/tests/command/list.sh @@ -17,6 +17,8 @@ top_srcdir=`cd $top_srcdir; pwd` STAT_CONFIG_PATH=$top_srcdir/config export STAT_CONFIG_PATH +LANG=C +export LANG cleanup() { diff --git a/tests/command/loop.sh b/tests/command/loop.sh index 03120299..7c7e493a 100755 --- a/tests/command/loop.sh +++ b/tests/command/loop.sh @@ -17,6 +17,9 @@ top_srcdir=`cd $top_srcdir; pwd` STAT_CONFIG_PATH=$top_srcdir/config export STAT_CONFIG_PATH +LANG=C +export LANG + cleanup() { diff --git a/tests/command/print.sh b/tests/command/print.sh index 32a96d7f..a7e5b655 100755 --- a/tests/command/print.sh +++ b/tests/command/print.sh @@ -17,6 +17,8 @@ top_srcdir=`cd $top_srcdir; pwd` STAT_CONFIG_PATH=$top_srcdir/config export STAT_CONFIG_PATH +LANG=C +export LANG cleanup() { diff --git a/tests/command/split-file.sh b/tests/command/split-file.sh index 250b97ab..10e34ed9 100755 --- a/tests/command/split-file.sh +++ b/tests/command/split-file.sh @@ -17,6 +17,9 @@ top_srcdir=`cd $top_srcdir; pwd` STAT_CONFIG_PATH=$top_srcdir/config export STAT_CONFIG_PATH +LANG=C +export LANG + cleanup() { diff --git a/tests/command/sysfile-info.sh b/tests/command/sysfile-info.sh index 03d71f74..99054665 100755 --- a/tests/command/sysfile-info.sh +++ b/tests/command/sysfile-info.sh @@ -17,6 +17,8 @@ top_srcdir=`cd $top_srcdir; pwd` STAT_CONFIG_PATH=$top_srcdir/config export STAT_CONFIG_PATH +LANG=C +export LANG cleanup() { diff --git a/tests/expressions/variables.sh b/tests/expressions/variables.sh index 3a2a3c2b..b9da30fb 100755 --- a/tests/expressions/variables.sh +++ b/tests/expressions/variables.sh @@ -14,6 +14,8 @@ PSPP=$top_builddir/src/ui/terminal/pspp STAT_CONFIG_PATH=$top_srcdir/config export STAT_CONFIG_PATH +LANG=C +export LANG cleanup() { diff --git a/tests/expressions/vectors.sh b/tests/expressions/vectors.sh index 52b9be62..62749d67 100755 --- a/tests/expressions/vectors.sh +++ b/tests/expressions/vectors.sh @@ -14,6 +14,9 @@ PSPP=$top_builddir/src/ui/terminal/pspp STAT_CONFIG_PATH=$top_srcdir/config export STAT_CONFIG_PATH +LANG=C +export LANG + cleanup() { diff --git a/tests/stats/descript-basic.sh b/tests/stats/descript-basic.sh index 0a8dc114..8f772ed3 100755 --- a/tests/stats/descript-basic.sh +++ b/tests/stats/descript-basic.sh @@ -16,11 +16,13 @@ top_srcdir=`cd $top_srcdir; pwd` STAT_CONFIG_PATH=$top_srcdir/config export STAT_CONFIG_PATH +LANG=C +export LANG cleanup() { cd / -# rm -rf $TEMPDIR + rm -rf $TEMPDIR } diff --git a/tests/stats/descript-missing.sh b/tests/stats/descript-missing.sh index 8d0de7d6..574ecf29 100755 --- a/tests/stats/descript-missing.sh +++ b/tests/stats/descript-missing.sh @@ -16,6 +16,8 @@ top_srcdir=`cd $top_srcdir; pwd` STAT_CONFIG_PATH=$top_srcdir/config export STAT_CONFIG_PATH +LANG=C +export LANG cleanup() { -- 2.30.2