gtk4/auto/
functions.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
5#[cfg(target_os = "linux")]
6#[cfg_attr(docsrs, doc(cfg(target_os = "linux")))]
7use crate::Printer;
8use crate::{
9    ffi, Accessible, AccessibleProperty, AccessibleRelation, AccessibleRole, AccessibleState,
10    DebugFlags, PageSetup, PrintSettings, StyleContext, TextDirection, TreeModel, TreePath, Widget,
11    Window,
12};
13use glib::{prelude::*, translate::*};
14use std::boxed::Box as Box_;
15
16/// Generates an accessible description of an accelerator.
17///
18/// This function is similar to [`accelerator_get_label()`][crate::accelerator_get_label()] but it is meant
19/// for accessibility layers labels rather than user-facing labels. The output
20/// of this function is fit for [enum@Gtk.AccessibleProperty.KEY_SHORTCUTS].
21///
22/// For more information, see the [WAI-ARIA](https://www.w3.org/TR/wai-aria/#aria-keyshortcuts)
23/// reference.
24/// ## `accelerator_key`
25/// accelerator keyval
26/// ## `accelerator_mods`
27/// accelerator modifier mask
28///
29/// # Returns
30///
31/// a newly-allocated string representing the accelerator
32#[cfg(feature = "v4_22")]
33#[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
34#[doc(alias = "gtk_accelerator_get_accessible_label")]
35pub fn accelerator_get_accessible_label(
36    accelerator_key: u32,
37    accelerator_mods: gdk::ModifierType,
38) -> glib::GString {
39    assert_initialized_main_thread!();
40    unsafe {
41        from_glib_full(ffi::gtk_accelerator_get_accessible_label(
42            accelerator_key,
43            accelerator_mods.into_glib(),
44        ))
45    }
46}
47
48/// Gets the modifier mask.
49///
50/// The modifier mask determines which modifiers are considered significant
51/// for keyboard accelerators. This includes all keyboard modifiers except
52/// for `GDK_LOCK_MASK`.
53///
54/// # Returns
55///
56/// the modifier mask for accelerators
57#[doc(alias = "gtk_accelerator_get_default_mod_mask")]
58pub fn accelerator_get_default_mod_mask() -> gdk::ModifierType {
59    assert_initialized_main_thread!();
60    unsafe { from_glib(ffi::gtk_accelerator_get_default_mod_mask()) }
61}
62
63/// Checks that the GTK library in use is compatible with the
64/// given version.
65///
66/// Generally you would pass in the constants `GTK_MAJOR_VERSION`,
67/// `GTK_MINOR_VERSION`, `GTK_MICRO_VERSION` as the three arguments
68/// to this function; that produces a check that the library in
69/// use is compatible with the version of GTK the application or
70/// module was compiled against.
71///
72/// Compatibility is defined by two things: first the version
73/// of the running library is newer than the version
74/// @required_major.required_minor.@required_micro. Second
75/// the running library must be binary compatible with the
76/// version @required_major.required_minor.@required_micro
77/// (same major version.)
78///
79/// This function is primarily for GTK modules; the module
80/// can call this function to check that it wasn’t loaded
81/// into an incompatible version of GTK. However, such a
82/// check isn’t completely reliable, since the module may be
83/// linked against an old version of GTK and calling the
84/// old version of gtk_check_version(), but still get loaded
85/// into an application using a newer version of GTK.
86/// ## `required_major`
87/// the required major version
88/// ## `required_minor`
89/// the required minor version
90/// ## `required_micro`
91/// the required micro version
92///
93/// # Returns
94///
95/// [`None`] if the GTK library is compatible with the
96///   given version, or a string describing the version mismatch.
97///   The returned string is owned by GTK and should not be modified
98///   or freed.
99#[doc(alias = "gtk_check_version")]
100pub fn check_version(
101    required_major: u32,
102    required_minor: u32,
103    required_micro: u32,
104) -> Option<glib::GString> {
105    skip_assert_initialized!();
106    unsafe {
107        from_glib_none(ffi::gtk_check_version(
108            required_major,
109            required_minor,
110            required_micro,
111        ))
112    }
113}
114
115/// Prevents GTK from using the specified portals.
116///
117/// This should only be used in portal implementations, apps must not call it.
118/// ## `portal_interfaces`
119///
120///     a [`None`]-terminated array of portal interface names to disable
121#[cfg(feature = "v4_22")]
122#[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
123#[doc(alias = "gtk_disable_portal_interfaces")]
124pub fn disable_portal_interfaces(portal_interfaces: &[&str]) {
125    assert_initialized_main_thread!();
126    unsafe {
127        ffi::gtk_disable_portal_interfaces(portal_interfaces.to_glib_none().0);
128    }
129}
130
131/// Prevents GTK from using portals.
132///
133/// This is equivalent to setting `GDK_DEBUG=no-portals` in the environment.
134///
135/// This should only be used in portal implementations, apps must not call it.
136#[cfg(feature = "v4_18")]
137#[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
138#[doc(alias = "gtk_disable_portals")]
139pub fn disable_portals() {
140    assert_not_initialized!();
141    unsafe {
142        ffi::gtk_disable_portals();
143    }
144}
145
146/// Prevents [`init()`][crate::init()] and `init_check()` from calling `setlocale()`.
147///
148/// You would want to use this function if you wanted to set the locale for
149/// your program to something other than the user’s locale, or if you wanted
150/// to set different values for different locale categories.
151///
152/// Most programs should not need to call this function.
153#[doc(alias = "gtk_disable_setlocale")]
154pub fn disable_setlocale() {
155    assert_not_initialized!();
156    unsafe {
157        ffi::gtk_disable_setlocale();
158    }
159}
160
161//#[doc(alias = "gtk_distribute_natural_allocation")]
162//pub fn distribute_natural_allocation(extra_space: i32, sizes: /*Ignored*/&[RequestedSize]) -> i32 {
163//    unsafe { TODO: call ffi:gtk_distribute_natural_allocation() }
164//}
165
166/// Calls a function for all printers that are known to GTK.
167///
168/// If @func returns true, the enumeration is stopped.
169/// ## `func`
170/// a function to call for each printer
171/// ## `wait`
172/// if true, wait in a recursive mainloop until
173///    all printers are enumerated; otherwise return early
174#[cfg(target_os = "linux")]
175#[cfg_attr(docsrs, doc(cfg(target_os = "linux")))]
176#[doc(alias = "gtk_enumerate_printers")]
177pub fn enumerate_printers<P: Fn(&Printer) -> bool + Send + Sync + 'static>(func: P, wait: bool) {
178    assert_initialized_main_thread!();
179    let func_data: Box_<P> = Box_::new(func);
180    unsafe extern "C" fn func_func<P: Fn(&Printer) -> bool + Send + Sync + 'static>(
181        printer: *mut ffi::GtkPrinter,
182        data: glib::ffi::gpointer,
183    ) -> glib::ffi::gboolean {
184        let printer = from_glib_borrow(printer);
185        let callback = &*(data as *mut P);
186        (*callback)(&printer).into_glib()
187    }
188    let func = Some(func_func::<P> as _);
189    unsafe extern "C" fn destroy_func<P: Fn(&Printer) -> bool + Send + Sync + 'static>(
190        data: glib::ffi::gpointer,
191    ) {
192        let _callback = Box_::from_raw(data as *mut P);
193    }
194    let destroy_call2 = Some(destroy_func::<P> as _);
195    let super_callback0: Box_<P> = func_data;
196    unsafe {
197        ffi::gtk_enumerate_printers(
198            func,
199            Box_::into_raw(super_callback0) as *mut _,
200            destroy_call2,
201            wait.into_glib(),
202        );
203    }
204}
205
206/// Returns the binary age as passed to `libtool`.
207///
208/// If `libtool` means nothing to you, don't worry about it.
209///
210/// # Returns
211///
212/// the binary age of the GTK library
213#[doc(alias = "gtk_get_binary_age")]
214#[doc(alias = "get_binary_age")]
215pub fn binary_age() -> u32 {
216    skip_assert_initialized!();
217    unsafe { ffi::gtk_get_binary_age() }
218}
219
220/// Returns the GTK debug flags that are currently active.
221///
222/// This function is intended for GTK modules that want
223/// to adjust their debug output based on GTK debug flags.
224///
225/// # Returns
226///
227/// the GTK debug flags.
228#[doc(alias = "gtk_get_debug_flags")]
229#[doc(alias = "get_debug_flags")]
230pub fn debug_flags() -> DebugFlags {
231    assert_initialized_main_thread!();
232    unsafe { from_glib(ffi::gtk_get_debug_flags()) }
233}
234
235/// Returns the [`pango::Language`][crate::pango::Language] for the default language
236/// currently in effect.
237///
238/// Note that this can change over the life of an
239/// application.
240///
241/// The default language is derived from the current
242/// locale. It determines, for example, whether GTK uses
243/// the right-to-left or left-to-right text direction.
244///
245/// This function is equivalent to [`pango::Language::default()`][crate::pango::Language::default()].
246/// See that function for details.
247///
248/// # Returns
249///
250/// the default language
251#[doc(alias = "gtk_get_default_language")]
252#[doc(alias = "get_default_language")]
253pub fn default_language() -> pango::Language {
254    assert_initialized_main_thread!();
255    unsafe { from_glib_none(ffi::gtk_get_default_language()) }
256}
257
258/// Returns the interface age as passed to `libtool`.
259///
260/// If `libtool` means nothing to you, don't worry about it.
261///
262/// # Returns
263///
264/// the interface age of the GTK library
265#[doc(alias = "gtk_get_interface_age")]
266#[doc(alias = "get_interface_age")]
267pub fn interface_age() -> u32 {
268    skip_assert_initialized!();
269    unsafe { ffi::gtk_get_interface_age() }
270}
271
272/// Gets the direction of the current locale.
273///
274/// This is the expected reading direction for text and UI.
275///
276/// This function depends on the current locale being set with
277/// `setlocale()` and will default to setting the `GTK_TEXT_DIR_LTR`
278/// direction otherwise. `GTK_TEXT_DIR_NONE` will never be returned.
279///
280/// GTK sets the default text direction according to the locale during
281/// [`init()`][crate::init()], and you should normally use [`WidgetExt::direction()`][crate::prelude::WidgetExt::direction()]
282/// or [`Widget::default_direction()`][crate::Widget::default_direction()] to obtain the current direction.
283///
284/// This function is only needed rare cases when the locale is
285/// changed after GTK has already been initialized. In this case,
286/// you can use it to update the default text direction as follows:
287///
288/// **⚠️ The following code is in c ⚠️**
289///
290/// ```c
291/// #include <locale.h>
292///
293/// static void
294/// update_locale (const char *new_locale)
295/// {
296///   setlocale (LC_ALL, new_locale);
297///   gtk_widget_set_default_direction (gtk_get_locale_direction ());
298/// }
299/// ```
300///
301/// # Returns
302///
303/// the direction of the current locale
304#[doc(alias = "gtk_get_locale_direction")]
305#[doc(alias = "get_locale_direction")]
306pub fn locale_direction() -> TextDirection {
307    assert_initialized_main_thread!();
308    unsafe { from_glib(ffi::gtk_get_locale_direction()) }
309}
310
311/// Returns the major version number of the GTK library.
312///
313/// For example, in GTK version 3.1.5 this is 3.
314///
315/// This function is in the library, so it represents the GTK library
316/// your code is running against. Contrast with the `GTK_MAJOR_VERSION`
317/// macro, which represents the major version of the GTK headers you
318/// have included when compiling your code.
319///
320/// # Returns
321///
322/// the major version number of the GTK library
323#[doc(alias = "gtk_get_major_version")]
324#[doc(alias = "get_major_version")]
325pub fn major_version() -> u32 {
326    skip_assert_initialized!();
327    unsafe { ffi::gtk_get_major_version() }
328}
329
330/// Returns the micro version number of the GTK library.
331///
332/// For example, in GTK version 3.1.5 this is 5.
333///
334/// This function is in the library, so it represents the GTK library
335/// your code is are running against. Contrast with the
336/// `GTK_MICRO_VERSION` macro, which represents the micro version of the
337/// GTK headers you have included when compiling your code.
338///
339/// # Returns
340///
341/// the micro version number of the GTK library
342#[doc(alias = "gtk_get_micro_version")]
343#[doc(alias = "get_micro_version")]
344pub fn micro_version() -> u32 {
345    skip_assert_initialized!();
346    unsafe { ffi::gtk_get_micro_version() }
347}
348
349/// Returns the minor version number of the GTK library.
350///
351/// For example, in GTK version 3.1.5 this is 1.
352///
353/// This function is in the library, so it represents the GTK library
354/// your code is are running against. Contrast with the
355/// `GTK_MINOR_VERSION` macro, which represents the minor version of the
356/// GTK headers you have included when compiling your code.
357///
358/// # Returns
359///
360/// the minor version number of the GTK library
361#[doc(alias = "gtk_get_minor_version")]
362#[doc(alias = "get_minor_version")]
363pub fn minor_version() -> u32 {
364    skip_assert_initialized!();
365    unsafe { ffi::gtk_get_minor_version() }
366}
367
368/// Converts a color from HSV space to RGB.
369///
370/// Input values must be in the [0.0, 1.0] range;
371/// output values will be in the same range.
372/// ## `h`
373/// Hue
374/// ## `s`
375/// Saturation
376/// ## `v`
377/// Value
378///
379/// # Returns
380///
381///
382/// ## `r`
383/// Return value for the red component
384///
385/// ## `g`
386/// Return value for the green component
387///
388/// ## `b`
389/// Return value for the blue component
390#[doc(alias = "gtk_hsv_to_rgb")]
391pub fn hsv_to_rgb(h: f32, s: f32, v: f32) -> (f32, f32, f32) {
392    assert_initialized_main_thread!();
393    unsafe {
394        let mut r = std::mem::MaybeUninit::uninit();
395        let mut g = std::mem::MaybeUninit::uninit();
396        let mut b = std::mem::MaybeUninit::uninit();
397        ffi::gtk_hsv_to_rgb(h, s, v, r.as_mut_ptr(), g.as_mut_ptr(), b.as_mut_ptr());
398        (r.assume_init(), g.assume_init(), b.assume_init())
399    }
400}
401
402/// Runs a page setup dialog, letting the user modify the values from @page_setup.
403///
404/// If the user cancels the dialog, the returned [`PageSetup`][crate::PageSetup] is identical
405/// to the passed in @page_setup, otherwise it contains the modifications
406/// done in the dialog.
407///
408/// Note that this function may use a recursive mainloop to show the page
409/// setup dialog. See [`print_run_page_setup_dialog_async()`][crate::print_run_page_setup_dialog_async()] if this is
410/// a problem.
411/// ## `parent`
412/// transient parent
413/// ## `page_setup`
414/// an existing [`PageSetup`][crate::PageSetup]
415/// ## `settings`
416/// a [`PrintSettings`][crate::PrintSettings]
417///
418/// # Returns
419///
420/// a new [`PageSetup`][crate::PageSetup]
421#[doc(alias = "gtk_print_run_page_setup_dialog")]
422pub fn print_run_page_setup_dialog(
423    parent: Option<&impl IsA<Window>>,
424    page_setup: Option<&PageSetup>,
425    settings: &PrintSettings,
426) -> PageSetup {
427    skip_assert_initialized!();
428    unsafe {
429        from_glib_full(ffi::gtk_print_run_page_setup_dialog(
430            parent.map(|p| p.as_ref()).to_glib_none().0,
431            page_setup.to_glib_none().0,
432            settings.to_glib_none().0,
433        ))
434    }
435}
436
437/// Runs a page setup dialog, letting the user modify the values from @page_setup.
438///
439/// In contrast to [`print_run_page_setup_dialog()`][crate::print_run_page_setup_dialog()], this function  returns
440/// after showing the page setup dialog on platforms that support this, and calls
441/// @done_cb from a signal handler for the ::response signal of the dialog.
442/// ## `parent`
443/// transient parent
444/// ## `page_setup`
445/// an existing [`PageSetup`][crate::PageSetup]
446/// ## `settings`
447/// a [`PrintSettings`][crate::PrintSettings]
448/// ## `done_cb`
449/// a function to call when the user saves
450///    the modified page setup
451#[doc(alias = "gtk_print_run_page_setup_dialog_async")]
452pub fn print_run_page_setup_dialog_async<P: FnOnce(&PageSetup) + Send + Sync + 'static>(
453    parent: Option<&impl IsA<Window>>,
454    page_setup: Option<&PageSetup>,
455    settings: &PrintSettings,
456    done_cb: P,
457) {
458    skip_assert_initialized!();
459    let done_cb_data: Box_<P> = Box_::new(done_cb);
460    unsafe extern "C" fn done_cb_func<P: FnOnce(&PageSetup) + Send + Sync + 'static>(
461        page_setup: *mut ffi::GtkPageSetup,
462        data: glib::ffi::gpointer,
463    ) {
464        let page_setup = from_glib_borrow(page_setup);
465        let callback = Box_::from_raw(data as *mut P);
466        (*callback)(&page_setup)
467    }
468    let done_cb = Some(done_cb_func::<P> as _);
469    let super_callback0: Box_<P> = done_cb_data;
470    unsafe {
471        ffi::gtk_print_run_page_setup_dialog_async(
472            parent.map(|p| p.as_ref()).to_glib_none().0,
473            page_setup.to_glib_none().0,
474            settings.to_glib_none().0,
475            done_cb,
476            Box_::into_raw(super_callback0) as *mut _,
477        );
478    }
479}
480
481/// Renders an activity indicator (such as in [`Spinner`][crate::Spinner]).
482/// The state [`StateFlags::CHECKED`][crate::StateFlags::CHECKED] determines whether there is
483/// activity going on.
484///
485/// # Deprecated since 4.10
486///
487/// ## `context`
488/// a [`StyleContext`][crate::StyleContext]
489/// ## `cr`
490/// a [`cairo::Context`][crate::cairo::Context]
491/// ## `x`
492/// X origin of the rectangle
493/// ## `y`
494/// Y origin of the rectangle
495/// ## `width`
496/// rectangle width
497/// ## `height`
498/// rectangle height
499#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
500#[allow(deprecated)]
501#[doc(alias = "gtk_render_activity")]
502pub fn render_activity(
503    context: &impl IsA<StyleContext>,
504    cr: &cairo::Context,
505    x: f64,
506    y: f64,
507    width: f64,
508    height: f64,
509) {
510    skip_assert_initialized!();
511    unsafe {
512        ffi::gtk_render_activity(
513            context.as_ref().to_glib_none().0,
514            mut_override(cr.to_glib_none().0),
515            x,
516            y,
517            width,
518            height,
519        );
520    }
521}
522
523/// Renders an arrow pointing to @angle.
524///
525/// Typical arrow rendering at 0, 1⁄2 π;, π; and 3⁄2 π:
526///
527/// ![](arrows.png)
528///
529/// # Deprecated since 4.10
530///
531/// ## `context`
532/// a [`StyleContext`][crate::StyleContext]
533/// ## `cr`
534/// a [`cairo::Context`][crate::cairo::Context]
535/// ## `angle`
536/// arrow angle from 0 to 2 * `G_PI`, being 0 the arrow pointing to the north
537/// ## `x`
538/// X origin of the render area
539/// ## `y`
540/// Y origin of the render area
541/// ## `size`
542/// square side for render area
543#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
544#[allow(deprecated)]
545#[doc(alias = "gtk_render_arrow")]
546pub fn render_arrow(
547    context: &impl IsA<StyleContext>,
548    cr: &cairo::Context,
549    angle: f64,
550    x: f64,
551    y: f64,
552    size: f64,
553) {
554    skip_assert_initialized!();
555    unsafe {
556        ffi::gtk_render_arrow(
557            context.as_ref().to_glib_none().0,
558            mut_override(cr.to_glib_none().0),
559            angle,
560            x,
561            y,
562            size,
563        );
564    }
565}
566
567/// Renders the background of an element.
568///
569/// Typical background rendering, showing the effect of
570/// `background-image`, `border-width` and `border-radius`:
571///
572/// ![](background.png)
573///
574/// # Deprecated since 4.10
575///
576/// ## `context`
577/// a [`StyleContext`][crate::StyleContext]
578/// ## `cr`
579/// a [`cairo::Context`][crate::cairo::Context]
580/// ## `x`
581/// X origin of the rectangle
582/// ## `y`
583/// Y origin of the rectangle
584/// ## `width`
585/// rectangle width
586/// ## `height`
587/// rectangle height
588#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
589#[allow(deprecated)]
590#[doc(alias = "gtk_render_background")]
591pub fn render_background(
592    context: &impl IsA<StyleContext>,
593    cr: &cairo::Context,
594    x: f64,
595    y: f64,
596    width: f64,
597    height: f64,
598) {
599    skip_assert_initialized!();
600    unsafe {
601        ffi::gtk_render_background(
602            context.as_ref().to_glib_none().0,
603            mut_override(cr.to_glib_none().0),
604            x,
605            y,
606            width,
607            height,
608        );
609    }
610}
611
612/// Renders a checkmark (as in a [`CheckButton`][crate::CheckButton]).
613///
614/// The [`StateFlags::CHECKED`][crate::StateFlags::CHECKED] state determines whether the check is
615/// on or off, and [`StateFlags::INCONSISTENT`][crate::StateFlags::INCONSISTENT] determines whether it
616/// should be marked as undefined.
617///
618/// Typical checkmark rendering:
619///
620/// ![](checks.png)
621///
622/// # Deprecated since 4.10
623///
624/// ## `context`
625/// a [`StyleContext`][crate::StyleContext]
626/// ## `cr`
627/// a [`cairo::Context`][crate::cairo::Context]
628/// ## `x`
629/// X origin of the rectangle
630/// ## `y`
631/// Y origin of the rectangle
632/// ## `width`
633/// rectangle width
634/// ## `height`
635/// rectangle height
636#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
637#[allow(deprecated)]
638#[doc(alias = "gtk_render_check")]
639pub fn render_check(
640    context: &impl IsA<StyleContext>,
641    cr: &cairo::Context,
642    x: f64,
643    y: f64,
644    width: f64,
645    height: f64,
646) {
647    skip_assert_initialized!();
648    unsafe {
649        ffi::gtk_render_check(
650            context.as_ref().to_glib_none().0,
651            mut_override(cr.to_glib_none().0),
652            x,
653            y,
654            width,
655            height,
656        );
657    }
658}
659
660/// Renders an expander (as used in [`TreeView`][crate::TreeView] and [`Expander`][crate::Expander]) in the area
661/// defined by @x, @y, @width, @height. The state [`StateFlags::CHECKED`][crate::StateFlags::CHECKED]
662/// determines whether the expander is collapsed or expanded.
663///
664/// Typical expander rendering:
665///
666/// ![](expanders.png)
667///
668/// # Deprecated since 4.10
669///
670/// ## `context`
671/// a [`StyleContext`][crate::StyleContext]
672/// ## `cr`
673/// a [`cairo::Context`][crate::cairo::Context]
674/// ## `x`
675/// X origin of the rectangle
676/// ## `y`
677/// Y origin of the rectangle
678/// ## `width`
679/// rectangle width
680/// ## `height`
681/// rectangle height
682#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
683#[allow(deprecated)]
684#[doc(alias = "gtk_render_expander")]
685pub fn render_expander(
686    context: &impl IsA<StyleContext>,
687    cr: &cairo::Context,
688    x: f64,
689    y: f64,
690    width: f64,
691    height: f64,
692) {
693    skip_assert_initialized!();
694    unsafe {
695        ffi::gtk_render_expander(
696            context.as_ref().to_glib_none().0,
697            mut_override(cr.to_glib_none().0),
698            x,
699            y,
700            width,
701            height,
702        );
703    }
704}
705
706/// Renders a focus indicator on the rectangle determined by @x, @y, @width, @height.
707///
708/// Typical focus rendering:
709///
710/// ![](focus.png)
711///
712/// # Deprecated since 4.10
713///
714/// ## `context`
715/// a [`StyleContext`][crate::StyleContext]
716/// ## `cr`
717/// a [`cairo::Context`][crate::cairo::Context]
718/// ## `x`
719/// X origin of the rectangle
720/// ## `y`
721/// Y origin of the rectangle
722/// ## `width`
723/// rectangle width
724/// ## `height`
725/// rectangle height
726#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
727#[allow(deprecated)]
728#[doc(alias = "gtk_render_focus")]
729pub fn render_focus(
730    context: &impl IsA<StyleContext>,
731    cr: &cairo::Context,
732    x: f64,
733    y: f64,
734    width: f64,
735    height: f64,
736) {
737    skip_assert_initialized!();
738    unsafe {
739        ffi::gtk_render_focus(
740            context.as_ref().to_glib_none().0,
741            mut_override(cr.to_glib_none().0),
742            x,
743            y,
744            width,
745            height,
746        );
747    }
748}
749
750/// Renders a frame around the rectangle defined by @x, @y, @width, @height.
751///
752/// Examples of frame rendering, showing the effect of `border-image`,
753/// `border-color`, `border-width`, `border-radius` and junctions:
754///
755/// ![](frames.png)
756///
757/// # Deprecated since 4.10
758///
759/// ## `context`
760/// a [`StyleContext`][crate::StyleContext]
761/// ## `cr`
762/// a [`cairo::Context`][crate::cairo::Context]
763/// ## `x`
764/// X origin of the rectangle
765/// ## `y`
766/// Y origin of the rectangle
767/// ## `width`
768/// rectangle width
769/// ## `height`
770/// rectangle height
771#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
772#[allow(deprecated)]
773#[doc(alias = "gtk_render_frame")]
774pub fn render_frame(
775    context: &impl IsA<StyleContext>,
776    cr: &cairo::Context,
777    x: f64,
778    y: f64,
779    width: f64,
780    height: f64,
781) {
782    skip_assert_initialized!();
783    unsafe {
784        ffi::gtk_render_frame(
785            context.as_ref().to_glib_none().0,
786            mut_override(cr.to_glib_none().0),
787            x,
788            y,
789            width,
790            height,
791        );
792    }
793}
794
795/// Renders a handle (as in [`Paned`][crate::Paned] and [`Window`][crate::Window]’s resize grip),
796/// in the rectangle determined by @x, @y, @width, @height.
797///
798/// Handles rendered for the paned and grip classes:
799///
800/// ![](handles.png)
801///
802/// # Deprecated since 4.10
803///
804/// ## `context`
805/// a [`StyleContext`][crate::StyleContext]
806/// ## `cr`
807/// a [`cairo::Context`][crate::cairo::Context]
808/// ## `x`
809/// X origin of the rectangle
810/// ## `y`
811/// Y origin of the rectangle
812/// ## `width`
813/// rectangle width
814/// ## `height`
815/// rectangle height
816#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
817#[allow(deprecated)]
818#[doc(alias = "gtk_render_handle")]
819pub fn render_handle(
820    context: &impl IsA<StyleContext>,
821    cr: &cairo::Context,
822    x: f64,
823    y: f64,
824    width: f64,
825    height: f64,
826) {
827    skip_assert_initialized!();
828    unsafe {
829        ffi::gtk_render_handle(
830            context.as_ref().to_glib_none().0,
831            mut_override(cr.to_glib_none().0),
832            x,
833            y,
834            width,
835            height,
836        );
837    }
838}
839
840/// Renders the icon in @texture at the specified @x and @y coordinates.
841///
842/// This function will render the icon in @texture at exactly its size,
843/// regardless of scaling factors, which may not be appropriate when
844/// drawing on displays with high pixel densities.
845///
846/// # Deprecated since 4.10
847///
848/// ## `context`
849/// a [`StyleContext`][crate::StyleContext]
850/// ## `cr`
851/// a [`cairo::Context`][crate::cairo::Context]
852/// ## `texture`
853/// a [`gdk::Texture`][crate::gdk::Texture] containing the icon to draw
854/// ## `x`
855/// X position for the @texture
856/// ## `y`
857/// Y position for the @texture
858#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
859#[allow(deprecated)]
860#[doc(alias = "gtk_render_icon")]
861pub fn render_icon(
862    context: &impl IsA<StyleContext>,
863    cr: &cairo::Context,
864    texture: &impl IsA<gdk::Texture>,
865    x: f64,
866    y: f64,
867) {
868    skip_assert_initialized!();
869    unsafe {
870        ffi::gtk_render_icon(
871            context.as_ref().to_glib_none().0,
872            mut_override(cr.to_glib_none().0),
873            texture.as_ref().to_glib_none().0,
874            x,
875            y,
876        );
877    }
878}
879
880/// Renders @layout on the coordinates @x, @y
881///
882/// # Deprecated since 4.10
883///
884/// ## `context`
885/// a [`StyleContext`][crate::StyleContext]
886/// ## `cr`
887/// a [`cairo::Context`][crate::cairo::Context]
888/// ## `x`
889/// X origin
890/// ## `y`
891/// Y origin
892/// ## `layout`
893/// the [`pango::Layout`][crate::pango::Layout] to render
894#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
895#[allow(deprecated)]
896#[doc(alias = "gtk_render_layout")]
897pub fn render_layout(
898    context: &impl IsA<StyleContext>,
899    cr: &cairo::Context,
900    x: f64,
901    y: f64,
902    layout: &pango::Layout,
903) {
904    skip_assert_initialized!();
905    unsafe {
906        ffi::gtk_render_layout(
907            context.as_ref().to_glib_none().0,
908            mut_override(cr.to_glib_none().0),
909            x,
910            y,
911            layout.to_glib_none().0,
912        );
913    }
914}
915
916/// Renders a line from (x0, y0) to (x1, y1).
917///
918/// # Deprecated since 4.10
919///
920/// ## `context`
921/// a [`StyleContext`][crate::StyleContext]
922/// ## `cr`
923/// a [`cairo::Context`][crate::cairo::Context]
924/// ## `x0`
925/// X coordinate for the origin of the line
926/// ## `y0`
927/// Y coordinate for the origin of the line
928/// ## `x1`
929/// X coordinate for the end of the line
930/// ## `y1`
931/// Y coordinate for the end of the line
932#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
933#[allow(deprecated)]
934#[doc(alias = "gtk_render_line")]
935pub fn render_line(
936    context: &impl IsA<StyleContext>,
937    cr: &cairo::Context,
938    x0: f64,
939    y0: f64,
940    x1: f64,
941    y1: f64,
942) {
943    skip_assert_initialized!();
944    unsafe {
945        ffi::gtk_render_line(
946            context.as_ref().to_glib_none().0,
947            mut_override(cr.to_glib_none().0),
948            x0,
949            y0,
950            x1,
951            y1,
952        );
953    }
954}
955
956/// Renders an option mark (as in a radio button), the [`StateFlags::CHECKED`][crate::StateFlags::CHECKED]
957/// state will determine whether the option is on or off, and
958/// [`StateFlags::INCONSISTENT`][crate::StateFlags::INCONSISTENT] whether it should be marked as undefined.
959///
960/// Typical option mark rendering:
961///
962/// ![](options.png)
963///
964/// # Deprecated since 4.10
965///
966/// ## `context`
967/// a [`StyleContext`][crate::StyleContext]
968/// ## `cr`
969/// a [`cairo::Context`][crate::cairo::Context]
970/// ## `x`
971/// X origin of the rectangle
972/// ## `y`
973/// Y origin of the rectangle
974/// ## `width`
975/// rectangle width
976/// ## `height`
977/// rectangle height
978#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
979#[allow(deprecated)]
980#[doc(alias = "gtk_render_option")]
981pub fn render_option(
982    context: &impl IsA<StyleContext>,
983    cr: &cairo::Context,
984    x: f64,
985    y: f64,
986    width: f64,
987    height: f64,
988) {
989    skip_assert_initialized!();
990    unsafe {
991        ffi::gtk_render_option(
992            context.as_ref().to_glib_none().0,
993            mut_override(cr.to_glib_none().0),
994            x,
995            y,
996            width,
997            height,
998        );
999    }
1000}
1001
1002/// Converts a color from RGB space to HSV.
1003///
1004/// Input values must be in the [0.0, 1.0] range;
1005/// output values will be in the same range.
1006/// ## `r`
1007/// Red
1008/// ## `g`
1009/// Green
1010/// ## `b`
1011/// Blue
1012///
1013/// # Returns
1014///
1015///
1016/// ## `h`
1017/// Return value for the hue component
1018///
1019/// ## `s`
1020/// Return value for the saturation component
1021///
1022/// ## `v`
1023/// Return value for the value component
1024#[doc(alias = "gtk_rgb_to_hsv")]
1025pub fn rgb_to_hsv(r: f32, g: f32, b: f32) -> (f32, f32, f32) {
1026    assert_initialized_main_thread!();
1027    unsafe {
1028        let mut h = std::mem::MaybeUninit::uninit();
1029        let mut s = std::mem::MaybeUninit::uninit();
1030        let mut v = std::mem::MaybeUninit::uninit();
1031        ffi::gtk_rgb_to_hsv(r, g, b, h.as_mut_ptr(), s.as_mut_ptr(), v.as_mut_ptr());
1032        (h.assume_init(), s.assume_init(), v.assume_init())
1033    }
1034}
1035
1036/// Sets the GTK debug flags.
1037/// ## `flags`
1038/// the debug flags to set
1039#[doc(alias = "gtk_set_debug_flags")]
1040pub fn set_debug_flags(flags: DebugFlags) {
1041    assert_initialized_main_thread!();
1042    unsafe {
1043        ffi::gtk_set_debug_flags(flags.into_glib());
1044    }
1045}
1046
1047/// This function launches the default application for showing
1048/// a given uri, or shows an error dialog if that fails.
1049///
1050/// # Deprecated since 4.10
1051///
1052/// Use [`FileLauncher::launch()`][crate::FileLauncher::launch()] or
1053///   [`UriLauncher::launch()`][crate::UriLauncher::launch()] instead
1054/// ## `parent`
1055/// parent window
1056/// ## `uri`
1057/// the uri to show
1058/// ## `timestamp`
1059/// timestamp from the event that triggered this call, or `GDK_CURRENT_TIME`
1060#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1061#[allow(deprecated)]
1062#[doc(alias = "gtk_show_uri")]
1063pub fn show_uri(parent: Option<&impl IsA<Window>>, uri: &str, timestamp: u32) {
1064    assert_initialized_main_thread!();
1065    unsafe {
1066        ffi::gtk_show_uri(
1067            parent.map(|p| p.as_ref()).to_glib_none().0,
1068            uri.to_glib_none().0,
1069            timestamp,
1070        );
1071    }
1072}
1073
1074/// Prints an assertion message for gtk_test_accessible_assert_role().
1075/// ## `domain`
1076/// a domain
1077/// ## `file`
1078/// a file name
1079/// ## `line`
1080/// the line in @file
1081/// ## `func`
1082/// a function name in @file
1083/// ## `expr`
1084/// the expression being tested
1085/// ## `accessible`
1086/// a [`Accessible`][crate::Accessible]
1087/// ## `expected_role`
1088/// the expected [`AccessibleRole`][crate::AccessibleRole]
1089/// ## `actual_role`
1090/// the actual [`AccessibleRole`][crate::AccessibleRole]
1091#[doc(alias = "gtk_test_accessible_assertion_message_role")]
1092pub fn test_accessible_assertion_message_role(
1093    domain: &str,
1094    file: &str,
1095    line: i32,
1096    func: &str,
1097    expr: &str,
1098    accessible: &impl IsA<Accessible>,
1099    expected_role: AccessibleRole,
1100    actual_role: AccessibleRole,
1101) {
1102    skip_assert_initialized!();
1103    unsafe {
1104        ffi::gtk_test_accessible_assertion_message_role(
1105            domain.to_glib_none().0,
1106            file.to_glib_none().0,
1107            line,
1108            func.to_glib_none().0,
1109            expr.to_glib_none().0,
1110            accessible.as_ref().to_glib_none().0,
1111            expected_role.into_glib(),
1112            actual_role.into_glib(),
1113        );
1114    }
1115}
1116
1117/// Checks whether the [`Accessible`][crate::Accessible] has @property set.
1118/// ## `accessible`
1119/// a [`Accessible`][crate::Accessible]
1120/// ## `property`
1121/// a [`AccessibleProperty`][crate::AccessibleProperty]
1122///
1123/// # Returns
1124///
1125/// [`true`] if the @property is set in the @accessible
1126#[doc(alias = "gtk_test_accessible_has_property")]
1127pub fn test_accessible_has_property(
1128    accessible: &impl IsA<Accessible>,
1129    property: AccessibleProperty,
1130) -> bool {
1131    skip_assert_initialized!();
1132    unsafe {
1133        from_glib(ffi::gtk_test_accessible_has_property(
1134            accessible.as_ref().to_glib_none().0,
1135            property.into_glib(),
1136        ))
1137    }
1138}
1139
1140/// Checks whether the [`Accessible`][crate::Accessible] has @relation set.
1141/// ## `accessible`
1142/// a [`Accessible`][crate::Accessible]
1143/// ## `relation`
1144/// a [`AccessibleRelation`][crate::AccessibleRelation]
1145///
1146/// # Returns
1147///
1148/// [`true`] if the @relation is set in the @accessible
1149#[doc(alias = "gtk_test_accessible_has_relation")]
1150pub fn test_accessible_has_relation(
1151    accessible: &impl IsA<Accessible>,
1152    relation: AccessibleRelation,
1153) -> bool {
1154    skip_assert_initialized!();
1155    unsafe {
1156        from_glib(ffi::gtk_test_accessible_has_relation(
1157            accessible.as_ref().to_glib_none().0,
1158            relation.into_glib(),
1159        ))
1160    }
1161}
1162
1163/// Checks whether the `GtkAccessible:accessible-role` of the accessible
1164/// is @role.
1165/// ## `accessible`
1166/// a [`Accessible`][crate::Accessible]
1167/// ## `role`
1168/// a [`AccessibleRole`][crate::AccessibleRole]
1169///
1170/// # Returns
1171///
1172/// [`true`] if the role matches
1173#[doc(alias = "gtk_test_accessible_has_role")]
1174pub fn test_accessible_has_role(accessible: &impl IsA<Accessible>, role: AccessibleRole) -> bool {
1175    skip_assert_initialized!();
1176    unsafe {
1177        from_glib(ffi::gtk_test_accessible_has_role(
1178            accessible.as_ref().to_glib_none().0,
1179            role.into_glib(),
1180        ))
1181    }
1182}
1183
1184/// Checks whether the [`Accessible`][crate::Accessible] has @state set.
1185/// ## `accessible`
1186/// a [`Accessible`][crate::Accessible]
1187/// ## `state`
1188/// a [`AccessibleState`][crate::AccessibleState]
1189///
1190/// # Returns
1191///
1192/// [`true`] if the @state is set in the @accessible
1193#[doc(alias = "gtk_test_accessible_has_state")]
1194pub fn test_accessible_has_state(
1195    accessible: &impl IsA<Accessible>,
1196    state: AccessibleState,
1197) -> bool {
1198    skip_assert_initialized!();
1199    unsafe {
1200        from_glib(ffi::gtk_test_accessible_has_state(
1201            accessible.as_ref().to_glib_none().0,
1202            state.into_glib(),
1203        ))
1204    }
1205}
1206
1207//#[doc(alias = "gtk_test_init")]
1208//pub fn test_init(argvp: /*Unimplemented*/Vec<glib::GString>, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
1209//    unsafe { TODO: call ffi:gtk_test_init() }
1210//}
1211
1212/// Force registration of all core GTK object types.
1213///
1214/// This allows to refer to any of those object types via
1215/// g_type_from_name() after calling this function.
1216#[doc(alias = "gtk_test_register_all_types")]
1217pub fn test_register_all_types() {
1218    assert_initialized_main_thread!();
1219    unsafe {
1220        ffi::gtk_test_register_all_types();
1221    }
1222}
1223
1224/// Enters the main loop and waits for @widget to be “drawn”.
1225///
1226/// In this context that means it waits for the frame clock of
1227/// @widget to have run a full styling, layout and drawing cycle.
1228///
1229/// This function is intended to be used for syncing with actions that
1230/// depend on @widget relayouting or on interaction with the display
1231/// server.
1232/// ## `widget`
1233/// the widget to wait for
1234#[doc(alias = "gtk_test_widget_wait_for_draw")]
1235pub fn test_widget_wait_for_draw(widget: &impl IsA<Widget>) {
1236    skip_assert_initialized!();
1237    unsafe {
1238        ffi::gtk_test_widget_wait_for_draw(widget.as_ref().to_glib_none().0);
1239    }
1240}
1241
1242/// Creates a content provider for dragging @path from @tree_model.
1243///
1244/// # Deprecated since 4.10
1245///
1246/// Use list models instead
1247/// ## `tree_model`
1248/// a [`TreeModel`][crate::TreeModel]
1249/// ## `path`
1250/// a row in @tree_model
1251///
1252/// # Returns
1253///
1254/// a new [`gdk::ContentProvider`][crate::gdk::ContentProvider]
1255#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1256#[allow(deprecated)]
1257#[doc(alias = "gtk_tree_create_row_drag_content")]
1258pub fn tree_create_row_drag_content(
1259    tree_model: &impl IsA<TreeModel>,
1260    path: &TreePath,
1261) -> gdk::ContentProvider {
1262    skip_assert_initialized!();
1263    unsafe {
1264        from_glib_full(ffi::gtk_tree_create_row_drag_content(
1265            tree_model.as_ref().to_glib_none().0,
1266            mut_override(path.to_glib_none().0),
1267        ))
1268    }
1269}
1270
1271/// Obtains a @tree_model and @path from value of target type
1272/// `GTK_TYPE_TREE_ROW_DATA`.
1273///
1274/// The returned path must be freed with gtk_tree_path_free().
1275///
1276/// # Deprecated since 4.10
1277///
1278/// Use list models instead
1279/// ## `value`
1280/// a `GValue`
1281///
1282/// # Returns
1283///
1284/// [`true`] if @selection_data had target type `GTK_TYPE_TREE_ROW_DATA`
1285///  is otherwise valid
1286///
1287/// ## `tree_model`
1288/// a [`TreeModel`][crate::TreeModel]
1289///
1290/// ## `path`
1291/// row in @tree_model
1292#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1293#[allow(deprecated)]
1294#[doc(alias = "gtk_tree_get_row_drag_data")]
1295pub fn tree_get_row_drag_data(
1296    value: &glib::Value,
1297) -> Option<(Option<TreeModel>, Option<TreePath>)> {
1298    assert_initialized_main_thread!();
1299    unsafe {
1300        let mut tree_model = std::ptr::null_mut();
1301        let mut path = std::ptr::null_mut();
1302        let ret = from_glib(ffi::gtk_tree_get_row_drag_data(
1303            value.to_glib_none().0,
1304            &mut tree_model,
1305            &mut path,
1306        ));
1307        if ret {
1308            Some((from_glib_none(tree_model), from_glib_full(path)))
1309        } else {
1310            None
1311        }
1312    }
1313}