Add boolean return value for gtk_text_tag_table_add()

The user doesn't need to check the return value, because if FALSE is
returned it is a programmer error. But it permits a nicer behavior for
gtk_text_buffer_create_tag() in case of failure.

https://bugzilla.gnome.org/show_bug.cgi?id=614717
This commit is contained in:
Sébastien Wilmet 2013-04-04 13:22:38 +02:00
parent a06fc473ec
commit 68ad33cb89
2 changed files with 9 additions and 6 deletions

View File

@ -236,17 +236,19 @@ gtk_text_tag_table_buildable_add_child (GtkBuildable *buildable,
*
* @tag must not be in a tag table already, and may not have
* the same name as an already-added tag.
*
* Returns: %TRUE on success.
**/
void
gboolean
gtk_text_tag_table_add (GtkTextTagTable *table,
GtkTextTag *tag)
{
GtkTextTagTablePrivate *priv;
guint size;
g_return_if_fail (GTK_IS_TEXT_TAG_TABLE (table));
g_return_if_fail (GTK_IS_TEXT_TAG (tag));
g_return_if_fail (tag->priv->table == NULL);
g_return_val_if_fail (GTK_IS_TEXT_TAG_TABLE (table), FALSE);
g_return_val_if_fail (GTK_IS_TEXT_TAG (tag), FALSE);
g_return_val_if_fail (tag->priv->table == NULL, FALSE);
priv = table->priv;
@ -254,7 +256,7 @@ gtk_text_tag_table_add (GtkTextTagTable *table,
{
g_warning ("A tag named '%s' is already in the tag table.",
tag->priv->name);
return;
return FALSE;
}
g_object_ref (tag);
@ -277,6 +279,7 @@ gtk_text_tag_table_add (GtkTextTagTable *table,
tag->priv->priority = size - 1;
g_signal_emit (table, signals[TAG_ADDED], 0, tag);
return TRUE;
}
/**

View File

@ -73,7 +73,7 @@ GType gtk_text_tag_table_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkTextTagTable *gtk_text_tag_table_new (void);
GDK_AVAILABLE_IN_ALL
void gtk_text_tag_table_add (GtkTextTagTable *table,
gboolean gtk_text_tag_table_add (GtkTextTagTable *table,
GtkTextTag *tag);
GDK_AVAILABLE_IN_ALL
void gtk_text_tag_table_remove (GtkTextTagTable *table,