nm_rs/auto/setting_generic.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir
3// from gtk-girs (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::{ffi,Setting};
7use glib::{prelude::*,translate::*};
8#[cfg(feature = "v1_46")]
9#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
10use glib::{signal::{connect_raw, SignalHandlerId}};
11#[cfg(feature = "v1_46")]
12#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
13use std::{boxed::Box as Box_};
14
15glib::wrapper! {
16 /// Generic Link Settings
17 ///
18 /// ## Properties
19 ///
20 ///
21 /// #### `device-handler`
22 /// Name of the device handler that will be invoked to add and delete
23 /// the device for this connection. The name can only contain ASCII
24 /// alphanumeric characters and '-', '_', '.'. It cannot start with '.'.
25 ///
26 /// See the NetworkManager-dispatcher(8) man page for more details
27 /// about how to write the device handler.
28 ///
29 /// By setting this property the generic connection becomes "virtual",
30 /// meaning that it can be activated without an existing device; the device
31 /// will be created at the time the connection is started by invoking the
32 /// device-handler.
33 ///
34 /// Readable | Writeable
35 /// <details><summary><h4>Setting</h4></summary>
36 ///
37 ///
38 /// #### `name`
39 /// The setting's name, which uniquely identifies the setting within the
40 /// connection. Each setting type has a name unique to that type, for
41 /// example "ppp" or "802-11-wireless" or "802-3-ethernet".
42 ///
43 /// Readable
44 /// </details>
45 ///
46 /// # Implements
47 ///
48 /// [`SettingExt`][trait@crate::prelude::SettingExt]
49 #[doc(alias = "NMSettingGeneric")]
50 pub struct SettingGeneric(Object<ffi::NMSettingGeneric, ffi::NMSettingGenericClass>) @extends Setting;
51
52 match fn {
53 type_ => || ffi::nm_setting_generic_get_type(),
54 }
55}
56
57impl SettingGeneric {
58 /// Creates a new #NMSettingGeneric object with default values.
59 ///
60 /// # Returns
61 ///
62 /// the new empty #NMSettingGeneric object
63 #[doc(alias = "nm_setting_generic_new")]
64 pub fn new() -> SettingGeneric {
65 assert_initialized_main_thread!();
66 unsafe {
67 Setting::from_glib_full(ffi::nm_setting_generic_new()).unsafe_cast()
68 }
69 }
70
71 // rustdoc-stripper-ignore-next
72 /// Creates a new builder-pattern struct instance to construct [`SettingGeneric`] objects.
73 ///
74 /// This method returns an instance of [`SettingGenericBuilder`](crate::builders::SettingGenericBuilder) which can be used to create [`SettingGeneric`] objects.
75 pub fn builder() -> SettingGenericBuilder {
76 SettingGenericBuilder::new()
77 }
78
79
80 /// Returns the #NMSettingGeneric:device-handler property of the connection.
81 ///
82 /// # Returns
83 ///
84 /// the device handler name, or [`None`] if no device handler is set
85 #[cfg(feature = "v1_46")]
86 #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
87 #[doc(alias = "nm_setting_generic_get_device_handler")]
88 #[doc(alias = "get_device_handler")]
89 #[doc(alias = "device-handler")]
90 pub fn device_handler(&self) -> glib::GString {
91 unsafe {
92 from_glib_none(ffi::nm_setting_generic_get_device_handler(self.to_glib_none().0))
93 }
94 }
95
96 /// Name of the device handler that will be invoked to add and delete
97 /// the device for this connection. The name can only contain ASCII
98 /// alphanumeric characters and '-', '_', '.'. It cannot start with '.'.
99 ///
100 /// See the NetworkManager-dispatcher(8) man page for more details
101 /// about how to write the device handler.
102 ///
103 /// By setting this property the generic connection becomes "virtual",
104 /// meaning that it can be activated without an existing device; the device
105 /// will be created at the time the connection is started by invoking the
106 /// device-handler.
107 #[cfg(feature = "v1_46")]
108 #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
109 #[doc(alias = "device-handler")]
110 pub fn set_device_handler(&self, device_handler: Option<&str>) {
111 ObjectExt::set_property(self,"device-handler", device_handler)
112 }
113
114 #[cfg(feature = "v1_46")]
115 #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
116 #[doc(alias = "device-handler")]
117 pub fn connect_device_handler_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
118 unsafe extern "C" fn notify_device_handler_trampoline<F: Fn(&SettingGeneric) + 'static>(this: *mut ffi::NMSettingGeneric, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
119 let f: &F = &*(f as *const F);
120 f(&from_glib_borrow(this))
121 }
122 unsafe {
123 let f: Box_<F> = Box_::new(f);
124 connect_raw(self.as_ptr() as *mut _, c"notify::device-handler".as_ptr() as *const _,
125 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_device_handler_trampoline::<F> as *const ())), Box_::into_raw(f))
126 }
127 }
128}
129
130impl Default for SettingGeneric {
131 fn default() -> Self {
132 Self::new()
133 }
134 }
135
136// rustdoc-stripper-ignore-next
137 /// A [builder-pattern] type to construct [`SettingGeneric`] objects.
138 ///
139 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
140#[must_use = "The builder must be built to be used"]
141pub struct SettingGenericBuilder {
142 builder: glib::object::ObjectBuilder<'static, SettingGeneric>,
143 }
144
145 impl SettingGenericBuilder {
146 fn new() -> Self {
147 Self { builder: glib::object::Object::builder() }
148 }
149
150 /// Name of the device handler that will be invoked to add and delete
151 /// the device for this connection. The name can only contain ASCII
152 /// alphanumeric characters and '-', '_', '.'. It cannot start with '.'.
153 ///
154 /// See the NetworkManager-dispatcher(8) man page for more details
155 /// about how to write the device handler.
156 ///
157 /// By setting this property the generic connection becomes "virtual",
158 /// meaning that it can be activated without an existing device; the device
159 /// will be created at the time the connection is started by invoking the
160 /// device-handler.
161 #[cfg(feature = "v1_46")]
162 #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
163 pub fn device_handler(self, device_handler: impl Into<glib::GString>) -> Self {
164 Self { builder: self.builder.property("device-handler", device_handler.into()), }
165 }
166
167 // rustdoc-stripper-ignore-next
168 /// Build the [`SettingGeneric`].
169 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
170 pub fn build(self) -> SettingGeneric {
171assert_initialized_main_thread!();
172 self.builder.build() }
173}