Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0, 1.0.1, and 1.0.2

cslist: extract method to insert csinfo to the item list

Changeset 5655c4b25d99

Parent 0d0955c1e3fb

by Yuki KODAMA

Changes to one file · Browse files at 5655c4b25d99 Showing diff from parent 0d0955c1e3fb Diff from another changeset...

 
480
481
482
483
484
485
 
 
 
486
487
488
 
548
549
550
551
 
552
553
554
555
556
 
557
558
559
 
574
575
576
577
578
579
 
580
581
582
 
622
623
624
 
 
 
 
 
 
 
 
 
625
626
627
 
640
641
642
 
643
644
645
646
647
 
 
 
 
 
 
 
 
 
 
648
649
650
 
480
481
482
 
 
 
483
484
485
486
487
488
 
548
549
550
 
551
552
 
 
 
 
553
554
555
556
 
571
572
573
 
 
 
574
575
576
577
 
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
 
644
645
646
647
648
649
650
651
 
652
653
654
655
656
657
658
659
660
661
662
663
664
@@ -480,9 +480,9 @@
  if pos < -1:   return None   def get_last(): - children = self.csbox.get_children() - return children[-1] - # -1 + child = self.csbox.get_children()[-1] + return isinstance(child, FixedHSeparator) and child or None + # last separator   if pos == -1:   return get_last()   # limiting case @@ -548,12 +548,9 @@
  # remove target csinfo   self.remove_csinfo(item)   - # insert csinfo before the last separator + # insert csinfo the end of the item list   item = self.curitems[-2] - info = self.add_csinfo(item) - info.show_all() - numc = len(self.csbox.get_children()) - self.csbox.reorder_child(info, numc - 2) + self.insert_csinfo(item, -1)     elif self.has_limit() and self.limit - 1 < insert:   if self.trans_to_show(insert) < self.limit: @@ -574,9 +571,7 @@
    # insert csinfo before snip box   item = self.curitems[self.limit - 1] - info = self.add_csinfo(item) - info.show_all() - self.csbox.reorder_child(info, self.limit - 2) + self.insert_csinfo(item, self.limit - 1)   else:   info = self.itemmap[self.showitems[pos]]['widget']   if insert < pos: @@ -622,6 +617,15 @@
  return FixedHSeparator()     def add_csinfo(self, item): + self.insert_csinfo(item, -1) + + def insert_csinfo(self, item, pos): + """ + item: String, revision number or patch file path to display. + pos: Number, an index of insertion point. If -1, indicates + the end of the item list. + """ + # create csinfo   wrapbox = gtk.VBox()   sep = self.create_sep()   wrapbox.pack_start(sep, False, False) @@ -640,11 +644,21 @@
  hbox.pack_start(info, False, False)   info = hbox   wrapbox.pack_start(info, False, False) + wrapbox.show_all()   self.csbox.pack_start(wrapbox, False, False)   self.itemmap[item] = {'widget': wrapbox,   'info': info,   'sep': sep} - return wrapbox + + # reorder it + children = self.csbox.get_children() + if 1 < len(children) and isinstance(children[-2], FixedHSeparator): + if pos == -1: + numc = len(children) + pos = numc - 2 + elif self.has_limit(): + pos = pos - 1 + self.csbox.reorder_child(wrapbox, pos)     def remove_csinfo(self, item):   info = self.itemmap[item]['widget']