gtk/auto/font_chooser_widget.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
5#[cfg(feature = "v3_24")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
7use crate::FontChooserLevel;
8use crate::{
9 Align, BaselinePosition, Box, Buildable, Container, FontChooser, Orientable, Orientation,
10 ResizeMode, Widget, ffi,
11};
12use glib::{
13 prelude::*,
14 signal::{SignalHandlerId, connect_raw},
15 translate::*,
16};
17use std::boxed::Box as Box_;
18
19glib::wrapper! {
20 /// The [`FontChooserWidget`][crate::FontChooserWidget] widget lists the available fonts,
21 /// styles and sizes, allowing the user to select a font. It is
22 /// used in the [`FontChooserDialog`][crate::FontChooserDialog] widget to provide a
23 /// dialog box for selecting fonts.
24 ///
25 /// To set the font which is initially selected, use
26 /// [`FontChooserExt::set_font()`][crate::prelude::FontChooserExt::set_font()] or [`FontChooserExt::set_font_desc()`][crate::prelude::FontChooserExt::set_font_desc()].
27 ///
28 /// To get the selected font use [`FontChooserExt::font()`][crate::prelude::FontChooserExt::font()] or
29 /// [`FontChooserExt::font_desc()`][crate::prelude::FontChooserExt::font_desc()].
30 ///
31 /// To change the text which is shown in the preview area, use
32 /// [`FontChooserExt::set_preview_text()`][crate::prelude::FontChooserExt::set_preview_text()].
33 ///
34 /// # CSS nodes
35 ///
36 /// GtkFontChooserWidget has a single CSS node with name fontchooser.
37 ///
38 /// ## Properties
39 ///
40 ///
41 /// #### `tweak-action`
42 /// A toggle action that can be used to switch to the tweak page
43 /// of the font chooser widget, which lets the user tweak the
44 /// OpenType features and variation axes of the selected font.
45 ///
46 /// The action will be enabled or disabled depending on whether
47 /// the selected font has any features or axes.
48 ///
49 /// Readable
50 /// <details><summary><h4>Box</h4></summary>
51 ///
52 ///
53 /// #### `baseline-position`
54 /// Readable | Writable
55 ///
56 ///
57 /// #### `homogeneous`
58 /// Readable | Writable
59 ///
60 ///
61 /// #### `spacing`
62 /// Readable | Writable
63 /// </details>
64 /// <details><summary><h4>Container</h4></summary>
65 ///
66 ///
67 /// #### `border-width`
68 /// Readable | Writable
69 ///
70 ///
71 /// #### `child`
72 /// Writable
73 ///
74 ///
75 /// #### `resize-mode`
76 /// Readable | Writable
77 /// </details>
78 /// <details><summary><h4>Widget</h4></summary>
79 ///
80 ///
81 /// #### `app-paintable`
82 /// Readable | Writable
83 ///
84 ///
85 /// #### `can-default`
86 /// Readable | Writable
87 ///
88 ///
89 /// #### `can-focus`
90 /// Readable | Writable
91 ///
92 ///
93 /// #### `composite-child`
94 /// Readable
95 ///
96 ///
97 /// #### `double-buffered`
98 /// Whether the widget is double buffered.
99 ///
100 /// Readable | Writable
101 ///
102 ///
103 /// #### `events`
104 /// Readable | Writable
105 ///
106 ///
107 /// #### `expand`
108 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
109 ///
110 /// Readable | Writable
111 ///
112 ///
113 /// #### `focus-on-click`
114 /// Whether the widget should grab focus when it is clicked with the mouse.
115 ///
116 /// This property is only relevant for widgets that can take focus.
117 ///
118 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
119 /// GtkComboBox) implemented this property individually.
120 ///
121 /// Readable | Writable
122 ///
123 ///
124 /// #### `halign`
125 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
126 ///
127 /// Readable | Writable
128 ///
129 ///
130 /// #### `has-default`
131 /// Readable | Writable
132 ///
133 ///
134 /// #### `has-focus`
135 /// Readable | Writable
136 ///
137 ///
138 /// #### `has-tooltip`
139 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
140 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
141 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
142 /// whether it will provide a tooltip or not.
143 ///
144 /// Note that setting this property to [`true`] for the first time will change
145 /// the event masks of the GdkWindows of this widget to include leave-notify
146 /// and motion-notify events. This cannot and will not be undone when the
147 /// property is set to [`false`] again.
148 ///
149 /// Readable | Writable
150 ///
151 ///
152 /// #### `height-request`
153 /// Readable | Writable
154 ///
155 ///
156 /// #### `hexpand`
157 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
158 ///
159 /// Readable | Writable
160 ///
161 ///
162 /// #### `hexpand-set`
163 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
164 ///
165 /// Readable | Writable
166 ///
167 ///
168 /// #### `is-focus`
169 /// Readable | Writable
170 ///
171 ///
172 /// #### `margin`
173 /// Sets all four sides' margin at once. If read, returns max
174 /// margin on any side.
175 ///
176 /// Readable | Writable
177 ///
178 ///
179 /// #### `margin-bottom`
180 /// Margin on bottom side of widget.
181 ///
182 /// This property adds margin outside of the widget's normal size
183 /// request, the margin will be added in addition to the size from
184 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
185 ///
186 /// Readable | Writable
187 ///
188 ///
189 /// #### `margin-end`
190 /// Margin on end of widget, horizontally. This property supports
191 /// left-to-right and right-to-left text directions.
192 ///
193 /// This property adds margin outside of the widget's normal size
194 /// request, the margin will be added in addition to the size from
195 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
196 ///
197 /// Readable | Writable
198 ///
199 ///
200 /// #### `margin-left`
201 /// Margin on left side of widget.
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 | Writable
208 ///
209 ///
210 /// #### `margin-right`
211 /// Margin on right side of widget.
212 ///
213 /// This property adds margin outside of the widget's normal size
214 /// request, the margin will be added in addition to the size from
215 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
216 ///
217 /// Readable | Writable
218 ///
219 ///
220 /// #### `margin-start`
221 /// Margin on start of widget, horizontally. This property supports
222 /// left-to-right and right-to-left text directions.
223 ///
224 /// This property adds margin outside of the widget's normal size
225 /// request, the margin will be added in addition to the size from
226 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
227 ///
228 /// Readable | Writable
229 ///
230 ///
231 /// #### `margin-top`
232 /// Margin on top side of widget.
233 ///
234 /// This property adds margin outside of the widget's normal size
235 /// request, the margin will be added in addition to the size from
236 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
237 ///
238 /// Readable | Writable
239 ///
240 ///
241 /// #### `name`
242 /// Readable | Writable
243 ///
244 ///
245 /// #### `no-show-all`
246 /// Readable | Writable
247 ///
248 ///
249 /// #### `opacity`
250 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
251 /// more details about window opacity.
252 ///
253 /// Before 3.8 this was only available in GtkWindow
254 ///
255 /// Readable | Writable
256 ///
257 ///
258 /// #### `parent`
259 /// Readable | Writable
260 ///
261 ///
262 /// #### `receives-default`
263 /// Readable | Writable
264 ///
265 ///
266 /// #### `scale-factor`
267 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
268 /// more details about widget scaling.
269 ///
270 /// Readable
271 ///
272 ///
273 /// #### `sensitive`
274 /// Readable | Writable
275 ///
276 ///
277 /// #### `style`
278 /// The style of the widget, which contains information about how it will look (colors, etc).
279 ///
280 /// Readable | Writable
281 ///
282 ///
283 /// #### `tooltip-markup`
284 /// Sets the text of tooltip to be the given string, which is marked up
285 /// with the [Pango text markup language][PangoMarkupFormat].
286 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
287 ///
288 /// This is a convenience property which will take care of getting the
289 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
290 /// will automatically be set to [`true`] and there will be taken care of
291 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
292 ///
293 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
294 /// are set, the last one wins.
295 ///
296 /// Readable | Writable
297 ///
298 ///
299 /// #### `tooltip-text`
300 /// Sets the text of tooltip to be the given string.
301 ///
302 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
303 ///
304 /// This is a convenience property which will take care of getting the
305 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
306 /// will automatically be set to [`true`] and there will be taken care of
307 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
308 ///
309 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
310 /// are set, the last one wins.
311 ///
312 /// Readable | Writable
313 ///
314 ///
315 /// #### `valign`
316 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
317 ///
318 /// Readable | Writable
319 ///
320 ///
321 /// #### `vexpand`
322 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
323 ///
324 /// Readable | Writable
325 ///
326 ///
327 /// #### `vexpand-set`
328 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
329 ///
330 /// Readable | Writable
331 ///
332 ///
333 /// #### `visible`
334 /// Readable | Writable
335 ///
336 ///
337 /// #### `width-request`
338 /// Readable | Writable
339 ///
340 ///
341 /// #### `window`
342 /// The widget's window if it is realized, [`None`] otherwise.
343 ///
344 /// Readable
345 /// </details>
346 /// <details><summary><h4>Orientable</h4></summary>
347 ///
348 ///
349 /// #### `orientation`
350 /// The orientation of the orientable.
351 ///
352 /// Readable | Writable
353 /// </details>
354 /// <details><summary><h4>FontChooser</h4></summary>
355 ///
356 ///
357 /// #### `font`
358 /// The font description as a string, e.g. "Sans Italic 12".
359 ///
360 /// Readable | Writable
361 ///
362 ///
363 /// #### `font-desc`
364 /// The font description as a [`pango::FontDescription`][crate::pango::FontDescription].
365 ///
366 /// Readable | Writable
367 ///
368 ///
369 /// #### `font-features`
370 /// The selected font features, in a format that is compatible with
371 /// CSS and with Pango attributes.
372 ///
373 /// Readable
374 ///
375 ///
376 /// #### `language`
377 /// The language for which the [`font-features`][struct@crate::FontChooser#font-features] were
378 /// selected, in a format that is compatible with CSS and with Pango
379 /// attributes.
380 ///
381 /// Readable | Writable
382 ///
383 ///
384 /// #### `level`
385 /// The level of granularity to offer for selecting fonts.
386 ///
387 /// Readable | Writable
388 ///
389 ///
390 /// #### `preview-text`
391 /// The string with which to preview the font.
392 ///
393 /// Readable | Writable
394 ///
395 ///
396 /// #### `show-preview-entry`
397 /// Whether to show an entry to change the preview text.
398 ///
399 /// Readable | Writable
400 /// </details>
401 ///
402 /// # Implements
403 ///
404 /// [`FontChooserWidgetExt`][trait@crate::prelude::FontChooserWidgetExt], [`BoxExt`][trait@crate::prelude::BoxExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`FontChooserExt`][trait@crate::prelude::FontChooserExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
405 #[doc(alias = "GtkFontChooserWidget")]
406 pub struct FontChooserWidget(Object<ffi::GtkFontChooserWidget, ffi::GtkFontChooserWidgetClass>) @extends Box, Container, Widget, @implements Buildable, Orientable, FontChooser;
407
408 match fn {
409 type_ => || ffi::gtk_font_chooser_widget_get_type(),
410 }
411}
412
413impl FontChooserWidget {
414 pub const NONE: Option<&'static FontChooserWidget> = None;
415
416 /// Creates a new [`FontChooserWidget`][crate::FontChooserWidget].
417 ///
418 /// # Returns
419 ///
420 /// a new [`FontChooserWidget`][crate::FontChooserWidget]
421 #[doc(alias = "gtk_font_chooser_widget_new")]
422 pub fn new() -> FontChooserWidget {
423 assert_initialized_main_thread!();
424 unsafe { Widget::from_glib_none(ffi::gtk_font_chooser_widget_new()).unsafe_cast() }
425 }
426
427 // rustdoc-stripper-ignore-next
428 /// Creates a new builder-pattern struct instance to construct [`FontChooserWidget`] objects.
429 ///
430 /// This method returns an instance of [`FontChooserWidgetBuilder`](crate::builders::FontChooserWidgetBuilder) which can be used to create [`FontChooserWidget`] objects.
431 pub fn builder() -> FontChooserWidgetBuilder {
432 FontChooserWidgetBuilder::new()
433 }
434}
435
436impl Default for FontChooserWidget {
437 fn default() -> Self {
438 Self::new()
439 }
440}
441
442// rustdoc-stripper-ignore-next
443/// A [builder-pattern] type to construct [`FontChooserWidget`] objects.
444///
445/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
446#[must_use = "The builder must be built to be used"]
447pub struct FontChooserWidgetBuilder {
448 builder: glib::object::ObjectBuilder<'static, FontChooserWidget>,
449}
450
451impl FontChooserWidgetBuilder {
452 fn new() -> Self {
453 Self {
454 builder: glib::object::Object::builder(),
455 }
456 }
457
458 pub fn baseline_position(self, baseline_position: BaselinePosition) -> Self {
459 Self {
460 builder: self
461 .builder
462 .property("baseline-position", baseline_position),
463 }
464 }
465
466 pub fn homogeneous(self, homogeneous: bool) -> Self {
467 Self {
468 builder: self.builder.property("homogeneous", homogeneous),
469 }
470 }
471
472 pub fn spacing(self, spacing: i32) -> Self {
473 Self {
474 builder: self.builder.property("spacing", spacing),
475 }
476 }
477
478 pub fn border_width(self, border_width: u32) -> Self {
479 Self {
480 builder: self.builder.property("border-width", border_width),
481 }
482 }
483
484 pub fn child(self, child: &impl IsA<Widget>) -> Self {
485 Self {
486 builder: self.builder.property("child", child.clone().upcast()),
487 }
488 }
489
490 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
491 Self {
492 builder: self.builder.property("resize-mode", resize_mode),
493 }
494 }
495
496 pub fn app_paintable(self, app_paintable: bool) -> Self {
497 Self {
498 builder: self.builder.property("app-paintable", app_paintable),
499 }
500 }
501
502 pub fn can_default(self, can_default: bool) -> Self {
503 Self {
504 builder: self.builder.property("can-default", can_default),
505 }
506 }
507
508 pub fn can_focus(self, can_focus: bool) -> Self {
509 Self {
510 builder: self.builder.property("can-focus", can_focus),
511 }
512 }
513
514 pub fn events(self, events: gdk::EventMask) -> Self {
515 Self {
516 builder: self.builder.property("events", events),
517 }
518 }
519
520 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
521 pub fn expand(self, expand: bool) -> Self {
522 Self {
523 builder: self.builder.property("expand", expand),
524 }
525 }
526
527 /// Whether the widget should grab focus when it is clicked with the mouse.
528 ///
529 /// This property is only relevant for widgets that can take focus.
530 ///
531 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
532 /// GtkComboBox) implemented this property individually.
533 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
534 Self {
535 builder: self.builder.property("focus-on-click", focus_on_click),
536 }
537 }
538
539 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
540 pub fn halign(self, halign: Align) -> Self {
541 Self {
542 builder: self.builder.property("halign", halign),
543 }
544 }
545
546 pub fn has_default(self, has_default: bool) -> Self {
547 Self {
548 builder: self.builder.property("has-default", has_default),
549 }
550 }
551
552 pub fn has_focus(self, has_focus: bool) -> Self {
553 Self {
554 builder: self.builder.property("has-focus", has_focus),
555 }
556 }
557
558 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
559 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
560 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
561 /// whether it will provide a tooltip or not.
562 ///
563 /// Note that setting this property to [`true`] for the first time will change
564 /// the event masks of the GdkWindows of this widget to include leave-notify
565 /// and motion-notify events. This cannot and will not be undone when the
566 /// property is set to [`false`] again.
567 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
568 Self {
569 builder: self.builder.property("has-tooltip", has_tooltip),
570 }
571 }
572
573 pub fn height_request(self, height_request: i32) -> Self {
574 Self {
575 builder: self.builder.property("height-request", height_request),
576 }
577 }
578
579 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
580 pub fn hexpand(self, hexpand: bool) -> Self {
581 Self {
582 builder: self.builder.property("hexpand", hexpand),
583 }
584 }
585
586 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
587 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
588 Self {
589 builder: self.builder.property("hexpand-set", hexpand_set),
590 }
591 }
592
593 pub fn is_focus(self, is_focus: bool) -> Self {
594 Self {
595 builder: self.builder.property("is-focus", is_focus),
596 }
597 }
598
599 /// Sets all four sides' margin at once. If read, returns max
600 /// margin on any side.
601 pub fn margin(self, margin: i32) -> Self {
602 Self {
603 builder: self.builder.property("margin", margin),
604 }
605 }
606
607 /// Margin on bottom side of widget.
608 ///
609 /// This property adds margin outside of the widget's normal size
610 /// request, the margin will be added in addition to the size from
611 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
612 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
613 Self {
614 builder: self.builder.property("margin-bottom", margin_bottom),
615 }
616 }
617
618 /// Margin on end of widget, horizontally. This property supports
619 /// left-to-right and right-to-left text directions.
620 ///
621 /// This property adds margin outside of the widget's normal size
622 /// request, the margin will be added in addition to the size from
623 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
624 pub fn margin_end(self, margin_end: i32) -> Self {
625 Self {
626 builder: self.builder.property("margin-end", margin_end),
627 }
628 }
629
630 /// Margin on start of widget, horizontally. This property supports
631 /// left-to-right and right-to-left text directions.
632 ///
633 /// This property adds margin outside of the widget's normal size
634 /// request, the margin will be added in addition to the size from
635 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
636 pub fn margin_start(self, margin_start: i32) -> Self {
637 Self {
638 builder: self.builder.property("margin-start", margin_start),
639 }
640 }
641
642 /// Margin on top side of widget.
643 ///
644 /// This property adds margin outside of the widget's normal size
645 /// request, the margin will be added in addition to the size from
646 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
647 pub fn margin_top(self, margin_top: i32) -> Self {
648 Self {
649 builder: self.builder.property("margin-top", margin_top),
650 }
651 }
652
653 pub fn name(self, name: impl Into<glib::GString>) -> Self {
654 Self {
655 builder: self.builder.property("name", name.into()),
656 }
657 }
658
659 pub fn no_show_all(self, no_show_all: bool) -> Self {
660 Self {
661 builder: self.builder.property("no-show-all", no_show_all),
662 }
663 }
664
665 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
666 /// more details about window opacity.
667 ///
668 /// Before 3.8 this was only available in GtkWindow
669 pub fn opacity(self, opacity: f64) -> Self {
670 Self {
671 builder: self.builder.property("opacity", opacity),
672 }
673 }
674
675 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
676 Self {
677 builder: self.builder.property("parent", parent.clone().upcast()),
678 }
679 }
680
681 pub fn receives_default(self, receives_default: bool) -> Self {
682 Self {
683 builder: self.builder.property("receives-default", receives_default),
684 }
685 }
686
687 pub fn sensitive(self, sensitive: bool) -> Self {
688 Self {
689 builder: self.builder.property("sensitive", sensitive),
690 }
691 }
692
693 /// Sets the text of tooltip to be the given string, which is marked up
694 /// with the [Pango text markup language][PangoMarkupFormat].
695 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
696 ///
697 /// This is a convenience property which will take care of getting the
698 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
699 /// will automatically be set to [`true`] and there will be taken care of
700 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
701 ///
702 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
703 /// are set, the last one wins.
704 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
705 Self {
706 builder: self
707 .builder
708 .property("tooltip-markup", tooltip_markup.into()),
709 }
710 }
711
712 /// Sets the text of tooltip to be the given string.
713 ///
714 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
715 ///
716 /// This is a convenience property which will take care of getting the
717 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
718 /// will automatically be set to [`true`] and there will be taken care of
719 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
720 ///
721 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
722 /// are set, the last one wins.
723 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
724 Self {
725 builder: self.builder.property("tooltip-text", tooltip_text.into()),
726 }
727 }
728
729 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
730 pub fn valign(self, valign: Align) -> Self {
731 Self {
732 builder: self.builder.property("valign", valign),
733 }
734 }
735
736 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
737 pub fn vexpand(self, vexpand: bool) -> Self {
738 Self {
739 builder: self.builder.property("vexpand", vexpand),
740 }
741 }
742
743 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
744 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
745 Self {
746 builder: self.builder.property("vexpand-set", vexpand_set),
747 }
748 }
749
750 pub fn visible(self, visible: bool) -> Self {
751 Self {
752 builder: self.builder.property("visible", visible),
753 }
754 }
755
756 pub fn width_request(self, width_request: i32) -> Self {
757 Self {
758 builder: self.builder.property("width-request", width_request),
759 }
760 }
761
762 /// The orientation of the orientable.
763 pub fn orientation(self, orientation: Orientation) -> Self {
764 Self {
765 builder: self.builder.property("orientation", orientation),
766 }
767 }
768
769 /// The font description as a string, e.g. "Sans Italic 12".
770 pub fn font(self, font: impl Into<glib::GString>) -> Self {
771 Self {
772 builder: self.builder.property("font", font.into()),
773 }
774 }
775
776 /// The font description as a [`pango::FontDescription`][crate::pango::FontDescription].
777 pub fn font_desc(self, font_desc: &pango::FontDescription) -> Self {
778 Self {
779 builder: self.builder.property("font-desc", font_desc),
780 }
781 }
782
783 /// The language for which the [`font-features`][struct@crate::FontChooser#font-features] were
784 /// selected, in a format that is compatible with CSS and with Pango
785 /// attributes.
786 #[cfg(feature = "v3_24")]
787 #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
788 pub fn language(self, language: impl Into<glib::GString>) -> Self {
789 Self {
790 builder: self.builder.property("language", language.into()),
791 }
792 }
793
794 /// The level of granularity to offer for selecting fonts.
795 #[cfg(feature = "v3_24")]
796 #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
797 pub fn level(self, level: FontChooserLevel) -> Self {
798 Self {
799 builder: self.builder.property("level", level),
800 }
801 }
802
803 /// The string with which to preview the font.
804 pub fn preview_text(self, preview_text: impl Into<glib::GString>) -> Self {
805 Self {
806 builder: self.builder.property("preview-text", preview_text.into()),
807 }
808 }
809
810 /// Whether to show an entry to change the preview text.
811 pub fn show_preview_entry(self, show_preview_entry: bool) -> Self {
812 Self {
813 builder: self
814 .builder
815 .property("show-preview-entry", show_preview_entry),
816 }
817 }
818
819 // rustdoc-stripper-ignore-next
820 /// Build the [`FontChooserWidget`].
821 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
822 pub fn build(self) -> FontChooserWidget {
823 assert_initialized_main_thread!();
824 self.builder.build()
825 }
826}
827
828/// Trait containing all [`struct@FontChooserWidget`] methods.
829///
830/// # Implementors
831///
832/// [`FontChooserWidget`][struct@crate::FontChooserWidget]
833pub trait FontChooserWidgetExt: IsA<FontChooserWidget> + 'static {
834 //#[doc(alias = "tweak-action")]
835 //fn tweak_action(&self) -> /*Ignored*/Option<gio::Action> {
836 // ObjectExt::property(self.as_ref(), "tweak-action")
837 //}
838
839 #[doc(alias = "tweak-action")]
840 fn connect_tweak_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
841 unsafe extern "C" fn notify_tweak_action_trampoline<
842 P: IsA<FontChooserWidget>,
843 F: Fn(&P) + 'static,
844 >(
845 this: *mut ffi::GtkFontChooserWidget,
846 _param_spec: glib::ffi::gpointer,
847 f: glib::ffi::gpointer,
848 ) {
849 unsafe {
850 let f: &F = &*(f as *const F);
851 f(FontChooserWidget::from_glib_borrow(this).unsafe_cast_ref())
852 }
853 }
854 unsafe {
855 let f: Box_<F> = Box_::new(f);
856 connect_raw(
857 self.as_ptr() as *mut _,
858 c"notify::tweak-action".as_ptr(),
859 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
860 notify_tweak_action_trampoline::<Self, F> as *const (),
861 )),
862 Box_::into_raw(f),
863 )
864 }
865 }
866}
867
868impl<O: IsA<FontChooserWidget>> FontChooserWidgetExt for O {}