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
6use crate::{
7    Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, FontChooser, FontChooserLevel,
8    LayoutManager, Overflow, Widget, ffi,
9};
10use glib::{
11    object::ObjectType as _,
12    prelude::*,
13    signal::{SignalHandlerId, connect_raw},
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            unsafe {
796                let f: &F = &*(f as *const F);
797                f(&from_glib_borrow(this))
798            }
799        }
800        unsafe {
801            let f: Box_<F> = Box_::new(f);
802            connect_raw(
803                self.as_ptr() as *mut _,
804                c"activate".as_ptr() as *const _,
805                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
806                    activate_trampoline::<F> as *const (),
807                )),
808                Box_::into_raw(f),
809            )
810        }
811    }
812
813    #[cfg(feature = "v4_4")]
814    #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
815    pub fn emit_activate(&self) {
816        self.emit_by_name::<()>("activate", &[]);
817    }
818
819    /// Emitted when the user selects a font.
820    ///
821    /// When handling this signal, use [`FontChooserExt::font()`][crate::prelude::FontChooserExt::font()]
822    /// to find out which font was just selected.
823    ///
824    /// Note that this signal is only emitted when the user changes the font.
825    /// If you need to react to programmatic font changes as well, use
826    /// the notify::font signal.
827    #[doc(alias = "font-set")]
828    pub fn connect_font_set<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
829        unsafe extern "C" fn font_set_trampoline<F: Fn(&FontButton) + 'static>(
830            this: *mut ffi::GtkFontButton,
831            f: glib::ffi::gpointer,
832        ) {
833            unsafe {
834                let f: &F = &*(f as *const F);
835                f(&from_glib_borrow(this))
836            }
837        }
838        unsafe {
839            let f: Box_<F> = Box_::new(f);
840            connect_raw(
841                self.as_ptr() as *mut _,
842                c"font-set".as_ptr() as *const _,
843                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
844                    font_set_trampoline::<F> as *const (),
845                )),
846                Box_::into_raw(f),
847            )
848        }
849    }
850
851    #[doc(alias = "modal")]
852    pub fn connect_modal_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
853        unsafe extern "C" fn notify_modal_trampoline<F: Fn(&FontButton) + 'static>(
854            this: *mut ffi::GtkFontButton,
855            _param_spec: glib::ffi::gpointer,
856            f: glib::ffi::gpointer,
857        ) {
858            unsafe {
859                let f: &F = &*(f as *const F);
860                f(&from_glib_borrow(this))
861            }
862        }
863        unsafe {
864            let f: Box_<F> = Box_::new(f);
865            connect_raw(
866                self.as_ptr() as *mut _,
867                c"notify::modal".as_ptr() as *const _,
868                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
869                    notify_modal_trampoline::<F> as *const (),
870                )),
871                Box_::into_raw(f),
872            )
873        }
874    }
875
876    #[doc(alias = "title")]
877    pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
878        unsafe extern "C" fn notify_title_trampoline<F: Fn(&FontButton) + 'static>(
879            this: *mut ffi::GtkFontButton,
880            _param_spec: glib::ffi::gpointer,
881            f: glib::ffi::gpointer,
882        ) {
883            unsafe {
884                let f: &F = &*(f as *const F);
885                f(&from_glib_borrow(this))
886            }
887        }
888        unsafe {
889            let f: Box_<F> = Box_::new(f);
890            connect_raw(
891                self.as_ptr() as *mut _,
892                c"notify::title".as_ptr() as *const _,
893                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
894                    notify_title_trampoline::<F> as *const (),
895                )),
896                Box_::into_raw(f),
897            )
898        }
899    }
900
901    #[doc(alias = "use-font")]
902    pub fn connect_use_font_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
903        unsafe extern "C" fn notify_use_font_trampoline<F: Fn(&FontButton) + 'static>(
904            this: *mut ffi::GtkFontButton,
905            _param_spec: glib::ffi::gpointer,
906            f: glib::ffi::gpointer,
907        ) {
908            unsafe {
909                let f: &F = &*(f as *const F);
910                f(&from_glib_borrow(this))
911            }
912        }
913        unsafe {
914            let f: Box_<F> = Box_::new(f);
915            connect_raw(
916                self.as_ptr() as *mut _,
917                c"notify::use-font".as_ptr() as *const _,
918                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
919                    notify_use_font_trampoline::<F> as *const (),
920                )),
921                Box_::into_raw(f),
922            )
923        }
924    }
925
926    #[doc(alias = "use-size")]
927    pub fn connect_use_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
928        unsafe extern "C" fn notify_use_size_trampoline<F: Fn(&FontButton) + 'static>(
929            this: *mut ffi::GtkFontButton,
930            _param_spec: glib::ffi::gpointer,
931            f: glib::ffi::gpointer,
932        ) {
933            unsafe {
934                let f: &F = &*(f as *const F);
935                f(&from_glib_borrow(this))
936            }
937        }
938        unsafe {
939            let f: Box_<F> = Box_::new(f);
940            connect_raw(
941                self.as_ptr() as *mut _,
942                c"notify::use-size".as_ptr() as *const _,
943                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
944                    notify_use_size_trampoline::<F> as *const (),
945                )),
946                Box_::into_raw(f),
947            )
948        }
949    }
950}
951
952impl Default for FontButton {
953    fn default() -> Self {
954        Self::new()
955    }
956}
957
958// rustdoc-stripper-ignore-next
959/// A [builder-pattern] type to construct [`FontButton`] objects.
960///
961/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
962#[must_use = "The builder must be built to be used"]
963pub struct FontButtonBuilder {
964    builder: glib::object::ObjectBuilder<'static, FontButton>,
965}
966
967impl FontButtonBuilder {
968    fn new() -> Self {
969        Self {
970            builder: glib::object::Object::builder(),
971        }
972    }
973
974    /// Whether the font chooser dialog should be modal.
975    pub fn modal(self, modal: bool) -> Self {
976        Self {
977            builder: self.builder.property("modal", modal),
978        }
979    }
980
981    /// The title of the font chooser dialog.
982    pub fn title(self, title: impl Into<glib::GString>) -> Self {
983        Self {
984            builder: self.builder.property("title", title.into()),
985        }
986    }
987
988    /// Whether the buttons label will be drawn in the selected font.
989    pub fn use_font(self, use_font: bool) -> Self {
990        Self {
991            builder: self.builder.property("use-font", use_font),
992        }
993    }
994
995    /// Whether the buttons label will use the selected font size.
996    pub fn use_size(self, use_size: bool) -> Self {
997        Self {
998            builder: self.builder.property("use-size", use_size),
999        }
1000    }
1001
1002    /// Whether the widget or any of its descendents can accept
1003    /// the input focus.
1004    ///
1005    /// This property is meant to be set by widget implementations,
1006    /// typically in their instance init function.
1007    pub fn can_focus(self, can_focus: bool) -> Self {
1008        Self {
1009            builder: self.builder.property("can-focus", can_focus),
1010        }
1011    }
1012
1013    /// Whether the widget can receive pointer events.
1014    pub fn can_target(self, can_target: bool) -> Self {
1015        Self {
1016            builder: self.builder.property("can-target", can_target),
1017        }
1018    }
1019
1020    /// A list of css classes applied to this widget.
1021    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1022        Self {
1023            builder: self.builder.property("css-classes", css_classes.into()),
1024        }
1025    }
1026
1027    /// The name of this widget in the CSS tree.
1028    ///
1029    /// This property is meant to be set by widget implementations,
1030    /// typically in their instance init function.
1031    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1032        Self {
1033            builder: self.builder.property("css-name", css_name.into()),
1034        }
1035    }
1036
1037    /// The cursor used by @widget.
1038    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1039        Self {
1040            builder: self.builder.property("cursor", cursor.clone()),
1041        }
1042    }
1043
1044    /// Whether the widget should grab focus when it is clicked with the mouse.
1045    ///
1046    /// This property is only relevant for widgets that can take focus.
1047    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1048        Self {
1049            builder: self.builder.property("focus-on-click", focus_on_click),
1050        }
1051    }
1052
1053    /// Whether this widget itself will accept the input focus.
1054    pub fn focusable(self, focusable: bool) -> Self {
1055        Self {
1056            builder: self.builder.property("focusable", focusable),
1057        }
1058    }
1059
1060    /// How to distribute horizontal space if widget gets extra space.
1061    pub fn halign(self, halign: Align) -> Self {
1062        Self {
1063            builder: self.builder.property("halign", halign),
1064        }
1065    }
1066
1067    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1068    /// signal on @widget.
1069    ///
1070    /// A true value indicates that @widget can have a tooltip, in this case
1071    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1072    /// determine whether it will provide a tooltip or not.
1073    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1074        Self {
1075            builder: self.builder.property("has-tooltip", has_tooltip),
1076        }
1077    }
1078
1079    /// Overrides for height request of the widget.
1080    ///
1081    /// If this is -1, the natural request will be used.
1082    pub fn height_request(self, height_request: i32) -> Self {
1083        Self {
1084            builder: self.builder.property("height-request", height_request),
1085        }
1086    }
1087
1088    /// Whether to expand horizontally.
1089    pub fn hexpand(self, hexpand: bool) -> Self {
1090        Self {
1091            builder: self.builder.property("hexpand", hexpand),
1092        }
1093    }
1094
1095    /// Whether to use the `hexpand` property.
1096    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1097        Self {
1098            builder: self.builder.property("hexpand-set", hexpand_set),
1099        }
1100    }
1101
1102    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1103    /// the preferred size of the widget, and allocate its children.
1104    ///
1105    /// This property is meant to be set by widget implementations,
1106    /// typically in their instance init function.
1107    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1108        Self {
1109            builder: self
1110                .builder
1111                .property("layout-manager", layout_manager.clone().upcast()),
1112        }
1113    }
1114
1115    /// Makes this widget act like a modal dialog, with respect to
1116    /// event delivery.
1117    ///
1118    /// Global event controllers will not handle events with targets
1119    /// inside the widget, unless they are set up to ignore propagation
1120    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1121    #[cfg(feature = "v4_18")]
1122    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1123    pub fn limit_events(self, limit_events: bool) -> Self {
1124        Self {
1125            builder: self.builder.property("limit-events", limit_events),
1126        }
1127    }
1128
1129    /// Margin on bottom side of widget.
1130    ///
1131    /// This property adds margin outside of the widget's normal size
1132    /// request, the margin will be added in addition to the size from
1133    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1134    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1135        Self {
1136            builder: self.builder.property("margin-bottom", margin_bottom),
1137        }
1138    }
1139
1140    /// Margin on end of widget, horizontally.
1141    ///
1142    /// This property supports left-to-right and right-to-left text
1143    /// directions.
1144    ///
1145    /// This property adds margin outside of the widget's normal size
1146    /// request, the margin will be added in addition to the size from
1147    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1148    pub fn margin_end(self, margin_end: i32) -> Self {
1149        Self {
1150            builder: self.builder.property("margin-end", margin_end),
1151        }
1152    }
1153
1154    /// Margin on start of widget, horizontally.
1155    ///
1156    /// This property supports left-to-right and right-to-left text
1157    /// directions.
1158    ///
1159    /// This property adds margin outside of the widget's normal size
1160    /// request, the margin will be added in addition to the size from
1161    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1162    pub fn margin_start(self, margin_start: i32) -> Self {
1163        Self {
1164            builder: self.builder.property("margin-start", margin_start),
1165        }
1166    }
1167
1168    /// Margin on top side of widget.
1169    ///
1170    /// This property adds margin outside of the widget's normal size
1171    /// request, the margin will be added in addition to the size from
1172    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1173    pub fn margin_top(self, margin_top: i32) -> Self {
1174        Self {
1175            builder: self.builder.property("margin-top", margin_top),
1176        }
1177    }
1178
1179    /// The name of the widget.
1180    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1181        Self {
1182            builder: self.builder.property("name", name.into()),
1183        }
1184    }
1185
1186    /// The requested opacity of the widget.
1187    pub fn opacity(self, opacity: f64) -> Self {
1188        Self {
1189            builder: self.builder.property("opacity", opacity),
1190        }
1191    }
1192
1193    /// How content outside the widget's content area is treated.
1194    ///
1195    /// This property is meant to be set by widget implementations,
1196    /// typically in their instance init function.
1197    pub fn overflow(self, overflow: Overflow) -> Self {
1198        Self {
1199            builder: self.builder.property("overflow", overflow),
1200        }
1201    }
1202
1203    /// Whether the widget will receive the default action when it is focused.
1204    pub fn receives_default(self, receives_default: bool) -> Self {
1205        Self {
1206            builder: self.builder.property("receives-default", receives_default),
1207        }
1208    }
1209
1210    /// Whether the widget responds to input.
1211    pub fn sensitive(self, sensitive: bool) -> Self {
1212        Self {
1213            builder: self.builder.property("sensitive", sensitive),
1214        }
1215    }
1216
1217    /// Sets the text of tooltip to be the given string, which is marked up
1218    /// with Pango markup.
1219    ///
1220    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1221    ///
1222    /// This is a convenience property which will take care of getting the
1223    /// tooltip shown if the given string is not `NULL`:
1224    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1225    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1226    /// the default signal handler.
1227    ///
1228    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1229    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1230    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1231        Self {
1232            builder: self
1233                .builder
1234                .property("tooltip-markup", tooltip_markup.into()),
1235        }
1236    }
1237
1238    /// Sets the text of tooltip to be the given string.
1239    ///
1240    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1241    ///
1242    /// This is a convenience property which will take care of getting the
1243    /// tooltip shown if the given string is not `NULL`:
1244    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1245    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1246    /// the default signal handler.
1247    ///
1248    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1249    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1250    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1251        Self {
1252            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1253        }
1254    }
1255
1256    /// How to distribute vertical space if widget gets extra space.
1257    pub fn valign(self, valign: Align) -> Self {
1258        Self {
1259            builder: self.builder.property("valign", valign),
1260        }
1261    }
1262
1263    /// Whether to expand vertically.
1264    pub fn vexpand(self, vexpand: bool) -> Self {
1265        Self {
1266            builder: self.builder.property("vexpand", vexpand),
1267        }
1268    }
1269
1270    /// Whether to use the `vexpand` property.
1271    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1272        Self {
1273            builder: self.builder.property("vexpand-set", vexpand_set),
1274        }
1275    }
1276
1277    /// Whether the widget is visible.
1278    pub fn visible(self, visible: bool) -> Self {
1279        Self {
1280            builder: self.builder.property("visible", visible),
1281        }
1282    }
1283
1284    /// Overrides for width request of the widget.
1285    ///
1286    /// If this is -1, the natural request will be used.
1287    pub fn width_request(self, width_request: i32) -> Self {
1288        Self {
1289            builder: self.builder.property("width-request", width_request),
1290        }
1291    }
1292
1293    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1294    ///
1295    /// The accessible role cannot be changed once set.
1296    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1297        Self {
1298            builder: self.builder.property("accessible-role", accessible_role),
1299        }
1300    }
1301
1302    /// The font description as a string, e.g. "Sans Italic 12".
1303    /// Use [`FontDialog`][crate::FontDialog] and [`FontDialogButton`][crate::FontDialogButton] instead
1304    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1305    pub fn font(self, font: impl Into<glib::GString>) -> Self {
1306        Self {
1307            builder: self.builder.property("font", font.into()),
1308        }
1309    }
1310
1311    /// The font description as a [`pango::FontDescription`][crate::pango::FontDescription].
1312    /// Use [`FontDialog`][crate::FontDialog] and [`FontDialogButton`][crate::FontDialogButton] instead
1313    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1314    pub fn font_desc(self, font_desc: &pango::FontDescription) -> Self {
1315        Self {
1316            builder: self.builder.property("font-desc", font_desc),
1317        }
1318    }
1319
1320    /// The language for which the font features were selected.
1321    /// Use [`FontDialog`][crate::FontDialog] and [`FontDialogButton`][crate::FontDialogButton] instead
1322    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1323    pub fn language(self, language: impl Into<glib::GString>) -> Self {
1324        Self {
1325            builder: self.builder.property("language", language.into()),
1326        }
1327    }
1328
1329    /// The level of granularity to offer for selecting fonts.
1330    /// Use [`FontDialog`][crate::FontDialog] and [`FontDialogButton`][crate::FontDialogButton] instead
1331    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1332    pub fn level(self, level: FontChooserLevel) -> Self {
1333        Self {
1334            builder: self.builder.property("level", level),
1335        }
1336    }
1337
1338    /// The string with which to preview the font.
1339    /// Use [`FontDialog`][crate::FontDialog] and [`FontDialogButton`][crate::FontDialogButton] instead
1340    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1341    pub fn preview_text(self, preview_text: impl Into<glib::GString>) -> Self {
1342        Self {
1343            builder: self.builder.property("preview-text", preview_text.into()),
1344        }
1345    }
1346
1347    /// Whether to show an entry to change the preview text.
1348    /// Use [`FontDialog`][crate::FontDialog] and [`FontDialogButton`][crate::FontDialogButton] instead
1349    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1350    pub fn show_preview_entry(self, show_preview_entry: bool) -> Self {
1351        Self {
1352            builder: self
1353                .builder
1354                .property("show-preview-entry", show_preview_entry),
1355        }
1356    }
1357
1358    // rustdoc-stripper-ignore-next
1359    /// Build the [`FontButton`].
1360    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1361    pub fn build(self) -> FontButton {
1362        assert_initialized_main_thread!();
1363        self.builder.build()
1364    }
1365}