X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-dict.c;h=312220f9de3ac23263d0e242c10bc46bef00cf5f;hb=698f289d1ecf1620aa5429599f2e76db23cff452;hp=b3a24838580ea5d45fe10a06f39408c78eefc4ce;hpb=9b55c770e627dd87c84ef64d8589a80fdf6b7431;p=pspp diff --git a/src/ui/gui/psppire-dict.c b/src/ui/gui/psppire-dict.c index b3a2483858..312220f9de 100644 --- a/src/ui/gui/psppire-dict.c +++ b/src/ui/gui/psppire-dict.c @@ -129,7 +129,7 @@ psppire_dict_class_init (PsppireDictClass *class) signals [VARIABLE_CHANGED] = - g_signal_new ("variable_changed", + g_signal_new ("variable-changed", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_FIRST, 0, @@ -142,7 +142,7 @@ psppire_dict_class_init (PsppireDictClass *class) signals [VARIABLE_INSERTED] = - g_signal_new ("variable_inserted", + g_signal_new ("variable-inserted", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_FIRST, 0, @@ -352,8 +352,8 @@ psppire_dict_replace_dictionary (PsppireDict *dict, struct dictionary *d) /* Stores a valid name for a new variable in DICT into the SIZE bytes in NAME. Returns true if successful, false if SIZE is insufficient. */ -static bool -auto_generate_var_name (const PsppireDict *dict, char *name, size_t size) +bool +psppire_dict_generate_name (const PsppireDict *dict, char *name, size_t size) { gint d; @@ -379,23 +379,24 @@ auto_generate_var_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 (!auto_generate_var_name (d, tmpname, sizeof tmpname)) - g_return_if_reached (); + if (!psppire_dict_generate_name (d, tmpname, sizeof tmpname)) + 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 */