[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] pspp/src data/ChangeLog data/dictionary.c data/...
From: |
John Darrington |
Subject: |
[Pspp-cvs] pspp/src data/ChangeLog data/dictionary.c data/... |
Date: |
Sun, 07 Jan 2007 04:04:00 +0000 |
CVSROOT: /sources/pspp
Module name: pspp
Changes by: John Darrington <jmd> 07/01/07 04:04:00
Modified files:
src/data : ChangeLog dictionary.c dictionary.h procedure.c
src/language/data-io: get.c
src/language/stats: aggregate.c
src/language/xforms: select-if.c
src/ui/gui : ChangeLog data-editor.c data-editor.glade
psppire-dict.c
Log message:
Applied patch #5661
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/ChangeLog?cvsroot=pspp&r1=1.96&r2=1.97
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/dictionary.c?cvsroot=pspp&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/dictionary.h?cvsroot=pspp&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/procedure.c?cvsroot=pspp&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/data-io/get.c?cvsroot=pspp&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/stats/aggregate.c?cvsroot=pspp&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/xforms/select-if.c?cvsroot=pspp&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/ChangeLog?cvsroot=pspp&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/data-editor.c?cvsroot=pspp&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/data-editor.glade?cvsroot=pspp&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/psppire-dict.c?cvsroot=pspp&r1=1.22&r2=1.23
Patches:
Index: data/ChangeLog
===================================================================
RCS file: /sources/pspp/pspp/src/data/ChangeLog,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -b -r1.96 -r1.97
--- data/ChangeLog 3 Jan 2007 02:03:18 -0000 1.96
+++ data/ChangeLog 7 Jan 2007 04:04:00 -0000 1.97
@@ -1,7 +1,17 @@
+Sun Jan 7 08:33:04 WST 2007 John Darrington <address@hidden>
+
+ * dictionary.c dictionary.h : Added callbacks for change of filter and
+ split variables. Refactored some code to ensure that callbacks get
+ invoked when appropriate.
+
+ * procedure.c (proc_cancel_temporary_transformations): Make sure that
+ replace_dict callback occurs when permanent_dict replaces the current
+ dictionary.
+
Wed Jan 3 11:02:11 WST 2007 John Darrington <address@hidden>
- * dictionary.c dictionary.h : Added callback for when the weight
variable
- of a dictionary changes.
+ * dictionary.c dictionary.h : Added callback for when the weight
+ variable of a dictionary changes.
Mon Jan 1 10:36:26 WST 2007 John Darrington <address@hidden>
Index: data/dictionary.c
===================================================================
RCS file: /sources/pspp/pspp/src/data/dictionary.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- data/dictionary.c 3 Jan 2007 02:03:18 -0000 1.28
+++ data/dictionary.c 7 Jan 2007 04:04:00 -0000 1.29
@@ -1,5 +1,5 @@
/* PSPP - computes sample statistics.
- Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -81,7 +81,6 @@
dict->cb_data = callback_data;
}
-
/* Shallow copy the callbacks from SRC to DEST */
void
dict_copy_callbacks (struct dictionary *dest,
@@ -97,21 +96,8 @@
{
struct dictionary *d = xzalloc (sizeof *d);
- d->var = NULL;
- d->var_cnt = d->var_cap = 0;
d->name_tab = hsh_create (8, compare_vars_by_name, hash_var_by_name,
NULL, NULL);
- d->next_value_idx = 0;
- d->split = NULL;
- d->split_cnt = 0;
- d->weight = NULL;
- d->filter = NULL;
- d->case_limit = 0;
- d->label = NULL;
- d->documents = NULL;
- d->vector = NULL;
- d->vector_cnt = 0;
-
return d;
}
@@ -145,10 +131,10 @@
}
if (s->weight != NULL)
- d->weight = dict_lookup_var_assert (d, var_get_name (s->weight));
+ dict_set_weight (d, dict_lookup_var_assert (d, var_get_name (s->weight)));
if (s->filter != NULL)
- d->filter = dict_lookup_var_assert (d, var_get_name (s->filter));
+ dict_set_filter (d, dict_lookup_var_assert (d, var_get_name (s->filter)));
d->case_limit = s->case_limit;
dict_set_label (d, dict_get_label (s));
@@ -186,11 +172,9 @@
d->var_cnt = d->var_cap = 0;
hsh_clear (d->name_tab);
d->next_value_idx = 0;
- free (d->split);
- d->split = NULL;
- d->split_cnt = 0;
- d->weight = NULL;
- d->filter = NULL;
+ dict_set_split_vars (d, NULL, 0);
+ dict_set_weight (d, NULL);
+ dict_set_filter (d, NULL);
d->case_limit = 0;
free (d->label);
d->label = NULL;
@@ -218,6 +202,10 @@
{
if (d != NULL)
{
+ /* In general, we don't want callbacks occuring, if the dictionary
+ is being destroyed */
+ d->callbacks = NULL ;
+
dict_clear (d);
hsh_destroy (d->name_tab);
free (d);
@@ -462,13 +450,14 @@
/* Delete aux data. */
var_clear_aux (v);
- /* Remove V from splits, weight, filter variables. */
- d->split_cnt = remove_equal (d->split, d->split_cnt, sizeof *d->split,
- &v, compare_var_ptrs, NULL);
+ dict_unset_split_var (d, v);
+
if (d->weight == v)
- d->weight = NULL;
+ dict_set_weight (d, NULL);
+
if (d->filter == v)
- d->filter = NULL;
+ dict_set_filter (d, NULL);
+
dict_clear_vectors (d);
/* Remove V from var array. */
@@ -763,6 +752,11 @@
assert (v == NULL || dict_contains_var (d, v));
d->filter = v;
+
+ if ( d->callbacks && d->callbacks->filter_changed )
+ d->callbacks->filter_changed (d,
+ v ? var_get_dict_index (v) : -1,
+ d->cb_data);
}
/* Returns the case limit for dictionary D, or zero if the number
@@ -1025,6 +1019,22 @@
return d->split_cnt;
}
+/* Removes variable V from the set of split variables in dictionary D */
+void
+dict_unset_split_var (struct dictionary *d,
+ struct variable *v)
+{
+ const int count = d->split_cnt;
+ d->split_cnt = remove_equal (d->split, d->split_cnt, sizeof *d->split,
+ &v, compare_var_ptrs, NULL);
+
+ if ( count == d->split_cnt)
+ return;
+
+ if ( d->callbacks && d->callbacks->split_changed )
+ d->callbacks->split_changed (d, d->cb_data);
+}
+
/* Sets CNT split vars SPLIT in dictionary D. */
void
dict_set_split_vars (struct dictionary *d,
@@ -1036,6 +1046,9 @@
d->split_cnt = cnt;
d->split = xnrealloc (d->split, cnt, sizeof *d->split);
memcpy (d->split, split, cnt * sizeof *d->split);
+
+ if ( d->callbacks && d->callbacks->split_changed )
+ d->callbacks->split_changed (d, d->cb_data);
}
/* Returns the file label for D, or a null pointer if D is
Index: data/dictionary.h
===================================================================
RCS file: /sources/pspp/pspp/src/data/dictionary.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- data/dictionary.h 3 Jan 2007 02:03:18 -0000 1.10
+++ data/dictionary.h 7 Jan 2007 04:04:00 -0000 1.11
@@ -1,5 +1,5 @@
/* PSPP - computes sample statistics.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -33,6 +33,8 @@
void (*var_deleted) (struct dictionary *, int, void *);
void (*var_changed) (struct dictionary *, int, void *);
void (*weight_changed) (struct dictionary *, int, void *);
+ void (*filter_changed) (struct dictionary *, int, void *);
+ void (*split_changed) (struct dictionary *, void *);
};
@@ -112,6 +114,8 @@
size_t dict_get_split_cnt (const struct dictionary *);
void dict_set_split_vars (struct dictionary *,
struct variable *const *, size_t cnt);
+void dict_unset_split_var (struct dictionary *d,
+ struct variable *v);
const char *dict_get_label (const struct dictionary *);
void dict_set_label (struct dictionary *, const char *);
@@ -134,5 +138,4 @@
/* Called only from variable.c */
void dict_var_changed (const struct variable *v);
-
#endif /* dictionary.h */
Index: data/procedure.c
===================================================================
RCS file: /sources/pspp/pspp/src/data/procedure.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- data/procedure.c 1 Jan 2007 01:44:33 -0000 1.22
+++ data/procedure.c 7 Jan 2007 04:04:00 -0000 1.23
@@ -1,5 +1,5 @@
/* PSPP - computes sample statistics.
- Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -801,6 +801,7 @@
add_case_limit_trns (ds);
ds->permanent_dict = dict_clone (ds->dict);
+
trns_chain_finalize (ds->permanent_trns_chain);
ds->temporary_trns_chain = ds->cur_trns_chain = trns_chain_create ();
}
@@ -836,8 +837,7 @@
{
if (proc_in_temporary_transformations (ds))
{
- dict_destroy (ds->dict);
- ds->dict = ds->permanent_dict;
+ dataset_set_dict (ds, ds->permanent_dict);
ds->permanent_dict = NULL;
trns_chain_destroy (ds->temporary_trns_chain);
@@ -1015,14 +1015,20 @@
}
+/* Set or replace dataset DS's dictionary with DICT.
+ The old dictionary is destroyed */
void
dataset_set_dict (struct dataset *ds, struct dictionary *dict)
{
+ struct dictionary *old_dict = ds->dict;
+
dict_copy_callbacks (dict, ds->dict);
ds->dict = dict;
if ( ds->replace_dict )
ds->replace_dict (dict);
+
+ dict_destroy (old_dict);
}
int
Index: language/data-io/get.c
===================================================================
RCS file: /sources/pspp/pspp/src/language/data-io/get.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- language/data-io/get.c 22 Dec 2006 11:12:14 -0000 1.28
+++ language/data-io/get.c 7 Jan 2007 04:04:00 -0000 1.29
@@ -149,7 +149,6 @@
pgm->map = finish_case_map (dict);
- dict_destroy (dataset_dict (ds));
dataset_set_dict (ds, dict);
proc_set_source (ds,
@@ -1137,7 +1136,6 @@
discard_variables (ds);
- dict_destroy (dataset_dict (ds));
dataset_set_dict (ds, mtf.dict);
mtf.dict = NULL;
proc_set_source (ds, storage_source_create (mtf.output));
Index: language/stats/aggregate.c
===================================================================
RCS file: /sources/pspp/pspp/src/language/stats/aggregate.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- language/stats/aggregate.c 23 Dec 2006 06:11:33 -0000 1.27
+++ language/stats/aggregate.c 7 Jan 2007 04:04:00 -0000 1.28
@@ -305,7 +305,6 @@
goto error;
}
discard_variables (ds);
- dict_destroy (dict);
dataset_set_dict (ds, agr.dict);
agr.dict = NULL;
proc_set_source (ds, agr.sink->class->make_source (agr.sink));
Index: language/xforms/select-if.c
===================================================================
RCS file: /sources/pspp/pspp/src/language/xforms/select-if.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- language/xforms/select-if.c 15 Dec 2006 00:16:03 -0000 1.14
+++ language/xforms/select-if.c 7 Jan 2007 04:04:00 -0000 1.15
@@ -95,12 +95,12 @@
{
struct dictionary *dict = dataset_dict (ds);
if (lex_match_id (lexer, "OFF"))
- dict_set_filter (dataset_dict (ds), NULL);
+ dict_set_filter (dict, NULL);
else if (lex_token (lexer) == '.')
{
msg (SW, _("Syntax error expecting OFF or BY. "
"Turning off case filtering."));
- dict_set_filter (dataset_dict (ds), NULL);
+ dict_set_filter (dict, NULL);
}
else
{
Index: ui/gui/ChangeLog
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/ChangeLog,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- ui/gui/ChangeLog 1 Jan 2007 01:44:33 -0000 1.34
+++ ui/gui/ChangeLog 7 Jan 2007 04:04:00 -0000 1.35
@@ -1,3 +1,11 @@
+Sun Jan 7 08:38:29 WST 2007 John Darrington <address@hidden>
+
+ * psppire-dict.c: Add FILTER_CHANGED and SPLIT_CHANGED signals
+ corresponding to the callbacks in src/data/dictionary.c
+
+ * data-editor.c : Connect functions to the FILTER_CHANGED and
+ SPLIT_CHANGED signals to update the status bar accordingly.
+
Mon Jan 1 10:37:07 WST 2007 John Darrington <address@hidden>
* psppire-case-file.c psppire-case-file.h: Changed the backend
Index: ui/gui/data-editor.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/data-editor.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- ui/gui/data-editor.c 4 Jan 2007 08:15:27 -0000 1.10
+++ ui/gui/data-editor.c 7 Jan 2007 04:04:00 -0000 1.11
@@ -59,8 +59,10 @@
static void select_sheet (struct data_editor *de, guint page_num);
-/* Callback for when the dictionary changes its weights */
+/* Callback for when the dictionary changes properties*/
static void on_weight_change (GObject *, gint, gpointer);
+static void on_filter_change (GObject *, gint, gpointer);
+static void on_split_change (PsppireDict *, gpointer);
static void data_var_select (GtkNotebook *notebook,
GtkNotebookPage *page,
@@ -136,6 +138,14 @@
G_CALLBACK (on_weight_change),
de);
+ g_signal_connect (vs->dict, "filter-changed",
+ G_CALLBACK (on_filter_change),
+ de);
+
+ g_signal_connect (vs->dict, "split-changed",
+ G_CALLBACK (on_split_change),
+ de);
+
connect_help (de->xml);
de->invoke_weight_cases_dialog =
@@ -672,6 +682,78 @@
psppire_dict_insert_variable (vs->dict, posn, NULL);
}
+/* Callback for when the dictionary changes its split variables */
+static void
+on_split_change (PsppireDict *dict, gpointer data)
+{
+ struct data_editor *de = data;
+
+ size_t n_split_vars = dict_get_split_cnt (dict->dict);
+
+ GtkWidget *split_status_area =
+ get_widget_assert (de->xml, "split-file-status-area");
+
+ if ( n_split_vars == 0 )
+ {
+ gtk_label_set_text (GTK_LABEL (split_status_area), _("No Split"));
+ }
+ else
+ {
+ gint i;
+ GString *text;
+ GtkSheet *var_sheet =
+ GTK_SHEET (get_widget_assert (de->xml, "variable_sheet"));
+
+ PsppireVarStore *vs = PSPPIRE_VAR_STORE
+ (gtk_sheet_get_model (var_sheet) );
+
+ struct variable *const * split_vars = dict_get_split_vars (dict->dict);
+
+ text = g_string_new (_("Split by "));
+
+ for (i = 0 ; i < n_split_vars - 1; ++i )
+ {
+ g_string_append_printf (text, "%s, ", var_get_name (split_vars[i]));
+ }
+ g_string_append (text, var_get_name (split_vars[i]));
+
+ gtk_label_set_text (GTK_LABEL (split_status_area), text->str);
+
+ g_string_free (text, TRUE);
+ }
+}
+
+
+/* Callback for when the dictionary changes its filter variable */
+static void
+on_filter_change (GObject *o, gint filter_index, gpointer data)
+{
+ struct data_editor *de = data;
+ GtkWidget *filter_status_area =
+ get_widget_assert (de->xml, "filter-use-status-area");
+
+ if ( filter_index == -1 )
+ {
+ gtk_label_set_text (GTK_LABEL (filter_status_area), _("Filter off"));
+ }
+ else
+ {
+ GtkSheet *var_sheet =
+ GTK_SHEET (get_widget_assert (de->xml, "variable_sheet"));
+
+ PsppireVarStore *vs = PSPPIRE_VAR_STORE
+ (gtk_sheet_get_model (var_sheet) );
+
+ struct variable *var = psppire_dict_get_variable (vs->dict,
+ filter_index);
+
+ gchar *text = g_strdup_printf (_("Filter by %s"), var_get_name (var));
+
+ gtk_label_set_text (GTK_LABEL (filter_status_area), text);
+
+ g_free (text);
+ }
+}
/* Callback for when the dictionary changes its weights */
static void
Index: ui/gui/data-editor.glade
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/data-editor.glade,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- ui/gui/data-editor.glade 4 Jan 2007 08:15:27 -0000 1.9
+++ ui/gui/data-editor.glade 7 Jan 2007 04:04:00 -0000 1.10
@@ -880,6 +880,7 @@
<child>
<widget class="GtkLabel" id="filter-use-status-area">
<property name="visible">True</property>
+ <property
name="ellipsize">PANGO_ELLIPSIZE_START</property>
<property name="width_chars">10</property>
<property name="single_line_mode">True</property>
</widget>
@@ -931,6 +932,7 @@
<child>
<widget class="GtkLabel" id="split-file-status-area">
<property name="visible">True</property>
+ <property
name="ellipsize">PANGO_ELLIPSIZE_START</property>
<property name="width_chars">10</property>
<property name="single_line_mode">True</property>
</widget>
Index: ui/gui/psppire-dict.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire-dict.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- ui/gui/psppire-dict.c 4 Jan 2007 08:15:27 -0000 1.22
+++ ui/gui/psppire-dict.c 7 Jan 2007 04:04:00 -0000 1.23
@@ -1,6 +1,6 @@
/*
PSPPIRE --- A Graphical User Interface for PSPP
- Copyright (C) 2004, 2006 Free Software Foundation
+ Copyright (C) 2004, 2006, 2007 Free Software Foundation
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -50,12 +50,12 @@
VARIABLE_INSERTED,
VARIABLES_DELETED,
WEIGHT_CHANGED,
+ FILTER_CHANGED,
+ SPLIT_CHANGED,
n_SIGNALS};
static guint signal[n_SIGNALS];
-#define CACHE_CHUNK 5
-
/* --- functions --- */
/**
* psppire_dict_get_type:
@@ -170,6 +170,29 @@
G_TYPE_NONE,
1,
G_TYPE_INT);
+
+
+ signal [FILTER_CHANGED] =
+ g_signal_new ("filter-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);
+
+
+ signal [SPLIT_CHANGED] =
+ g_signal_new ("split-changed",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
static void
@@ -208,13 +231,27 @@
g_signal_emit (pd, signal [WEIGHT_CHANGED], 0, idx);
}
+static void
+filter_changed_callback (struct dictionary *d, int idx, void *pd)
+{
+ g_signal_emit (pd, signal [FILTER_CHANGED], 0, idx);
+}
+
+static void
+split_changed_callback (struct dictionary *d, void *pd)
+{
+ g_signal_emit (pd, signal [SPLIT_CHANGED], 0);
+}
+
static const struct dict_callbacks gui_callbacks =
{
addcb,
delcb,
mutcb,
- weight_changed_callback
+ weight_changed_callback,
+ filter_changed_callback,
+ split_changed_callback
};
static void