[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 07/11] Allow dictionary 'var_deleted' callback to examine the del
From: |
Ben Pfaff |
Subject: |
[PATCH 07/11] Allow dictionary 'var_deleted' callback to examine the deleted var. |
Date: |
Sun, 15 Apr 2012 16:58:29 -0700 |
The dictionary 'var_deleted' callback is the last chance to look at
a variable as it is getting deleted from a dictionary. For some of
the information in the variable, it legitimately doesn't make any
sense to get it from the variable itself at this point, e.g. the
index into the dictionary or the case, since it no longer is in
a dictionary. But for most of it, it's reasonable to get it from
the variable itself, but the callback doesn't provide any way to
do that, because it doesn't pass in the variable, just a dictionary
index that is no longer correct.
This commit changes the 'var_deleted' interface to pass in the
variable plus the information that can no longer be obtained from
the variable itself. An upcoming change to the GUI will make use
of this.
This commit also adapts all the existing users to the new interface.
---
src/data/dictionary.c | 6 +++---
src/data/dictionary.h | 3 ++-
src/ui/gui/marshaller-list | 2 +-
src/ui/gui/psppire-data-editor.c | 11 ++++++-----
src/ui/gui/psppire-data-store.c | 6 +++---
src/ui/gui/psppire-dict.c | 9 +++++----
src/ui/gui/psppire-var-store.c | 5 +++--
7 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/src/data/dictionary.c b/src/data/dictionary.c
index b64d84a..b9efb2b 100644
--- a/src/data/dictionary.c
+++ b/src/data/dictionary.c
@@ -600,7 +600,6 @@ dict_delete_var (struct dictionary *d, struct variable *v)
{
int dict_index = var_get_dict_index (v);
const int case_index = var_get_case_index (v);
- const int width = var_get_width (v);
assert (dict_contains_var (d, v));
@@ -628,13 +627,14 @@ dict_delete_var (struct dictionary *d, struct variable *v)
/* Free memory. */
var_clear_vardict (v);
- var_destroy (v);
if ( d->changed ) d->changed (d, d->changed_data);
invalidate_proto (d);
if (d->callbacks && d->callbacks->var_deleted )
- d->callbacks->var_deleted (d, dict_index, case_index, width, d->cb_data);
+ d->callbacks->var_deleted (d, v, dict_index, case_index, d->cb_data);
+
+ var_destroy (v);
}
/* Deletes the COUNT variables listed in VARS from D. This is
diff --git a/src/data/dictionary.h b/src/data/dictionary.h
index 2a19695..d509212 100644
--- a/src/data/dictionary.h
+++ b/src/data/dictionary.h
@@ -177,7 +177,8 @@ void dict_destroy_internal_var (struct variable *);
struct dict_callbacks
{
void (*var_added) (struct dictionary *, int, void *);
- void (*var_deleted) (struct dictionary *, int, int, int, void *);
+ void (*var_deleted) (struct dictionary *, const struct variable *,
+ int dict_index, int case_index, void *);
void (*var_changed) (struct dictionary *, int, void *);
void (*var_resized) (struct dictionary *, int, int, void *);
void (*weight_changed) (struct dictionary *, int, void *);
diff --git a/src/ui/gui/marshaller-list b/src/ui/gui/marshaller-list
index cb7c911..f21c407 100644
--- a/src/ui/gui/marshaller-list
+++ b/src/ui/gui/marshaller-list
@@ -7,7 +7,7 @@ BOOLEAN:VOID
VOID:BOXED,BOXED
VOID:INT,INT
VOID:INT,LONG
-VOID:INT,INT,INT
VOID:INT,INT,INT,INT
VOID:INT,POINTER
VOID:OBJECT,OBJECT
+VOID:POINTER,INT,INT
diff --git a/src/ui/gui/psppire-data-editor.c b/src/ui/gui/psppire-data-editor.c
index 6f1c0af..16b1393 100644
--- a/src/ui/gui/psppire-data-editor.c
+++ b/src/ui/gui/psppire-data-editor.c
@@ -1,5 +1,5 @@
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2009, 2010, 2011, 2012 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 published by
@@ -337,17 +337,18 @@ insert_variable_callback (PsppireDict *dict, gint x,
gpointer data)
static void
-delete_variable_callback (PsppireDict *dict, gint posn,
- gint x UNUSED, gint y UNUSED, gpointer data)
+delete_variable_callback (PsppireDict *dict,
+ const struct variable *var UNUSED,
+ gint dict_idx, gint case_idx UNUSED, gpointer data)
{
PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (data);
PsppireAxis *var_vaxis;
g_object_get (de->var_sheet, "vertical-axis", &var_vaxis, NULL);
- psppire_axis_delete (var_vaxis, posn, 1);
+ psppire_axis_delete (var_vaxis, dict_idx, 1);
- psppire_axis_delete (de->haxis, posn, 1);
+ psppire_axis_delete (de->haxis, dict_idx, 1);
}
diff --git a/src/ui/gui/psppire-data-store.c b/src/ui/gui/psppire-data-store.c
index 43e101e..fb89dfa 100644
--- a/src/ui/gui/psppire-data-store.c
+++ b/src/ui/gui/psppire-data-store.c
@@ -1,5 +1,5 @@
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2006, 2008, 2009, 2010 Free Software Foundation
+ Copyright (C) 2006, 2008, 2009, 2010, 2012 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
@@ -301,8 +301,8 @@ psppire_data_store_sheet_model_init (PsppireSheetModelIface
*iface)
A callback which occurs after a variable has been deleted.
*/
static void
-delete_variable_callback (GObject *obj, gint dict_index,
- gint case_index, gint width,
+delete_variable_callback (GObject *obj, const struct variable *var UNUSED,
+ gint dict_index, gint case_index,
gpointer data)
{
PsppireDataStore *store = PSPPIRE_DATA_STORE (data);
diff --git a/src/ui/gui/psppire-dict.c b/src/ui/gui/psppire-dict.c
index e731b18..ea67c85 100644
--- a/src/ui/gui/psppire-dict.c
+++ b/src/ui/gui/psppire-dict.c
@@ -159,10 +159,10 @@ psppire_dict_class_init (PsppireDictClass *class)
G_SIGNAL_RUN_FIRST,
0,
NULL, NULL,
- psppire_marshal_VOID__INT_INT_INT,
+ psppire_marshal_VOID__POINTER_INT_INT,
G_TYPE_NONE,
3,
- G_TYPE_INT,
+ G_TYPE_POINTER,
G_TYPE_INT,
G_TYPE_INT);
@@ -248,10 +248,11 @@ addcb (struct dictionary *d, int idx, void *pd)
}
static void
-delcb (struct dictionary *d, int dict_idx, int case_idx, int width, void *pd)
+delcb (struct dictionary *d, const struct variable *var,
+ int dict_idx, int case_idx, void *pd)
{
g_signal_emit (pd, signals [VARIABLE_DELETED], 0,
- dict_idx, case_idx, width );
+ var, dict_idx, case_idx);
}
static void
diff --git a/src/ui/gui/psppire-var-store.c b/src/ui/gui/psppire-var-store.c
index f924c17..bc348ef 100644
--- a/src/ui/gui/psppire-var-store.c
+++ b/src/ui/gui/psppire-var-store.c
@@ -1,5 +1,5 @@
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2006, 2009, 2010, 2011 Free Software Foundation
+ Copyright (C) 2006, 2009, 2010, 2011, 2012 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
@@ -52,7 +52,8 @@ var_change_callback (GtkWidget *w, gint n, gpointer data)
static void
-var_delete_callback (GtkWidget *w, gint dict_idx, gint case_idx, gint val_cnt,
gpointer data)
+var_delete_callback (GtkWidget *w, const struct variable *var UNUSED,
+ gint dict_idx, gint case_idx UNUSED, gpointer data)
{
PsppireSheetModel *model = PSPPIRE_SHEET_MODEL (data);
--
1.7.2.5
- [PATCH 00/11] first batch of psppsheet changes, Ben Pfaff, 2012/04/15
- [PATCH 01/11] psppire-data-editor: Drop psppire_data_editor_set_font() redundancy., Ben Pfaff, 2012/04/15
- [PATCH 04/11] psppire-buttonbox: Fix style in header file., Ben Pfaff, 2012/04/15
- [PATCH 03/11] psppire-data-store: Use NULL for a null pointer., Ben Pfaff, 2012/04/15
- [PATCH 02/11] psppire-data-store: Use PSPPIRE namespace instead of GTK+'s., Ben Pfaff, 2012/04/15
- [PATCH 06/11] find-dialog: Change "Cancel" button to "Close" button., Ben Pfaff, 2012/04/15
- [PATCH 05/11] gtkxpaned: Remove write-only variables., Ben Pfaff, 2012/04/15
- [PATCH 08/11] psppire-dict: Get rid of static var in auto_generate_var_name()., Ben Pfaff, 2012/04/15
- [PATCH 07/11] Allow dictionary 'var_deleted' callback to examine the deleted var.,
Ben Pfaff <=
- [PATCH 09/11] psppire-dict: Make auto_generate_var_name() public, and rename., Ben Pfaff, 2012/04/15
- [PATCH 10/11] psppire-dict: Return new var from psppire_dict_insert_variable()., Ben Pfaff, 2012/04/15
- [PATCH 11/11] psppire-dict: Better validate idx arg in psppire_dict_get_variable()., Ben Pfaff, 2012/04/15
- Re: [PATCH 00/11] first batch of psppsheet changes, John Darrington, 2012/04/16