1use crate::{ffi, Dialog, DialogPresentationMode, ShortcutsSection};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10 #[doc(alias = "AdwShortcutsDialog")]
11 pub struct ShortcutsDialog(Object<ffi::AdwShortcutsDialog, ffi::AdwShortcutsDialogClass>) @extends Dialog, gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::ShortcutManager;
12
13 match fn {
14 type_ => || ffi::adw_shortcuts_dialog_get_type(),
15 }
16}
17
18impl ShortcutsDialog {
19 #[doc(alias = "adw_shortcuts_dialog_new")]
20 pub fn new() -> ShortcutsDialog {
21 assert_initialized_main_thread!();
22 unsafe { Dialog::from_glib_none(ffi::adw_shortcuts_dialog_new()).unsafe_cast() }
23 }
24
25 pub fn builder() -> ShortcutsDialogBuilder {
30 ShortcutsDialogBuilder::new()
31 }
32
33 #[doc(alias = "adw_shortcuts_dialog_add")]
34 pub fn add(&self, section: ShortcutsSection) {
35 unsafe {
36 ffi::adw_shortcuts_dialog_add(self.to_glib_none().0, section.into_glib_ptr());
37 }
38 }
39}
40
41#[cfg(feature = "v1_8")]
42#[cfg_attr(docsrs, doc(cfg(feature = "v1_8")))]
43impl Default for ShortcutsDialog {
44 fn default() -> Self {
45 Self::new()
46 }
47}
48
49#[must_use = "The builder must be built to be used"]
54pub struct ShortcutsDialogBuilder {
55 builder: glib::object::ObjectBuilder<'static, ShortcutsDialog>,
56}
57
58impl ShortcutsDialogBuilder {
59 fn new() -> Self {
60 Self {
61 builder: glib::object::Object::builder(),
62 }
63 }
64
65 #[cfg(feature = "v1_5")]
66 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
67 pub fn can_close(self, can_close: bool) -> Self {
68 Self {
69 builder: self.builder.property("can-close", can_close),
70 }
71 }
72
73 #[cfg(feature = "v1_5")]
74 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
75 pub fn child(self, child: &impl IsA<gtk::Widget>) -> Self {
76 Self {
77 builder: self.builder.property("child", child.clone().upcast()),
78 }
79 }
80
81 #[cfg(feature = "v1_5")]
82 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
83 pub fn content_height(self, content_height: i32) -> Self {
84 Self {
85 builder: self.builder.property("content-height", content_height),
86 }
87 }
88
89 #[cfg(feature = "v1_5")]
90 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
91 pub fn content_width(self, content_width: i32) -> Self {
92 Self {
93 builder: self.builder.property("content-width", content_width),
94 }
95 }
96
97 #[cfg(feature = "v1_5")]
98 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
99 pub fn default_widget(self, default_widget: &impl IsA<gtk::Widget>) -> Self {
100 Self {
101 builder: self
102 .builder
103 .property("default-widget", default_widget.clone().upcast()),
104 }
105 }
106
107 #[cfg(feature = "v1_5")]
108 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
109 pub fn focus_widget(self, focus_widget: &impl IsA<gtk::Widget>) -> Self {
110 Self {
111 builder: self
112 .builder
113 .property("focus-widget", focus_widget.clone().upcast()),
114 }
115 }
116
117 #[cfg(feature = "v1_5")]
118 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
119 pub fn follows_content_size(self, follows_content_size: bool) -> Self {
120 Self {
121 builder: self
122 .builder
123 .property("follows-content-size", follows_content_size),
124 }
125 }
126
127 #[cfg(feature = "v1_5")]
128 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
129 pub fn presentation_mode(self, presentation_mode: DialogPresentationMode) -> Self {
130 Self {
131 builder: self
132 .builder
133 .property("presentation-mode", presentation_mode),
134 }
135 }
136
137 #[cfg(feature = "v1_5")]
138 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
139 pub fn title(self, title: impl Into<glib::GString>) -> Self {
140 Self {
141 builder: self.builder.property("title", title.into()),
142 }
143 }
144
145 pub fn can_focus(self, can_focus: bool) -> Self {
146 Self {
147 builder: self.builder.property("can-focus", can_focus),
148 }
149 }
150
151 pub fn can_target(self, can_target: bool) -> Self {
152 Self {
153 builder: self.builder.property("can-target", can_target),
154 }
155 }
156
157 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
158 Self {
159 builder: self.builder.property("css-classes", css_classes.into()),
160 }
161 }
162
163 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
164 Self {
165 builder: self.builder.property("css-name", css_name.into()),
166 }
167 }
168
169 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
170 Self {
171 builder: self.builder.property("cursor", cursor.clone()),
172 }
173 }
174
175 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
176 Self {
177 builder: self.builder.property("focus-on-click", focus_on_click),
178 }
179 }
180
181 pub fn focusable(self, focusable: bool) -> Self {
182 Self {
183 builder: self.builder.property("focusable", focusable),
184 }
185 }
186
187 pub fn halign(self, halign: gtk::Align) -> Self {
188 Self {
189 builder: self.builder.property("halign", halign),
190 }
191 }
192
193 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
194 Self {
195 builder: self.builder.property("has-tooltip", has_tooltip),
196 }
197 }
198
199 pub fn height_request(self, height_request: i32) -> Self {
200 Self {
201 builder: self.builder.property("height-request", height_request),
202 }
203 }
204
205 pub fn hexpand(self, hexpand: bool) -> Self {
206 Self {
207 builder: self.builder.property("hexpand", hexpand),
208 }
209 }
210
211 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
212 Self {
213 builder: self.builder.property("hexpand-set", hexpand_set),
214 }
215 }
216
217 pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
218 Self {
219 builder: self
220 .builder
221 .property("layout-manager", layout_manager.clone().upcast()),
222 }
223 }
224
225 #[cfg(feature = "gtk_v4_18")]
226 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
227 pub fn limit_events(self, limit_events: bool) -> Self {
228 Self {
229 builder: self.builder.property("limit-events", limit_events),
230 }
231 }
232
233 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
234 Self {
235 builder: self.builder.property("margin-bottom", margin_bottom),
236 }
237 }
238
239 pub fn margin_end(self, margin_end: i32) -> Self {
240 Self {
241 builder: self.builder.property("margin-end", margin_end),
242 }
243 }
244
245 pub fn margin_start(self, margin_start: i32) -> Self {
246 Self {
247 builder: self.builder.property("margin-start", margin_start),
248 }
249 }
250
251 pub fn margin_top(self, margin_top: i32) -> Self {
252 Self {
253 builder: self.builder.property("margin-top", margin_top),
254 }
255 }
256
257 pub fn name(self, name: impl Into<glib::GString>) -> Self {
258 Self {
259 builder: self.builder.property("name", name.into()),
260 }
261 }
262
263 pub fn opacity(self, opacity: f64) -> Self {
264 Self {
265 builder: self.builder.property("opacity", opacity),
266 }
267 }
268
269 pub fn overflow(self, overflow: gtk::Overflow) -> Self {
270 Self {
271 builder: self.builder.property("overflow", overflow),
272 }
273 }
274
275 pub fn receives_default(self, receives_default: bool) -> Self {
276 Self {
277 builder: self.builder.property("receives-default", receives_default),
278 }
279 }
280
281 pub fn sensitive(self, sensitive: bool) -> Self {
282 Self {
283 builder: self.builder.property("sensitive", sensitive),
284 }
285 }
286
287 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
288 Self {
289 builder: self
290 .builder
291 .property("tooltip-markup", tooltip_markup.into()),
292 }
293 }
294
295 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
296 Self {
297 builder: self.builder.property("tooltip-text", tooltip_text.into()),
298 }
299 }
300
301 pub fn valign(self, valign: gtk::Align) -> Self {
302 Self {
303 builder: self.builder.property("valign", valign),
304 }
305 }
306
307 pub fn vexpand(self, vexpand: bool) -> Self {
308 Self {
309 builder: self.builder.property("vexpand", vexpand),
310 }
311 }
312
313 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
314 Self {
315 builder: self.builder.property("vexpand-set", vexpand_set),
316 }
317 }
318
319 pub fn visible(self, visible: bool) -> Self {
320 Self {
321 builder: self.builder.property("visible", visible),
322 }
323 }
324
325 pub fn width_request(self, width_request: i32) -> Self {
326 Self {
327 builder: self.builder.property("width-request", width_request),
328 }
329 }
330
331 pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
332 Self {
333 builder: self.builder.property("accessible-role", accessible_role),
334 }
335 }
336
337 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
340 pub fn build(self) -> ShortcutsDialog {
341 assert_initialized_main_thread!();
342 self.builder.build()
343 }
344}