1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::Widget;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
glib::wrapper! {
/// [`Tooltip`][crate::Tooltip] is an object representing a widget tooltip.
///
/// Basic tooltips can be realized simply by using
/// [`WidgetExt::set_tooltip_text()`][crate::prelude::WidgetExt::set_tooltip_text()] or
/// [`WidgetExt::set_tooltip_markup()`][crate::prelude::WidgetExt::set_tooltip_markup()] without
/// any explicit tooltip object.
///
/// When you need a tooltip with a little more fancy contents,
/// like adding an image, or you want the tooltip to have different
/// contents per [`TreeView`][crate::TreeView] row or cell, you will have to do a
/// little more work:
///
/// - Set the `property::Widget::has-tooltip` property to [`true`].
/// This will make GTK monitor the widget for motion and related events
/// which are needed to determine when and where to show a tooltip.
///
/// - Connect to the `signal::Widget::query-tooltip` signal.
/// This signal will be emitted when a tooltip is supposed to be shown.
/// One of the arguments passed to the signal handler is a [`Tooltip`][crate::Tooltip]
/// object. This is the object that we are about to display as a tooltip,
/// and can be manipulated in your callback using functions like
/// [`set_icon()`][Self::set_icon()]. There are functions for setting
/// the tooltip’s markup, setting an image from a named icon, or even
/// putting in a custom widget.
///
/// - Return [`true`] from your ::query-tooltip handler. This causes the tooltip
/// to be show. If you return [`false`], it will not be shown.
///
/// # Implements
///
/// [`trait@glib::ObjectExt`]
#[doc(alias = "GtkTooltip")]
pub struct Tooltip(Object<ffi::GtkTooltip>);
match fn {
type_ => || ffi::gtk_tooltip_get_type(),
}
}
impl Tooltip {
/// Replaces the widget packed into the tooltip with
/// @custom_widget. @custom_widget does not get destroyed when the tooltip goes
/// away.
/// By default a box with a [`Image`][crate::Image] and [`Label`][crate::Label] is embedded in
/// the tooltip, which can be configured using gtk_tooltip_set_markup()
/// and gtk_tooltip_set_icon().
/// ## `custom_widget`
/// a [`Widget`][crate::Widget], or [`None`] to unset the old custom widget.
#[doc(alias = "gtk_tooltip_set_custom")]
pub fn set_custom(&self, custom_widget: Option<&impl IsA<Widget>>) {
unsafe {
ffi::gtk_tooltip_set_custom(
self.to_glib_none().0,
custom_widget.map(|p| p.as_ref()).to_glib_none().0,
);
}
}
/// Sets the icon of the tooltip (which is in front of the text) to be
/// @paintable. If @paintable is [`None`], the image will be hidden.
/// ## `paintable`
/// a [`gdk::Paintable`][crate::gdk::Paintable]
#[doc(alias = "gtk_tooltip_set_icon")]
pub fn set_icon(&self, paintable: Option<&impl IsA<gdk::Paintable>>) {
unsafe {
ffi::gtk_tooltip_set_icon(
self.to_glib_none().0,
paintable.map(|p| p.as_ref()).to_glib_none().0,
);
}
}
/// Sets the icon of the tooltip (which is in front of the text)
/// to be the icon indicated by @gicon with the size indicated
/// by @size. If @gicon is [`None`], the image will be hidden.
/// ## `gicon`
/// a `GIcon` representing the icon
#[doc(alias = "gtk_tooltip_set_icon_from_gicon")]
pub fn set_icon_from_gicon(&self, gicon: Option<&impl IsA<gio::Icon>>) {
unsafe {
ffi::gtk_tooltip_set_icon_from_gicon(
self.to_glib_none().0,
gicon.map(|p| p.as_ref()).to_glib_none().0,
);
}
}
/// Sets the icon of the tooltip (which is in front of the text) to be
/// the icon indicated by @icon_name with the size indicated
/// by @size. If @icon_name is [`None`], the image will be hidden.
/// ## `icon_name`
/// an icon name
#[doc(alias = "gtk_tooltip_set_icon_from_icon_name")]
pub fn set_icon_from_icon_name(&self, icon_name: Option<&str>) {
unsafe {
ffi::gtk_tooltip_set_icon_from_icon_name(
self.to_glib_none().0,
icon_name.to_glib_none().0,
);
}
}
/// Sets the text of the tooltip to be @markup.
///
/// The string must be marked up with Pango markup.
/// If @markup is [`None`], the label will be hidden.
/// ## `markup`
/// a string with Pango markup or `NLL`
#[doc(alias = "gtk_tooltip_set_markup")]
pub fn set_markup(&self, markup: Option<&str>) {
unsafe {
ffi::gtk_tooltip_set_markup(self.to_glib_none().0, markup.to_glib_none().0);
}
}
/// Sets the text of the tooltip to be @text.
///
/// If @text is [`None`], the label will be hidden.
/// See also [`set_markup()`][Self::set_markup()].
/// ## `text`
/// a text string
#[doc(alias = "gtk_tooltip_set_text")]
pub fn set_text(&self, text: Option<&str>) {
unsafe {
ffi::gtk_tooltip_set_text(self.to_glib_none().0, text.to_glib_none().0);
}
}
/// Sets the area of the widget, where the contents of this tooltip apply,
/// to be @rect (in widget coordinates). This is especially useful for
/// properly setting tooltips on [`TreeView`][crate::TreeView] rows and cells, `GtkIconViews`,
/// etc.
///
/// For setting tooltips on [`TreeView`][crate::TreeView], please refer to the convenience
/// functions for this: gtk_tree_view_set_tooltip_row() and
/// gtk_tree_view_set_tooltip_cell().
/// ## `rect`
/// a [`gdk::Rectangle`][crate::gdk::Rectangle]
#[doc(alias = "gtk_tooltip_set_tip_area")]
pub fn set_tip_area(&self, rect: &gdk::Rectangle) {
unsafe {
ffi::gtk_tooltip_set_tip_area(self.to_glib_none().0, rect.to_glib_none().0);
}
}
}
impl fmt::Display for Tooltip {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Tooltip")
}
}