def on_send_to_image_viewer_or_editor_clicked(self): appchooserdialog = Gtk.AppChooserDialog(content_type="image/png") response = appchooserdialog.run() if response == Gtk.ResponseType.OK: app_info = appchooserdialog.get_app_info() display_name = app_info.get_display_name() f = open("/tmp/.app_name", "w") f.write("{0}".format(display_name)) f.close() thread.start_new_thread(self.thread_image_viewer_or_editor, ("start_in_new_thread", )) appchooserdialog.destroy()
def on_item_activated(self, flowbox, child): image_file = child.get_child().image_file dialog = Gtk.AppChooserDialog(parent=self, flags=Gtk.DialogFlags.MODAL, gfile=image_file) widget = dialog.get_widget() widget.set_show_default(True) content_type = widget.get_content_type() default_app_info = app_info_get_default_for_type(content_type, False) if default_app_info is not None: default_app_info.launch([image_file], None) else: response = dialog.run() if response == Gtk.ResponseType.OK: appinfo = dialog.get_app_info() appinfo.set_as_default_for_type(content_type) appinfo.launch([image_file], None) dialog.destroy()
#!/usr/bin/env python3 from gi.repository import Gtk appchooserdialog = Gtk.AppChooserDialog(content_type="image/png") response = appchooserdialog.run() if response == Gtk.ResponseType.OK: app_info = appchooserdialog.get_app_info() display_name = app_info.get_display_name() description = app_info.get_description() print("Application selected") print("Name:\t\t%s" % display_name) print("Description:\t%s" % description) appchooserdialog.destroy()
#!/usr/bin/env python from gi.repository import Gtk appchooserdialog = Gtk.AppChooserDialog(parent=None, flags=0, content_type="audio/flac") response = appchooserdialog.run() if response == Gtk.ResponseType.OK: print("Application activated: %s" % appchooserdialog.get_app_info().get_name()) appchooserdialog.destroy()