Class: Gtk::TextTagTable

Inherits:
Object
  • Object
show all
Defined in:
lib/gtk3/text-tag-table.rb

Overview

The collection of tags in a GtkTextBuffer

You may wish to begin by reading the text widget conceptual overview, which gives an overview of all the objects and data types related to the text widget and how they work together.

GtkTextTagTables as GtkBuildable

The GtkTextTagTable implementation of the GtkBuildable interface supports adding tags by specifying “tag” as the “type” attribute of a <child> element.

An example of a UI definition fragment specifying tags:

<object class="GtkTextTagTable">
 <child type="tag">
   <object class="GtkTextTag"/>
 </child>
</object>

Instance Method Summary collapse

Constructor Details

#initializeGtk::TextTagTable

Creates a new GtkTextTagTable.

The table contains no tags by default.

Instance Method Details

#add(tag) ⇒ Boolean

Add a tag to the table.

The tag is assigned the highest priority in the table.

tag must not be in a tag table already, and may not have the same name as an already-added tag.

Parameters:

Returns:

  • (Boolean)

    true on success.



20
21
22
23
24
25
26
27
28
29
# File 'lib/gtk3/text-tag-table.rb', line 20

def add(tag)
  succeeded = add_raw(tag)
  # GTK+ 3.12 or older returns nothing.
  # We assume that it's always succeeded for the case.
  if succeeded.nil?
    true
  else
    succeeded
  end
end

#add_rawBoolean

Add a tag to the table.

The tag is assigned the highest priority in the table.

tag must not be in a tag table already, and may not have the same name as an already-added tag.

Parameters:

Returns:

  • (Boolean)

    true on success.



# File 'lib/gtk3/text-tag-table.rb', line 19

#foreach(func, data) ⇒ nil

Calls func on each tag in table, with user data data.

Note that the table may not be modified while iterating over it (you can’t add/remove tags).

Parameters:

  • func (Gtk::TextTagTableForeach)

    a function to call on each tag

  • data (GObject)

    user data

Returns:

  • (nil)

#lookup(name) ⇒ Gtk::TextTag

Look up a named tag.

Parameters:

  • name (String)

    name of a tag

Returns:

#remove(tag) ⇒ nil

Remove a tag from the table.

If a GtkTextBuffer has table as its tag table, the tag is removed from the buffer. The table’s reference to the tag is removed, so the tag will end up destroyed if you don’t have a reference to it.

Parameters:

Returns:

  • (nil)

#sizeInteger

Returns the size of the table (number of tags)

Returns:

  • (Integer)

    number of tags in table