}
}
+static void
+case_inserted_callback (PsppireDataStore *ds, gint before, gpointer data)
+{
+ PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (data);
+
+ gint i;
+
+ for (i = 0 ; i < 4 ; ++i)
+ {
+ PsppireAxisUniform *vaxis;
+ casenumber n_cases = psppire_data_store_get_case_count (ds);
+
+ g_object_get (de->data_sheet[i], "vertical-axis", &vaxis, NULL);
+
+ psppire_axis_uniform_set_count (vaxis, n_cases + 1);
+ }
+}
+
+
+static void
+cases_deleted_callback (PsppireDataStore *ds, gint first, gint n_cases, gpointer data)
+{
+ PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (data);
+
+ gint i;
+
+ for (i = 0 ; i < 4 ; ++i)
+ {
+ PsppireAxisUniform *vaxis;
+ casenumber case_count = psppire_data_store_get_case_count (ds);
+
+ g_object_get (de->data_sheet[i], "vertical-axis", &vaxis, NULL);
+
+ psppire_axis_uniform_set_count (vaxis, case_count - n_cases);
+ }
+}
+
+
+
/* Return the width (in pixels) of an upper case M when rendered in the
current font of W
*/
"model", de->data_store,
NULL);
- g_signal_connect (de->data_store->dict, "backend-changed", G_CALLBACK (new_variables_callback), de);
- g_signal_connect (de->data_store->dict, "variable-inserted", G_CALLBACK (insert_variable_callback), de);
- g_signal_connect (de->data_store->dict, "variable-deleted", G_CALLBACK (delete_variable_callback), de);
- g_signal_connect (de->data_store->dict, "variable-display-width-changed", G_CALLBACK (rewidth_variable_callback), de);
+ g_signal_connect (de->data_store->dict, "backend-changed",
+ G_CALLBACK (new_variables_callback), de);
+
+ g_signal_connect (de->data_store->dict, "variable-inserted",
+ G_CALLBACK (insert_variable_callback), de);
+
+ g_signal_connect (de->data_store->dict, "variable-deleted",
+ G_CALLBACK (delete_variable_callback), de);
+
+ g_signal_connect (de->data_store->dict, "variable-display-width-changed",
+ G_CALLBACK (rewidth_variable_callback), de);
+
+ g_signal_connect (de->data_store, "backend-changed",
+ G_CALLBACK (new_data_callback), de);
+
+ g_signal_connect (de->data_store, "case-inserted",
+ G_CALLBACK (case_inserted_callback), de);
+
+ g_signal_connect (de->data_store, "cases-deleted",
+ G_CALLBACK (cases_deleted_callback), de);
- g_signal_connect (de->data_store, "backend-changed", G_CALLBACK (new_data_callback), de);
break;
case PROP_VAR_STORE:
if ( de->var_store) g_object_unref (de->var_store);
#include <data/variable.h>
#include <gtksheet/gsheetmodel.h>
+#include <gtksheet/psppire-marshal.h>
#include <pango/pango-context.h>
#include "xmalloca.h"
-enum cf_signal_handler {
- CASES_DELETED,
- CASE_INSERTED,
- CASE_CHANGED,
- n_cf_signals
-};
-
static void psppire_data_store_init (PsppireDataStore *data_store);
static void psppire_data_store_class_init (PsppireDataStoreClass *class);
static GObjectClass *parent_class = NULL;
-enum {
- BACKEND_CHANGED,
- n_SIGNALS};
+enum
+ {
+ BACKEND_CHANGED,
+ CASES_DELETED,
+ CASE_INSERTED,
+ CASE_CHANGED,
+ n_SIGNALS
+ };
static guint signals [n_SIGNALS];
};
- data_store_type = g_type_register_static (G_TYPE_OBJECT, "PsppireDataStore",
+ data_store_type = g_type_register_static (G_TYPE_OBJECT,
+ "PsppireDataStore",
&data_store_info, 0);
g_type_add_interface_static (data_store_type,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
+
+ signals [CASE_INSERTED] =
+ g_signal_new ("case-inserted",
+ 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 [CASE_CHANGED] =
+ g_signal_new ("case-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 [CASES_DELETED] =
+ g_signal_new ("cases-deleted",
+ 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);
}
iface->get_row_sensitivity = get_row_sensitivity;
}
-static void
-delete_cases_callback (GtkWidget *w,
- casenumber first, casenumber n_cases, gpointer data)
-{
- PsppireDataStore *store ;
-
- g_return_if_fail (data);
-
- store = PSPPIRE_DATA_STORE (data);
-
- g_assert (first >= 0);
-
- g_sheet_model_rows_deleted (G_SHEET_MODEL (store), first, n_cases);
-}
-
-
-static void
-insert_case_callback (GtkWidget *w, casenumber casenum, gpointer data)
-{
- PsppireDataStore *store = PSPPIRE_DATA_STORE (data);
-
- g_return_if_fail (data);
-
- g_print ("%s\n", __FUNCTION__);
-
- g_sheet_model_range_changed (G_SHEET_MODEL (store),
- casenum, -1,
- psppire_data_store_get_case_count (store),
- -1);
-
- g_sheet_model_rows_inserted (G_SHEET_MODEL (store), casenum, 1);
-}
-
-
-static void
-changed_case_callback (GtkWidget *w, gint casenum, gpointer data)
-{
- PsppireDataStore *store ;
- g_return_if_fail (data);
-
- store = PSPPIRE_DATA_STORE (data);
-
- g_sheet_model_range_changed (G_SHEET_MODEL (store),
- casenum, -1,
- casenum, -1);
-}
-
/*
A callback which occurs after a variable has been deleted.
}
+
static void
variable_changed_callback (GObject *obj, gint var_num, gpointer data)
{
g_sheet_model_range_changed (G_SHEET_MODEL (ds),
-1, -1, -1, -1);
-#if 0
- for (i = 0 ; i < n_cf_signals ; ++i )
- {
- if ( ds->cf_handler_id [i] > 0 )
- g_signal_handler_disconnect (ds->case_file,
- ds->cf_handler_id[i]);
- }
-#endif
-
if ( ds->dict )
for (i = 0 ; i < n_dict_signals; ++i )
{
}
}
-#if 0
- ds->cf_handler_id [CASES_DELETED] =
- g_signal_connect (ds->case_file, "cases-deleted",
- G_CALLBACK (delete_cases_callback),
- ds);
-
- ds->cf_handler_id [CASE_INSERTED] =
- g_signal_connect (ds->case_file, "case-inserted",
- G_CALLBACK (insert_case_callback),
- ds);
-
- ds->cf_handler_id [CASE_CHANGED] =
- g_signal_connect (ds->case_file, "case-changed",
- G_CALLBACK (changed_case_callback),
- ds);
-#endif
-
g_signal_emit (ds, signals[BACKEND_CHANGED], 0);
}
int i;
struct casereader *reader ;
-#if 0
- for (i = 0 ; i < n_cf_signals ; ++i )
- {
- g_signal_handler_disconnect (ds->case_file, ds->cf_handler_id[i]);
- ds->cf_handler_id[i] = 0 ;
- }
-#endif
-
if ( ds->dict )
for (i = 0 ; i < n_dict_signals; ++i )
{
ds->dict_handler_id[i]);
}
- reader = datasheet_make_reader (ds->datasheet);
+ reader = datasheet_make_reader (ds->datasheet);
/* We must not reference this again */
ds->datasheet = NULL;
gboolean
-psppire_data_store_delete_cases (PsppireDataStore *ds, casenumber n_cases,
- casenumber first)
+psppire_data_store_delete_cases (PsppireDataStore *ds, casenumber first,
+ casenumber n_cases)
{
g_return_val_if_fail (ds, FALSE);
g_return_val_if_fail (ds->datasheet, FALSE);
g_return_val_if_fail (first + n_cases <=
psppire_data_store_get_case_count (ds), FALSE);
+
datasheet_delete_rows (ds->datasheet, first, n_cases);
g_signal_emit (ds, signals [CASES_DELETED], 0, first, n_cases);
case_clone (&tmp, cc);
result = datasheet_insert_rows (ds->datasheet, posn, &tmp, 1);
- g_debug ("Result %d. Inserted case at posn %ld", result, posn);
if ( result )
g_signal_emit (ds, signals [CASE_INSERTED], 0, posn);
else