Skip to main content

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