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:
@ -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
|
* @tag must not be in a tag table already, and may not have
|
||||||
* the same name as an already-added tag.
|
* the same name as an already-added tag.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE on success.
|
||||||
**/
|
**/
|
||||||
void
|
gboolean
|
||||||
gtk_text_tag_table_add (GtkTextTagTable *table,
|
gtk_text_tag_table_add (GtkTextTagTable *table,
|
||||||
GtkTextTag *tag)
|
GtkTextTag *tag)
|
||||||
{
|
{
|
||||||
GtkTextTagTablePrivate *priv;
|
GtkTextTagTablePrivate *priv;
|
||||||
guint size;
|
guint size;
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_TEXT_TAG_TABLE (table));
|
g_return_val_if_fail (GTK_IS_TEXT_TAG_TABLE (table), FALSE);
|
||||||
g_return_if_fail (GTK_IS_TEXT_TAG (tag));
|
g_return_val_if_fail (GTK_IS_TEXT_TAG (tag), FALSE);
|
||||||
g_return_if_fail (tag->priv->table == NULL);
|
g_return_val_if_fail (tag->priv->table == NULL, FALSE);
|
||||||
|
|
||||||
priv = table->priv;
|
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.",
|
g_warning ("A tag named '%s' is already in the tag table.",
|
||||||
tag->priv->name);
|
tag->priv->name);
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_ref (tag);
|
g_object_ref (tag);
|
||||||
@ -277,6 +279,7 @@ gtk_text_tag_table_add (GtkTextTagTable *table,
|
|||||||
tag->priv->priority = size - 1;
|
tag->priv->priority = size - 1;
|
||||||
|
|
||||||
g_signal_emit (table, signals[TAG_ADDED], 0, tag);
|
g_signal_emit (table, signals[TAG_ADDED], 0, tag);
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -73,7 +73,7 @@ GType gtk_text_tag_table_get_type (void) G_GNUC_CONST;
|
|||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GtkTextTagTable *gtk_text_tag_table_new (void);
|
GtkTextTagTable *gtk_text_tag_table_new (void);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
void gtk_text_tag_table_add (GtkTextTagTable *table,
|
gboolean gtk_text_tag_table_add (GtkTextTagTable *table,
|
||||||
GtkTextTag *tag);
|
GtkTextTag *tag);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
void gtk_text_tag_table_remove (GtkTextTagTable *table,
|
void gtk_text_tag_table_remove (GtkTextTagTable *table,
|
||||||
|
|||||||
Reference in New Issue
Block a user