Skip to main content

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