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