Package ch.bailu.gtk.gtk
Class ComboBoxText
- All Implemented Interfaces:
PointerInterface
A `GtkComboBoxText` is a simple variant of `GtkComboBox` for text-only
use cases.
![An example GtkComboBoxText](combo-box-text.png)
`GtkComboBoxText` hides the model-view complexity of `GtkComboBox`.
To create a `GtkComboBoxText`, use [ctor@Gtk.ComboBoxText.new] or
[ctor@Gtk.ComboBoxText.new_with_entry].
You can add items to a `GtkComboBoxText` with
[method@Gtk.ComboBoxText.append_text],
[method@Gtk.ComboBoxText.insert_text] or
[method@Gtk.ComboBoxText.prepend_text] and remove options with
[method@Gtk.ComboBoxText.remove].
If the `GtkComboBoxText` contains an entry (via the
[property@Gtk.ComboBox:has-entry] property), its contents can be retrieved
using [method@Gtk.ComboBoxText.get_active_text].
You should not call [method@Gtk.ComboBox.set_model] or attempt to pack more
cells into this combo box via its [iface@Gtk.CellLayout] 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:
```xml
<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.
use cases.
![An example GtkComboBoxText](combo-box-text.png)
`GtkComboBoxText` hides the model-view complexity of `GtkComboBox`.
To create a `GtkComboBoxText`, use [ctor@Gtk.ComboBoxText.new] or
[ctor@Gtk.ComboBoxText.new_with_entry].
You can add items to a `GtkComboBoxText` with
[method@Gtk.ComboBoxText.append_text],
[method@Gtk.ComboBoxText.insert_text] or
[method@Gtk.ComboBoxText.prepend_text] and remove options with
[method@Gtk.ComboBoxText.remove].
If the `GtkComboBoxText` contains an entry (via the
[property@Gtk.ComboBox:has-entry] property), its contents can be retrieved
using [method@Gtk.ComboBoxText.get_active_text].
You should not call [method@Gtk.ComboBox.set_model] or attempt to pack more
cells into this combo box via its [iface@Gtk.CellLayout] 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:
```xml
<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.
-
Nested Class Summary
Nested classes/interfaces inherited from class ch.bailu.gtk.gtk.ComboBox
ComboBox.OnActivate, ComboBox.OnChanged, ComboBox.OnDestroyNotify, ComboBox.OnFormatEntryText, ComboBox.OnMoveActive, ComboBox.OnPopdown, ComboBox.OnPopup, ComboBox.OnTreeViewRowSeparatorFunc
Nested classes/interfaces inherited from class ch.bailu.gtk.gtk.Widget
Widget.OnDestroy, Widget.OnDirectionChanged, Widget.OnHide, Widget.OnKeynavFailed, Widget.OnMap, Widget.OnMnemonicActivate, Widget.OnMoveFocus, Widget.OnQueryTooltip, Widget.OnRealize, Widget.OnShow, Widget.OnStateFlagsChanged, Widget.OnTickCallback, Widget.OnUnmap, Widget.OnUnrealize
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gtk.ComboBox
SIGNAL_ON_ACTIVATE, SIGNAL_ON_CHANGED, SIGNAL_ON_FORMAT_ENTRY_TEXT, SIGNAL_ON_MOVE_ACTIVE, SIGNAL_ON_POPDOWN, SIGNAL_ON_POPUP
Fields inherited from class ch.bailu.gtk.gtk.Widget
SIGNAL_ON_DESTROY, SIGNAL_ON_DIRECTION_CHANGED, SIGNAL_ON_HIDE, SIGNAL_ON_KEYNAV_FAILED, SIGNAL_ON_MAP, SIGNAL_ON_MNEMONIC_ACTIVATE, SIGNAL_ON_MOVE_FOCUS, SIGNAL_ON_QUERY_TOOLTIP, SIGNAL_ON_REALIZE, SIGNAL_ON_SHOW, SIGNAL_ON_STATE_FLAGS_CHANGED, SIGNAL_ON_UNMAP, SIGNAL_ON_UNREALIZE
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Appends @text to the list of strings stored in @combo_box.void
Appends @text to the list of strings stored in @combo_box.void
appendText
(Str text) Appends @text to the list of strings stored in @combo_box.void
appendText
(String text) Appends @text to the list of strings stored in @combo_box.Implements interfaceAccessible
.Implements interfaceBuildable
.Implements interfaceCellEditable
.Implements interfaceCellLayout
.Implements interfaceConstraintTarget
.Returns the currently active string in @combo_box.static ClassHandler
static int
static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
void
Inserts @text at @position in the list of strings stored in @combo_box.void
Inserts @text at @position in the list of strings stored in @combo_box.void
insertText
(int position, Str text) Inserts @text at @position in the list of strings stored in @combo_box.void
insertText
(int position, String text) Inserts @text at @position in the list of strings stored in @combo_box.static ComboBoxText
Creates a new `GtkComboBoxText` with an entry.void
Prepends @text to the list of strings stored in @combo_box.void
Prepends @text to the list of strings stored in @combo_box.void
prependText
(Str text) Prepends @text to the list of strings stored in @combo_box.void
prependText
(String text) Prepends @text to the list of strings stored in @combo_box.void
remove
(int position) Removes the string at @position from @combo_box.void
Removes all the text entries from the combo box.Methods inherited from class ch.bailu.gtk.gtk.ComboBox
getActive, getActiveId, getActiveIter, getButtonSensitivity, getChild, getEntryTextColumn, getHasEntry, getIdColumn, getModel, getPopupFixedWidth, newWithEntryComboBox, newWithModelAndEntryComboBox, newWithModelComboBox, onActivate, onChanged, onFormatEntryText, onMoveActive, onPopdown, onPopup, popdown, popup, popupForDevice, setActive, setActiveId, setActiveId, setActiveIter, setButtonSensitivity, setChild, setEntryTextColumn, setIdColumn, setModel, setPopupFixedWidth, setRowSeparatorFunc
Methods inherited from class ch.bailu.gtk.gtk.Widget
actionSetEnabled, actionSetEnabled, activate, activateAction, activateAction, activateActionVariant, activateActionVariant, activateDefault, addController, addCssClass, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getCanFocus, getCanTarget, getChildVisible, getClipboard, getCssClasses, getCssName, getCursor, getDefaultDirection, getDirection, getDisplay, getFirstChild, getFocusable, getFocusChild, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeCssClass, removeMnemonicLabel, removeTickCallback, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipMarkup, setTooltipText, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, snapshotChild, triggerTooltipQuery, unmap, unparent, unrealize, unsetStateFlags
Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
ComboBoxText
-
ComboBoxText
public ComboBoxText()Creates a new `GtkComboBoxText`.
-
-
Method Details
-
getClassHandler
-
newWithEntryComboBoxText
Creates a new `GtkComboBoxText` with an entry.- Returns:
- a new `GtkComboBoxText`
-
append
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 [method@Gtk.ComboBoxText.insert]
with a position of -1.- Parameters:
id
- a string ID for this valuetext
- A string
-
append
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 [method@Gtk.ComboBoxText.insert]
with a position of -1.- Parameters:
id
- a string ID for this valuetext
- A string
-
appendText
Appends @text to the list of strings stored in @combo_box.
This is the same as calling [method@Gtk.ComboBoxText.insert_text]
with a position of -1.- Parameters:
text
- A string
-
appendText
Appends @text to the list of strings stored in @combo_box.
This is the same as calling [method@Gtk.ComboBoxText.insert_text]
with a position of -1.- Parameters:
text
- A string
-
getActiveText
Returns the currently active string in @combo_box.
If no row is currently selected, %NULL is returned.
If @combo_box contains an entry, this function will
return its contents (which will not necessarily
be an item from the list).- Returns:
- a newly allocated string containing the currently active text. Must be freed with g_free().
-
insert
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 [property@Gtk.ComboBox:id-column].
If @position is negative then @text is appended.- Parameters:
position
- An index to insert @textid
- a string ID for this valuetext
- A string to display
-
insert
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 [property@Gtk.ComboBox:id-column].
If @position is negative then @text is appended.- Parameters:
position
- An index to insert @textid
- a string ID for this valuetext
- A string to display
-
insertText
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 [method@Gtk.ComboBoxText.insert]
with a %NULL ID string.- Parameters:
position
- An index to insert @texttext
- A string
-
insertText
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 [method@Gtk.ComboBoxText.insert]
with a %NULL ID string.- Parameters:
position
- An index to insert @texttext
- A string
-
prepend
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 [method@Gtk.ComboBoxText.insert]
with a position of 0.- Parameters:
id
- a string ID for this valuetext
- a string
-
prepend
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 [method@Gtk.ComboBoxText.insert]
with a position of 0.- Parameters:
id
- a string ID for this valuetext
- a string
-
prependText
Prepends @text to the list of strings stored in @combo_box.
This is the same as calling [method@Gtk.ComboBoxText.insert_text]
with a position of 0.- Parameters:
text
- A string
-
prependText
Prepends @text to the list of strings stored in @combo_box.
This is the same as calling [method@Gtk.ComboBoxText.insert_text]
with a position of 0.- Parameters:
text
- A string
-
remove
public void remove(int position) Removes the string at @position from @combo_box.- Parameters:
position
- Index of the item to remove
-
removeAll
public void removeAll()Removes all the text entries from the combo box. -
asAccessible
Implements interfaceAccessible
. Call this to get access to interface functions.- Overrides:
asAccessible
in classComboBox
- Returns:
Accessible
-
asBuildable
Implements interfaceBuildable
. Call this to get access to interface functions.- Overrides:
asBuildable
in classComboBox
- Returns:
Buildable
-
asCellEditable
Implements interfaceCellEditable
. Call this to get access to interface functions.- Overrides:
asCellEditable
in classComboBox
- Returns:
CellEditable
-
asCellLayout
Implements interfaceCellLayout
. Call this to get access to interface functions.- Overrides:
asCellLayout
in classComboBox
- Returns:
CellLayout
-
asConstraintTarget
Implements interfaceConstraintTarget
. Call this to get access to interface functions.- Overrides:
asConstraintTarget
in classComboBox
- Returns:
ConstraintTarget
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-