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