Fixed minor memory leak.
[pspp-builds.git] / src / ui / gui / var-sheet.c
index e04d48955d571f3edec16d54e858b6c11f8fca23..5dcbf2f655fbb254836e739d3aa37fb9b697e3dd 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}, 
 };
 
 
@@ -95,17 +98,17 @@ click2row(GtkWidget *w, gint row, gpointer data)
 
 
 
-const gchar *alignments[]={
-  _("Left"),
-  _("Right"),
-  _("Centre"),
+const gchar *alignments[n_ALIGNMENTS + 1]={
+  N_("Left"),
+  N_("Right"),
+  N_("Centre"),
   0
 };
 
-const gchar *measures[]={
-  _("Nominal"),
-  _("Ordinal"),
-  _("Scale"),
+const gchar *measures[n_MEASURES + 1]={
+  N_("Nominal"),
+  N_("Ordinal"),
+  N_("Scale"),
   0
 };
 
@@ -124,7 +127,7 @@ create_label_list(const gchar **labels)
     {
       gtk_list_store_append (list_store, &iter);
       gtk_list_store_set (list_store, &iter,
-                         0, s,
+                         0, gettext(s),
                          -1);
     }
        
@@ -366,11 +369,11 @@ var_sheet_cell_change_entry (GtkSheet * sheet, gint row, gint column,
                {
                case COL_WIDTH:
                  r_min = fmt->d + 1;
-                 r_max = (psppire_variable_get_type(pv) == ALPHA) ? 255 : 40;
+                 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);
+                 r_max = MIN(fmt->w - 1, 16);
                  break;
                case COL_COLUMNS:
                  r_min = 1;
@@ -445,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);