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