def format_update_interval_value(self, scale, value): value = int(value) if value == 0: return _('manually') elif value > 0 and len(self.update_interval_presets) > value: return util.format_seconds_to_hour_min_sec(self.update_interval_presets[value]*60) else: return str(value)
def __on_download_progress_changed( self, count, percentage): """ callback by download manager during dowloading. It updates the tooltip with information on how many files are dowloaded and the percentage of dowload """ tooltip=[] if count > 0: self.__is_downloading=True if not self.__download_start_time: self.__download_start_time=datetime.datetime.now() if count == 1: tooltip.append(_('downloading one episode')) else: tooltip.append(_('downloading %d episodes')%count) tooltip.append(' (%d%%) :'%percentage) downloading=[] for episode in self.__finished_downloads: downloading.append(_("%s (completed)") % episode) for status in services.download_status_manager.status_list.values(): downloading.append(status['thread'].episode.title + " (%d%% - %s)" % (status['progress'], status['speed'])) tooltip.append(self.format_episode_list(downloading)) if percentage <> 0: date_diff=datetime.datetime.now() - self.__download_start_time estim=date_diff.seconds * 100 // percentage - date_diff.seconds tooltip.append('\n' + _('Estimated remaining time: ')) tooltip.append(util.format_seconds_to_hour_min_sec(estim)) self.set_status(self.STATUS_DOWNLOAD_IN_PROGRESS, ''.join(tooltip)) self.progress_bar(float(percentage)/100.) else: self.__is_downloading=False self.__download_start_time=None self.set_status() num=len(self.__finished_downloads) if num == 1: title=_('one episodes downloaded:') elif num > 1: title=_('%d episodes downloaded:')%num else: # No episodes have finished downloading, ignore return message=self.format_episode_list(self.__finished_downloads, title) self.send_notification(message, _('gPodder downloads finished')) self.__finished_downloads=[]
def format_update_interval_value(self, scale, value): value = int(value) ret = None if value == 0: ret = _('manually') elif value > 0 and len(self.update_interval_presets) > value: ret = util.format_seconds_to_hour_min_sec(self.update_interval_presets[value] * 60) else: ret = str(value) # bug in gtk3: value representation (pixels) must be smaller than value for highest value. # this makes sense when formatting e.g. 0 to 1000 where '1000' is the longest # string, but not when '10 minutes' is longer than '12 hours' # so we replace spaces with non breaking spaces otherwise '10 minutes' is displayed as '10' ret = ret.replace(' ', '\xa0') return ret
def format_update_interval_value(self, scale, value): value = int(value) if value == 0: return _('manual only') else: return util.format_seconds_to_hour_min_sec(self.update_interval_presets[int(value)]*60)