package Implements_Gtk_Buildable is new Glib.Types.Implements (Gtk.Buildable.Gtk_Buildable, Gtk_Label_Record, Gtk_Label);
type Gtk_Label_Record is new Gtk_Misc_Record with null record;
type Gtk_Label is access all Gtk_Label_Record'Class;
type Cb_Gtk_Label_Void is not null access procedure (Self : access Gtk_Label_Record'Class);
type Cb_GObject_Void is not null access procedure (Self : access Glib.Object.GObject_Record'Class);
type Cb_Gtk_Label_UTF8_String_Boolean is not null access function (Self : access Gtk_Label_Record'Class; URI : UTF8_String) return Boolean;
type Cb_GObject_UTF8_String_Boolean is not null access function (Self : access Glib.Object.GObject_Record'Class; URI : UTF8_String) return Boolean;
type Cb_Gtk_Label_Gtk_Movement_Step_Gint_Boolean_Void is not null access procedure (Self : access Gtk_Label_Record'Class; Step : Gtk.Enums.Gtk_Movement_Step; Count : Gint; Extend_Selection : Boolean);
type Cb_GObject_Gtk_Movement_Step_Gint_Boolean_Void is not null access procedure (Self : access Glib.Object.GObject_Record'Class; Step : Gtk.Enums.Gtk_Movement_Step; Count : Gint; Extend_Selection : Boolean);
type Cb_Gtk_Label_Gtk_Menu_Void is not null access procedure (Self : access Gtk_Label_Record'Class; Menu : not null access Gtk.Menu.Gtk_Menu_Record'Class);
type Cb_GObject_Gtk_Menu_Void is not null access procedure (Self : access Glib.Object.GObject_Record'Class; Menu : not null access Gtk.Menu.Gtk_Menu_Record'Class);
Angle_Property : constant Glib.Properties.Property_Double;
Attributes_Property : constant Glib.Properties.Property_Object;
Cursor_Position_Property : constant Glib.Properties.Property_Int;
Ellipsize_Property : constant Pango.Layout.Property_Pango_Ellipsize_Mode;
Justify_Property : constant Gtk.Enums.Property_Gtk_Justification;
Label_Property : constant Glib.Properties.Property_String;
Max_Width_Chars_Property : constant Glib.Properties.Property_Int;
Mnemonic_Keyval_Property : constant Glib.Properties.Property_Uint;
Mnemonic_Widget_Property : constant Glib.Properties.Property_Object;
Pattern_Property : constant Glib.Properties.Property_String;
Selectable_Property : constant Glib.Properties.Property_Boolean;
Selection_Bound_Property : constant Glib.Properties.Property_Int;
Single_Line_Mode_Property : constant Glib.Properties.Property_Boolean;
Track_Visited_Links_Property : constant Glib.Properties.Property_Boolean;
Use_Markup_Property : constant Glib.Properties.Property_Boolean;
Use_Underline_Property : constant Glib.Properties.Property_Boolean;
Width_Chars_Property : constant Glib.Properties.Property_Int;
Wrap_Property : constant Glib.Properties.Property_Boolean;
Wrap_Mode_Property : constant Pango.Enums.Property_Wrap_Mode;
Signal_Activate_Current_Link : constant Glib.Signal_Name := "activate-current-link";
Signal_Activate_Link : constant Glib.Signal_Name := "activate-link";
Signal_Copy_Clipboard : constant Glib.Signal_Name := "copy-clipboard";
Signal_Move_Cursor : constant Glib.Signal_Name := "move-cursor";
Signal_Populate_Popup : constant Glib.Signal_Name := "populate-popup";
procedure Gtk_New
( | Label | : out Gtk_Label; |
Str | : UTF8_String := ""); |
procedure Initialize
( | Label | : not null access Gtk_Label_Record'Class; |
Str | : UTF8_String := ""); |
function Gtk_Label_New
( | Str | : UTF8_String := "") return Gtk_Label; |
procedure Gtk_New_With_Mnemonic
( | Label | : out Gtk_Label; |
Str | : UTF8_String); |
procedure Initialize_With_Mnemonic
( | Label | : not null access Gtk_Label_Record'Class; |
Str | : UTF8_String); |
function Gtk_Label_New_With_Mnemonic
( | Str | : UTF8_String) return Gtk_Label; |
function Get_Type return Glib.GType;
function Get_Angle
( | Label | : not null access Gtk_Label_Record) return Gdouble; |
procedure Set_Angle
( | Label | : not null access Gtk_Label_Record; |
Angle | : Gdouble); |
function Get_Attributes
( | Label | : not null access Gtk_Label_Record) return Pango.Attributes.Pango_Attr_List; |
procedure Set_Attributes
( | Label | : not null access Gtk_Label_Record; |
Attrs | : Pango.Attributes.Pango_Attr_List); |
function Get_Current_Uri
( | Label | : not null access Gtk_Label_Record) return UTF8_String; |
function Get_Ellipsize
( | Label | : not null access Gtk_Label_Record) return Pango.Layout.Pango_Ellipsize_Mode; |
procedure Set_Ellipsize
( | Label | : not null access Gtk_Label_Record; |
Mode | : Pango.Layout.Pango_Ellipsize_Mode); |
function Get_Justify
( | Label | : not null access Gtk_Label_Record) return Gtk.Enums.Gtk_Justification; |
procedure Set_Justify
( | Label | : not null access Gtk_Label_Record; |
Jtype | : Gtk.Enums.Gtk_Justification); |
function Get_Label
( | Label | : not null access Gtk_Label_Record) return UTF8_String; |
procedure Set_Label
( | Label | : not null access Gtk_Label_Record; |
Str | : UTF8_String); |
function Get_Layout
( | Label | : not null access Gtk_Label_Record) return Pango.Layout.Pango_Layout; |
procedure Get_Layout_Offsets
( | Label | : not null access Gtk_Label_Record; |
X | : out Gint; | |
Y | : out Gint); |
function Get_Line_Wrap
( | Label | : not null access Gtk_Label_Record) return Boolean; |
procedure Set_Line_Wrap
( | Label | : not null access Gtk_Label_Record; |
Wrap | : Boolean); |
function Get_Line_Wrap_Mode
( | Label | : not null access Gtk_Label_Record) return Pango.Enums.Wrap_Mode; |
procedure Set_Line_Wrap_Mode
( | Label | : not null access Gtk_Label_Record; |
Wrap_Mode | : Pango.Enums.Wrap_Mode); |
function Get_Max_Width_Chars
( | Label | : not null access Gtk_Label_Record) return Gint; |
procedure Set_Max_Width_Chars
( | Label | : not null access Gtk_Label_Record; |
N_Chars | : Gint); |
function Get_Mnemonic_Keyval
( | Label | : not null access Gtk_Label_Record) return Guint; |
function Get_Mnemonic_Widget
( | Label | : not null access Gtk_Label_Record) return Gtk.Widget.Gtk_Widget; |
procedure Set_Mnemonic_Widget
( | Label | : not null access Gtk_Label_Record; |
Widget | : access Gtk.Widget.Gtk_Widget_Record'Class); |
function Get_Selectable
( | Label | : not null access Gtk_Label_Record) return Boolean; |
procedure Set_Selectable
( | Label | : not null access Gtk_Label_Record; |
Setting | : Boolean); |
procedure Get_Selection_Bounds
( | Label | : not null access Gtk_Label_Record; |
Start | : out Gint; | |
The_End | : out Gint; | |
Has_Selection | : out Boolean); |
function Get_Single_Line_Mode
( | Label | : not null access Gtk_Label_Record) return Boolean; |
procedure Set_Single_Line_Mode
( | Label | : not null access Gtk_Label_Record; |
Single_Line_Mode | : Boolean); |
function Get_Text
( | Label | : not null access Gtk_Label_Record) return UTF8_String; |
procedure Set_Text
( | Label | : not null access Gtk_Label_Record; |
Str | : UTF8_String); |
function Get_Track_Visited_Links
( | Label | : not null access Gtk_Label_Record) return Boolean; |
procedure Set_Track_Visited_Links
( | Label | : not null access Gtk_Label_Record; |
Track_Links | : Boolean); |
function Get_Use_Markup
( | Label | : not null access Gtk_Label_Record) return Boolean; |
procedure Set_Use_Markup
( | Label | : not null access Gtk_Label_Record; |
Setting | : Boolean); |
function Get_Use_Underline
( | Label | : not null access Gtk_Label_Record) return Boolean; |
procedure Set_Use_Underline
( | Label | : not null access Gtk_Label_Record; |
Setting | : Boolean); |
function Get_Width_Chars
( | Label | : not null access Gtk_Label_Record) return Gint; |
procedure Set_Width_Chars
( | Label | : not null access Gtk_Label_Record; |
N_Chars | : Gint); |
procedure Select_Region
( | Label | : not null access Gtk_Label_Record; |
Start_Offset | : Gint := -1; | |
End_Offset | : Gint := -1); |
procedure Set_Markup
( | Label | : not null access Gtk_Label_Record; |
Str | : UTF8_String); |
procedure Set_Markup_With_Mnemonic
( | Label | : not null access Gtk_Label_Record; |
Str | : UTF8_String); |
procedure Set_Pattern
( | Label | : not null access Gtk_Label_Record; |
Pattern | : UTF8_String); |
procedure Set_Text_With_Mnemonic
( | Label | : not null access Gtk_Label_Record; |
Str | : UTF8_String); |
procedure On_Activate_Current_Link
( | Self | : not null access Gtk_Label_Record; |
Call | : Cb_Gtk_Label_Void; | |
After | : Boolean := False); |
procedure On_Activate_Current_Link
( | Self | : not null access Gtk_Label_Record; |
Call | : Cb_GObject_Void; | |
Slot | : not null access Glib.Object.GObject_Record'Class; | |
After | : Boolean := False); |
procedure On_Activate_Link
( | Self | : not null access Gtk_Label_Record; |
Call | : Cb_Gtk_Label_UTF8_String_Boolean; | |
After | : Boolean := False); |
procedure On_Activate_Link
( | Self | : not null access Gtk_Label_Record; |
Call | : Cb_GObject_UTF8_String_Boolean; | |
Slot | : not null access Glib.Object.GObject_Record'Class; | |
After | : Boolean := False); |
procedure On_Copy_Clipboard
( | Self | : not null access Gtk_Label_Record; |
Call | : Cb_Gtk_Label_Void; | |
After | : Boolean := False); |
procedure On_Copy_Clipboard
( | Self | : not null access Gtk_Label_Record; |
Call | : Cb_GObject_Void; | |
Slot | : not null access Glib.Object.GObject_Record'Class; | |
After | : Boolean := False); |
procedure On_Move_Cursor
( | Self | : not null access Gtk_Label_Record; |
Call | : Cb_Gtk_Label_Gtk_Movement_Step_Gint_Boolean_Void; | |
After | : Boolean := False); |
procedure On_Move_Cursor
( | Self | : not null access Gtk_Label_Record; |
Call | : Cb_GObject_Gtk_Movement_Step_Gint_Boolean_Void; | |
Slot | : not null access Glib.Object.GObject_Record'Class; | |
After | : Boolean := False); |
procedure On_Populate_Popup
( | Self | : not null access Gtk_Label_Record; |
Call | : Cb_Gtk_Label_Gtk_Menu_Void; | |
After | : Boolean := False); |
procedure On_Populate_Popup
( | Self | : not null access Gtk_Label_Record; |
Call | : Cb_GObject_Gtk_Menu_Void; | |
Slot | : not null access Glib.Object.GObject_Record'Class; | |
After | : Boolean := False); |
function "+"
( | Widget | : access Gtk_Label_Record'Class) return Gtk.Buildable.Gtk_Buildable renames Implements_Gtk_Buildable.To_Interface; |
function "-"
( | Interf | : Gtk.Buildable.Gtk_Buildable) return Gtk_Label renames Implements_Gtk_Buildable.To_Object; |
The Gtk.Label.Gtk_Label widget displays a small amount of text. As the name implies, most labels are used to label another widget such as a Gtk.Button.Gtk_Button, a Gtk.Menu_Item.Gtk_Menu_Item, or a Gtk.Combo_Box.Gtk_Combo_Box. == GtkLabel as GtkBuildable == The GtkLabel implementation of the GtkBuildable interface supports a custom <attributes> element, which supports any number of <attribute> elements. the <attribute> element has attributes named name, value, start and end and allows you to specify Pango.Attributes.Pango_Attribute values for this label. == A UI definition fragment specifying Pango attributes == <object class="GtkLabel"> <attributes> <attribute name="weight" value="PANGO_WEIGHT_BOLD"/> <attribute name="background" value="red" start="5" end="10"/>" </attributes> </object> The start and end attributes specify the range of characters to which the Pango attribute applies. If start and end are not specified, the attribute is applied to the whole text. Note that specifying ranges does not make much sense with translatable attributes. Use markup embedded in the translatable content instead. == Mnemonics == Labels may contain 'mnemonics'. Mnemonics are underlined characters in the label, used for keyboard navigation. Mnemonics are created by providing a string with an underscore before the mnemonic character, such as '"_File"', to the functions Gtk.Label.Gtk_New_With_Mnemonic or Gtk.Label.Set_Text_With_Mnemonic.
Mnemonics automatically activate any activatable widget the label is inside, such as a Gtk.Button.Gtk_Button; if the label is not inside the mnemonic's target widget, you have to tell the label about the target using Gtk.Label.Set_Mnemonic_Widget. Here's a simple example where the label is inside a button: // Pressing Alt+H will activate this button button = gtk_button_new (<!-- -->); label = gtk_label_new_with_mnemonic ("_Hello"); gtk_container_add (GTK_CONTAINER (button), label); There's a convenience function to create buttons with a mnemonic label already inside: // Pressing Alt+H will activate this button button = gtk_button_new_with_mnemonic ("_Hello"); To create a mnemonic for a widget alongside the label, such as a Gtk.GEntry.Gtk_Entry, you have to point the label at the entry with Gtk.Label.Set_Mnemonic_Widget: // Pressing Alt+H will focus the entry entry = gtk_entry_new (<!-- -->); label = gtk_label_new_with_mnemonic ("_Hello"); gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry); == Markup (styled text) == To make it easy to format text in a label (changing colors, fonts, etc.), label text can be provided in a simple <link linkend="PangoMarkupFormat">markup format</link>. Here's how to create a label with a small font: label = gtk_label_new (NULL); gtk_label_set_markup (GTK_LABEL (label), "<small>Small text</small>"); (See <link linkend="PangoMarkupFormat">complete documentation</link> of available tags in the Pango manual.) The markup passed to Gtk.Label.Set_Markup must be valid; for example, literal <, > and & characters must be escaped as \<, \gt;, and \&.
If you pass text obtained from the user, file, or a network to Gtk.Label.Set_Markup, you'll want to escape it with g_markup_escape_text or g_markup_printf_escaped.
Markup strings are just a convenient way to set the Pango.Attributes.Pango_Attr_List on a label; Gtk.Label.Set_Attributes may be a simpler way to set attributes in some cases. Be careful though; Pango.Attributes.Pango_Attr_List tends to cause internationalization problems, unless you're applying attributes to the entire string (i.e. unless you set the range of each attribute to [0, G_MAXINT)). The reason is that specifying the start_index and end_index for a Pango.Attributes.Pango_Attribute requires knowledge of the exact string being displayed, so translations will cause problems. == Selectable labels == Labels can be made selectable with Gtk.Label.Set_Selectable. Selectable labels allow the user to copy the label contents to the clipboard. Only labels that contain useful-to-copy information — such as error messages — should be made selectable. == Text layout == A label can contain any number of paragraphs, but will have performance problems if it contains more than a small number. Paragraphs are separated by newlines or other paragraph separators understood by Pango.
Labels can automatically wrap text if you call Gtk.Label.Set_Line_Wrap.
Gtk.Label.Set_Justify sets how the lines in a label align with one another. If you want to set how the label as a whole aligns in its available space, see Gtk.Misc.Set_Alignment.
The Gtk.Label.Gtk_Label:width-chars and Gtk.Label.Gtk_Label:max-width-chars properties can be used to control the size allocation of ellipsized or wrapped labels. For ellipsizing labels, if either is specified (and less than the actual text size), it is used as the minimum width, and the actual text size is used as the natural width of the label. For wrapping labels, width-chars is used as the minimum width, if specified, and max-width-chars is used as the natural width. Even if max-width-chars specified, wrapping labels will be rewrapped to use all of the available width.
Note: Note that the interpretation of Gtk.Label.Gtk_Label:width-chars and Gtk.Label.Gtk_Label:max-width-chars has changed a bit with the introduction of <link linkend="geometry-management">width-for-height geometry management.</link> == Links == Since 2.18, GTK+ supports markup for clickable hyperlinks in addition to regular Pango markup. The markup for links is borrowed from HTML, using the <tag>a</tag> with href and title attributes. GTK+ renders links similar to the way they appear in web browsers, with colored, underlined text. The title attribute is displayed as a tooltip on the link. An example looks like this: gtk_label_set_markup (label, "Go to the <a href="http://www.gtk.org" title="<i>Our</i> website">GTK+ website</a> for more..."); It is possible to implement custom handling for links and their tooltips with the Gtk.Label.Gtk_Label::activate-link signal and the Gtk.Label.Get_Current_Uri function.