diff --git a/src/tab_details.py b/src/tab_details.py index d8addb28a..03774b820 100644 --- a/src/tab_details.py +++ b/src/tab_details.py @@ -61,8 +61,8 @@ class DetailsTabManager(object): self.next_announce = glade.get_widget("summary_next_announce") self.eta = glade.get_widget("summary_eta") self.torrent_path = glade.get_widget("summary_torrent_path") - self.advanced_progressbar=glade.get_widget("advanced_progressbar") - self.last_state=None + self.advanced_progressbar = glade.get_widget("advanced_progressbar") + self.last_state = None self.prefchanged_progress() self.manager.config.onValueChanged('use_advanced_bar',self.prefchanged_progress) @@ -75,40 +75,40 @@ class DetailsTabManager(object): self.progress_bar.show() self.advanced_progressbar.hide() - def paint_customprogress(self,arg1=None,arg2=None): + def paint_customprogress(self, arg1=None, arg2=None): # Draw the custom progress bar - progress_window=self.custom_progress.window - colormap=self.custom_progress.get_colormap() - gc=progress_window.new_gc() - size=progress_window.get_size() - progress_window.begin_paint_rect(gtk.gdk.Rectangle(0,0,size[0],size[1])) - height=size[1] - if height>25: height=25 - top=(size[1]-height)/2 + progress_window = self.custom_progress.window + colormap = self.custom_progress.get_colormap() + gc = progress_window.new_gc() + size = progress_window.get_size() + progress_window.begin_paint_rect(gtk.gdk.Rectangle(0, 0, size[0], size[1])) + height = size[1] + if height > 25: height = 25 + top = (size[1] - height) / 2 gc.set_foreground(colormap.alloc_color('#F0F0FF')) - progress_window.draw_rectangle(gc,True,0,top,size[0],height-1) + progress_window.draw_rectangle(gc, True, 0, top, size[0], height - 1) gc.set_foreground(colormap.alloc_color('#A0A0AF')) - progress_window.draw_line(gc,0,top+4,size[0],top+4) - state=self.last_state - if state!=None: + progress_window.draw_line(gc, 0, top + 4, size[0], top + 4) + state = self.last_state + if state != None: gc.set_foreground(colormap.alloc_color('#2020FF')) - progress_window.draw_rectangle(gc,True,0,top,int(size[0]*float(state['progress'])),4) - num_pieces=state["num_pieces"] + progress_window.draw_rectangle(gc, True, 0, top, int(size[0] * float(state['progress'])), 4) + num_pieces = state["num_pieces"] for pieces_range in state['pieces']: - range_first=pieces_range[0]*size[0]/num_pieces - range_length=((pieces_range[1]-pieces_range[0]+1)*size[0]/num_pieces) - if range_length==0: - range_length=1 + range_first = pieces_range[0] * size[0] / num_pieces + range_length = ((pieces_range[1] - pieces_range[0] + 1) * size[0] / num_pieces) + if range_length == 0: + range_length = 1 gc.set_foreground(colormap.alloc_color('#8080FF')) else: gc.set_foreground(colormap.alloc_color('#2020FF')) - progress_window.draw_rectangle(gc,True,range_first,top+5,range_length,height-5) + progress_window.draw_rectangle(gc, True, range_first, top + 5, range_length, height - 5) gc.set_foreground(colormap.alloc_color('dim gray')) - progress_window.draw_line(gc,0,top,0,top+height) - progress_window.draw_line(gc,0,top,size[0],top) + progress_window.draw_line(gc, 0, top, 0, top + height) + progress_window.draw_line(gc, 0, top, size[0], top) gc.set_foreground(colormap.alloc_color('white')) - progress_window.draw_line(gc,0,top+height,size[0]-1,top+height) - progress_window.draw_line(gc,size[0]-1,top,size[0]-1,top+height) + progress_window.draw_line(gc, 0, top + height, size[0] - 1, top + height) + progress_window.draw_line(gc, size[0] - 1, top, size[0] - 1, top + height) progress_window.end_paint() # Done drawing custom progress bar @@ -192,3 +192,6 @@ class DetailsTabManager(object): self.next_announce.set_text("") self.eta.set_text("") self.torrent_path.set_text("") + if self.use_advanced_bar: + self.last_state = None + self.paint_customprogress()