gtk/auto/frame.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
5use crate::{Align, Bin, Buildable, Container, ResizeMode, ShadowType, Widget};
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::{boxed::Box as Box_, fmt, mem, mem::transmute};
12
13glib::wrapper! {
14 /// The frame widget is a bin that surrounds its child with a decorative
15 /// frame and an optional label. If present, the label is drawn in a gap
16 /// in the top side of the frame. The position of the label can be
17 /// controlled with [`FrameExt::set_label_align()`][crate::prelude::FrameExt::set_label_align()].
18 ///
19 /// # GtkFrame as GtkBuildable
20 ///
21 /// The GtkFrame implementation of the [`Buildable`][crate::Buildable] interface supports
22 /// placing a child in the label position by specifying “label” as the
23 /// “type” attribute of a ``<child>`` element. A normal content child can
24 /// be specified without specifying a ``<child>`` type attribute.
25 ///
26 /// An example of a UI definition fragment with [`Frame`][crate::Frame]:
27 ///
28 ///
29 ///
30 /// **⚠️ The following code is in xml ⚠️**
31 ///
32 /// ```xml
33 /// <object class="GtkFrame">
34 /// <child type="label">
35 /// <object class="GtkLabel" id="frame-label"/>
36 /// </child>
37 /// <child>
38 /// <object class="GtkEntry" id="frame-content"/>
39 /// </child>
40 /// </object>
41 /// ```
42 ///
43 /// # CSS nodes
44 ///
45 ///
46 ///
47 /// **⚠️ The following code is in plain ⚠️**
48 ///
49 /// ```plain
50 /// frame
51 /// ├── border[.flat]
52 /// ├── <label widget>
53 /// ╰── <child>
54 /// ```
55 ///
56 /// GtkFrame has a main CSS node named “frame” and a subnode named “border”. The
57 /// “border” node is used to draw the visible border. You can set the appearance
58 /// of the border using CSS properties like “border-style” on the “border” node.
59 ///
60 /// The border node can be given the style class “.flat”, which is used by themes
61 /// to disable drawing of the border. To do this from code, call
62 /// [`FrameExt::set_shadow_type()`][crate::prelude::FrameExt::set_shadow_type()] with [`ShadowType::None`][crate::ShadowType::None] to add the “.flat” class or
63 /// any other shadow type to remove it.
64 ///
65 /// ## Properties
66 ///
67 ///
68 /// #### `label`
69 /// Readable | Writeable
70 ///
71 ///
72 /// #### `label-widget`
73 /// Readable | Writeable
74 ///
75 ///
76 /// #### `label-xalign`
77 /// Readable | Writeable
78 ///
79 ///
80 /// #### `label-yalign`
81 /// Readable | Writeable
82 ///
83 ///
84 /// #### `shadow-type`
85 /// Readable | Writeable
86 /// <details><summary><h4>Container</h4></summary>
87 ///
88 ///
89 /// #### `border-width`
90 /// Readable | Writeable
91 ///
92 ///
93 /// #### `child`
94 /// Writeable
95 ///
96 ///
97 /// #### `resize-mode`
98 /// Readable | Writeable
99 /// </details>
100 /// <details><summary><h4>Widget</h4></summary>
101 ///
102 ///
103 /// #### `app-paintable`
104 /// Readable | Writeable
105 ///
106 ///
107 /// #### `can-default`
108 /// Readable | Writeable
109 ///
110 ///
111 /// #### `can-focus`
112 /// Readable | Writeable
113 ///
114 ///
115 /// #### `composite-child`
116 /// Readable
117 ///
118 ///
119 /// #### `double-buffered`
120 /// Whether the widget is double buffered.
121 ///
122 /// Readable | Writeable
123 ///
124 ///
125 /// #### `events`
126 /// Readable | Writeable
127 ///
128 ///
129 /// #### `expand`
130 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
131 ///
132 /// Readable | Writeable
133 ///
134 ///
135 /// #### `focus-on-click`
136 /// Whether the widget should grab focus when it is clicked with the mouse.
137 ///
138 /// This property is only relevant for widgets that can take focus.
139 ///
140 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
141 /// GtkComboBox) implemented this property individually.
142 ///
143 /// Readable | Writeable
144 ///
145 ///
146 /// #### `halign`
147 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
148 ///
149 /// Readable | Writeable
150 ///
151 ///
152 /// #### `has-default`
153 /// Readable | Writeable
154 ///
155 ///
156 /// #### `has-focus`
157 /// Readable | Writeable
158 ///
159 ///
160 /// #### `has-tooltip`
161 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
162 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
163 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
164 /// whether it will provide a tooltip or not.
165 ///
166 /// Note that setting this property to [`true`] for the first time will change
167 /// the event masks of the GdkWindows of this widget to include leave-notify
168 /// and motion-notify events. This cannot and will not be undone when the
169 /// property is set to [`false`] again.
170 ///
171 /// Readable | Writeable
172 ///
173 ///
174 /// #### `height-request`
175 /// Readable | Writeable
176 ///
177 ///
178 /// #### `hexpand`
179 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
180 ///
181 /// Readable | Writeable
182 ///
183 ///
184 /// #### `hexpand-set`
185 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
186 ///
187 /// Readable | Writeable
188 ///
189 ///
190 /// #### `is-focus`
191 /// Readable | Writeable
192 ///
193 ///
194 /// #### `margin`
195 /// Sets all four sides' margin at once. If read, returns max
196 /// margin on any side.
197 ///
198 /// Readable | Writeable
199 ///
200 ///
201 /// #### `margin-bottom`
202 /// Margin on bottom side of widget.
203 ///
204 /// This property adds margin outside of the widget's normal size
205 /// request, the margin will be added in addition to the size from
206 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
207 ///
208 /// Readable | Writeable
209 ///
210 ///
211 /// #### `margin-end`
212 /// Margin on end of widget, horizontally. This property supports
213 /// left-to-right and right-to-left text directions.
214 ///
215 /// This property adds margin outside of the widget's normal size
216 /// request, the margin will be added in addition to the size from
217 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
218 ///
219 /// Readable | Writeable
220 ///
221 ///
222 /// #### `margin-left`
223 /// Margin on left side of widget.
224 ///
225 /// This property adds margin outside of the widget's normal size
226 /// request, the margin will be added in addition to the size from
227 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
228 ///
229 /// Readable | Writeable
230 ///
231 ///
232 /// #### `margin-right`
233 /// Margin on right side of widget.
234 ///
235 /// This property adds margin outside of the widget's normal size
236 /// request, the margin will be added in addition to the size from
237 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
238 ///
239 /// Readable | Writeable
240 ///
241 ///
242 /// #### `margin-start`
243 /// Margin on start of widget, horizontally. This property supports
244 /// left-to-right and right-to-left text directions.
245 ///
246 /// This property adds margin outside of the widget's normal size
247 /// request, the margin will be added in addition to the size from
248 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
249 ///
250 /// Readable | Writeable
251 ///
252 ///
253 /// #### `margin-top`
254 /// Margin on top side of widget.
255 ///
256 /// This property adds margin outside of the widget's normal size
257 /// request, the margin will be added in addition to the size from
258 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
259 ///
260 /// Readable | Writeable
261 ///
262 ///
263 /// #### `name`
264 /// Readable | Writeable
265 ///
266 ///
267 /// #### `no-show-all`
268 /// Readable | Writeable
269 ///
270 ///
271 /// #### `opacity`
272 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
273 /// more details about window opacity.
274 ///
275 /// Before 3.8 this was only available in GtkWindow
276 ///
277 /// Readable | Writeable
278 ///
279 ///
280 /// #### `parent`
281 /// Readable | Writeable
282 ///
283 ///
284 /// #### `receives-default`
285 /// Readable | Writeable
286 ///
287 ///
288 /// #### `scale-factor`
289 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
290 /// more details about widget scaling.
291 ///
292 /// Readable
293 ///
294 ///
295 /// #### `sensitive`
296 /// Readable | Writeable
297 ///
298 ///
299 /// #### `style`
300 /// The style of the widget, which contains information about how it will look (colors, etc).
301 ///
302 /// Readable | Writeable
303 ///
304 ///
305 /// #### `tooltip-markup`
306 /// Sets the text of tooltip to be the given string, which is marked up
307 /// with the [Pango text markup language][PangoMarkupFormat].
308 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
309 ///
310 /// This is a convenience property which will take care of getting the
311 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
312 /// will automatically be set to [`true`] and there will be taken care of
313 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
314 ///
315 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
316 /// are set, the last one wins.
317 ///
318 /// Readable | Writeable
319 ///
320 ///
321 /// #### `tooltip-text`
322 /// Sets the text of tooltip to be the given string.
323 ///
324 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
325 ///
326 /// This is a convenience property which will take care of getting the
327 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
328 /// will automatically be set to [`true`] and there will be taken care of
329 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
330 ///
331 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
332 /// are set, the last one wins.
333 ///
334 /// Readable | Writeable
335 ///
336 ///
337 /// #### `valign`
338 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
339 ///
340 /// Readable | Writeable
341 ///
342 ///
343 /// #### `vexpand`
344 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
345 ///
346 /// Readable | Writeable
347 ///
348 ///
349 /// #### `vexpand-set`
350 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
351 ///
352 /// Readable | Writeable
353 ///
354 ///
355 /// #### `visible`
356 /// Readable | Writeable
357 ///
358 ///
359 /// #### `width-request`
360 /// Readable | Writeable
361 ///
362 ///
363 /// #### `window`
364 /// The widget's window if it is realized, [`None`] otherwise.
365 ///
366 /// Readable
367 /// </details>
368 ///
369 /// # Implements
370 ///
371 /// [`FrameExt`][trait@crate::prelude::FrameExt], [`BinExt`][trait@crate::prelude::BinExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
372 #[doc(alias = "GtkFrame")]
373 pub struct Frame(Object<ffi::GtkFrame, ffi::GtkFrameClass>) @extends Bin, Container, Widget, @implements Buildable;
374
375 match fn {
376 type_ => || ffi::gtk_frame_get_type(),
377 }
378}
379
380impl Frame {
381 pub const NONE: Option<&'static Frame> = None;
382
383 /// Creates a new [`Frame`][crate::Frame], with optional label `label`.
384 /// If `label` is [`None`], the label is omitted.
385 /// ## `label`
386 /// the text to use as the label of the frame
387 ///
388 /// # Returns
389 ///
390 /// a new [`Frame`][crate::Frame] widget
391 #[doc(alias = "gtk_frame_new")]
392 pub fn new(label: Option<&str>) -> Frame {
393 assert_initialized_main_thread!();
394 unsafe { Widget::from_glib_none(ffi::gtk_frame_new(label.to_glib_none().0)).unsafe_cast() }
395 }
396
397 // rustdoc-stripper-ignore-next
398 /// Creates a new builder-pattern struct instance to construct [`Frame`] objects.
399 ///
400 /// This method returns an instance of [`FrameBuilder`](crate::builders::FrameBuilder) which can be used to create [`Frame`] objects.
401 pub fn builder() -> FrameBuilder {
402 FrameBuilder::new()
403 }
404}
405
406impl Default for Frame {
407 fn default() -> Self {
408 glib::object::Object::new::<Self>()
409 }
410}
411
412// rustdoc-stripper-ignore-next
413/// A [builder-pattern] type to construct [`Frame`] objects.
414///
415/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
416#[must_use = "The builder must be built to be used"]
417pub struct FrameBuilder {
418 builder: glib::object::ObjectBuilder<'static, Frame>,
419}
420
421impl FrameBuilder {
422 fn new() -> Self {
423 Self {
424 builder: glib::object::Object::builder(),
425 }
426 }
427
428 pub fn label(self, label: impl Into<glib::GString>) -> Self {
429 Self {
430 builder: self.builder.property("label", label.into()),
431 }
432 }
433
434 pub fn label_widget(self, label_widget: &impl IsA<Widget>) -> Self {
435 Self {
436 builder: self
437 .builder
438 .property("label-widget", label_widget.clone().upcast()),
439 }
440 }
441
442 pub fn label_xalign(self, label_xalign: f32) -> Self {
443 Self {
444 builder: self.builder.property("label-xalign", label_xalign),
445 }
446 }
447
448 pub fn label_yalign(self, label_yalign: f32) -> Self {
449 Self {
450 builder: self.builder.property("label-yalign", label_yalign),
451 }
452 }
453
454 pub fn shadow_type(self, shadow_type: ShadowType) -> Self {
455 Self {
456 builder: self.builder.property("shadow-type", shadow_type),
457 }
458 }
459
460 pub fn border_width(self, border_width: u32) -> Self {
461 Self {
462 builder: self.builder.property("border-width", border_width),
463 }
464 }
465
466 pub fn child(self, child: &impl IsA<Widget>) -> Self {
467 Self {
468 builder: self.builder.property("child", child.clone().upcast()),
469 }
470 }
471
472 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
473 Self {
474 builder: self.builder.property("resize-mode", resize_mode),
475 }
476 }
477
478 pub fn app_paintable(self, app_paintable: bool) -> Self {
479 Self {
480 builder: self.builder.property("app-paintable", app_paintable),
481 }
482 }
483
484 pub fn can_default(self, can_default: bool) -> Self {
485 Self {
486 builder: self.builder.property("can-default", can_default),
487 }
488 }
489
490 pub fn can_focus(self, can_focus: bool) -> Self {
491 Self {
492 builder: self.builder.property("can-focus", can_focus),
493 }
494 }
495
496 pub fn events(self, events: gdk::EventMask) -> Self {
497 Self {
498 builder: self.builder.property("events", events),
499 }
500 }
501
502 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
503 pub fn expand(self, expand: bool) -> Self {
504 Self {
505 builder: self.builder.property("expand", expand),
506 }
507 }
508
509 /// Whether the widget should grab focus when it is clicked with the mouse.
510 ///
511 /// This property is only relevant for widgets that can take focus.
512 ///
513 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
514 /// GtkComboBox) implemented this property individually.
515 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
516 Self {
517 builder: self.builder.property("focus-on-click", focus_on_click),
518 }
519 }
520
521 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
522 pub fn halign(self, halign: Align) -> Self {
523 Self {
524 builder: self.builder.property("halign", halign),
525 }
526 }
527
528 pub fn has_default(self, has_default: bool) -> Self {
529 Self {
530 builder: self.builder.property("has-default", has_default),
531 }
532 }
533
534 pub fn has_focus(self, has_focus: bool) -> Self {
535 Self {
536 builder: self.builder.property("has-focus", has_focus),
537 }
538 }
539
540 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
541 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
542 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
543 /// whether it will provide a tooltip or not.
544 ///
545 /// Note that setting this property to [`true`] for the first time will change
546 /// the event masks of the GdkWindows of this widget to include leave-notify
547 /// and motion-notify events. This cannot and will not be undone when the
548 /// property is set to [`false`] again.
549 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
550 Self {
551 builder: self.builder.property("has-tooltip", has_tooltip),
552 }
553 }
554
555 pub fn height_request(self, height_request: i32) -> Self {
556 Self {
557 builder: self.builder.property("height-request", height_request),
558 }
559 }
560
561 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
562 pub fn hexpand(self, hexpand: bool) -> Self {
563 Self {
564 builder: self.builder.property("hexpand", hexpand),
565 }
566 }
567
568 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
569 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
570 Self {
571 builder: self.builder.property("hexpand-set", hexpand_set),
572 }
573 }
574
575 pub fn is_focus(self, is_focus: bool) -> Self {
576 Self {
577 builder: self.builder.property("is-focus", is_focus),
578 }
579 }
580
581 /// Sets all four sides' margin at once. If read, returns max
582 /// margin on any side.
583 pub fn margin(self, margin: i32) -> Self {
584 Self {
585 builder: self.builder.property("margin", margin),
586 }
587 }
588
589 /// Margin on bottom side of widget.
590 ///
591 /// This property adds margin outside of the widget's normal size
592 /// request, the margin will be added in addition to the size from
593 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
594 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
595 Self {
596 builder: self.builder.property("margin-bottom", margin_bottom),
597 }
598 }
599
600 /// Margin on end of widget, horizontally. This property supports
601 /// left-to-right and right-to-left text directions.
602 ///
603 /// This property adds margin outside of the widget's normal size
604 /// request, the margin will be added in addition to the size from
605 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
606 pub fn margin_end(self, margin_end: i32) -> Self {
607 Self {
608 builder: self.builder.property("margin-end", margin_end),
609 }
610 }
611
612 /// Margin on start of widget, horizontally. This property supports
613 /// left-to-right and right-to-left text directions.
614 ///
615 /// This property adds margin outside of the widget's normal size
616 /// request, the margin will be added in addition to the size from
617 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
618 pub fn margin_start(self, margin_start: i32) -> Self {
619 Self {
620 builder: self.builder.property("margin-start", margin_start),
621 }
622 }
623
624 /// Margin on top side of widget.
625 ///
626 /// This property adds margin outside of the widget's normal size
627 /// request, the margin will be added in addition to the size from
628 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
629 pub fn margin_top(self, margin_top: i32) -> Self {
630 Self {
631 builder: self.builder.property("margin-top", margin_top),
632 }
633 }
634
635 pub fn name(self, name: impl Into<glib::GString>) -> Self {
636 Self {
637 builder: self.builder.property("name", name.into()),
638 }
639 }
640
641 pub fn no_show_all(self, no_show_all: bool) -> Self {
642 Self {
643 builder: self.builder.property("no-show-all", no_show_all),
644 }
645 }
646
647 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
648 /// more details about window opacity.
649 ///
650 /// Before 3.8 this was only available in GtkWindow
651 pub fn opacity(self, opacity: f64) -> Self {
652 Self {
653 builder: self.builder.property("opacity", opacity),
654 }
655 }
656
657 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
658 Self {
659 builder: self.builder.property("parent", parent.clone().upcast()),
660 }
661 }
662
663 pub fn receives_default(self, receives_default: bool) -> Self {
664 Self {
665 builder: self.builder.property("receives-default", receives_default),
666 }
667 }
668
669 pub fn sensitive(self, sensitive: bool) -> Self {
670 Self {
671 builder: self.builder.property("sensitive", sensitive),
672 }
673 }
674
675 /// Sets the text of tooltip to be the given string, which is marked up
676 /// with the [Pango text markup language][PangoMarkupFormat].
677 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
678 ///
679 /// This is a convenience property which will take care of getting the
680 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
681 /// will automatically be set to [`true`] and there will be taken care of
682 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
683 ///
684 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
685 /// are set, the last one wins.
686 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
687 Self {
688 builder: self
689 .builder
690 .property("tooltip-markup", tooltip_markup.into()),
691 }
692 }
693
694 /// Sets the text of tooltip to be the given string.
695 ///
696 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
697 ///
698 /// This is a convenience property which will take care of getting the
699 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
700 /// will automatically be set to [`true`] and there will be taken care of
701 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
702 ///
703 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
704 /// are set, the last one wins.
705 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
706 Self {
707 builder: self.builder.property("tooltip-text", tooltip_text.into()),
708 }
709 }
710
711 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
712 pub fn valign(self, valign: Align) -> Self {
713 Self {
714 builder: self.builder.property("valign", valign),
715 }
716 }
717
718 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
719 pub fn vexpand(self, vexpand: bool) -> Self {
720 Self {
721 builder: self.builder.property("vexpand", vexpand),
722 }
723 }
724
725 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
726 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
727 Self {
728 builder: self.builder.property("vexpand-set", vexpand_set),
729 }
730 }
731
732 pub fn visible(self, visible: bool) -> Self {
733 Self {
734 builder: self.builder.property("visible", visible),
735 }
736 }
737
738 pub fn width_request(self, width_request: i32) -> Self {
739 Self {
740 builder: self.builder.property("width-request", width_request),
741 }
742 }
743
744 // rustdoc-stripper-ignore-next
745 /// Build the [`Frame`].
746 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
747 pub fn build(self) -> Frame {
748 self.builder.build()
749 }
750}
751
752mod sealed {
753 pub trait Sealed {}
754 impl<T: super::IsA<super::Frame>> Sealed for T {}
755}
756
757/// Trait containing all [`struct@Frame`] methods.
758///
759/// # Implementors
760///
761/// [`AspectFrame`][struct@crate::AspectFrame], [`Frame`][struct@crate::Frame]
762pub trait FrameExt: IsA<Frame> + sealed::Sealed + 'static {
763 /// If the frame’s label widget is a [`Label`][crate::Label], returns the
764 /// text in the label widget. (The frame will have a [`Label`][crate::Label]
765 /// for the label widget if a non-[`None`] argument was passed
766 /// to [`Frame::new()`][crate::Frame::new()].)
767 ///
768 /// # Returns
769 ///
770 /// the text in the label, or [`None`] if there
771 /// was no label widget or the lable widget was not
772 /// a [`Label`][crate::Label]. This string is owned by GTK+ and
773 /// must not be modified or freed.
774 #[doc(alias = "gtk_frame_get_label")]
775 #[doc(alias = "get_label")]
776 fn label(&self) -> Option<glib::GString> {
777 unsafe { from_glib_none(ffi::gtk_frame_get_label(self.as_ref().to_glib_none().0)) }
778 }
779
780 /// Retrieves the X and Y alignment of the frame’s label. See
781 /// [`set_label_align()`][Self::set_label_align()].
782 ///
783 /// # Returns
784 ///
785 ///
786 /// ## `xalign`
787 /// location to store X alignment of
788 /// frame’s label, or [`None`]
789 ///
790 /// ## `yalign`
791 /// location to store X alignment of
792 /// frame’s label, or [`None`]
793 #[doc(alias = "gtk_frame_get_label_align")]
794 #[doc(alias = "get_label_align")]
795 fn label_align(&self) -> (f32, f32) {
796 unsafe {
797 let mut xalign = mem::MaybeUninit::uninit();
798 let mut yalign = mem::MaybeUninit::uninit();
799 ffi::gtk_frame_get_label_align(
800 self.as_ref().to_glib_none().0,
801 xalign.as_mut_ptr(),
802 yalign.as_mut_ptr(),
803 );
804 (xalign.assume_init(), yalign.assume_init())
805 }
806 }
807
808 /// Retrieves the label widget for the frame. See
809 /// [`set_label_widget()`][Self::set_label_widget()].
810 ///
811 /// # Returns
812 ///
813 /// the label widget, or [`None`] if
814 /// there is none.
815 #[doc(alias = "gtk_frame_get_label_widget")]
816 #[doc(alias = "get_label_widget")]
817 fn label_widget(&self) -> Option<Widget> {
818 unsafe {
819 from_glib_none(ffi::gtk_frame_get_label_widget(
820 self.as_ref().to_glib_none().0,
821 ))
822 }
823 }
824
825 /// Retrieves the shadow type of the frame. See
826 /// [`set_shadow_type()`][Self::set_shadow_type()].
827 ///
828 /// # Returns
829 ///
830 /// the current shadow type of the frame.
831 #[doc(alias = "gtk_frame_get_shadow_type")]
832 #[doc(alias = "get_shadow_type")]
833 fn shadow_type(&self) -> ShadowType {
834 unsafe {
835 from_glib(ffi::gtk_frame_get_shadow_type(
836 self.as_ref().to_glib_none().0,
837 ))
838 }
839 }
840
841 /// Removes the current [`label-widget`][struct@crate::Frame#label-widget]. If `label` is not [`None`], creates a
842 /// new [`Label`][crate::Label] with that text and adds it as the [`label-widget`][struct@crate::Frame#label-widget].
843 /// ## `label`
844 /// the text to use as the label of the frame
845 #[doc(alias = "gtk_frame_set_label")]
846 fn set_label(&self, label: Option<&str>) {
847 unsafe {
848 ffi::gtk_frame_set_label(self.as_ref().to_glib_none().0, label.to_glib_none().0);
849 }
850 }
851
852 /// Sets the alignment of the frame widget’s label. The
853 /// default values for a newly created frame are 0.0 and 0.5.
854 /// ## `xalign`
855 /// The position of the label along the top edge
856 /// of the widget. A value of 0.0 represents left alignment;
857 /// 1.0 represents right alignment.
858 /// ## `yalign`
859 /// The y alignment of the label. A value of 0.0 aligns under
860 /// the frame; 1.0 aligns above the frame. If the values are exactly
861 /// 0.0 or 1.0 the gap in the frame won’t be painted because the label
862 /// will be completely above or below the frame.
863 #[doc(alias = "gtk_frame_set_label_align")]
864 fn set_label_align(&self, xalign: f32, yalign: f32) {
865 unsafe {
866 ffi::gtk_frame_set_label_align(self.as_ref().to_glib_none().0, xalign, yalign);
867 }
868 }
869
870 /// Sets the [`label-widget`][struct@crate::Frame#label-widget] for the frame. This is the widget that
871 /// will appear embedded in the top edge of the frame as a title.
872 /// ## `label_widget`
873 /// the new label widget
874 #[doc(alias = "gtk_frame_set_label_widget")]
875 fn set_label_widget(&self, label_widget: Option<&impl IsA<Widget>>) {
876 unsafe {
877 ffi::gtk_frame_set_label_widget(
878 self.as_ref().to_glib_none().0,
879 label_widget.map(|p| p.as_ref()).to_glib_none().0,
880 );
881 }
882 }
883
884 /// Sets the [`shadow-type`][struct@crate::Frame#shadow-type] for `self`, i.e. whether it is drawn without
885 /// ([`ShadowType::None`][crate::ShadowType::None]) or with (other values) a visible border. Values other than
886 /// [`ShadowType::None`][crate::ShadowType::None] are treated identically by GtkFrame. The chosen type is
887 /// applied by removing or adding the .flat class to the CSS node named border.
888 /// ## `type_`
889 /// the new [`ShadowType`][crate::ShadowType]
890 #[doc(alias = "gtk_frame_set_shadow_type")]
891 fn set_shadow_type(&self, type_: ShadowType) {
892 unsafe {
893 ffi::gtk_frame_set_shadow_type(self.as_ref().to_glib_none().0, type_.into_glib());
894 }
895 }
896
897 #[doc(alias = "label-xalign")]
898 fn label_xalign(&self) -> f32 {
899 ObjectExt::property(self.as_ref(), "label-xalign")
900 }
901
902 #[doc(alias = "label-xalign")]
903 fn set_label_xalign(&self, label_xalign: f32) {
904 ObjectExt::set_property(self.as_ref(), "label-xalign", label_xalign)
905 }
906
907 #[doc(alias = "label-yalign")]
908 fn label_yalign(&self) -> f32 {
909 ObjectExt::property(self.as_ref(), "label-yalign")
910 }
911
912 #[doc(alias = "label-yalign")]
913 fn set_label_yalign(&self, label_yalign: f32) {
914 ObjectExt::set_property(self.as_ref(), "label-yalign", label_yalign)
915 }
916
917 #[doc(alias = "label")]
918 fn connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
919 unsafe extern "C" fn notify_label_trampoline<P: IsA<Frame>, F: Fn(&P) + 'static>(
920 this: *mut ffi::GtkFrame,
921 _param_spec: glib::ffi::gpointer,
922 f: glib::ffi::gpointer,
923 ) {
924 let f: &F = &*(f as *const F);
925 f(Frame::from_glib_borrow(this).unsafe_cast_ref())
926 }
927 unsafe {
928 let f: Box_<F> = Box_::new(f);
929 connect_raw(
930 self.as_ptr() as *mut _,
931 b"notify::label\0".as_ptr() as *const _,
932 Some(transmute::<_, unsafe extern "C" fn()>(
933 notify_label_trampoline::<Self, F> as *const (),
934 )),
935 Box_::into_raw(f),
936 )
937 }
938 }
939
940 #[doc(alias = "label-widget")]
941 fn connect_label_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
942 unsafe extern "C" fn notify_label_widget_trampoline<P: IsA<Frame>, F: Fn(&P) + 'static>(
943 this: *mut ffi::GtkFrame,
944 _param_spec: glib::ffi::gpointer,
945 f: glib::ffi::gpointer,
946 ) {
947 let f: &F = &*(f as *const F);
948 f(Frame::from_glib_borrow(this).unsafe_cast_ref())
949 }
950 unsafe {
951 let f: Box_<F> = Box_::new(f);
952 connect_raw(
953 self.as_ptr() as *mut _,
954 b"notify::label-widget\0".as_ptr() as *const _,
955 Some(transmute::<_, unsafe extern "C" fn()>(
956 notify_label_widget_trampoline::<Self, F> as *const (),
957 )),
958 Box_::into_raw(f),
959 )
960 }
961 }
962
963 #[doc(alias = "label-xalign")]
964 fn connect_label_xalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
965 unsafe extern "C" fn notify_label_xalign_trampoline<P: IsA<Frame>, F: Fn(&P) + 'static>(
966 this: *mut ffi::GtkFrame,
967 _param_spec: glib::ffi::gpointer,
968 f: glib::ffi::gpointer,
969 ) {
970 let f: &F = &*(f as *const F);
971 f(Frame::from_glib_borrow(this).unsafe_cast_ref())
972 }
973 unsafe {
974 let f: Box_<F> = Box_::new(f);
975 connect_raw(
976 self.as_ptr() as *mut _,
977 b"notify::label-xalign\0".as_ptr() as *const _,
978 Some(transmute::<_, unsafe extern "C" fn()>(
979 notify_label_xalign_trampoline::<Self, F> as *const (),
980 )),
981 Box_::into_raw(f),
982 )
983 }
984 }
985
986 #[doc(alias = "label-yalign")]
987 fn connect_label_yalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
988 unsafe extern "C" fn notify_label_yalign_trampoline<P: IsA<Frame>, F: Fn(&P) + 'static>(
989 this: *mut ffi::GtkFrame,
990 _param_spec: glib::ffi::gpointer,
991 f: glib::ffi::gpointer,
992 ) {
993 let f: &F = &*(f as *const F);
994 f(Frame::from_glib_borrow(this).unsafe_cast_ref())
995 }
996 unsafe {
997 let f: Box_<F> = Box_::new(f);
998 connect_raw(
999 self.as_ptr() as *mut _,
1000 b"notify::label-yalign\0".as_ptr() as *const _,
1001 Some(transmute::<_, unsafe extern "C" fn()>(
1002 notify_label_yalign_trampoline::<Self, F> as *const (),
1003 )),
1004 Box_::into_raw(f),
1005 )
1006 }
1007 }
1008
1009 #[doc(alias = "shadow-type")]
1010 fn connect_shadow_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1011 unsafe extern "C" fn notify_shadow_type_trampoline<P: IsA<Frame>, F: Fn(&P) + 'static>(
1012 this: *mut ffi::GtkFrame,
1013 _param_spec: glib::ffi::gpointer,
1014 f: glib::ffi::gpointer,
1015 ) {
1016 let f: &F = &*(f as *const F);
1017 f(Frame::from_glib_borrow(this).unsafe_cast_ref())
1018 }
1019 unsafe {
1020 let f: Box_<F> = Box_::new(f);
1021 connect_raw(
1022 self.as_ptr() as *mut _,
1023 b"notify::shadow-type\0".as_ptr() as *const _,
1024 Some(transmute::<_, unsafe extern "C" fn()>(
1025 notify_shadow_type_trampoline::<Self, F> as *const (),
1026 )),
1027 Box_::into_raw(f),
1028 )
1029 }
1030 }
1031}
1032
1033impl<O: IsA<Frame>> FrameExt for O {}
1034
1035impl fmt::Display for Frame {
1036 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1037 f.write_str("Frame")
1038 }
1039}