gtk4/auto/tooltip.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{Widget, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// s markup, setting an image from a named icon, or even
10 /// putting in a custom widget.
11 ///
12 /// - Return [`true`] from your ::query-tooltip handler. This causes the tooltip
13 /// to be show. If you return [`false`], it will not be shown.
14 ///
15 /// # Implements
16 ///
17 /// [`trait@glib::ObjectExt`]
18 #[doc(alias = "GtkTooltip")]
19 pub struct Tooltip(Object<ffi::GtkTooltip>);
20
21 match fn {
22 type_ => || ffi::gtk_tooltip_get_type(),
23 }
24}
25
26impl Tooltip {
27 /// Replaces the widget packed into the tooltip with
28 /// @custom_widget. @custom_widget does not get destroyed when the tooltip goes
29 /// away.
30 /// By default a box with a [`Image`][crate::Image] and [`Label`][crate::Label] is embedded in
31 /// the tooltip, which can be configured using gtk_tooltip_set_markup()
32 /// and gtk_tooltip_set_icon().
33 /// ## `custom_widget`
34 /// a [`Widget`][crate::Widget], or [`None`] to unset the old custom widget.
35 #[doc(alias = "gtk_tooltip_set_custom")]
36 pub fn set_custom(&self, custom_widget: Option<&impl IsA<Widget>>) {
37 unsafe {
38 ffi::gtk_tooltip_set_custom(
39 self.to_glib_none().0,
40 custom_widget.map(|p| p.as_ref()).to_glib_none().0,
41 );
42 }
43 }
44
45 /// Sets the icon of the tooltip (which is in front of the text) to be
46 /// @paintable. If @paintable is [`None`], the image will be hidden.
47 /// ## `paintable`
48 /// a [`gdk::Paintable`][crate::gdk::Paintable]
49 #[doc(alias = "gtk_tooltip_set_icon")]
50 pub fn set_icon(&self, paintable: Option<&impl IsA<gdk::Paintable>>) {
51 unsafe {
52 ffi::gtk_tooltip_set_icon(
53 self.to_glib_none().0,
54 paintable.map(|p| p.as_ref()).to_glib_none().0,
55 );
56 }
57 }
58
59 /// Sets the icon of the tooltip (which is in front of the text)
60 /// to be the icon indicated by @gicon with the size indicated
61 /// by @size. If @gicon is [`None`], the image will be hidden.
62 /// ## `gicon`
63 /// a `GIcon` representing the icon
64 #[doc(alias = "gtk_tooltip_set_icon_from_gicon")]
65 pub fn set_icon_from_gicon(&self, gicon: Option<&impl IsA<gio::Icon>>) {
66 unsafe {
67 ffi::gtk_tooltip_set_icon_from_gicon(
68 self.to_glib_none().0,
69 gicon.map(|p| p.as_ref()).to_glib_none().0,
70 );
71 }
72 }
73
74 /// Sets the icon of the tooltip (which is in front of the text) to be
75 /// the icon indicated by @icon_name with the size indicated
76 /// by @size. If @icon_name is [`None`], the image will be hidden.
77 /// ## `icon_name`
78 /// an icon name
79 #[doc(alias = "gtk_tooltip_set_icon_from_icon_name")]
80 pub fn set_icon_from_icon_name(&self, icon_name: Option<&str>) {
81 unsafe {
82 ffi::gtk_tooltip_set_icon_from_icon_name(
83 self.to_glib_none().0,
84 icon_name.to_glib_none().0,
85 );
86 }
87 }
88
89 /// Sets the text of the tooltip to be @markup.
90 ///
91 /// The string must be marked up with Pango markup.
92 /// If @markup is [`None`], the label will be hidden.
93 /// ## `markup`
94 /// a string with Pango markup or `NLL`
95 #[doc(alias = "gtk_tooltip_set_markup")]
96 pub fn set_markup(&self, markup: Option<&str>) {
97 unsafe {
98 ffi::gtk_tooltip_set_markup(self.to_glib_none().0, markup.to_glib_none().0);
99 }
100 }
101
102 /// Sets the text of the tooltip to be @text.
103 ///
104 /// If @text is [`None`], the label will be hidden.
105 /// See also [`set_markup()`][Self::set_markup()].
106 /// ## `text`
107 /// a text string
108 #[doc(alias = "gtk_tooltip_set_text")]
109 pub fn set_text(&self, text: Option<&str>) {
110 unsafe {
111 ffi::gtk_tooltip_set_text(self.to_glib_none().0, text.to_glib_none().0);
112 }
113 }
114
115 /// Sets the area of the widget, where the contents of this tooltip apply,
116 /// to be @rect (in widget coordinates). This is especially useful for
117 /// properly setting tooltips on [`TreeView`][crate::TreeView] rows and cells, `GtkIconViews`,
118 /// etc.
119 ///
120 /// For setting tooltips on [`TreeView`][crate::TreeView], please refer to the convenience
121 /// functions for this: gtk_tree_view_set_tooltip_row() and
122 /// gtk_tree_view_set_tooltip_cell().
123 /// ## `rect`
124 /// a [`gdk::Rectangle`][crate::gdk::Rectangle]
125 #[doc(alias = "gtk_tooltip_set_tip_area")]
126 pub fn set_tip_area(&self, rect: &gdk::Rectangle) {
127 unsafe {
128 ffi::gtk_tooltip_set_tip_area(self.to_glib_none().0, rect.to_glib_none().0);
129 }
130 }
131}