Class AppChooserButton

All Implemented Interfaces:
PointerInterface

public class AppChooserButton extends Widget
The `GtkAppChooserButton` lets the user select an application.

![An example GtkAppChooserButton](appchooserbutton.png)

Initially, a `GtkAppChooserButton` selects the first application
in its list, which will either be the most-recently used application
or, if [property@Gtk.AppChooserButton:show-default-item] is %TRUE, the
default application.

The list of applications shown in a `GtkAppChooserButton` includes
the recommended applications for the given content type. When
[property@Gtk.AppChooserButton:show-default-item] is set, the default
application is also included. To let the user chooser other applications,
you can set the [property@Gtk.AppChooserButton:show-dialog-item] property,
which allows to open a full [class@Gtk.AppChooserDialog].

It is possible to add custom items to the list, using
[method@Gtk.AppChooserButton.append_custom_item]. These items cause
the [signal@Gtk.AppChooserButton::custom-item-activated] signal to be
emitted when they are selected.

To track changes in the selected application, use the
[signal@Gtk.AppChooserButton::changed] signal.

# CSS nodes

`GtkAppChooserButton` has a single CSS node with the name “appchooserbutton”.

https://docs.gtk.org/gtk4/class.AppChooserButton.html

  • Field Details

  • Constructor Details

    • AppChooserButton

      public AppChooserButton(PointerContainer pointer)
    • AppChooserButton

      public AppChooserButton(@Nonnull Str content_type)
      Creates a new `GtkAppChooserButton` for applications
      that can handle content of the given type.
      Parameters:
      content_type - the content type to show applications for
    • AppChooserButton

      public AppChooserButton(String content_type)
      Creates a new `GtkAppChooserButton` for applications
      that can handle content of the given type.
      Parameters:
      content_type - the content type to show applications for
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • appendCustomItem

      public void appendCustomItem(@Nonnull Str name, @Nonnull Str label, @Nonnull Icon icon)
      Appends a custom item to the list of applications that is shown
      in the popup.

      The item name must be unique per-widget. Clients can use the
      provided name as a detail for the
      [signal@Gtk.AppChooserButton::custom-item-activated] signal, to add a
      callback for the activation of a particular custom item in the list.

      See also [method@Gtk.AppChooserButton.append_separator].
      Parameters:
      name - the name of the custom item
      label - the label for the custom item
      icon - the icon for the custom item
    • appendCustomItem

      public void appendCustomItem(String name, String label, @Nonnull Icon icon)
      Appends a custom item to the list of applications that is shown
      in the popup.

      The item name must be unique per-widget. Clients can use the
      provided name as a detail for the
      [signal@Gtk.AppChooserButton::custom-item-activated] signal, to add a
      callback for the activation of a particular custom item in the list.

      See also [method@Gtk.AppChooserButton.append_separator].
      Parameters:
      name - the name of the custom item
      label - the label for the custom item
      icon - the icon for the custom item
    • appendSeparator

      public void appendSeparator()
      Appends a separator to the list of applications that is shown
      in the popup.
    • getHeading

      public Str getHeading()
      Returns the text to display at the top of the dialog.
      Returns:
      the text to display at the top of the dialog, or %NULL, in which case a default text is displayed
    • getModal

      public boolean getModal()
      Gets whether the dialog is modal.
      Returns:
      %TRUE if the dialog is modal
    • getShowDefaultItem

      public boolean getShowDefaultItem()
      Returns whether the dropdown menu should show the default
      application at the top.
      Returns:
      the value of [property@Gtk.AppChooserButton:show-default-item]
    • getShowDialogItem

      public boolean getShowDialogItem()
      Returns whether the dropdown menu shows an item
      for a `GtkAppChooserDialog`.
      Returns:
      the value of [property@Gtk.AppChooserButton:show-dialog-item]
    • setActiveCustomItem

      public void setActiveCustomItem(@Nonnull Str name)
      Selects a custom item.

      See [method@Gtk.AppChooserButton.append_custom_item].

      Use [method@Gtk.AppChooser.refresh] to bring the selection
      to its initial state.
      Parameters:
      name - the name of the custom item
    • setActiveCustomItem

      public void setActiveCustomItem(String name)
      Selects a custom item.

      See [method@Gtk.AppChooserButton.append_custom_item].

      Use [method@Gtk.AppChooser.refresh] to bring the selection
      to its initial state.
      Parameters:
      name - the name of the custom item
    • setHeading

      public void setHeading(@Nonnull Str heading)
      Sets the text to display at the top of the dialog.

      If the heading is not set, the dialog displays a default text.
      Parameters:
      heading - a string containing Pango markup
    • setHeading

      public void setHeading(String heading)
      Sets the text to display at the top of the dialog.

      If the heading is not set, the dialog displays a default text.
      Parameters:
      heading - a string containing Pango markup
    • setModal

      public void setModal(boolean modal)
      Sets whether the dialog should be modal.
      Parameters:
      modal - %TRUE to make the dialog modal
    • setShowDefaultItem

      public void setShowDefaultItem(boolean setting)
      Sets whether the dropdown menu of this button should show the
      default application for the given content type at top.
      Parameters:
      setting - the new value for [property@Gtk.AppChooserButton:show-default-item]
    • setShowDialogItem

      public void setShowDialogItem(boolean setting)
      Sets whether the dropdown menu of this button should show an
      entry to trigger a `GtkAppChooserDialog`.
      Parameters:
      setting - the new value for [property@Gtk.AppChooserButton:show-dialog-item]
    • onActivate

      public SignalHandler onActivate(AppChooserButton.OnActivate signal)
      Connect to signal "activate".
      See AppChooserButton.OnActivate.onActivate() for signal description.
      Field SIGNAL_ON_ACTIVATE contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • onChanged

      public SignalHandler onChanged(AppChooserButton.OnChanged signal)
      Connect to signal "changed".
      See AppChooserButton.OnChanged.onChanged() for signal description.
      Field SIGNAL_ON_CHANGED contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • onCustomItemActivated

      public SignalHandler onCustomItemActivated(AppChooserButton.OnCustomItemActivated signal)
      Connect to signal "custom-item-activated".
      See AppChooserButton.OnCustomItemActivated.onCustomItemActivated(ch.bailu.gtk.type.Str) for signal description.
      Field SIGNAL_ON_CUSTOM_ITEM_ACTIVATED contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • asAccessible

      public Accessible asAccessible()
      Implements interface Accessible. Call this to get access to interface functions.
      Overrides:
      asAccessible in class Widget
      Returns:
      Accessible
    • asAppChooser

      public AppChooser asAppChooser()
      Implements interface AppChooser. Call this to get access to interface functions.
      Returns:
      AppChooser
    • asBuildable

      public Buildable asBuildable()
      Implements interface Buildable. Call this to get access to interface functions.
      Overrides:
      asBuildable in class Widget
      Returns:
      Buildable
    • asConstraintTarget

      public ConstraintTarget asConstraintTarget()
      Implements interface ConstraintTarget. Call this to get access to interface functions.
      Overrides:
      asConstraintTarget in class Widget
      Returns:
      ConstraintTarget
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()