GtkEditableLabel

GtkEditableLabel — A label that can be edited

Properties

gboolean editing Read

Actions

  editing.stop b
  editing.start  

Types and Values

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GtkWidget
            ╰── GtkEditableLabel

Implemented Interfaces

GtkEditableLabel implements GtkAccessible, GtkBuildable, GtkConstraintTarget and GtkEditable.

Includes

#include <gtk/gtk.h>

Description

A GtkEditableLabel is a GtkLabel that allows users to edit the text by switching the widget to an “edit mode”.

GtkEditableLabel does not have API of its own, but it implements the GtkEditable interface.

The default bindings for activating the edit mode is to click or press the Enter key. The default bindings for leaving the edit mode are the Enter key (to save the results) or the Escape key (to cancel the editing).

CSS nodes

1
2
3
4
editablelabel[.editing]
╰── stack
    ├── label
    ╰── text

GtkEditableLabel has a main node with the name editablelabel. When the entry is in editing mode, it gets the .editing style class.

For all the subnodes added to the text node in various situations, see GtkText.

Functions

gtk_editable_label_new ()

GtkWidget *
gtk_editable_label_new (const char *str);

Creates a new GtkEditableLabel widget.

Parameters

str

the text for the label

 

Returns

the new GtkEditableLabel


gtk_editable_label_get_editing ()

gboolean
gtk_editable_label_get_editing (GtkEditableLabel *self);

Returns whether the label is currently in “editing mode”.

Parameters

self

a GtkEditableLabel

 

Returns

TRUE if self is currently in editing mode


gtk_editable_label_start_editing ()

void
gtk_editable_label_start_editing (GtkEditableLabel *self);

Switches the label into “editing mode”.

Parameters

self

a GtkEditableLabel

 

gtk_editable_label_stop_editing ()

void
gtk_editable_label_stop_editing (GtkEditableLabel *self,
                                 gboolean commit);

Switches the label out of “editing mode”. If commit is TRUE, the resulting text is kept as the “text” property value, otherwise the resulting text is discarded and the label will keep its previous “text” property value.

Parameters

self

a GtkEditableLabel

 

commit

whether to set the edited text on the label

 

Types and Values

GtkEditableLabel

typedef struct _GtkEditableLabel GtkEditableLabel;

Property Details

The “editing” property

  “editing”                  gboolean

This property is TRUE while the widget is in edit mode.

Owner: GtkEditableLabel

Flags: Read

Default value: FALSE

Action Details

The “editing.stop” action

Switch the widget out of editing mode. If commit is TRUE, then the results of the editing are taken as the new value of “text”.

The default binding for this action is the Escape key.

This action is disabled when “editing” is FALSE.

Parameter type: b

Parameters

commit

Whether the make changes permanent

 

The “editing.start” action

Switch the widget into editing mode, so that the user can make changes to the text.

The default bindings for this action are clicking on the widget and the Enter key.

This action is disabled when “editing” is FALSE.