Gtk.Combo_Box_Text

Entities

Tagged Types

Access Types

Subprograms

Generic Instantiations

Description

A GtkComboBoxText is a simple variant of Gtk.Combo_Box.Gtk_Combo_Box that hides the model-view complexity for simple text-only use cases.

To create a GtkComboBoxText, use Gtk.Combo_Box_Text.Gtk_New or Gtk.Combo_Box_Text.Gtk_New_With_Entry.

You can add items to a GtkComboBoxText with Gtk.Combo_Box_Text.Append_Text, Gtk.Combo_Box_Text.Insert_Text or Gtk.Combo_Box_Text.Prepend_Text and remove options with Gtk.Combo_Box_Text.Remove.

If the GtkComboBoxText contains an entry (via the "has-entry" property), its contents can be retrieved using Gtk.Combo_Box_Text.Get_Active_Text. The entry itself can be accessed by calling Gtk.Bin.Get_Child on the combo box.

You should not call Gtk.Combo_Box.Set_Model or attempt to pack more cells into this combo box via its GtkCellLayout interface.

# GtkComboBoxText as GtkBuildable

The GtkComboBoxText implementation of the GtkBuildable interface supports adding items directly using the <items> element and specifying <item> elements for each item. Each <item> element can specify the "id" corresponding to the appended text and also supports the regular translation attributes "translatable", "context" and "comments".

Here is a UI definition fragment specifying GtkComboBoxText items:

<object class="GtkComboBoxText">
  <items>
    <item translatable="yes" id="factory">Factory</item>
    <item translatable="yes" id="home">Home</item>
    <item translatable="yes" id="subway">Subway</item>
  </items>
</object>

# CSS nodes

combobox
╰── box.linked
    ├── entry.combo
    ├── button.combo
    ╰── window.popup

GtkComboBoxText has a single CSS node with name combobox. It adds the style class .combo to the main CSS nodes of its entry and button children, and the .linked class to the node of its internal box.

<group>Numeric/Text Data Entry</group>

"+"

function "+"
  (Widget : access Gtk_Combo_Box_Text_Record'Class)
return Gtk.Buildable.Gtk_Buildable
Parameters
Widget
Return Value

"+"

function "+"
  (Widget : access Gtk_Combo_Box_Text_Record'Class)
return Gtk.Cell_Editable.Gtk_Cell_Editable
Parameters
Widget
Return Value

"+"

function "+"
  (Widget : access Gtk_Combo_Box_Text_Record'Class)
return Gtk.Cell_Layout.Gtk_Cell_Layout
Parameters
Widget
Return Value

"-"

function "-"
  (Interf : Gtk.Buildable.Gtk_Buildable)
return Gtk_Combo_Box_Text
Parameters
Interf
Return Value

"-"

function "-"
  (Interf : Gtk.Cell_Editable.Gtk_Cell_Editable)
return Gtk_Combo_Box_Text
Parameters
Interf
Return Value

"-"

function "-"
  (Interf : Gtk.Cell_Layout.Gtk_Cell_Layout)
return Gtk_Combo_Box_Text
Parameters
Interf
Return Value

Add_Attribute

procedure Add_Attribute
   (Cell_Layout : not null access Gtk_Combo_Box_Text_Record;
    Cell        : not null access Gtk.Cell_Renderer.Gtk_Cell_Renderer_Record'Class;
    Attribute   : UTF8_String;
    Column      : Glib.Gint)
Parameters
Cell_Layout
Cell
Attribute
Column

Append

procedure Append
   (Self : not null access Gtk_Combo_Box_Text_Record;
    Id   : UTF8_String := "";
    Text : UTF8_String)

Appends Text to the list of strings stored in Combo_Box. If Id is non-null then it is used as the ID of the row. This is the same as calling Gtk.Combo_Box_Text.Insert with a position of -1. Since: gtk+ 2.24

Parameters
Self
Id

a string ID for this value, or null

Text

A string

Append_Text

procedure Append_Text
   (Self : not null access Gtk_Combo_Box_Text_Record;
    Text : UTF8_String)

Appends Text to the list of strings stored in Combo_Box. This is the same as calling Gtk.Combo_Box_Text.Insert_Text with a position of -1. Since: gtk+ 2.24

Parameters
Self
Text

A string

Clear

procedure Clear (Cell_Layout : not null access Gtk_Combo_Box_Text_Record)
Parameters
Cell_Layout

Clear_Attributes

procedure Clear_Attributes
   (Cell_Layout : not null access Gtk_Combo_Box_Text_Record;
    Cell        : not null access Gtk.Cell_Renderer.Gtk_Cell_Renderer_Record'Class)
Parameters
Cell_Layout
Cell

Editing_Done

procedure Editing_Done
   (Cell_Editable : not null access Gtk_Combo_Box_Text_Record)
Parameters
Cell_Editable

Get_Active_Text

function Get_Active_Text
   (Self : not null access Gtk_Combo_Box_Text_Record) return UTF8_String

Returns the currently active string in Combo_Box, or null if none is selected. If Combo_Box contains an entry, this function will return its contents (which will not necessarily be an item from the list). Since: gtk+ 2.24

Parameters
Self
Return Value

a newly allocated string containing the currently active text. Must be freed with g_free.

Get_Cells

function Get_Cells
   (Cell_Layout : not null access Gtk_Combo_Box_Text_Record)
    return Gtk.Cell_Renderer.Cell_Renderer_List.Glist
Parameters
Cell_Layout
Return Value

Get_Type

function Get_Type return Glib.GType
Return Value

Gtk_Cell_Layout_Data_Func

type Gtk_Cell_Layout_Data_Func is access procedure
  (Cell_Layout : Gtk.Cell_Layout.Gtk_Cell_Layout;
   Cell        : not null access Gtk.Cell_Renderer.Gtk_Cell_Renderer_Record'Class;
   Tree_Model  : Gtk.Tree_Model.Gtk_Tree_Model;
   Iter        : Gtk.Tree_Model.Gtk_Tree_Iter);

A function which should set the value of Cell_Layout's cell renderer(s) as appropriate.

Parameters
Cell_Layout

a Gtk.Cell_Layout.Gtk_Cell_Layout

Cell

the cell renderer whose value is to be set

Tree_Model

the model

Iter

a Gtk.Tree_Model.Gtk_Tree_Iter indicating the row to set the value for

Gtk_Combo_Box_Text

type Gtk_Combo_Box_Text is access all Gtk_Combo_Box_Text_Record'Class;

Gtk_Combo_Box_Text_New

function Gtk_Combo_Box_Text_New return Gtk_Combo_Box_Text

Creates a new Gtk.Combo_Box_Text.Gtk_Combo_Box_Text, which is a Gtk.Combo_Box.Gtk_Combo_Box just displaying strings. Since: gtk+ 2.24

Return Value

Gtk_Combo_Box_Text_New_With_Entry

function Gtk_Combo_Box_Text_New_With_Entry return Gtk_Combo_Box_Text

Creates a new Gtk.Combo_Box_Text.Gtk_Combo_Box_Text, which is a Gtk.Combo_Box.Gtk_Combo_Box just displaying strings. The combo box created by this function has an entry. Since: gtk+ 2.24

Return Value

Gtk_Combo_Box_Text_Record

type Gtk_Combo_Box_Text_Record is new Gtk_Combo_Box_Record with null record;

Gtk_New

procedure Gtk_New (Self : out Gtk_Combo_Box_Text)

Creates a new Gtk.Combo_Box_Text.Gtk_Combo_Box_Text, which is a Gtk.Combo_Box.Gtk_Combo_Box just displaying strings. Since: gtk+ 2.24 Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Self

Gtk_New_With_Entry

procedure Gtk_New_With_Entry (Self : out Gtk_Combo_Box_Text)

Creates a new Gtk.Combo_Box_Text.Gtk_Combo_Box_Text, which is a Gtk.Combo_Box.Gtk_Combo_Box just displaying strings. The combo box created by this function has an entry. Since: gtk+ 2.24 Initialize_With_Entry does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Self

Implements_Gtk_Buildable

package Implements_Gtk_Buildable is new Glib.Types.Implements
  (Gtk.Buildable.Gtk_Buildable, Gtk_Combo_Box_Text_Record, Gtk_Combo_Box_Text);

Implements_Gtk_Cell_Editable

package Implements_Gtk_Cell_Editable is new Glib.Types.Implements
  (Gtk.Cell_Editable.Gtk_Cell_Editable, Gtk_Combo_Box_Text_Record, Gtk_Combo_Box_Text);

Implements_Gtk_Cell_Layout

package Implements_Gtk_Cell_Layout is new Glib.Types.Implements
  (Gtk.Cell_Layout.Gtk_Cell_Layout, Gtk_Combo_Box_Text_Record, Gtk_Combo_Box_Text);

Initialize

procedure Initialize
   (Self : not null access Gtk_Combo_Box_Text_Record'Class)

Creates a new Gtk.Combo_Box_Text.Gtk_Combo_Box_Text, which is a Gtk.Combo_Box.Gtk_Combo_Box just displaying strings. Since: gtk+ 2.24 Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Self

Initialize_With_Entry

procedure Initialize_With_Entry
   (Self : not null access Gtk_Combo_Box_Text_Record'Class)

Creates a new Gtk.Combo_Box_Text.Gtk_Combo_Box_Text, which is a Gtk.Combo_Box.Gtk_Combo_Box just displaying strings. The combo box created by this function has an entry. Since: gtk+ 2.24 Initialize_With_Entry does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Self

Insert

procedure Insert
   (Self     : not null access Gtk_Combo_Box_Text_Record;
    Position : Glib.Gint;
    Id       : UTF8_String := "";
    Text     : UTF8_String)

Inserts Text at Position in the list of strings stored in Combo_Box. If Id is non-null then it is used as the ID of the row. See Gtk.Combo_Box.Gtk_Combo_Box:id-column. If Position is negative then Text is appended. Since: gtk+ 3.0

Parameters
Self
Position

An index to insert Text

Id

a string ID for this value, or null

Text

A string to display

Insert_Text

procedure Insert_Text
   (Self     : not null access Gtk_Combo_Box_Text_Record;
    Position : Glib.Gint;
    Text     : UTF8_String)

Inserts Text at Position in the list of strings stored in Combo_Box. If Position is negative then Text is appended. This is the same as calling Gtk.Combo_Box_Text.Insert with a null ID string. Since: gtk+ 2.24

Parameters
Self
Position

An index to insert Text

Text

A string

Pack_End

procedure Pack_End
   (Cell_Layout : not null access Gtk_Combo_Box_Text_Record;
    Cell        : not null access Gtk.Cell_Renderer.Gtk_Cell_Renderer_Record'Class;
    Expand      : Boolean)
Parameters
Cell_Layout
Cell
Expand

Pack_Start

procedure Pack_Start
   (Cell_Layout : not null access Gtk_Combo_Box_Text_Record;
    Cell        : not null access Gtk.Cell_Renderer.Gtk_Cell_Renderer_Record'Class;
    Expand      : Boolean)
Parameters
Cell_Layout
Cell
Expand

Prepend

procedure Prepend
   (Self : not null access Gtk_Combo_Box_Text_Record;
    Id   : UTF8_String := "";
    Text : UTF8_String)

Prepends Text to the list of strings stored in Combo_Box. If Id is non-null then it is used as the ID of the row. This is the same as calling Gtk.Combo_Box_Text.Insert with a position of 0. Since: gtk+ 2.24

Parameters
Self
Id

a string ID for this value, or null

Text

a string

Prepend_Text

procedure Prepend_Text
   (Self : not null access Gtk_Combo_Box_Text_Record;
    Text : UTF8_String)

Prepends Text to the list of strings stored in Combo_Box. This is the same as calling Gtk.Combo_Box_Text.Insert_Text with a position of 0. Since: gtk+ 2.24

Parameters
Self
Text

A string

Remove

procedure Remove
   (Self     : not null access Gtk_Combo_Box_Text_Record;
    Position : Glib.Gint)

Removes the string at Position from Combo_Box. Since: gtk+ 2.24

Parameters
Self
Position

Index of the item to remove

Remove_All

procedure Remove_All (Self : not null access Gtk_Combo_Box_Text_Record)

Removes all the text entries from the combo box. Since: gtk+ 3.0

Parameters
Self

Remove_Widget

procedure Remove_Widget
   (Cell_Editable : not null access Gtk_Combo_Box_Text_Record)
Parameters
Cell_Editable

Reorder

procedure Reorder
   (Cell_Layout : not null access Gtk_Combo_Box_Text_Record;
    Cell        : not null access Gtk.Cell_Renderer.Gtk_Cell_Renderer_Record'Class;
    Position    : Glib.Gint)
Parameters
Cell_Layout
Cell
Position

Set_Cell_Data_Func

procedure Set_Cell_Data_Func
   (Cell_Layout : not null access Gtk_Combo_Box_Text_Record;
    Cell        : not null access Gtk.Cell_Renderer.Gtk_Cell_Renderer_Record'Class;
    Func        : Gtk_Cell_Layout_Data_Func)

Sets the Gtk_Cell_Layout_Data_Func to use for Cell_Layout. This function is used instead of the standard attributes mapping for setting the column value, and should set the value of Cell_Layout's cell renderer(s) as appropriate. Func may be null to remove a previously set function. Since: gtk+ 2.4

Parameters
Cell_Layout
Cell

a Gtk.Cell_Renderer.Gtk_Cell_Renderer

Func

the Gtk_Cell_Layout_Data_Func to use, or null

Start_Editing

procedure Start_Editing
   (Cell_Editable : not null access Gtk_Combo_Box_Text_Record;
    Event         : Gdk.Event.Gdk_Event)
Parameters
Cell_Editable
Event