1#![allow(deprecated)]
5
6#[cfg(feature = "v4_14")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
8use crate::ShortcutsShortcut;
9use crate::{
10 ffi, Accessible, AccessibleRole, Align, BaselinePosition, Box, Buildable, ConstraintTarget,
11 LayoutManager, Orientable, Orientation, Overflow, SizeGroup, Widget,
12};
13use glib::{
14 prelude::*,
15 signal::{connect_raw, SignalHandlerId},
16 translate::*,
17};
18use std::boxed::Box as Box_;
19
20glib::wrapper! {
21 #[doc(alias = "GtkShortcutsGroup")]
22 pub struct ShortcutsGroup(Object<ffi::GtkShortcutsGroup, ffi::GtkShortcutsGroupClass>) @extends Box, Widget, @implements Accessible, Buildable, ConstraintTarget, Orientable;
23
24 match fn {
25 type_ => || ffi::gtk_shortcuts_group_get_type(),
26 }
27}
28
29impl ShortcutsGroup {
30 pub fn builder() -> ShortcutsGroupBuilder {
35 ShortcutsGroupBuilder::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_group_add_shortcut")]
43 pub fn add_shortcut(&self, shortcut: &ShortcutsShortcut) {
44 unsafe {
45 ffi::gtk_shortcuts_group_add_shortcut(self.to_glib_none().0, shortcut.to_glib_none().0);
46 }
47 }
48
49 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
50 #[doc(alias = "accel-size-group")]
51 pub fn set_accel_size_group(&self, accel_size_group: Option<&SizeGroup>) {
52 ObjectExt::set_property(self, "accel-size-group", accel_size_group)
53 }
54
55 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
56 pub fn height(&self) -> u32 {
57 ObjectExt::property(self, "height")
58 }
59
60 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
61 pub fn title(&self) -> Option<glib::GString> {
62 ObjectExt::property(self, "title")
63 }
64
65 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
66 pub fn set_title(&self, title: Option<&str>) {
67 ObjectExt::set_property(self, "title", title)
68 }
69
70 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
71 #[doc(alias = "title-size-group")]
72 pub fn set_title_size_group(&self, title_size_group: Option<&SizeGroup>) {
73 ObjectExt::set_property(self, "title-size-group", title_size_group)
74 }
75
76 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
77 pub fn view(&self) -> Option<glib::GString> {
78 ObjectExt::property(self, "view")
79 }
80
81 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
82 pub fn set_view(&self, view: Option<&str>) {
83 ObjectExt::set_property(self, "view", view)
84 }
85
86 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
87 #[doc(alias = "accel-size-group")]
88 pub fn connect_accel_size_group_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
89 unsafe extern "C" fn notify_accel_size_group_trampoline<
90 F: Fn(&ShortcutsGroup) + 'static,
91 >(
92 this: *mut ffi::GtkShortcutsGroup,
93 _param_spec: glib::ffi::gpointer,
94 f: glib::ffi::gpointer,
95 ) {
96 let f: &F = &*(f as *const F);
97 f(&from_glib_borrow(this))
98 }
99 unsafe {
100 let f: Box_<F> = Box_::new(f);
101 connect_raw(
102 self.as_ptr() as *mut _,
103 c"notify::accel-size-group".as_ptr() as *const _,
104 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
105 notify_accel_size_group_trampoline::<F> as *const (),
106 )),
107 Box_::into_raw(f),
108 )
109 }
110 }
111
112 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
113 #[doc(alias = "height")]
114 pub fn connect_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
115 unsafe extern "C" fn notify_height_trampoline<F: Fn(&ShortcutsGroup) + 'static>(
116 this: *mut ffi::GtkShortcutsGroup,
117 _param_spec: glib::ffi::gpointer,
118 f: glib::ffi::gpointer,
119 ) {
120 let f: &F = &*(f as *const F);
121 f(&from_glib_borrow(this))
122 }
123 unsafe {
124 let f: Box_<F> = Box_::new(f);
125 connect_raw(
126 self.as_ptr() as *mut _,
127 c"notify::height".as_ptr() as *const _,
128 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
129 notify_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 = "title")]
138 pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
139 unsafe extern "C" fn notify_title_trampoline<F: Fn(&ShortcutsGroup) + 'static>(
140 this: *mut ffi::GtkShortcutsGroup,
141 _param_spec: glib::ffi::gpointer,
142 f: glib::ffi::gpointer,
143 ) {
144 let f: &F = &*(f as *const F);
145 f(&from_glib_borrow(this))
146 }
147 unsafe {
148 let f: Box_<F> = Box_::new(f);
149 connect_raw(
150 self.as_ptr() as *mut _,
151 c"notify::title".as_ptr() as *const _,
152 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
153 notify_title_trampoline::<F> as *const (),
154 )),
155 Box_::into_raw(f),
156 )
157 }
158 }
159
160 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
161 #[doc(alias = "title-size-group")]
162 pub fn connect_title_size_group_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
163 unsafe extern "C" fn notify_title_size_group_trampoline<
164 F: Fn(&ShortcutsGroup) + 'static,
165 >(
166 this: *mut ffi::GtkShortcutsGroup,
167 _param_spec: glib::ffi::gpointer,
168 f: glib::ffi::gpointer,
169 ) {
170 let f: &F = &*(f as *const F);
171 f(&from_glib_borrow(this))
172 }
173 unsafe {
174 let f: Box_<F> = Box_::new(f);
175 connect_raw(
176 self.as_ptr() as *mut _,
177 c"notify::title-size-group".as_ptr() as *const _,
178 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
179 notify_title_size_group_trampoline::<F> as *const (),
180 )),
181 Box_::into_raw(f),
182 )
183 }
184 }
185
186 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
187 #[doc(alias = "view")]
188 pub fn connect_view_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
189 unsafe extern "C" fn notify_view_trampoline<F: Fn(&ShortcutsGroup) + 'static>(
190 this: *mut ffi::GtkShortcutsGroup,
191 _param_spec: glib::ffi::gpointer,
192 f: glib::ffi::gpointer,
193 ) {
194 let f: &F = &*(f as *const F);
195 f(&from_glib_borrow(this))
196 }
197 unsafe {
198 let f: Box_<F> = Box_::new(f);
199 connect_raw(
200 self.as_ptr() as *mut _,
201 c"notify::view".as_ptr() as *const _,
202 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
203 notify_view_trampoline::<F> as *const (),
204 )),
205 Box_::into_raw(f),
206 )
207 }
208 }
209}
210
211#[must_use = "The builder must be built to be used"]
216pub struct ShortcutsGroupBuilder {
217 builder: glib::object::ObjectBuilder<'static, ShortcutsGroup>,
218}
219
220impl ShortcutsGroupBuilder {
221 fn new() -> Self {
222 Self {
223 builder: glib::object::Object::builder(),
224 }
225 }
226
227 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
228 pub fn accel_size_group(self, accel_size_group: &SizeGroup) -> Self {
229 Self {
230 builder: self
231 .builder
232 .property("accel-size-group", accel_size_group.clone()),
233 }
234 }
235
236 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
237 pub fn title(self, title: impl Into<glib::GString>) -> Self {
238 Self {
239 builder: self.builder.property("title", title.into()),
240 }
241 }
242
243 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
244 pub fn title_size_group(self, title_size_group: &SizeGroup) -> Self {
245 Self {
246 builder: self
247 .builder
248 .property("title-size-group", title_size_group.clone()),
249 }
250 }
251
252 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
253 pub fn view(self, view: impl Into<glib::GString>) -> Self {
254 Self {
255 builder: self.builder.property("view", view.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) -> ShortcutsGroup {
489 assert_initialized_main_thread!();
490 self.builder.build()
491 }
492}