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