[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 10/11] psppire-dict: Return new var from psppire_dict_insert_vari
From: |
Ben Pfaff |
Subject: |
[PATCH 10/11] psppire-dict: Return new var from psppire_dict_insert_variable(). |
Date: |
Sun, 15 Apr 2012 16:58:32 -0700 |
An upcoming commit will introduce a user for the return value.
---
src/ui/gui/psppire-dict.c | 19 +++++++++++--------
src/ui/gui/psppire-dict.h | 3 ++-
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/ui/gui/psppire-dict.c b/src/ui/gui/psppire-dict.c
index 1e8beac..04bd3e3 100644
--- a/src/ui/gui/psppire-dict.c
+++ b/src/ui/gui/psppire-dict.c
@@ -379,23 +379,24 @@ psppire_dict_generate_name (const PsppireDict *dict, char
*name, size_t size)
return name;
}
-/* Insert a new variable at posn IDX, with the name NAME.
+/* Insert a new variable at posn IDX, with the name NAME, and return the
+ new variable.
If NAME is null, then a name will be automatically assigned.
*/
-void
+struct variable *
psppire_dict_insert_variable (PsppireDict *d, gint idx, const gchar *name)
{
- struct variable *var ;
+ struct variable *var;
char tmpname[64];
- g_return_if_fail (idx >= 0);
- g_return_if_fail (d);
- g_return_if_fail (PSPPIRE_IS_DICT (d));
+ g_return_val_if_fail (idx >= 0, NULL);
+ g_return_val_if_fail (d, NULL);
+ g_return_val_if_fail (PSPPIRE_IS_DICT (d), NULL);
- if ( ! name )
+ if (name == NULL)
{
if (!psppire_dict_generate_name (d, tmpname, sizeof tmpname))
- g_return_if_reached ();
+ g_return_val_if_reached (NULL);
name = tmpname;
}
@@ -409,6 +410,8 @@ psppire_dict_insert_variable (PsppireDict *d, gint idx,
const gchar *name)
d->disable_insert_signal = FALSE;
g_signal_emit (d, signals[VARIABLE_INSERTED], 0, idx);
+
+ return var;
}
/* Delete N variables beginning at FIRST */
diff --git a/src/ui/gui/psppire-dict.h b/src/ui/gui/psppire-dict.h
index 53b09f4..4deabca 100644
--- a/src/ui/gui/psppire-dict.h
+++ b/src/ui/gui/psppire-dict.h
@@ -90,7 +90,8 @@ struct variable * psppire_dict_get_variable (const
PsppireDict *d, gint idx);
void psppire_dict_delete_variables (PsppireDict *d, gint first, gint n);
/* Insert a new variable at posn IDX */
-void psppire_dict_insert_variable (PsppireDict *d, gint idx, const gchar
*name);
+struct variable *psppire_dict_insert_variable (PsppireDict *d, gint idx,
+ const gchar *name);
void psppire_dict_resize_variable (PsppireDict *,
const struct variable *,
--
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, 2012/04/15
- [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 <=
- [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