gtk/auto/shortcut_label.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::{Box, Buildable, Container, Orientable, Widget, ffi};
6use glib::{
7 prelude::*,
8 signal::{SignalHandlerId, connect_raw},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 /// [`ShortcutLabel`][crate::ShortcutLabel] is a widget that represents a single keyboard shortcut or gesture
15 /// in the user interface.
16 ///
17 /// ## Properties
18 ///
19 ///
20 /// #### `accelerator`
21 /// The accelerator that `self_` displays. See [`accelerator`][struct@crate::ShortcutsShortcut#accelerator]
22 /// for the accepted syntax.
23 ///
24 /// Readable | Writable
25 ///
26 ///
27 /// #### `disabled-text`
28 /// The text that is displayed when no accelerator is set.
29 ///
30 /// Readable | Writable
31 /// <details><summary><h4>Box</h4></summary>
32 ///
33 ///
34 /// #### `baseline-position`
35 /// Readable | Writable
36 ///
37 ///
38 /// #### `homogeneous`
39 /// Readable | Writable
40 ///
41 ///
42 /// #### `spacing`
43 /// Readable | Writable
44 /// </details>
45 /// <details><summary><h4>Container</h4></summary>
46 ///
47 ///
48 /// #### `border-width`
49 /// Readable | Writable
50 ///
51 ///
52 /// #### `child`
53 /// Writable
54 ///
55 ///
56 /// #### `resize-mode`
57 /// Readable | Writable
58 /// </details>
59 /// <details><summary><h4>Widget</h4></summary>
60 ///
61 ///
62 /// #### `app-paintable`
63 /// Readable | Writable
64 ///
65 ///
66 /// #### `can-default`
67 /// Readable | Writable
68 ///
69 ///
70 /// #### `can-focus`
71 /// Readable | Writable
72 ///
73 ///
74 /// #### `composite-child`
75 /// Readable
76 ///
77 ///
78 /// #### `double-buffered`
79 /// Whether the widget is double buffered.
80 ///
81 /// Readable | Writable
82 ///
83 ///
84 /// #### `events`
85 /// Readable | Writable
86 ///
87 ///
88 /// #### `expand`
89 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
90 ///
91 /// Readable | Writable
92 ///
93 ///
94 /// #### `focus-on-click`
95 /// Whether the widget should grab focus when it is clicked with the mouse.
96 ///
97 /// This property is only relevant for widgets that can take focus.
98 ///
99 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
100 /// GtkComboBox) implemented this property individually.
101 ///
102 /// Readable | Writable
103 ///
104 ///
105 /// #### `halign`
106 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
107 ///
108 /// Readable | Writable
109 ///
110 ///
111 /// #### `has-default`
112 /// Readable | Writable
113 ///
114 ///
115 /// #### `has-focus`
116 /// Readable | Writable
117 ///
118 ///
119 /// #### `has-tooltip`
120 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
121 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
122 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
123 /// whether it will provide a tooltip or not.
124 ///
125 /// Note that setting this property to [`true`] for the first time will change
126 /// the event masks of the GdkWindows of this widget to include leave-notify
127 /// and motion-notify events. This cannot and will not be undone when the
128 /// property is set to [`false`] again.
129 ///
130 /// Readable | Writable
131 ///
132 ///
133 /// #### `height-request`
134 /// Readable | Writable
135 ///
136 ///
137 /// #### `hexpand`
138 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
139 ///
140 /// Readable | Writable
141 ///
142 ///
143 /// #### `hexpand-set`
144 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
145 ///
146 /// Readable | Writable
147 ///
148 ///
149 /// #### `is-focus`
150 /// Readable | Writable
151 ///
152 ///
153 /// #### `margin`
154 /// Sets all four sides' margin at once. If read, returns max
155 /// margin on any side.
156 ///
157 /// Readable | Writable
158 ///
159 ///
160 /// #### `margin-bottom`
161 /// Margin on bottom side of widget.
162 ///
163 /// This property adds margin outside of the widget's normal size
164 /// request, the margin will be added in addition to the size from
165 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
166 ///
167 /// Readable | Writable
168 ///
169 ///
170 /// #### `margin-end`
171 /// Margin on end of widget, horizontally. This property supports
172 /// left-to-right and right-to-left text directions.
173 ///
174 /// This property adds margin outside of the widget's normal size
175 /// request, the margin will be added in addition to the size from
176 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
177 ///
178 /// Readable | Writable
179 ///
180 ///
181 /// #### `margin-left`
182 /// Margin on left side of widget.
183 ///
184 /// This property adds margin outside of the widget's normal size
185 /// request, the margin will be added in addition to the size from
186 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
187 ///
188 /// Readable | Writable
189 ///
190 ///
191 /// #### `margin-right`
192 /// Margin on right side of widget.
193 ///
194 /// This property adds margin outside of the widget's normal size
195 /// request, the margin will be added in addition to the size from
196 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
197 ///
198 /// Readable | Writable
199 ///
200 ///
201 /// #### `margin-start`
202 /// Margin on start of widget, horizontally. This property supports
203 /// left-to-right and right-to-left text directions.
204 ///
205 /// This property adds margin outside of the widget's normal size
206 /// request, the margin will be added in addition to the size from
207 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
208 ///
209 /// Readable | Writable
210 ///
211 ///
212 /// #### `margin-top`
213 /// Margin on top side of widget.
214 ///
215 /// This property adds margin outside of the widget's normal size
216 /// request, the margin will be added in addition to the size from
217 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
218 ///
219 /// Readable | Writable
220 ///
221 ///
222 /// #### `name`
223 /// Readable | Writable
224 ///
225 ///
226 /// #### `no-show-all`
227 /// Readable | Writable
228 ///
229 ///
230 /// #### `opacity`
231 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
232 /// more details about window opacity.
233 ///
234 /// Before 3.8 this was only available in GtkWindow
235 ///
236 /// Readable | Writable
237 ///
238 ///
239 /// #### `parent`
240 /// Readable | Writable
241 ///
242 ///
243 /// #### `receives-default`
244 /// Readable | Writable
245 ///
246 ///
247 /// #### `scale-factor`
248 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
249 /// more details about widget scaling.
250 ///
251 /// Readable
252 ///
253 ///
254 /// #### `sensitive`
255 /// Readable | Writable
256 ///
257 ///
258 /// #### `style`
259 /// The style of the widget, which contains information about how it will look (colors, etc).
260 ///
261 /// Readable | Writable
262 ///
263 ///
264 /// #### `tooltip-markup`
265 /// Sets the text of tooltip to be the given string, which is marked up
266 /// with the [Pango text markup language][PangoMarkupFormat].
267 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
268 ///
269 /// This is a convenience property which will take care of getting the
270 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
271 /// will automatically be set to [`true`] and there will be taken care of
272 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
273 ///
274 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
275 /// are set, the last one wins.
276 ///
277 /// Readable | Writable
278 ///
279 ///
280 /// #### `tooltip-text`
281 /// Sets the text of tooltip to be the given string.
282 ///
283 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
284 ///
285 /// This is a convenience property which will take care of getting the
286 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
287 /// will automatically be set to [`true`] and there will be taken care of
288 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
289 ///
290 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
291 /// are set, the last one wins.
292 ///
293 /// Readable | Writable
294 ///
295 ///
296 /// #### `valign`
297 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
298 ///
299 /// Readable | Writable
300 ///
301 ///
302 /// #### `vexpand`
303 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
304 ///
305 /// Readable | Writable
306 ///
307 ///
308 /// #### `vexpand-set`
309 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
310 ///
311 /// Readable | Writable
312 ///
313 ///
314 /// #### `visible`
315 /// Readable | Writable
316 ///
317 ///
318 /// #### `width-request`
319 /// Readable | Writable
320 ///
321 ///
322 /// #### `window`
323 /// The widget's window if it is realized, [`None`] otherwise.
324 ///
325 /// Readable
326 /// </details>
327 /// <details><summary><h4>Orientable</h4></summary>
328 ///
329 ///
330 /// #### `orientation`
331 /// The orientation of the orientable.
332 ///
333 /// Readable | Writable
334 /// </details>
335 ///
336 /// # Implements
337 ///
338 /// [`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]
339 #[doc(alias = "GtkShortcutLabel")]
340 pub struct ShortcutLabel(Object<ffi::GtkShortcutLabel, ffi::GtkShortcutLabelClass>) @extends Box, Container, Widget, @implements Buildable, Orientable;
341
342 match fn {
343 type_ => || ffi::gtk_shortcut_label_get_type(),
344 }
345}
346
347impl ShortcutLabel {
348 /// Creates a new [`ShortcutLabel`][crate::ShortcutLabel] with `accelerator` set.
349 /// ## `accelerator`
350 /// the initial accelerator
351 ///
352 /// # Returns
353 ///
354 /// a newly-allocated [`ShortcutLabel`][crate::ShortcutLabel]
355 #[doc(alias = "gtk_shortcut_label_new")]
356 pub fn new(accelerator: &str) -> ShortcutLabel {
357 assert_initialized_main_thread!();
358 unsafe {
359 Widget::from_glib_none(ffi::gtk_shortcut_label_new(accelerator.to_glib_none().0))
360 .unsafe_cast()
361 }
362 }
363
364 /// Retrieves the current accelerator of `self`.
365 ///
366 /// # Returns
367 ///
368 /// the current accelerator.
369 #[doc(alias = "gtk_shortcut_label_get_accelerator")]
370 #[doc(alias = "get_accelerator")]
371 pub fn accelerator(&self) -> Option<glib::GString> {
372 unsafe {
373 from_glib_none(ffi::gtk_shortcut_label_get_accelerator(
374 self.to_glib_none().0,
375 ))
376 }
377 }
378
379 /// Retrieves the text that is displayed when no accelerator is set.
380 ///
381 /// # Returns
382 ///
383 /// the current text displayed when no
384 /// accelerator is set.
385 #[doc(alias = "gtk_shortcut_label_get_disabled_text")]
386 #[doc(alias = "get_disabled_text")]
387 #[doc(alias = "disabled-text")]
388 pub fn disabled_text(&self) -> Option<glib::GString> {
389 unsafe {
390 from_glib_none(ffi::gtk_shortcut_label_get_disabled_text(
391 self.to_glib_none().0,
392 ))
393 }
394 }
395
396 /// Sets the accelerator to be displayed by `self`.
397 /// ## `accelerator`
398 /// the new accelerator
399 #[doc(alias = "gtk_shortcut_label_set_accelerator")]
400 #[doc(alias = "accelerator")]
401 pub fn set_accelerator(&self, accelerator: &str) {
402 unsafe {
403 ffi::gtk_shortcut_label_set_accelerator(
404 self.to_glib_none().0,
405 accelerator.to_glib_none().0,
406 );
407 }
408 }
409
410 /// Sets the text to be displayed by `self` when no accelerator is set.
411 /// ## `disabled_text`
412 /// the text to be displayed when no accelerator is set
413 #[doc(alias = "gtk_shortcut_label_set_disabled_text")]
414 #[doc(alias = "disabled-text")]
415 pub fn set_disabled_text(&self, disabled_text: &str) {
416 unsafe {
417 ffi::gtk_shortcut_label_set_disabled_text(
418 self.to_glib_none().0,
419 disabled_text.to_glib_none().0,
420 );
421 }
422 }
423
424 #[doc(alias = "accelerator")]
425 pub fn connect_accelerator_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
426 unsafe extern "C" fn notify_accelerator_trampoline<F: Fn(&ShortcutLabel) + 'static>(
427 this: *mut ffi::GtkShortcutLabel,
428 _param_spec: glib::ffi::gpointer,
429 f: glib::ffi::gpointer,
430 ) {
431 unsafe {
432 let f: &F = &*(f as *const F);
433 f(&from_glib_borrow(this))
434 }
435 }
436 unsafe {
437 let f: Box_<F> = Box_::new(f);
438 connect_raw(
439 self.as_ptr() as *mut _,
440 c"notify::accelerator".as_ptr(),
441 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
442 notify_accelerator_trampoline::<F> as *const (),
443 )),
444 Box_::into_raw(f),
445 )
446 }
447 }
448
449 #[doc(alias = "disabled-text")]
450 pub fn connect_disabled_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
451 unsafe extern "C" fn notify_disabled_text_trampoline<F: Fn(&ShortcutLabel) + 'static>(
452 this: *mut ffi::GtkShortcutLabel,
453 _param_spec: glib::ffi::gpointer,
454 f: glib::ffi::gpointer,
455 ) {
456 unsafe {
457 let f: &F = &*(f as *const F);
458 f(&from_glib_borrow(this))
459 }
460 }
461 unsafe {
462 let f: Box_<F> = Box_::new(f);
463 connect_raw(
464 self.as_ptr() as *mut _,
465 c"notify::disabled-text".as_ptr(),
466 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
467 notify_disabled_text_trampoline::<F> as *const (),
468 )),
469 Box_::into_raw(f),
470 )
471 }
472 }
473}