11.54Class GtkEntry

A single line text entry field

Class GtkEntry

The GtkEntry widget is a single line text entry widget. A fairly large set of key bindings are supported by default. If the entered text is longer than the allocation of the widget, the widget will scroll so that the cursor position is visible.

When using an entry for passwords and other sensitive information, it can be put into "password mode" using set_visibility(). In this mode, entered text is displayed using a 'invisible' character. By default, GTK+ picks the best invisible character that is available in the current font, but it can be changed with set_invisible_char(). Since 2.16, GTK+ displays a warning when Caps Lock or input methods might interfere with entering text in a password entry. The warning can be turned off with the "caps-lock-warning" property.

Since 2.16, GtkEntry has the ability to display progress or activity information behind the text. To make an entry display such information, use set_progress_fraction() or set_progress_pulse_step().

Additionally, GtkEntry can show icons at either side of the entry. These icons can be activatable by clicking, can be set up as drag source and can have tooltips. To add an icon, use set_icon_from_gicon() or one of the various other functions that set an icon from a stock id, an icon name or a pixbuf. To trigger an action when the user clicks an icon, connect to the "icon-press" signal. To allow DND operations from an icon, use set_icon_drag_source(). To set a tooltip on an icon, use set_icon_tooltip_text() or the corresponding function for markup.

Note that functionality or information that is only available by clicking on an icon in an entry may not be accessible at all to users which are not able to use a mouse or other pointing device. It is therefore recommended that any such functionality should also be available by other means, e.g. via the context menu of the entry.

Methods
get_activates_defaultRetrieves the value set by set_activates_default().
get_alignmentGets the value set by gtk_entry_set_alignment().
get_bufferGet the GtkEntryBuffer object which holds the text for this widget.
get_cursor_hadjustmentRetrieves the horizontal cursor adjustment for the entry
get_has_frameGets the value set by gtk_entry_set_has_frame().
get_icon_activatableReturns whether the icon is activatable.
get_icon_at_posFinds the icon at the given position and return its index.
get_icon_nameRetrieves the icon name used for the icon, or NULL if there is no icon or if the icon was set by some other method (e.g., by pixbuf, stock or gicon).
get_icon_pixbufRetrieves the image used for the icon.
get_icon_sensitiveReturns whether the icon appears sensitive or insensitive.
get_icon_stockRetrieves the stock id used for the icon, or NULL if there is no icon or if the icon was set by some other method (e.g., by pixbuf, icon name or gicon).
get_icon_storage_typeGets the type of representation being used by the icon to store image data.
get_icon_tooltip_markupGets the contents of the tooltip on the icon at the specified position in entry.
get_icon_tooltip_textGets the contents of the tooltip on the icon at the specified position in entry.
get_invisible_charRetrieves the character displayed in place of the real characters for entries with visibility set to false.
get_layout_offsetsObtains the position of the PangoLayout used to render text in the entry, in widget coordinates.
get_max_lengthRetrieves the maximum allowed length of the text in entry.
get_overwrite_modeGets the value set by gtk_entry_set_overwrite_mode().
get_progress_fractionReturns the current fraction of the task that's been completed.
get_progress_pulse_stepRetrieves the pulse step set with gtk_entry_set_progress_pulse_step().
get_textRetrieves the contents of the entry widget.
get_text_lengthRetrieves the current length of the text in entry.
get_visibilityRetrieves whether the text in entry is visible.
get_width_charsGets the value set by gtk_entry_set_width_chars().
layout_index_to_text_indexConverts from a position in the entry contents (returned by gtk_entry_get_text()) to a position in the entry's PangoLayout (returned by gtk_entry_get_layout(), with text retrieved via pango_layout_get_text()).
new_with_bufferCreates a new entry with the specified text buffer.
new_with_max_lengthCreates a new GtkEntry widget with the given maximum length.
progress_pulseIndicates that some progress is made, but you don't know how much.
set_activates_defaultIf setting is TRUE, pressing Enter in the entry will activate the default widget for the window containing the entry.
set_alignmentSets the alignment for the contents of the entry.
set_bufferSet the GtkEntryBuffer object which holds the text for this widget.
set_cursor_hadjustmentHooks up an adjustment to the cursor position in an entry, so that when the cursor is moved, the adjustment is scrolled to show that position.
set_has_frameSets whether the entry has a beveled frame around it.
set_icon_activatableSets whether the icon is activatable.
set_icon_from_icon_nameSets the icon shown in the entry at the specified position from the current icon theme.
set_icon_from_pixbufSets the icon shown in the specified position using a pixbuf.
set_icon_from_stockSets the icon shown in the entry at the specified position from a stock image.
set_icon_sensitiveSets the sensitivity for the specified icon.
set_icon_tooltip_markupSets tooltip as the contents of the tooltip for the icon at the specified position.
set_icon_tooltip_textSets tooltip as the contents of the tooltip for the icon at the specified position.
set_invisible_charSets the entry invisible char
set_max_lengthSets the maximum allowed length of the contents of the widget.
set_overwrite_modeSets whether the text is overwritten when typing in the GtkEntry.
set_progress_fractionCauses the entry's progress indicator to "fill in" the given fraction of the bar.
set_progress_pulse_stepSets the fraction of total entry width to move the progress bouncing block for each call to gtk_entry_progress_pulse().
set_textSets the text in the widget to the given value, replacing the current contents.
set_visiblitySets whether the contents of the entry are visible or not.
set_width_charsChanges the size request of the entry to be about the right size for n_chars characters.
signal_activateA keybinding signal which gets emitted when the user activates the entry.
signal_backspaceThe backspace signal is a keybinding signal which gets emitted when the user asks for it.
signal_copy_clipboardThe copy-clipboard signal is a keybinding signal which gets emitted to copy the selection to the clipboard.
signal_cut_clipboardThe cut-clipboard signal is a keybinding signal which gets emitted to cut the selection to the clipboard.
signal_delete_from_cursorThe delete-from-cursor signal is a keybinding signal which gets emitted when the user initiates a text deletion.
signal_icon_pressThe ::icon-press signal is emitted when an activatable icon is clicked.
signal_icon_releaseThe icon-release signal is emitted on the button release from a mouse click over an activatable icon.
signal_insert_at_cursorThe insert-at-cursor signal is a keybinding signal which gets emitted when the user initiates the insertion of a fixed string at the cursor.
signal_move_cursorThe move-cursor signal is a keybinding signal which gets emitted when the user initiates a cursor movement.
signal_paste_clipboardThe paste-clipboard signal is a keybinding signal which gets emitted to paste the contents of the clipboard into the text view.
signal_populate_popupThe populate-popup signal gets emitted before showing the context menu of the entry.
signal_preedit_changedIf an input method is used, the typed text will not immediately be committed to the buffer. So if you are interested in the text, connect to this signal.
signal_toggle_overwriteThe toggle-overwrite signal is a keybinding signal which gets emitted to toggle the overwrite mode of the entry.
text_index_to_layout_indexConverts from a position in the entry's PangoLayout (returned by gtk_entry_get_layout()) to a position in the entry contents (returned by gtk_entry_get_text()).
unset_invisible_charUnsets the invisible char previously set with set_invisible_char().

Methods

get_activates_default

Retrieves the value set by set_activates_default().

GtkEntry.get_activates_default()
Return(boolean) true if the entry will activate the default widget

get_alignment

Gets the value set by gtk_entry_set_alignment().

GtkEntry.get_alignment()
Returnthe alignment

get_buffer

Get the GtkEntryBuffer object which holds the text for this widget.

GtkEntry.get_buffer()
ReturnA GtkEntryBuffer object.

get_cursor_hadjustment

Retrieves the horizontal cursor adjustment for the entry

GtkEntry.get_cursor_hadjustment()
Returnthe horizontal cursor adjustment, or NULL if none has been set.

get_has_frame

Gets the value set by gtk_entry_set_has_frame().

GtkEntry.get_has_frame()
Returnwhether the entry has a beveled frame

get_icon_activatable

Returns whether the icon is activatable.

GtkEntry.get_icon_activatable( icon_pos )
icon_pos Icon position (GtkEntryIconPosition).
ReturnTRUE if the icon is activatable.

get_icon_at_pos

Finds the icon at the given position and return its index.

GtkEntry.get_icon_at_pos( x, y )
x the x coordinate of the position to find
y the y coordinate of the position to find
Returnthe index of the icon at the given position, or -1.

If x, y doesn't lie inside an icon, -1 is returned. This function is intended for use in a "query-tooltip" signal handler.

get_icon_name

Retrieves the icon name used for the icon, or NULL if there is no icon or if the icon was set by some other method (e.g., by pixbuf, stock or gicon).

GtkEntry.get_icon_name( icon_pos )
icon_pos Icon position (GtkEntryIconPosition).
ReturnAn icon name, or NULL if no icon is set or if the icon wasn't set from an icon name

get_icon_pixbuf

Retrieves the image used for the icon.

GtkEntry.get_icon_pixbuf( icon_pos )
icon_pos Icon position (GtkEntryIconPosition).
ReturnA GdkPixbuf, or NULL if no icon is set for this position.

Unlike the other methods of setting and getting icon data, this method will work regardless of whether the icon was set using a GdkPixbuf, a GIcon, a stock item, or an icon name.

get_icon_sensitive

Returns whether the icon appears sensitive or insensitive.

GtkEntry.get_icon_sensitive( icon_pos )
icon_pos Icon position (GtkEntryIconPosition).
ReturnTRUE if the icon is sensitive.

get_icon_stock

Retrieves the stock id used for the icon, or NULL if there is no icon or if the icon was set by some other method (e.g., by pixbuf, icon name or gicon).

GtkEntry.get_icon_stock( icon_pos )
icon_pos Icon position (GtkEntryIconPosition).
ReturnA stock id, or NULL if no icon is set or if the icon wasn't set from a stock id.

get_icon_storage_type

Gets the type of representation being used by the icon to store image data.

GtkEntry.get_icon_storage_type( icon_pos )
icon_pos Icon position (GtkEntryIconPosition).
Returnimage representation being used

If the icon has no image data, the return value will be GTK_IMAGE_EMPTY.

get_icon_tooltip_markup

Gets the contents of the tooltip on the icon at the specified position in entry.

GtkEntry.get_icon_tooltip_markup( icon_pos )
icon_pos Icon position (GtkEntryIconPosition).
Returnthe tooltip text, or NULL.

get_icon_tooltip_text

Gets the contents of the tooltip on the icon at the specified position in entry.

GtkEntry.get_icon_tooltip_text( icon_pos )
icon_pos Icon position (GtkEntryIconPosition).
Returnthe tooltip text, or NULL.

get_invisible_char

Retrieves the character displayed in place of the real characters for entries with visibility set to false.

GtkEntry.get_invisible_char()
Returnthe current invisible char, or "", if the entry does not show invisible text at all.

get_layout_offsets

Obtains the position of the PangoLayout used to render text in the entry, in widget coordinates.

GtkEntry.get_layout_offsets()
Returnan array ( X offset, Y offset ).

Useful if you want to line up the text in an entry with some other text, e.g. when using the entry to implement editable cells in a sheet widget.

Also useful to convert mouse events into coordinates inside the PangoLayout, e.g. to take some action if some part of the entry text is clicked.

Note that as the user scrolls around in the entry the offsets will change; you'll need to connect to the "notify::scroll-offset" signal to track this. Remember when using the PangoLayout functions you need to convert to and from pixels using PANGO_PIXELS() or PANGO_SCALE.

Keep in mind that the layout text may contain a preedit string, so gtk_entry_layout_index_to_text_index() and gtk_entry_text_index_to_layout_index() are needed to convert byte indices in the layout to byte indices in the entry contents.

get_max_length

Retrieves the maximum allowed length of the text in entry.

GtkEntry.get_max_length()
Returnthe maximum allowed number of characters in GtkEntry, or 0 if there is no maximum.

get_overwrite_mode

Gets the value set by gtk_entry_set_overwrite_mode().

GtkEntry.get_overwrite_mode()
Returnwhether the text is overwritten when typing.

get_progress_fraction

Returns the current fraction of the task that's been completed.

GtkEntry.get_progress_fraction()
Returna fraction from 0.0 to 1.0

get_progress_pulse_step

Retrieves the pulse step set with gtk_entry_set_progress_pulse_step().

GtkEntry.get_progress_pulse_step()
Returna fraction from 0.0 to 1.0

get_text

Retrieves the contents of the entry widget.

GtkEntry.get_text()
Returnthe contents of the widget as a string.

get_text_length

Retrieves the current length of the text in entry.

GtkEntry.get_text_length()
Returnthe current number of characters in GtkEntry, or 0 if there are none.

get_visibility

Retrieves whether the text in entry is visible.

GtkEntry.get_visibility()
ReturnTRUE if the text is currently visible

get_width_chars

Gets the value set by gtk_entry_set_width_chars().

GtkEntry.get_width_chars()
Returnnumber of chars to request space for, or negative if unset

layout_index_to_text_index

Converts from a position in the entry contents (returned by gtk_entry_get_text()) to a position in the entry's PangoLayout (returned by gtk_entry_get_layout(), with text retrieved via pango_layout_get_text()).

GtkEntry.layout_index_to_text_index( layout_index )
layout_index byte index into the entry layout text
Returnbyte index into the entry contents

new_with_buffer

Creates a new entry with the specified text buffer.

GtkEntry.new_with_buffer( buffer )
buffer The GtkEntryBuffer to use for the new GtkEntry.

new_with_max_length

Creates a new GtkEntry widget with the given maximum length.

GtkEntry.new_with_max_length( max )
max the maximum length of the entry, or 0 for no maximum. (other than the maximum length of entries.) The value passed in will be clamped to the range 0-65536.

gtk_entry_new_with_max_length has been deprecated since version 2.0 and should not be used in newly-written code. Use gtk_entry_set_max_length() instead.

progress_pulse

Indicates that some progress is made, but you don't know how much.

GtkEntry.progress_pulse()

Causes the entry's progress indicator to enter "activity mode," where a block bounces back and forth. Each call to gtk_entry_progress_pulse() causes the block to move by a little bit (the amount of movement per pulse is determined by gtk_entry_set_progress_pulse_step()).

set_activates_default

If setting is TRUE, pressing Enter in the entry will activate the default widget for the window containing the entry.

GtkEntry.set_activates_default( setting )
setting TRUE to activate window's default widget on Enter keypress

This usually means that the dialog box containing the entry will be closed, since the default widget is usually one of the dialog buttons.

(For experts: if setting is TRUE, the entry calls gtk_window_activate_default() on the window containing the entry, in the default handler for the "activate" signal.)

set_alignment

Sets the alignment for the contents of the entry.

GtkEntry.set_alignment( xalign )
xalign The horizontal alignment, from 0 (left) to 1 (right). Reversed for RTL layouts

This controls the horizontal positioning of the contents when the displayed text is shorter than the width of the entry.

set_buffer

Set the GtkEntryBuffer object which holds the text for this widget.

GtkEntry.set_buffer( buffer )
buffer a GtkEntryBuffer

set_cursor_hadjustment

Hooks up an adjustment to the cursor position in an entry, so that when the cursor is moved, the adjustment is scrolled to show that position.

GtkEntry.set_cursor_hadjustment( adjustment )
adjustment an adjustment which should be adjusted when the cursor is moved, or NULL

See gtk_scrolled_window_get_hadjustment() for a typical way of obtaining the adjustment.

The adjustment has to be in pixel units and in the same coordinate system as the entry.

set_has_frame

Sets whether the entry has a beveled frame around it.

GtkEntry.set_has_frame( setting )
setting new value (boolean).

set_icon_activatable

Sets whether the icon is activatable.

GtkEntry.set_icon_activatable( icon_pos, activatable )
icon_pos Icon position (GtkEntryIconPosition).
activatable TRUE if the icon should be activatable.

set_icon_from_icon_name

Sets the icon shown in the entry at the specified position from the current icon theme.

GtkEntry.set_icon_from_icon_name( icon_pos, icon_name )
icon_pos The position at which to set the icon (GtkEntryIconPosition).
icon_name An icon name, or NULL.

If the icon name isn't known, a "broken image" icon will be displayed instead.

If icon_name is NULL, no icon will be shown in the specified position.

set_icon_from_pixbuf

Sets the icon shown in the specified position using a pixbuf.

GtkEntry.set_icon_from_pixbuf( icon_pos, pixbuf )
icon_pos Icon position (GtkEntryIconPosition).
pixbuf A GdkPixbuf, or NULL.

If pixbuf is NULL, no icon will be shown in the specified position.

set_icon_from_stock

Sets the icon shown in the entry at the specified position from a stock image.

GtkEntry.set_icon_from_stock( icon_pos, stock_id )
icon_pos Icon position (GtkEntryIconPosition).
stock_id The name of the stock item, or NULL.

If stock_id is NULL, no icon will be shown in the specified position.

set_icon_sensitive

Sets the sensitivity for the specified icon.

GtkEntry.set_icon_sensitive( icon_pos, sensitive )
icon_pos Icon position (GtkEntryIconPosition).
sensitive Specifies whether the icon should appear sensitive or insensitive

set_icon_tooltip_markup

Sets tooltip as the contents of the tooltip for the icon at the specified position.

GtkEntry.set_icon_tooltip_markup( icon_pos, tooltip )
icon_pos Icon position (GtkEntryIconPosition).
tooltip the contents of the tooltip for the icon, or NULL.

tooltip is assumed to be marked up with the Pango text markup language.

Use NULL for tooltip to remove an existing tooltip.

See also gtk_widget_set_tooltip_markup() and gtk_enty_set_icon_tooltip_text().

set_icon_tooltip_text

Sets tooltip as the contents of the tooltip for the icon at the specified position.

GtkEntry.set_icon_tooltip_text( icon_pos, tooltip )
icon_pos Icon position (GtkEntryIconPosition).
tooltip the contents of the tooltip for the icon, or NULL.

Use NULL for tooltip to remove an existing tooltip.

set_invisible_char

Sets the entry invisible char

GtkEntry.set_invisible_char( ch )
ch a character

Sets the character to use in place of the actual text when set_visibility() has been called to set text visibility to false. i.e. this is the character used in "password mode" to show the user how many characters have been typed. By default, GTK+ picks the best invisible char available in the current font. If you set the invisible char to "", then the user will get no feedback at all; there will be no text on the screen as they type.

set_max_length

Sets the maximum allowed length of the contents of the widget.

GtkEntry.set_max_length( max )
max the maximum length of the entry, or 0 for no maximum. (other than the maximum length of entries.)

The value passed in will be clamped to the range 0-65536.

If the current contents are longer than the given length, then they will be truncated to fit.

set_overwrite_mode

Sets whether the text is overwritten when typing in the GtkEntry.

GtkEntry.set_overwrite_mode( overwrite )
overwrite new value (boolean).

set_progress_fraction

Causes the entry's progress indicator to "fill in" the given fraction of the bar.

GtkEntry.set_progress_fraction( fraction )
fraction fraction of the task that's been completed.

The fraction should be between 0.0 and 1.0, inclusive.

set_progress_pulse_step

Sets the fraction of total entry width to move the progress bouncing block for each call to gtk_entry_progress_pulse().

GtkEntry.set_progress_pulse_step( fraction )
fraction fraction between 0.0 and 1.0

set_text

Sets the text in the widget to the given value, replacing the current contents.

GtkEntry.set_text( text )
text the new text

set_visiblity

Sets whether the contents of the entry are visible or not.

GtkEntry.set_visiblity( visible )
visible (boolean) true if the contents of the entry are displayed as plaintext

When visibility is set to false, characters are displayed as the invisible char, and will also appear that way when the text in the entry widget is copied elsewhere.

By default, GTK+ picks the best invisible character available in the current font, but it can be changed with set_invisible_char().

set_width_chars

Changes the size request of the entry to be about the right size for n_chars characters.

GtkEntry.set_width_chars( n_chars )
n_chars width in chars

Note that it changes the size request, the size can still be affected by how you pack the widget into containers. If n_chars is -1, the size reverts to the default entry size.

signal_activate

A keybinding signal which gets emitted when the user activates the entry.

GtkEntry.signal_activate()

Applications should not connect to it, but may emit it with g_signal_emit_by_name() if they need to control activation programmatically.

The default bindings for this signal are all forms of the Enter key.

signal_backspace

The backspace signal is a keybinding signal which gets emitted when the user asks for it.

GtkEntry.signal_backspace()

The default bindings for this signal are Backspace and Shift-Backspace.

signal_copy_clipboard

The copy-clipboard signal is a keybinding signal which gets emitted to copy the selection to the clipboard.

GtkEntry.signal_copy_clipboard()

The default bindings for this signal are Ctrl-c and Ctrl-Insert.

signal_cut_clipboard

The cut-clipboard signal is a keybinding signal which gets emitted to cut the selection to the clipboard.

GtkEntry.signal_cut_clipboard()

The default bindings for this signal are Ctrl-x and Shift-Delete.

signal_delete_from_cursor

The delete-from-cursor signal is a keybinding signal which gets emitted when the user initiates a text deletion.

GtkEntry.signal_delete_from_cursor()

If the type is GTK_DELETE_CHARS, GTK+ deletes the selection if there is one, otherwise it deletes the requested number of characters.

The default bindings for this signal are Delete for deleting a character and Ctrl-Delete for deleting a word.

signal_icon_press

The ::icon-press signal is emitted when an activatable icon is clicked.

GtkEntry.signal_icon_press()

Note: Currently not implemented.

signal_icon_release

The icon-release signal is emitted on the button release from a mouse click over an activatable icon.

GtkEntry.signal_icon_release()

Note: Currently not implemented.

signal_insert_at_cursor

The insert-at-cursor signal is a keybinding signal which gets emitted when the user initiates the insertion of a fixed string at the cursor.

GtkEntry.signal_insert_at_cursor()

This signal has no default bindings.

signal_move_cursor

The move-cursor signal is a keybinding signal which gets emitted when the user initiates a cursor movement.

GtkEntry.signal_move_cursor()

If the cursor is not visible in entry, this signal causes the viewport to be moved instead.

Applications should not connect to it, but may emit it with g_signal_emit_by_name() if they need to control the cursor programmatically.

The default bindings for this signal come in two variants, the variant with the Shift modifier extends the selection, the variant without the Shift modifer does not. There are too many key combinations to list them all here.

- Arrow keys move by individual characters/lines

signal_paste_clipboard

The paste-clipboard signal is a keybinding signal which gets emitted to paste the contents of the clipboard into the text view.

GtkEntry.signal_paste_clipboard()

The default bindings for this signal are Ctrl-v and Shift-Insert.

signal_populate_popup

The populate-popup signal gets emitted before showing the context menu of the entry.

GtkEntry.signal_populate_popup()

If you need to add items to the context menu, connect to this signal and append your menuitems to the menu.

signal_preedit_changed

If an input method is used, the typed text will not immediately be committed to the buffer. So if you are interested in the text, connect to this signal.

GtkEntry.signal_preedit_changed()

signal_toggle_overwrite

The toggle-overwrite signal is a keybinding signal which gets emitted to toggle the overwrite mode of the entry.

GtkEntry.signal_toggle_overwrite()

The default bindings for this signal is Insert.

text_index_to_layout_index

Converts from a position in the entry's PangoLayout (returned by gtk_entry_get_layout()) to a position in the entry contents (returned by gtk_entry_get_text()).

GtkEntry.text_index_to_layout_index( text_index )
text_index byte index into the entry contents
Returnbyte index into the entry layout text

unset_invisible_char

Unsets the invisible char previously set with set_invisible_char().

GtkEntry.unset_invisible_char()

So that the default invisible char is used again.

Made with http://www.falconpl.org