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