Synopsis
#include <gtk/gtk.h>
GtkEntry;
GtkWidget* gtk_entry_new (void);
GtkWidget* gtk_entry_new_with_max_length (gint max);
void gtk_entry_set_text (GtkEntry *entry,
const gchar *text);
void gtk_entry_append_text (GtkEntry *entry,
const gchar *text);
void gtk_entry_prepend_text (GtkEntry *entry,
const gchar *text);
void gtk_entry_set_position (GtkEntry *entry,
gint position);
const gchar* gtk_entry_get_text (GtkEntry *entry);
guint16 gtk_entry_get_text_length (GtkEntry *entry);
void gtk_entry_select_region (GtkEntry *entry,
gint start,
gint end);
void gtk_entry_set_visibility (GtkEntry *entry,
gboolean visible);
void gtk_entry_set_invisible_char (GtkEntry *entry,
gunichar ch);
void gtk_entry_set_editable (GtkEntry *entry,
gboolean editable);
void gtk_entry_set_max_length (GtkEntry *entry,
gint max);
gboolean gtk_entry_get_activates_default (GtkEntry *entry);
gboolean gtk_entry_get_has_frame (GtkEntry *entry);
const GtkBorder* gtk_entry_get_inner_border (GtkEntry *entry);
gint gtk_entry_get_width_chars (GtkEntry *entry);
void gtk_entry_set_activates_default (GtkEntry *entry,
gboolean setting);
void gtk_entry_set_has_frame (GtkEntry *entry,
gboolean setting);
void gtk_entry_set_inner_border (GtkEntry *entry,
const GtkBorder *border);
void gtk_entry_set_width_chars (GtkEntry *entry,
gint n_chars);
gunichar gtk_entry_get_invisible_char (GtkEntry *entry);
void gtk_entry_set_alignment (GtkEntry *entry,
gfloat xalign);
gfloat gtk_entry_get_alignment (GtkEntry *entry);
void gtk_entry_set_overwrite_mode (GtkEntry *entry,
gboolean overwrite);
gboolean gtk_entry_get_overwrite_mode (GtkEntry *entry);
PangoLayout* gtk_entry_get_layout (GtkEntry *entry);
void gtk_entry_get_layout_offsets (GtkEntry *entry,
gint *x,
gint *y);
gint gtk_entry_layout_index_to_text_index
(GtkEntry *entry,
gint layout_index);
gint gtk_entry_text_index_to_layout_index
(GtkEntry *entry,
gint text_index);
gint gtk_entry_get_max_length (GtkEntry *entry);
gboolean gtk_entry_get_visibility (GtkEntry *entry);
void gtk_entry_set_completion (GtkEntry *entry,
GtkEntryCompletion *completion);
GtkEntryCompletion* gtk_entry_get_completion (GtkEntry *entry);
void gtk_entry_set_cursor_hadjustment (GtkEntry *entry,
GtkAdjustment *adjustment);
GtkAdjustment* gtk_entry_get_cursor_hadjustment (GtkEntry *entry);
Object Hierarchy
GObject
+----GInitiallyUnowned
+----GtkObject
+----GtkWidget
+----GtkEntry
+----GtkSpinButton
Implemented InterfacesGtkEntry implements AtkImplementorIface, GtkBuildable, GtkCellEditable and GtkEditable. Properties"activates-default" gboolean : Read / Write "cursor-position" gint : Read "editable" gboolean : Read / Write "has-frame" gboolean : Read / Write "inner-border" GtkBorder* : Read / Write "invisible-char" guint : Read / Write "max-length" gint : Read / Write "overwrite-mode" gboolean : Read / Write "scroll-offset" gint : Read "selection-bound" gint : Read "shadow-type" GtkShadowType : Read / Write "text" gchar* : Read / Write "text-length" guint : Read "truncate-multiline" gboolean : Read / Write "visibility" gboolean : Read / Write "width-chars" gint : Read / Write "xalign" gfloat : Read / Write Signals"activate" : Run Last / Action "backspace" : Run Last / Action "copy-clipboard" : Run Last / Action "cut-clipboard" : Run Last / Action "delete-from-cursor" : Run Last / Action "insert-at-cursor" : Run Last / Action "move-cursor" : Run Last / Action "paste-clipboard" : Run Last / Action "populate-popup" : Run Last "toggle-overwrite" : Run Last / Action DescriptionThe 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. Detailsgtk_entry_new_with_max_length ()GtkWidget* gtk_entry_new_with_max_length (gint max); Warning
Creates a new GtkEntry widget with the given maximum length.
Note: the existence of this function is inconsistent
with the rest of the GTK+ API. The normal setup would
be to just require the user to make an extra call
to
gtk_entry_set_text ()void gtk_entry_set_text (GtkEntry *entry, const gchar *text); Sets the text in the widget to the given value, replacing the current contents.
gtk_entry_append_text ()void gtk_entry_append_text (GtkEntry *entry, const gchar *text); Warning
Appends the given text to the contents of the widget.
gtk_entry_prepend_text ()void gtk_entry_prepend_text (GtkEntry *entry, const gchar *text); Warning
Prepends the given text to the contents of the widget.
gtk_entry_set_position ()void gtk_entry_set_position (GtkEntry *entry, gint position); Warning
Sets the cursor position in an entry to the given value.
gtk_entry_get_text ()const gchar* gtk_entry_get_text (GtkEntry *entry);
Retrieves the contents of the entry widget.
See also
gtk_entry_get_text_length ()guint16 gtk_entry_get_text_length (GtkEntry *entry);
Retrieves the current length of the text in
Since 2.14 gtk_entry_select_region ()void gtk_entry_select_region (GtkEntry *entry, gint start, gint end); Warning
Selects a region of text. The characters that are selected are
those characters at positions from
gtk_entry_set_visibility ()void gtk_entry_set_visibility (GtkEntry *entry, gboolean visible);
Sets whether the contents of the entry are visible or not.
When visibility is set to
The default invisible char is the asterisk '*', but it can
be changed with
gtk_entry_set_invisible_char ()void gtk_entry_set_invisible_char (GtkEntry *entry, gunichar ch);
Sets the character to use in place of the actual text when
gtk_entry_set_editable ()void gtk_entry_set_editable (GtkEntry *entry, gboolean editable); Warning
Determines if the user can edit the text in the editable widget or not.
gtk_entry_set_max_length ()void gtk_entry_set_max_length (GtkEntry *entry, gint max); Sets the maximum allowed length of the contents of the widget. If the current contents are longer than the given length, then they will be truncated to fit.
gtk_entry_get_activates_default ()gboolean gtk_entry_get_activates_default (GtkEntry *entry);
Retrieves the value set by
gtk_entry_get_has_frame ()gboolean gtk_entry_get_has_frame (GtkEntry *entry);
Gets the value set by
gtk_entry_get_inner_border ()const GtkBorder* gtk_entry_get_inner_border (GtkEntry *entry);
This function returns the entry's "inner-border" property. See
Since 2.10 gtk_entry_get_width_chars ()gint gtk_entry_get_width_chars (GtkEntry *entry);
Gets the value set by
gtk_entry_set_activates_default ()void gtk_entry_set_activates_default (GtkEntry *entry, gboolean setting);
If
(For experts: if
gtk_entry_set_has_frame ()void gtk_entry_set_has_frame (GtkEntry *entry, gboolean setting); Sets whether the entry has a beveled frame around it.
gtk_entry_set_inner_border ()void gtk_entry_set_inner_border (GtkEntry *entry, const GtkBorder *border);
Sets If set, this property overrides the inner-border style property. Overriding the style-provided border is useful when you want to do in-place editing of some text in a canvas or list widget, where pixel-exact positioning of the entry is important.
Since 2.10 gtk_entry_set_width_chars ()void gtk_entry_set_width_chars (GtkEntry *entry, gint n_chars);
Changes the size request of the entry to be about the right size
for
gtk_entry_get_invisible_char ()gunichar gtk_entry_get_invisible_char (GtkEntry *entry);
Retrieves the character displayed in place of the real characters
for entries with visibility set to false. See
gtk_entry_set_alignment ()void gtk_entry_set_alignment (GtkEntry *entry, gfloat xalign); Sets the alignment for the contents of the entry. This controls the horizontal positioning of the contents when the displayed text is shorter than the width of the entry.
Since 2.4 gtk_entry_get_alignment ()gfloat gtk_entry_get_alignment (GtkEntry *entry);
Gets the value set by
Since 2.4 gtk_entry_set_overwrite_mode ()void gtk_entry_set_overwrite_mode (GtkEntry *entry, gboolean overwrite); Sets whether the text is overwritten when typing in the GtkEntry.
Since 2.14 gtk_entry_get_overwrite_mode ()gboolean gtk_entry_get_overwrite_mode (GtkEntry *entry);
Gets the value set by
Since 2.14 gtk_entry_get_layout ()PangoLayout* gtk_entry_get_layout (GtkEntry *entry);
Gets the PangoLayout used to display the entry.
The layout is useful to e.g. convert text positions to
pixel positions, in combination with
Keep in mind that the layout text may contain a preedit string, so
gtk_entry_get_layout_offsets ()void gtk_entry_get_layout_offsets (GtkEntry *entry, gint *x, gint *y); Obtains the position of the PangoLayout used to render text in the entry, in widget coordinates. 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
Keep in mind that the layout text may contain a preedit string, so
gtk_entry_layout_index_to_text_index ()gint gtk_entry_layout_index_to_text_index
(GtkEntry *entry,
gint layout_index);
Converts from a position in the entry contents (returned
by
gtk_entry_text_index_to_layout_index ()gint gtk_entry_text_index_to_layout_index
(GtkEntry *entry,
gint text_index);
Converts from a position in the entry's PangoLayout (returned by
gtk_entry_get_max_length ()gint gtk_entry_get_max_length (GtkEntry *entry);
Retrieves the maximum allowed length of the text in
gtk_entry_get_visibility ()gboolean gtk_entry_get_visibility (GtkEntry *entry);
Retrieves whether the text in
gtk_entry_set_completion ()void gtk_entry_set_completion (GtkEntry *entry, GtkEntryCompletion *completion);
Sets
Since 2.4 gtk_entry_get_completion ()GtkEntryCompletion* gtk_entry_get_completion (GtkEntry *entry);
Returns the auxiliary completion object currently in use by
Since 2.4 gtk_entry_set_cursor_hadjustment ()void gtk_entry_set_cursor_hadjustment (GtkEntry *entry, GtkAdjustment *adjustment);
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.
See The adjustment has to be in pixel units and in the same coordinate system as the entry.
Since 2.12 gtk_entry_get_cursor_hadjustment ()GtkAdjustment* gtk_entry_get_cursor_hadjustment (GtkEntry *entry);
Retrieves the horizontal cursor adjustment for the entry.
See
Since 2.12 Property DetailsThe
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"backspace" signalvoid user_function (GtkEntry *entry, gpointer user_data) : Run Last / Action
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"copy-clipboard" signalvoid user_function (GtkEntry *entry, gpointer user_data) : Run Last / Action
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"cut-clipboard" signalvoid user_function (GtkEntry *entry, gpointer user_data) : Run Last / Action
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"delete-from-cursor" signalvoid user_function (GtkEntry *entry, GtkDeleteType arg1, gint arg2, gpointer user_data) : Run Last / Action
|
the object which received the signal. |
|
|
|
|
|
user data set when the signal handler was connected. |
"insert-at-cursor" signalvoid user_function (GtkEntry *entry, gchar *arg1, gpointer user_data) : Run Last / Action
|
the object which received the signal. |
|
|
|
user data set when the signal handler was connected. |
"move-cursor" signalvoid user_function (GtkEntry *entry, GtkMovementStep arg1, gint arg2, gboolean arg3, gpointer user_data) : Run Last / Action
|
the object which received the signal. |
|
|
|
|
|
|
|
user data set when the signal handler was connected. |
"paste-clipboard" signalvoid user_function (GtkEntry *entry, gpointer user_data) : Run Last / Action
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"populate-popup" signalvoid user_function (GtkEntry *entry, GtkMenu *arg1, gpointer user_data) : Run Last
|
the object which received the signal. |
|
|
|
user data set when the signal handler was connected. |
"toggle-overwrite" signalvoid user_function (GtkEntry *entry, gpointer user_data) : Run Last / Action
|
the object which received the signal. |
|
user data set when the signal handler was connected. |