Written a proper implementation of psppire_axis_impl_delete
[pspp-builds.git] / src / ui / gui / psppire-data-editor.c
index 74660f12e37caa2b96bee61f976986496a9b0974..cab0f755bc5a20f8a1eeee9162ff1b4f6ff60d9f 100644 (file)
@@ -280,6 +280,18 @@ width_of_m (GtkWidget *w)
   return rect.width;
 }
 
+/* Callback for the axis' resize signal.
+   Changes the variable's display width */
+static void
+rewidth_variable (PsppireDataEditor *de, gint unit, glong size)
+{
+  const PsppireDict *dict = de->data_store->dict;
+  struct variable *var = psppire_dict_get_variable (dict, unit);
+
+  var_set_display_width (var, size / (float) width_of_m (de));
+}
+
+
 static void
 new_variables_callback (PsppireDict *dict, gpointer data)
 {
@@ -298,6 +310,9 @@ new_variables_callback (PsppireDict *dict, gpointer data)
       PsppireAxisImpl *haxis;
       g_object_get (de->data_sheet[i], "horizontal-axis", &haxis, NULL);
 
+      g_signal_connect_swapped (haxis, "resize-unit",
+                               G_CALLBACK (rewidth_variable), de);
+
       psppire_axis_impl_clear (haxis);
 
       for (v = 0 ; v < psppire_dict_get_var_cnt (dict); ++v)
@@ -346,13 +361,13 @@ delete_variable_callback (PsppireDict *dict, gint posn,
 
   psppire_axis_impl_delete (var_vaxis, posn, 1);
 
-  for (i = 0 ; i < 4 ; ++i)
-    {
-      PsppireAxisImpl *haxis;
-      g_object_get (de->data_sheet[i], "horizontal-axis", &haxis, NULL);
 
-      psppire_axis_impl_delete (haxis, posn, 1);
-    }
+  {
+    PsppireAxisImpl *haxis;
+    g_object_get (de->data_sheet[0], "horizontal-axis", &haxis, NULL);
+
+    psppire_axis_impl_delete (haxis, posn, 1);
+  }
 }