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