Skip to content

Gtk.AppChooserButton

class — extends Widget, Accessible, AppChooser, Buildable, ConstraintTarget

:::warning Deprecated since 4.10 This API is deprecated. :::

The GtkAppChooserButton lets the user select an application.

<picture> <source srcset="appchooserbutton-dark.png" media="(prefers-color-scheme: dark)"> <img alt="An example GtkAppChooserButton" src="appchooserbutton.png"> </picture>

Initially, a GtkAppChooserButton selects the first application in its list, which will either be the most-recently used application or, if 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 AppChooserButton.show-default-item is set, the default application is also included. To let the user chooser other applications, you can set the AppChooserButton.show-dialog-item property, which allows to open a full AppChooserDialog.

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

To track changes in the selected application, use the AppChooserButton.changed signal.

CSS nodes

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

Constructors

new

@classmethod
def new(cls, content_type: str) -> Widget

:::warning Deprecated since 4.10 This API is deprecated. :::

Creates a new GtkAppChooserButton for applications that can handle content of the given type.

Parameters:

  • content_type — the content type to show applications for

Methods

append_custom_item

def append_custom_item(self, name: str, label: str, icon: Gio.Icon) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

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 AppChooserButton.custom-item-activated signal, to add a callback for the activation of a particular custom item in the list.

See also 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

append_separator

def append_separator(self) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

Appends a separator to the list of applications that is shown in the popup.

get_heading

def get_heading(self) -> str | None

:::warning Deprecated since 4.10 This API is deprecated. :::

Returns the text to display at the top of the dialog.

get_modal

def get_modal(self) -> bool

:::warning Deprecated since 4.10 This API is deprecated. :::

Gets whether the dialog is modal.

get_show_default_item

def get_show_default_item(self) -> bool

:::warning Deprecated since 4.10 This API is deprecated. :::

Returns whether the dropdown menu should show the default application at the top.

get_show_dialog_item

def get_show_dialog_item(self) -> bool

:::warning Deprecated since 4.10 This API is deprecated. :::

Returns whether the dropdown menu shows an item for a GtkAppChooserDialog.

set_active_custom_item

def set_active_custom_item(self, name: str) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

Selects a custom item.

See AppChooserButton.append_custom_item.

Use AppChooser.refresh to bring the selection to its initial state.

Parameters:

  • name — the name of the custom item

set_heading

def set_heading(self, heading: str) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

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

set_modal

def set_modal(self, modal: bool) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

Sets whether the dialog should be modal.

Parameters:

  • modalTrue to make the dialog modal

set_show_default_item

def set_show_default_item(self, setting: bool) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

Sets whether the dropdown menu of this button should show the default application for the given content type at top.

Parameters:

set_show_dialog_item

def set_show_dialog_item(self, setting: bool) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

Sets whether the dropdown menu of this button should show an entry to trigger a GtkAppChooserDialog.

Parameters:

Properties

heading

heading: str  # read/write

The text to show at the top of the dialog that can be opened from the button.

The string may contain Pango markup.

modal

modal: bool  # read/write

Whether the app chooser dialog should be modal.

show_default_item

show_default_item: bool  # read/write

Determines whether the dropdown menu shows the default application on top for the provided content type.

show_dialog_item

show_dialog_item: bool  # read/write

Determines whether the dropdown menu shows an item to open a GtkAppChooserDialog.

Signals

activate

def on_activate(self) -> None: ...

Emitted to when the button is activated.

The ::activate signal on GtkAppChooserButton is an action signal and emitting it causes the button to pop up its dialog.

changed

def on_changed(self) -> None: ...

Emitted when the active application changes.

custom-item-activated

def on_custom_item_activated(self, item_name: str) -> None: ...

Emitted when a custom item is activated.

Use AppChooserButton.append_custom_item, to add custom items.