|
Packit Service |
fb6fa5 |
/* GTK - The GIMP Toolkit
|
|
Packit Service |
fb6fa5 |
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* This library is free software; you can redistribute it and/or
|
|
Packit Service |
fb6fa5 |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
fb6fa5 |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
fb6fa5 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* This library is distributed in the hope that it will be useful,
|
|
Packit Service |
fb6fa5 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
fb6fa5 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
fb6fa5 |
* Lesser General Public License for more details.
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
fb6fa5 |
* License along with this library; if not, write to the
|
|
Packit Service |
fb6fa5 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
Packit Service |
fb6fa5 |
* Boston, MA 02111-1307, USA.
|
|
Packit Service |
fb6fa5 |
*/
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/*
|
|
Packit Service |
fb6fa5 |
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
|
Packit Service |
fb6fa5 |
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
Packit Service |
fb6fa5 |
* files for a list of changes. These files are distributed with
|
|
Packit Service |
fb6fa5 |
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
Packit Service |
fb6fa5 |
*/
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
#include "config.h"
|
|
Packit Service |
fb6fa5 |
#include "gtktexttagtable.h"
|
|
Packit Service |
fb6fa5 |
#include "gtkbuildable.h"
|
|
Packit Service |
fb6fa5 |
#include "gtkmarshalers.h"
|
|
Packit Service |
fb6fa5 |
#include "gtktextbuffer.h" /* just for the lame notify_will_remove_tag hack */
|
|
Packit Service |
fb6fa5 |
#include "gtkintl.h"
|
|
Packit Service |
fb6fa5 |
#include "gtkalias.h"
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
#include <stdlib.h>
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/**
|
|
Packit Service |
fb6fa5 |
* SECTION:gtktexttagtable
|
|
Packit Service |
fb6fa5 |
* @Short_description: Collection of tags that can be used together
|
|
Packit Service |
fb6fa5 |
* @Title: GtkTextTagTable
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* You may wish to begin by reading the <link linkend="TextWidget">text widget
|
|
Packit Service |
fb6fa5 |
* conceptual overview</link> which gives an overview of all the objects and data
|
|
Packit Service |
fb6fa5 |
* types related to the text widget and how they work together.
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* <refsect2 id="GtkTextTagTable-BUILDER-UI">
|
|
Packit Service |
fb6fa5 |
* <title>GtkTextTagTables as GtkBuildable</title>
|
|
Packit Service |
fb6fa5 |
* <para>
|
|
Packit Service |
fb6fa5 |
* The GtkTextTagTable implementation of the GtkBuildable interface
|
|
Packit Service |
fb6fa5 |
* supports adding tags by specifying "tag" as the "type"
|
|
Packit Service |
fb6fa5 |
* attribute of a <child> element.
|
|
Packit Service |
fb6fa5 |
* </para>
|
|
Packit Service |
fb6fa5 |
* <example>
|
|
Packit Service |
fb6fa5 |
* <title>A UI definition fragment specifying tags</title>
|
|
Packit Service |
fb6fa5 |
* <programlisting>
|
|
Packit Service |
fb6fa5 |
* <object class="GtkTextTagTable">
|
|
Packit Service |
fb6fa5 |
* <child type="tag">
|
|
Packit Service |
fb6fa5 |
* <object class="GtkTextTag"/>
|
|
Packit Service |
fb6fa5 |
* </child>
|
|
Packit Service |
fb6fa5 |
* </object>
|
|
Packit Service |
fb6fa5 |
* ]]></programlisting>
|
|
Packit Service |
fb6fa5 |
* </example>
|
|
Packit Service |
fb6fa5 |
* </refsect2>
|
|
Packit Service |
fb6fa5 |
*/
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
enum {
|
|
Packit Service |
fb6fa5 |
TAG_CHANGED,
|
|
Packit Service |
fb6fa5 |
TAG_ADDED,
|
|
Packit Service |
fb6fa5 |
TAG_REMOVED,
|
|
Packit Service |
fb6fa5 |
LAST_SIGNAL
|
|
Packit Service |
fb6fa5 |
};
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
enum {
|
|
Packit Service |
fb6fa5 |
LAST_ARG
|
|
Packit Service |
fb6fa5 |
};
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void gtk_text_tag_table_finalize (GObject *object);
|
|
Packit Service |
fb6fa5 |
static void gtk_text_tag_table_set_property (GObject *object,
|
|
Packit Service |
fb6fa5 |
guint prop_id,
|
|
Packit Service |
fb6fa5 |
const GValue *value,
|
|
Packit Service |
fb6fa5 |
GParamSpec *pspec);
|
|
Packit Service |
fb6fa5 |
static void gtk_text_tag_table_get_property (GObject *object,
|
|
Packit Service |
fb6fa5 |
guint prop_id,
|
|
Packit Service |
fb6fa5 |
GValue *value,
|
|
Packit Service |
fb6fa5 |
GParamSpec *pspec);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void gtk_text_tag_table_buildable_interface_init (GtkBuildableIface *iface);
|
|
Packit Service |
fb6fa5 |
static void gtk_text_tag_table_buildable_add_child (GtkBuildable *buildable,
|
|
Packit Service |
fb6fa5 |
GtkBuilder *builder,
|
|
Packit Service |
fb6fa5 |
GObject *child,
|
|
Packit Service |
fb6fa5 |
const gchar *type);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static guint signals[LAST_SIGNAL] = { 0 };
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
G_DEFINE_TYPE_WITH_CODE (GtkTextTagTable, gtk_text_tag_table, G_TYPE_OBJECT,
|
|
Packit Service |
fb6fa5 |
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
|
Packit Service |
fb6fa5 |
gtk_text_tag_table_buildable_interface_init))
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
gtk_text_tag_table_class_init (GtkTextTagTableClass *klass)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
object_class->set_property = gtk_text_tag_table_set_property;
|
|
Packit Service |
fb6fa5 |
object_class->get_property = gtk_text_tag_table_get_property;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
object_class->finalize = gtk_text_tag_table_finalize;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
signals[TAG_CHANGED] =
|
|
Packit Service |
fb6fa5 |
g_signal_new (I_("tag-changed"),
|
|
Packit Service |
fb6fa5 |
G_OBJECT_CLASS_TYPE (object_class),
|
|
Packit Service |
fb6fa5 |
G_SIGNAL_RUN_LAST,
|
|
Packit Service |
fb6fa5 |
G_STRUCT_OFFSET (GtkTextTagTableClass, tag_changed),
|
|
Packit Service |
fb6fa5 |
NULL, NULL,
|
|
Packit Service |
fb6fa5 |
_gtk_marshal_VOID__OBJECT_BOOLEAN,
|
|
Packit Service |
fb6fa5 |
G_TYPE_NONE,
|
|
Packit Service |
fb6fa5 |
2,
|
|
Packit Service |
fb6fa5 |
GTK_TYPE_TEXT_TAG,
|
|
Packit Service |
fb6fa5 |
G_TYPE_BOOLEAN);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
signals[TAG_ADDED] =
|
|
Packit Service |
fb6fa5 |
g_signal_new (I_("tag-added"),
|
|
Packit Service |
fb6fa5 |
G_OBJECT_CLASS_TYPE (object_class),
|
|
Packit Service |
fb6fa5 |
G_SIGNAL_RUN_LAST,
|
|
Packit Service |
fb6fa5 |
G_STRUCT_OFFSET (GtkTextTagTableClass, tag_added),
|
|
Packit Service |
fb6fa5 |
NULL, NULL,
|
|
Packit Service |
fb6fa5 |
_gtk_marshal_VOID__OBJECT,
|
|
Packit Service |
fb6fa5 |
G_TYPE_NONE,
|
|
Packit Service |
fb6fa5 |
1,
|
|
Packit Service |
fb6fa5 |
GTK_TYPE_TEXT_TAG);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
signals[TAG_REMOVED] =
|
|
Packit Service |
fb6fa5 |
g_signal_new (I_("tag-removed"),
|
|
Packit Service |
fb6fa5 |
G_OBJECT_CLASS_TYPE (object_class),
|
|
Packit Service |
fb6fa5 |
G_SIGNAL_RUN_LAST,
|
|
Packit Service |
fb6fa5 |
G_STRUCT_OFFSET (GtkTextTagTableClass, tag_removed),
|
|
Packit Service |
fb6fa5 |
NULL, NULL,
|
|
Packit Service |
fb6fa5 |
_gtk_marshal_VOID__OBJECT,
|
|
Packit Service |
fb6fa5 |
G_TYPE_NONE,
|
|
Packit Service |
fb6fa5 |
1,
|
|
Packit Service |
fb6fa5 |
GTK_TYPE_TEXT_TAG);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
gtk_text_tag_table_init (GtkTextTagTable *table)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
table->hash = g_hash_table_new (g_str_hash, g_str_equal);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/**
|
|
Packit Service |
fb6fa5 |
* gtk_text_tag_table_new:
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* Creates a new #GtkTextTagTable. The table contains no tags by
|
|
Packit Service |
fb6fa5 |
* default.
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* Return value: a new #GtkTextTagTable
|
|
Packit Service |
fb6fa5 |
**/
|
|
Packit Service |
fb6fa5 |
GtkTextTagTable*
|
|
Packit Service |
fb6fa5 |
gtk_text_tag_table_new (void)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GtkTextTagTable *table;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
table = g_object_new (GTK_TYPE_TEXT_TAG_TABLE, NULL);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
return table;
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
foreach_unref (GtkTextTag *tag, gpointer data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GSList *tmp;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* We don't want to emit the remove signal here; so we just unparent
|
|
Packit Service |
fb6fa5 |
* and unref the tag.
|
|
Packit Service |
fb6fa5 |
*/
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
tmp = tag->table->buffers;
|
|
Packit Service |
fb6fa5 |
while (tmp != NULL)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
_gtk_text_buffer_notify_will_remove_tag (GTK_TEXT_BUFFER (tmp->data),
|
|
Packit Service |
fb6fa5 |
tag);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
tmp = tmp->next;
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
tag->table = NULL;
|
|
Packit Service |
fb6fa5 |
g_object_unref (tag);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
gtk_text_tag_table_finalize (GObject *object)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GtkTextTagTable *table;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
table = GTK_TEXT_TAG_TABLE (object);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_text_tag_table_foreach (table, foreach_unref, NULL);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_hash_table_destroy (table->hash);
|
|
Packit Service |
fb6fa5 |
g_slist_free (table->anonymous);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_slist_free (table->buffers);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
G_OBJECT_CLASS (gtk_text_tag_table_parent_class)->finalize (object);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
gtk_text_tag_table_set_property (GObject *object,
|
|
Packit Service |
fb6fa5 |
guint prop_id,
|
|
Packit Service |
fb6fa5 |
const GValue *value,
|
|
Packit Service |
fb6fa5 |
GParamSpec *pspec)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
switch (prop_id)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
default:
|
|
Packit Service |
fb6fa5 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
Packit Service |
fb6fa5 |
break;
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
gtk_text_tag_table_get_property (GObject *object,
|
|
Packit Service |
fb6fa5 |
guint prop_id,
|
|
Packit Service |
fb6fa5 |
GValue *value,
|
|
Packit Service |
fb6fa5 |
GParamSpec *pspec)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
switch (prop_id)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
default:
|
|
Packit Service |
fb6fa5 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
Packit Service |
fb6fa5 |
break;
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
gtk_text_tag_table_buildable_interface_init (GtkBuildableIface *iface)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
iface->add_child = gtk_text_tag_table_buildable_add_child;
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
gtk_text_tag_table_buildable_add_child (GtkBuildable *buildable,
|
|
Packit Service |
fb6fa5 |
GtkBuilder *builder,
|
|
Packit Service |
fb6fa5 |
GObject *child,
|
|
Packit Service |
fb6fa5 |
const gchar *type)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
if (type && strcmp (type, "tag") == 0)
|
|
Packit Service |
fb6fa5 |
gtk_text_tag_table_add (GTK_TEXT_TAG_TABLE (buildable),
|
|
Packit Service |
fb6fa5 |
GTK_TEXT_TAG (child));
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/**
|
|
Packit Service |
fb6fa5 |
* gtk_text_tag_table_add:
|
|
Packit Service |
fb6fa5 |
* @table: a #GtkTextTagTable
|
|
Packit Service |
fb6fa5 |
* @tag: a #GtkTextTag
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* Add a tag to the table. The tag is assigned the highest priority
|
|
Packit Service |
fb6fa5 |
* in the table.
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* @tag must not be in a tag table already, and may not have
|
|
Packit Service |
fb6fa5 |
* the same name as an already-added tag.
|
|
Packit Service |
fb6fa5 |
**/
|
|
Packit Service |
fb6fa5 |
void
|
|
Packit Service |
fb6fa5 |
gtk_text_tag_table_add (GtkTextTagTable *table,
|
|
Packit Service |
fb6fa5 |
GtkTextTag *tag)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
guint size;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_return_if_fail (GTK_IS_TEXT_TAG_TABLE (table));
|
|
Packit Service |
fb6fa5 |
g_return_if_fail (GTK_IS_TEXT_TAG (tag));
|
|
Packit Service |
fb6fa5 |
g_return_if_fail (tag->table == NULL);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
if (tag->name && g_hash_table_lookup (table->hash, tag->name))
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
g_warning ("A tag named '%s' is already in the tag table.",
|
|
Packit Service |
fb6fa5 |
tag->name);
|
|
Packit Service |
fb6fa5 |
return;
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_object_ref (tag);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
if (tag->name)
|
|
Packit Service |
fb6fa5 |
g_hash_table_insert (table->hash, tag->name, tag);
|
|
Packit Service |
fb6fa5 |
else
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
table->anonymous = g_slist_prepend (table->anonymous, tag);
|
|
Packit Service |
fb6fa5 |
table->anon_count += 1;
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
tag->table = table;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* We get the highest tag priority, as the most-recently-added
|
|
Packit Service |
fb6fa5 |
tag. Note that we do NOT use gtk_text_tag_set_priority,
|
|
Packit Service |
fb6fa5 |
as it assumes the tag is already in the table. */
|
|
Packit Service |
fb6fa5 |
size = gtk_text_tag_table_get_size (table);
|
|
Packit Service |
fb6fa5 |
g_assert (size > 0);
|
|
Packit Service |
fb6fa5 |
tag->priority = size - 1;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_signal_emit (table, signals[TAG_ADDED], 0, tag);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/**
|
|
Packit Service |
fb6fa5 |
* gtk_text_tag_table_lookup:
|
|
Packit Service |
fb6fa5 |
* @table: a #GtkTextTagTable
|
|
Packit Service |
fb6fa5 |
* @name: name of a tag
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* Look up a named tag.
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* Return value: (transfer none): The tag, or %NULL if none by that name is in the table.
|
|
Packit Service |
fb6fa5 |
**/
|
|
Packit Service |
fb6fa5 |
GtkTextTag*
|
|
Packit Service |
fb6fa5 |
gtk_text_tag_table_lookup (GtkTextTagTable *table,
|
|
Packit Service |
fb6fa5 |
const gchar *name)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
g_return_val_if_fail (GTK_IS_TEXT_TAG_TABLE (table), NULL);
|
|
Packit Service |
fb6fa5 |
g_return_val_if_fail (name != NULL, NULL);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
return g_hash_table_lookup (table->hash, name);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/**
|
|
Packit Service |
fb6fa5 |
* gtk_text_tag_table_remove:
|
|
Packit Service |
fb6fa5 |
* @table: a #GtkTextTagTable
|
|
Packit Service |
fb6fa5 |
* @tag: a #GtkTextTag
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* Remove a tag from the table. This will remove the table's
|
|
Packit Service |
fb6fa5 |
* reference to the tag, so be careful - the tag will end
|
|
Packit Service |
fb6fa5 |
* up destroyed if you don't have a reference to it.
|
|
Packit Service |
fb6fa5 |
**/
|
|
Packit Service |
fb6fa5 |
void
|
|
Packit Service |
fb6fa5 |
gtk_text_tag_table_remove (GtkTextTagTable *table,
|
|
Packit Service |
fb6fa5 |
GtkTextTag *tag)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GSList *tmp;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_return_if_fail (GTK_IS_TEXT_TAG_TABLE (table));
|
|
Packit Service |
fb6fa5 |
g_return_if_fail (GTK_IS_TEXT_TAG (tag));
|
|
Packit Service |
fb6fa5 |
g_return_if_fail (tag->table == table);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* Our little bad hack to be sure buffers don't still have the tag
|
|
Packit Service |
fb6fa5 |
* applied to text in the buffer
|
|
Packit Service |
fb6fa5 |
*/
|
|
Packit Service |
fb6fa5 |
tmp = table->buffers;
|
|
Packit Service |
fb6fa5 |
while (tmp != NULL)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
_gtk_text_buffer_notify_will_remove_tag (GTK_TEXT_BUFFER (tmp->data),
|
|
Packit Service |
fb6fa5 |
tag);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
tmp = tmp->next;
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* Set ourselves to the highest priority; this means
|
|
Packit Service |
fb6fa5 |
when we're removed, there won't be any gaps in the
|
|
Packit Service |
fb6fa5 |
priorities of the tags in the table. */
|
|
Packit Service |
fb6fa5 |
gtk_text_tag_set_priority (tag, gtk_text_tag_table_get_size (table) - 1);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
tag->table = NULL;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
if (tag->name)
|
|
Packit Service |
fb6fa5 |
g_hash_table_remove (table->hash, tag->name);
|
|
Packit Service |
fb6fa5 |
else
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
table->anonymous = g_slist_remove (table->anonymous, tag);
|
|
Packit Service |
fb6fa5 |
table->anon_count -= 1;
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_signal_emit (table, signals[TAG_REMOVED], 0, tag);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_object_unref (tag);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
struct ForeachData
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GtkTextTagTableForeach func;
|
|
Packit Service |
fb6fa5 |
gpointer data;
|
|
Packit Service |
fb6fa5 |
};
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
hash_foreach (gpointer key, gpointer value, gpointer data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
struct ForeachData *fd = data;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_return_if_fail (GTK_IS_TEXT_TAG (value));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
(* fd->func) (value, fd->data);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_foreach (gpointer data, gpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
struct ForeachData *fd = user_data;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_return_if_fail (GTK_IS_TEXT_TAG (data));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
(* fd->func) (data, fd->data);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/**
|
|
Packit Service |
fb6fa5 |
* gtk_text_tag_table_foreach:
|
|
Packit Service |
fb6fa5 |
* @table: a #GtkTextTagTable
|
|
Packit Service |
fb6fa5 |
* @func: (scope call): a function to call on each tag
|
|
Packit Service |
fb6fa5 |
* @data: user data
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* Calls @func on each tag in @table, with user data @data.
|
|
Packit Service |
fb6fa5 |
* Note that the table may not be modified while iterating
|
|
Packit Service |
fb6fa5 |
* over it (you can't add/remove tags).
|
|
Packit Service |
fb6fa5 |
**/
|
|
Packit Service |
fb6fa5 |
void
|
|
Packit Service |
fb6fa5 |
gtk_text_tag_table_foreach (GtkTextTagTable *table,
|
|
Packit Service |
fb6fa5 |
GtkTextTagTableForeach func,
|
|
Packit Service |
fb6fa5 |
gpointer data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
struct ForeachData d;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_return_if_fail (GTK_IS_TEXT_TAG_TABLE (table));
|
|
Packit Service |
fb6fa5 |
g_return_if_fail (func != NULL);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
d.func = func;
|
|
Packit Service |
fb6fa5 |
d.data = data;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_hash_table_foreach (table->hash, hash_foreach, &d);
|
|
Packit Service |
fb6fa5 |
g_slist_foreach (table->anonymous, list_foreach, &d);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/**
|
|
Packit Service |
fb6fa5 |
* gtk_text_tag_table_get_size:
|
|
Packit Service |
fb6fa5 |
* @table: a #GtkTextTagTable
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* Returns the size of the table (number of tags)
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* Return value: number of tags in @table
|
|
Packit Service |
fb6fa5 |
**/
|
|
Packit Service |
fb6fa5 |
gint
|
|
Packit Service |
fb6fa5 |
gtk_text_tag_table_get_size (GtkTextTagTable *table)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
g_return_val_if_fail (GTK_IS_TEXT_TAG_TABLE (table), 0);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
return g_hash_table_size (table->hash) + table->anon_count;
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
void
|
|
Packit Service |
fb6fa5 |
_gtk_text_tag_table_add_buffer (GtkTextTagTable *table,
|
|
Packit Service |
fb6fa5 |
gpointer buffer)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
g_return_if_fail (GTK_IS_TEXT_TAG_TABLE (table));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
table->buffers = g_slist_prepend (table->buffers, buffer);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
foreach_remove_tag (GtkTextTag *tag, gpointer data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GtkTextBuffer *buffer;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
buffer = GTK_TEXT_BUFFER (data);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
_gtk_text_buffer_notify_will_remove_tag (buffer, tag);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
void
|
|
Packit Service |
fb6fa5 |
_gtk_text_tag_table_remove_buffer (GtkTextTagTable *table,
|
|
Packit Service |
fb6fa5 |
gpointer buffer)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
g_return_if_fail (GTK_IS_TEXT_TAG_TABLE (table));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_text_tag_table_foreach (table, foreach_remove_tag, buffer);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
table->buffers = g_slist_remove (table->buffers, buffer);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
#define __GTK_TEXT_TAG_TABLE_C__
|
|
Packit Service |
fb6fa5 |
#include "gtkaliasdef.c"
|