1#![allow(deprecated)]
5
6#[cfg(feature = "v4_14")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
8use crate::ShortcutsGroup;
9use crate::{
10 Accessible, AccessibleRole, Align, BaselinePosition, Box, Buildable, ConstraintTarget,
11 LayoutManager, Orientable, Orientation, Overflow, Widget, ffi,
12};
13use glib::{
14 prelude::*,
15 signal::{SignalHandlerId, connect_raw},
16 translate::*,
17};
18use std::boxed::Box as Box_;
19
20glib::wrapper! {
21 #[doc(alias = "GtkShortcutsSection")]
22 pub struct ShortcutsSection(Object<ffi::GtkShortcutsSection, ffi::GtkShortcutsSectionClass>) @extends Box, Widget, @implements Accessible, Buildable, ConstraintTarget, Orientable;
23
24 match fn {
25 type_ => || ffi::gtk_shortcuts_section_get_type(),
26 }
27}
28
29impl ShortcutsSection {
30 pub fn builder() -> ShortcutsSectionBuilder {
35 ShortcutsSectionBuilder::new()
36 }
37
38 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
39 #[cfg(feature = "v4_14")]
40 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
41 #[allow(deprecated)]
42 #[doc(alias = "gtk_shortcuts_section_add_group")]
43 pub fn add_group(&self, group: &ShortcutsGroup) {
44 unsafe {
45 ffi::gtk_shortcuts_section_add_group(self.to_glib_none().0, group.to_glib_none().0);
46 }
47 }
48
49 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
50 #[doc(alias = "max-height")]
51 pub fn max_height(&self) -> u32 {
52 ObjectExt::property(self, "max-height")
53 }
54
55 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
56 #[doc(alias = "max-height")]
57 pub fn set_max_height(&self, max_height: u32) {
58 ObjectExt::set_property(self, "max-height", max_height)
59 }
60
61 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
62 #[doc(alias = "section-name")]
63 pub fn section_name(&self) -> Option<glib::GString> {
64 ObjectExt::property(self, "section-name")
65 }
66
67 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
68 #[doc(alias = "section-name")]
69 pub fn set_section_name(&self, section_name: Option<&str>) {
70 ObjectExt::set_property(self, "section-name", section_name)
71 }
72
73 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
74 pub fn title(&self) -> Option<glib::GString> {
75 ObjectExt::property(self, "title")
76 }
77
78 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
79 pub fn set_title(&self, title: Option<&str>) {
80 ObjectExt::set_property(self, "title", title)
81 }
82
83 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
84 #[doc(alias = "view-name")]
85 pub fn view_name(&self) -> Option<glib::GString> {
86 ObjectExt::property(self, "view-name")
87 }
88
89 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
90 #[doc(alias = "view-name")]
91 pub fn set_view_name(&self, view_name: Option<&str>) {
92 ObjectExt::set_property(self, "view-name", view_name)
93 }
94
95 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
96 #[doc(alias = "max-height")]
97 pub fn connect_max_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
98 unsafe extern "C" fn notify_max_height_trampoline<F: Fn(&ShortcutsSection) + 'static>(
99 this: *mut ffi::GtkShortcutsSection,
100 _param_spec: glib::ffi::gpointer,
101 f: glib::ffi::gpointer,
102 ) {
103 unsafe {
104 let f: &F = &*(f as *const F);
105 f(&from_glib_borrow(this))
106 }
107 }
108 unsafe {
109 let f: Box_<F> = Box_::new(f);
110 connect_raw(
111 self.as_ptr() as *mut _,
112 c"notify::max-height".as_ptr(),
113 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
114 notify_max_height_trampoline::<F> as *const (),
115 )),
116 Box_::into_raw(f),
117 )
118 }
119 }
120
121 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
122 #[doc(alias = "section-name")]
123 pub fn connect_section_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
124 unsafe extern "C" fn notify_section_name_trampoline<F: Fn(&ShortcutsSection) + 'static>(
125 this: *mut ffi::GtkShortcutsSection,
126 _param_spec: glib::ffi::gpointer,
127 f: glib::ffi::gpointer,
128 ) {
129 unsafe {
130 let f: &F = &*(f as *const F);
131 f(&from_glib_borrow(this))
132 }
133 }
134 unsafe {
135 let f: Box_<F> = Box_::new(f);
136 connect_raw(
137 self.as_ptr() as *mut _,
138 c"notify::section-name".as_ptr(),
139 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
140 notify_section_name_trampoline::<F> as *const (),
141 )),
142 Box_::into_raw(f),
143 )
144 }
145 }
146
147 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
148 #[doc(alias = "title")]
149 pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
150 unsafe extern "C" fn notify_title_trampoline<F: Fn(&ShortcutsSection) + 'static>(
151 this: *mut ffi::GtkShortcutsSection,
152 _param_spec: glib::ffi::gpointer,
153 f: glib::ffi::gpointer,
154 ) {
155 unsafe {
156 let f: &F = &*(f as *const F);
157 f(&from_glib_borrow(this))
158 }
159 }
160 unsafe {
161 let f: Box_<F> = Box_::new(f);
162 connect_raw(
163 self.as_ptr() as *mut _,
164 c"notify::title".as_ptr(),
165 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
166 notify_title_trampoline::<F> as *const (),
167 )),
168 Box_::into_raw(f),
169 )
170 }
171 }
172
173 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
174 #[doc(alias = "view-name")]
175 pub fn connect_view_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
176 unsafe extern "C" fn notify_view_name_trampoline<F: Fn(&ShortcutsSection) + 'static>(
177 this: *mut ffi::GtkShortcutsSection,
178 _param_spec: glib::ffi::gpointer,
179 f: glib::ffi::gpointer,
180 ) {
181 unsafe {
182 let f: &F = &*(f as *const F);
183 f(&from_glib_borrow(this))
184 }
185 }
186 unsafe {
187 let f: Box_<F> = Box_::new(f);
188 connect_raw(
189 self.as_ptr() as *mut _,
190 c"notify::view-name".as_ptr(),
191 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
192 notify_view_name_trampoline::<F> as *const (),
193 )),
194 Box_::into_raw(f),
195 )
196 }
197 }
198}
199
200#[must_use = "The builder must be built to be used"]
205pub struct ShortcutsSectionBuilder {
206 builder: glib::object::ObjectBuilder<'static, ShortcutsSection>,
207}
208
209impl ShortcutsSectionBuilder {
210 fn new() -> Self {
211 Self {
212 builder: glib::object::Object::builder(),
213 }
214 }
215
216 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
217 pub fn max_height(self, max_height: u32) -> Self {
218 Self {
219 builder: self.builder.property("max-height", max_height),
220 }
221 }
222
223 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
224 pub fn section_name(self, section_name: impl Into<glib::GString>) -> Self {
225 Self {
226 builder: self.builder.property("section-name", section_name.into()),
227 }
228 }
229
230 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
231 pub fn title(self, title: impl Into<glib::GString>) -> Self {
232 Self {
233 builder: self.builder.property("title", title.into()),
234 }
235 }
236
237 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
238 pub fn view_name(self, view_name: impl Into<glib::GString>) -> Self {
239 Self {
240 builder: self.builder.property("view-name", view_name.into()),
241 }
242 }
243
244 #[cfg(feature = "v4_12")]
245 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
246 pub fn baseline_child(self, baseline_child: i32) -> Self {
247 Self {
248 builder: self.builder.property("baseline-child", baseline_child),
249 }
250 }
251
252 pub fn baseline_position(self, baseline_position: BaselinePosition) -> Self {
253 Self {
254 builder: self
255 .builder
256 .property("baseline-position", baseline_position),
257 }
258 }
259
260 pub fn homogeneous(self, homogeneous: bool) -> Self {
261 Self {
262 builder: self.builder.property("homogeneous", homogeneous),
263 }
264 }
265
266 pub fn spacing(self, spacing: i32) -> Self {
267 Self {
268 builder: self.builder.property("spacing", spacing),
269 }
270 }
271
272 pub fn can_focus(self, can_focus: bool) -> Self {
273 Self {
274 builder: self.builder.property("can-focus", can_focus),
275 }
276 }
277
278 pub fn can_target(self, can_target: bool) -> Self {
279 Self {
280 builder: self.builder.property("can-target", can_target),
281 }
282 }
283
284 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
285 Self {
286 builder: self.builder.property("css-classes", css_classes.into()),
287 }
288 }
289
290 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
291 Self {
292 builder: self.builder.property("css-name", css_name.into()),
293 }
294 }
295
296 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
297 Self {
298 builder: self.builder.property("cursor", cursor.clone()),
299 }
300 }
301
302 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
303 Self {
304 builder: self.builder.property("focus-on-click", focus_on_click),
305 }
306 }
307
308 pub fn focusable(self, focusable: bool) -> Self {
309 Self {
310 builder: self.builder.property("focusable", focusable),
311 }
312 }
313
314 pub fn halign(self, halign: Align) -> Self {
315 Self {
316 builder: self.builder.property("halign", halign),
317 }
318 }
319
320 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
321 Self {
322 builder: self.builder.property("has-tooltip", has_tooltip),
323 }
324 }
325
326 pub fn height_request(self, height_request: i32) -> Self {
327 Self {
328 builder: self.builder.property("height-request", height_request),
329 }
330 }
331
332 pub fn hexpand(self, hexpand: bool) -> Self {
333 Self {
334 builder: self.builder.property("hexpand", hexpand),
335 }
336 }
337
338 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
339 Self {
340 builder: self.builder.property("hexpand-set", hexpand_set),
341 }
342 }
343
344 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
345 Self {
346 builder: self
347 .builder
348 .property("layout-manager", layout_manager.clone().upcast()),
349 }
350 }
351
352 #[cfg(feature = "v4_18")]
353 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
354 pub fn limit_events(self, limit_events: bool) -> Self {
355 Self {
356 builder: self.builder.property("limit-events", limit_events),
357 }
358 }
359
360 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
361 Self {
362 builder: self.builder.property("margin-bottom", margin_bottom),
363 }
364 }
365
366 pub fn margin_end(self, margin_end: i32) -> Self {
367 Self {
368 builder: self.builder.property("margin-end", margin_end),
369 }
370 }
371
372 pub fn margin_start(self, margin_start: i32) -> Self {
373 Self {
374 builder: self.builder.property("margin-start", margin_start),
375 }
376 }
377
378 pub fn margin_top(self, margin_top: i32) -> Self {
379 Self {
380 builder: self.builder.property("margin-top", margin_top),
381 }
382 }
383
384 pub fn name(self, name: impl Into<glib::GString>) -> Self {
385 Self {
386 builder: self.builder.property("name", name.into()),
387 }
388 }
389
390 pub fn opacity(self, opacity: f64) -> Self {
391 Self {
392 builder: self.builder.property("opacity", opacity),
393 }
394 }
395
396 pub fn overflow(self, overflow: Overflow) -> Self {
397 Self {
398 builder: self.builder.property("overflow", overflow),
399 }
400 }
401
402 pub fn receives_default(self, receives_default: bool) -> Self {
403 Self {
404 builder: self.builder.property("receives-default", receives_default),
405 }
406 }
407
408 pub fn sensitive(self, sensitive: bool) -> Self {
409 Self {
410 builder: self.builder.property("sensitive", sensitive),
411 }
412 }
413
414 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
415 Self {
416 builder: self
417 .builder
418 .property("tooltip-markup", tooltip_markup.into()),
419 }
420 }
421
422 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
423 Self {
424 builder: self.builder.property("tooltip-text", tooltip_text.into()),
425 }
426 }
427
428 pub fn valign(self, valign: Align) -> Self {
429 Self {
430 builder: self.builder.property("valign", valign),
431 }
432 }
433
434 pub fn vexpand(self, vexpand: bool) -> Self {
435 Self {
436 builder: self.builder.property("vexpand", vexpand),
437 }
438 }
439
440 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
441 Self {
442 builder: self.builder.property("vexpand-set", vexpand_set),
443 }
444 }
445
446 pub fn visible(self, visible: bool) -> Self {
447 Self {
448 builder: self.builder.property("visible", visible),
449 }
450 }
451
452 pub fn width_request(self, width_request: i32) -> Self {
453 Self {
454 builder: self.builder.property("width-request", width_request),
455 }
456 }
457
458 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
459 Self {
460 builder: self.builder.property("accessible-role", accessible_role),
461 }
462 }
463
464 pub fn orientation(self, orientation: Orientation) -> Self {
465 Self {
466 builder: self.builder.property("orientation", orientation),
467 }
468 }
469
470 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
473 pub fn build(self) -> ShortcutsSection {
474 assert_initialized_main_thread!();
475 self.builder.build()
476 }
477}