gdk4/auto/app_launch_context.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::{Display, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// message);
10 ///
11 /// g_object_unref (context);
12 /// ```text
13 ///
14 ///
15 /// ## Properties
16 ///
17 ///
18 /// #### `display`
19 /// The display that the [`AppLaunchContext`][crate::AppLaunchContext] is on.
20 ///
21 /// Readable | Writable | Construct Only
22 ///
23 /// # Implements
24 ///
25 /// [`GdkAppLaunchContextExt`][trait@crate::prelude::GdkAppLaunchContextExt], [`trait@gio::prelude::AppLaunchContextExt`]
26 #[doc(alias = "GdkAppLaunchContext")]
27 pub struct AppLaunchContext(Object<ffi::GdkAppLaunchContext>) @extends gio::AppLaunchContext;
28
29 match fn {
30 type_ => || ffi::gdk_app_launch_context_get_type(),
31 }
32}
33
34impl AppLaunchContext {
35 pub const NONE: Option<&'static AppLaunchContext> = None;
36}
37
38/// Trait containing all [`struct@AppLaunchContext`] methods.
39///
40/// # Implementors
41///
42/// [`AppLaunchContext`][struct@crate::AppLaunchContext]
43pub trait GdkAppLaunchContextExt: IsA<AppLaunchContext> + 'static {
44 /// Gets the [`Display`][crate::Display] that @self is for.
45 ///
46 /// # Returns
47 ///
48 /// the display of @self
49 #[doc(alias = "gdk_app_launch_context_get_display")]
50 #[doc(alias = "get_display")]
51 fn display(&self) -> Display {
52 unsafe {
53 from_glib_none(ffi::gdk_app_launch_context_get_display(
54 self.as_ref().to_glib_none().0,
55 ))
56 }
57 }
58
59 /// Sets the workspace on which applications will be launched.
60 ///
61 /// This only works when running under a window manager that
62 /// supports multiple workspaces, as described in the
63 /// [Extended Window Manager Hints](https://specifications.freedesktop.org/wm/latest/).
64 /// Specifically this sets the `_NET_WM_DESKTOP` property described
65 /// in that spec.
66 ///
67 /// This only works when using the X11 backend.
68 ///
69 /// When the workspace is not specified or @desktop is set to -1,
70 /// it is up to the window manager to pick one, typically it will
71 /// be the current workspace.
72 /// ## `desktop`
73 /// the number of a workspace, or -1
74 #[doc(alias = "gdk_app_launch_context_set_desktop")]
75 fn set_desktop(&self, desktop: i32) {
76 unsafe {
77 ffi::gdk_app_launch_context_set_desktop(self.as_ref().to_glib_none().0, desktop);
78 }
79 }
80
81 /// Sets the icon for applications that are launched with this
82 /// context.
83 ///
84 /// Window Managers can use this information when displaying startup
85 /// notification.
86 ///
87 /// See also [`set_icon_name()`][Self::set_icon_name()].
88 /// ## `icon`
89 /// a `GIcon`
90 #[doc(alias = "gdk_app_launch_context_set_icon")]
91 fn set_icon(&self, icon: Option<&impl IsA<gio::Icon>>) {
92 unsafe {
93 ffi::gdk_app_launch_context_set_icon(
94 self.as_ref().to_glib_none().0,
95 icon.map(|p| p.as_ref()).to_glib_none().0,
96 );
97 }
98 }
99
100 /// Sets the icon for applications that are launched with this context.
101 ///
102 /// The @icon_name will be interpreted in the same way as the Icon field
103 /// in desktop files. See also [`set_icon()`][Self::set_icon()].
104 ///
105 /// If both @icon and @icon_name are set, the @icon_name takes priority.
106 /// If neither @icon or @icon_name is set, the icon is taken from either
107 /// the file that is passed to launched application or from the `GAppInfo`
108 /// for the launched application itself.
109 /// ## `icon_name`
110 /// an icon name
111 #[doc(alias = "gdk_app_launch_context_set_icon_name")]
112 fn set_icon_name(&self, icon_name: Option<&str>) {
113 unsafe {
114 ffi::gdk_app_launch_context_set_icon_name(
115 self.as_ref().to_glib_none().0,
116 icon_name.to_glib_none().0,
117 );
118 }
119 }
120
121 /// Sets the timestamp of @self.
122 ///
123 /// The timestamp should ideally be taken from the event that
124 /// triggered the launch.
125 ///
126 /// Window managers can use this information to avoid moving the
127 /// focus to the newly launched application when the user is busy
128 /// typing in another window. This is also known as 'focus stealing
129 /// prevention'.
130 /// ## `timestamp`
131 /// a timestamp
132 #[doc(alias = "gdk_app_launch_context_set_timestamp")]
133 fn set_timestamp(&self, timestamp: u32) {
134 unsafe {
135 ffi::gdk_app_launch_context_set_timestamp(self.as_ref().to_glib_none().0, timestamp);
136 }
137 }
138}
139
140impl<O: IsA<AppLaunchContext>> GdkAppLaunchContextExt for O {}