def createNumIcon(self, index):
     '''Create num icon.'''
     numBox = gtk.EventBox()
     numLabel = gtk.Label()
     if self.pageIndex == index:
         numColor = '#BB00BB'
     else:
         numColor = '#1A3E88'
     numLabel.set_markup(("<span foreground='%s' size='%s'>%s</span>" % (numColor, LABEL_FONT_SIZE, str(index))))
     numBox.add(numLabel)
     numBox.connect("button-press-event", lambda widget, event: self.jumpPage(index))
     numBox.connect("expose-event", lambda w, e: drawBackground(w, e, "#FFFFFF"))
     utils.setClickableCursor(numBox)
     
     return numBox
 def createIndexbar(self):
     '''Create bottom bar.'''
     # Init.
     paddingX = 5
     paddingY = 5
         
     # Just render when application more than one page.
     if self.appNum > self.defaultRows * self.pageSize:
         # Create index box.
         box = gtk.HBox()
         align = gtk.Alignment()
         align.set(0.5, 1.0, 0.0, 0.0)
         align.set_padding(paddingY, paddingY, paddingX, paddingX)
         align.add(box)
         
         # Get start/end index.
         if self.pageIndex % self.pageSize == 0:
             (startIndex, endIndex) = (max(1, (self.pageIndex - 1) / self.pageSize * self.pageSize + 1),
                                       min(self.pageIndex + 1,
                                           self.maxPageIndex + 1))
         else:
             (startIndex, endIndex) = (int(self.pageIndex / self.pageSize) * self.pageSize + 1, 
                                       min((int(self.pageIndex / self.pageSize) + 1) * self.pageSize + 1,
                                           self.maxPageIndex + 1))
         
         # Add index box.
         iconSize = 24
             
         # Don't add first icon if at first *page*.
         if startIndex != 1:
             # Add previous icon.
             prev = gtk.image_new_from_pixbuf(gtk.gdk.pixbuf_new_from_file("./icons/index/backward.png"))
             prevBox = gtk.EventBox()
             prevBox.add(prev)
             prevBox.connect("button-press-event", lambda widget, event: self.jumpPage(max(1, self.pageIndex - self.pageSize)))
             prevBox.connect("expose-event", lambda w, e: drawBackground(w, e, "#FFFFFF"))
             box.pack_start(prevBox, False, False, paddingX)
             utils.setClickableCursor(prevBox)
             
             first = gtk.Label()
             first.set_markup("<span foreground='#1A3E88' size='%s'>1 ... </span>" % (LABEL_FONT_SIZE))
             firstBox = gtk.EventBox()
             firstBox.add(first)
             firstBox.connect("button-press-event", lambda widget, event: self.jumpPage(1))
             firstBox.connect("expose-event", lambda w, e: drawBackground(w, e, "#FFFFFF"))
             box.pack_start(firstBox, False, False, paddingX)
             utils.setClickableCursor(firstBox)
         
         # Add index number icon.
         for i in range(startIndex, endIndex):
             box.pack_start(self.createNumIcon(i), False, False, paddingX)
         
         # Don't add last icon if at last *page*.
         if endIndex - 1 != self.maxPageIndex:
             last = gtk.Label()
             last.set_markup("<span foreground='#1A3E88' size='%s'> ... %s</span>" % (LABEL_FONT_SIZE, str(self.maxPageIndex)))
             lastBox = gtk.EventBox()
             lastBox.add(last)
             lastBox.connect("button-press-event", lambda widget, event: self.jumpPage(self.maxPageIndex))
             lastBox.connect("expose-event", lambda w, e: drawBackground(w, e, "#FFFFFF"))
             box.pack_start(lastBox, False, False, paddingX)
             utils.setClickableCursor(lastBox)
             
             # Add next icon.
             next = gtk.image_new_from_pixbuf(gtk.gdk.pixbuf_new_from_file("./icons/index/forward.png"))
             nextBox = gtk.EventBox()
             nextBox.add(next)
             nextBox.connect("button-press-event", lambda widget, event: self.jumpPage(min(self.maxPageIndex, 
                                                                                           self.pageIndex + self.pageSize)))
             nextBox.connect("expose-event", lambda w, e: drawBackground(w, e, "#FFFFFF"))
             box.pack_start(nextBox, False, False, paddingX)
             utils.setClickableCursor(nextBox)
         
         # Add jump button.
         spinButton = gtk.SpinButton()
         spinButton.set_digits(0)
         spinButton.set_increments(1, self.defaultRows)
         spinButton.set_range(1, self.maxPageIndex)
         spinButton.set_value(self.pageIndex)
         self.jumpButton = spinButton
         
         # Add jump label.
         jumpBeforeLabel = gtk.Label()
         jumpBeforeLabel.set_markup("<span size='%s'>%s</span>" % (LABEL_FONT_SIZE, "跳到第"))
         jumpAfterLabel = gtk.Label()
         jumpAfterLabel.set_markup("<span size='%s'>%s</span>" % (LABEL_FONT_SIZE, "页"))
         jumpButton = utils.newButtonWithoutPadding()
         jumpButton.connect("button-release-event", lambda widget, event: self.jumpPage(int(self.jumpButton.get_text())))
         drawButton(jumpButton, "confirm", "index", False, "确定", BUTTON_FONT_SIZE_SMALL)
         
         # Connect widget.
         box.pack_start(jumpBeforeLabel, False, False, paddingX)
         box.pack_start(spinButton, False, False, paddingX)
         box.pack_start(jumpAfterLabel, False, False, paddingX)
         box.pack_start(jumpButton, False, False, paddingX)
         
         return align
     elif self.appNum > self.defaultRows:
         # Init.
         box = gtk.HBox()
         align = gtk.Alignment()
         align.set(0.5, 1.0, 0.0, 0.0)
         align.set_padding(paddingY, paddingY, paddingX, paddingX)
         align.add(box)
         
         # Add index number icon.
         for i in range(1, self.maxPageIndex + 1):
             box.pack_start(self.createNumIcon(i), False, False, paddingX)
         
         return align
     else:
         return None