psppire-var-sheet: Allow adjusting width of string variables.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 2 Sep 2012 18:07:59 +0000 (11:07 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 2 Sep 2012 18:07:59 +0000 (11:07 -0700)
John Darrington pointed out that the "width" column in the variable
sheet didn't allow the width to be modified with a spin button for
string variables, as it did for numeric variables.  This commit
fixes the problem.

The reordering in on_var_column_edited() is necessary because the
print format of a string variable can't be changed to a different
width before changing the variable's width.  (The change from
var_set_print_format() to var_set_both_formats() is not
necessary.  It is for consistency with changing variable type and
format via the var-type-dialog.)

src/ui/gui/psppire-var-sheet.c

index dfd5ce1c4c7732ad1f102309da2de65313599368..0234573196c96d0f1675344d2027e24f404f7ab6 100644 (file)
@@ -225,8 +225,8 @@ on_var_column_edited (GtkCellRendererText *cell,
 
           format = *var_get_print_format (var);
           fmt_change_width (&format, width, var_sheet->format_use);
-          var_set_print_format (var, &format);
           var_set_width (var, fmt_var_width (&format));
+          var_set_both_formats (var, &format);
         }
       break;
 
@@ -342,16 +342,10 @@ render_var_cell (PsppSheetViewColumn *tree_column,
       break;
 
     case VS_WIDTH:
-      {
-        int step = fmt_step_width (print->type);
-        if (var_is_numeric (var))
-          set_spin_cell (cell, print->w,
-                         fmt_min_width (print->type, var_sheet->format_use),
-                         fmt_max_width (print->type, var_sheet->format_use),
-                         step);
-        else
-          set_spin_cell (cell, print->w, 0, 0, step);
-      }
+      set_spin_cell (cell, print->w,
+                     fmt_min_width (print->type, var_sheet->format_use),
+                     fmt_max_width (print->type, var_sheet->format_use),
+                     fmt_step_width (print->type));
       break;
 
     case VS_DECIMALS: