def on_download_progress(self, progress): logger.debug("download progress: %f", progress) if not self.config.download_progress_bar: # reset the icon in case option was turned off during download if self.last_progress < 1: self.last_progress = 1 self.set_icon() # in any case, we're now done return if progress == 1: self.set_icon() # no progress bar self.last_progress = progress return # Only update in 3-percent-steps to save some resources if abs(progress - self.last_progress) < 0.03 and progress > self.last_progress: return icon = self.get_icon_pixbuf().copy() progressbar = draw.progressbar_pixbuf(icon.get_width(), icon.get_height(), progress) progressbar.composite(icon, 0, 0, icon.get_width(), icon.get_height(), 0, 0, 1, 1, GdkPixbuf.InterpType.NEAREST, 255) self.status_icon.set_from_pixbuf(icon) self.last_progress = progress
def draw_progress_bar(self, ratio): """ Draw a progress bar on top of this tray icon. The ratio parameter should be a value from 0 to 1. """ # Only update in 3-percent-steps to save some resources if abs(ratio - self.__last_ratio) < 0.03 and ratio > self.__last_ratio: return icon = self.__current_pixbuf.copy() progressbar = draw.progressbar_pixbuf(icon.get_width(), icon.get_height(), ratio) progressbar.composite(icon, 0, 0, icon.get_width(), icon.get_height(), 0, 0, 1, 1, gtk.gdk.INTERP_NEAREST, 255) self.set_from_pixbuf(icon) self.__last_ratio = ratio
def draw_progress_bar(self, ratio): """ Draw a progress bar on top of this tray icon. The ratio parameter should be a value from 0 to 1. """ # Only update in 3-percent-steps to save some resources if abs(ratio-self.__last_ratio) < 0.03 and ratio > self.__last_ratio: return icon = self.__current_pixbuf.copy() progressbar = draw.progressbar_pixbuf(icon.get_width(), icon.get_height(), ratio) progressbar.composite(icon, 0, 0, icon.get_width(), icon.get_height(), 0, 0, 1, 1, gtk.gdk.INTERP_NEAREST, 255) self.set_from_pixbuf(icon) self.__last_ratio = ratio