Gtk.AppChooser


Gtk.AppChooser — Interface implemented by widgets for choosing an application

Object Hierarchy:

    GInterface
    ╰── Gtk.AppChooser

Functions:

Description:

Gtk.AppChooser is an interface that can be implemented by widgets which allow the user to choose an application (typically for the purpose of opening a file). The main objects that implement this interface are Gtk.AppChooserWidget, Gtk.AppChooserDialog and Gtk.AppChooserButton.

Applications are represented by GIO Gio.AppInfo objects here.

GIO has a concept of recommended and fallback applications for a given content type. Recommended applications are those that claim to handle the content type itself, while fallback also includes applications that handle a more generic content type. GIO also knows the default and last-used application for a given content type. The Gtk.AppChooserWidget provides detailed control over whether the shown list of applications should include default, recommended or fallback applications.

To obtain the application that has been selected in a Gtk.AppChooser, use Gtk.AppChooser::get_app_info().

    appchooserbutton = Gtk.AppChooserButton(content_type="audio/flac")
    appchooserbutton.set_show_dialog_item(True)
    appchooserbutton.connect("changed", self.on_item_changed)
    self.add(appchooserbutton)
    appchooserwidget = Gtk.AppChooserWidget(content_type="video/webm")
    appchooserwidget.connect("application-activated", self.on_application_activated)
    self.add(appchooserwidget)
    def on_button_clicked(self, button): 
        dialog = Gtk.AppChooserDialog(parent=self, content_type="image/png")
        dialog.set_title("AppChooserDialog")
        dialog.connect("response", self.on_response)
        dialog.run()        

    def on_response(self, dialog, response):
        if response == Gtk.ResponseType.OK:
            app_info = dialog.get_app_info()
            name = app_info.get_display_name()
            description = app_info.get_description()

            print("Name:\t\t%s" % (name))
            print("Description:\t%s" % (description))

        dialog.destroy()

Function Details:

get_app_info()

get_app_info (self) -> Gio.AppInfo

Returns the currently selected application.

  • Returns: a GAppInfo for the currently selectedapplication, or None if none is selected. Free with g_object_unref().

  • Since: 3.0


get_content_type()

get_content_type (self) -> str

Returns the current value of the “content-type” property.

  • Returns: the content type of self. Free with g_free()

  • Since: 3.0


refresh()

refresh (self)

Reloads the list of applications.

  • Since: 3.0

results matching ""

    No results matching ""