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