gdk4/auto/toplevel.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(feature = "v4_4")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
7use crate::TitlebarGesture;
8use crate::{
9 Device, Event, FullscreenMode, Surface, SurfaceEdge, Texture, ToplevelLayout, ToplevelState,
10 ffi,
11};
12#[cfg(feature = "v4_20")]
13#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
14use crate::{Gravity, ToplevelCapabilities};
15use glib::{
16 prelude::*,
17 signal::{SignalHandlerId, connect_raw},
18 translate::*,
19};
20use std::boxed::Box as Box_;
21
22glib::wrapper! {
23 /// A freestanding toplevel surface.
24 ///
25 /// The [`Toplevel`][crate::Toplevel] interface provides useful APIs for interacting with
26 /// the windowing system, such as controlling maximization and size of the
27 /// surface, setting icons and transient parents for dialogs.
28 ///
29 /// ## Properties
30 ///
31 ///
32 /// #### `capabilities`
33 /// The capabilities that are available for this toplevel.
34 ///
35 /// Readable
36 ///
37 ///
38 /// #### `decorated`
39 /// Whether the window manager should add decorations.
40 ///
41 /// Readable | Writeable
42 ///
43 ///
44 /// #### `deletable`
45 /// Whether the window manager should allow to close the surface.
46 ///
47 /// Readable | Writeable
48 ///
49 ///
50 /// #### `fullscreen-mode`
51 /// The fullscreen mode of the surface.
52 ///
53 /// Readable | Writeable
54 ///
55 ///
56 /// #### `gravity`
57 /// The gravity to use when resizing a surface programmatically.
58 ///
59 /// Gravity describes which point of the surface we want to keep
60 /// fixed (meaning that the surface will grow in the opposite direction).
61 /// For example, a gravity of `GDK_GRAVITY_NORTH_EAST` means that we
62 /// want to fix top right corner of the surface.
63 ///
64 /// This property is just a hint that may affect the result when negotiating
65 /// toplevel sizes with the windowing system. It does not affect interactive
66 /// resizes started with [`ToplevelExt::begin_resize()`][crate::prelude::ToplevelExt::begin_resize()].
67 ///
68 /// Readable | Writeable
69 ///
70 ///
71 /// #### `icon-list`
72 /// A list of textures to use as icon.
73 ///
74 /// Readable | Writeable
75 ///
76 ///
77 /// #### `modal`
78 /// Whether the surface is modal.
79 ///
80 /// Readable | Writeable
81 ///
82 ///
83 /// #### `shortcuts-inhibited`
84 /// Whether the surface should inhibit keyboard shortcuts.
85 ///
86 /// Readable
87 ///
88 ///
89 /// #### `startup-id`
90 /// The startup ID of the surface.
91 ///
92 /// See [`AppLaunchContext`][crate::AppLaunchContext] for more information about
93 /// startup feedback.
94 ///
95 /// Readable | Writeable
96 ///
97 ///
98 /// #### `state`
99 /// The state of the toplevel.
100 ///
101 /// Readable
102 ///
103 ///
104 /// #### `title`
105 /// The title of the surface.
106 ///
107 /// Readable | Writeable
108 ///
109 ///
110 /// #### `transient-for`
111 /// The transient parent of the surface.
112 ///
113 /// Readable | Writeable
114 /// <details><summary><h4>Surface</h4></summary>
115 ///
116 ///
117 /// #### `cursor`
118 /// The mouse pointer for the [`Surface`][crate::Surface].
119 ///
120 /// Readable | Writeable
121 ///
122 ///
123 /// #### `display`
124 /// The [`Display`][crate::Display] connection of the surface.
125 ///
126 /// Readable | Writeable | Construct Only
127 ///
128 ///
129 /// #### `frame-clock`
130 /// The [`FrameClock`][crate::FrameClock] of the surface.
131 ///
132 /// Readable | Writeable | Construct Only
133 ///
134 ///
135 /// #### `height`
136 /// The height of the surface, in pixels.
137 ///
138 /// Readable
139 ///
140 ///
141 /// #### `mapped`
142 /// Whether the surface is mapped.
143 ///
144 /// Readable
145 ///
146 ///
147 /// #### `scale`
148 /// The scale of the surface.
149 ///
150 /// Readable
151 ///
152 ///
153 /// #### `scale-factor`
154 /// The scale factor of the surface.
155 ///
156 /// The scale factor is the next larger integer,
157 /// compared to [`scale`][struct@crate::Surface#scale].
158 ///
159 /// Readable
160 ///
161 ///
162 /// #### `width`
163 /// The width of the surface in pixels.
164 ///
165 /// Readable
166 /// </details>
167 ///
168 /// ## Signals
169 ///
170 ///
171 /// #### `compute-size`
172 /// Emitted when the size for the surface needs to be computed, when
173 /// it is present.
174 ///
175 /// This signal will normally be emitted during or after a call to
176 /// [`ToplevelExt::present()`][crate::prelude::ToplevelExt::present()], depending on the configuration
177 /// received by the windowing system. It may also be emitted at any
178 /// other point in time, in response to the windowing system
179 /// spontaneously changing the configuration of the toplevel surface.
180 ///
181 /// It is the responsibility of the toplevel user to handle this signal
182 /// and compute the desired size of the toplevel, given the information
183 /// passed via the [`ToplevelSize`][crate::ToplevelSize] object. Failing to do so
184 /// will result in an arbitrary size being used as a result.
185 ///
186 ///
187 /// <details><summary><h4>Surface</h4></summary>
188 ///
189 ///
190 /// #### `enter-monitor`
191 /// Emitted when @surface starts being present on the monitor.
192 ///
193 ///
194 ///
195 ///
196 /// #### `event`
197 /// Emitted when GDK receives an input event for @surface.
198 ///
199 ///
200 ///
201 ///
202 /// #### `layout`
203 /// Emitted when the size of @surface is changed, or when relayout should
204 /// be performed.
205 ///
206 /// Surface size is reported in ”application pixels”, not
207 /// ”device pixels” (see gdk_surface_get_scale_factor()).
208 ///
209 ///
210 ///
211 ///
212 /// #### `leave-monitor`
213 /// Emitted when @surface stops being present on the monitor.
214 ///
215 ///
216 ///
217 ///
218 /// #### `render`
219 /// Emitted when part of the surface needs to be redrawn.
220 ///
221 ///
222 /// </details>
223 ///
224 /// # Implements
225 ///
226 /// [`ToplevelExt`][trait@crate::prelude::ToplevelExt], [`SurfaceExt`][trait@crate::prelude::SurfaceExt], [`ToplevelExtManual`][trait@crate::prelude::ToplevelExtManual], [`SurfaceExtManual`][trait@crate::prelude::SurfaceExtManual]
227 #[doc(alias = "GdkToplevel")]
228 pub struct Toplevel(Interface<ffi::GdkToplevel, ffi::GdkToplevelInterface>) @requires Surface;
229
230 match fn {
231 type_ => || ffi::gdk_toplevel_get_type(),
232 }
233}
234
235impl Toplevel {
236 pub const NONE: Option<&'static Toplevel> = None;
237}
238
239/// Trait containing all [`struct@Toplevel`] methods.
240///
241/// # Implementors
242///
243/// [`Toplevel`][struct@crate::Toplevel]
244pub trait ToplevelExt: IsA<Toplevel> + 'static {
245 /// Begins an interactive move operation.
246 ///
247 /// You might use this function to implement draggable titlebars.
248 /// ## `device`
249 /// the device used for the operation
250 /// ## `button`
251 /// the button being used to drag, or 0 for a keyboard-initiated drag
252 /// ## `x`
253 /// surface X coordinate of mouse click that began the drag
254 /// ## `y`
255 /// surface Y coordinate of mouse click that began the drag
256 /// ## `timestamp`
257 /// timestamp of mouse click that began the drag (use
258 /// [`Event::time()`][crate::Event::time()])
259 #[doc(alias = "gdk_toplevel_begin_move")]
260 fn begin_move(&self, device: &impl IsA<Device>, button: i32, x: f64, y: f64, timestamp: u32) {
261 unsafe {
262 ffi::gdk_toplevel_begin_move(
263 self.as_ref().to_glib_none().0,
264 device.as_ref().to_glib_none().0,
265 button,
266 x,
267 y,
268 timestamp,
269 );
270 }
271 }
272
273 /// Begins an interactive resize operation.
274 ///
275 /// You might use this function to implement a “window resize grip.”
276 /// ## `edge`
277 /// the edge or corner from which the drag is started
278 /// ## `device`
279 /// the device used for the operation
280 /// ## `button`
281 /// the button being used to drag, or 0 for a keyboard-initiated drag
282 /// ## `x`
283 /// surface X coordinate of mouse click that began the drag
284 /// ## `y`
285 /// surface Y coordinate of mouse click that began the drag
286 /// ## `timestamp`
287 /// timestamp of mouse click that began the drag (use
288 /// [`Event::time()`][crate::Event::time()])
289 #[doc(alias = "gdk_toplevel_begin_resize")]
290 fn begin_resize(
291 &self,
292 edge: SurfaceEdge,
293 device: Option<&impl IsA<Device>>,
294 button: i32,
295 x: f64,
296 y: f64,
297 timestamp: u32,
298 ) {
299 unsafe {
300 ffi::gdk_toplevel_begin_resize(
301 self.as_ref().to_glib_none().0,
302 edge.into_glib(),
303 device.map(|p| p.as_ref()).to_glib_none().0,
304 button,
305 x,
306 y,
307 timestamp,
308 );
309 }
310 }
311
312 /// Sets keyboard focus to @surface.
313 ///
314 /// In most cases, [gtk_window_present_with_time()](../gtk4/method.Window.present_with_time.html)
315 /// should be used on a [GtkWindow](../gtk4/class.Window.html), rather than
316 /// calling this function.
317 /// ## `timestamp`
318 /// timestamp of the event triggering the surface focus
319 #[doc(alias = "gdk_toplevel_focus")]
320 fn focus(&self, timestamp: u32) {
321 unsafe {
322 ffi::gdk_toplevel_focus(self.as_ref().to_glib_none().0, timestamp);
323 }
324 }
325
326 /// The capabilities that are available for this toplevel.
327 ///
328 /// # Returns
329 ///
330 /// the capabilities of the [`Toplevel`][crate::Toplevel].
331 #[cfg(feature = "v4_20")]
332 #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
333 #[doc(alias = "gdk_toplevel_get_capabilities")]
334 #[doc(alias = "get_capabilities")]
335 fn capabilities(&self) -> ToplevelCapabilities {
336 unsafe {
337 from_glib(ffi::gdk_toplevel_get_capabilities(
338 self.as_ref().to_glib_none().0,
339 ))
340 }
341 }
342
343 /// Returns the gravity that is used when changing the toplevel
344 /// size programmatically.
345 ///
346 /// # Returns
347 ///
348 /// the gravity
349 #[cfg(feature = "v4_20")]
350 #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
351 #[doc(alias = "gdk_toplevel_get_gravity")]
352 #[doc(alias = "get_gravity")]
353 fn gravity(&self) -> Gravity {
354 unsafe {
355 from_glib(ffi::gdk_toplevel_get_gravity(
356 self.as_ref().to_glib_none().0,
357 ))
358 }
359 }
360
361 /// Gets the bitwise or of the currently active surface state flags,
362 /// from the [`ToplevelState`][crate::ToplevelState] enumeration.
363 ///
364 /// # Returns
365 ///
366 /// surface state bitfield
367 #[doc(alias = "gdk_toplevel_get_state")]
368 #[doc(alias = "get_state")]
369 fn state(&self) -> ToplevelState {
370 unsafe { from_glib(ffi::gdk_toplevel_get_state(self.as_ref().to_glib_none().0)) }
371 }
372
373 /// Requests that the @self inhibit the system shortcuts.
374 ///
375 /// This is asking the desktop environment/windowing system to let all
376 /// keyboard events reach the surface, as long as it is focused, instead
377 /// of triggering system actions.
378 ///
379 /// If granted, the rerouting remains active until the default shortcuts
380 /// processing is restored with [`restore_system_shortcuts()`][Self::restore_system_shortcuts()],
381 /// or the request is revoked by the desktop environment, windowing system
382 /// or the user.
383 ///
384 /// A typical use case for this API is remote desktop or virtual machine
385 /// viewers which need to inhibit the default system keyboard shortcuts
386 /// so that the remote session or virtual host gets those instead of the
387 /// local environment.
388 ///
389 /// The windowing system or desktop environment may ask the user to grant
390 /// or deny the request or even choose to ignore the request entirely.
391 ///
392 /// The caller can be notified whenever the request is granted or revoked
393 /// by listening to the [`shortcuts-inhibited`][struct@crate::Toplevel#shortcuts-inhibited] property.
394 /// ## `event`
395 /// the [`Event`][crate::Event] that is triggering the inhibit
396 /// request, or [`None`] if none is available
397 #[doc(alias = "gdk_toplevel_inhibit_system_shortcuts")]
398 fn inhibit_system_shortcuts(&self, event: Option<impl AsRef<Event>>) {
399 unsafe {
400 ffi::gdk_toplevel_inhibit_system_shortcuts(
401 self.as_ref().to_glib_none().0,
402 event.as_ref().map(|p| p.as_ref()).to_glib_none().0,
403 );
404 }
405 }
406
407 /// Asks to lower the @self below other windows.
408 ///
409 /// The windowing system may choose to ignore the request.
410 ///
411 /// # Returns
412 ///
413 /// [`true`] if the surface was lowered
414 #[doc(alias = "gdk_toplevel_lower")]
415 fn lower(&self) -> bool {
416 unsafe { from_glib(ffi::gdk_toplevel_lower(self.as_ref().to_glib_none().0)) }
417 }
418
419 /// Asks to minimize the @self.
420 ///
421 /// The windowing system may choose to ignore the request.
422 ///
423 /// # Returns
424 ///
425 /// [`true`] if the surface was minimized
426 #[doc(alias = "gdk_toplevel_minimize")]
427 fn minimize(&self) -> bool {
428 unsafe { from_glib(ffi::gdk_toplevel_minimize(self.as_ref().to_glib_none().0)) }
429 }
430
431 /// Present @self after having processed the [`ToplevelLayout`][crate::ToplevelLayout] rules.
432 ///
433 /// If the toplevel was previously not showing, it will be showed,
434 /// otherwise it will change layout according to @layout.
435 ///
436 /// GDK may emit the [`compute-size`][struct@crate::Toplevel#compute-size] signal to let
437 /// the user of this toplevel compute the preferred size of the toplevel
438 /// surface.
439 ///
440 /// Presenting is asynchronous and the specified layout parameters are not
441 /// guaranteed to be respected.
442 /// ## `layout`
443 /// the [`ToplevelLayout`][crate::ToplevelLayout] object used to layout
444 #[doc(alias = "gdk_toplevel_present")]
445 fn present(&self, layout: &ToplevelLayout) {
446 unsafe {
447 ffi::gdk_toplevel_present(self.as_ref().to_glib_none().0, layout.to_glib_none().0);
448 }
449 }
450
451 /// Restore default system keyboard shortcuts which were previously
452 /// inhibited.
453 ///
454 /// This undoes the effect of [`inhibit_system_shortcuts()`][Self::inhibit_system_shortcuts()].
455 #[doc(alias = "gdk_toplevel_restore_system_shortcuts")]
456 fn restore_system_shortcuts(&self) {
457 unsafe {
458 ffi::gdk_toplevel_restore_system_shortcuts(self.as_ref().to_glib_none().0);
459 }
460 }
461
462 /// Sets the toplevel to be decorated.
463 ///
464 /// Setting @decorated to [`false`] hints the desktop environment
465 /// that the surface has its own, client-side decorations and
466 /// does not need to have window decorations added.
467 /// ## `decorated`
468 /// [`true`] to request decorations
469 #[doc(alias = "gdk_toplevel_set_decorated")]
470 #[doc(alias = "decorated")]
471 fn set_decorated(&self, decorated: bool) {
472 unsafe {
473 ffi::gdk_toplevel_set_decorated(self.as_ref().to_glib_none().0, decorated.into_glib());
474 }
475 }
476
477 /// Sets the toplevel to be deletable.
478 ///
479 /// Setting @deletable to [`true`] hints the desktop environment
480 /// that it should offer the user a way to close the surface.
481 /// ## `deletable`
482 /// [`true`] to request a delete button
483 #[doc(alias = "gdk_toplevel_set_deletable")]
484 #[doc(alias = "deletable")]
485 fn set_deletable(&self, deletable: bool) {
486 unsafe {
487 ffi::gdk_toplevel_set_deletable(self.as_ref().to_glib_none().0, deletable.into_glib());
488 }
489 }
490
491 /// Sets the gravity that is used when changing the toplevel
492 /// size programmatically.
493 /// ## `gravity`
494 /// the new gravity
495 #[cfg(feature = "v4_20")]
496 #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
497 #[doc(alias = "gdk_toplevel_set_gravity")]
498 #[doc(alias = "gravity")]
499 fn set_gravity(&self, gravity: Gravity) {
500 unsafe {
501 ffi::gdk_toplevel_set_gravity(self.as_ref().to_glib_none().0, gravity.into_glib());
502 }
503 }
504
505 /// Sets a list of icons for the surface.
506 ///
507 /// One of these will be used to represent the surface in iconic form.
508 /// The icon may be shown in window lists or task bars. Which icon
509 /// size is shown depends on the window manager. The window manager
510 /// can scale the icon but setting several size icons can give better
511 /// image quality.
512 ///
513 /// Note that some platforms don't support surface icons.
514 /// ## `surfaces`
515 ///
516 /// A list of textures to use as icon, of different sizes
517 #[doc(alias = "gdk_toplevel_set_icon_list")]
518 #[doc(alias = "icon-list")]
519 fn set_icon_list(&self, surfaces: &[Texture]) {
520 unsafe {
521 ffi::gdk_toplevel_set_icon_list(
522 self.as_ref().to_glib_none().0,
523 surfaces.to_glib_none().0,
524 );
525 }
526 }
527
528 /// Sets the toplevel to be modal.
529 ///
530 /// The application can use this hint to tell the
531 /// window manager that a certain surface has modal
532 /// behaviour. The window manager can use this information
533 /// to handle modal surfaces in a special way.
534 ///
535 /// You should only use this on surfaces for which you have
536 /// previously called [`set_transient_for()`][Self::set_transient_for()].
537 /// ## `modal`
538 /// [`true`] if the surface is modal, [`false`] otherwise.
539 #[doc(alias = "gdk_toplevel_set_modal")]
540 #[doc(alias = "modal")]
541 fn set_modal(&self, modal: bool) {
542 unsafe {
543 ffi::gdk_toplevel_set_modal(self.as_ref().to_glib_none().0, modal.into_glib());
544 }
545 }
546
547 /// Sets the startup notification ID.
548 ///
549 /// When using GTK, typically you should use
550 /// [gtk_window_set_startup_id()](../gtk4/method.Window.set_startup_id.html)
551 /// instead of this low-level function.
552 /// ## `startup_id`
553 /// a string with startup-notification identifier
554 #[doc(alias = "gdk_toplevel_set_startup_id")]
555 #[doc(alias = "startup-id")]
556 fn set_startup_id(&self, startup_id: &str) {
557 unsafe {
558 ffi::gdk_toplevel_set_startup_id(
559 self.as_ref().to_glib_none().0,
560 startup_id.to_glib_none().0,
561 );
562 }
563 }
564
565 /// Sets the title of a toplevel surface.
566 ///
567 /// The title maybe be displayed in the titlebar,
568 /// in lists of windows, etc.
569 /// ## `title`
570 /// title of @surface
571 #[doc(alias = "gdk_toplevel_set_title")]
572 #[doc(alias = "title")]
573 fn set_title(&self, title: &str) {
574 unsafe {
575 ffi::gdk_toplevel_set_title(self.as_ref().to_glib_none().0, title.to_glib_none().0);
576 }
577 }
578
579 /// Sets a transient-for parent.
580 ///
581 /// Indicates to the window manager that @surface is a transient
582 /// dialog associated with the application surface @parent. This
583 /// allows the window manager to do things like center @surface
584 /// on @parent and keep @surface above @parent.
585 ///
586 /// See [gtk_window_set_transient_for()](../gtk4/method.Window.set_transient_for.html)
587 /// if you’re using [GtkWindow](../gtk4/class.Window.html).
588 /// ## `parent`
589 /// another toplevel [`Surface`][crate::Surface]
590 #[doc(alias = "gdk_toplevel_set_transient_for")]
591 #[doc(alias = "transient-for")]
592 fn set_transient_for(&self, parent: &impl IsA<Surface>) {
593 unsafe {
594 ffi::gdk_toplevel_set_transient_for(
595 self.as_ref().to_glib_none().0,
596 parent.as_ref().to_glib_none().0,
597 );
598 }
599 }
600
601 /// Asks the windowing system to show the window menu.
602 ///
603 /// The window menu is the menu shown when right-clicking the titlebar
604 /// on traditional windows managed by the window manager. This is useful
605 /// for windows using client-side decorations, activating it with a
606 /// right-click on the window decorations.
607 /// ## `event`
608 /// a [`Event`][crate::Event] to show the menu for
609 ///
610 /// # Returns
611 ///
612 /// [`true`] if the window menu was shown and [`false`] otherwise.
613 #[doc(alias = "gdk_toplevel_show_window_menu")]
614 fn show_window_menu(&self, event: impl AsRef<Event>) -> bool {
615 unsafe {
616 from_glib(ffi::gdk_toplevel_show_window_menu(
617 self.as_ref().to_glib_none().0,
618 event.as_ref().to_glib_none().0,
619 ))
620 }
621 }
622
623 /// Returns whether the desktop environment supports
624 /// tiled window states.
625 ///
626 /// # Returns
627 ///
628 /// [`true`] if the desktop environment supports tiled window states
629 #[doc(alias = "gdk_toplevel_supports_edge_constraints")]
630 fn supports_edge_constraints(&self) -> bool {
631 unsafe {
632 from_glib(ffi::gdk_toplevel_supports_edge_constraints(
633 self.as_ref().to_glib_none().0,
634 ))
635 }
636 }
637
638 /// Performs a title bar gesture.
639 /// ## `gesture`
640 /// a [`TitlebarGesture`][crate::TitlebarGesture]
641 ///
642 /// # Returns
643 ///
644 /// whether the gesture was performed
645 #[cfg(feature = "v4_4")]
646 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
647 #[doc(alias = "gdk_toplevel_titlebar_gesture")]
648 fn titlebar_gesture(&self, gesture: TitlebarGesture) -> bool {
649 unsafe {
650 from_glib(ffi::gdk_toplevel_titlebar_gesture(
651 self.as_ref().to_glib_none().0,
652 gesture.into_glib(),
653 ))
654 }
655 }
656
657 /// Whether the window manager should add decorations.
658 fn is_decorated(&self) -> bool {
659 ObjectExt::property(self.as_ref(), "decorated")
660 }
661
662 /// Whether the window manager should allow to close the surface.
663 fn is_deletable(&self) -> bool {
664 ObjectExt::property(self.as_ref(), "deletable")
665 }
666
667 /// The fullscreen mode of the surface.
668 #[doc(alias = "fullscreen-mode")]
669 fn fullscreen_mode(&self) -> FullscreenMode {
670 ObjectExt::property(self.as_ref(), "fullscreen-mode")
671 }
672
673 /// The fullscreen mode of the surface.
674 #[doc(alias = "fullscreen-mode")]
675 fn set_fullscreen_mode(&self, fullscreen_mode: FullscreenMode) {
676 ObjectExt::set_property(self.as_ref(), "fullscreen-mode", fullscreen_mode)
677 }
678
679 //#[doc(alias = "icon-list")]
680 //fn icon_list(&self) -> /*Unimplemented*/Basic: Pointer {
681 // ObjectExt::property(self.as_ref(), "icon-list")
682 //}
683
684 /// Whether the surface is modal.
685 fn is_modal(&self) -> bool {
686 ObjectExt::property(self.as_ref(), "modal")
687 }
688
689 /// Whether the surface should inhibit keyboard shortcuts.
690 #[doc(alias = "shortcuts-inhibited")]
691 fn is_shortcuts_inhibited(&self) -> bool {
692 ObjectExt::property(self.as_ref(), "shortcuts-inhibited")
693 }
694
695 /// The startup ID of the surface.
696 ///
697 /// See [`AppLaunchContext`][crate::AppLaunchContext] for more information about
698 /// startup feedback.
699 #[doc(alias = "startup-id")]
700 fn startup_id(&self) -> Option<glib::GString> {
701 ObjectExt::property(self.as_ref(), "startup-id")
702 }
703
704 /// The title of the surface.
705 fn title(&self) -> Option<glib::GString> {
706 ObjectExt::property(self.as_ref(), "title")
707 }
708
709 /// The transient parent of the surface.
710 #[doc(alias = "transient-for")]
711 fn transient_for(&self) -> Option<Surface> {
712 ObjectExt::property(self.as_ref(), "transient-for")
713 }
714
715 #[cfg(feature = "v4_20")]
716 #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
717 #[doc(alias = "capabilities")]
718 fn connect_capabilities_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
719 unsafe extern "C" fn notify_capabilities_trampoline<
720 P: IsA<Toplevel>,
721 F: Fn(&P) + 'static,
722 >(
723 this: *mut ffi::GdkToplevel,
724 _param_spec: glib::ffi::gpointer,
725 f: glib::ffi::gpointer,
726 ) {
727 unsafe {
728 let f: &F = &*(f as *const F);
729 f(Toplevel::from_glib_borrow(this).unsafe_cast_ref())
730 }
731 }
732 unsafe {
733 let f: Box_<F> = Box_::new(f);
734 connect_raw(
735 self.as_ptr() as *mut _,
736 c"notify::capabilities".as_ptr() as *const _,
737 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
738 notify_capabilities_trampoline::<Self, F> as *const (),
739 )),
740 Box_::into_raw(f),
741 )
742 }
743 }
744
745 #[doc(alias = "decorated")]
746 fn connect_decorated_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
747 unsafe extern "C" fn notify_decorated_trampoline<P: IsA<Toplevel>, F: Fn(&P) + 'static>(
748 this: *mut ffi::GdkToplevel,
749 _param_spec: glib::ffi::gpointer,
750 f: glib::ffi::gpointer,
751 ) {
752 unsafe {
753 let f: &F = &*(f as *const F);
754 f(Toplevel::from_glib_borrow(this).unsafe_cast_ref())
755 }
756 }
757 unsafe {
758 let f: Box_<F> = Box_::new(f);
759 connect_raw(
760 self.as_ptr() as *mut _,
761 c"notify::decorated".as_ptr() as *const _,
762 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
763 notify_decorated_trampoline::<Self, F> as *const (),
764 )),
765 Box_::into_raw(f),
766 )
767 }
768 }
769
770 #[doc(alias = "deletable")]
771 fn connect_deletable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
772 unsafe extern "C" fn notify_deletable_trampoline<P: IsA<Toplevel>, F: Fn(&P) + 'static>(
773 this: *mut ffi::GdkToplevel,
774 _param_spec: glib::ffi::gpointer,
775 f: glib::ffi::gpointer,
776 ) {
777 unsafe {
778 let f: &F = &*(f as *const F);
779 f(Toplevel::from_glib_borrow(this).unsafe_cast_ref())
780 }
781 }
782 unsafe {
783 let f: Box_<F> = Box_::new(f);
784 connect_raw(
785 self.as_ptr() as *mut _,
786 c"notify::deletable".as_ptr() as *const _,
787 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
788 notify_deletable_trampoline::<Self, F> as *const (),
789 )),
790 Box_::into_raw(f),
791 )
792 }
793 }
794
795 #[doc(alias = "fullscreen-mode")]
796 fn connect_fullscreen_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
797 unsafe extern "C" fn notify_fullscreen_mode_trampoline<
798 P: IsA<Toplevel>,
799 F: Fn(&P) + 'static,
800 >(
801 this: *mut ffi::GdkToplevel,
802 _param_spec: glib::ffi::gpointer,
803 f: glib::ffi::gpointer,
804 ) {
805 unsafe {
806 let f: &F = &*(f as *const F);
807 f(Toplevel::from_glib_borrow(this).unsafe_cast_ref())
808 }
809 }
810 unsafe {
811 let f: Box_<F> = Box_::new(f);
812 connect_raw(
813 self.as_ptr() as *mut _,
814 c"notify::fullscreen-mode".as_ptr() as *const _,
815 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
816 notify_fullscreen_mode_trampoline::<Self, F> as *const (),
817 )),
818 Box_::into_raw(f),
819 )
820 }
821 }
822
823 #[cfg(feature = "v4_20")]
824 #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
825 #[doc(alias = "gravity")]
826 fn connect_gravity_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
827 unsafe extern "C" fn notify_gravity_trampoline<P: IsA<Toplevel>, F: Fn(&P) + 'static>(
828 this: *mut ffi::GdkToplevel,
829 _param_spec: glib::ffi::gpointer,
830 f: glib::ffi::gpointer,
831 ) {
832 unsafe {
833 let f: &F = &*(f as *const F);
834 f(Toplevel::from_glib_borrow(this).unsafe_cast_ref())
835 }
836 }
837 unsafe {
838 let f: Box_<F> = Box_::new(f);
839 connect_raw(
840 self.as_ptr() as *mut _,
841 c"notify::gravity".as_ptr() as *const _,
842 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
843 notify_gravity_trampoline::<Self, F> as *const (),
844 )),
845 Box_::into_raw(f),
846 )
847 }
848 }
849
850 #[doc(alias = "icon-list")]
851 fn connect_icon_list_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
852 unsafe extern "C" fn notify_icon_list_trampoline<P: IsA<Toplevel>, F: Fn(&P) + 'static>(
853 this: *mut ffi::GdkToplevel,
854 _param_spec: glib::ffi::gpointer,
855 f: glib::ffi::gpointer,
856 ) {
857 unsafe {
858 let f: &F = &*(f as *const F);
859 f(Toplevel::from_glib_borrow(this).unsafe_cast_ref())
860 }
861 }
862 unsafe {
863 let f: Box_<F> = Box_::new(f);
864 connect_raw(
865 self.as_ptr() as *mut _,
866 c"notify::icon-list".as_ptr() as *const _,
867 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
868 notify_icon_list_trampoline::<Self, F> as *const (),
869 )),
870 Box_::into_raw(f),
871 )
872 }
873 }
874
875 #[doc(alias = "modal")]
876 fn connect_modal_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
877 unsafe extern "C" fn notify_modal_trampoline<P: IsA<Toplevel>, F: Fn(&P) + 'static>(
878 this: *mut ffi::GdkToplevel,
879 _param_spec: glib::ffi::gpointer,
880 f: glib::ffi::gpointer,
881 ) {
882 unsafe {
883 let f: &F = &*(f as *const F);
884 f(Toplevel::from_glib_borrow(this).unsafe_cast_ref())
885 }
886 }
887 unsafe {
888 let f: Box_<F> = Box_::new(f);
889 connect_raw(
890 self.as_ptr() as *mut _,
891 c"notify::modal".as_ptr() as *const _,
892 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
893 notify_modal_trampoline::<Self, F> as *const (),
894 )),
895 Box_::into_raw(f),
896 )
897 }
898 }
899
900 #[doc(alias = "shortcuts-inhibited")]
901 fn connect_shortcuts_inhibited_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
902 unsafe extern "C" fn notify_shortcuts_inhibited_trampoline<
903 P: IsA<Toplevel>,
904 F: Fn(&P) + 'static,
905 >(
906 this: *mut ffi::GdkToplevel,
907 _param_spec: glib::ffi::gpointer,
908 f: glib::ffi::gpointer,
909 ) {
910 unsafe {
911 let f: &F = &*(f as *const F);
912 f(Toplevel::from_glib_borrow(this).unsafe_cast_ref())
913 }
914 }
915 unsafe {
916 let f: Box_<F> = Box_::new(f);
917 connect_raw(
918 self.as_ptr() as *mut _,
919 c"notify::shortcuts-inhibited".as_ptr() as *const _,
920 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
921 notify_shortcuts_inhibited_trampoline::<Self, F> as *const (),
922 )),
923 Box_::into_raw(f),
924 )
925 }
926 }
927
928 #[doc(alias = "startup-id")]
929 fn connect_startup_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
930 unsafe extern "C" fn notify_startup_id_trampoline<P: IsA<Toplevel>, F: Fn(&P) + 'static>(
931 this: *mut ffi::GdkToplevel,
932 _param_spec: glib::ffi::gpointer,
933 f: glib::ffi::gpointer,
934 ) {
935 unsafe {
936 let f: &F = &*(f as *const F);
937 f(Toplevel::from_glib_borrow(this).unsafe_cast_ref())
938 }
939 }
940 unsafe {
941 let f: Box_<F> = Box_::new(f);
942 connect_raw(
943 self.as_ptr() as *mut _,
944 c"notify::startup-id".as_ptr() as *const _,
945 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
946 notify_startup_id_trampoline::<Self, F> as *const (),
947 )),
948 Box_::into_raw(f),
949 )
950 }
951 }
952
953 #[doc(alias = "state")]
954 fn connect_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
955 unsafe extern "C" fn notify_state_trampoline<P: IsA<Toplevel>, F: Fn(&P) + 'static>(
956 this: *mut ffi::GdkToplevel,
957 _param_spec: glib::ffi::gpointer,
958 f: glib::ffi::gpointer,
959 ) {
960 unsafe {
961 let f: &F = &*(f as *const F);
962 f(Toplevel::from_glib_borrow(this).unsafe_cast_ref())
963 }
964 }
965 unsafe {
966 let f: Box_<F> = Box_::new(f);
967 connect_raw(
968 self.as_ptr() as *mut _,
969 c"notify::state".as_ptr() as *const _,
970 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
971 notify_state_trampoline::<Self, F> as *const (),
972 )),
973 Box_::into_raw(f),
974 )
975 }
976 }
977
978 #[doc(alias = "title")]
979 fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
980 unsafe extern "C" fn notify_title_trampoline<P: IsA<Toplevel>, F: Fn(&P) + 'static>(
981 this: *mut ffi::GdkToplevel,
982 _param_spec: glib::ffi::gpointer,
983 f: glib::ffi::gpointer,
984 ) {
985 unsafe {
986 let f: &F = &*(f as *const F);
987 f(Toplevel::from_glib_borrow(this).unsafe_cast_ref())
988 }
989 }
990 unsafe {
991 let f: Box_<F> = Box_::new(f);
992 connect_raw(
993 self.as_ptr() as *mut _,
994 c"notify::title".as_ptr() as *const _,
995 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
996 notify_title_trampoline::<Self, F> as *const (),
997 )),
998 Box_::into_raw(f),
999 )
1000 }
1001 }
1002
1003 #[doc(alias = "transient-for")]
1004 fn connect_transient_for_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1005 unsafe extern "C" fn notify_transient_for_trampoline<
1006 P: IsA<Toplevel>,
1007 F: Fn(&P) + 'static,
1008 >(
1009 this: *mut ffi::GdkToplevel,
1010 _param_spec: glib::ffi::gpointer,
1011 f: glib::ffi::gpointer,
1012 ) {
1013 unsafe {
1014 let f: &F = &*(f as *const F);
1015 f(Toplevel::from_glib_borrow(this).unsafe_cast_ref())
1016 }
1017 }
1018 unsafe {
1019 let f: Box_<F> = Box_::new(f);
1020 connect_raw(
1021 self.as_ptr() as *mut _,
1022 c"notify::transient-for".as_ptr() as *const _,
1023 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1024 notify_transient_for_trampoline::<Self, F> as *const (),
1025 )),
1026 Box_::into_raw(f),
1027 )
1028 }
1029 }
1030}
1031
1032impl<O: IsA<Toplevel>> ToplevelExt for O {}