libadwaita/auto/
window_title.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::ffi;
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "AdwWindowTitle")]
16    pub struct WindowTitle(Object<ffi::AdwWindowTitle, ffi::AdwWindowTitleClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
17
18    match fn {
19        type_ => || ffi::adw_window_title_get_type(),
20    }
21}
22
23impl WindowTitle {
24    #[doc(alias = "adw_window_title_new")]
25    pub fn new(title: &str, subtitle: &str) -> WindowTitle {
26        assert_initialized_main_thread!();
27        unsafe {
28            gtk::Widget::from_glib_none(ffi::adw_window_title_new(
29                title.to_glib_none().0,
30                subtitle.to_glib_none().0,
31            ))
32            .unsafe_cast()
33        }
34    }
35
36    // rustdoc-stripper-ignore-next
37    /// Creates a new builder-pattern struct instance to construct [`WindowTitle`] objects.
38    ///
39    /// This method returns an instance of [`WindowTitleBuilder`](crate::builders::WindowTitleBuilder) which can be used to create [`WindowTitle`] objects.
40    pub fn builder() -> WindowTitleBuilder {
41        WindowTitleBuilder::new()
42    }
43
44    #[doc(alias = "adw_window_title_get_subtitle")]
45    #[doc(alias = "get_subtitle")]
46    pub fn subtitle(&self) -> glib::GString {
47        unsafe { from_glib_none(ffi::adw_window_title_get_subtitle(self.to_glib_none().0)) }
48    }
49
50    #[doc(alias = "adw_window_title_get_title")]
51    #[doc(alias = "get_title")]
52    pub fn title(&self) -> glib::GString {
53        unsafe { from_glib_none(ffi::adw_window_title_get_title(self.to_glib_none().0)) }
54    }
55
56    #[doc(alias = "adw_window_title_set_subtitle")]
57    #[doc(alias = "subtitle")]
58    pub fn set_subtitle(&self, subtitle: &str) {
59        unsafe {
60            ffi::adw_window_title_set_subtitle(self.to_glib_none().0, subtitle.to_glib_none().0);
61        }
62    }
63
64    #[doc(alias = "adw_window_title_set_title")]
65    #[doc(alias = "title")]
66    pub fn set_title(&self, title: &str) {
67        unsafe {
68            ffi::adw_window_title_set_title(self.to_glib_none().0, title.to_glib_none().0);
69        }
70    }
71
72    #[doc(alias = "subtitle")]
73    pub fn connect_subtitle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
74        unsafe extern "C" fn notify_subtitle_trampoline<F: Fn(&WindowTitle) + 'static>(
75            this: *mut ffi::AdwWindowTitle,
76            _param_spec: glib::ffi::gpointer,
77            f: glib::ffi::gpointer,
78        ) {
79            let f: &F = &*(f as *const F);
80            f(&from_glib_borrow(this))
81        }
82        unsafe {
83            let f: Box_<F> = Box_::new(f);
84            connect_raw(
85                self.as_ptr() as *mut _,
86                c"notify::subtitle".as_ptr() as *const _,
87                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
88                    notify_subtitle_trampoline::<F> as *const (),
89                )),
90                Box_::into_raw(f),
91            )
92        }
93    }
94
95    #[doc(alias = "title")]
96    pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
97        unsafe extern "C" fn notify_title_trampoline<F: Fn(&WindowTitle) + 'static>(
98            this: *mut ffi::AdwWindowTitle,
99            _param_spec: glib::ffi::gpointer,
100            f: glib::ffi::gpointer,
101        ) {
102            let f: &F = &*(f as *const F);
103            f(&from_glib_borrow(this))
104        }
105        unsafe {
106            let f: Box_<F> = Box_::new(f);
107            connect_raw(
108                self.as_ptr() as *mut _,
109                c"notify::title".as_ptr() as *const _,
110                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
111                    notify_title_trampoline::<F> as *const (),
112                )),
113                Box_::into_raw(f),
114            )
115        }
116    }
117}
118
119impl Default for WindowTitle {
120    fn default() -> Self {
121        glib::object::Object::new::<Self>()
122    }
123}
124
125// rustdoc-stripper-ignore-next
126/// A [builder-pattern] type to construct [`WindowTitle`] objects.
127///
128/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
129#[must_use = "The builder must be built to be used"]
130pub struct WindowTitleBuilder {
131    builder: glib::object::ObjectBuilder<'static, WindowTitle>,
132}
133
134impl WindowTitleBuilder {
135    fn new() -> Self {
136        Self {
137            builder: glib::object::Object::builder(),
138        }
139    }
140
141    pub fn subtitle(self, subtitle: impl Into<glib::GString>) -> Self {
142        Self {
143            builder: self.builder.property("subtitle", subtitle.into()),
144        }
145    }
146
147    pub fn title(self, title: impl Into<glib::GString>) -> Self {
148        Self {
149            builder: self.builder.property("title", title.into()),
150        }
151    }
152
153    pub fn can_focus(self, can_focus: bool) -> Self {
154        Self {
155            builder: self.builder.property("can-focus", can_focus),
156        }
157    }
158
159    pub fn can_target(self, can_target: bool) -> Self {
160        Self {
161            builder: self.builder.property("can-target", can_target),
162        }
163    }
164
165    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
166        Self {
167            builder: self.builder.property("css-classes", css_classes.into()),
168        }
169    }
170
171    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
172        Self {
173            builder: self.builder.property("css-name", css_name.into()),
174        }
175    }
176
177    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
178        Self {
179            builder: self.builder.property("cursor", cursor.clone()),
180        }
181    }
182
183    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
184        Self {
185            builder: self.builder.property("focus-on-click", focus_on_click),
186        }
187    }
188
189    pub fn focusable(self, focusable: bool) -> Self {
190        Self {
191            builder: self.builder.property("focusable", focusable),
192        }
193    }
194
195    pub fn halign(self, halign: gtk::Align) -> Self {
196        Self {
197            builder: self.builder.property("halign", halign),
198        }
199    }
200
201    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
202        Self {
203            builder: self.builder.property("has-tooltip", has_tooltip),
204        }
205    }
206
207    pub fn height_request(self, height_request: i32) -> Self {
208        Self {
209            builder: self.builder.property("height-request", height_request),
210        }
211    }
212
213    pub fn hexpand(self, hexpand: bool) -> Self {
214        Self {
215            builder: self.builder.property("hexpand", hexpand),
216        }
217    }
218
219    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
220        Self {
221            builder: self.builder.property("hexpand-set", hexpand_set),
222        }
223    }
224
225    pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
226        Self {
227            builder: self
228                .builder
229                .property("layout-manager", layout_manager.clone().upcast()),
230        }
231    }
232
233    #[cfg(feature = "gtk_v4_18")]
234    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
235    pub fn limit_events(self, limit_events: bool) -> Self {
236        Self {
237            builder: self.builder.property("limit-events", limit_events),
238        }
239    }
240
241    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
242        Self {
243            builder: self.builder.property("margin-bottom", margin_bottom),
244        }
245    }
246
247    pub fn margin_end(self, margin_end: i32) -> Self {
248        Self {
249            builder: self.builder.property("margin-end", margin_end),
250        }
251    }
252
253    pub fn margin_start(self, margin_start: i32) -> Self {
254        Self {
255            builder: self.builder.property("margin-start", margin_start),
256        }
257    }
258
259    pub fn margin_top(self, margin_top: i32) -> Self {
260        Self {
261            builder: self.builder.property("margin-top", margin_top),
262        }
263    }
264
265    pub fn name(self, name: impl Into<glib::GString>) -> Self {
266        Self {
267            builder: self.builder.property("name", name.into()),
268        }
269    }
270
271    pub fn opacity(self, opacity: f64) -> Self {
272        Self {
273            builder: self.builder.property("opacity", opacity),
274        }
275    }
276
277    pub fn overflow(self, overflow: gtk::Overflow) -> Self {
278        Self {
279            builder: self.builder.property("overflow", overflow),
280        }
281    }
282
283    pub fn receives_default(self, receives_default: bool) -> Self {
284        Self {
285            builder: self.builder.property("receives-default", receives_default),
286        }
287    }
288
289    pub fn sensitive(self, sensitive: bool) -> Self {
290        Self {
291            builder: self.builder.property("sensitive", sensitive),
292        }
293    }
294
295    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
296        Self {
297            builder: self
298                .builder
299                .property("tooltip-markup", tooltip_markup.into()),
300        }
301    }
302
303    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
304        Self {
305            builder: self.builder.property("tooltip-text", tooltip_text.into()),
306        }
307    }
308
309    pub fn valign(self, valign: gtk::Align) -> Self {
310        Self {
311            builder: self.builder.property("valign", valign),
312        }
313    }
314
315    pub fn vexpand(self, vexpand: bool) -> Self {
316        Self {
317            builder: self.builder.property("vexpand", vexpand),
318        }
319    }
320
321    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
322        Self {
323            builder: self.builder.property("vexpand-set", vexpand_set),
324        }
325    }
326
327    pub fn visible(self, visible: bool) -> Self {
328        Self {
329            builder: self.builder.property("visible", visible),
330        }
331    }
332
333    pub fn width_request(self, width_request: i32) -> Self {
334        Self {
335            builder: self.builder.property("width-request", width_request),
336        }
337    }
338
339    pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
340        Self {
341            builder: self.builder.property("accessible-role", accessible_role),
342        }
343    }
344
345    // rustdoc-stripper-ignore-next
346    /// Build the [`WindowTitle`].
347    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
348    pub fn build(self) -> WindowTitle {
349        assert_initialized_main_thread!();
350        self.builder.build()
351    }
352}