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