Fixed a lot of internationalisation issues.
[pspp-builds.git] / src / ui / gui / var-sheet.c
index b38806bb1644dea49f20010011d65ac682b25baa..3fd426efdf866582c2576eb7a9e873706ddee766 100644 (file)
 /* This module creates the Variable Sheet used for inputing the
    variables in the  dictonary */
 
+#include <config.h>
+#include <gettext.h>
+#define _(msgid) gettext (msgid)
+#define N_(msgid) msgid
+
 #include <data/value-labels.h>
 
 #include <glade/glade.h>
@@ -30,7 +35,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#define min(A,B) ((A < B)?A:B)
+#include <data/value.h>
 
 #include <gtksheet/gtksheet.h>
 #include <gtksheet/gsheet-hetero-column.h>
@@ -48,8 +53,6 @@
 #include "val-labs-dialog.h"
 #include "missing-val-dialog.h"
 
-#define _(A) A
-#define N_(A) A
 
 
 static const gint n_initial_rows = 40;
@@ -64,16 +67,16 @@ struct column_parameters
 };
 
 static const struct column_parameters column_def[] = {
-  {N_("Name"),    80},
-  {N_("Type"),    100},
-  {N_("Width"),   57}, 
-  {N_("Decimals"),91}, 
-  {N_("Label"),   95}, 
-  {N_("Values"),  103},
-  {N_("Missing"), 95}, 
-  {N_("Columns"), 80}, 
-  {N_("Align"),   69}, 
-  {N_("Measure"), 99}, 
+  { N_("Name"),    80},
+  { N_("Type"),    100},
+  { N_("Width"),   57}, 
+  { N_("Decimals"),91}, 
+  { N_("Label"),   95}, 
+  { N_("Values"),  103},
+  { N_("Missing"), 95}, 
+  { N_("Columns"), 80}, 
+  { N_("Align"),   69}, 
+  { N_("Measure"), 99}, 
 };
 
 
@@ -81,9 +84,9 @@ static gboolean
 click2row(GtkWidget *w, gint row, gpointer data)
 {
   gint current_row, current_column;
+  GtkWidget *data_sheet  = get_widget_assert(xml, "data_sheet");
 
   select_sheet(PAGE_DATA_SHEET);
-  GtkWidget *data_sheet  = get_widget_assert(xml, "data_sheet");
 
   gtk_sheet_get_active_cell(GTK_SHEET(data_sheet), 
                            &current_row, &current_column);
@@ -96,34 +99,35 @@ click2row(GtkWidget *w, gint row, gpointer data)
 
 
 const gchar *alignments[]={
-  _("Left"),
-  _("Right"),
-  _("Centre"),
+  N_("Left"),
+  N_("Right"),
+  N_("Centre"),
   0
 };
 
 const gchar *measures[]={
-  _("Nominal"),
-  _("Ordinal"),
-  _("Scale"),
+  N_("Nominal"),
+  N_("Ordinal"),
+  N_("Scale"),
   0
 };
 
 static GtkListStore *
 create_label_list(const gchar **labels)
 {
+  const gchar *s;
   gint i = 0;
   GtkTreeIter iter;
 
   GtkListStore *list_store;
   list_store = gtk_list_store_new (1, G_TYPE_STRING);
 
-  const gchar *s;
+
   while ( (s = labels[i++]))
     {
       gtk_list_store_append (list_store, &iter);
       gtk_list_store_set (list_store, &iter,
-                         0, s,
+                         0, gettext(s),
                          -1);
     }
        
@@ -206,9 +210,13 @@ static gboolean
 var_sheet_cell_change_entry (GtkSheet * sheet, gint row, gint column, 
                             gpointer leaving)
 {
+  GtkSheetCellAttr attributes;
+  PsppireVarStore *var_store ;
+  struct PsppireVariable *pv ;
+
   g_return_val_if_fail(sheet != NULL, FALSE);
 
-  PsppireVarStore *var_store = PSPPIRE_VAR_STORE(gtk_sheet_get_model(sheet));
+  var_store = PSPPIRE_VAR_STORE(gtk_sheet_get_model(sheet));
 
   if ( row >= psppire_var_store_get_var_cnt(var_store))
     return TRUE;
@@ -219,10 +227,10 @@ var_sheet_cell_change_entry (GtkSheet * sheet, gint row, gint column,
       return TRUE;
     }
 
-  GtkSheetCellAttr attributes;
+
   gtk_sheet_get_attributes(sheet, row, column, &attributes);
 
-  struct PsppireVariable *pv = psppire_var_store_get_variable(var_store, row);
+  pv = psppire_var_store_get_variable(var_store, row);
 
   switch (column)
     {
@@ -351,40 +359,43 @@ var_sheet_cell_change_entry (GtkSheet * sheet, gint row, gint column,
            if (!s) 
              return FALSE;
 
-           const gint current_value  = atoi(s);
-
-           const struct fmt_spec *fmt = psppire_variable_get_write_spec(pv);
-           switch (column) 
-             {
-             case COL_WIDTH:
-               r_min = fmt->d + 1;
-               r_max = (psppire_variable_get_type(pv) == ALPHA) ? 255 : 40;
-               break;
-             case COL_DECIMALS:
-               r_min = 0 ; 
-               r_max = min(fmt->w - 1, 16);
-               break;
-             case COL_COLUMNS:
-               r_min = 1;
-               r_max = 255 ; /* Is this a sensible value ? */
-               break;
-             default:
-               g_assert_not_reached();
-             }
-
-           GtkObject *adj =  
-             gtk_adjustment_new(current_value,
-                                r_min, r_max,
-                                1.0, 1.0, 1.0 /* steps */
-                                );
-
-           gtk_sheet_change_entry(sheet, GTK_TYPE_SPIN_BUTTON);
-
-           GtkSpinButton *spinButton = 
-             GTK_SPIN_BUTTON(gtk_sheet_get_entry(sheet));
-
-           gtk_spin_button_set_adjustment(spinButton, GTK_ADJUSTMENT(adj));
-           gtk_spin_button_set_digits(spinButton, 0);
+           {
+             GtkSpinButton *spinButton ;
+             const gint current_value  = atoi(s);
+             GtkObject *adj ;
+
+             const struct fmt_spec *fmt = psppire_variable_get_write_spec(pv);
+             switch (column) 
+               {
+               case COL_WIDTH:
+                 r_min = fmt->d + 1;
+                 r_max = (psppire_variable_get_type(pv) == ALPHA) ? MAX_STRING : 40;
+                 break;
+               case COL_DECIMALS:
+                 r_min = 0 ; 
+                 r_max = MIN(fmt->w - 1, 16);
+                 break;
+               case COL_COLUMNS:
+                 r_min = 1;
+                 r_max = 255 ; /* Is this a sensible value ? */
+                 break;
+               default:
+                 g_assert_not_reached();
+               }
+
+             adj = gtk_adjustment_new(current_value,
+                                      r_min, r_max,
+                                      1.0, 1.0, 1.0 /* steps */
+                                      );
+
+             gtk_sheet_change_entry(sheet, GTK_TYPE_SPIN_BUTTON);
+
+             spinButton = 
+               GTK_SPIN_BUTTON(gtk_sheet_get_entry(sheet));
+
+             gtk_spin_button_set_adjustment(spinButton, GTK_ADJUSTMENT(adj));
+             gtk_spin_button_set_digits(spinButton, 0);
+           }
          }
       }
       break; 
@@ -437,7 +448,7 @@ psppire_variable_sheet_create (gchar *widget_name,
   for (i = 0 ; i < n_COLS ; ++i ) 
     {
       g_sheet_hetero_column_set_button_label(G_SHEET_HETERO_COLUMN(geo), i, 
-                                              column_def[i].label);
+                                              gettext(column_def[i].label));
 
       g_sheet_hetero_column_set_width(G_SHEET_HETERO_COLUMN(geo), i, 
                                               column_def[i].width);