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