}
-/* Called from variable.c to notify the dictionary that the variable's width
- has changed */
-void
-dict_var_resized (const struct variable *v, int old_width)
-{
- if ( var_has_vardict (v))
- {
- const struct vardict_info *vardict = var_get_vardict (v);
- struct dictionary *d;
-
- d = vardict->dict;
-
- if (d->changed) d->changed (d, d->changed_data);
-
- invalidate_proto (d);
- if ( d->callbacks && d->callbacks->var_resized )
- d->callbacks->var_resized (d, var_get_dict_index (v), old_width,
- d->cb_data);
- }
-}
-
-/* Called from variable.c to notify the dictionary that the variable's display width
- has changed */
-void
-dict_var_display_width_changed (const struct variable *v)
-{
- if ( var_has_vardict (v))
- {
- const struct vardict_info *vardict = var_get_vardict (v);
- struct dictionary *d;
-
- d = vardict->dict;
-
- if (d->changed) d->changed (d, d->changed_data);
- if ( d->callbacks && d->callbacks->var_display_width_changed )
- d->callbacks->var_display_width_changed (d, var_get_dict_index (v), d->cb_data);
- }
-}
\f
/* Dictionary used to contain "internal variables". */
static struct dictionary *internal_dict;
void (*var_deleted) (struct dictionary *, const struct variable *,
int dict_index, int case_index, void *);
void (*var_changed) (struct dictionary *, int, unsigned int, const struct variable *, void *);
- void (*var_resized) (struct dictionary *, int, int, void *);
void (*weight_changed) (struct dictionary *, int, void *);
void (*filter_changed) (struct dictionary *, int, void *);
void (*split_changed) (struct dictionary *, void *);
- void (*var_display_width_changed) (struct dictionary *, int, void *);
};
void dict_set_callbacks (struct dictionary *, const struct dict_callbacks *,
/* Called by variable.c, defined in dictionary.c. */
void dict_var_changed (const struct variable *v, unsigned int what, struct variable *ov);
-void dict_var_resized (const struct variable *v, int old_width);
-void dict_var_display_width_changed (const struct variable *v);
int vardict_get_dict_index (const struct vardict_info *);
fmt_resize (&v->write, new_width);
v->width = new_width;
- dict_var_resized (v, old_width);
dict_var_changed (v, VAR_TRAIT_WIDTH, ov);
}
if (v->display_width != new_width)
{
v->display_width = new_width;
- dict_var_display_width_changed (v);
}
}
g_return_if_fail (data_sheet->data_store != NULL);
g_return_if_fail (dict == data_sheet->data_store->dict);
+
+ if (what & VAR_TRAIT_DISPLAY_WIDTH)
+ on_variable_display_width_changed (dict, dict_index, data_sheet);
+
column = psppire_data_sheet_find_column_for_variable (data_sheet,
dict_index);
if (column == NULL)
return;
+
var = psppire_dict_get_variable (data_store->dict, dict_index);
g_return_if_fail (var != NULL);
g_signal_connect (data_store->dict, "variable-changed",
G_CALLBACK (on_variable_changed),
data_sheet);
- g_signal_connect (data_store->dict, "variable-display-width-changed",
- G_CALLBACK (on_variable_display_width_changed),
- data_sheet);
g_signal_connect (data_store->dict, "variable-inserted",
G_CALLBACK (on_variable_inserted), data_sheet);
g_signal_connect (data_store->dict, "variable-deleted",
datasheet_insert_column (store->datasheet, NULL, -1, case_index);
}
-static void
-variable_changed_callback (GObject *obj, gint var_num, guint what, const struct variable *oldvar, gpointer data)
-{
-}
-
-static void
-insert_variable_callback (GObject *obj, gint var_num, gpointer data)
-{
- struct variable *variable;
- PsppireDataStore *store;
- gint posn;
-
- g_return_if_fail (data);
-
- store = PSPPIRE_DATA_STORE (data);
-
- variable = psppire_dict_get_variable (store->dict, var_num);
- posn = var_get_case_index (variable);
- psppire_data_store_insert_value (store, var_get_width (variable), posn);
-}
-
struct resize_datum_aux
{
int old_width;
int new_width;
};
-
-void
+static void
resize_datum (const union value *old, union value *new, void *aux_)
{
struct resize_datum_aux *aux = aux_;
}
static void
-dict_size_change_callback (GObject *obj,
- gint var_num, gint old_width, gpointer data)
+variable_changed_callback (GObject *obj, gint var_num, guint what, const struct variable *oldvar,
+ gpointer data)
{
PsppireDataStore *store = PSPPIRE_DATA_STORE (data);
- struct variable *variable;
- int posn;
-
- variable = psppire_dict_get_variable (store->dict, var_num);
- posn = var_get_case_index (variable);
+ struct variable *variable = psppire_dict_get_variable (store->dict, var_num);
- if (old_width != var_get_width (variable))
+ if (what & VAR_TRAIT_WIDTH)
{
+ int posn = var_get_case_index (variable);
struct resize_datum_aux aux;
- aux.old_width = old_width;
+ aux.old_width = var_get_width (oldvar);
aux.new_width = var_get_width (variable);
datasheet_resize_column (store->datasheet, posn, aux.new_width,
resize_datum, &aux);
}
}
+static void
+insert_variable_callback (GObject *obj, gint var_num, gpointer data)
+{
+ struct variable *variable;
+ PsppireDataStore *store;
+ gint posn;
+ g_return_if_fail (data);
+
+ store = PSPPIRE_DATA_STORE (data);
+
+ variable = psppire_dict_get_variable (store->dict, var_num);
+ posn = var_get_case_index (variable);
+ psppire_data_store_insert_value (store, var_get_width (variable), posn);
+}
/**
* psppire_data_store_new:
g_signal_connect (dict, "variable-changed",
G_CALLBACK (variable_changed_callback),
data_store);
-
- data_store->dict_handler_id [SIZE_CHANGED] =
- g_signal_connect (dict, "dict-size-changed",
- G_CALLBACK (dict_size_change_callback),
- data_store);
}
VARIABLE_INSERTED,
VARIABLE_CHANGED,
VARIABLE_DELETED,
- SIZE_CHANGED,
n_dict_signals
};
BACKEND_CHANGED,
VARIABLE_CHANGED,
- VARIABLE_RESIZED,
VARIABLE_INSERTED,
VARIABLE_DELETED,
- VARIABLE_DISPLAY_WIDTH_CHANGED,
WEIGHT_CHANGED,
FILTER_CHANGED,
G_TYPE_INT);
- signals [VARIABLE_RESIZED] =
- g_signal_new ("dict-size-changed",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST,
- 0,
- NULL, NULL,
- psppire_marshal_VOID__INT_INT,
- G_TYPE_NONE,
- 2,
- G_TYPE_INT,
- G_TYPE_INT);
-
- signals [VARIABLE_DISPLAY_WIDTH_CHANGED] =
- g_signal_new ("variable-display-width-changed",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE,
- 1,
- G_TYPE_INT);
-
-
signals [WEIGHT_CHANGED] =
g_signal_new ("weight-changed",
G_TYPE_FROM_CLASS (class),
g_signal_emit (pd, signals [VARIABLE_CHANGED], 0, idx, what, oldvar);
}
-static void
-resize_cb (struct dictionary *d, int idx, int old_width, void *pd)
-{
- g_signal_emit (pd, signals [VARIABLE_RESIZED], 0, idx, old_width);
-}
-
static void
weight_changed_callback (struct dictionary *d, int idx, void *pd)
{
g_signal_emit (pd, signals [SPLIT_CHANGED], 0);
}
-static void
-variable_display_width_callback (struct dictionary *d, int idx, void *pd)
-{
- g_signal_emit (pd, signals [VARIABLE_DISPLAY_WIDTH_CHANGED], 0, idx);
-}
-
-
-
static const struct dict_callbacks gui_callbacks =
{
addcb,
delcb,
mutcb,
- resize_cb,
weight_changed_callback,
filter_changed_callback,
- split_changed_callback,
- variable_display_width_callback
+ split_changed_callback
};
static void
}
-void
-psppire_dict_resize_variable (PsppireDict *d, const struct variable *pv,
- gint old_size, gint new_size)
-{
- g_return_if_fail (d);
- g_return_if_fail (d->dict);
-
- if ( old_size == new_size )
- return ;
-
- g_signal_emit (d, signals [VARIABLE_RESIZED], 0,
- var_get_dict_index (pv),
- new_size - old_size );
-}
-
-
/* Tree Model Stuff */
static GtkTreeModelFlags tree_model_get_flags (GtkTreeModel *model);
struct variable *psppire_dict_insert_variable (PsppireDict *d, gint idx,
const gchar *name);
-void psppire_dict_resize_variable (PsppireDict *,
- const struct variable *,
- gint, gint );
-
gboolean psppire_dict_check_name (const PsppireDict *dict,
const gchar *name, gboolean report);