Gtk.AppChooserWidget


Gtk.AppChooserWidget — Application chooser widget that can be embedded in other widgets

Object Hierarchy:

    GObject
    ╰── GInitiallyUnowned
        ╰── Gtk.Widget
            ╰── Gtk.Container
                ╰── Gtk.Box
                    ╰── Gtk.AppChooserWidget

Functions:


Signals:

  • “application-activated” (self, application, user_data)
  • “application-selected” (self, application, user_data)
  • “populate-popup” (self, menu, application, user_data)

Description:

Gtk.AppChooserWidget is a widget for selecting applications.

It is the main building block for Gtk.AppChooserDialog. Most applications only need to use the latter; but you can use this widget as part of a larger widget if you have special needs.

Gtk.AppChooserWidget offers detailed control over what applications are shown, using the Gtk.AppChooserWidget::show-default, Gtk.AppChooserWidget::show-recommended, Gtk.AppChooserWidget::show-fallback, Gtk.AppChooserWidget::show-other and Gtk.AppChooserWidget::show-all properties. See the Gtk.AppChooser documentation for more information about these groups of applications.

To keep track of the selected application, use the Gtk.AppChooserWidget::application-selected and Gtk.AppChooserWidget::application-activated signals.

  • Code snap:
    appchooserwidget = Gtk.AppChooserWidget(content_type="video/webm")
    appchooserwidget.connect("application-activated", self.on_application_activated)
    self.add(appchooserwidget)

Function Details:

new()

new (content_type:str) -> Gtk.Widget

Creates a new Gtk.AppChooserWidget for applicationsthat can handle content of the given type.

  • Returns: a newly created Gtk.AppChooserWidget

  • Since: 3.0


set_show_default()

set_show_default (self, setting:bool)

Sets whether the app chooser should show the default handlerfor the content type in a separate section.

  • Since: 3.0

get_show_default()

get_show_default (self) -> bool

Returns the current value of the “show-default”property.

  • Returns: the value of “show-default”

  • Since: 3.0


set_show_recommended()

set_show_recommended (self, setting:bool)

Sets whether the app chooser should show recommended applicationsfor the content type in a separate section.

  • Since: 3.0

get_show_recommended()

get_show_recommended (self) -> bool

Returns the current value of the “show-recommended”property.

  • Returns: the value of “show-recommended”

  • Since: 3.0


set_show_fallback()

set_show_fallback (self, setting:bool)

Sets whether the app chooser should show related applicationsfor the content type in a separate section.

  • Since: 3.0

get_show_fallback()

get_show_fallback (self) -> bool

Returns the current value of the “show-fallback”property.

  • Returns: the value of “show-fallback”

  • Since: 3.0


set_show_other()

set_show_other (self, setting:bool)

Sets whether the app chooser should show applicationswhich are unrelated to the content type.

  • Since: 3.0

get_show_other()

get_show_other (self) -> bool

Returns the current value of the “show-other”property.

  • Returns: the value of “show-other”

  • Since: 3.0


set_show_all()

set_show_all (self, setting:bool)

Sets whether the app chooser should show all applicationsin a flat list.

  • Since: 3.0

get_show_all()

get_show_all (self) -> bool

Returns the current value of the “show-all”property.

  • Returns: the value of “show-all”

  • Since: 3.0


set_default_text()

set_default_text (self, text:str)

Sets the text that is shown if there are not applicationsthat can handle the content type.


get_default_text()

get_default_text (self) -> str

Returns the text that is shown if there are not applicationsthat can handle the content type.

  • Returns: the value of “default-text”

  • Since: 3.0


Example:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

class AppChooserWidget(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self)
        self.set_title("AppChooserWidget")
        self.connect("destroy", Gtk.main_quit)

        appchooserwidget = Gtk.AppChooserWidget(content_type="video/webm")
        appchooserwidget.connect("application-activated", self.on_application_activated)
        self.add(appchooserwidget)

    def on_application_activated(self, appchooserwidget, desktopappinfo):
        app_info = appchooserwidget.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))

window = AppChooserWidget()
window.show_all()

Gtk.main()

results matching ""

    No results matching ""