1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.Label;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gobject.Signals;
31 private import gtk.Menu;
32 private import gtk.Misc;
33 private import gtk.Widget;
34 private import gtk.c.functions;
35 public  import gtk.c.types;
36 public  import gtkc.gtktypes;
37 private import pango.PgAttributeList;
38 private import pango.PgLayout;
39 private import std.algorithm;
40 
41 
42 /**
43  * The #GtkLabel widget displays a small amount of text. As the name
44  * implies, most labels are used to label another widget such as a
45  * #GtkButton, a #GtkMenuItem, or a #GtkComboBox.
46  * 
47  * # CSS nodes
48  * 
49  * |[<!-- language="plain" -->
50  * label
51  * ├── [selection]
52  * ├── [link]
53  * ┊
54  * ╰── [link]
55  * ]|
56  * 
57  * GtkLabel has a single CSS node with the name label. A wide variety
58  * of style classes may be applied to labels, such as .title, .subtitle,
59  * .dim-label, etc. In the #GtkShortcutsWindow, labels are used wth the
60  * .keycap style class.
61  * 
62  * If the label has a selection, it gets a subnode with name selection.
63  * 
64  * If the label has links, there is one subnode per link. These subnodes
65  * carry the link or visited state depending on whether they have been
66  * visited.
67  * 
68  * # GtkLabel as GtkBuildable
69  * 
70  * The GtkLabel implementation of the GtkBuildable interface supports a
71  * custom <attributes> element, which supports any number of <attribute>
72  * elements. The <attribute> element has attributes named “name“, “value“,
73  * “start“ and “end“ and allows you to specify #PangoAttribute values for
74  * this label.
75  * 
76  * An example of a UI definition fragment specifying Pango attributes:
77  * |[
78  * <object class="GtkLabel">
79  * <attributes>
80  * <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
81  * <attribute name="background" value="red" start="5" end="10"/>
82  * </attributes>
83  * </object>
84  * ]|
85  * 
86  * The start and end attributes specify the range of characters to which the
87  * Pango attribute applies. If start and end are not specified, the attribute is
88  * applied to the whole text. Note that specifying ranges does not make much
89  * sense with translatable attributes. Use markup embedded in the translatable
90  * content instead.
91  * 
92  * # Mnemonics
93  * 
94  * Labels may contain “mnemonics”. Mnemonics are
95  * underlined characters in the label, used for keyboard navigation.
96  * Mnemonics are created by providing a string with an underscore before
97  * the mnemonic character, such as `"_File"`, to the
98  * functions gtk_label_new_with_mnemonic() or
99  * gtk_label_set_text_with_mnemonic().
100  * 
101  * Mnemonics automatically activate any activatable widget the label is
102  * inside, such as a #GtkButton; if the label is not inside the
103  * mnemonic’s target widget, you have to tell the label about the target
104  * using gtk_label_set_mnemonic_widget(). Here’s a simple example where
105  * the label is inside a button:
106  * 
107  * |[<!-- language="C" -->
108  * // Pressing Alt+H will activate this button
109  * GtkWidget *button = gtk_button_new ();
110  * GtkWidget *label = gtk_label_new_with_mnemonic ("_Hello");
111  * gtk_container_add (GTK_CONTAINER (button), label);
112  * ]|
113  * 
114  * There’s a convenience function to create buttons with a mnemonic label
115  * already inside:
116  * 
117  * |[<!-- language="C" -->
118  * // Pressing Alt+H will activate this button
119  * GtkWidget *button = gtk_button_new_with_mnemonic ("_Hello");
120  * ]|
121  * 
122  * To create a mnemonic for a widget alongside the label, such as a
123  * #GtkEntry, you have to point the label at the entry with
124  * gtk_label_set_mnemonic_widget():
125  * 
126  * |[<!-- language="C" -->
127  * // Pressing Alt+H will focus the entry
128  * GtkWidget *entry = gtk_entry_new ();
129  * GtkWidget *label = gtk_label_new_with_mnemonic ("_Hello");
130  * gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
131  * ]|
132  * 
133  * # Markup (styled text)
134  * 
135  * To make it easy to format text in a label (changing colors,
136  * fonts, etc.), label text can be provided in a simple
137  * [markup format][PangoMarkupFormat].
138  * 
139  * Here’s how to create a label with a small font:
140  * |[<!-- language="C" -->
141  * GtkWidget *label = gtk_label_new (NULL);
142  * gtk_label_set_markup (GTK_LABEL (label), "<small>Small text</small>");
143  * ]|
144  * 
145  * (See [complete documentation][PangoMarkupFormat] of available
146  * tags in the Pango manual.)
147  * 
148  * The markup passed to gtk_label_set_markup() must be valid; for example,
149  * literal <, > and & characters must be escaped as &lt;, &gt;, and &amp;.
150  * If you pass text obtained from the user, file, or a network to
151  * gtk_label_set_markup(), you’ll want to escape it with
152  * g_markup_escape_text() or g_markup_printf_escaped().
153  * 
154  * Markup strings are just a convenient way to set the #PangoAttrList on
155  * a label; gtk_label_set_attributes() may be a simpler way to set
156  * attributes in some cases. Be careful though; #PangoAttrList tends to
157  * cause internationalization problems, unless you’re applying attributes
158  * to the entire string (i.e. unless you set the range of each attribute
159  * to [0, %G_MAXINT)). The reason is that specifying the start_index and
160  * end_index for a #PangoAttribute requires knowledge of the exact string
161  * being displayed, so translations will cause problems.
162  * 
163  * # Selectable labels
164  * 
165  * Labels can be made selectable with gtk_label_set_selectable().
166  * Selectable labels allow the user to copy the label contents to
167  * the clipboard. Only labels that contain useful-to-copy information
168  * — such as error messages — should be made selectable.
169  * 
170  * # Text layout # {#label-text-layout}
171  * 
172  * A label can contain any number of paragraphs, but will have
173  * performance problems if it contains more than a small number.
174  * Paragraphs are separated by newlines or other paragraph separators
175  * understood by Pango.
176  * 
177  * Labels can automatically wrap text if you call
178  * gtk_label_set_line_wrap().
179  * 
180  * gtk_label_set_justify() sets how the lines in a label align
181  * with one another. If you want to set how the label as a whole
182  * aligns in its available space, see the #GtkWidget:halign and
183  * #GtkWidget:valign properties.
184  * 
185  * The #GtkLabel:width-chars and #GtkLabel:max-width-chars properties
186  * can be used to control the size allocation of ellipsized or wrapped
187  * labels. For ellipsizing labels, if either is specified (and less
188  * than the actual text size), it is used as the minimum width, and the actual
189  * text size is used as the natural width of the label. For wrapping labels,
190  * width-chars is used as the minimum width, if specified, and max-width-chars
191  * is used as the natural width. Even if max-width-chars specified, wrapping
192  * labels will be rewrapped to use all of the available width.
193  * 
194  * Note that the interpretation of #GtkLabel:width-chars and
195  * #GtkLabel:max-width-chars has changed a bit with the introduction of
196  * [width-for-height geometry management.][geometry-management]
197  * 
198  * # Links
199  * 
200  * Since 2.18, GTK+ supports markup for clickable hyperlinks in addition
201  * to regular Pango markup. The markup for links is borrowed from HTML,
202  * using the `<a>` with “href“ and “title“ attributes. GTK+ renders links
203  * similar to the way they appear in web browsers, with colored, underlined
204  * text. The “title“ attribute is displayed as a tooltip on the link.
205  * 
206  * An example looks like this:
207  * 
208  * |[<!-- language="C" -->
209  * const gchar *text =
210  * "Go to the"
211  * "<a href=\"http://www.gtk.org title=\"&lt;i&gt;Our&lt;/i&gt; website\">"
212  * "GTK+ website</a> for more...";
213  * GtkWidget *label = gtk_label_new (NULL);
214  * gtk_label_set_markup (GTK_LABEL (label), text);
215  * ]|
216  * 
217  * It is possible to implement custom handling for links and their tooltips with
218  * the #GtkLabel::activate-link signal and the gtk_label_get_current_uri() function.
219  */
220 public class Label : Misc
221 {
222 	/** the main Gtk struct */
223 	protected GtkLabel* gtkLabel;
224 
225 	/** Get the main Gtk struct */
226 	public GtkLabel* getLabelStruct(bool transferOwnership = false)
227 	{
228 		if (transferOwnership)
229 			ownedRef = false;
230 		return gtkLabel;
231 	}
232 
233 	/** the main Gtk struct as a void* */
234 	protected override void* getStruct()
235 	{
236 		return cast(void*)gtkLabel;
237 	}
238 
239 	/**
240 	 * Sets our main struct and passes it to the parent class.
241 	 */
242 	public this (GtkLabel* gtkLabel, bool ownedRef = false)
243 	{
244 		this.gtkLabel = gtkLabel;
245 		super(cast(GtkMisc*)gtkLabel, ownedRef);
246 	}
247 
248 	/**
249 	 * Creates a new GtkLabel, containing the text in str.
250 	 * If characters in str are preceded by an underscore, they are
251 	 * underlined. If you need a literal underscore character in a label, use
252 	 * '__' (two underscores). The first underlined character represents a
253 	 * keyboard accelerator called a mnemonic. The mnemonic key can be used
254 	 * to activate another widget, chosen automatically, or explicitly using
255 	 * setMnemonicWidget().
256 	 *
257 	 * If setMnemonicWidget() is not called, then the first activatable ancestor of the Label
258 	 * will be chosen as the mnemonic widget. For instance, if the
259 	 * label is inside a button or menu item, the button or menu item will
260 	 * automatically become the mnemonic widget and be activated by
261 	 * the mnemonic.
262 	 * Params:
263 	 *  str = The text of the label, with an underscore in front of the
264 	 *  mnemonic character
265 	 *  mnemonic = when false uses the literal text passed in without mnemonic
266 	 * Throws: ConstructionException GTK+ fails to create the object.
267 	 */
268 	public this (string str, bool mnemonic=true)
269 	{
270 		GtkLabel* p;
271 
272 		if ( mnemonic )
273 		{
274 			// GtkWidget* gtk_label_new_with_mnemonic (const gchar *str);
275 			p = cast(GtkLabel*)gtk_label_new_with_mnemonic(Str.toStringz(str));
276 		}
277 		else
278 		{
279 			// GtkWidget* gtk_label_new (const gchar *str);
280 			p = cast(GtkLabel*)gtk_label_new(Str.toStringz(str));
281 		}
282 
283 		if(p is null)
284 		{
285 			throw new ConstructionException("null returned by gtk_label_new");
286 		}
287 
288 		this(p);
289 	}
290 
291 	/**
292 	 */
293 
294 	/** */
295 	public static GType getType()
296 	{
297 		return gtk_label_get_type();
298 	}
299 
300 	/**
301 	 * Gets the angle of rotation for the label. See
302 	 * gtk_label_set_angle().
303 	 *
304 	 * Returns: the angle of rotation for the label
305 	 *
306 	 * Since: 2.6
307 	 */
308 	public double getAngle()
309 	{
310 		return gtk_label_get_angle(gtkLabel);
311 	}
312 
313 	/**
314 	 * Gets the attribute list that was set on the label using
315 	 * gtk_label_set_attributes(), if any. This function does
316 	 * not reflect attributes that come from the labels markup
317 	 * (see gtk_label_set_markup()). If you want to get the
318 	 * effective attributes for the label, use
319 	 * pango_layout_get_attribute (gtk_label_get_layout (label)).
320 	 *
321 	 * Returns: the attribute list, or %NULL
322 	 *     if none was set.
323 	 */
324 	public PgAttributeList getAttributes()
325 	{
326 		auto p = gtk_label_get_attributes(gtkLabel);
327 
328 		if(p is null)
329 		{
330 			return null;
331 		}
332 
333 		return ObjectG.getDObject!(PgAttributeList)(cast(PangoAttrList*) p);
334 	}
335 
336 	/**
337 	 * Returns the URI for the currently active link in the label.
338 	 * The active link is the one under the mouse pointer or, in a
339 	 * selectable label, the link in which the text cursor is currently
340 	 * positioned.
341 	 *
342 	 * This function is intended for use in a #GtkLabel::activate-link handler
343 	 * or for use in a #GtkWidget::query-tooltip handler.
344 	 *
345 	 * Returns: the currently active URI. The string is owned by GTK+ and must
346 	 *     not be freed or modified.
347 	 *
348 	 * Since: 2.18
349 	 */
350 	public string getCurrentUri()
351 	{
352 		return Str.toString(gtk_label_get_current_uri(gtkLabel));
353 	}
354 
355 	/**
356 	 * Returns the ellipsizing position of the label. See gtk_label_set_ellipsize().
357 	 *
358 	 * Returns: #PangoEllipsizeMode
359 	 *
360 	 * Since: 2.6
361 	 */
362 	public PangoEllipsizeMode getEllipsize()
363 	{
364 		return gtk_label_get_ellipsize(gtkLabel);
365 	}
366 
367 	/**
368 	 * Returns the justification of the label. See gtk_label_set_justify().
369 	 *
370 	 * Returns: #GtkJustification
371 	 */
372 	public GtkJustification getJustify()
373 	{
374 		return gtk_label_get_justify(gtkLabel);
375 	}
376 
377 	/**
378 	 * Fetches the text from a label widget including any embedded
379 	 * underlines indicating mnemonics and Pango markup. (See
380 	 * gtk_label_get_text()).
381 	 *
382 	 * Returns: the text of the label widget. This string is
383 	 *     owned by the widget and must not be modified or freed.
384 	 */
385 	public string getLabel()
386 	{
387 		return Str.toString(gtk_label_get_label(gtkLabel));
388 	}
389 
390 	/**
391 	 * Gets the #PangoLayout used to display the label.
392 	 * The layout is useful to e.g. convert text positions to
393 	 * pixel positions, in combination with gtk_label_get_layout_offsets().
394 	 * The returned layout is owned by the @label so need not be
395 	 * freed by the caller. The @label is free to recreate its layout at
396 	 * any time, so it should be considered read-only.
397 	 *
398 	 * Returns: the #PangoLayout for this label
399 	 */
400 	public PgLayout getLayout()
401 	{
402 		auto p = gtk_label_get_layout(gtkLabel);
403 
404 		if(p is null)
405 		{
406 			return null;
407 		}
408 
409 		return ObjectG.getDObject!(PgLayout)(cast(PangoLayout*) p);
410 	}
411 
412 	/**
413 	 * Obtains the coordinates where the label will draw the #PangoLayout
414 	 * representing the text in the label; useful to convert mouse events
415 	 * into coordinates inside the #PangoLayout, e.g. to take some action
416 	 * if some part of the label is clicked. Of course you will need to
417 	 * create a #GtkEventBox to receive the events, and pack the label
418 	 * inside it, since labels are windowless (they return %FALSE from
419 	 * gtk_widget_get_has_window()). Remember
420 	 * when using the #PangoLayout functions you need to convert to
421 	 * and from pixels using PANGO_PIXELS() or #PANGO_SCALE.
422 	 *
423 	 * Params:
424 	 *     x = location to store X offset of layout, or %NULL
425 	 *     y = location to store Y offset of layout, or %NULL
426 	 */
427 	public void getLayoutOffsets(out int x, out int y)
428 	{
429 		gtk_label_get_layout_offsets(gtkLabel, &x, &y);
430 	}
431 
432 	/**
433 	 * Returns whether lines in the label are automatically wrapped.
434 	 * See gtk_label_set_line_wrap().
435 	 *
436 	 * Returns: %TRUE if the lines of the label are automatically wrapped.
437 	 */
438 	public bool getLineWrap()
439 	{
440 		return gtk_label_get_line_wrap(gtkLabel) != 0;
441 	}
442 
443 	/**
444 	 * Returns line wrap mode used by the label. See gtk_label_set_line_wrap_mode().
445 	 *
446 	 * Returns: %TRUE if the lines of the label are automatically wrapped.
447 	 *
448 	 * Since: 2.10
449 	 */
450 	public PangoWrapMode getLineWrapMode()
451 	{
452 		return gtk_label_get_line_wrap_mode(gtkLabel);
453 	}
454 
455 	/**
456 	 * Gets the number of lines to which an ellipsized, wrapping
457 	 * label should be limited. See gtk_label_set_lines().
458 	 *
459 	 * Returns: The number of lines
460 	 *
461 	 * Since: 3.10
462 	 */
463 	public int getLines()
464 	{
465 		return gtk_label_get_lines(gtkLabel);
466 	}
467 
468 	/**
469 	 * Retrieves the desired maximum width of @label, in characters. See
470 	 * gtk_label_set_width_chars().
471 	 *
472 	 * Returns: the maximum width of the label in characters.
473 	 *
474 	 * Since: 2.6
475 	 */
476 	public int getMaxWidthChars()
477 	{
478 		return gtk_label_get_max_width_chars(gtkLabel);
479 	}
480 
481 	/**
482 	 * If the label has been set so that it has an mnemonic key this function
483 	 * returns the keyval used for the mnemonic accelerator. If there is no
484 	 * mnemonic set up it returns #GDK_KEY_VoidSymbol.
485 	 *
486 	 * Returns: GDK keyval usable for accelerators, or #GDK_KEY_VoidSymbol
487 	 */
488 	public uint getMnemonicKeyval()
489 	{
490 		return gtk_label_get_mnemonic_keyval(gtkLabel);
491 	}
492 
493 	/**
494 	 * Retrieves the target of the mnemonic (keyboard shortcut) of this
495 	 * label. See gtk_label_set_mnemonic_widget().
496 	 *
497 	 * Returns: the target of the label’s mnemonic,
498 	 *     or %NULL if none has been set and the default algorithm will be used.
499 	 */
500 	public Widget getMnemonicWidget()
501 	{
502 		auto p = gtk_label_get_mnemonic_widget(gtkLabel);
503 
504 		if(p is null)
505 		{
506 			return null;
507 		}
508 
509 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
510 	}
511 
512 	/**
513 	 * Gets the value set by gtk_label_set_selectable().
514 	 *
515 	 * Returns: %TRUE if the user can copy text from the label
516 	 */
517 	public bool getSelectable()
518 	{
519 		return gtk_label_get_selectable(gtkLabel) != 0;
520 	}
521 
522 	/**
523 	 * Gets the selected range of characters in the label, returning %TRUE
524 	 * if there’s a selection.
525 	 *
526 	 * Params:
527 	 *     start = return location for start of selection, as a character offset
528 	 *     end = return location for end of selection, as a character offset
529 	 *
530 	 * Returns: %TRUE if selection is non-empty
531 	 */
532 	public bool getSelectionBounds(out int start, out int end)
533 	{
534 		return gtk_label_get_selection_bounds(gtkLabel, &start, &end) != 0;
535 	}
536 
537 	/**
538 	 * Returns whether the label is in single line mode.
539 	 *
540 	 * Returns: %TRUE when the label is in single line mode.
541 	 *
542 	 * Since: 2.6
543 	 */
544 	public bool getSingleLineMode()
545 	{
546 		return gtk_label_get_single_line_mode(gtkLabel) != 0;
547 	}
548 
549 	/**
550 	 * Fetches the text from a label widget, as displayed on the
551 	 * screen. This does not include any embedded underlines
552 	 * indicating mnemonics or Pango markup. (See gtk_label_get_label())
553 	 *
554 	 * Returns: the text in the label widget. This is the internal
555 	 *     string used by the label, and must not be modified.
556 	 */
557 	public string getText()
558 	{
559 		return Str.toString(gtk_label_get_text(gtkLabel));
560 	}
561 
562 	/**
563 	 * Returns whether the label is currently keeping track
564 	 * of clicked links.
565 	 *
566 	 * Returns: %TRUE if clicked links are remembered
567 	 *
568 	 * Since: 2.18
569 	 */
570 	public bool getTrackVisitedLinks()
571 	{
572 		return gtk_label_get_track_visited_links(gtkLabel) != 0;
573 	}
574 
575 	/**
576 	 * Returns whether the label’s text is interpreted as marked up with
577 	 * the [Pango text markup language][PangoMarkupFormat].
578 	 * See gtk_label_set_use_markup ().
579 	 *
580 	 * Returns: %TRUE if the label’s text will be parsed for markup.
581 	 */
582 	public bool getUseMarkup()
583 	{
584 		return gtk_label_get_use_markup(gtkLabel) != 0;
585 	}
586 
587 	/**
588 	 * Returns whether an embedded underline in the label indicates a
589 	 * mnemonic. See gtk_label_set_use_underline().
590 	 *
591 	 * Returns: %TRUE whether an embedded underline in the label indicates
592 	 *     the mnemonic accelerator keys.
593 	 */
594 	public bool getUseUnderline()
595 	{
596 		return gtk_label_get_use_underline(gtkLabel) != 0;
597 	}
598 
599 	/**
600 	 * Retrieves the desired width of @label, in characters. See
601 	 * gtk_label_set_width_chars().
602 	 *
603 	 * Returns: the width of the label in characters.
604 	 *
605 	 * Since: 2.6
606 	 */
607 	public int getWidthChars()
608 	{
609 		return gtk_label_get_width_chars(gtkLabel);
610 	}
611 
612 	/**
613 	 * Gets the #GtkLabel:xalign property for @label.
614 	 *
615 	 * Returns: the xalign property
616 	 *
617 	 * Since: 3.16
618 	 */
619 	public float getXalign()
620 	{
621 		return gtk_label_get_xalign(gtkLabel);
622 	}
623 
624 	/**
625 	 * Gets the #GtkLabel:yalign property for @label.
626 	 *
627 	 * Returns: the yalign property
628 	 *
629 	 * Since: 3.16
630 	 */
631 	public float getYalign()
632 	{
633 		return gtk_label_get_yalign(gtkLabel);
634 	}
635 
636 	/**
637 	 * Selects a range of characters in the label, if the label is selectable.
638 	 * See gtk_label_set_selectable(). If the label is not selectable,
639 	 * this function has no effect. If @start_offset or
640 	 * @end_offset are -1, then the end of the label will be substituted.
641 	 *
642 	 * Params:
643 	 *     startOffset = start offset (in characters not bytes)
644 	 *     endOffset = end offset (in characters not bytes)
645 	 */
646 	public void selectRegion(int startOffset, int endOffset)
647 	{
648 		gtk_label_select_region(gtkLabel, startOffset, endOffset);
649 	}
650 
651 	/**
652 	 * Sets the angle of rotation for the label. An angle of 90 reads from
653 	 * from bottom to top, an angle of 270, from top to bottom. The angle
654 	 * setting for the label is ignored if the label is selectable,
655 	 * wrapped, or ellipsized.
656 	 *
657 	 * Params:
658 	 *     angle = the angle that the baseline of the label makes with
659 	 *         the horizontal, in degrees, measured counterclockwise
660 	 *
661 	 * Since: 2.6
662 	 */
663 	public void setAngle(double angle)
664 	{
665 		gtk_label_set_angle(gtkLabel, angle);
666 	}
667 
668 	/**
669 	 * Sets a #PangoAttrList; the attributes in the list are applied to the
670 	 * label text.
671 	 *
672 	 * The attributes set with this function will be applied
673 	 * and merged with any other attributes previously effected by way
674 	 * of the #GtkLabel:use-underline or #GtkLabel:use-markup properties.
675 	 * While it is not recommended to mix markup strings with manually set
676 	 * attributes, if you must; know that the attributes will be applied
677 	 * to the label after the markup string is parsed.
678 	 *
679 	 * Params:
680 	 *     attrs = a #PangoAttrList, or %NULL
681 	 */
682 	public void setAttributes(PgAttributeList attrs)
683 	{
684 		gtk_label_set_attributes(gtkLabel, (attrs is null) ? null : attrs.getPgAttributeListStruct());
685 	}
686 
687 	/**
688 	 * Sets the mode used to ellipsize (add an ellipsis: "...") to the text
689 	 * if there is not enough space to render the entire string.
690 	 *
691 	 * Params:
692 	 *     mode = a #PangoEllipsizeMode
693 	 *
694 	 * Since: 2.6
695 	 */
696 	public void setEllipsize(PangoEllipsizeMode mode)
697 	{
698 		gtk_label_set_ellipsize(gtkLabel, mode);
699 	}
700 
701 	/**
702 	 * Sets the alignment of the lines in the text of the label relative to
703 	 * each other. %GTK_JUSTIFY_LEFT is the default value when the widget is
704 	 * first created with gtk_label_new(). If you instead want to set the
705 	 * alignment of the label as a whole, use gtk_widget_set_halign() instead.
706 	 * gtk_label_set_justify() has no effect on labels containing only a
707 	 * single line.
708 	 *
709 	 * Params:
710 	 *     jtype = a #GtkJustification
711 	 */
712 	public void setJustify(GtkJustification jtype)
713 	{
714 		gtk_label_set_justify(gtkLabel, jtype);
715 	}
716 
717 	/**
718 	 * Sets the text of the label. The label is interpreted as
719 	 * including embedded underlines and/or Pango markup depending
720 	 * on the values of the #GtkLabel:use-underline and
721 	 * #GtkLabel:use-markup properties.
722 	 *
723 	 * Params:
724 	 *     str = the new text to set for the label
725 	 */
726 	public void setLabel(string str)
727 	{
728 		gtk_label_set_label(gtkLabel, Str.toStringz(str));
729 	}
730 
731 	/**
732 	 * Toggles line wrapping within the #GtkLabel widget. %TRUE makes it break
733 	 * lines if text exceeds the widget’s size. %FALSE lets the text get cut off
734 	 * by the edge of the widget if it exceeds the widget size.
735 	 *
736 	 * Note that setting line wrapping to %TRUE does not make the label
737 	 * wrap at its parent container’s width, because GTK+ widgets
738 	 * conceptually can’t make their requisition depend on the parent
739 	 * container’s size. For a label that wraps at a specific position,
740 	 * set the label’s width using gtk_widget_set_size_request().
741 	 *
742 	 * Params:
743 	 *     wrap = the setting
744 	 */
745 	public void setLineWrap(bool wrap)
746 	{
747 		gtk_label_set_line_wrap(gtkLabel, wrap);
748 	}
749 
750 	/**
751 	 * If line wrapping is on (see gtk_label_set_line_wrap()) this controls how
752 	 * the line wrapping is done. The default is %PANGO_WRAP_WORD which means
753 	 * wrap on word boundaries.
754 	 *
755 	 * Params:
756 	 *     wrapMode = the line wrapping mode
757 	 *
758 	 * Since: 2.10
759 	 */
760 	public void setLineWrapMode(PangoWrapMode wrapMode)
761 	{
762 		gtk_label_set_line_wrap_mode(gtkLabel, wrapMode);
763 	}
764 
765 	/**
766 	 * Sets the number of lines to which an ellipsized, wrapping label
767 	 * should be limited. This has no effect if the label is not wrapping
768 	 * or ellipsized. Set this to -1 if you don’t want to limit the
769 	 * number of lines.
770 	 *
771 	 * Params:
772 	 *     lines = the desired number of lines, or -1
773 	 *
774 	 * Since: 3.10
775 	 */
776 	public void setLines(int lines)
777 	{
778 		gtk_label_set_lines(gtkLabel, lines);
779 	}
780 
781 	/**
782 	 * Parses @str which is marked up with the
783 	 * [Pango text markup language][PangoMarkupFormat], setting the
784 	 * label’s text and attribute list based on the parse results.
785 	 *
786 	 * If the @str is external data, you may need to escape it with
787 	 * g_markup_escape_text() or g_markup_printf_escaped():
788 	 *
789 	 * |[<!-- language="C" -->
790 	 * GtkWidget *label = gtk_label_new (NULL);
791 	 * const char *str = "some text";
792 	 * const char *format = "<span style=\"italic\">\%s</span>";
793 	 * char *markup;
794 	 *
795 	 * markup = g_markup_printf_escaped (format, str);
796 	 * gtk_label_set_markup (GTK_LABEL (label), markup);
797 	 * g_free (markup);
798 	 * ]|
799 	 *
800 	 * This function will set the #GtkLabel:use-markup property to %TRUE as
801 	 * a side effect.
802 	 *
803 	 * If you set the label contents using the #GtkLabel:label property you
804 	 * should also ensure that you set the #GtkLabel:use-markup property
805 	 * accordingly.
806 	 *
807 	 * See also: gtk_label_set_text()
808 	 *
809 	 * Params:
810 	 *     str = a markup string (see [Pango markup format][PangoMarkupFormat])
811 	 */
812 	public void setMarkup(string str)
813 	{
814 		gtk_label_set_markup(gtkLabel, Str.toStringz(str));
815 	}
816 
817 	/**
818 	 * Parses @str which is marked up with the
819 	 * [Pango text markup language][PangoMarkupFormat],
820 	 * setting the label’s text and attribute list based on the parse results.
821 	 * If characters in @str are preceded by an underscore, they are underlined
822 	 * indicating that they represent a keyboard accelerator called a mnemonic.
823 	 *
824 	 * The mnemonic key can be used to activate another widget, chosen
825 	 * automatically, or explicitly using gtk_label_set_mnemonic_widget().
826 	 *
827 	 * Params:
828 	 *     str = a markup string (see
829 	 *         [Pango markup format][PangoMarkupFormat])
830 	 */
831 	public void setMarkupWithMnemonic(string str)
832 	{
833 		gtk_label_set_markup_with_mnemonic(gtkLabel, Str.toStringz(str));
834 	}
835 
836 	/**
837 	 * Sets the desired maximum width in characters of @label to @n_chars.
838 	 *
839 	 * Params:
840 	 *     nChars = the new desired maximum width, in characters.
841 	 *
842 	 * Since: 2.6
843 	 */
844 	public void setMaxWidthChars(int nChars)
845 	{
846 		gtk_label_set_max_width_chars(gtkLabel, nChars);
847 	}
848 
849 	/**
850 	 * If the label has been set so that it has an mnemonic key (using
851 	 * i.e. gtk_label_set_markup_with_mnemonic(),
852 	 * gtk_label_set_text_with_mnemonic(), gtk_label_new_with_mnemonic()
853 	 * or the “use_underline” property) the label can be associated with a
854 	 * widget that is the target of the mnemonic. When the label is inside
855 	 * a widget (like a #GtkButton or a #GtkNotebook tab) it is
856 	 * automatically associated with the correct widget, but sometimes
857 	 * (i.e. when the target is a #GtkEntry next to the label) you need to
858 	 * set it explicitly using this function.
859 	 *
860 	 * The target widget will be accelerated by emitting the
861 	 * GtkWidget::mnemonic-activate signal on it. The default handler for
862 	 * this signal will activate the widget if there are no mnemonic collisions
863 	 * and toggle focus between the colliding widgets otherwise.
864 	 *
865 	 * Params:
866 	 *     widget = the target #GtkWidget, or %NULL to unset
867 	 */
868 	public void setMnemonicWidget(Widget widget)
869 	{
870 		gtk_label_set_mnemonic_widget(gtkLabel, (widget is null) ? null : widget.getWidgetStruct());
871 	}
872 
873 	/**
874 	 * The pattern of underlines you want under the existing text within the
875 	 * #GtkLabel widget.  For example if the current text of the label says
876 	 * “FooBarBaz” passing a pattern of “___   ___” will underline
877 	 * “Foo” and “Baz” but not “Bar”.
878 	 *
879 	 * Params:
880 	 *     pattern = The pattern as described above.
881 	 */
882 	public void setPattern(string pattern)
883 	{
884 		gtk_label_set_pattern(gtkLabel, Str.toStringz(pattern));
885 	}
886 
887 	/**
888 	 * Selectable labels allow the user to select text from the label, for
889 	 * copy-and-paste.
890 	 *
891 	 * Params:
892 	 *     setting = %TRUE to allow selecting text in the label
893 	 */
894 	public void setSelectable(bool setting)
895 	{
896 		gtk_label_set_selectable(gtkLabel, setting);
897 	}
898 
899 	/**
900 	 * Sets whether the label is in single line mode.
901 	 *
902 	 * Params:
903 	 *     singleLineMode = %TRUE if the label should be in single line mode
904 	 *
905 	 * Since: 2.6
906 	 */
907 	public void setSingleLineMode(bool singleLineMode)
908 	{
909 		gtk_label_set_single_line_mode(gtkLabel, singleLineMode);
910 	}
911 
912 	/**
913 	 * Sets the text within the #GtkLabel widget. It overwrites any text that
914 	 * was there before.
915 	 *
916 	 * This function will clear any previously set mnemonic accelerators, and
917 	 * set the #GtkLabel:use-underline property to %FALSE as a side effect.
918 	 *
919 	 * This function will set the #GtkLabel:use-markup property to %FALSE
920 	 * as a side effect.
921 	 *
922 	 * See also: gtk_label_set_markup()
923 	 *
924 	 * Params:
925 	 *     str = The text you want to set
926 	 */
927 	public void setText(string str)
928 	{
929 		gtk_label_set_text(gtkLabel, Str.toStringz(str));
930 	}
931 
932 	/**
933 	 * Sets the label’s text from the string @str.
934 	 * If characters in @str are preceded by an underscore, they are underlined
935 	 * indicating that they represent a keyboard accelerator called a mnemonic.
936 	 * The mnemonic key can be used to activate another widget, chosen
937 	 * automatically, or explicitly using gtk_label_set_mnemonic_widget().
938 	 *
939 	 * Params:
940 	 *     str = a string
941 	 */
942 	public void setTextWithMnemonic(string str)
943 	{
944 		gtk_label_set_text_with_mnemonic(gtkLabel, Str.toStringz(str));
945 	}
946 
947 	/**
948 	 * Sets whether the label should keep track of clicked
949 	 * links (and use a different color for them).
950 	 *
951 	 * Params:
952 	 *     trackLinks = %TRUE to track visited links
953 	 *
954 	 * Since: 2.18
955 	 */
956 	public void setTrackVisitedLinks(bool trackLinks)
957 	{
958 		gtk_label_set_track_visited_links(gtkLabel, trackLinks);
959 	}
960 
961 	/**
962 	 * Sets whether the text of the label contains markup in
963 	 * [Pango’s text markup language][PangoMarkupFormat].
964 	 * See gtk_label_set_markup().
965 	 *
966 	 * Params:
967 	 *     setting = %TRUE if the label’s text should be parsed for markup.
968 	 */
969 	public void setUseMarkup(bool setting)
970 	{
971 		gtk_label_set_use_markup(gtkLabel, setting);
972 	}
973 
974 	/**
975 	 * If true, an underline in the text indicates the next character should be
976 	 * used for the mnemonic accelerator key.
977 	 *
978 	 * Params:
979 	 *     setting = %TRUE if underlines in the text indicate mnemonics
980 	 */
981 	public void setUseUnderline(bool setting)
982 	{
983 		gtk_label_set_use_underline(gtkLabel, setting);
984 	}
985 
986 	/**
987 	 * Sets the desired width in characters of @label to @n_chars.
988 	 *
989 	 * Params:
990 	 *     nChars = the new desired width, in characters.
991 	 *
992 	 * Since: 2.6
993 	 */
994 	public void setWidthChars(int nChars)
995 	{
996 		gtk_label_set_width_chars(gtkLabel, nChars);
997 	}
998 
999 	/**
1000 	 * Sets the #GtkLabel:xalign property for @label.
1001 	 *
1002 	 * Params:
1003 	 *     xalign = the new xalign value, between 0 and 1
1004 	 *
1005 	 * Since: 3.16
1006 	 */
1007 	public void setXalign(float xalign)
1008 	{
1009 		gtk_label_set_xalign(gtkLabel, xalign);
1010 	}
1011 
1012 	/**
1013 	 * Sets the #GtkLabel:yalign property for @label.
1014 	 *
1015 	 * Params:
1016 	 *     yalign = the new yalign value, between 0 and 1
1017 	 *
1018 	 * Since: 3.16
1019 	 */
1020 	public void setYalign(float yalign)
1021 	{
1022 		gtk_label_set_yalign(gtkLabel, yalign);
1023 	}
1024 
1025 	/**
1026 	 * A [keybinding signal][GtkBindingSignal]
1027 	 * which gets emitted when the user activates a link in the label.
1028 	 *
1029 	 * Applications may also emit the signal with g_signal_emit_by_name()
1030 	 * if they need to control activation of URIs programmatically.
1031 	 *
1032 	 * The default bindings for this signal are all forms of the Enter key.
1033 	 *
1034 	 * Since: 2.18
1035 	 */
1036 	gulong addOnActivateCurrentLink(void delegate(Label) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1037 	{
1038 		return Signals.connect(this, "activate-current-link", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1039 	}
1040 
1041 	/**
1042 	 * The signal which gets emitted to activate a URI.
1043 	 * Applications may connect to it to override the default behaviour,
1044 	 * which is to call gtk_show_uri_on_window().
1045 	 *
1046 	 * Params:
1047 	 *     uri = the URI that is activated
1048 	 *
1049 	 * Returns: %TRUE if the link has been activated
1050 	 *
1051 	 * Since: 2.18
1052 	 */
1053 	gulong addOnActivateLink(bool delegate(string, Label) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1054 	{
1055 		return Signals.connect(this, "activate-link", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1056 	}
1057 
1058 	/**
1059 	 * The ::copy-clipboard signal is a
1060 	 * [keybinding signal][GtkBindingSignal]
1061 	 * which gets emitted to copy the selection to the clipboard.
1062 	 *
1063 	 * The default binding for this signal is Ctrl-c.
1064 	 */
1065 	gulong addOnCopyClipboard(void delegate(Label) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1066 	{
1067 		return Signals.connect(this, "copy-clipboard", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1068 	}
1069 
1070 	/**
1071 	 * The ::move-cursor signal is a
1072 	 * [keybinding signal][GtkBindingSignal]
1073 	 * which gets emitted when the user initiates a cursor movement.
1074 	 * If the cursor is not visible in @entry, this signal causes
1075 	 * the viewport to be moved instead.
1076 	 *
1077 	 * Applications should not connect to it, but may emit it with
1078 	 * g_signal_emit_by_name() if they need to control the cursor
1079 	 * programmatically.
1080 	 *
1081 	 * The default bindings for this signal come in two variants,
1082 	 * the variant with the Shift modifier extends the selection,
1083 	 * the variant without the Shift modifer does not.
1084 	 * There are too many key combinations to list them all here.
1085 	 * - Arrow keys move by individual characters/lines
1086 	 * - Ctrl-arrow key combinations move by words/paragraphs
1087 	 * - Home/End keys move to the ends of the buffer
1088 	 *
1089 	 * Params:
1090 	 *     step = the granularity of the move, as a #GtkMovementStep
1091 	 *     count = the number of @step units to move
1092 	 *     extendSelection = %TRUE if the move should extend the selection
1093 	 */
1094 	gulong addOnMoveCursor(void delegate(GtkMovementStep, int, bool, Label) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1095 	{
1096 		return Signals.connect(this, "move-cursor", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1097 	}
1098 
1099 	/**
1100 	 * The ::populate-popup signal gets emitted before showing the
1101 	 * context menu of the label. Note that only selectable labels
1102 	 * have context menus.
1103 	 *
1104 	 * If you need to add items to the context menu, connect
1105 	 * to this signal and append your menuitems to the @menu.
1106 	 *
1107 	 * Params:
1108 	 *     menu = the menu that is being populated
1109 	 */
1110 	gulong addOnPopulatePopup(void delegate(Menu, Label) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1111 	{
1112 		return Signals.connect(this, "populate-popup", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1113 	}
1114 }