def startup_ui(self): sys.excepthook = self.exception_handler Application.startup_ui(self) call_on_ui_thread(migrateappname.migrateVideos, 'Democracy', 'Miro') call_on_ui_thread(flash.check_flash_install) call_on_ui_thread(bonjour.check_bonjour_install) timer.add(15, self._init_autoupdate)
def _device_connected(self, device): id_, info = self._get_device_info(device) logging.debug('seen device: %r' % (device,)) if not info['mount']: # we don't get notified :( so poll instead timer.add(0.5, self._check_device_mount, device) app.device_manager.device_connected(id_, **info)
def _device_connected(self, device): id_, info = self._get_device_info(device) logging.debug('seen device: %r' % (device, )) if not info['mount']: # we don't get notified :( so poll instead timer.add(0.5, self._check_device_mount, device) app.device_manager.device_connected(id_, **info)
def _check_device_mount(self, device): if device['volume'] not in self._connected: # device was removed return if os.path.exists(device['mount']): self._device_changed(device) return timer.add(0.5, self._check_device_mount, device)
def _check_device_mount(self, device): if device['volume'] not in self._connected: # device was removed return if 'future_mount' in device and os.path.exists(device['future_mount']): device['mount'] = device['future_mount'] del device['future_mount'] self._device_changed(device) return timer.add(0.5, self._check_device_mount, device)
def select_display_for_tabs(self, selected_tab_list, selected_tabs): """Select a display to show in the right-hand side. """ if self._select_display_for_tabs_args is None: # First call to select_display_for_tabs(), we need to schedule # _select_display_for_tabs() to be called. timer.add(0.01, self._select_display_for_tabs) # For all cases, we want to store these arguments in # _select_display_for_tabs_args so that when # _select_display_for_tabs() is called it uses them. self._select_display_for_tabs_args = (selected_tab_list, selected_tabs)
def _device_connected(self, device): try: info = self._get_device_info(device) except KeyError: logging.debug('unknown device connected: %r' % (device,)) return logging.debug('seen device: %r' % (device,)) if not info.mount: # we don't get notified :( so poll instead timer.add(0.5, self._check_device_mount, device) devices.device_connected(info)
def _do_iteration(self, item_id, repeat_delay): try: item_info = self.item_list.get_item(item_id) except KeyError: # item was deleted from model self.currently_animating.remove(item_id) return rv = self.continue_animation(item_info) if rv != False: timer.add(repeat_delay, self._do_iteration, item_id, repeat_delay) else: self.currently_animating.remove(item_id) self.finish_animation(item_info) for view in self.item_views: view.model_changed()
def _drive_disconnected(self, volume_monitor, drive): if drive is None: # can happen when a CD is inserted return for id_, info in self._get_device_info(drive): timeout_id = timer.add(0.5, self._drive_disconnected_timeout, id_) self._disconnecting[id_] = timeout_id
def schedule_update(self): def notify_and_reschedule(): if self.update_timeout is not None: self.update_timeout = None if self.is_playing and not self.is_paused: if not self.is_suspended: self.notify_update() self.schedule_update() self.update_timeout = timer.add(0.5, notify_and_reschedule)
def _drive_disconnected(self, volume_monitor, drive): if drive is None: # can happen when a CD is inserted return try: info = self._get_device_info(drive) except KeyError: return timeout_id = timer.add(0.5, self._drive_disconnected_timeout, info) self._disconnecting[info.id] = timeout_id
def pulse_updating_animation(self, id_): try: iter_ = self.iter_map[id_] except KeyError: # feed was removed del self.updating_animations[id_] return self.view.pulse_updating_image(iter_) timer_id = timer.add(0.1, self.pulse_updating_animation, id_) self.updating_animations[id_] = timer_id
def schedule_update(self): def notify_and_reschedule(): if self.update_timeout is not None: self.update_timeout = None if self.is_playing: if not self.is_suspended: self.notify_update() self.schedule_update() if self.update_timeout: self.cancel_update_timer() self.update_timeout = timer.add(0.5, notify_and_reschedule)
def start_updating(self, id_): # The spinning wheel is constantly updating the cell value, between # validating the cell value for the drag and drop and the actual drop # the cell value most likely changes, and some GUI toolkits may get # confused. # # We'll let the underlying platform code figure out what's the best # thing to do here. self.view.set_volatile(True) if id_ in self.updating_animations: return timer_id = timer.add(0, self.pulse_updating_animation, id_) self.updating_animations[id_] = timer_id
def change_non_video_displays(self, display): # If the dc exists, cancel it. If the cancel failed because lost # the race to cancel it, then the display will load and some # some redundant code will be scheduled onto the main thread, but # that's okay, since at the next invocation of the delayed call # we shall get the correct display. We use a miro.timer here # rather than tacking onto the UI loop using call_on_ui_thread() # since we can't cancel it. if self.change_non_video_displays_dc: timer.cancel(self.change_non_video_displays_dc) self.change_non_video_displays_dc = None self.change_non_video_displays_dc = timer.add(0.1, lambda: call_on_ui_thread( lambda: self.do_change_non_video_displays(display)))
def on_pressed(self, widget): if self.timeout: timer.cancel(self.timeout) self.button_down = True self.button_held = False self.timeout = timer.add(self.initial_delay, self.on_button_hold)
def schedule_mark_as_watched(self, info): # Note: mark_as_watched time should match the minimum resume # time in update_current_resume_time. self.mark_as_watched_timeout = timer.add(3, self.mark_as_watched, info)
def blink_tab(self, tab_id): self.show_auto_tab(tab_id) self.view.blink_tab(self.iter_map[tab_id]) timer.add(1, self._unblink_tab, tab_id)
def _on_download_started(self, widget): """ Shows the download started icon for 5 seconds, then hide it. """ self.toolbar.loading_icon.set_download(True) timer.add(5, lambda: self.toolbar.loading_icon.set_download(False))
def on_button_hold(self): self.button_held = True self.emit('held-down') self.timeout = timer.add(self.repeat_delay, self.on_button_hold)
def start(self, item_info): if item_info.id not in self.currently_animating: self.currently_animating.add(item_info.id) self.start_animation(item_info) timer.add(self.initial_delay(item_info), self._do_iteration, item_info.id, self.repeat_delay(item_info))
def _add_fake_tabs(self, info): TabList.add(self, self._fake_info(info, "Video"), info.id) TabList.add(self, self._fake_info(info, "Audio"), info.id) # OS X doesn't listen if we do it immediately, so wait a bit timer.add(0, self.set_folder_expanded, info.id, True)
def blink_tab(self, id): self.view.blink_tab(self.iter_map[id]) timer.add(1, self._unblink_tab, id)
def _schedule_throbber_timeout(self, id): timeout = timer.add(0.4, self._throbber_timeout, id) self._throbber_timeouts[id] = timeout