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