{
PsppireCaseFile *cf = PSPPIRE_CASE_FILE (object);
- datasheet_destroy (cf->datasheet);
+ if ( cf->accessible)
+ datasheet_destroy (cf->datasheet);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
psppire_case_file_init (PsppireCaseFile *cf)
{
cf->datasheet = NULL;
+ cf->accessible = FALSE;
}
* Creates a new #PsppireCaseFile.
*/
PsppireCaseFile*
-psppire_case_file_new (void)
+psppire_case_file_new (struct casereader *reader)
{
PsppireCaseFile *cf = g_object_new (G_TYPE_PSPPIRE_CASE_FILE, NULL);
- cf->datasheet = datasheet_create (NULL);
+ cf->datasheet = datasheet_create (reader);
+ cf->accessible = TRUE;
return cf;
}
-void
-psppire_case_file_replace_datasheet (PsppireCaseFile *cf, struct datasheet *ds)
-{
- cf->datasheet = ds;
-}
-
-
-
gboolean
psppire_case_file_delete_cases (PsppireCaseFile *cf, gint n_cases, gint first)
{
psppire_case_file_get_case_count (const PsppireCaseFile *cf)
{
g_return_val_if_fail (cf, FALSE);
+ g_return_val_if_fail (cf->accessible, FALSE);
if ( ! cf->datasheet)
return 0;
{
union value *values;
g_return_val_if_fail (cf, FALSE);
+ g_return_val_if_fail (cf->accessible, FALSE);
if ( ! cf->datasheet )
cf->datasheet = datasheet_create (NULL);
return datasheet_get_row (cf->datasheet, casenum, c);
}
+
+
+
+struct casereader *
+psppire_case_file_make_reader (PsppireCaseFile *cf)
+{
+ struct casereader *r = datasheet_make_reader (cf->datasheet);
+ cf->accessible = FALSE;
+ return r;
+}
+
typedef struct _PsppireCaseFileClass PsppireCaseFileClass;
struct ccase;
-struct flexifile;
-struct casefile;
+struct casereader;
struct _PsppireCaseFile
{
GObject parent;
+ /* <private> */
struct datasheet *datasheet;
+ gboolean accessible;
};
/* -- PsppireCaseFile --- */
GType psppire_case_file_get_type (void);
-PsppireCaseFile *psppire_case_file_new (void);
+PsppireCaseFile *psppire_case_file_new (struct casereader *);
gboolean psppire_case_file_insert_case (PsppireCaseFile *cf, struct ccase *c, gint row);
gboolean psppire_case_file_insert_values (PsppireCaseFile *cf, gint n_values, gint before);
struct case_ordering;
+
void psppire_case_file_sort (PsppireCaseFile *cf, struct case_ordering *);
gboolean psppire_case_file_get_case (const PsppireCaseFile *cf, gint casenum,
struct ccase *c);
-void psppire_case_file_replace_datasheet (PsppireCaseFile *,
- struct datasheet *);
-
-
-
G_END_DECLS
#endif /* __PSPPIRE_CASE_FILE_H__ */
}
-
-/**
- * psppire_data_store_replace_set_dictionary:
- * @data_store: The variable store
- * @dict: The dictionary to set
- *
- * If a dictionary is already associated with the data-store, then it will be
- * destroyed.
- **/
void
-psppire_data_store_set_dictionary (PsppireDataStore *data_store, PsppireDict *dict)
+psppire_data_store_set_case_file (PsppireDataStore *data_store,
+ PsppireCaseFile *cf)
{
- data_store->dict = dict;
-
if ( data_store->case_file)
{
g_object_unref (data_store->case_file);
- data_store->case_file = 0;
}
- data_store->case_file = psppire_case_file_new ();
-
-
+ data_store->case_file = cf;
g_signal_connect (data_store->case_file, "cases-deleted",
G_CALLBACK (delete_cases_callback),
g_signal_connect (data_store->case_file, "case-changed",
G_CALLBACK (changed_case_callback),
data_store);
+}
+
+
+
+/**
+ * psppire_data_store_replace_set_dictionary:
+ * @data_store: The variable store
+ * @dict: The dictionary to set
+ *
+ * If a dictionary is already associated with the data-store, then it will be
+ * destroyed.
+ **/
+void
+psppire_data_store_set_dictionary (PsppireDataStore *data_store, PsppireDict *dict)
+{
+ data_store->dict = dict;
g_signal_connect (dict, "variable-inserted",
G_CALLBACK (insert_variable_callback),
inline GType psppire_data_store_get_type (void) G_GNUC_CONST;
PsppireDataStore *psppire_data_store_new (PsppireDict *dict);
+void psppire_data_store_set_case_file (PsppireDataStore *data_store,
+ PsppireCaseFile *cf);
+
void psppire_data_store_set_dictionary (PsppireDataStore *data_store,
- PsppireDict *dict);
+ PsppireDict *dict);
void psppire_data_store_set_font (PsppireDataStore *store,
const PangoFontDescription *fd);
static void
replace_casereader (struct casereader *s)
{
- struct datasheet *datasheet = datasheet_create (s);
+ PsppireCaseFile *pcf = psppire_case_file_new (s);
- psppire_case_file_replace_datasheet (the_data_store->case_file,
- datasheet);
+ psppire_data_store_set_case_file (the_data_store, pcf);
}
void
the_dataset = create_dataset (replace_casereader,
replace_dictionary);
+
+
message_dialog_init (the_source_stream);
- dictionary = psppire_dict_new_from_dict (
- dataset_dict (the_dataset)
- );
+ dictionary = psppire_dict_new_from_dict (dataset_dict (the_dataset));
+
bind_textdomain_codeset (PACKAGE, "UTF-8");
the_var_store = psppire_var_store_new (dictionary);
the_data_store = psppire_data_store_new (dictionary);
-
-
- proc_set_active_file_data (the_dataset,
- datasheet_make_reader (the_data_store->case_file->datasheet));
+ replace_casereader (NULL);
create_icon_factory ();