def do_check_gui(use_gui): from zeroinstall.gui import main if use_gui == "yes": use_gui = True elif use_gui == "no": return False elif use_gui == "maybe": use_gui = None else: assert 0, use_gui return main.gui_is_available(use_gui)
def do_open_cache_explorer(config, ticket): global cache_explorer assert cache_explorer is None try: from zeroinstall.gui import main main.gui_is_available(True) # Will throw if not blocker = tasks.Blocker("Cache explorer window") import gtk from zeroinstall.gtkui import cache cache_explorer = cache.CacheExplorer(config) cache_explorer.window.connect('destroy', lambda widget: blocker.trigger()) cache_explorer.show() gtk.gdk.flush() yield blocker tasks.check(blocker) send_json(["return", ticket, ["ok", None]]) except Exception as ex: logger.warning("Returning error", exc_info = True) send_json(["return", ticket, ["error", str(ex)]])
def should_use_gui(use_gui): if use_gui is False: return False if not os.environ.get('DISPLAY', None): if use_gui is None: return False else: raise SafeException("Can't use GUI because $DISPLAY is not set") from zeroinstall.gui import main if main.gui_is_available(use_gui): return True if use_gui is None: return False else: raise SafeException("No GUI available")
def do_open_add_box(ticket, uri): from zeroinstall.gui import main main.gui_is_available(True) from zeroinstall.gtkui.addbox import AddBox wait_for_destroy(ticket, AddBox(uri).window)
def do_open_app_list_box(ticket): from zeroinstall.gui import main main.gui_is_available(True) from zeroinstall.gtkui.applistbox import AppListBox, AppList from zeroinstall.injector.iface_cache import iface_cache wait_for_destroy(ticket, AppListBox(iface_cache, AppList()).window)