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