gtk4/auto/font_button.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#![allow(deprecated)]
5
6use crate::{
7 ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, FontChooser,
8 FontChooserLevel, LayoutManager, Overflow, Widget,
9};
10use glib::{
11 object::ObjectType as _,
12 prelude::*,
13 signal::{connect_raw, SignalHandlerId},
14 translate::*,
15};
16use std::boxed::Box as Box_;
17
18glib::wrapper! {
19 /// Use [`FontDialogButton`][crate::FontDialogButton] instead
20 /// The [`FontButton`][crate::FontButton] allows to open a font chooser dialog to change
21 /// the font.
22 ///
23 /// <picture>
24 /// <source srcset="font-button-dark.png" media="(prefers-color-scheme: dark)">
25 /// <img alt="An example GtkFontButton" src="font-button.png">
26 /// </picture>
27 ///
28 /// It is suitable widget for selecting a font in a preference dialog.
29 ///
30 /// # CSS nodes
31 ///
32 /// ```text
33 /// fontbutton
34 /// ╰── button.font
35 /// ╰── [content]
36 /// ```
37 ///
38 /// [`FontButton`][crate::FontButton] has a single CSS node with name fontbutton which
39 /// contains a button node with the .font style class.
40 ///
41 /// ## Properties
42 ///
43 ///
44 /// #### `modal`
45 /// Whether the font chooser dialog should be modal.
46 ///
47 /// Readable | Writeable
48 ///
49 ///
50 /// #### `title`
51 /// The title of the font chooser dialog.
52 ///
53 /// Readable | Writeable
54 ///
55 ///
56 /// #### `use-font`
57 /// Whether the buttons label will be drawn in the selected font.
58 ///
59 /// Readable | Writeable
60 ///
61 ///
62 /// #### `use-size`
63 /// Whether the buttons label will use the selected font size.
64 ///
65 /// Readable | Writeable
66 /// <details><summary><h4>Widget</h4></summary>
67 ///
68 ///
69 /// #### `can-focus`
70 /// Whether the widget or any of its descendents can accept
71 /// the input focus.
72 ///
73 /// This property is meant to be set by widget implementations,
74 /// typically in their instance init function.
75 ///
76 /// Readable | Writeable
77 ///
78 ///
79 /// #### `can-target`
80 /// Whether the widget can receive pointer events.
81 ///
82 /// Readable | Writeable
83 ///
84 ///
85 /// #### `css-classes`
86 /// A list of css classes applied to this widget.
87 ///
88 /// Readable | Writeable
89 ///
90 ///
91 /// #### `css-name`
92 /// The name of this widget in the CSS tree.
93 ///
94 /// This property is meant to be set by widget implementations,
95 /// typically in their instance init function.
96 ///
97 /// Readable | Writeable | Construct Only
98 ///
99 ///
100 /// #### `cursor`
101 /// The cursor used by @widget.
102 ///
103 /// Readable | Writeable
104 ///
105 ///
106 /// #### `focus-on-click`
107 /// Whether the widget should grab focus when it is clicked with the mouse.
108 ///
109 /// This property is only relevant for widgets that can take focus.
110 ///
111 /// Readable | Writeable
112 ///
113 ///
114 /// #### `focusable`
115 /// Whether this widget itself will accept the input focus.
116 ///
117 /// Readable | Writeable
118 ///
119 ///
120 /// #### `halign`
121 /// How to distribute horizontal space if widget gets extra space.
122 ///
123 /// Readable | Writeable
124 ///
125 ///
126 /// #### `has-default`
127 /// Whether the widget is the default widget.
128 ///
129 /// Readable
130 ///
131 ///
132 /// #### `has-focus`
133 /// Whether the widget has the input focus.
134 ///
135 /// Readable
136 ///
137 ///
138 /// #### `has-tooltip`
139 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
140 /// signal on @widget.
141 ///
142 /// A true value indicates that @widget can have a tooltip, in this case
143 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
144 /// determine whether it will provide a tooltip or not.
145 ///
146 /// Readable | Writeable
147 ///
148 ///
149 /// #### `height-request`
150 /// Overrides for height request of the widget.
151 ///
152 /// If this is -1, the natural request will be used.
153 ///
154 /// Readable | Writeable
155 ///
156 ///
157 /// #### `hexpand`
158 /// Whether to expand horizontally.
159 ///
160 /// Readable | Writeable
161 ///
162 ///
163 /// #### `hexpand-set`
164 /// Whether to use the `hexpand` property.
165 ///
166 /// Readable | Writeable
167 ///
168 ///
169 /// #### `layout-manager`
170 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
171 /// the preferred size of the widget, and allocate its children.
172 ///
173 /// This property is meant to be set by widget implementations,
174 /// typically in their instance init function.
175 ///
176 /// Readable | Writeable
177 ///
178 ///
179 /// #### `limit-events`
180 /// Makes this widget act like a modal dialog, with respect to
181 /// event delivery.
182 ///
183 /// Global event controllers will not handle events with targets
184 /// inside the widget, unless they are set up to ignore propagation
185 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
186 ///
187 /// Readable | Writeable
188 ///
189 ///
190 /// #### `margin-bottom`
191 /// Margin on bottom side of widget.
192 ///
193 /// This property adds margin outside of the widget's normal size
194 /// request, the margin will be added in addition to the size from
195 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
196 ///
197 /// Readable | Writeable
198 ///
199 ///
200 /// #### `margin-end`
201 /// Margin on end of widget, horizontally.
202 ///
203 /// This property supports left-to-right and right-to-left text
204 /// directions.
205 ///
206 /// This property adds margin outside of the widget's normal size
207 /// request, the margin will be added in addition to the size from
208 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
209 ///
210 /// Readable | Writeable
211 ///
212 ///
213 /// #### `margin-start`
214 /// Margin on start of widget, horizontally.
215 ///
216 /// This property supports left-to-right and right-to-left text
217 /// directions.
218 ///
219 /// This property adds margin outside of the widget's normal size
220 /// request, the margin will be added in addition to the size from
221 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
222 ///
223 /// Readable | Writeable
224 ///
225 ///
226 /// #### `margin-top`
227 /// Margin on top side of widget.
228 ///
229 /// This property adds margin outside of the widget's normal size
230 /// request, the margin will be added in addition to the size from
231 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
232 ///
233 /// Readable | Writeable
234 ///
235 ///
236 /// #### `name`
237 /// The name of the widget.
238 ///
239 /// Readable | Writeable
240 ///
241 ///
242 /// #### `opacity`
243 /// The requested opacity of the widget.
244 ///
245 /// Readable | Writeable
246 ///
247 ///
248 /// #### `overflow`
249 /// How content outside the widget's content area is treated.
250 ///
251 /// This property is meant to be set by widget implementations,
252 /// typically in their instance init function.
253 ///
254 /// Readable | Writeable
255 ///
256 ///
257 /// #### `parent`
258 /// The parent widget of this widget.
259 ///
260 /// Readable
261 ///
262 ///
263 /// #### `receives-default`
264 /// Whether the widget will receive the default action when it is focused.
265 ///
266 /// Readable | Writeable
267 ///
268 ///
269 /// #### `root`
270 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
271 ///
272 /// This will be `NULL` if the widget is not contained in a root widget.
273 ///
274 /// Readable
275 ///
276 ///
277 /// #### `scale-factor`
278 /// The scale factor of the widget.
279 ///
280 /// Readable
281 ///
282 ///
283 /// #### `sensitive`
284 /// Whether the widget responds to input.
285 ///
286 /// Readable | Writeable
287 ///
288 ///
289 /// #### `tooltip-markup`
290 /// Sets the text of tooltip to be the given string, which is marked up
291 /// with Pango markup.
292 ///
293 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
294 ///
295 /// This is a convenience property which will take care of getting the
296 /// tooltip shown if the given string is not `NULL`:
297 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
298 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
299 /// the default signal handler.
300 ///
301 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
302 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
303 ///
304 /// Readable | Writeable
305 ///
306 ///
307 /// #### `tooltip-text`
308 /// Sets the text of tooltip to be the given string.
309 ///
310 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
311 ///
312 /// This is a convenience property which will take care of getting the
313 /// tooltip shown if the given string is not `NULL`:
314 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
315 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
316 /// the default signal handler.
317 ///
318 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
319 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
320 ///
321 /// Readable | Writeable
322 ///
323 ///
324 /// #### `valign`
325 /// How to distribute vertical space if widget gets extra space.
326 ///
327 /// Readable | Writeable
328 ///
329 ///
330 /// #### `vexpand`
331 /// Whether to expand vertically.
332 ///
333 /// Readable | Writeable
334 ///
335 ///
336 /// #### `vexpand-set`
337 /// Whether to use the `vexpand` property.
338 ///
339 /// Readable | Writeable
340 ///
341 ///
342 /// #### `visible`
343 /// Whether the widget is visible.
344 ///
345 /// Readable | Writeable
346 ///
347 ///
348 /// #### `width-request`
349 /// Overrides for width request of the widget.
350 ///
351 /// If this is -1, the natural request will be used.
352 ///
353 /// Readable | Writeable
354 /// </details>
355 /// <details><summary><h4>Accessible</h4></summary>
356 ///
357 ///
358 /// #### `accessible-role`
359 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
360 ///
361 /// The accessible role cannot be changed once set.
362 ///
363 /// Readable | Writeable
364 /// </details>
365 /// <details><summary><h4>FontChooser</h4></summary>
366 ///
367 ///
368 /// #### `font`
369 /// The font description as a string, e.g. "Sans Italic 12".
370 ///
371 /// Readable | Writeable
372 ///
373 ///
374 /// #### `font-desc`
375 /// The font description as a [`pango::FontDescription`][crate::pango::FontDescription].
376 ///
377 /// Readable | Writeable
378 ///
379 ///
380 /// #### `font-features`
381 /// The selected font features.
382 ///
383 /// The format of the string is compatible with
384 /// CSS and with Pango attributes.
385 ///
386 /// Readable
387 ///
388 ///
389 /// #### `language`
390 /// The language for which the font features were selected.
391 ///
392 /// Readable | Writeable
393 ///
394 ///
395 /// #### `level`
396 /// The level of granularity to offer for selecting fonts.
397 ///
398 /// Readable | Writeable
399 ///
400 ///
401 /// #### `preview-text`
402 /// The string with which to preview the font.
403 ///
404 /// Readable | Writeable
405 ///
406 ///
407 /// #### `show-preview-entry`
408 /// Whether to show an entry to change the preview text.
409 ///
410 /// Readable | Writeable
411 /// </details>
412 ///
413 /// ## Signals
414 ///
415 ///
416 /// #### `activate`
417 /// Emitted to when the font button is activated.
418 ///
419 /// The `::activate` signal on [`FontButton`][crate::FontButton] is an action signal and
420 /// emitting it causes the button to present its dialog.
421 ///
422 /// Action
423 ///
424 ///
425 /// #### `font-set`
426 /// Emitted when the user selects a font.
427 ///
428 /// When handling this signal, use [`FontChooserExt::font()`][crate::prelude::FontChooserExt::font()]
429 /// to find out which font was just selected.
430 ///
431 /// Note that this signal is only emitted when the user changes the font.
432 /// If you need to react to programmatic font changes as well, use
433 /// the notify::font signal.
434 ///
435 ///
436 /// <details><summary><h4>Widget</h4></summary>
437 ///
438 ///
439 /// #### `destroy`
440 /// Signals that all holders of a reference to the widget should release
441 /// the reference that they hold.
442 ///
443 /// May result in finalization of the widget if all references are released.
444 ///
445 /// This signal is not suitable for saving widget state.
446 ///
447 ///
448 ///
449 ///
450 /// #### `direction-changed`
451 /// Emitted when the text direction of a widget changes.
452 ///
453 ///
454 ///
455 ///
456 /// #### `hide`
457 /// Emitted when @widget is hidden.
458 ///
459 ///
460 ///
461 ///
462 /// #### `keynav-failed`
463 /// Emitted if keyboard navigation fails.
464 ///
465 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
466 ///
467 ///
468 ///
469 ///
470 /// #### `map`
471 /// Emitted when @widget is going to be mapped.
472 ///
473 /// A widget is mapped when the widget is visible (which is controlled with
474 /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
475 /// are also visible.
476 ///
477 /// The `::map` signal can be used to determine whether a widget will be drawn,
478 /// for instance it can resume an animation that was stopped during the
479 /// emission of [`unmap`][struct@crate::Widget#unmap].
480 ///
481 ///
482 ///
483 ///
484 /// #### `mnemonic-activate`
485 /// Emitted when a widget is activated via a mnemonic.
486 ///
487 /// The default handler for this signal activates @widget if @group_cycling
488 /// is false, or just makes @widget grab focus if @group_cycling is true.
489 ///
490 ///
491 ///
492 ///
493 /// #### `move-focus`
494 /// Emitted when the focus is moved.
495 ///
496 /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
497 ///
498 /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
499 /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
500 ///
501 /// Action
502 ///
503 ///
504 /// #### `query-tooltip`
505 /// Emitted when the widget’s tooltip is about to be shown.
506 ///
507 /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
508 /// is true and the hover timeout has expired with the cursor hovering
509 /// above @widget; or emitted when @widget got focus in keyboard mode.
510 ///
511 /// Using the given coordinates, the signal handler should determine
512 /// whether a tooltip should be shown for @widget. If this is the case
513 /// true should be returned, false otherwise. Note that if @keyboard_mode
514 /// is true, the values of @x and @y are undefined and should not be used.
515 ///
516 /// The signal handler is free to manipulate @tooltip with the therefore
517 /// destined function calls.
518 ///
519 ///
520 ///
521 ///
522 /// #### `realize`
523 /// Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
524 ///
525 /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
526 /// or the widget has been mapped (that is, it is going to be drawn).
527 ///
528 ///
529 ///
530 ///
531 /// #### `show`
532 /// Emitted when @widget is shown.
533 ///
534 ///
535 ///
536 ///
537 /// #### `state-flags-changed`
538 /// Emitted when the widget state changes.
539 ///
540 /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
541 ///
542 ///
543 ///
544 ///
545 /// #### `unmap`
546 /// Emitted when @widget is going to be unmapped.
547 ///
548 /// A widget is unmapped when either it or any of its parents up to the
549 /// toplevel widget have been set as hidden.
550 ///
551 /// As `::unmap` indicates that a widget will not be shown any longer,
552 /// it can be used to, for example, stop an animation on the widget.
553 ///
554 ///
555 ///
556 ///
557 /// #### `unrealize`
558 /// Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
559 ///
560 /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
561 /// or the widget has been unmapped (that is, it is going to be hidden).
562 ///
563 ///
564 /// </details>
565 /// <details><summary><h4>FontChooser</h4></summary>
566 ///
567 ///
568 /// #### `font-activated`
569 /// Emitted when a font is activated.
570 ///
571 /// This usually happens when the user double clicks an item,
572 /// or an item is selected and the user presses one of the keys
573 /// Space, Shift+Space, Return or Enter.
574 ///
575 ///
576 /// </details>
577 ///
578 /// # Implements
579 ///
580 /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`FontChooserExt`][trait@crate::prelude::FontChooserExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual], [`FontChooserExtManual`][trait@crate::prelude::FontChooserExtManual]
581 #[doc(alias = "GtkFontButton")]
582 pub struct FontButton(Object<ffi::GtkFontButton>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, FontChooser;
583
584 match fn {
585 type_ => || ffi::gtk_font_button_get_type(),
586 }
587}
588
589impl FontButton {
590 /// Creates a new font picker widget.
591 ///
592 /// # Deprecated since 4.10
593 ///
594 /// Use [`FontDialogButton`][crate::FontDialogButton] instead
595 ///
596 /// # Returns
597 ///
598 /// a new font picker widget.
599 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
600 #[allow(deprecated)]
601 #[doc(alias = "gtk_font_button_new")]
602 pub fn new() -> FontButton {
603 assert_initialized_main_thread!();
604 unsafe { Widget::from_glib_none(ffi::gtk_font_button_new()).unsafe_cast() }
605 }
606
607 /// Creates a new font picker widget showing the given font.
608 ///
609 /// # Deprecated since 4.10
610 ///
611 /// Use [`FontDialogButton`][crate::FontDialogButton] instead
612 /// ## `fontname`
613 /// Name of font to display in font chooser dialog
614 ///
615 /// # Returns
616 ///
617 /// a new font picker widget.
618 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
619 #[allow(deprecated)]
620 #[doc(alias = "gtk_font_button_new_with_font")]
621 #[doc(alias = "new_with_font")]
622 pub fn with_font(fontname: &str) -> FontButton {
623 assert_initialized_main_thread!();
624 unsafe {
625 Widget::from_glib_none(ffi::gtk_font_button_new_with_font(
626 fontname.to_glib_none().0,
627 ))
628 .unsafe_cast()
629 }
630 }
631
632 // rustdoc-stripper-ignore-next
633 /// Creates a new builder-pattern struct instance to construct [`FontButton`] objects.
634 ///
635 /// This method returns an instance of [`FontButtonBuilder`](crate::builders::FontButtonBuilder) which can be used to create [`FontButton`] objects.
636 pub fn builder() -> FontButtonBuilder {
637 FontButtonBuilder::new()
638 }
639
640 /// Gets whether the dialog is modal.
641 ///
642 /// # Deprecated since 4.10
643 ///
644 /// Use [`FontDialogButton`][crate::FontDialogButton] instead
645 ///
646 /// # Returns
647 ///
648 /// [`true`] if the dialog is modal
649 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
650 #[allow(deprecated)]
651 #[doc(alias = "gtk_font_button_get_modal")]
652 #[doc(alias = "get_modal")]
653 #[doc(alias = "modal")]
654 pub fn is_modal(&self) -> bool {
655 unsafe { from_glib(ffi::gtk_font_button_get_modal(self.to_glib_none().0)) }
656 }
657
658 /// Retrieves the title of the font chooser dialog.
659 ///
660 /// # Deprecated since 4.10
661 ///
662 /// Use [`FontDialogButton`][crate::FontDialogButton] instead
663 ///
664 /// # Returns
665 ///
666 /// an internal copy of the title string
667 /// which must not be freed.
668 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
669 #[allow(deprecated)]
670 #[doc(alias = "gtk_font_button_get_title")]
671 #[doc(alias = "get_title")]
672 pub fn title(&self) -> glib::GString {
673 unsafe { from_glib_none(ffi::gtk_font_button_get_title(self.to_glib_none().0)) }
674 }
675
676 /// Returns whether the selected font is used in the label.
677 ///
678 /// # Deprecated since 4.10
679 ///
680 /// Use [`FontDialogButton`][crate::FontDialogButton] instead
681 ///
682 /// # Returns
683 ///
684 /// whether the selected font is used in the label.
685 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
686 #[allow(deprecated)]
687 #[doc(alias = "gtk_font_button_get_use_font")]
688 #[doc(alias = "get_use_font")]
689 #[doc(alias = "use-font")]
690 pub fn uses_font(&self) -> bool {
691 unsafe { from_glib(ffi::gtk_font_button_get_use_font(self.to_glib_none().0)) }
692 }
693
694 /// Returns whether the selected size is used in the label.
695 ///
696 /// # Deprecated since 4.10
697 ///
698 /// Use [`FontDialogButton`][crate::FontDialogButton] instead
699 ///
700 /// # Returns
701 ///
702 /// whether the selected size is used in the label.
703 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
704 #[allow(deprecated)]
705 #[doc(alias = "gtk_font_button_get_use_size")]
706 #[doc(alias = "get_use_size")]
707 #[doc(alias = "use-size")]
708 pub fn uses_size(&self) -> bool {
709 unsafe { from_glib(ffi::gtk_font_button_get_use_size(self.to_glib_none().0)) }
710 }
711
712 /// Sets whether the dialog should be modal.
713 ///
714 /// # Deprecated since 4.10
715 ///
716 /// Use [`FontDialogButton`][crate::FontDialogButton] instead
717 /// ## `modal`
718 /// [`true`] to make the dialog modal
719 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
720 #[allow(deprecated)]
721 #[doc(alias = "gtk_font_button_set_modal")]
722 #[doc(alias = "modal")]
723 pub fn set_modal(&self, modal: bool) {
724 unsafe {
725 ffi::gtk_font_button_set_modal(self.to_glib_none().0, modal.into_glib());
726 }
727 }
728
729 /// Sets the title for the font chooser dialog.
730 ///
731 /// # Deprecated since 4.10
732 ///
733 /// Use [`FontDialogButton`][crate::FontDialogButton] instead
734 /// ## `title`
735 /// a string containing the font chooser dialog title
736 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
737 #[allow(deprecated)]
738 #[doc(alias = "gtk_font_button_set_title")]
739 #[doc(alias = "title")]
740 pub fn set_title(&self, title: &str) {
741 unsafe {
742 ffi::gtk_font_button_set_title(self.to_glib_none().0, title.to_glib_none().0);
743 }
744 }
745
746 /// If @use_font is [`true`], the font name will be written
747 /// using the selected font.
748 ///
749 /// # Deprecated since 4.10
750 ///
751 /// Use [`FontDialogButton`][crate::FontDialogButton] instead
752 /// ## `use_font`
753 /// If [`true`], font name will be written using font chosen.
754 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
755 #[allow(deprecated)]
756 #[doc(alias = "gtk_font_button_set_use_font")]
757 #[doc(alias = "use-font")]
758 pub fn set_use_font(&self, use_font: bool) {
759 unsafe {
760 ffi::gtk_font_button_set_use_font(self.to_glib_none().0, use_font.into_glib());
761 }
762 }
763
764 /// If @use_size is [`true`], the font name will be written using
765 /// the selected size.
766 ///
767 /// # Deprecated since 4.10
768 ///
769 /// Use [`FontDialogButton`][crate::FontDialogButton] instead
770 /// ## `use_size`
771 /// If [`true`], font name will be written using the
772 /// selected size.
773 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
774 #[allow(deprecated)]
775 #[doc(alias = "gtk_font_button_set_use_size")]
776 #[doc(alias = "use-size")]
777 pub fn set_use_size(&self, use_size: bool) {
778 unsafe {
779 ffi::gtk_font_button_set_use_size(self.to_glib_none().0, use_size.into_glib());
780 }
781 }
782
783 /// Emitted to when the font button is activated.
784 ///
785 /// The `::activate` signal on [`FontButton`][crate::FontButton] is an action signal and
786 /// emitting it causes the button to present its dialog.
787 #[cfg(feature = "v4_4")]
788 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
789 #[doc(alias = "activate")]
790 pub fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
791 unsafe extern "C" fn activate_trampoline<F: Fn(&FontButton) + 'static>(
792 this: *mut ffi::GtkFontButton,
793 f: glib::ffi::gpointer,
794 ) {
795 let f: &F = &*(f as *const F);
796 f(&from_glib_borrow(this))
797 }
798 unsafe {
799 let f: Box_<F> = Box_::new(f);
800 connect_raw(
801 self.as_ptr() as *mut _,
802 c"activate".as_ptr() as *const _,
803 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
804 activate_trampoline::<F> as *const (),
805 )),
806 Box_::into_raw(f),
807 )
808 }
809 }
810
811 #[cfg(feature = "v4_4")]
812 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
813 pub fn emit_activate(&self) {
814 self.emit_by_name::<()>("activate", &[]);
815 }
816
817 /// Emitted when the user selects a font.
818 ///
819 /// When handling this signal, use [`FontChooserExt::font()`][crate::prelude::FontChooserExt::font()]
820 /// to find out which font was just selected.
821 ///
822 /// Note that this signal is only emitted when the user changes the font.
823 /// If you need to react to programmatic font changes as well, use
824 /// the notify::font signal.
825 #[doc(alias = "font-set")]
826 pub fn connect_font_set<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
827 unsafe extern "C" fn font_set_trampoline<F: Fn(&FontButton) + 'static>(
828 this: *mut ffi::GtkFontButton,
829 f: glib::ffi::gpointer,
830 ) {
831 let f: &F = &*(f as *const F);
832 f(&from_glib_borrow(this))
833 }
834 unsafe {
835 let f: Box_<F> = Box_::new(f);
836 connect_raw(
837 self.as_ptr() as *mut _,
838 c"font-set".as_ptr() as *const _,
839 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
840 font_set_trampoline::<F> as *const (),
841 )),
842 Box_::into_raw(f),
843 )
844 }
845 }
846
847 #[doc(alias = "modal")]
848 pub fn connect_modal_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
849 unsafe extern "C" fn notify_modal_trampoline<F: Fn(&FontButton) + 'static>(
850 this: *mut ffi::GtkFontButton,
851 _param_spec: glib::ffi::gpointer,
852 f: glib::ffi::gpointer,
853 ) {
854 let f: &F = &*(f as *const F);
855 f(&from_glib_borrow(this))
856 }
857 unsafe {
858 let f: Box_<F> = Box_::new(f);
859 connect_raw(
860 self.as_ptr() as *mut _,
861 c"notify::modal".as_ptr() as *const _,
862 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
863 notify_modal_trampoline::<F> as *const (),
864 )),
865 Box_::into_raw(f),
866 )
867 }
868 }
869
870 #[doc(alias = "title")]
871 pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
872 unsafe extern "C" fn notify_title_trampoline<F: Fn(&FontButton) + 'static>(
873 this: *mut ffi::GtkFontButton,
874 _param_spec: glib::ffi::gpointer,
875 f: glib::ffi::gpointer,
876 ) {
877 let f: &F = &*(f as *const F);
878 f(&from_glib_borrow(this))
879 }
880 unsafe {
881 let f: Box_<F> = Box_::new(f);
882 connect_raw(
883 self.as_ptr() as *mut _,
884 c"notify::title".as_ptr() as *const _,
885 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
886 notify_title_trampoline::<F> as *const (),
887 )),
888 Box_::into_raw(f),
889 )
890 }
891 }
892
893 #[doc(alias = "use-font")]
894 pub fn connect_use_font_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
895 unsafe extern "C" fn notify_use_font_trampoline<F: Fn(&FontButton) + 'static>(
896 this: *mut ffi::GtkFontButton,
897 _param_spec: glib::ffi::gpointer,
898 f: glib::ffi::gpointer,
899 ) {
900 let f: &F = &*(f as *const F);
901 f(&from_glib_borrow(this))
902 }
903 unsafe {
904 let f: Box_<F> = Box_::new(f);
905 connect_raw(
906 self.as_ptr() as *mut _,
907 c"notify::use-font".as_ptr() as *const _,
908 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
909 notify_use_font_trampoline::<F> as *const (),
910 )),
911 Box_::into_raw(f),
912 )
913 }
914 }
915
916 #[doc(alias = "use-size")]
917 pub fn connect_use_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
918 unsafe extern "C" fn notify_use_size_trampoline<F: Fn(&FontButton) + 'static>(
919 this: *mut ffi::GtkFontButton,
920 _param_spec: glib::ffi::gpointer,
921 f: glib::ffi::gpointer,
922 ) {
923 let f: &F = &*(f as *const F);
924 f(&from_glib_borrow(this))
925 }
926 unsafe {
927 let f: Box_<F> = Box_::new(f);
928 connect_raw(
929 self.as_ptr() as *mut _,
930 c"notify::use-size".as_ptr() as *const _,
931 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
932 notify_use_size_trampoline::<F> as *const (),
933 )),
934 Box_::into_raw(f),
935 )
936 }
937 }
938}
939
940impl Default for FontButton {
941 fn default() -> Self {
942 Self::new()
943 }
944}
945
946// rustdoc-stripper-ignore-next
947/// A [builder-pattern] type to construct [`FontButton`] objects.
948///
949/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
950#[must_use = "The builder must be built to be used"]
951pub struct FontButtonBuilder {
952 builder: glib::object::ObjectBuilder<'static, FontButton>,
953}
954
955impl FontButtonBuilder {
956 fn new() -> Self {
957 Self {
958 builder: glib::object::Object::builder(),
959 }
960 }
961
962 /// Whether the font chooser dialog should be modal.
963 pub fn modal(self, modal: bool) -> Self {
964 Self {
965 builder: self.builder.property("modal", modal),
966 }
967 }
968
969 /// The title of the font chooser dialog.
970 pub fn title(self, title: impl Into<glib::GString>) -> Self {
971 Self {
972 builder: self.builder.property("title", title.into()),
973 }
974 }
975
976 /// Whether the buttons label will be drawn in the selected font.
977 pub fn use_font(self, use_font: bool) -> Self {
978 Self {
979 builder: self.builder.property("use-font", use_font),
980 }
981 }
982
983 /// Whether the buttons label will use the selected font size.
984 pub fn use_size(self, use_size: bool) -> Self {
985 Self {
986 builder: self.builder.property("use-size", use_size),
987 }
988 }
989
990 /// Whether the widget or any of its descendents can accept
991 /// the input focus.
992 ///
993 /// This property is meant to be set by widget implementations,
994 /// typically in their instance init function.
995 pub fn can_focus(self, can_focus: bool) -> Self {
996 Self {
997 builder: self.builder.property("can-focus", can_focus),
998 }
999 }
1000
1001 /// Whether the widget can receive pointer events.
1002 pub fn can_target(self, can_target: bool) -> Self {
1003 Self {
1004 builder: self.builder.property("can-target", can_target),
1005 }
1006 }
1007
1008 /// A list of css classes applied to this widget.
1009 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1010 Self {
1011 builder: self.builder.property("css-classes", css_classes.into()),
1012 }
1013 }
1014
1015 /// The name of this widget in the CSS tree.
1016 ///
1017 /// This property is meant to be set by widget implementations,
1018 /// typically in their instance init function.
1019 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1020 Self {
1021 builder: self.builder.property("css-name", css_name.into()),
1022 }
1023 }
1024
1025 /// The cursor used by @widget.
1026 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1027 Self {
1028 builder: self.builder.property("cursor", cursor.clone()),
1029 }
1030 }
1031
1032 /// Whether the widget should grab focus when it is clicked with the mouse.
1033 ///
1034 /// This property is only relevant for widgets that can take focus.
1035 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1036 Self {
1037 builder: self.builder.property("focus-on-click", focus_on_click),
1038 }
1039 }
1040
1041 /// Whether this widget itself will accept the input focus.
1042 pub fn focusable(self, focusable: bool) -> Self {
1043 Self {
1044 builder: self.builder.property("focusable", focusable),
1045 }
1046 }
1047
1048 /// How to distribute horizontal space if widget gets extra space.
1049 pub fn halign(self, halign: Align) -> Self {
1050 Self {
1051 builder: self.builder.property("halign", halign),
1052 }
1053 }
1054
1055 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1056 /// signal on @widget.
1057 ///
1058 /// A true value indicates that @widget can have a tooltip, in this case
1059 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1060 /// determine whether it will provide a tooltip or not.
1061 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1062 Self {
1063 builder: self.builder.property("has-tooltip", has_tooltip),
1064 }
1065 }
1066
1067 /// Overrides for height request of the widget.
1068 ///
1069 /// If this is -1, the natural request will be used.
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.
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` property.
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 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1091 /// the preferred size of the widget, and allocate its children.
1092 ///
1093 /// This property is meant to be set by widget implementations,
1094 /// typically in their instance init function.
1095 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1096 Self {
1097 builder: self
1098 .builder
1099 .property("layout-manager", layout_manager.clone().upcast()),
1100 }
1101 }
1102
1103 /// Makes this widget act like a modal dialog, with respect to
1104 /// event delivery.
1105 ///
1106 /// Global event controllers will not handle events with targets
1107 /// inside the widget, unless they are set up to ignore propagation
1108 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1109 #[cfg(feature = "v4_18")]
1110 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1111 pub fn limit_events(self, limit_events: bool) -> Self {
1112 Self {
1113 builder: self.builder.property("limit-events", limit_events),
1114 }
1115 }
1116
1117 /// Margin on bottom side of widget.
1118 ///
1119 /// This property adds margin outside of the widget's normal size
1120 /// request, the margin will be added in addition to the size from
1121 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1122 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1123 Self {
1124 builder: self.builder.property("margin-bottom", margin_bottom),
1125 }
1126 }
1127
1128 /// Margin on end of widget, horizontally.
1129 ///
1130 /// This property supports left-to-right and right-to-left text
1131 /// directions.
1132 ///
1133 /// This property adds margin outside of the widget's normal size
1134 /// request, the margin will be added in addition to the size from
1135 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1136 pub fn margin_end(self, margin_end: i32) -> Self {
1137 Self {
1138 builder: self.builder.property("margin-end", margin_end),
1139 }
1140 }
1141
1142 /// Margin on start of widget, horizontally.
1143 ///
1144 /// This property supports left-to-right and right-to-left text
1145 /// directions.
1146 ///
1147 /// This property adds margin outside of the widget's normal size
1148 /// request, the margin will be added in addition to the size from
1149 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1150 pub fn margin_start(self, margin_start: i32) -> Self {
1151 Self {
1152 builder: self.builder.property("margin-start", margin_start),
1153 }
1154 }
1155
1156 /// Margin on top side of widget.
1157 ///
1158 /// This property adds margin outside of the widget's normal size
1159 /// request, the margin will be added in addition to the size from
1160 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1161 pub fn margin_top(self, margin_top: i32) -> Self {
1162 Self {
1163 builder: self.builder.property("margin-top", margin_top),
1164 }
1165 }
1166
1167 /// The name of the widget.
1168 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1169 Self {
1170 builder: self.builder.property("name", name.into()),
1171 }
1172 }
1173
1174 /// The requested opacity of the widget.
1175 pub fn opacity(self, opacity: f64) -> Self {
1176 Self {
1177 builder: self.builder.property("opacity", opacity),
1178 }
1179 }
1180
1181 /// How content outside the widget's content area is treated.
1182 ///
1183 /// This property is meant to be set by widget implementations,
1184 /// typically in their instance init function.
1185 pub fn overflow(self, overflow: Overflow) -> Self {
1186 Self {
1187 builder: self.builder.property("overflow", overflow),
1188 }
1189 }
1190
1191 /// Whether the widget will receive the default action when it is focused.
1192 pub fn receives_default(self, receives_default: bool) -> Self {
1193 Self {
1194 builder: self.builder.property("receives-default", receives_default),
1195 }
1196 }
1197
1198 /// Whether the widget responds to input.
1199 pub fn sensitive(self, sensitive: bool) -> Self {
1200 Self {
1201 builder: self.builder.property("sensitive", sensitive),
1202 }
1203 }
1204
1205 /// Sets the text of tooltip to be the given string, which is marked up
1206 /// with Pango markup.
1207 ///
1208 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1209 ///
1210 /// This is a convenience property which will take care of getting the
1211 /// tooltip shown if the given string is not `NULL`:
1212 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1213 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1214 /// the default signal handler.
1215 ///
1216 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1217 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1218 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1219 Self {
1220 builder: self
1221 .builder
1222 .property("tooltip-markup", tooltip_markup.into()),
1223 }
1224 }
1225
1226 /// Sets the text of tooltip to be the given string.
1227 ///
1228 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1229 ///
1230 /// This is a convenience property which will take care of getting the
1231 /// tooltip shown if the given string is not `NULL`:
1232 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1233 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1234 /// the default signal handler.
1235 ///
1236 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1237 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1238 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1239 Self {
1240 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1241 }
1242 }
1243
1244 /// How to distribute vertical space if widget gets extra space.
1245 pub fn valign(self, valign: Align) -> Self {
1246 Self {
1247 builder: self.builder.property("valign", valign),
1248 }
1249 }
1250
1251 /// Whether to expand vertically.
1252 pub fn vexpand(self, vexpand: bool) -> Self {
1253 Self {
1254 builder: self.builder.property("vexpand", vexpand),
1255 }
1256 }
1257
1258 /// Whether to use the `vexpand` property.
1259 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1260 Self {
1261 builder: self.builder.property("vexpand-set", vexpand_set),
1262 }
1263 }
1264
1265 /// Whether the widget is visible.
1266 pub fn visible(self, visible: bool) -> Self {
1267 Self {
1268 builder: self.builder.property("visible", visible),
1269 }
1270 }
1271
1272 /// Overrides for width request of the widget.
1273 ///
1274 /// If this is -1, the natural request will be used.
1275 pub fn width_request(self, width_request: i32) -> Self {
1276 Self {
1277 builder: self.builder.property("width-request", width_request),
1278 }
1279 }
1280
1281 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1282 ///
1283 /// The accessible role cannot be changed once set.
1284 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1285 Self {
1286 builder: self.builder.property("accessible-role", accessible_role),
1287 }
1288 }
1289
1290 /// The font description as a string, e.g. "Sans Italic 12".
1291 /// Use [`FontDialog`][crate::FontDialog] and [`FontDialogButton`][crate::FontDialogButton] instead
1292 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1293 pub fn font(self, font: impl Into<glib::GString>) -> Self {
1294 Self {
1295 builder: self.builder.property("font", font.into()),
1296 }
1297 }
1298
1299 /// The font description as a [`pango::FontDescription`][crate::pango::FontDescription].
1300 /// Use [`FontDialog`][crate::FontDialog] and [`FontDialogButton`][crate::FontDialogButton] instead
1301 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1302 pub fn font_desc(self, font_desc: &pango::FontDescription) -> Self {
1303 Self {
1304 builder: self.builder.property("font-desc", font_desc),
1305 }
1306 }
1307
1308 /// The language for which the font features were selected.
1309 /// Use [`FontDialog`][crate::FontDialog] and [`FontDialogButton`][crate::FontDialogButton] instead
1310 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1311 pub fn language(self, language: impl Into<glib::GString>) -> Self {
1312 Self {
1313 builder: self.builder.property("language", language.into()),
1314 }
1315 }
1316
1317 /// The level of granularity to offer for selecting fonts.
1318 /// Use [`FontDialog`][crate::FontDialog] and [`FontDialogButton`][crate::FontDialogButton] instead
1319 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1320 pub fn level(self, level: FontChooserLevel) -> Self {
1321 Self {
1322 builder: self.builder.property("level", level),
1323 }
1324 }
1325
1326 /// The string with which to preview the font.
1327 /// Use [`FontDialog`][crate::FontDialog] and [`FontDialogButton`][crate::FontDialogButton] instead
1328 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1329 pub fn preview_text(self, preview_text: impl Into<glib::GString>) -> Self {
1330 Self {
1331 builder: self.builder.property("preview-text", preview_text.into()),
1332 }
1333 }
1334
1335 /// Whether to show an entry to change the preview text.
1336 /// Use [`FontDialog`][crate::FontDialog] and [`FontDialogButton`][crate::FontDialogButton] instead
1337 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1338 pub fn show_preview_entry(self, show_preview_entry: bool) -> Self {
1339 Self {
1340 builder: self
1341 .builder
1342 .property("show-preview-entry", show_preview_entry),
1343 }
1344 }
1345
1346 // rustdoc-stripper-ignore-next
1347 /// Build the [`FontButton`].
1348 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1349 pub fn build(self) -> FontButton {
1350 assert_initialized_main_thread!();
1351 self.builder.build()
1352 }
1353}