def info_for(name: str) -> Gio.DesktopAppInfo: if name not in NAME_MAP.keys(): messages.add(Message('No matching application for ' + name, 'error')) return None if not name or not name.strip() or name not in NAME_MAP.keys(): messages.add(Message('Missing application name', 'error')) return None return Gio.DesktopAppInfo.new_from_filename(LOCATION_MAP[name])
def launch_app(app_info, timestamp: int = None, desktop: int = -1): if not timestamp: timestamp = datetime.now().microsecond try: display: Gdk.Display = Gdk.Display.get_default() context: GdkX11.X11AppLaunchContext = display.get_app_launch_context() context.setenv(DESKTOP_STARTUP_ID, context.get_startup_notify_id(app_info, [])) context.set_timestamp(timestamp) context.set_desktop(desktop) context.set_screen(display.get_default_screen()) app_info.launch_uris_as_manager([], context, SPAWN_FLAGS, USER_SETUP, USER_SETUP_DATA, None) except GLib.GError as exc: messages.add(Message('Error launching ' + str(app_info), 'error'))
def call(function, user_event: UserEvent, multiplier=1): try: _pre_processing() for i in range(multiplier): return_message = function(user_event) if return_message: messages.add(return_message) _post_processing(user_event) except Exception as inst: msg = 'ERROR ({}) executing: {}'.format(str(inst), user_event.text) print(traceback.format_exc()) messages.add_error(msg) reading.begin(user_event.time) return False
def list(self, user_event: UserEvent): if user_event.text: messages.add(messages.Message(PROMPT + user_event.text, 'info')) from pocoy.view import BufferName for window in self.get_buffers(): messages.add(BufferName(window, self))
def read_screen(user_event: UserEvent): messages.add(text=model.resume())