gtk/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
5use crate::{
6 AccelGroup, Orientation, PageSetup, PositionType, PrintSettings, SelectionData, StyleContext,
7 TextBuffer, TextDirection, TreeModel, TreePath, Widget, Window, ffi,
8};
9use glib::{prelude::*, translate::*};
10use std::boxed::Box as Box_;
11
12/// Finds the first accelerator in any [`AccelGroup`][crate::AccelGroup] attached
13/// to `object` that matches `accel_key` and `accel_mods`, and
14/// activates that accelerator.
15/// ## `object`
16/// the [`glib::Object`][crate::glib::Object], usually a [`Window`][crate::Window], on which
17/// to activate the accelerator
18/// ## `accel_key`
19/// accelerator keyval from a key event
20/// ## `accel_mods`
21/// keyboard state mask from a key event
22///
23/// # Returns
24///
25/// [`true`] if an accelerator was activated and handled
26/// this keypress
27#[doc(alias = "gtk_accel_groups_activate")]
28pub fn accel_groups_activate(
29 object: &impl IsA<glib::Object>,
30 accel_key: u32,
31 accel_mods: gdk::ModifierType,
32) -> bool {
33 assert_initialized_main_thread!();
34 unsafe {
35 from_glib(ffi::gtk_accel_groups_activate(
36 object.as_ref().to_glib_none().0,
37 accel_key,
38 accel_mods.into_glib(),
39 ))
40 }
41}
42
43/// Gets a list of all accel groups which are attached to `object`.
44/// ## `object`
45/// a [`glib::Object`][crate::glib::Object], usually a [`Window`][crate::Window]
46///
47/// # Returns
48///
49/// a list of
50/// all accel groups which are attached to `object`
51#[doc(alias = "gtk_accel_groups_from_object")]
52pub fn accel_groups_from_object(object: &impl IsA<glib::Object>) -> Vec<AccelGroup> {
53 assert_initialized_main_thread!();
54 unsafe {
55 FromGlibPtrContainer::from_glib_none(ffi::gtk_accel_groups_from_object(
56 object.as_ref().to_glib_none().0,
57 ))
58 }
59}
60
61/// Gets the modifier mask.
62///
63/// The modifier mask determines which modifiers are considered significant
64/// for keyboard accelerators. See [`accelerator_set_default_mod_mask()`][crate::accelerator_set_default_mod_mask()].
65///
66/// # Returns
67///
68/// the default accelerator modifier mask
69#[doc(alias = "gtk_accelerator_get_default_mod_mask")]
70pub fn accelerator_get_default_mod_mask() -> gdk::ModifierType {
71 assert_initialized_main_thread!();
72 unsafe { from_glib(ffi::gtk_accelerator_get_default_mod_mask()) }
73}
74
75/// Converts an accelerator keyval and modifier mask into a string
76/// which can be used to represent the accelerator to the user.
77/// ## `accelerator_key`
78/// accelerator keyval
79/// ## `accelerator_mods`
80/// accelerator modifier mask
81///
82/// # Returns
83///
84/// a newly-allocated string representing the accelerator.
85#[doc(alias = "gtk_accelerator_get_label")]
86pub fn accelerator_get_label(
87 accelerator_key: u32,
88 accelerator_mods: gdk::ModifierType,
89) -> Option<glib::GString> {
90 assert_initialized_main_thread!();
91 unsafe {
92 from_glib_full(ffi::gtk_accelerator_get_label(
93 accelerator_key,
94 accelerator_mods.into_glib(),
95 ))
96 }
97}
98
99/// Converts an accelerator keyval and modifier mask
100/// into a (possibly translated) string that can be displayed to
101/// a user, similarly to [`accelerator_get_label()`][crate::accelerator_get_label()], but handling
102/// keycodes.
103///
104/// This is only useful for system-level components, applications
105/// should use [`accelerator_parse()`][crate::accelerator_parse()] instead.
106/// ## `display`
107/// a [`gdk::Display`][crate::gdk::Display] or [`None`] to use the default display
108/// ## `accelerator_key`
109/// accelerator keyval
110/// ## `keycode`
111/// accelerator keycode
112/// ## `accelerator_mods`
113/// accelerator modifier mask
114///
115/// # Returns
116///
117/// a newly-allocated string representing the accelerator.
118#[doc(alias = "gtk_accelerator_get_label_with_keycode")]
119pub fn accelerator_get_label_with_keycode(
120 display: Option<&gdk::Display>,
121 accelerator_key: u32,
122 keycode: u32,
123 accelerator_mods: gdk::ModifierType,
124) -> Option<glib::GString> {
125 assert_initialized_main_thread!();
126 unsafe {
127 from_glib_full(ffi::gtk_accelerator_get_label_with_keycode(
128 display.to_glib_none().0,
129 accelerator_key,
130 keycode,
131 accelerator_mods.into_glib(),
132 ))
133 }
134}
135
136/// q”.
137///
138/// If you need to display accelerators in the user interface,
139/// see [`accelerator_get_label()`][crate::accelerator_get_label()].
140/// ## `accelerator_key`
141/// accelerator keyval
142/// ## `accelerator_mods`
143/// accelerator modifier mask
144///
145/// # Returns
146///
147/// a newly-allocated accelerator name
148#[doc(alias = "gtk_accelerator_name")]
149pub fn accelerator_name(
150 accelerator_key: u32,
151 accelerator_mods: gdk::ModifierType,
152) -> Option<glib::GString> {
153 assert_initialized_main_thread!();
154 unsafe {
155 from_glib_full(ffi::gtk_accelerator_name(
156 accelerator_key,
157 accelerator_mods.into_glib(),
158 ))
159 }
160}
161
162/// Converts an accelerator keyval and modifier mask
163/// into a string parseable by [`accelerator_parse_with_keycode()`][crate::accelerator_parse_with_keycode()],
164/// similarly to [`accelerator_name()`][crate::accelerator_name()] but handling keycodes.
165/// This is only useful for system-level components, applications
166/// should use [`accelerator_parse()`][crate::accelerator_parse()] instead.
167/// ## `display`
168/// a [`gdk::Display`][crate::gdk::Display] or [`None`] to use the default display
169/// ## `accelerator_key`
170/// accelerator keyval
171/// ## `keycode`
172/// accelerator keycode
173/// ## `accelerator_mods`
174/// accelerator modifier mask
175///
176/// # Returns
177///
178/// a newly allocated accelerator name.
179#[doc(alias = "gtk_accelerator_name_with_keycode")]
180pub fn accelerator_name_with_keycode(
181 display: Option<&gdk::Display>,
182 accelerator_key: u32,
183 keycode: u32,
184 accelerator_mods: gdk::ModifierType,
185) -> Option<glib::GString> {
186 assert_initialized_main_thread!();
187 unsafe {
188 from_glib_full(ffi::gtk_accelerator_name_with_keycode(
189 display.to_glib_none().0,
190 accelerator_key,
191 keycode,
192 accelerator_mods.into_glib(),
193 ))
194 }
195}
196
197/// -`.
198///
199/// If the parse fails, `accelerator_key` and `accelerator_mods` will
200/// be set to 0 (zero).
201/// ## `accelerator`
202/// string representing an accelerator
203///
204/// # Returns
205///
206///
207/// ## `accelerator_key`
208/// return location for accelerator
209/// keyval, or [`None`]
210///
211/// ## `accelerator_mods`
212/// return location for accelerator
213/// modifier mask, [`None`]
214#[doc(alias = "gtk_accelerator_parse")]
215pub fn accelerator_parse(accelerator: &str) -> (u32, gdk::ModifierType) {
216 assert_initialized_main_thread!();
217 unsafe {
218 let mut accelerator_key = std::mem::MaybeUninit::uninit();
219 let mut accelerator_mods = std::mem::MaybeUninit::uninit();
220 ffi::gtk_accelerator_parse(
221 accelerator.to_glib_none().0,
222 accelerator_key.as_mut_ptr(),
223 accelerator_mods.as_mut_ptr(),
224 );
225 (
226 accelerator_key.assume_init(),
227 from_glib(accelerator_mods.assume_init()),
228 )
229 }
230}
231
232/// Sets the modifiers that will be considered significant for keyboard
233/// accelerators. The default mod mask depends on the GDK backend in use,
234/// but will typically include [`gdk::ModifierType::CONTROL_MASK`][crate::gdk::ModifierType::CONTROL_MASK] | [`gdk::ModifierType::SHIFT_MASK`][crate::gdk::ModifierType::SHIFT_MASK] |
235/// [`gdk::ModifierType::MOD1_MASK`][crate::gdk::ModifierType::MOD1_MASK] | [`gdk::ModifierType::SUPER_MASK`][crate::gdk::ModifierType::SUPER_MASK] | [`gdk::ModifierType::HYPER_MASK`][crate::gdk::ModifierType::HYPER_MASK] | [`gdk::ModifierType::META_MASK`][crate::gdk::ModifierType::META_MASK].
236/// In other words, Control, Shift, Alt, Super, Hyper and Meta. Other
237/// modifiers will by default be ignored by [`AccelGroup`][crate::AccelGroup].
238///
239/// You must include at least the three modifiers Control, Shift
240/// and Alt in any value you pass to this function.
241///
242/// The default mod mask should be changed on application startup,
243/// before using any accelerator groups.
244/// ## `default_mod_mask`
245/// accelerator modifier mask
246#[doc(alias = "gtk_accelerator_set_default_mod_mask")]
247pub fn accelerator_set_default_mod_mask(default_mod_mask: gdk::ModifierType) {
248 assert_initialized_main_thread!();
249 unsafe {
250 ffi::gtk_accelerator_set_default_mod_mask(default_mod_mask.into_glib());
251 }
252}
253
254/// Determines whether a given keyval and modifier mask constitute
255/// a valid keyboard accelerator. For example, the `GDK_KEY_a` keyval
256/// plus [`gdk::ModifierType::CONTROL_MASK`][crate::gdk::ModifierType::CONTROL_MASK] is valid - this is a “Ctrl+a” accelerator.
257/// But, you can't, for instance, use the `GDK_KEY_Control_L` keyval
258/// as an accelerator.
259/// ## `keyval`
260/// a GDK keyval
261/// ## `modifiers`
262/// modifier mask
263///
264/// # Returns
265///
266/// [`true`] if the accelerator is valid
267#[doc(alias = "gtk_accelerator_valid")]
268pub fn accelerator_valid(keyval: u32, modifiers: gdk::ModifierType) -> bool {
269 assert_initialized_main_thread!();
270 unsafe { from_glib(ffi::gtk_accelerator_valid(keyval, modifiers.into_glib())) }
271}
272
273/// Find a key binding matching `keyval` and `modifiers` and activate the
274/// binding on `object`.
275/// ## `object`
276/// object to activate when binding found
277/// ## `keyval`
278/// key value of the binding
279/// ## `modifiers`
280/// key modifier of the binding
281///
282/// # Returns
283///
284/// [`true`] if a binding was found and activated
285#[doc(alias = "gtk_bindings_activate")]
286pub fn bindings_activate(
287 object: &impl IsA<glib::Object>,
288 keyval: u32,
289 modifiers: gdk::ModifierType,
290) -> bool {
291 assert_initialized_main_thread!();
292 unsafe {
293 from_glib(ffi::gtk_bindings_activate(
294 object.as_ref().to_glib_none().0,
295 keyval,
296 modifiers.into_glib(),
297 ))
298 }
299}
300
301/// Looks up key bindings for `object` to find one matching
302/// `event`, and if one was found, activate it.
303/// ## `object`
304/// a [`glib::Object`][crate::glib::Object] (generally must be a widget)
305/// ## `event`
306/// a [`gdk::EventKey`][crate::gdk::EventKey]
307///
308/// # Returns
309///
310/// [`true`] if a matching key binding was found
311#[doc(alias = "gtk_bindings_activate_event")]
312pub fn bindings_activate_event(object: &impl IsA<glib::Object>, event: &mut gdk::EventKey) -> bool {
313 assert_initialized_main_thread!();
314 unsafe {
315 from_glib(ffi::gtk_bindings_activate_event(
316 object.as_ref().to_glib_none().0,
317 event.to_glib_none_mut().0,
318 ))
319 }
320}
321
322/// This function is supposed to be called in [`draw`][struct@crate::Widget#draw]
323/// implementations for widgets that support multiple windows.
324/// `cr` must be untransformed from invoking of the draw function.
325/// This function will return [`true`] if the contents of the given
326/// `window` are supposed to be drawn and [`false`] otherwise. Note
327/// that when the drawing was not initiated by the windowing
328/// system this function will return [`true`] for all windows, so
329/// you need to draw the bottommost window first. Also, do not
330/// use “else if” statements to check which window should be drawn.
331/// ## `cr`
332/// a cairo context
333/// ## `window`
334/// the window to check. `window` may not be an input-only
335/// window.
336///
337/// # Returns
338///
339/// [`true`] if `window` should be drawn
340#[doc(alias = "gtk_cairo_should_draw_window")]
341pub fn cairo_should_draw_window(cr: &cairo::Context, window: &gdk::Window) -> bool {
342 assert_initialized_main_thread!();
343 unsafe {
344 from_glib(ffi::gtk_cairo_should_draw_window(
345 mut_override(cr.to_glib_none().0),
346 window.to_glib_none().0,
347 ))
348 }
349}
350
351/// Transforms the given cairo context `cr` that from `widget`-relative
352/// coordinates to `window`-relative coordinates.
353/// If the `widget`’s window is not an ancestor of `window`, no
354/// modification will be applied.
355///
356/// This is the inverse to the transformation GTK applies when
357/// preparing an expose event to be emitted with the [`draw`][struct@crate::Widget#draw]
358/// signal. It is intended to help porting multiwindow widgets from
359/// GTK+ 2 to the rendering architecture of GTK+ 3.
360/// ## `cr`
361/// the cairo context to transform
362/// ## `widget`
363/// the widget the context is currently centered for
364/// ## `window`
365/// the window to transform the context to
366#[doc(alias = "gtk_cairo_transform_to_window")]
367pub fn cairo_transform_to_window(
368 cr: &cairo::Context,
369 widget: &impl IsA<Widget>,
370 window: &gdk::Window,
371) {
372 skip_assert_initialized!();
373 unsafe {
374 ffi::gtk_cairo_transform_to_window(
375 mut_override(cr.to_glib_none().0),
376 widget.as_ref().to_glib_none().0,
377 window.to_glib_none().0,
378 );
379 }
380}
381
382/// Checks that the GTK+ library in use is compatible with the
383/// given version. Generally you would pass in the constants
384/// `GTK_MAJOR_VERSION`, `GTK_MINOR_VERSION`, `GTK_MICRO_VERSION`
385/// as the three arguments to this function; that produces
386/// a check that the library in use is compatible with
387/// the version of GTK+ the application or module was compiled
388/// against.
389///
390/// Compatibility is defined by two things: first the version
391/// of the running library is newer than the version
392/// `required_major`.`required_micro`. Second
393/// the running library must be binary compatible with the
394/// version `required_major`.`required_micro`
395/// (same major version.)
396///
397/// This function is primarily for GTK+ modules; the module
398/// can call this function to check that it wasn’t loaded
399/// into an incompatible version of GTK+. However, such a
400/// check isn’t completely reliable, since the module may be
401/// linked against an old version of GTK+ and calling the
402/// old version of [`check_version()`][crate::check_version()], but still get loaded
403/// into an application using a newer version of GTK+.
404/// ## `required_major`
405/// the required major version
406/// ## `required_minor`
407/// the required minor version
408/// ## `required_micro`
409/// the required micro version
410///
411/// # Returns
412///
413/// [`None`] if the GTK+ library is compatible with the
414/// given version, or a string describing the version mismatch.
415/// The returned string is owned by GTK+ and should not be modified
416/// or freed.
417#[doc(alias = "gtk_check_version")]
418pub fn check_version(
419 required_major: u32,
420 required_minor: u32,
421 required_micro: u32,
422) -> Option<glib::GString> {
423 skip_assert_initialized!();
424 unsafe {
425 from_glib_none(ffi::gtk_check_version(
426 required_major,
427 required_minor,
428 required_micro,
429 ))
430 }
431}
432
433/// Adds a GTK+ grab on `device`, so all the events on `device` and its
434/// associated pointer or keyboard (if any) are delivered to `widget`.
435/// If the `block_others` parameter is [`true`], any other devices will be
436/// unable to interact with `widget` during the grab.
437/// ## `widget`
438/// a [`Widget`][crate::Widget]
439/// ## `device`
440/// a [`gdk::Device`][crate::gdk::Device] to grab on.
441/// ## `block_others`
442/// [`true`] to prevent other devices to interact with `widget`.
443#[doc(alias = "gtk_device_grab_add")]
444pub fn device_grab_add(widget: &impl IsA<Widget>, device: &gdk::Device, block_others: bool) {
445 skip_assert_initialized!();
446 unsafe {
447 ffi::gtk_device_grab_add(
448 widget.as_ref().to_glib_none().0,
449 device.to_glib_none().0,
450 block_others.into_glib(),
451 );
452 }
453}
454
455/// Removes a device grab from the given widget.
456///
457/// You have to pair calls to [`device_grab_add()`][crate::device_grab_add()] and
458/// [`device_grab_remove()`][crate::device_grab_remove()].
459/// ## `widget`
460/// a [`Widget`][crate::Widget]
461/// ## `device`
462/// a [`gdk::Device`][crate::gdk::Device]
463#[doc(alias = "gtk_device_grab_remove")]
464pub fn device_grab_remove(widget: &impl IsA<Widget>, device: &gdk::Device) {
465 skip_assert_initialized!();
466 unsafe {
467 ffi::gtk_device_grab_remove(widget.as_ref().to_glib_none().0, device.to_glib_none().0);
468 }
469}
470
471/// Prevents `gtk_init()`, `gtk_init_check()`, `gtk_init_with_args()` and
472/// `gtk_parse_args()` from automatically
473/// calling `setlocale (LC_ALL, "")`. You would
474/// want to use this function if you wanted to set the locale for
475/// your program to something other than the user’s locale, or if
476/// you wanted to set different values for different locale categories.
477///
478/// Most programs should not need to call this function.
479#[doc(alias = "gtk_disable_setlocale")]
480pub fn disable_setlocale() {
481 assert_not_initialized!();
482 unsafe {
483 ffi::gtk_disable_setlocale();
484 }
485}
486
487//#[doc(alias = "gtk_distribute_natural_allocation")]
488//pub fn distribute_natural_allocation(extra_space: i32, n_requested_sizes: u32, sizes: /*Ignored*/&mut RequestedSize) -> i32 {
489// unsafe { TODO: call ffi:gtk_distribute_natural_allocation() }
490//}
491
492///
493/// // computation going on...
494///
495/// while (gtk_events_pending ())
496/// gtk_main_iteration ();
497///
498/// // ...computation continued
499/// ]|
500///
501/// # Returns
502///
503/// [`true`] if any events are pending, [`false`] otherwise
504#[doc(alias = "gtk_events_pending")]
505pub fn events_pending() -> bool {
506 assert_initialized_main_thread!();
507 unsafe { from_glib(ffi::gtk_events_pending()) }
508}
509
510/// Analogical to [`true_()`][crate::true_()], this function does nothing
511/// but always returns [`false`].
512///
513/// # Returns
514///
515/// [`false`]
516#[doc(alias = "gtk_false")]
517#[doc(alias = "false")]
518pub fn false_() -> bool {
519 assert_initialized_main_thread!();
520 unsafe { from_glib(ffi::gtk_false()) }
521}
522
523/// Returns the binary age as passed to `libtool`
524/// when building the GTK+ library the process is running against.
525/// If `libtool` means nothing to you, don't
526/// worry about it.
527///
528/// # Returns
529///
530/// the binary age of the GTK+ library
531#[doc(alias = "gtk_get_binary_age")]
532#[doc(alias = "get_binary_age")]
533pub fn binary_age() -> u32 {
534 skip_assert_initialized!();
535 unsafe { ffi::gtk_get_binary_age() }
536}
537
538/// Obtains a copy of the event currently being processed by GTK+.
539///
540/// For example, if you are handling a [`clicked`][struct@crate::Button#clicked] signal,
541/// the current event will be the [`gdk::EventButton`][crate::gdk::EventButton] that triggered
542/// the ::clicked signal.
543///
544/// # Returns
545///
546/// a copy of the current event, or
547/// [`None`] if there is no current event. The returned event must be
548/// freed with `gdk_event_free()`.
549#[doc(alias = "gtk_get_current_event")]
550#[doc(alias = "get_current_event")]
551pub fn current_event() -> Option<gdk::Event> {
552 assert_initialized_main_thread!();
553 unsafe { from_glib_full(ffi::gtk_get_current_event()) }
554}
555
556/// If there is a current event and it has a device, return that
557/// device, otherwise return [`None`].
558///
559/// # Returns
560///
561/// a [`gdk::Device`][crate::gdk::Device], or [`None`]
562#[doc(alias = "gtk_get_current_event_device")]
563#[doc(alias = "get_current_event_device")]
564pub fn current_event_device() -> Option<gdk::Device> {
565 assert_initialized_main_thread!();
566 unsafe { from_glib_none(ffi::gtk_get_current_event_device()) }
567}
568
569/// If there is a current event and it has a state field, place
570/// that state field in `state` and return [`true`], otherwise return
571/// [`false`].
572///
573/// # Returns
574///
575/// [`true`] if there was a current event and it
576/// had a state field
577///
578/// ## `state`
579/// a location to store the state of the current event
580#[doc(alias = "gtk_get_current_event_state")]
581#[doc(alias = "get_current_event_state")]
582pub fn current_event_state() -> Option<gdk::ModifierType> {
583 assert_initialized_main_thread!();
584 unsafe {
585 let mut state = std::mem::MaybeUninit::uninit();
586 let ret = from_glib(ffi::gtk_get_current_event_state(state.as_mut_ptr()));
587 if ret {
588 Some(from_glib(state.assume_init()))
589 } else {
590 None
591 }
592 }
593}
594
595/// If there is a current event and it has a timestamp,
596/// return that timestamp, otherwise return `GDK_CURRENT_TIME`.
597///
598/// # Returns
599///
600/// the timestamp from the current event,
601/// or `GDK_CURRENT_TIME`.
602#[doc(alias = "gtk_get_current_event_time")]
603#[doc(alias = "get_current_event_time")]
604pub fn current_event_time() -> u32 {
605 assert_initialized_main_thread!();
606 unsafe { ffi::gtk_get_current_event_time() }
607}
608
609/// Returns the GTK+ debug flags.
610///
611/// This function is intended for GTK+ modules that want
612/// to adjust their debug output based on GTK+ debug flags.
613///
614/// # Returns
615///
616/// the GTK+ debug flags.
617#[doc(alias = "gtk_get_debug_flags")]
618#[doc(alias = "get_debug_flags")]
619pub fn debug_flags() -> u32 {
620 assert_initialized_main_thread!();
621 unsafe { ffi::gtk_get_debug_flags() }
622}
623
624/// Returns the [`pango::Language`][crate::pango::Language] for the default language currently in
625/// effect. (Note that this can change over the life of an
626/// application.) The default language is derived from the current
627/// locale. It determines, for example, whether GTK+ uses the
628/// right-to-left or left-to-right text direction.
629///
630/// This function is equivalent to [`pango::Language::default()`][crate::pango::Language::default()].
631/// See that function for details.
632///
633/// # Returns
634///
635/// the default language as a [`pango::Language`][crate::pango::Language],
636/// must not be freed
637#[doc(alias = "gtk_get_default_language")]
638#[doc(alias = "get_default_language")]
639pub fn default_language() -> Option<pango::Language> {
640 assert_initialized_main_thread!();
641 unsafe { from_glib_none(ffi::gtk_get_default_language()) }
642}
643
644/// If `event` is [`None`] or the event was not associated with any widget,
645/// returns [`None`], otherwise returns the widget that received the event
646/// originally.
647/// ## `event`
648/// a `GdkEvent`
649///
650/// # Returns
651///
652/// the widget that originally
653/// received `event`, or [`None`]
654#[doc(alias = "gtk_get_event_widget")]
655#[doc(alias = "get_event_widget")]
656pub fn event_widget(event: &mut gdk::Event) -> Option<Widget> {
657 assert_initialized_main_thread!();
658 unsafe { from_glib_none(ffi::gtk_get_event_widget(event.to_glib_none_mut().0)) }
659}
660
661/// Returns the interface age as passed to `libtool`
662/// when building the GTK+ library the process is running against.
663/// If `libtool` means nothing to you, don't
664/// worry about it.
665///
666/// # Returns
667///
668/// the interface age of the GTK+ library
669#[doc(alias = "gtk_get_interface_age")]
670#[doc(alias = "get_interface_age")]
671pub fn interface_age() -> u32 {
672 skip_assert_initialized!();
673 unsafe { ffi::gtk_get_interface_age() }
674}
675
676///
677/// setlocale (LC_ALL, new_locale);
678/// direction = gtk_get_locale_direction ();
679/// gtk_widget_set_default_direction (direction);
680/// ]|
681///
682/// # Returns
683///
684/// the [`TextDirection`][crate::TextDirection] of the current locale
685#[doc(alias = "gtk_get_locale_direction")]
686#[doc(alias = "get_locale_direction")]
687pub fn locale_direction() -> TextDirection {
688 assert_initialized_main_thread!();
689 unsafe { from_glib(ffi::gtk_get_locale_direction()) }
690}
691
692/// Returns the major version number of the GTK+ library.
693/// (e.g. in GTK+ version 3.1.5 this is 3.)
694///
695/// This function is in the library, so it represents the GTK+ library
696/// your code is running against. Contrast with the `GTK_MAJOR_VERSION`
697/// macro, which represents the major version of the GTK+ headers you
698/// have included when compiling your code.
699///
700/// # Returns
701///
702/// the major version number of the GTK+ library
703#[doc(alias = "gtk_get_major_version")]
704#[doc(alias = "get_major_version")]
705pub fn major_version() -> u32 {
706 skip_assert_initialized!();
707 unsafe { ffi::gtk_get_major_version() }
708}
709
710/// Returns the micro version number of the GTK+ library.
711/// (e.g. in GTK+ version 3.1.5 this is 5.)
712///
713/// This function is in the library, so it represents the GTK+ library
714/// your code is are running against. Contrast with the
715/// `GTK_MICRO_VERSION` macro, which represents the micro version of the
716/// GTK+ headers you have included when compiling your code.
717///
718/// # Returns
719///
720/// the micro version number of the GTK+ library
721#[doc(alias = "gtk_get_micro_version")]
722#[doc(alias = "get_micro_version")]
723pub fn micro_version() -> u32 {
724 skip_assert_initialized!();
725 unsafe { ffi::gtk_get_micro_version() }
726}
727
728/// Returns the minor version number of the GTK+ library.
729/// (e.g. in GTK+ version 3.1.5 this is 1.)
730///
731/// This function is in the library, so it represents the GTK+ library
732/// your code is are running against. Contrast with the
733/// `GTK_MINOR_VERSION` macro, which represents the minor version of the
734/// GTK+ headers you have included when compiling your code.
735///
736/// # Returns
737///
738/// the minor version number of the GTK+ library
739#[doc(alias = "gtk_get_minor_version")]
740#[doc(alias = "get_minor_version")]
741pub fn minor_version() -> u32 {
742 skip_assert_initialized!();
743 unsafe { ffi::gtk_get_minor_version() }
744}
745
746//#[doc(alias = "gtk_get_option_group")]
747//#[doc(alias = "get_option_group")]
748//pub fn option_group(open_default_display: bool) -> /*Ignored*/Option<glib::OptionGroup> {
749// unsafe { TODO: call ffi:gtk_get_option_group() }
750//}
751
752/// Queries the current grab of the default window group.
753///
754/// # Returns
755///
756/// The widget which currently
757/// has the grab or [`None`] if no grab is active
758#[doc(alias = "gtk_grab_get_current")]
759pub fn grab_get_current() -> Option<Widget> {
760 assert_initialized_main_thread!();
761 unsafe { from_glib_none(ffi::gtk_grab_get_current()) }
762}
763
764/// Runs the main loop until `gtk_main_quit()` is called.
765///
766/// You can nest calls to [`main()`][crate::main()]. In that case `gtk_main_quit()`
767/// will make the innermost invocation of the main loop return.
768#[doc(alias = "gtk_main")]
769pub fn main() {
770 assert_initialized_main_thread!();
771 unsafe {
772 ffi::gtk_main();
773 }
774}
775
776/// Processes a single GDK event.
777///
778/// This is public only to allow filtering of events between GDK and GTK+.
779/// You will not usually need to call this function directly.
780///
781/// While you should not call this function directly, you might want to
782/// know how exactly events are handled. So here is what this function
783/// does with the event:
784///
785/// 1. Compress enter/leave notify events. If the event passed build an
786/// enter/leave pair together with the next event (peeked from GDK), both
787/// events are thrown away. This is to avoid a backlog of (de-)highlighting
788/// widgets crossed by the pointer.
789///
790/// 2. Find the widget which got the event. If the widget can’t be determined
791/// the event is thrown away unless it belongs to a INCR transaction.
792///
793/// 3. Then the event is pushed onto a stack so you can query the currently
794/// handled event with [`current_event()`][crate::current_event()].
795///
796/// 4. The event is sent to a widget. If a grab is active all events for widgets
797/// that are not in the contained in the grab widget are sent to the latter
798/// with a few exceptions:
799/// - Deletion and destruction events are still sent to the event widget for
800/// obvious reasons.
801/// - Events which directly relate to the visual representation of the event
802/// widget.
803/// - Leave events are delivered to the event widget if there was an enter
804/// event delivered to it before without the paired leave event.
805/// - Drag events are not redirected because it is unclear what the semantics
806/// of that would be.
807/// Another point of interest might be that all key events are first passed
808/// through the key snooper functions if there are any. Read the description
809/// of `gtk_key_snooper_install()` if you need this feature.
810///
811/// 5. After finishing the delivery the event is popped from the event stack.
812/// ## `event`
813/// An event to process (normally passed by GDK)
814#[doc(alias = "gtk_main_do_event")]
815pub fn main_do_event(event: &mut gdk::Event) {
816 assert_initialized_main_thread!();
817 unsafe {
818 ffi::gtk_main_do_event(event.to_glib_none_mut().0);
819 }
820}
821
822/// Runs a single iteration of the mainloop.
823///
824/// If no events are waiting to be processed GTK+ will block
825/// until the next event is noticed. If you don’t want to block
826/// look at [`main_iteration_do()`][crate::main_iteration_do()] or check if any events are
827/// pending with [`events_pending()`][crate::events_pending()] first.
828///
829/// # Returns
830///
831/// [`true`] if `gtk_main_quit()` has been called for the
832/// innermost mainloop
833#[doc(alias = "gtk_main_iteration")]
834pub fn main_iteration() -> bool {
835 assert_initialized_main_thread!();
836 unsafe { from_glib(ffi::gtk_main_iteration()) }
837}
838
839/// Runs a single iteration of the mainloop.
840/// If no events are available either return or block depending on
841/// the value of `blocking`.
842/// ## `blocking`
843/// [`true`] if you want GTK+ to block if no events are pending
844///
845/// # Returns
846///
847/// [`true`] if `gtk_main_quit()` has been called for the
848/// innermost mainloop
849#[doc(alias = "gtk_main_iteration_do")]
850pub fn main_iteration_do(blocking: bool) -> bool {
851 assert_initialized_main_thread!();
852 unsafe { from_glib(ffi::gtk_main_iteration_do(blocking.into_glib())) }
853}
854
855/// Asks for the current nesting level of the main loop.
856///
857/// # Returns
858///
859/// the nesting level of the current invocation
860/// of the main loop
861#[doc(alias = "gtk_main_level")]
862pub fn main_level() -> u32 {
863 assert_initialized_main_thread!();
864 unsafe { ffi::gtk_main_level() }
865}
866
867/// Runs a page setup dialog, letting the user modify the values from
868/// `page_setup`. If the user cancels the dialog, the returned [`PageSetup`][crate::PageSetup]
869/// is identical to the passed in `page_setup`, otherwise it contains the
870/// modifications done in the dialog.
871///
872/// Note that this function may use a recursive mainloop to show the page
873/// setup dialog. See [`print_run_page_setup_dialog_async()`][crate::print_run_page_setup_dialog_async()] if this is
874/// a problem.
875/// ## `parent`
876/// transient parent
877/// ## `page_setup`
878/// an existing [`PageSetup`][crate::PageSetup]
879/// ## `settings`
880/// a [`PrintSettings`][crate::PrintSettings]
881///
882/// # Returns
883///
884/// a new [`PageSetup`][crate::PageSetup]
885#[doc(alias = "gtk_print_run_page_setup_dialog")]
886pub fn print_run_page_setup_dialog(
887 parent: Option<&impl IsA<Window>>,
888 page_setup: Option<&PageSetup>,
889 settings: &PrintSettings,
890) -> Option<PageSetup> {
891 skip_assert_initialized!();
892 unsafe {
893 from_glib_full(ffi::gtk_print_run_page_setup_dialog(
894 parent.map(|p| p.as_ref()).to_glib_none().0,
895 page_setup.to_glib_none().0,
896 settings.to_glib_none().0,
897 ))
898 }
899}
900
901/// Runs a page setup dialog, letting the user modify the values from `page_setup`.
902///
903/// In contrast to [`print_run_page_setup_dialog()`][crate::print_run_page_setup_dialog()], this function returns after
904/// showing the page setup dialog on platforms that support this, and calls `done_cb`
905/// from a signal handler for the ::response signal of the dialog.
906/// ## `parent`
907/// transient parent, or [`None`]
908/// ## `page_setup`
909/// an existing [`PageSetup`][crate::PageSetup], or [`None`]
910/// ## `settings`
911/// a [`PrintSettings`][crate::PrintSettings]
912/// ## `done_cb`
913/// a function to call when the user saves
914/// the modified page setup
915#[doc(alias = "gtk_print_run_page_setup_dialog_async")]
916pub fn print_run_page_setup_dialog_async<P: FnOnce(&PageSetup) + Send + Sync + 'static>(
917 parent: Option<&impl IsA<Window>>,
918 page_setup: Option<&PageSetup>,
919 settings: &PrintSettings,
920 done_cb: P,
921) {
922 skip_assert_initialized!();
923 let done_cb_data: Box_<P> = Box_::new(done_cb);
924 unsafe extern "C" fn done_cb_func<P: FnOnce(&PageSetup) + Send + Sync + 'static>(
925 page_setup: *mut ffi::GtkPageSetup,
926 data: glib::ffi::gpointer,
927 ) {
928 unsafe {
929 let page_setup = from_glib_borrow(page_setup);
930 let callback = Box_::from_raw(data as *mut P);
931 (*callback)(&page_setup)
932 }
933 }
934 let done_cb = Some(done_cb_func::<P> as _);
935 let super_callback0: Box_<P> = done_cb_data;
936 unsafe {
937 ffi::gtk_print_run_page_setup_dialog_async(
938 parent.map(|p| p.as_ref()).to_glib_none().0,
939 page_setup.to_glib_none().0,
940 settings.to_glib_none().0,
941 done_cb,
942 Box_::into_raw(super_callback0) as *mut _,
943 );
944 }
945}
946
947/// Sends an event to a widget, propagating the event to parent widgets
948/// if the event remains unhandled.
949///
950/// Events received by GTK+ from GDK normally begin in [`main_do_event()`][crate::main_do_event()].
951/// Depending on the type of event, existence of modal dialogs, grabs, etc.,
952/// the event may be propagated; if so, this function is used.
953///
954/// [`propagate_event()`][crate::propagate_event()] calls [`WidgetExt::event()`][crate::prelude::WidgetExt::event()] on each widget it
955/// decides to send the event to. So [`WidgetExt::event()`][crate::prelude::WidgetExt::event()] is the lowest-level
956/// function; it simply emits the [`event`][struct@crate::Widget#event] and possibly an
957/// event-specific signal on a widget. [`propagate_event()`][crate::propagate_event()] is a bit
958/// higher-level, and [`main_do_event()`][crate::main_do_event()] is the highest level.
959///
960/// All that said, you most likely don’t want to use any of these
961/// functions; synthesizing events is rarely needed. There are almost
962/// certainly better ways to achieve your goals. For example, use
963/// [`Window::invalidate_rect()`][crate::gdk::Window::invalidate_rect()] or [`WidgetExt::queue_draw()`][crate::prelude::WidgetExt::queue_draw()] instead
964/// of making up expose events.
965/// ## `widget`
966/// a [`Widget`][crate::Widget]
967/// ## `event`
968/// an event
969#[doc(alias = "gtk_propagate_event")]
970pub fn propagate_event(widget: &impl IsA<Widget>, event: &mut gdk::Event) {
971 skip_assert_initialized!();
972 unsafe {
973 ffi::gtk_propagate_event(widget.as_ref().to_glib_none().0, event.to_glib_none_mut().0);
974 }
975}
976
977/// Renders an activity indicator (such as in [`Spinner`][crate::Spinner]).
978/// The state [`StateFlags::CHECKED`][crate::StateFlags::CHECKED] determines whether there is
979/// activity going on.
980/// ## `context`
981/// a [`StyleContext`][crate::StyleContext]
982/// ## `cr`
983/// a [`cairo::Context`][crate::cairo::Context]
984/// ## `x`
985/// X origin of the rectangle
986/// ## `y`
987/// Y origin of the rectangle
988/// ## `width`
989/// rectangle width
990/// ## `height`
991/// rectangle height
992#[doc(alias = "gtk_render_activity")]
993pub fn render_activity(
994 context: &impl IsA<StyleContext>,
995 cr: &cairo::Context,
996 x: f64,
997 y: f64,
998 width: f64,
999 height: f64,
1000) {
1001 skip_assert_initialized!();
1002 unsafe {
1003 ffi::gtk_render_activity(
1004 context.as_ref().to_glib_none().0,
1005 mut_override(cr.to_glib_none().0),
1006 x,
1007 y,
1008 width,
1009 height,
1010 );
1011 }
1012}
1013
1014/// Renders an arrow pointing to `angle`.
1015///
1016/// Typical arrow rendering at 0, 1⁄2 π;, π; and 3⁄2 π:
1017///
1018/// 
1019/// ## `context`
1020/// a [`StyleContext`][crate::StyleContext]
1021/// ## `cr`
1022/// a [`cairo::Context`][crate::cairo::Context]
1023/// ## `angle`
1024/// arrow angle from 0 to 2 * `G_PI`, being 0 the arrow pointing to the north
1025/// ## `x`
1026/// X origin of the render area
1027/// ## `y`
1028/// Y origin of the render area
1029/// ## `size`
1030/// square side for render area
1031#[doc(alias = "gtk_render_arrow")]
1032pub fn render_arrow(
1033 context: &impl IsA<StyleContext>,
1034 cr: &cairo::Context,
1035 angle: f64,
1036 x: f64,
1037 y: f64,
1038 size: f64,
1039) {
1040 skip_assert_initialized!();
1041 unsafe {
1042 ffi::gtk_render_arrow(
1043 context.as_ref().to_glib_none().0,
1044 mut_override(cr.to_glib_none().0),
1045 angle,
1046 x,
1047 y,
1048 size,
1049 );
1050 }
1051}
1052
1053/// Renders the background of an element.
1054///
1055/// Typical background rendering, showing the effect of
1056/// `background-image`, `border-width` and `border-radius`:
1057///
1058/// 
1059/// ## `context`
1060/// a [`StyleContext`][crate::StyleContext]
1061/// ## `cr`
1062/// a [`cairo::Context`][crate::cairo::Context]
1063/// ## `x`
1064/// X origin of the rectangle
1065/// ## `y`
1066/// Y origin of the rectangle
1067/// ## `width`
1068/// rectangle width
1069/// ## `height`
1070/// rectangle height
1071#[doc(alias = "gtk_render_background")]
1072pub fn render_background(
1073 context: &impl IsA<StyleContext>,
1074 cr: &cairo::Context,
1075 x: f64,
1076 y: f64,
1077 width: f64,
1078 height: f64,
1079) {
1080 skip_assert_initialized!();
1081 unsafe {
1082 ffi::gtk_render_background(
1083 context.as_ref().to_glib_none().0,
1084 mut_override(cr.to_glib_none().0),
1085 x,
1086 y,
1087 width,
1088 height,
1089 );
1090 }
1091}
1092
1093/// Returns the area that will be affected (i.e. drawn to) when
1094/// calling [`render_background()`][crate::render_background()] for the given `context` and
1095/// rectangle.
1096/// ## `context`
1097/// a [`StyleContext`][crate::StyleContext]
1098/// ## `x`
1099/// X origin of the rectangle
1100/// ## `y`
1101/// Y origin of the rectangle
1102/// ## `width`
1103/// rectangle width
1104/// ## `height`
1105/// rectangle height
1106///
1107/// # Returns
1108///
1109///
1110/// ## `out_clip`
1111/// return location for the clip
1112#[doc(alias = "gtk_render_background_get_clip")]
1113pub fn render_background_get_clip(
1114 context: &impl IsA<StyleContext>,
1115 x: f64,
1116 y: f64,
1117 width: f64,
1118 height: f64,
1119) -> gdk::Rectangle {
1120 skip_assert_initialized!();
1121 unsafe {
1122 let mut out_clip = gdk::Rectangle::uninitialized();
1123 ffi::gtk_render_background_get_clip(
1124 context.as_ref().to_glib_none().0,
1125 x,
1126 y,
1127 width,
1128 height,
1129 out_clip.to_glib_none_mut().0,
1130 );
1131 out_clip
1132 }
1133}
1134
1135/// Renders a checkmark (as in a [`CheckButton`][crate::CheckButton]).
1136///
1137/// The [`StateFlags::CHECKED`][crate::StateFlags::CHECKED] state determines whether the check is
1138/// on or off, and [`StateFlags::INCONSISTENT`][crate::StateFlags::INCONSISTENT] determines whether it
1139/// should be marked as undefined.
1140///
1141/// Typical checkmark rendering:
1142///
1143/// 
1144/// ## `context`
1145/// a [`StyleContext`][crate::StyleContext]
1146/// ## `cr`
1147/// a [`cairo::Context`][crate::cairo::Context]
1148/// ## `x`
1149/// X origin of the rectangle
1150/// ## `y`
1151/// Y origin of the rectangle
1152/// ## `width`
1153/// rectangle width
1154/// ## `height`
1155/// rectangle height
1156#[doc(alias = "gtk_render_check")]
1157pub fn render_check(
1158 context: &impl IsA<StyleContext>,
1159 cr: &cairo::Context,
1160 x: f64,
1161 y: f64,
1162 width: f64,
1163 height: f64,
1164) {
1165 skip_assert_initialized!();
1166 unsafe {
1167 ffi::gtk_render_check(
1168 context.as_ref().to_glib_none().0,
1169 mut_override(cr.to_glib_none().0),
1170 x,
1171 y,
1172 width,
1173 height,
1174 );
1175 }
1176}
1177
1178/// Renders an expander (as used in [`TreeView`][crate::TreeView] and [`Expander`][crate::Expander]) in the area
1179/// defined by `x`, `y`, `width`, `height`. The state [`StateFlags::CHECKED`][crate::StateFlags::CHECKED]
1180/// determines whether the expander is collapsed or expanded.
1181///
1182/// Typical expander rendering:
1183///
1184/// 
1185/// ## `context`
1186/// a [`StyleContext`][crate::StyleContext]
1187/// ## `cr`
1188/// a [`cairo::Context`][crate::cairo::Context]
1189/// ## `x`
1190/// X origin of the rectangle
1191/// ## `y`
1192/// Y origin of the rectangle
1193/// ## `width`
1194/// rectangle width
1195/// ## `height`
1196/// rectangle height
1197#[doc(alias = "gtk_render_expander")]
1198pub fn render_expander(
1199 context: &impl IsA<StyleContext>,
1200 cr: &cairo::Context,
1201 x: f64,
1202 y: f64,
1203 width: f64,
1204 height: f64,
1205) {
1206 skip_assert_initialized!();
1207 unsafe {
1208 ffi::gtk_render_expander(
1209 context.as_ref().to_glib_none().0,
1210 mut_override(cr.to_glib_none().0),
1211 x,
1212 y,
1213 width,
1214 height,
1215 );
1216 }
1217}
1218
1219/// Renders a extension (as in a [`Notebook`][crate::Notebook] tab) in the rectangle
1220/// defined by `x`, `y`, `width`, `height`. The side where the extension
1221/// connects to is defined by `gap_side`.
1222///
1223/// Typical extension rendering:
1224///
1225/// 
1226/// ## `context`
1227/// a [`StyleContext`][crate::StyleContext]
1228/// ## `cr`
1229/// a [`cairo::Context`][crate::cairo::Context]
1230/// ## `x`
1231/// X origin of the rectangle
1232/// ## `y`
1233/// Y origin of the rectangle
1234/// ## `width`
1235/// rectangle width
1236/// ## `height`
1237/// rectangle height
1238/// ## `gap_side`
1239/// side where the gap is
1240#[doc(alias = "gtk_render_extension")]
1241pub fn render_extension(
1242 context: &impl IsA<StyleContext>,
1243 cr: &cairo::Context,
1244 x: f64,
1245 y: f64,
1246 width: f64,
1247 height: f64,
1248 gap_side: PositionType,
1249) {
1250 skip_assert_initialized!();
1251 unsafe {
1252 ffi::gtk_render_extension(
1253 context.as_ref().to_glib_none().0,
1254 mut_override(cr.to_glib_none().0),
1255 x,
1256 y,
1257 width,
1258 height,
1259 gap_side.into_glib(),
1260 );
1261 }
1262}
1263
1264/// Renders a focus indicator on the rectangle determined by `x`, `y`, `width`, `height`.
1265///
1266/// Typical focus rendering:
1267///
1268/// 
1269/// ## `context`
1270/// a [`StyleContext`][crate::StyleContext]
1271/// ## `cr`
1272/// a [`cairo::Context`][crate::cairo::Context]
1273/// ## `x`
1274/// X origin of the rectangle
1275/// ## `y`
1276/// Y origin of the rectangle
1277/// ## `width`
1278/// rectangle width
1279/// ## `height`
1280/// rectangle height
1281#[doc(alias = "gtk_render_focus")]
1282pub fn render_focus(
1283 context: &impl IsA<StyleContext>,
1284 cr: &cairo::Context,
1285 x: f64,
1286 y: f64,
1287 width: f64,
1288 height: f64,
1289) {
1290 skip_assert_initialized!();
1291 unsafe {
1292 ffi::gtk_render_focus(
1293 context.as_ref().to_glib_none().0,
1294 mut_override(cr.to_glib_none().0),
1295 x,
1296 y,
1297 width,
1298 height,
1299 );
1300 }
1301}
1302
1303/// Renders a frame around the rectangle defined by `x`, `y`, `width`, `height`.
1304///
1305/// Examples of frame rendering, showing the effect of `border-image`,
1306/// `border-color`, `border-width`, `border-radius` and junctions:
1307///
1308/// 
1309/// ## `context`
1310/// a [`StyleContext`][crate::StyleContext]
1311/// ## `cr`
1312/// a [`cairo::Context`][crate::cairo::Context]
1313/// ## `x`
1314/// X origin of the rectangle
1315/// ## `y`
1316/// Y origin of the rectangle
1317/// ## `width`
1318/// rectangle width
1319/// ## `height`
1320/// rectangle height
1321#[doc(alias = "gtk_render_frame")]
1322pub fn render_frame(
1323 context: &impl IsA<StyleContext>,
1324 cr: &cairo::Context,
1325 x: f64,
1326 y: f64,
1327 width: f64,
1328 height: f64,
1329) {
1330 skip_assert_initialized!();
1331 unsafe {
1332 ffi::gtk_render_frame(
1333 context.as_ref().to_glib_none().0,
1334 mut_override(cr.to_glib_none().0),
1335 x,
1336 y,
1337 width,
1338 height,
1339 );
1340 }
1341}
1342
1343/// Renders a frame around the rectangle defined by (`x`, `y`, `width`, `height`),
1344/// leaving a gap on one side. `xy0_gap` and `xy1_gap` will mean X coordinates
1345/// for [`PositionType::Top`][crate::PositionType::Top] and [`PositionType::Bottom`][crate::PositionType::Bottom] gap sides, and Y coordinates for
1346/// [`PositionType::Left`][crate::PositionType::Left] and [`PositionType::Right`][crate::PositionType::Right].
1347///
1348/// Typical rendering of a frame with a gap:
1349///
1350/// 
1351///
1352/// # Deprecated since 3.24
1353///
1354/// Use [`render_frame()`][crate::render_frame()] instead. Themes can create gaps
1355/// by omitting borders via CSS.
1356/// ## `context`
1357/// a [`StyleContext`][crate::StyleContext]
1358/// ## `cr`
1359/// a [`cairo::Context`][crate::cairo::Context]
1360/// ## `x`
1361/// X origin of the rectangle
1362/// ## `y`
1363/// Y origin of the rectangle
1364/// ## `width`
1365/// rectangle width
1366/// ## `height`
1367/// rectangle height
1368/// ## `gap_side`
1369/// side where the gap is
1370/// ## `xy0_gap`
1371/// initial coordinate (X or Y depending on `gap_side`) for the gap
1372/// ## `xy1_gap`
1373/// end coordinate (X or Y depending on `gap_side`) for the gap
1374#[cfg_attr(feature = "v3_24", deprecated = "Since 3.24")]
1375#[allow(deprecated)]
1376#[doc(alias = "gtk_render_frame_gap")]
1377pub fn render_frame_gap(
1378 context: &impl IsA<StyleContext>,
1379 cr: &cairo::Context,
1380 x: f64,
1381 y: f64,
1382 width: f64,
1383 height: f64,
1384 gap_side: PositionType,
1385 xy0_gap: f64,
1386 xy1_gap: f64,
1387) {
1388 skip_assert_initialized!();
1389 unsafe {
1390 ffi::gtk_render_frame_gap(
1391 context.as_ref().to_glib_none().0,
1392 mut_override(cr.to_glib_none().0),
1393 x,
1394 y,
1395 width,
1396 height,
1397 gap_side.into_glib(),
1398 xy0_gap,
1399 xy1_gap,
1400 );
1401 }
1402}
1403
1404/// Renders a handle (as in `GtkHandleBox`, [`Paned`][crate::Paned] and
1405/// [`Window`][crate::Window]’s resize grip), in the rectangle
1406/// determined by `x`, `y`, `width`, `height`.
1407///
1408/// Handles rendered for the paned and grip classes:
1409///
1410/// 
1411/// ## `context`
1412/// a [`StyleContext`][crate::StyleContext]
1413/// ## `cr`
1414/// a [`cairo::Context`][crate::cairo::Context]
1415/// ## `x`
1416/// X origin of the rectangle
1417/// ## `y`
1418/// Y origin of the rectangle
1419/// ## `width`
1420/// rectangle width
1421/// ## `height`
1422/// rectangle height
1423#[doc(alias = "gtk_render_handle")]
1424pub fn render_handle(
1425 context: &impl IsA<StyleContext>,
1426 cr: &cairo::Context,
1427 x: f64,
1428 y: f64,
1429 width: f64,
1430 height: f64,
1431) {
1432 skip_assert_initialized!();
1433 unsafe {
1434 ffi::gtk_render_handle(
1435 context.as_ref().to_glib_none().0,
1436 mut_override(cr.to_glib_none().0),
1437 x,
1438 y,
1439 width,
1440 height,
1441 );
1442 }
1443}
1444
1445/// Renders the icon in `pixbuf` at the specified `x` and `y` coordinates.
1446///
1447/// This function will render the icon in `pixbuf` at exactly its size,
1448/// regardless of scaling factors, which may not be appropriate when
1449/// drawing on displays with high pixel densities.
1450///
1451/// You probably want to use [`render_icon_surface()`][crate::render_icon_surface()] instead, if you
1452/// already have a Cairo surface.
1453/// ## `context`
1454/// a [`StyleContext`][crate::StyleContext]
1455/// ## `cr`
1456/// a [`cairo::Context`][crate::cairo::Context]
1457/// ## `pixbuf`
1458/// a [`gdk_pixbuf::Pixbuf`][crate::gdk_pixbuf::Pixbuf] containing the icon to draw
1459/// ## `x`
1460/// X position for the `pixbuf`
1461/// ## `y`
1462/// Y position for the `pixbuf`
1463#[doc(alias = "gtk_render_icon")]
1464pub fn render_icon(
1465 context: &impl IsA<StyleContext>,
1466 cr: &cairo::Context,
1467 pixbuf: &gdk_pixbuf::Pixbuf,
1468 x: f64,
1469 y: f64,
1470) {
1471 skip_assert_initialized!();
1472 unsafe {
1473 ffi::gtk_render_icon(
1474 context.as_ref().to_glib_none().0,
1475 mut_override(cr.to_glib_none().0),
1476 pixbuf.to_glib_none().0,
1477 x,
1478 y,
1479 );
1480 }
1481}
1482
1483/// Renders the icon in `surface` at the specified `x` and `y` coordinates.
1484/// ## `context`
1485/// a [`StyleContext`][crate::StyleContext]
1486/// ## `cr`
1487/// a [`cairo::Context`][crate::cairo::Context]
1488/// ## `surface`
1489/// a [`cairo::Surface`][crate::cairo::Surface] containing the icon to draw
1490/// ## `x`
1491/// X position for the `icon`
1492/// ## `y`
1493/// Y position for the `incon`
1494#[doc(alias = "gtk_render_icon_surface")]
1495pub fn render_icon_surface(
1496 context: &impl IsA<StyleContext>,
1497 cr: &cairo::Context,
1498 surface: &cairo::Surface,
1499 x: f64,
1500 y: f64,
1501) {
1502 skip_assert_initialized!();
1503 unsafe {
1504 ffi::gtk_render_icon_surface(
1505 context.as_ref().to_glib_none().0,
1506 mut_override(cr.to_glib_none().0),
1507 mut_override(surface.to_glib_none().0),
1508 x,
1509 y,
1510 );
1511 }
1512}
1513
1514/// Draws a text caret on `cr` at the specified index of `layout`.
1515/// ## `context`
1516/// a [`StyleContext`][crate::StyleContext]
1517/// ## `cr`
1518/// a [`cairo::Context`][crate::cairo::Context]
1519/// ## `x`
1520/// X origin
1521/// ## `y`
1522/// Y origin
1523/// ## `layout`
1524/// the [`pango::Layout`][crate::pango::Layout] of the text
1525/// ## `index`
1526/// the index in the [`pango::Layout`][crate::pango::Layout]
1527/// ## `direction`
1528/// the [`pango::Direction`][crate::pango::Direction] of the text
1529#[doc(alias = "gtk_render_insertion_cursor")]
1530pub fn render_insertion_cursor(
1531 context: &impl IsA<StyleContext>,
1532 cr: &cairo::Context,
1533 x: f64,
1534 y: f64,
1535 layout: &pango::Layout,
1536 index: i32,
1537 direction: pango::Direction,
1538) {
1539 skip_assert_initialized!();
1540 unsafe {
1541 ffi::gtk_render_insertion_cursor(
1542 context.as_ref().to_glib_none().0,
1543 mut_override(cr.to_glib_none().0),
1544 x,
1545 y,
1546 layout.to_glib_none().0,
1547 index,
1548 direction.into_glib(),
1549 );
1550 }
1551}
1552
1553/// Renders `layout` on the coordinates `x`, `y`
1554/// ## `context`
1555/// a [`StyleContext`][crate::StyleContext]
1556/// ## `cr`
1557/// a [`cairo::Context`][crate::cairo::Context]
1558/// ## `x`
1559/// X origin
1560/// ## `y`
1561/// Y origin
1562/// ## `layout`
1563/// the [`pango::Layout`][crate::pango::Layout] to render
1564#[doc(alias = "gtk_render_layout")]
1565pub fn render_layout(
1566 context: &impl IsA<StyleContext>,
1567 cr: &cairo::Context,
1568 x: f64,
1569 y: f64,
1570 layout: &pango::Layout,
1571) {
1572 skip_assert_initialized!();
1573 unsafe {
1574 ffi::gtk_render_layout(
1575 context.as_ref().to_glib_none().0,
1576 mut_override(cr.to_glib_none().0),
1577 x,
1578 y,
1579 layout.to_glib_none().0,
1580 );
1581 }
1582}
1583
1584/// Renders a line from (x0, y0) to (x1, y1).
1585/// ## `context`
1586/// a [`StyleContext`][crate::StyleContext]
1587/// ## `cr`
1588/// a [`cairo::Context`][crate::cairo::Context]
1589/// ## `x0`
1590/// X coordinate for the origin of the line
1591/// ## `y0`
1592/// Y coordinate for the origin of the line
1593/// ## `x1`
1594/// X coordinate for the end of the line
1595/// ## `y1`
1596/// Y coordinate for the end of the line
1597#[doc(alias = "gtk_render_line")]
1598pub fn render_line(
1599 context: &impl IsA<StyleContext>,
1600 cr: &cairo::Context,
1601 x0: f64,
1602 y0: f64,
1603 x1: f64,
1604 y1: f64,
1605) {
1606 skip_assert_initialized!();
1607 unsafe {
1608 ffi::gtk_render_line(
1609 context.as_ref().to_glib_none().0,
1610 mut_override(cr.to_glib_none().0),
1611 x0,
1612 y0,
1613 x1,
1614 y1,
1615 );
1616 }
1617}
1618
1619/// Renders an option mark (as in a [`RadioButton`][crate::RadioButton]), the [`StateFlags::CHECKED`][crate::StateFlags::CHECKED]
1620/// state will determine whether the option is on or off, and
1621/// [`StateFlags::INCONSISTENT`][crate::StateFlags::INCONSISTENT] whether it should be marked as undefined.
1622///
1623/// Typical option mark rendering:
1624///
1625/// 
1626/// ## `context`
1627/// a [`StyleContext`][crate::StyleContext]
1628/// ## `cr`
1629/// a [`cairo::Context`][crate::cairo::Context]
1630/// ## `x`
1631/// X origin of the rectangle
1632/// ## `y`
1633/// Y origin of the rectangle
1634/// ## `width`
1635/// rectangle width
1636/// ## `height`
1637/// rectangle height
1638#[doc(alias = "gtk_render_option")]
1639pub fn render_option(
1640 context: &impl IsA<StyleContext>,
1641 cr: &cairo::Context,
1642 x: f64,
1643 y: f64,
1644 width: f64,
1645 height: f64,
1646) {
1647 skip_assert_initialized!();
1648 unsafe {
1649 ffi::gtk_render_option(
1650 context.as_ref().to_glib_none().0,
1651 mut_override(cr.to_glib_none().0),
1652 x,
1653 y,
1654 width,
1655 height,
1656 );
1657 }
1658}
1659
1660/// Renders a slider (as in [`Scale`][crate::Scale]) in the rectangle defined by `x`, `y`,
1661/// `width`, `height`. `orientation` defines whether the slider is vertical
1662/// or horizontal.
1663///
1664/// Typical slider rendering:
1665///
1666/// 
1667/// ## `context`
1668/// a [`StyleContext`][crate::StyleContext]
1669/// ## `cr`
1670/// a [`cairo::Context`][crate::cairo::Context]
1671/// ## `x`
1672/// X origin of the rectangle
1673/// ## `y`
1674/// Y origin of the rectangle
1675/// ## `width`
1676/// rectangle width
1677/// ## `height`
1678/// rectangle height
1679/// ## `orientation`
1680/// orientation of the slider
1681#[doc(alias = "gtk_render_slider")]
1682pub fn render_slider(
1683 context: &impl IsA<StyleContext>,
1684 cr: &cairo::Context,
1685 x: f64,
1686 y: f64,
1687 width: f64,
1688 height: f64,
1689 orientation: Orientation,
1690) {
1691 skip_assert_initialized!();
1692 unsafe {
1693 ffi::gtk_render_slider(
1694 context.as_ref().to_glib_none().0,
1695 mut_override(cr.to_glib_none().0),
1696 x,
1697 y,
1698 width,
1699 height,
1700 orientation.into_glib(),
1701 );
1702 }
1703}
1704
1705/// Converts a color from RGB space to HSV.
1706///
1707/// Input values must be in the [0.0, 1.0] range;
1708/// output values will be in the same range.
1709/// ## `r`
1710/// Red
1711/// ## `g`
1712/// Green
1713/// ## `b`
1714/// Blue
1715///
1716/// # Returns
1717///
1718///
1719/// ## `h`
1720/// Return value for the hue component
1721///
1722/// ## `s`
1723/// Return value for the saturation component
1724///
1725/// ## `v`
1726/// Return value for the value component
1727#[doc(alias = "gtk_rgb_to_hsv")]
1728pub fn rgb_to_hsv(r: f64, g: f64, b: f64) -> (f64, f64, f64) {
1729 assert_initialized_main_thread!();
1730 unsafe {
1731 let mut h = std::mem::MaybeUninit::uninit();
1732 let mut s = std::mem::MaybeUninit::uninit();
1733 let mut v = std::mem::MaybeUninit::uninit();
1734 ffi::gtk_rgb_to_hsv(r, g, b, h.as_mut_ptr(), s.as_mut_ptr(), v.as_mut_ptr());
1735 (h.assume_init(), s.assume_init(), v.assume_init())
1736 }
1737}
1738
1739/// Appends a specified target to the list of supported targets for a
1740/// given widget and selection.
1741/// ## `widget`
1742/// a [`Widget`][crate::Widget]
1743/// ## `selection`
1744/// the selection
1745/// ## `target`
1746/// target to add.
1747/// ## `info`
1748/// A unsigned integer which will be passed back to the application.
1749#[doc(alias = "gtk_selection_add_target")]
1750pub fn selection_add_target(
1751 widget: &impl IsA<Widget>,
1752 selection: &gdk::Atom,
1753 target: &gdk::Atom,
1754 info: u32,
1755) {
1756 skip_assert_initialized!();
1757 unsafe {
1758 ffi::gtk_selection_add_target(
1759 widget.as_ref().to_glib_none().0,
1760 selection.to_glib_none().0,
1761 target.to_glib_none().0,
1762 info,
1763 );
1764 }
1765}
1766
1767/// Remove all targets registered for the given selection for the
1768/// widget.
1769/// ## `widget`
1770/// a [`Widget`][crate::Widget]
1771/// ## `selection`
1772/// an atom representing a selection
1773#[doc(alias = "gtk_selection_clear_targets")]
1774pub fn selection_clear_targets(widget: &impl IsA<Widget>, selection: &gdk::Atom) {
1775 skip_assert_initialized!();
1776 unsafe {
1777 ffi::gtk_selection_clear_targets(
1778 widget.as_ref().to_glib_none().0,
1779 selection.to_glib_none().0,
1780 );
1781 }
1782}
1783
1784/// Requests the contents of a selection. When received,
1785/// a “selection-received” signal will be generated.
1786/// ## `widget`
1787/// The widget which acts as requestor
1788/// ## `selection`
1789/// Which selection to get
1790/// ## `target`
1791/// Form of information desired (e.g., STRING)
1792/// ## `time_`
1793/// Time of request (usually of triggering event)
1794/// In emergency, you could use `GDK_CURRENT_TIME`
1795///
1796/// # Returns
1797///
1798/// [`true`] if requested succeeded. [`false`] if we could not process
1799/// request. (e.g., there was already a request in process for
1800/// this widget).
1801#[doc(alias = "gtk_selection_convert")]
1802pub fn selection_convert(
1803 widget: &impl IsA<Widget>,
1804 selection: &gdk::Atom,
1805 target: &gdk::Atom,
1806 time_: u32,
1807) -> bool {
1808 skip_assert_initialized!();
1809 unsafe {
1810 from_glib(ffi::gtk_selection_convert(
1811 widget.as_ref().to_glib_none().0,
1812 selection.to_glib_none().0,
1813 target.to_glib_none().0,
1814 time_,
1815 ))
1816 }
1817}
1818
1819/// Claims ownership of a given selection for a particular widget,
1820/// or, if `widget` is [`None`], release ownership of the selection.
1821/// ## `widget`
1822/// a [`Widget`][crate::Widget], or [`None`].
1823/// ## `selection`
1824/// an interned atom representing the selection to claim
1825/// ## `time_`
1826/// timestamp with which to claim the selection
1827///
1828/// # Returns
1829///
1830/// [`true`] if the operation succeeded
1831#[doc(alias = "gtk_selection_owner_set")]
1832pub fn selection_owner_set(
1833 widget: Option<&impl IsA<Widget>>,
1834 selection: &gdk::Atom,
1835 time_: u32,
1836) -> bool {
1837 assert_initialized_main_thread!();
1838 unsafe {
1839 from_glib(ffi::gtk_selection_owner_set(
1840 widget.map(|p| p.as_ref()).to_glib_none().0,
1841 selection.to_glib_none().0,
1842 time_,
1843 ))
1844 }
1845}
1846
1847/// Claim ownership of a given selection for a particular widget, or,
1848/// if `widget` is [`None`], release ownership of the selection.
1849/// ## `display`
1850/// the [`gdk::Display`][crate::gdk::Display] where the selection is set
1851/// ## `widget`
1852/// new selection owner (a [`Widget`][crate::Widget]), or [`None`].
1853/// ## `selection`
1854/// an interned atom representing the selection to claim.
1855/// ## `time_`
1856/// timestamp with which to claim the selection
1857///
1858/// # Returns
1859///
1860/// TRUE if the operation succeeded
1861#[doc(alias = "gtk_selection_owner_set_for_display")]
1862pub fn selection_owner_set_for_display(
1863 display: &gdk::Display,
1864 widget: Option<&impl IsA<Widget>>,
1865 selection: &gdk::Atom,
1866 time_: u32,
1867) -> bool {
1868 assert_initialized_main_thread!();
1869 unsafe {
1870 from_glib(ffi::gtk_selection_owner_set_for_display(
1871 display.to_glib_none().0,
1872 widget.map(|p| p.as_ref()).to_glib_none().0,
1873 selection.to_glib_none().0,
1874 time_,
1875 ))
1876 }
1877}
1878
1879/// Removes all handlers and unsets ownership of all
1880/// selections for a widget. Called when widget is being
1881/// destroyed. This function will not generally be
1882/// called by applications.
1883/// ## `widget`
1884/// a [`Widget`][crate::Widget]
1885#[doc(alias = "gtk_selection_remove_all")]
1886pub fn selection_remove_all(widget: &impl IsA<Widget>) {
1887 skip_assert_initialized!();
1888 unsafe {
1889 ffi::gtk_selection_remove_all(widget.as_ref().to_glib_none().0);
1890 }
1891}
1892
1893/// Sets the GTK+ debug flags.
1894#[doc(alias = "gtk_set_debug_flags")]
1895pub fn set_debug_flags(flags: u32) {
1896 assert_initialized_main_thread!();
1897 unsafe {
1898 ffi::gtk_set_debug_flags(flags);
1899 }
1900}
1901
1902//#[doc(alias = "gtk_show_about_dialog")]
1903//pub fn show_about_dialog(parent: Option<&impl IsA<Window>>, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
1904// unsafe { TODO: call ffi:gtk_show_about_dialog() }
1905//}
1906
1907/// This is a convenience function for launching the default application
1908/// to show the uri. The uri must be of a form understood by GIO (i.e. you
1909/// need to install gvfs to get support for uri schemes such as http://
1910/// or ftp://, as only local files are handled by GIO itself).
1911/// Typical examples are
1912/// - `file:///home/gnome/pict.jpg`
1913/// - `http://www.gnome.org`
1914/// - `mailto:me`gnome``
1915///
1916/// Ideally the timestamp is taken from the event triggering
1917/// the `gtk_show_uri()` call. If timestamp is not known you can take
1918/// `GDK_CURRENT_TIME`.
1919///
1920/// This is the recommended call to be used as it passes information
1921/// necessary for sandbox helpers to parent their dialogs properly.
1922/// ## `parent`
1923/// parent window
1924/// ## `uri`
1925/// the uri to show
1926/// ## `timestamp`
1927/// a timestamp to prevent focus stealing
1928///
1929/// # Returns
1930///
1931/// [`true`] on success, [`false`] on error
1932#[doc(alias = "gtk_show_uri_on_window")]
1933pub fn show_uri_on_window(
1934 parent: Option<&impl IsA<Window>>,
1935 uri: &str,
1936 timestamp: u32,
1937) -> Result<(), glib::Error> {
1938 assert_initialized_main_thread!();
1939 unsafe {
1940 let mut error = std::ptr::null_mut();
1941 let is_ok = ffi::gtk_show_uri_on_window(
1942 parent.map(|p| p.as_ref()).to_glib_none().0,
1943 uri.to_glib_none().0,
1944 timestamp,
1945 &mut error,
1946 );
1947 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
1948 if error.is_null() {
1949 Ok(())
1950 } else {
1951 Err(from_glib_full(error))
1952 }
1953 }
1954}
1955
1956/// Determines if any of the targets in `targets` can be used to
1957/// provide a [`gdk_pixbuf::Pixbuf`][crate::gdk_pixbuf::Pixbuf].
1958/// ## `targets`
1959/// an array of `GdkAtoms`
1960/// ## `writable`
1961/// whether to accept only targets for which GTK+ knows
1962/// how to convert a pixbuf into the format
1963///
1964/// # Returns
1965///
1966/// [`true`] if `targets` include a suitable target for images,
1967/// otherwise [`false`].
1968#[doc(alias = "gtk_targets_include_image")]
1969pub fn targets_include_image(targets: &[gdk::Atom], writable: bool) -> bool {
1970 assert_initialized_main_thread!();
1971 let n_targets = targets.len() as _;
1972 unsafe {
1973 from_glib(ffi::gtk_targets_include_image(
1974 targets.to_glib_none().0,
1975 n_targets,
1976 writable.into_glib(),
1977 ))
1978 }
1979}
1980
1981/// Determines if any of the targets in `targets` can be used to
1982/// provide rich text.
1983/// ## `targets`
1984/// an array of `GdkAtoms`
1985/// ## `buffer`
1986/// a [`TextBuffer`][crate::TextBuffer]
1987///
1988/// # Returns
1989///
1990/// [`true`] if `targets` include a suitable target for rich text,
1991/// otherwise [`false`].
1992#[doc(alias = "gtk_targets_include_rich_text")]
1993pub fn targets_include_rich_text(targets: &[gdk::Atom], buffer: &impl IsA<TextBuffer>) -> bool {
1994 skip_assert_initialized!();
1995 let n_targets = targets.len() as _;
1996 unsafe {
1997 from_glib(ffi::gtk_targets_include_rich_text(
1998 targets.to_glib_none().0,
1999 n_targets,
2000 buffer.as_ref().to_glib_none().0,
2001 ))
2002 }
2003}
2004
2005/// Determines if any of the targets in `targets` can be used to
2006/// provide text.
2007/// ## `targets`
2008/// an array of `GdkAtoms`
2009///
2010/// # Returns
2011///
2012/// [`true`] if `targets` include a suitable target for text,
2013/// otherwise [`false`].
2014#[doc(alias = "gtk_targets_include_text")]
2015pub fn targets_include_text(targets: &[gdk::Atom]) -> bool {
2016 assert_initialized_main_thread!();
2017 let n_targets = targets.len() as _;
2018 unsafe {
2019 from_glib(ffi::gtk_targets_include_text(
2020 targets.to_glib_none().0,
2021 n_targets,
2022 ))
2023 }
2024}
2025
2026/// Determines if any of the targets in `targets` can be used to
2027/// provide an uri list.
2028/// ## `targets`
2029/// an array of `GdkAtoms`
2030///
2031/// # Returns
2032///
2033/// [`true`] if `targets` include a suitable target for uri lists,
2034/// otherwise [`false`].
2035#[doc(alias = "gtk_targets_include_uri")]
2036pub fn targets_include_uri(targets: &[gdk::Atom]) -> bool {
2037 assert_initialized_main_thread!();
2038 let n_targets = targets.len() as _;
2039 unsafe {
2040 from_glib(ffi::gtk_targets_include_uri(
2041 targets.to_glib_none().0,
2042 n_targets,
2043 ))
2044 }
2045}
2046
2047/// This function will search `widget` and all its descendants for a GtkLabel
2048/// widget with a text string matching `label_pattern`.
2049/// The `label_pattern` may contain asterisks “*” and question marks “?” as
2050/// placeholders, `g_pattern_match()` is used for the matching.
2051/// Note that locales other than "C“ tend to alter (translate” label strings,
2052/// so this function is genrally only useful in test programs with
2053/// predetermined locales, see `gtk_test_init()` for more details.
2054/// ## `widget`
2055/// Valid label or container widget.
2056/// ## `label_pattern`
2057/// Shell-glob pattern to match a label string.
2058///
2059/// # Returns
2060///
2061/// a GtkLabel widget if any is found.
2062#[doc(alias = "gtk_test_find_label")]
2063pub fn test_find_label(widget: &impl IsA<Widget>, label_pattern: &str) -> Option<Widget> {
2064 skip_assert_initialized!();
2065 unsafe {
2066 from_glib_none(ffi::gtk_test_find_label(
2067 widget.as_ref().to_glib_none().0,
2068 label_pattern.to_glib_none().0,
2069 ))
2070 }
2071}
2072
2073/// This function will search siblings of `base_widget` and siblings of its
2074/// ancestors for all widgets matching `widget_type`.
2075/// Of the matching widgets, the one that is geometrically closest to
2076/// `base_widget` will be returned.
2077/// The general purpose of this function is to find the most likely “action”
2078/// widget, relative to another labeling widget. Such as finding a
2079/// button or text entry widget, given its corresponding label widget.
2080/// ## `base_widget`
2081/// Valid widget, part of a widget hierarchy
2082/// ## `widget_type`
2083/// Type of a aearched for sibling widget
2084///
2085/// # Returns
2086///
2087/// a widget of type `widget_type` if any is found.
2088#[doc(alias = "gtk_test_find_sibling")]
2089pub fn test_find_sibling(
2090 base_widget: &impl IsA<Widget>,
2091 widget_type: glib::types::Type,
2092) -> Option<Widget> {
2093 skip_assert_initialized!();
2094 unsafe {
2095 from_glib_none(ffi::gtk_test_find_sibling(
2096 base_widget.as_ref().to_glib_none().0,
2097 widget_type.into_glib(),
2098 ))
2099 }
2100}
2101
2102/// This function will search the descendants of `widget` for a widget
2103/// of type `widget_type` that has a label matching `label_pattern` next
2104/// to it. This is most useful for automated GUI testing, e.g. to find
2105/// the “OK” button in a dialog and synthesize clicks on it.
2106/// However see [`test_find_label()`][crate::test_find_label()], [`test_find_sibling()`][crate::test_find_sibling()] and
2107/// `gtk_test_widget_click()` for possible caveats involving the search of
2108/// such widgets and synthesizing widget events.
2109/// ## `widget`
2110/// Container widget, usually a GtkWindow.
2111/// ## `label_pattern`
2112/// Shell-glob pattern to match a label string.
2113/// ## `widget_type`
2114/// Type of a aearched for label sibling widget.
2115///
2116/// # Returns
2117///
2118/// a valid widget if any is found or [`None`].
2119#[doc(alias = "gtk_test_find_widget")]
2120pub fn test_find_widget(
2121 widget: &impl IsA<Widget>,
2122 label_pattern: &str,
2123 widget_type: glib::types::Type,
2124) -> Option<Widget> {
2125 skip_assert_initialized!();
2126 unsafe {
2127 from_glib_none(ffi::gtk_test_find_widget(
2128 widget.as_ref().to_glib_none().0,
2129 label_pattern.to_glib_none().0,
2130 widget_type.into_glib(),
2131 ))
2132 }
2133}
2134
2135//#[doc(alias = "gtk_test_list_all_types")]
2136//pub fn test_list_all_types() -> /*Unimplemented*/CArray TypeId { ns_id: 0, id: 30 } {
2137// unsafe { TODO: call ffi:gtk_test_list_all_types() }
2138//}
2139
2140/// Force registration of all core Gtk+ and Gdk object types.
2141/// This allowes to refer to any of those object types via
2142/// `g_type_from_name()` after calling this function.
2143#[doc(alias = "gtk_test_register_all_types")]
2144pub fn test_register_all_types() {
2145 assert_initialized_main_thread!();
2146 unsafe {
2147 ffi::gtk_test_register_all_types();
2148 }
2149}
2150
2151/// window.
2152/// Certain caveats should be considered when using this function, in
2153/// particular because the mouse pointer is warped to the key press
2154/// location, see `gdk_test_simulate_key()` for details.
2155/// ## `widget`
2156/// Widget to generate a key press and release on.
2157/// ## `keyval`
2158/// A Gdk keyboard value.
2159/// ## `modifiers`
2160/// Keyboard modifiers the event is setup with.
2161///
2162/// # Returns
2163///
2164/// whether all actions neccessary for the key event simulation were carried out successfully.
2165#[doc(alias = "gtk_test_widget_send_key")]
2166pub fn test_widget_send_key(
2167 widget: &impl IsA<Widget>,
2168 keyval: u32,
2169 modifiers: gdk::ModifierType,
2170) -> bool {
2171 skip_assert_initialized!();
2172 unsafe {
2173 from_glib(ffi::gtk_test_widget_send_key(
2174 widget.as_ref().to_glib_none().0,
2175 keyval,
2176 modifiers.into_glib(),
2177 ))
2178 }
2179}
2180
2181/// Enters the main loop and waits for `widget` to be “drawn”. In this
2182/// context that means it waits for the frame clock of `widget` to have
2183/// run a full styling, layout and drawing cycle.
2184///
2185/// This function is intended to be used for syncing with actions that
2186/// depend on `widget` relayouting or on interaction with the display
2187/// server.
2188/// ## `widget`
2189/// the widget to wait for
2190#[doc(alias = "gtk_test_widget_wait_for_draw")]
2191pub fn test_widget_wait_for_draw(widget: &impl IsA<Widget>) {
2192 skip_assert_initialized!();
2193 unsafe {
2194 ffi::gtk_test_widget_wait_for_draw(widget.as_ref().to_glib_none().0);
2195 }
2196}
2197
2198/// Obtains a `tree_model` and `path` from selection data of target type
2199/// `GTK_TREE_MODEL_ROW`. Normally called from a drag_data_received handler.
2200/// This function can only be used if `selection_data` originates from the same
2201/// process that’s calling this function, because a pointer to the tree model
2202/// is being passed around. If you aren’t in the same process, then you'll
2203/// get memory corruption. In the [`TreeDragDest`][crate::TreeDragDest] drag_data_received handler,
2204/// you can assume that selection data of type `GTK_TREE_MODEL_ROW` is
2205/// in from the current process. The returned path must be freed with
2206/// `gtk_tree_path_free()`.
2207/// ## `selection_data`
2208/// a [`SelectionData`][crate::SelectionData]
2209///
2210/// # Returns
2211///
2212/// [`true`] if `selection_data` had target type `GTK_TREE_MODEL_ROW` and
2213/// is otherwise valid
2214///
2215/// ## `tree_model`
2216/// a [`TreeModel`][crate::TreeModel]
2217///
2218/// ## `path`
2219/// row in `tree_model`
2220#[doc(alias = "gtk_tree_get_row_drag_data")]
2221pub fn tree_get_row_drag_data(
2222 selection_data: &SelectionData,
2223) -> Option<(Option<TreeModel>, Option<TreePath>)> {
2224 assert_initialized_main_thread!();
2225 unsafe {
2226 let mut tree_model = std::ptr::null_mut();
2227 let mut path = std::ptr::null_mut();
2228 let ret = from_glib(ffi::gtk_tree_get_row_drag_data(
2229 mut_override(selection_data.to_glib_none().0),
2230 &mut tree_model,
2231 &mut path,
2232 ));
2233 if ret {
2234 Some((from_glib_none(tree_model), from_glib_full(path)))
2235 } else {
2236 None
2237 }
2238 }
2239}
2240
2241/// Sets selection data of target type `GTK_TREE_MODEL_ROW`. Normally used
2242/// in a drag_data_get handler.
2243/// ## `selection_data`
2244/// some [`SelectionData`][crate::SelectionData]
2245/// ## `tree_model`
2246/// a [`TreeModel`][crate::TreeModel]
2247/// ## `path`
2248/// a row in `tree_model`
2249///
2250/// # Returns
2251///
2252/// [`true`] if the [`SelectionData`][crate::SelectionData] had the proper target type to allow us to set a tree row
2253#[doc(alias = "gtk_tree_set_row_drag_data")]
2254pub fn tree_set_row_drag_data(
2255 selection_data: &SelectionData,
2256 tree_model: &impl IsA<TreeModel>,
2257 path: &mut TreePath,
2258) -> bool {
2259 skip_assert_initialized!();
2260 unsafe {
2261 from_glib(ffi::gtk_tree_set_row_drag_data(
2262 mut_override(selection_data.to_glib_none().0),
2263 tree_model.as_ref().to_glib_none().0,
2264 path.to_glib_none_mut().0,
2265 ))
2266 }
2267}
2268
2269/// argv);
2270///
2271/// win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
2272/// g_signal_connect (win,
2273/// "delete-event",
2274/// G_CALLBACK (gtk_true),
2275/// NULL);
2276/// g_signal_connect (win, "destroy",
2277/// G_CALLBACK (gtk_main_quit),
2278/// NULL);
2279///
2280/// but = gtk_button_new_with_label (text);
2281/// g_signal_connect_swapped (but, "clicked",
2282/// G_CALLBACK (gtk_object_destroy),
2283/// win);
2284/// gtk_container_add (GTK_CONTAINER (win), but);
2285///
2286/// gtk_widget_show_all (win);
2287///
2288/// gtk_main ();
2289///
2290/// return 0;
2291/// }
2292/// ]|
2293///
2294/// # Returns
2295///
2296/// [`true`]
2297#[doc(alias = "gtk_true")]
2298#[doc(alias = "true")]
2299pub fn true_() -> bool {
2300 assert_initialized_main_thread!();
2301 unsafe { from_glib(ffi::gtk_true()) }
2302}