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