gtk/auto/shortcuts_shortcut.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6 Align, BaselinePosition, Box, Buildable, Container, Orientable, Orientation, ResizeMode,
7 ShortcutType, SizeGroup, TextDirection, Widget, ffi,
8};
9use glib::{
10 prelude::*,
11 signal::{SignalHandlerId, connect_raw},
12 translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17 /// A GtkShortcutsShortcut represents a single keyboard shortcut or gesture
18 /// with a short text. This widget is only meant to be used with [`ShortcutsWindow`][crate::ShortcutsWindow].
19 ///
20 /// ## Properties
21 ///
22 ///
23 /// #### `accel-size-group`
24 /// The size group for the accelerator portion of this shortcut.
25 ///
26 /// This is used internally by GTK+, and must not be modified by applications.
27 ///
28 /// Writable
29 ///
30 ///
31 /// #### `accelerator`
32 /// amp; when used
33 /// in .ui files.
34 ///
35 /// Readable | Writable
36 ///
37 ///
38 /// #### `action-name`
39 /// A detailed action name. If this is set for a shortcut
40 /// of type [`ShortcutType::Accelerator`][crate::ShortcutType::Accelerator], then GTK+ will use
41 /// the accelerators that are associated with the action
42 /// via [`GtkApplicationExt::set_accels_for_action()`][crate::prelude::GtkApplicationExt::set_accels_for_action()], and setting
43 /// [`accelerator`][struct@crate::ShortcutsShortcut#accelerator] is not necessary.
44 ///
45 /// Readable | Writable
46 ///
47 ///
48 /// #### `direction`
49 /// The text direction for which this shortcut is active. If the shortcut
50 /// is used regardless of the text direction, set this property to
51 /// [`TextDirection::None`][crate::TextDirection::None].
52 ///
53 /// Readable | Writable
54 ///
55 ///
56 /// #### `icon`
57 /// An icon to represent the shortcut or gesture. This property is used if
58 /// [`shortcut-type`][struct@crate::ShortcutsShortcut#shortcut-type] is set to [`ShortcutType::Gesture`][crate::ShortcutType::Gesture].
59 /// For the other predefined gesture types, GTK+ provides an icon on its own.
60 ///
61 /// Readable | Writable
62 ///
63 ///
64 /// #### `icon-set`
65 /// [`true`] if an icon has been set.
66 ///
67 /// Readable | Writable
68 ///
69 ///
70 /// #### `shortcut-type`
71 /// The type of shortcut that is represented.
72 ///
73 /// Readable | Writable
74 ///
75 ///
76 /// #### `subtitle`
77 /// The subtitle for the shortcut or gesture.
78 ///
79 /// This is typically used for gestures and should be a short, one-line
80 /// text that describes the gesture itself. For the predefined gesture
81 /// types, GTK+ provides a subtitle on its own.
82 ///
83 /// Readable | Writable
84 ///
85 ///
86 /// #### `subtitle-set`
87 /// [`true`] if a subtitle has been set.
88 ///
89 /// Readable | Writable
90 ///
91 ///
92 /// #### `title`
93 /// The textual description for the shortcut or gesture represented by
94 /// this object. This should be a short string that can fit in a single line.
95 ///
96 /// Readable | Writable
97 ///
98 ///
99 /// #### `title-size-group`
100 /// The size group for the textual portion of this shortcut.
101 ///
102 /// This is used internally by GTK+, and must not be modified by applications.
103 ///
104 /// Writable
105 /// <details><summary><h4>Box</h4></summary>
106 ///
107 ///
108 /// #### `baseline-position`
109 /// Readable | Writable
110 ///
111 ///
112 /// #### `homogeneous`
113 /// Readable | Writable
114 ///
115 ///
116 /// #### `spacing`
117 /// Readable | Writable
118 /// </details>
119 /// <details><summary><h4>Container</h4></summary>
120 ///
121 ///
122 /// #### `border-width`
123 /// Readable | Writable
124 ///
125 ///
126 /// #### `child`
127 /// Writable
128 ///
129 ///
130 /// #### `resize-mode`
131 /// Readable | Writable
132 /// </details>
133 /// <details><summary><h4>Widget</h4></summary>
134 ///
135 ///
136 /// #### `app-paintable`
137 /// Readable | Writable
138 ///
139 ///
140 /// #### `can-default`
141 /// Readable | Writable
142 ///
143 ///
144 /// #### `can-focus`
145 /// Readable | Writable
146 ///
147 ///
148 /// #### `composite-child`
149 /// Readable
150 ///
151 ///
152 /// #### `double-buffered`
153 /// Whether the widget is double buffered.
154 ///
155 /// Readable | Writable
156 ///
157 ///
158 /// #### `events`
159 /// Readable | Writable
160 ///
161 ///
162 /// #### `expand`
163 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
164 ///
165 /// Readable | Writable
166 ///
167 ///
168 /// #### `focus-on-click`
169 /// Whether the widget should grab focus when it is clicked with the mouse.
170 ///
171 /// This property is only relevant for widgets that can take focus.
172 ///
173 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
174 /// GtkComboBox) implemented this property individually.
175 ///
176 /// Readable | Writable
177 ///
178 ///
179 /// #### `halign`
180 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
181 ///
182 /// Readable | Writable
183 ///
184 ///
185 /// #### `has-default`
186 /// Readable | Writable
187 ///
188 ///
189 /// #### `has-focus`
190 /// Readable | Writable
191 ///
192 ///
193 /// #### `has-tooltip`
194 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
195 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
196 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
197 /// whether it will provide a tooltip or not.
198 ///
199 /// Note that setting this property to [`true`] for the first time will change
200 /// the event masks of the GdkWindows of this widget to include leave-notify
201 /// and motion-notify events. This cannot and will not be undone when the
202 /// property is set to [`false`] again.
203 ///
204 /// Readable | Writable
205 ///
206 ///
207 /// #### `height-request`
208 /// Readable | Writable
209 ///
210 ///
211 /// #### `hexpand`
212 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
213 ///
214 /// Readable | Writable
215 ///
216 ///
217 /// #### `hexpand-set`
218 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
219 ///
220 /// Readable | Writable
221 ///
222 ///
223 /// #### `is-focus`
224 /// Readable | Writable
225 ///
226 ///
227 /// #### `margin`
228 /// Sets all four sides' margin at once. If read, returns max
229 /// margin on any side.
230 ///
231 /// Readable | Writable
232 ///
233 ///
234 /// #### `margin-bottom`
235 /// Margin on bottom side of widget.
236 ///
237 /// This property adds margin outside of the widget's normal size
238 /// request, the margin will be added in addition to the size from
239 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
240 ///
241 /// Readable | Writable
242 ///
243 ///
244 /// #### `margin-end`
245 /// Margin on end of widget, horizontally. This property supports
246 /// left-to-right and right-to-left text directions.
247 ///
248 /// This property adds margin outside of the widget's normal size
249 /// request, the margin will be added in addition to the size from
250 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
251 ///
252 /// Readable | Writable
253 ///
254 ///
255 /// #### `margin-left`
256 /// Margin on left side of widget.
257 ///
258 /// This property adds margin outside of the widget's normal size
259 /// request, the margin will be added in addition to the size from
260 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
261 ///
262 /// Readable | Writable
263 ///
264 ///
265 /// #### `margin-right`
266 /// Margin on right side of widget.
267 ///
268 /// This property adds margin outside of the widget's normal size
269 /// request, the margin will be added in addition to the size from
270 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
271 ///
272 /// Readable | Writable
273 ///
274 ///
275 /// #### `margin-start`
276 /// Margin on start of widget, horizontally. This property supports
277 /// left-to-right and right-to-left text directions.
278 ///
279 /// This property adds margin outside of the widget's normal size
280 /// request, the margin will be added in addition to the size from
281 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
282 ///
283 /// Readable | Writable
284 ///
285 ///
286 /// #### `margin-top`
287 /// Margin on top side of widget.
288 ///
289 /// This property adds margin outside of the widget's normal size
290 /// request, the margin will be added in addition to the size from
291 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
292 ///
293 /// Readable | Writable
294 ///
295 ///
296 /// #### `name`
297 /// Readable | Writable
298 ///
299 ///
300 /// #### `no-show-all`
301 /// Readable | Writable
302 ///
303 ///
304 /// #### `opacity`
305 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
306 /// more details about window opacity.
307 ///
308 /// Before 3.8 this was only available in GtkWindow
309 ///
310 /// Readable | Writable
311 ///
312 ///
313 /// #### `parent`
314 /// Readable | Writable
315 ///
316 ///
317 /// #### `receives-default`
318 /// Readable | Writable
319 ///
320 ///
321 /// #### `scale-factor`
322 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
323 /// more details about widget scaling.
324 ///
325 /// Readable
326 ///
327 ///
328 /// #### `sensitive`
329 /// Readable | Writable
330 ///
331 ///
332 /// #### `style`
333 /// The style of the widget, which contains information about how it will look (colors, etc).
334 ///
335 /// Readable | Writable
336 ///
337 ///
338 /// #### `tooltip-markup`
339 /// Sets the text of tooltip to be the given string, which is marked up
340 /// with the [Pango text markup language][PangoMarkupFormat].
341 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
342 ///
343 /// This is a convenience property which will take care of getting the
344 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
345 /// will automatically be set to [`true`] and there will be taken care of
346 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
347 ///
348 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
349 /// are set, the last one wins.
350 ///
351 /// Readable | Writable
352 ///
353 ///
354 /// #### `tooltip-text`
355 /// Sets the text of tooltip to be the given string.
356 ///
357 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
358 ///
359 /// This is a convenience property which will take care of getting the
360 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
361 /// will automatically be set to [`true`] and there will be taken care of
362 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
363 ///
364 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
365 /// are set, the last one wins.
366 ///
367 /// Readable | Writable
368 ///
369 ///
370 /// #### `valign`
371 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
372 ///
373 /// Readable | Writable
374 ///
375 ///
376 /// #### `vexpand`
377 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
378 ///
379 /// Readable | Writable
380 ///
381 ///
382 /// #### `vexpand-set`
383 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
384 ///
385 /// Readable | Writable
386 ///
387 ///
388 /// #### `visible`
389 /// Readable | Writable
390 ///
391 ///
392 /// #### `width-request`
393 /// Readable | Writable
394 ///
395 ///
396 /// #### `window`
397 /// The widget's window if it is realized, [`None`] otherwise.
398 ///
399 /// Readable
400 /// </details>
401 /// <details><summary><h4>Orientable</h4></summary>
402 ///
403 ///
404 /// #### `orientation`
405 /// The orientation of the orientable.
406 ///
407 /// Readable | Writable
408 /// </details>
409 ///
410 /// # Implements
411 ///
412 /// [`BoxExt`][trait@crate::prelude::BoxExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
413 #[doc(alias = "GtkShortcutsShortcut")]
414 pub struct ShortcutsShortcut(Object<ffi::GtkShortcutsShortcut, ffi::GtkShortcutsShortcutClass>) @extends Box, Container, Widget, @implements Buildable, Orientable;
415
416 match fn {
417 type_ => || ffi::gtk_shortcuts_shortcut_get_type(),
418 }
419}
420
421impl ShortcutsShortcut {
422 // rustdoc-stripper-ignore-next
423 /// Creates a new builder-pattern struct instance to construct [`ShortcutsShortcut`] objects.
424 ///
425 /// This method returns an instance of [`ShortcutsShortcutBuilder`](crate::builders::ShortcutsShortcutBuilder) which can be used to create [`ShortcutsShortcut`] objects.
426 pub fn builder() -> ShortcutsShortcutBuilder {
427 ShortcutsShortcutBuilder::new()
428 }
429
430 /// The size group for the accelerator portion of this shortcut.
431 ///
432 /// This is used internally by GTK+, and must not be modified by applications.
433 #[doc(alias = "accel-size-group")]
434 pub fn set_accel_size_group<P: IsA<SizeGroup>>(&self, accel_size_group: Option<&P>) {
435 ObjectExt::set_property(self, "accel-size-group", accel_size_group)
436 }
437
438 /// amp; when used
439 /// in .ui files.
440 pub fn accelerator(&self) -> Option<glib::GString> {
441 ObjectExt::property(self, "accelerator")
442 }
443
444 /// amp; when used
445 /// in .ui files.
446 pub fn set_accelerator(&self, accelerator: Option<&str>) {
447 ObjectExt::set_property(self, "accelerator", accelerator)
448 }
449
450 /// A detailed action name. If this is set for a shortcut
451 /// of type [`ShortcutType::Accelerator`][crate::ShortcutType::Accelerator], then GTK+ will use
452 /// the accelerators that are associated with the action
453 /// via [`GtkApplicationExt::set_accels_for_action()`][crate::prelude::GtkApplicationExt::set_accels_for_action()], and setting
454 /// [`accelerator`][struct@crate::ShortcutsShortcut#accelerator] is not necessary.
455 #[doc(alias = "action-name")]
456 pub fn action_name(&self) -> Option<glib::GString> {
457 ObjectExt::property(self, "action-name")
458 }
459
460 /// A detailed action name. If this is set for a shortcut
461 /// of type [`ShortcutType::Accelerator`][crate::ShortcutType::Accelerator], then GTK+ will use
462 /// the accelerators that are associated with the action
463 /// via [`GtkApplicationExt::set_accels_for_action()`][crate::prelude::GtkApplicationExt::set_accels_for_action()], and setting
464 /// [`accelerator`][struct@crate::ShortcutsShortcut#accelerator] is not necessary.
465 #[doc(alias = "action-name")]
466 pub fn set_action_name(&self, action_name: Option<&str>) {
467 ObjectExt::set_property(self, "action-name", action_name)
468 }
469
470 /// An icon to represent the shortcut or gesture. This property is used if
471 /// [`shortcut-type`][struct@crate::ShortcutsShortcut#shortcut-type] is set to [`ShortcutType::Gesture`][crate::ShortcutType::Gesture].
472 /// For the other predefined gesture types, GTK+ provides an icon on its own.
473 pub fn icon(&self) -> Option<gio::Icon> {
474 ObjectExt::property(self, "icon")
475 }
476
477 /// An icon to represent the shortcut or gesture. This property is used if
478 /// [`shortcut-type`][struct@crate::ShortcutsShortcut#shortcut-type] is set to [`ShortcutType::Gesture`][crate::ShortcutType::Gesture].
479 /// For the other predefined gesture types, GTK+ provides an icon on its own.
480 pub fn set_icon<P: IsA<gio::Icon>>(&self, icon: Option<&P>) {
481 ObjectExt::set_property(self, "icon", icon)
482 }
483
484 /// [`true`] if an icon has been set.
485 #[doc(alias = "icon-set")]
486 pub fn is_icon_set(&self) -> bool {
487 ObjectExt::property(self, "icon-set")
488 }
489
490 /// [`true`] if an icon has been set.
491 #[doc(alias = "icon-set")]
492 pub fn set_icon_set(&self, icon_set: bool) {
493 ObjectExt::set_property(self, "icon-set", icon_set)
494 }
495
496 /// The type of shortcut that is represented.
497 #[doc(alias = "shortcut-type")]
498 pub fn shortcut_type(&self) -> ShortcutType {
499 ObjectExt::property(self, "shortcut-type")
500 }
501
502 /// The type of shortcut that is represented.
503 #[doc(alias = "shortcut-type")]
504 pub fn set_shortcut_type(&self, shortcut_type: ShortcutType) {
505 ObjectExt::set_property(self, "shortcut-type", shortcut_type)
506 }
507
508 /// The subtitle for the shortcut or gesture.
509 ///
510 /// This is typically used for gestures and should be a short, one-line
511 /// text that describes the gesture itself. For the predefined gesture
512 /// types, GTK+ provides a subtitle on its own.
513 pub fn subtitle(&self) -> Option<glib::GString> {
514 ObjectExt::property(self, "subtitle")
515 }
516
517 /// The subtitle for the shortcut or gesture.
518 ///
519 /// This is typically used for gestures and should be a short, one-line
520 /// text that describes the gesture itself. For the predefined gesture
521 /// types, GTK+ provides a subtitle on its own.
522 pub fn set_subtitle(&self, subtitle: Option<&str>) {
523 ObjectExt::set_property(self, "subtitle", subtitle)
524 }
525
526 /// [`true`] if a subtitle has been set.
527 #[doc(alias = "subtitle-set")]
528 pub fn is_subtitle_set(&self) -> bool {
529 ObjectExt::property(self, "subtitle-set")
530 }
531
532 /// [`true`] if a subtitle has been set.
533 #[doc(alias = "subtitle-set")]
534 pub fn set_subtitle_set(&self, subtitle_set: bool) {
535 ObjectExt::set_property(self, "subtitle-set", subtitle_set)
536 }
537
538 /// The textual description for the shortcut or gesture represented by
539 /// this object. This should be a short string that can fit in a single line.
540 pub fn title(&self) -> Option<glib::GString> {
541 ObjectExt::property(self, "title")
542 }
543
544 /// The textual description for the shortcut or gesture represented by
545 /// this object. This should be a short string that can fit in a single line.
546 pub fn set_title(&self, title: Option<&str>) {
547 ObjectExt::set_property(self, "title", title)
548 }
549
550 /// The size group for the textual portion of this shortcut.
551 ///
552 /// This is used internally by GTK+, and must not be modified by applications.
553 #[doc(alias = "title-size-group")]
554 pub fn set_title_size_group<P: IsA<SizeGroup>>(&self, title_size_group: Option<&P>) {
555 ObjectExt::set_property(self, "title-size-group", title_size_group)
556 }
557
558 #[doc(alias = "accel-size-group")]
559 pub fn connect_accel_size_group_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
560 unsafe extern "C" fn notify_accel_size_group_trampoline<
561 F: Fn(&ShortcutsShortcut) + 'static,
562 >(
563 this: *mut ffi::GtkShortcutsShortcut,
564 _param_spec: glib::ffi::gpointer,
565 f: glib::ffi::gpointer,
566 ) {
567 unsafe {
568 let f: &F = &*(f as *const F);
569 f(&from_glib_borrow(this))
570 }
571 }
572 unsafe {
573 let f: Box_<F> = Box_::new(f);
574 connect_raw(
575 self.as_ptr() as *mut _,
576 c"notify::accel-size-group".as_ptr(),
577 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
578 notify_accel_size_group_trampoline::<F> as *const (),
579 )),
580 Box_::into_raw(f),
581 )
582 }
583 }
584
585 #[doc(alias = "accelerator")]
586 pub fn connect_accelerator_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
587 unsafe extern "C" fn notify_accelerator_trampoline<F: Fn(&ShortcutsShortcut) + 'static>(
588 this: *mut ffi::GtkShortcutsShortcut,
589 _param_spec: glib::ffi::gpointer,
590 f: glib::ffi::gpointer,
591 ) {
592 unsafe {
593 let f: &F = &*(f as *const F);
594 f(&from_glib_borrow(this))
595 }
596 }
597 unsafe {
598 let f: Box_<F> = Box_::new(f);
599 connect_raw(
600 self.as_ptr() as *mut _,
601 c"notify::accelerator".as_ptr(),
602 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
603 notify_accelerator_trampoline::<F> as *const (),
604 )),
605 Box_::into_raw(f),
606 )
607 }
608 }
609
610 #[doc(alias = "action-name")]
611 pub fn connect_action_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
612 unsafe extern "C" fn notify_action_name_trampoline<F: Fn(&ShortcutsShortcut) + 'static>(
613 this: *mut ffi::GtkShortcutsShortcut,
614 _param_spec: glib::ffi::gpointer,
615 f: glib::ffi::gpointer,
616 ) {
617 unsafe {
618 let f: &F = &*(f as *const F);
619 f(&from_glib_borrow(this))
620 }
621 }
622 unsafe {
623 let f: Box_<F> = Box_::new(f);
624 connect_raw(
625 self.as_ptr() as *mut _,
626 c"notify::action-name".as_ptr(),
627 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
628 notify_action_name_trampoline::<F> as *const (),
629 )),
630 Box_::into_raw(f),
631 )
632 }
633 }
634
635 #[doc(alias = "direction")]
636 pub fn connect_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
637 unsafe extern "C" fn notify_direction_trampoline<F: Fn(&ShortcutsShortcut) + 'static>(
638 this: *mut ffi::GtkShortcutsShortcut,
639 _param_spec: glib::ffi::gpointer,
640 f: glib::ffi::gpointer,
641 ) {
642 unsafe {
643 let f: &F = &*(f as *const F);
644 f(&from_glib_borrow(this))
645 }
646 }
647 unsafe {
648 let f: Box_<F> = Box_::new(f);
649 connect_raw(
650 self.as_ptr() as *mut _,
651 c"notify::direction".as_ptr(),
652 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
653 notify_direction_trampoline::<F> as *const (),
654 )),
655 Box_::into_raw(f),
656 )
657 }
658 }
659
660 #[doc(alias = "icon")]
661 pub fn connect_icon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
662 unsafe extern "C" fn notify_icon_trampoline<F: Fn(&ShortcutsShortcut) + 'static>(
663 this: *mut ffi::GtkShortcutsShortcut,
664 _param_spec: glib::ffi::gpointer,
665 f: glib::ffi::gpointer,
666 ) {
667 unsafe {
668 let f: &F = &*(f as *const F);
669 f(&from_glib_borrow(this))
670 }
671 }
672 unsafe {
673 let f: Box_<F> = Box_::new(f);
674 connect_raw(
675 self.as_ptr() as *mut _,
676 c"notify::icon".as_ptr(),
677 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
678 notify_icon_trampoline::<F> as *const (),
679 )),
680 Box_::into_raw(f),
681 )
682 }
683 }
684
685 #[doc(alias = "icon-set")]
686 pub fn connect_icon_set_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
687 unsafe extern "C" fn notify_icon_set_trampoline<F: Fn(&ShortcutsShortcut) + 'static>(
688 this: *mut ffi::GtkShortcutsShortcut,
689 _param_spec: glib::ffi::gpointer,
690 f: glib::ffi::gpointer,
691 ) {
692 unsafe {
693 let f: &F = &*(f as *const F);
694 f(&from_glib_borrow(this))
695 }
696 }
697 unsafe {
698 let f: Box_<F> = Box_::new(f);
699 connect_raw(
700 self.as_ptr() as *mut _,
701 c"notify::icon-set".as_ptr(),
702 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
703 notify_icon_set_trampoline::<F> as *const (),
704 )),
705 Box_::into_raw(f),
706 )
707 }
708 }
709
710 #[doc(alias = "shortcut-type")]
711 pub fn connect_shortcut_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
712 unsafe extern "C" fn notify_shortcut_type_trampoline<
713 F: Fn(&ShortcutsShortcut) + 'static,
714 >(
715 this: *mut ffi::GtkShortcutsShortcut,
716 _param_spec: glib::ffi::gpointer,
717 f: glib::ffi::gpointer,
718 ) {
719 unsafe {
720 let f: &F = &*(f as *const F);
721 f(&from_glib_borrow(this))
722 }
723 }
724 unsafe {
725 let f: Box_<F> = Box_::new(f);
726 connect_raw(
727 self.as_ptr() as *mut _,
728 c"notify::shortcut-type".as_ptr(),
729 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
730 notify_shortcut_type_trampoline::<F> as *const (),
731 )),
732 Box_::into_raw(f),
733 )
734 }
735 }
736
737 #[doc(alias = "subtitle")]
738 pub fn connect_subtitle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
739 unsafe extern "C" fn notify_subtitle_trampoline<F: Fn(&ShortcutsShortcut) + 'static>(
740 this: *mut ffi::GtkShortcutsShortcut,
741 _param_spec: glib::ffi::gpointer,
742 f: glib::ffi::gpointer,
743 ) {
744 unsafe {
745 let f: &F = &*(f as *const F);
746 f(&from_glib_borrow(this))
747 }
748 }
749 unsafe {
750 let f: Box_<F> = Box_::new(f);
751 connect_raw(
752 self.as_ptr() as *mut _,
753 c"notify::subtitle".as_ptr(),
754 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
755 notify_subtitle_trampoline::<F> as *const (),
756 )),
757 Box_::into_raw(f),
758 )
759 }
760 }
761
762 #[doc(alias = "subtitle-set")]
763 pub fn connect_subtitle_set_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
764 unsafe extern "C" fn notify_subtitle_set_trampoline<F: Fn(&ShortcutsShortcut) + 'static>(
765 this: *mut ffi::GtkShortcutsShortcut,
766 _param_spec: glib::ffi::gpointer,
767 f: glib::ffi::gpointer,
768 ) {
769 unsafe {
770 let f: &F = &*(f as *const F);
771 f(&from_glib_borrow(this))
772 }
773 }
774 unsafe {
775 let f: Box_<F> = Box_::new(f);
776 connect_raw(
777 self.as_ptr() as *mut _,
778 c"notify::subtitle-set".as_ptr(),
779 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
780 notify_subtitle_set_trampoline::<F> as *const (),
781 )),
782 Box_::into_raw(f),
783 )
784 }
785 }
786
787 #[doc(alias = "title")]
788 pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
789 unsafe extern "C" fn notify_title_trampoline<F: Fn(&ShortcutsShortcut) + 'static>(
790 this: *mut ffi::GtkShortcutsShortcut,
791 _param_spec: glib::ffi::gpointer,
792 f: glib::ffi::gpointer,
793 ) {
794 unsafe {
795 let f: &F = &*(f as *const F);
796 f(&from_glib_borrow(this))
797 }
798 }
799 unsafe {
800 let f: Box_<F> = Box_::new(f);
801 connect_raw(
802 self.as_ptr() as *mut _,
803 c"notify::title".as_ptr(),
804 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
805 notify_title_trampoline::<F> as *const (),
806 )),
807 Box_::into_raw(f),
808 )
809 }
810 }
811
812 #[doc(alias = "title-size-group")]
813 pub fn connect_title_size_group_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
814 unsafe extern "C" fn notify_title_size_group_trampoline<
815 F: Fn(&ShortcutsShortcut) + 'static,
816 >(
817 this: *mut ffi::GtkShortcutsShortcut,
818 _param_spec: glib::ffi::gpointer,
819 f: glib::ffi::gpointer,
820 ) {
821 unsafe {
822 let f: &F = &*(f as *const F);
823 f(&from_glib_borrow(this))
824 }
825 }
826 unsafe {
827 let f: Box_<F> = Box_::new(f);
828 connect_raw(
829 self.as_ptr() as *mut _,
830 c"notify::title-size-group".as_ptr(),
831 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
832 notify_title_size_group_trampoline::<F> as *const (),
833 )),
834 Box_::into_raw(f),
835 )
836 }
837 }
838}
839
840// rustdoc-stripper-ignore-next
841/// A [builder-pattern] type to construct [`ShortcutsShortcut`] objects.
842///
843/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
844#[must_use = "The builder must be built to be used"]
845pub struct ShortcutsShortcutBuilder {
846 builder: glib::object::ObjectBuilder<'static, ShortcutsShortcut>,
847}
848
849impl ShortcutsShortcutBuilder {
850 fn new() -> Self {
851 Self {
852 builder: glib::object::Object::builder(),
853 }
854 }
855
856 /// The size group for the accelerator portion of this shortcut.
857 ///
858 /// This is used internally by GTK+, and must not be modified by applications.
859 pub fn accel_size_group(self, accel_size_group: &impl IsA<SizeGroup>) -> Self {
860 Self {
861 builder: self
862 .builder
863 .property("accel-size-group", accel_size_group.clone().upcast()),
864 }
865 }
866
867 /// amp; when used
868 /// in .ui files.
869 pub fn accelerator(self, accelerator: impl Into<glib::GString>) -> Self {
870 Self {
871 builder: self.builder.property("accelerator", accelerator.into()),
872 }
873 }
874
875 /// A detailed action name. If this is set for a shortcut
876 /// of type [`ShortcutType::Accelerator`][crate::ShortcutType::Accelerator], then GTK+ will use
877 /// the accelerators that are associated with the action
878 /// via [`GtkApplicationExt::set_accels_for_action()`][crate::prelude::GtkApplicationExt::set_accels_for_action()], and setting
879 /// [`accelerator`][struct@crate::ShortcutsShortcut#accelerator] is not necessary.
880 pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
881 Self {
882 builder: self.builder.property("action-name", action_name.into()),
883 }
884 }
885
886 /// The text direction for which this shortcut is active. If the shortcut
887 /// is used regardless of the text direction, set this property to
888 /// [`TextDirection::None`][crate::TextDirection::None].
889 pub fn direction(self, direction: TextDirection) -> Self {
890 Self {
891 builder: self.builder.property("direction", direction),
892 }
893 }
894
895 /// An icon to represent the shortcut or gesture. This property is used if
896 /// [`shortcut-type`][struct@crate::ShortcutsShortcut#shortcut-type] is set to [`ShortcutType::Gesture`][crate::ShortcutType::Gesture].
897 /// For the other predefined gesture types, GTK+ provides an icon on its own.
898 pub fn icon(self, icon: &impl IsA<gio::Icon>) -> Self {
899 Self {
900 builder: self.builder.property("icon", icon.clone().upcast()),
901 }
902 }
903
904 /// [`true`] if an icon has been set.
905 pub fn icon_set(self, icon_set: bool) -> Self {
906 Self {
907 builder: self.builder.property("icon-set", icon_set),
908 }
909 }
910
911 /// The type of shortcut that is represented.
912 pub fn shortcut_type(self, shortcut_type: ShortcutType) -> Self {
913 Self {
914 builder: self.builder.property("shortcut-type", shortcut_type),
915 }
916 }
917
918 /// The subtitle for the shortcut or gesture.
919 ///
920 /// This is typically used for gestures and should be a short, one-line
921 /// text that describes the gesture itself. For the predefined gesture
922 /// types, GTK+ provides a subtitle on its own.
923 pub fn subtitle(self, subtitle: impl Into<glib::GString>) -> Self {
924 Self {
925 builder: self.builder.property("subtitle", subtitle.into()),
926 }
927 }
928
929 /// [`true`] if a subtitle has been set.
930 pub fn subtitle_set(self, subtitle_set: bool) -> Self {
931 Self {
932 builder: self.builder.property("subtitle-set", subtitle_set),
933 }
934 }
935
936 /// The textual description for the shortcut or gesture represented by
937 /// this object. This should be a short string that can fit in a single line.
938 pub fn title(self, title: impl Into<glib::GString>) -> Self {
939 Self {
940 builder: self.builder.property("title", title.into()),
941 }
942 }
943
944 /// The size group for the textual portion of this shortcut.
945 ///
946 /// This is used internally by GTK+, and must not be modified by applications.
947 pub fn title_size_group(self, title_size_group: &impl IsA<SizeGroup>) -> Self {
948 Self {
949 builder: self
950 .builder
951 .property("title-size-group", title_size_group.clone().upcast()),
952 }
953 }
954
955 pub fn baseline_position(self, baseline_position: BaselinePosition) -> Self {
956 Self {
957 builder: self
958 .builder
959 .property("baseline-position", baseline_position),
960 }
961 }
962
963 pub fn homogeneous(self, homogeneous: bool) -> Self {
964 Self {
965 builder: self.builder.property("homogeneous", homogeneous),
966 }
967 }
968
969 pub fn spacing(self, spacing: i32) -> Self {
970 Self {
971 builder: self.builder.property("spacing", spacing),
972 }
973 }
974
975 pub fn border_width(self, border_width: u32) -> Self {
976 Self {
977 builder: self.builder.property("border-width", border_width),
978 }
979 }
980
981 pub fn child(self, child: &impl IsA<Widget>) -> Self {
982 Self {
983 builder: self.builder.property("child", child.clone().upcast()),
984 }
985 }
986
987 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
988 Self {
989 builder: self.builder.property("resize-mode", resize_mode),
990 }
991 }
992
993 pub fn app_paintable(self, app_paintable: bool) -> Self {
994 Self {
995 builder: self.builder.property("app-paintable", app_paintable),
996 }
997 }
998
999 pub fn can_default(self, can_default: bool) -> Self {
1000 Self {
1001 builder: self.builder.property("can-default", can_default),
1002 }
1003 }
1004
1005 pub fn can_focus(self, can_focus: bool) -> Self {
1006 Self {
1007 builder: self.builder.property("can-focus", can_focus),
1008 }
1009 }
1010
1011 pub fn events(self, events: gdk::EventMask) -> Self {
1012 Self {
1013 builder: self.builder.property("events", events),
1014 }
1015 }
1016
1017 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
1018 pub fn expand(self, expand: bool) -> Self {
1019 Self {
1020 builder: self.builder.property("expand", expand),
1021 }
1022 }
1023
1024 /// Whether the widget should grab focus when it is clicked with the mouse.
1025 ///
1026 /// This property is only relevant for widgets that can take focus.
1027 ///
1028 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
1029 /// GtkComboBox) implemented this property individually.
1030 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1031 Self {
1032 builder: self.builder.property("focus-on-click", focus_on_click),
1033 }
1034 }
1035
1036 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
1037 pub fn halign(self, halign: Align) -> Self {
1038 Self {
1039 builder: self.builder.property("halign", halign),
1040 }
1041 }
1042
1043 pub fn has_default(self, has_default: bool) -> Self {
1044 Self {
1045 builder: self.builder.property("has-default", has_default),
1046 }
1047 }
1048
1049 pub fn has_focus(self, has_focus: bool) -> Self {
1050 Self {
1051 builder: self.builder.property("has-focus", has_focus),
1052 }
1053 }
1054
1055 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
1056 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
1057 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
1058 /// whether it will provide a tooltip or not.
1059 ///
1060 /// Note that setting this property to [`true`] for the first time will change
1061 /// the event masks of the GdkWindows of this widget to include leave-notify
1062 /// and motion-notify events. This cannot and will not be undone when the
1063 /// property is set to [`false`] again.
1064 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1065 Self {
1066 builder: self.builder.property("has-tooltip", has_tooltip),
1067 }
1068 }
1069
1070 pub fn height_request(self, height_request: i32) -> Self {
1071 Self {
1072 builder: self.builder.property("height-request", height_request),
1073 }
1074 }
1075
1076 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
1077 pub fn hexpand(self, hexpand: bool) -> Self {
1078 Self {
1079 builder: self.builder.property("hexpand", hexpand),
1080 }
1081 }
1082
1083 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
1084 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1085 Self {
1086 builder: self.builder.property("hexpand-set", hexpand_set),
1087 }
1088 }
1089
1090 pub fn is_focus(self, is_focus: bool) -> Self {
1091 Self {
1092 builder: self.builder.property("is-focus", is_focus),
1093 }
1094 }
1095
1096 /// Sets all four sides' margin at once. If read, returns max
1097 /// margin on any side.
1098 pub fn margin(self, margin: i32) -> Self {
1099 Self {
1100 builder: self.builder.property("margin", margin),
1101 }
1102 }
1103
1104 /// Margin on bottom side of widget.
1105 ///
1106 /// This property adds margin outside of the widget's normal size
1107 /// request, the margin will be added in addition to the size from
1108 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1109 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1110 Self {
1111 builder: self.builder.property("margin-bottom", margin_bottom),
1112 }
1113 }
1114
1115 /// Margin on end of widget, horizontally. This property supports
1116 /// left-to-right and right-to-left text directions.
1117 ///
1118 /// This property adds margin outside of the widget's normal size
1119 /// request, the margin will be added in addition to the size from
1120 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1121 pub fn margin_end(self, margin_end: i32) -> Self {
1122 Self {
1123 builder: self.builder.property("margin-end", margin_end),
1124 }
1125 }
1126
1127 /// Margin on start of widget, horizontally. This property supports
1128 /// left-to-right and right-to-left text directions.
1129 ///
1130 /// This property adds margin outside of the widget's normal size
1131 /// request, the margin will be added in addition to the size from
1132 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1133 pub fn margin_start(self, margin_start: i32) -> Self {
1134 Self {
1135 builder: self.builder.property("margin-start", margin_start),
1136 }
1137 }
1138
1139 /// Margin on top side of widget.
1140 ///
1141 /// This property adds margin outside of the widget's normal size
1142 /// request, the margin will be added in addition to the size from
1143 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1144 pub fn margin_top(self, margin_top: i32) -> Self {
1145 Self {
1146 builder: self.builder.property("margin-top", margin_top),
1147 }
1148 }
1149
1150 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1151 Self {
1152 builder: self.builder.property("name", name.into()),
1153 }
1154 }
1155
1156 pub fn no_show_all(self, no_show_all: bool) -> Self {
1157 Self {
1158 builder: self.builder.property("no-show-all", no_show_all),
1159 }
1160 }
1161
1162 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
1163 /// more details about window opacity.
1164 ///
1165 /// Before 3.8 this was only available in GtkWindow
1166 pub fn opacity(self, opacity: f64) -> Self {
1167 Self {
1168 builder: self.builder.property("opacity", opacity),
1169 }
1170 }
1171
1172 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
1173 Self {
1174 builder: self.builder.property("parent", parent.clone().upcast()),
1175 }
1176 }
1177
1178 pub fn receives_default(self, receives_default: bool) -> Self {
1179 Self {
1180 builder: self.builder.property("receives-default", receives_default),
1181 }
1182 }
1183
1184 pub fn sensitive(self, sensitive: bool) -> Self {
1185 Self {
1186 builder: self.builder.property("sensitive", sensitive),
1187 }
1188 }
1189
1190 /// Sets the text of tooltip to be the given string, which is marked up
1191 /// with the [Pango text markup language][PangoMarkupFormat].
1192 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1193 ///
1194 /// This is a convenience property which will take care of getting the
1195 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1196 /// will automatically be set to [`true`] and there will be taken care of
1197 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1198 ///
1199 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1200 /// are set, the last one wins.
1201 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1202 Self {
1203 builder: self
1204 .builder
1205 .property("tooltip-markup", tooltip_markup.into()),
1206 }
1207 }
1208
1209 /// Sets the text of tooltip to be the given string.
1210 ///
1211 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1212 ///
1213 /// This is a convenience property which will take care of getting the
1214 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1215 /// will automatically be set to [`true`] and there will be taken care of
1216 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1217 ///
1218 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1219 /// are set, the last one wins.
1220 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1221 Self {
1222 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1223 }
1224 }
1225
1226 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
1227 pub fn valign(self, valign: Align) -> Self {
1228 Self {
1229 builder: self.builder.property("valign", valign),
1230 }
1231 }
1232
1233 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
1234 pub fn vexpand(self, vexpand: bool) -> Self {
1235 Self {
1236 builder: self.builder.property("vexpand", vexpand),
1237 }
1238 }
1239
1240 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
1241 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1242 Self {
1243 builder: self.builder.property("vexpand-set", vexpand_set),
1244 }
1245 }
1246
1247 pub fn visible(self, visible: bool) -> Self {
1248 Self {
1249 builder: self.builder.property("visible", visible),
1250 }
1251 }
1252
1253 pub fn width_request(self, width_request: i32) -> Self {
1254 Self {
1255 builder: self.builder.property("width-request", width_request),
1256 }
1257 }
1258
1259 /// The orientation of the orientable.
1260 pub fn orientation(self, orientation: Orientation) -> Self {
1261 Self {
1262 builder: self.builder.property("orientation", orientation),
1263 }
1264 }
1265
1266 // rustdoc-stripper-ignore-next
1267 /// Build the [`ShortcutsShortcut`].
1268 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1269 pub fn build(self) -> ShortcutsShortcut {
1270 assert_initialized_main_thread!();
1271 self.builder.build()
1272 }
1273}