set_var_dict_index (struct variable *v, int dict_index)
{
struct vardict_info vdi = *var_get_vardict (v);
+ struct dictionary *d = vdi.dict;
vdi.dict_index = dict_index;
var_set_vardict (v, &vdi);
+
+ if ( d->callbacks && d->callbacks->var_changed )
+ d->callbacks->var_changed (d, dict_index, d->cb_data);
}
/* Sets the case_index in V's vardict to DICT_INDEX. */
listed in ORDER in that order at the beginning of D. The
other variables in D, if any, retain their relative
positions. */
-void
+void
dict_reorder_vars (struct dictionary *d,
- struct variable *const *order, size_t count)
+ struct variable *const *order, size_t count)
{
struct variable **new_var;
size_t i;
-
+
assert (d != NULL);
assert (count == 0 || order != NULL);
assert (count <= d->var_cnt);
new_var = xnmalloc (d->var_cnt, sizeof *new_var);
memcpy (new_var, order, count * sizeof *new_var);
- for (i = 0; i < count; i++)
+ for (i = 0; i < count; i++)
{
size_t index = var_get_dict_index (order[i]);
assert (d->var[index] == order[i]);
#include "psppire-var-store.h"
+static void insert_variable (GtkCheckMenuItem *m, gpointer data);
+
+
/* Switch between the VAR SHEET and the DATA SHEET */
enum {PAGE_DATA_SHEET = 0, PAGE_VAR_SHEET};
de);
+ g_signal_connect (get_widget_assert (de->xml,"data_insert-variable"),
+ "activate",
+ G_CALLBACK (insert_variable),
+ de);
+
g_signal_connect (get_widget_assert (de->xml,"help_about"),
"activate",
static void
select_sheet (struct data_editor *de, guint page_num)
{
- GtkWidget *insert_variable = get_widget_assert (de->xml, "insert-variable");
+ GtkWidget *insert_variable = get_widget_assert (de->xml, "data_insert-variable");
GtkWidget *insert_cases = get_widget_assert (de->xml, "insert-cases");
GtkWidget *view_data = get_widget_assert (de->xml, "view_data");
case PAGE_DATA_SHEET:
gtk_widget_show (view_variables);
gtk_widget_hide (view_data);
- gtk_widget_set_sensitive (insert_variable, FALSE);
+#if 0
gtk_widget_set_sensitive (insert_cases, TRUE);
+#endif
break;
default:
g_assert_not_reached ();
g_assert_not_reached ();
}
}
+
+
+/* Insert a new variable before the current row in the variable sheet,
+ or before the current column in the data sheet, whichever is selected */
+static void
+insert_variable (GtkCheckMenuItem *m, gpointer data)
+{
+ struct data_editor *de = data;
+ gint posn;
+
+ GtkWidget *notebook = get_widget_assert (de->xml, "notebook");
+
+ GtkSheet *var_sheet =
+ GTK_SHEET (get_widget_assert (de->xml, "variable_sheet"));
+
+
+
+ PsppireVarStore *vs = PSPPIRE_VAR_STORE
+ (gtk_sheet_get_model (var_sheet) );
+
+
+ switch ( gtk_notebook_get_current_page ( GTK_NOTEBOOK (notebook)) )
+ {
+ case PAGE_VAR_SHEET:
+ posn = var_sheet->active_cell.row;
+ break;
+ case PAGE_DATA_SHEET:
+ {
+ GtkSheet *data_sheet =
+ GTK_SHEET (get_widget_assert (de->xml, "data_sheet"));
+
+ if ( data_sheet->state == GTK_SHEET_COLUMN_SELECTED )
+ posn = data_sheet->range.col0;
+ else
+ posn = data_sheet->active_cell.col;
+ }
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ psppire_dict_insert_variable (vs->dict, posn, NULL);
+
+}
+
+
<property name="use_underline">True</property>
<child internal-child="image">
- <widget class="GtkImage" id="image44">
+ <widget class="GtkImage" id="image47">
<property name="visible">True</property>
<property name="stock">gtk-find</property>
<property name="icon_size">1</property>
</child>
<child>
- <widget class="GtkMenuItem" id="menuitem4">
+ <widget class="GtkMenuItem" id="data">
<property name="visible">True</property>
- <property name="sensitive">False</property>
<property name="label" translatable="yes">_Data</property>
<property name="use_underline">True</property>
<child>
- <widget class="GtkMenu" id="menuitem4_menu">
+ <widget class="GtkMenu" id="data_menu">
<child>
- <widget class="GtkMenuItem" id="insert-variable">
+ <widget class="GtkMenuItem" id="data_insert-variable">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="label" translatable="yes">Insert Variable</property>
<child>
<widget class="GtkMenuItem" id="insert-cases">
<property name="visible">True</property>
+ <property name="sensitive">False</property>
<property name="label" translatable="yes">Insert Cases</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_insert_cases" last_modification_time="Sat, 01 Jul 2006 08:40:06 GMT"/>
<child>
<widget class="GtkImageMenuItem" id="go_to_case">
<property name="visible">True</property>
+ <property name="sensitive">False</property>
<property name="label" translatable="yes">Go To Case</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_go_to_case_activate" last_modification_time="Mon, 19 Jun 2006 10:29:37 GMT"/>
<child internal-child="image">
- <widget class="GtkImage" id="image45">
+ <widget class="GtkImage" id="image48">
<property name="visible">True</property>
<property name="stock">gtk-jump-to</property>
<property name="icon_size">1</property>
<child>
<widget class="GtkSeparatorMenuItem" id="separator4">
<property name="visible">True</property>
+ <property name="sensitive">False</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="sort_cases">
<property name="visible">True</property>
+ <property name="sensitive">False</property>
<property name="label" translatable="yes">Sort Cases</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_sort_cases_activate" last_modification_time="Tue, 20 Jun 2006 10:27:11 GMT"/>
<child>
<widget class="GtkSeparatorMenuItem" id="separator5">
<property name="visible">True</property>
+ <property name="sensitive">False</property>
</widget>
</child>
ds->width_of_m = calc_m_width (sheet, ds->font_desc);
}
+
+
GtkWidget*
psppire_data_sheet_create (gchar *widget_name, gchar *string1, gchar *string2,
gint int1, gint int2)
gtk_sheet_set_active_cell (GTK_SHEET (sheet), -1, -1);
-
gtk_sheet_set_model (GTK_SHEET (sheet), G_SHEET_MODEL (the_data_store));
gtk_widget_show (sheet);
var_num, -1);
}
+
+static void
+variable_changed_callback (GObject *obj, gint var_num, gpointer data)
+{
+ PsppireDataStore *store;
+
+ g_return_if_fail (data);
+
+ store = PSPPIRE_DATA_STORE (data);
+
+ g_sheet_column_columns_changed (G_SHEET_COLUMN (store),
+ var_num, 1);
+
+
+ g_sheet_model_range_changed (G_SHEET_MODEL (store),
+ -1, var_num,
+ -1, var_num);
+}
+
static void
insert_variable_callback (GObject *obj, gint var_num, gpointer data)
{
G_CALLBACK (delete_variables_callback),
data_store);
+ g_signal_connect (dict, "variable-changed",
+ G_CALLBACK (variable_changed_callback),
+ data_store);
+
+
g_signal_connect (dict, "dict-size-changed",
G_CALLBACK (dict_size_change_callback),
data_store);
psppire_dict_insert_variable (PsppireDict *d, gint idx, const gchar *name)
{
struct variable *var ;
+ g_return_if_fail (idx >= 0);
g_return_if_fail (d);
g_return_if_fail (G_IS_PSPPIRE_DICT (d));
-
if ( ! name )
name = auto_generate_var_name (d);
var_change_callback (GtkWidget *w, gint n, gpointer data)
{
GSheetModel *model = G_SHEET_MODEL (data);
+
g_sheet_model_range_changed (model,
n, 0, n, n_COLS);
}