#include <libpspp/pool.h>
#include <libpspp/misc.h>
#include "psppire-axis.h"
+#include "psppire-marshal.h"
#include <gtk/gtk.h>
+
+/* Signals */
+enum
+ {
+ RESIZE_UNIT,
+ n_signals
+ };
+
+static guint signals[n_signals] ;
+
+
#define PSPPIRE_AXIS_GET_IFACE(obj) \
(G_TYPE_INSTANCE_GET_INTERFACE ((obj), PSPPIRE_TYPE_AXIS_IFACE, PsppireAxisIface))
parent_class = g_type_class_peek_parent (class);
object_class->finalize = psppire_axis_finalize;
+
+
+ signals[RESIZE_UNIT] =
+ g_signal_new ("resize-unit",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ psppire_marshal_VOID__INT_LONG,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_INT,
+ G_TYPE_LONG
+ );
}
if (PSPPIRE_AXIS_GET_IFACE (a)->resize)
PSPPIRE_AXIS_GET_IFACE (a)->resize (a, unit, size);
+
+
+ g_signal_emit (a, signals [RESIZE_UNIT], 0, unit, size);
}
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)
{
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)