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