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