def show(self, scrollToTop=True):
     '''Show application view.'''
     # Remove child widgets first.
     utils.containerRemoveAll(self.box)
     self.itemDict.clear()
     
     if self.appNum != 0:
         # Get application list.
         appList = self.getListFunc((self.pageIndex - 1) * self.defaultRows,
                                    min(self.pageIndex * self.defaultRows, self.appNum)
                                    )
         
         # Create application view.
         self.box.pack_start(self.createAppList(appList))
         
         # Create index view.
         indexbar = self.createIndexbar()
         if not indexbar == None:
             self.box.pack_start(indexbar)
             
         self.box.show_all()
         
         # Request vote data.
         self.fetchVoteCallback(
             self.pageId, 
             map (lambda appInfo: utils.getPkgName(appInfo.pkg), appList),
             self.isSearchPage)
         
     # Scroll ScrolledWindow to top after render.
     if scrollToTop:
         utils.scrollToTop(self.scrolledwindow)
    def show(self):
        '''Show application view.'''
        # Remove child widgets first.
        utils.containerRemoveAll(self.box)
        self.itemDict.clear()

        if self.appNum != 0:
            # Get application list.
            sortType = self.getSortTypeFunc()
            appList = self.getListFunc(
                self.category, sortType,
                (self.pageIndex - 1) * self.defaultRows,
                min(self.pageIndex * self.defaultRows, self.appNum))

            # Create application view.
            self.box.pack_start(self.createAppList(appList))

            # Create index view.
            indexbar = self.createIndexbar()
            if not indexbar == None:
                self.box.pack_start(indexbar)

            # Show all.
            self.box.show_all()

            # Request vote data.
            self.fetchVoteCallback(
                PAGE_REPO,
                map(lambda appInfo: utils.getPkgName(appInfo.pkg), appList))

        # Scroll ScrolledWindow to top after render.
        utils.scrollToTop(self.scrolledwindow)
 def initNormalStatus(self):
     '''Init normal status.'''
     pkg = self.appInfo.pkg
     
     # Clean right box first.
     utils.containerRemoveAll(self.appAdditionBox)
     
     # Add application vote information.
     self.appVoteView = VoteView(
         self.appInfo, PAGE_UPGRADE, 
         self.sendVoteCallback)
     self.appAdditionBox.pack_start(self.appVoteView.eventbox, False, False)
     
     # Add application size.
     size = utils.getPkgSize(pkg)
     appSize = gtk.Label()
     appSize.set_size_request(self.SIZE_LABEL_WIDTH, -1)
     appSize.set_markup("<span size='%s'>%s</span>" % (LABEL_FONT_SIZE, utils.formatFileSize(size)))
     appSize.set_alignment(1.0, 0.5)
     self.appAdditionBox.pack_start(appSize, False, False, self.APP_RIGHT_PADDING_X)
     
     # Add ignore button.
     (ignoreLabel, ignoreEventBox) = setDefaultClickableDynamicLabel(
         __("Notify again"),
         "appIgnore",
         )
     ignoreEventBox.connect("button-press-event", 
                            lambda w, e: self.removeIgnorePkgCallback([utils.getPkgName(pkg)]))
     
     ignoreLabelPaddingX = 30
     ignoreAlign = gtk.Alignment()
     ignoreAlign.set(0.0, 0.5, 0.0, 0.0)
     ignoreAlign.set_padding(0, 0, ignoreLabelPaddingX, ignoreLabelPaddingX)
     ignoreAlign.add(ignoreEventBox)
     self.appAdditionBox.pack_start(ignoreAlign, False, False)
 def __init__(self, appInfo, 
              entryDetailCallback, sendVoteCallback,
              index, getSelectIndex, setSelectIndex,
              selectPkgCallback, unselectPkgCallback, 
              getSelectStatusCallback, removeIgnorePkgCallback):
     '''Init for application item.'''
     self.appInfo = appInfo
     self.entryDetailCallback = entryDetailCallback
     self.sendVoteCallback = sendVoteCallback
     self.selectPkgCallback = selectPkgCallback
     self.unselectPkgCallback = unselectPkgCallback
     self.getSelectStatusCallback = getSelectStatusCallback
     self.removeIgnorePkgCallback = removeIgnorePkgCallback
     self.checkButton = None
     self.index = index
     self.setSelectIndex = setSelectIndex
     
     # Init.
     self.itemBox = gtk.HBox()
     self.itemEventBox = gtk.EventBox()
     self.itemEventBox.connect("button-press-event", self.clickItem)
     self.itemEventBox.add(self.itemBox)
     drawListItem(self.itemEventBox, index, getSelectIndex)
     
     self.itemFrame = gtk.Alignment()
     self.itemFrame.set(0.0, 0.5, 1.0, 1.0)
     self.itemFrame.add(self.itemEventBox)
     
     # Add check box.
     checkPaddingLeft = 20
     checkPaddingRight = 15
     checkPaddingY = 10
     self.checkButton = gtk.CheckButton()
     self.checkButton.set_active(self.getSelectStatusCallback(utils.getPkgName(self.appInfo.pkg)))
     self.checkButton.connect("toggled", lambda w: self.toggleSelectStatus())
     checkButtonSetBackground(
         self.checkButton,
         False, False, 
         "cell/select.png",
         "cell/selected.png",
         )
     self.checkAlign = gtk.Alignment()
     self.checkAlign.set(0.5, 0.5, 0.0, 0.0)
     self.checkAlign.set_padding(checkPaddingY, checkPaddingY, checkPaddingLeft, checkPaddingRight)
     self.checkAlign.add(self.checkButton)
     self.itemBox.pack_start(self.checkAlign, False, False)
     
     self.appBasicView = AppBasicView(self.appInfo, 300 + APP_BASIC_WIDTH_ADJUST, self.itemBox, self.entryDetailView) 
     self.itemBox.pack_start(self.appBasicView.align, True, True)
     
     self.appAdditionBox = gtk.HBox()
     self.appAdditionAlign = gtk.Alignment()
     self.appAdditionAlign.set(1.0, 0.5, 0.0, 0.0)
     self.appAdditionAlign.add(self.appAdditionBox)
     self.itemBox.pack_start(self.appAdditionAlign, False, False)
     
     self.initAdditionStatus()
    
     self.itemFrame.show_all()
 def sendVote(self):
     '''Send vote.'''
     if self.starView != None:
         name = utils.getPkgName(self.appInfo.pkg)
         vote = self.starView.getStarLevel()
         self.sendVoteCallback(name, vote)
     else:
         print "sendVote: starView is None, send vote failed."
 def toggleSelectStatus(self):
     '''Toggle select status.'''
     selectStatus = self.checkButton.get_active()    
     pkgName = utils.getPkgName(self.appInfo.pkg)
     if selectStatus:
         self.selectPkgCallback(pkgName)
     else:
         self.unselectPkgCallback(pkgName)
 def switchToNormal(self):
     '''Switch to normal.'''
     pkgName = utils.getPkgName(self.appInfo.pkg)
     if self.appInfo.pkg.is_upgradable:
         self.switchStatus(pkgName, APP_STATE_UPGRADE)
     else:
         self.switchStatus(pkgName, APP_STATE_NORMAL)
     self.downloadQueue.stopDownload(pkgName)
 def sendVote(self):
     '''Send vote.'''
     if self.starView != None:
         name = utils.getPkgName(self.appInfo.pkg)                
         vote = self.starView.getStarLevel()
         self.sendVoteCallback(name, vote)
     else:
         print "sendVote: starView is None, send vote failed."
 def switchToNormal(self):
     '''Switch to normal.'''
     pkgName = utils.getPkgName(self.appInfo.pkg)
     self.downloadQueue.stopDownload(pkgName)
     if self.appInfo.pkg.is_upgradable:
         self.switchStatus(pkgName, APP_STATE_UPGRADE)
     else:
         self.switchStatus(pkgName, APP_STATE_NORMAL)
 def toggleSelectStatus(self):
     '''Toggle select status.'''
     selectStatus = self.checkButton.get_active()
     pkgName = utils.getPkgName(self.appInfo.pkg)
     if selectStatus:
         self.selectPkgCallback(pkgName)
     else:
         self.unselectPkgCallback(pkgName)
 def show(self, scrollToTop=True):
     '''Show application view.'''
     # Remove child widgets first.
     utils.containerRemoveAll(self.box)
     self.itemDict.clear()
     
     # If i don't re-connect self.eventbox and self.box,
     # update view will show nothing.
     # I still can't understand why?
     # Maybe this is bug of GtkEventBox?
     utils.containerRemoveAll(self.eventbox)
     self.eventbox.add(self.box)
     
     if self.appNum == 0:
         notifyBox = gtk.HBox()
         notifyAlign = gtk.Alignment()
         notifyAlign.set(0.5, 0.5, 0.0, 0.0)
         notifyAlign.add(notifyBox)
         self.box.pack_start(notifyAlign)
         
         notifyIconAlignX = 5
         notifyIcon = gtk.image_new_from_file("./icons/update/smile.gif")
         notifyIconAlign = gtk.Alignment()
         notifyIconAlign.set(0.5, 1.0, 0.0, 0.0)
         notifyIconAlign.set_padding(0, 0, notifyIconAlignX, notifyIconAlignX)
         notifyIconAlign.add(notifyIcon)
         notifyBox.pack_start(notifyIconAlign)
         
         notifyLabel = gtk.Label()
         notifyLabel.set_markup("<span foreground='#1A38EE' size='%s'>%s</span>" % (LABEL_FONT_XX_LARGE_SIZE, "你的系统已经是最新的. :)"))
         notifyBox.pack_start(notifyLabel, False, False)
         
         self.box.show_all()
     else:
         # Get application list.
         appList = self.getListFunc(
             (self.pageIndex - 1) * self.defaultRows,
             min(self.pageIndex * self.defaultRows, self.appNum)
             )
         
         # Create application view.
         self.box.pack_start(self.createAppList(appList))
         
         # Create index view.
         indexbar = self.createIndexbar()
         if not indexbar == None:
             self.box.pack_start(indexbar)
             
         self.box.show_all()
         
         # Request vote data.
         self.fetchVoteCallback(
             PAGE_UPGRADE, 
             map (lambda appInfo: utils.getPkgName(appInfo.pkg), appList))
         
     # Scroll ScrolledWindow to top after render.
     if scrollToTop:
         utils.scrollToTop(self.scrolledwindow)
 def show(self):
     '''Show application view.'''
     # Remove child widgets first.
     utils.containerRemoveAll(self.box)
     self.itemDict.clear()
     
     if self.appNum == 0:
         if (getDefaultLanguage() == "default"):
             paddingX = 10
         else:
             paddingX = 45
         
         notifyBox = gtk.VBox()
         notifyAlign = gtk.Alignment()
         notifyAlign.set(0.5, 0.5, 0.0, 0.0)
         notifyAlign.add(notifyBox)
         self.box.pack_start(notifyAlign)
         
         tipImage = gtk.image_new_from_pixbuf(
             gtk.gdk.pixbuf_new_from_file("../icon/tips/%s/downloadTip.png" % (getDefaultLanguage())))
         tipAlign = gtk.Alignment()
         tipAlign.set_padding(0, 0, paddingX, 0)
         tipAlign.add(tipImage)
         notifyBox.pack_start(tipAlign)
         
         penguinImage = gtk.image_new_from_pixbuf(
             gtk.gdk.pixbuf_new_from_file("../icon/tips/penguin.png"))
         penguinAlign = gtk.Alignment()
         penguinAlign.set_padding(0, 0, 0, paddingX)
         penguinAlign.add(penguinImage)
         notifyBox.pack_start(penguinAlign)
         
         self.box.show_all()
     else:
         # Get application list.
         appList = self.getListFunc(
             (self.pageIndex - 1) * self.defaultRows,
             min(self.pageIndex * self.defaultRows, self.appNum)
             )
         
         # Create application view.
         self.box.pack_start(self.createAppList(appList))
         
         # Create index view.
         indexbar = self.createIndexbar()
         if not indexbar == None:
             self.box.pack_start(indexbar)
         
         # Show all.
         self.box.show_all()
         
         # Request vote data.
         self.fetchVoteCallback(
             PAGE_DOWNLOAD_MANAGE, 
             map (lambda appInfo: utils.getPkgName(appInfo.pkg), appList))
         
     # Scroll ScrolledWindow to top after render.
     utils.scrollToTop(self.scrolledwindow)
 def show(self):
     '''Show application view.'''
     # Remove child widgets first.
     utils.containerRemoveAll(self.box)
     self.itemDict.clear()
     
     if self.appNum == 0:
         if (getDefaultLanguage() == "default"):
             paddingX = 10
         else:
             paddingX = 45
         
         notifyBox = gtk.VBox()
         notifyAlign = gtk.Alignment()
         notifyAlign.set(0.5, 0.5, 0.0, 0.0)
         notifyAlign.add(notifyBox)
         self.box.pack_start(notifyAlign)
         
         tipImage = gtk.image_new_from_pixbuf(
             gtk.gdk.pixbuf_new_from_file("../icon/tips/%s/downloadTip.png" % (getDefaultLanguage())))
         tipAlign = gtk.Alignment()
         tipAlign.set_padding(0, 0, paddingX, 0)
         tipAlign.add(tipImage)
         notifyBox.pack_start(tipAlign)
         
         penguinImage = gtk.image_new_from_pixbuf(
             gtk.gdk.pixbuf_new_from_file("../icon/tips/penguin.png"))
         penguinAlign = gtk.Alignment()
         penguinAlign.set_padding(0, 0, 0, paddingX)
         penguinAlign.add(penguinImage)
         notifyBox.pack_start(penguinAlign)
         
         self.box.show_all()
     else:
         # Get application list.
         appList = self.getListFunc(
             (self.pageIndex - 1) * self.defaultRows,
             min(self.pageIndex * self.defaultRows, self.appNum)
             )
         
         # Create application view.
         self.box.pack_start(self.createAppList(appList))
         
         # Create index view.
         indexbar = self.createIndexbar()
         if not indexbar == None:
             self.box.pack_start(indexbar)
         
         # Show all.
         self.box.show_all()
         
         # Request vote data.
         self.fetchVoteCallback(
             PAGE_DOWNLOAD_MANAGE, 
             map (lambda appInfo: utils.getPkgName(appInfo.pkg), appList))
         
     # Scroll ScrolledWindow to top after render.
     utils.scrollToTop(self.scrolledwindow)
 def entryDetailView(self, pageId, appInfo):
     '''Entry detail view.'''
     view = detailView.DetailView(
         self.aptCache, pageId, appInfo, self.switchStatus, self.downloadQueue, self.actionQueue,
         self.exitDetailView, self.noscreenshotList, self.updateMoreComment, self.message)
     self.detailViewDict[pageId] = view
     
     # Fetch detail thread.
     fetchDetailThread = FetchDetail(pageId, utils.getPkgName(appInfo.pkg), self.updateDetailView)
     fetchDetailThread.start()
     
     self.selectPage(pageId)
 def createAppList(self, appList):
     '''Create application list.'''
     itemPaddingY = 5
     
     box = gtk.VBox()
     for (index, appInfo) in enumerate(appList):
         appItem = DownloadManageItem(appInfo, self.switchStatus, self.downloadQueue, 
                                      self.entryDetailCallback,
                                      self.sendVoteCallback,
                                      index, self.getSelectItemIndex, self.setSelectItemIndex)
         self.box.pack_start(appItem.itemFrame, False, False)
         self.itemDict[utils.getPkgName(appItem.appInfo.pkg)] = appItem
     
     return box
    def initNormalStatus(self):
        '''Init normal status.'''
        pkg = self.appInfo.pkg

        # Clean right box first.
        utils.containerRemoveAll(self.appAdditionBox)

        # Add application vote information.
        self.appVoteView = VoteView(self.appInfo, PAGE_UPGRADE,
                                    self.sendVoteCallback)
        self.appAdditionBox.pack_start(self.appVoteView.eventbox, False, False)

        # Add application size.
        size = utils.getPkgSize(pkg)

        appSizeLabel = DynamicSimpleLabel(
            self.appAdditionBox,
            utils.formatFileSize(size),
            appTheme.getDynamicColor("appSize"),
            LABEL_FONT_SIZE,
        )
        appSize = appSizeLabel.getLabel()

        appSize.set_size_request(self.SIZE_LABEL_WIDTH, -1)
        appSize.set_alignment(1.0, 0.5)
        self.appAdditionBox.pack_start(appSize, False, False,
                                       self.APP_RIGHT_PADDING_X)

        # Add ignore button.
        (ignoreLabel, ignoreEventBox) = setDefaultClickableDynamicLabel(
            __("Don't Notify"),
            "appIgnore",
        )
        self.appAdditionBox.pack_start(ignoreEventBox, False, False)
        ignoreEventBox.connect(
            "button-press-event",
            lambda w, e: self.addIgnorePkgCallback(utils.getPkgName(pkg)))

        # Add action button.
        (actionButtonBox, actionButtonAlign) = createActionButton()
        self.appAdditionBox.pack_start(actionButtonAlign, False, False)

        (appButton, appButtonAlign) = newActionButton("update", 0.5, 0.5,
                                                      "cell", False,
                                                      __("Action Update"),
                                                      BUTTON_FONT_SIZE_SMALL,
                                                      "buttonFont")
        appButton.connect("button-release-event",
                          lambda widget, event: self.switchToDownloading())
        actionButtonBox.pack_start(appButtonAlign)
 def createAppList(self, appList):
     '''Create application list.'''
     itemPaddingY = 5
     
     box = gtk.VBox()
     for (index, appInfo) in enumerate(appList):
         appItem = DownloadManageItem(appInfo, self.switchStatus, self.downloadQueue, 
                                      self.entryDetailCallback,
                                      self.sendVoteCallback,
                                      index, self.getSelectItemIndex, self.setSelectItemIndex)
         self.box.pack_start(appItem.itemFrame, False, False)
         self.itemDict[utils.getPkgName(appItem.appInfo.pkg)] = appItem
     
     return box
 def createAppList(self, appList):
     '''Create application list.'''
     # Init.
     itemPaddingY = 5
     
     box = gtk.VBox()
     for (index, appInfo) in enumerate(appList):
         appItem = UninstallItem(appInfo, self.actionQueue, 
                                 self.entryDetailCallback, 
                                 self.sendVoteCallback,
                                 index, self.getSelectItemIndex, self.setSelectItemIndex)
         box.pack_start(appItem.itemFrame, False, False)
         self.itemDict[utils.getPkgName(appItem.appInfo.pkg)] = appItem
         
     return box
    def initNormalStatus(self):
        '''Init normal status.'''
        pkg = self.appInfo.pkg
        
        # Clean right box first.
        utils.containerRemoveAll(self.appAdditionBox)
        
        # Add application vote information.
        self.appVoteView = VoteView(
            self.appInfo, PAGE_UPGRADE, 
            self.sendVoteCallback)
        self.appAdditionBox.pack_start(self.appVoteView.eventbox, False, False)
        
        # Add application size.
        size = utils.getPkgSize(pkg)

        appSizeLabel = DynamicSimpleLabel(
            self.appAdditionBox,
            utils.formatFileSize(size),
            appTheme.getDynamicColor("appSize"),
            LABEL_FONT_SIZE,
            )
        appSize = appSizeLabel.getLabel()
        
        appSize.set_size_request(self.SIZE_LABEL_WIDTH, -1)
        appSize.set_alignment(1.0, 0.5)
        self.appAdditionBox.pack_start(appSize, False, False, self.APP_RIGHT_PADDING_X)
        
        # Add ignore button.
        (ignoreLabel, ignoreEventBox) = setDefaultClickableDynamicLabel(
            __("Don't Notify"),
            "appIgnore",
            )
        self.appAdditionBox.pack_start(ignoreEventBox, False, False)
        ignoreEventBox.connect("button-press-event", 
                               lambda w, e: self.addIgnorePkgCallback(utils.getPkgName(pkg)))
        
        # Add action button.
        (actionButtonBox, actionButtonAlign) = createActionButton()
        self.appAdditionBox.pack_start(actionButtonAlign, False, False)
        
        (appButton, appButtonAlign) = newActionButton(
            "update", 0.5, 0.5, "cell", False, __("Action Update"), BUTTON_FONT_SIZE_SMALL, "buttonFont")
        appButton.connect("button-release-event", lambda widget, event: self.switchToDownloading())
        actionButtonBox.pack_start(appButtonAlign)
Exemple #20
0
 def initBasicBox(self):
     '''Create item information.'''
     # Init.
     pkg = self.appInfo.pkg
     
     # Add application icon.
     appIcon = createAppIcon(pkg)
     self.appIconBox.pack_start(appIcon, False, False)
     
     # Add application name.
     pkgName = utils.getPkgName(pkg)
     (appName, appNameEventBox) = setDefaultClickableDynamicLabel(
         pkgName,
         "appName",
         LABEL_FONT_SIZE,
         )
     appName.set_size_request(self.NAME_WIDTH, -1)
     appName.set_single_line_mode(True)
     appName.set_alignment(0.0, 0.5)
     appNameEventBox.connect(
         "button-press-event",
         lambda w, e: self.entryDetailView())
     
     utils.showVersionTooltip(appNameEventBox, pkg)
     
     self.appNameBox.pack_start(appNameEventBox, False, False)
     
     # Add application summary.
     summary = utils.getPkgShortDesc(pkg)
     appSummaryLabel = DynamicSimpleLabel(
         self.appSummaryBox,
         summary,
         appTheme.getDynamicColor("appSummary"),
         LABEL_FONT_SIZE
         )
     appSummary = appSummaryLabel.getLabel()
     appSummary.set_size_request(self.SUMMARY_WIDTH, -1)
     appSummary.set_single_line_mode(True)
     appSummary.set_ellipsize(pango.ELLIPSIZE_END)
     appSummary.set_alignment(0.0, 0.5)
     self.appSummaryBox.pack_start(appSummary, False, False)
     self.appStatusBox.pack_start(self.appSummaryBox, False, False)
 def show(self, scrollToTop=True):
     '''Show application view.'''
     # Remove child widgets first.
     utils.containerRemoveAll(self.box)
     self.itemDict.clear()
     
     # If i don't re-connect self.eventbox and self.box,
     # update view will show nothing.
     # I still can't understand why?
     # Maybe this is bug of GtkEventBox?
     utils.containerRemoveAll(self.eventbox)
     self.eventbox.add(self.box)
     
     if self.appNum != 0:
         # Get application list.
         appList = self.getListFunc((self.pageIndex - 1) * self.defaultRows,
                                    min(self.pageIndex * self.defaultRows, self.appNum)
                                    )
         
         # Create application view.
         self.box.pack_start(self.createAppList(appList))
         
         # Create index view.
         indexbar = self.createIndexbar()
         if not indexbar == None:
             self.box.pack_start(indexbar)
             
         self.box.show_all()
         
         # Request vote data.
         self.fetchVoteCallback(
             self.pageId, 
             map (lambda appInfo: utils.getPkgName(appInfo.pkg), appList),
             self.isSearchPage)
         
     # Scroll ScrolledWindow to top after render.
     if scrollToTop:
         utils.scrollToTop(self.scrolledwindow)
 def show(self, scrollToTop=True):
     '''Show application view.'''
     # Remove child widgets first.
     utils.containerRemoveAll(self.box)
     self.itemDict.clear()
     
     # If i don't re-connect self.eventbox and self.box,
     # update view will show nothing.
     # I still can't understand why?
     # Maybe this is bug of GtkEventBox?
     utils.containerRemoveAll(self.eventbox)
     self.eventbox.add(self.box)
     
     if self.appNum != 0:
         # Get application list.
         appList = self.getListFunc((self.pageIndex - 1) * self.defaultRows,
                                    min(self.pageIndex * self.defaultRows, self.appNum)
                                    )
         
         # Create application view.
         self.box.pack_start(self.createAppList(appList))
         
         # Create index view.
         indexbar = self.createIndexbar()
         if not indexbar == None:
             self.box.pack_start(indexbar)
             
         self.box.show_all()
         
         # Request vote data.
         self.fetchVoteCallback(
             self.pageId, 
             map (lambda appInfo: utils.getPkgName(appInfo.pkg), appList),
             self.isSearchPage)
         
     # Scroll ScrolledWindow to top after render.
     if scrollToTop:
         utils.scrollToTop(self.scrolledwindow)
    def initNormalStatus(self):
        '''Init normal status.'''
        pkg = self.appInfo.pkg

        # Clean right box first.
        utils.containerRemoveAll(self.appAdditionBox)

        # Add application vote information.
        self.appVoteView = VoteView(self.appInfo, PAGE_UPGRADE,
                                    self.sendVoteCallback)
        self.appAdditionBox.pack_start(self.appVoteView.eventbox, False, False)

        # Add application size.
        size = utils.getPkgSize(pkg)
        appSize = gtk.Label()
        appSize.set_size_request(self.SIZE_LABEL_WIDTH, -1)
        appSize.set_markup("<span size='%s'>%s</span>" %
                           (LABEL_FONT_SIZE, utils.formatFileSize(size)))
        appSize.set_alignment(1.0, 0.5)
        self.appAdditionBox.pack_start(appSize, False, False,
                                       self.APP_RIGHT_PADDING_X)

        # Add ignore button.
        (ignoreLabel, ignoreEventBox) = setDefaultClickableDynamicLabel(
            __("Notify again"),
            "appIgnore",
        )
        ignoreEventBox.connect(
            "button-press-event",
            lambda w, e: self.removeIgnorePkgCallback([utils.getPkgName(pkg)]))

        ignoreLabelPaddingX = 30
        ignoreAlign = gtk.Alignment()
        ignoreAlign.set(0.0, 0.5, 0.0, 0.0)
        ignoreAlign.set_padding(0, 0, ignoreLabelPaddingX, ignoreLabelPaddingX)
        ignoreAlign.add(ignoreEventBox)
        self.appAdditionBox.pack_start(ignoreAlign, False, False)
 def updateMoreComment(self, pageId, pkgName, voteJson):
     '''Update vote view.'''
     if self.detailViewDict.has_key(pageId):
         detailView = self.detailViewDict[pageId]
         if pkgName == utils.getPkgName(detailView.appInfo.pkg):
             detailView.updateMoreComment(voteJson)
 def switchToDownloading(self):
     '''Switch to downloading.'''
     pkgName = utils.getPkgName(self.appInfo.pkg)
     self.downloadQueue.addDownload(pkgName)
     self.switchStatus(pkgName, APP_STATE_DOWNLOADING)
 def __init__(self, appInfo, maxWidth, parent, entryDetailCallback):
     '''Init application basic view.'''
     # Init.
     self.align = gtk.Alignment()
     self.align.set(0.0, 0.5, 1.0, 1.0)
     self.commentNum = 0
     
     appBasicBox = gtk.HBox()
     self.align.add(appBasicBox)
     pkg = appInfo.pkg
     
     # Add application icon.
     appIcon = createAppIcon(pkg)
     appBasicBox.pack_start(appIcon, False, False)
     
     # Add application left box.
     appBox = gtk.VBox()
     appAlign = gtk.Alignment()
     appAlign.set(0.0, 0.5, 0.0, 0.0)
     appAlign.add(appBox)
     appBasicBox.pack_start(appAlign)
     
     # Add application name.
     pkgName = utils.getPkgName(pkg)
     
     appNameLabel = DynamicLabel(
         parent,
         pkgName,
         appTheme.getDynamicLabelColor("appName"), 
         LABEL_FONT_SIZE,
         )
     appName = appNameLabel.getLabel()
     
     appName.set_single_line_mode(True)
     appName.set_alignment(0.0, 0.0)
     
     self.appNameBox = gtk.HBox()
     self.appNameBox.pack_start(appName, False, False)
     
     self.appCommentNumBox = gtk.VBox()
     self.appNameBox.pack_start(self.appCommentNumBox, True, True)
     
     appNameEventBox = gtk.EventBox()
     appNameEventBox.add(self.appNameBox)
     appNameEventBox.set_visible_window(False)
     appNameEventBox.connect(
         "button-press-event",
         lambda w, e: entryDetailCallback())
     appBox.pack_start(appNameEventBox, False, False)
     
     utils.showVersionTooltip(appNameEventBox, pkg)
     
     setClickableDynamicLabel(
         appNameEventBox,
         appNameLabel,
         )
     
     # Add application summary.
     summary = utils.getPkgShortDesc(pkg)
     appSummaryBox = gtk.HBox()
     appSummaryLabel = DynamicSimpleLabel(
         parent,
         summary,
         appTheme.getDynamicColor("appSummary"),
         LABEL_FONT_SIZE
         )
     appSummary = appSummaryLabel.getLabel()
     parent.connect("size-allocate", 
                    lambda w, e: adjustLabelWidth(parent, 
                                                  appSummary,
                                                  LABEL_FONT_SIZE / 1000,
                                                  maxWidth))
     
     appSummary.set_single_line_mode(True)
     appSummary.set_ellipsize(pango.ELLIPSIZE_END)
     appSummary.set_alignment(0.0, 0.5)
     appSummaryBox.pack_start(appSummary, False, False)
     appBox.pack_start(appSummaryBox, False, False)
def createItemBasicBox(appInfo, maxWidth, parent, showVersion=True):
    '''Create item information.'''
    # Init.
    appBasicAlign = gtk.Alignment()
    appBasicAlign.set(0.0, 0.5, 1.0, 1.0)
    
    appBasicBox = gtk.HBox()
    appBasicAlign.add(appBasicBox)
    pkg = appInfo.pkg
    
    # Add application icon.
    appIcon = createAppIcon(pkg)
    appBasicBox.pack_start(appIcon, False, False)
    
    # Add application left box.
    appBox = gtk.VBox()
    appAlign = gtk.Alignment()
    appAlign.set(0.0, 0.5, 0.0, 0.0)
    appAlign.add(appBox)
    appBasicBox.pack_start(appAlign)
    
    # Add application name.
    pkgName = utils.getPkgName(pkg)
    appName = gtk.Label()
    parent.connect("size-allocate", 
                   lambda w, e: adjustLabelWidth(parent, 
                                                 appName,
                                                 LABEL_FONT_SIZE / 1000,
                                                 maxWidth))
    
    appName.set_single_line_mode(True)
    appName.set_ellipsize(pango.ELLIPSIZE_END)
    appName.set_alignment(0.0, 0.5)
    appBox.pack_start(appName, False, False)
    
    pkgVersion = utils.getPkgVersion(pkg)
    nameMarkup = "<span foreground='#1A3E88' size='%s'>%s</span>" % (LABEL_FONT_SIZE, pkgName)
    versionMarkup = "<span foreground='#00BB00' size='%s'> (%s)</span>" % (LABEL_FONT_SIZE, pkgVersion)
    if showVersion:
        appName.set_markup(nameMarkup + versionMarkup)
    else:
        appName.set_markup(nameMarkup)
    
    # Add application summary.
    summary = utils.getPkgShortDesc(pkg)
    appSummaryBox = gtk.HBox()
    appSummary = gtk.Label()
    appSummary.set_markup("<span foreground='#000000' size='%s'>%s</span>" % (LABEL_FONT_SIZE, summary))
    parent.connect("size-allocate", 
                   lambda w, e: adjustLabelWidth(parent, 
                                                 appSummary,
                                                 LABEL_FONT_SIZE / 1000,
                                                 maxWidth))
    
    appSummary.set_single_line_mode(True)
    appSummary.set_ellipsize(pango.ELLIPSIZE_END)
    appSummary.set_alignment(0.0, 0.5)
    appSummaryBox.pack_start(appSummary, False, False)
    appBox.pack_start(appSummaryBox, False, False)
    
    return appBasicAlign
 def switchToDownloading(self):
     '''Switch to downloading.'''
     pkgName = utils.getPkgName(self.appInfo.pkg)
     self.switchStatus(pkgName, APP_STATE_DOWNLOADING)
     self.downloadQueue.addDownload(pkgName)
 def switchToDownloadPause(self):
     '''Switch to pause.'''
     pkgName = utils.getPkgName(self.appInfo.pkg)
     self.switchStatus(pkgName, APP_STATE_DOWNLOAD_PAUSE)
     self.downloadQueue.stopDownload(pkgName)
 def switchToUninstalling(self):
     '''Switch to uninstalling.'''
     self.appInfo.status = APP_STATE_UNINSTALLING
     self.initAdditionStatus()
     self.actionQueue.addAction(utils.getPkgName(self.appInfo.pkg), ACTION_UNINSTALL)
 def switchToUninstalling(self):
     '''Switch to un-installing.'''
     self.appInfo.status = APP_STATE_UNINSTALLING
     self.initAdditionStatus()
     self.actionQueue.addAction(utils.getPkgName(self.appInfo.pkg),
                                ACTION_UNINSTALL)
 def show(self, scrollToTop=True):
     '''Show application view.'''
     # Remove child widgets first.
     utils.containerRemoveAll(self.box)
     self.itemDict.clear()
     
     # If i don't re-connect self.eventbox and self.box,
     # update view will show nothing.
     # I still can't understand why?
     # Maybe this is bug of GtkEventBox?
     utils.containerRemoveAll(self.eventbox)
     self.eventbox.add(self.box)
     
     if self.appNum == 0:
         if (getDefaultLanguage() == "default"):
             paddingX = 10
         else:
             paddingX = 0
         
         notifyBox = gtk.VBox()
         notifyAlign = gtk.Alignment()
         notifyAlign.set(0.5, 0.5, 0.0, 0.0)
         notifyAlign.add(notifyBox)
         self.box.pack_start(notifyAlign)
         
         tipImage = gtk.image_new_from_pixbuf(
             gtk.gdk.pixbuf_new_from_file("../icon/tips/%s/updateTip.png" % (getDefaultLanguage())))
         tipAlign = gtk.Alignment()
         tipAlign.set_padding(0, 0, paddingX, 0)
         tipAlign.add(tipImage)
         notifyBox.pack_start(tipAlign)
         
         penguinImage = gtk.image_new_from_pixbuf(
             gtk.gdk.pixbuf_new_from_file("../icon/tips/penguin.png"))
         penguinAlign = gtk.Alignment()
         penguinAlign.set_padding(0, 0, 0, paddingX)
         penguinAlign.add(penguinImage)
         notifyBox.pack_start(penguinAlign)
         
         self.box.show_all()
     else:
         # Get application list.
         appList = self.getListFunc(
             (self.pageIndex - 1) * self.defaultRows,
             min(self.pageIndex * self.defaultRows, self.appNum)
             )
         
         # Create application view.
         self.box.pack_start(self.createAppList(appList))
         
         # Create index view.
         indexbar = self.createIndexbar()
         if not indexbar == None:
             self.box.pack_start(indexbar)
             
         self.box.show_all()
         
         # Request vote data.
         self.fetchVoteCallback(
             PAGE_UPGRADE, 
             map (lambda appInfo: utils.getPkgName(appInfo.pkg), appList))
         
     # Scroll ScrolledWindow to top after render.
     if scrollToTop:
         utils.scrollToTop(self.scrolledwindow)
    def __init__(self, appInfo, maxWidth, parent, entryDetailCallback):
        '''Init application basic view.'''
        # Init.
        self.align = gtk.Alignment()
        self.align.set(0.0, 0.5, 1.0, 1.0)
        self.commentNum = 0

        appBasicBox = gtk.HBox()
        self.align.add(appBasicBox)
        pkg = appInfo.pkg

        # Add application icon.
        appIcon = createAppIcon(pkg)
        appBasicBox.pack_start(appIcon, False, False)

        # Add application left box.
        appBox = gtk.VBox()
        appAlign = gtk.Alignment()
        appAlign.set(0.0, 0.5, 0.0, 0.0)
        appAlign.add(appBox)
        appBasicBox.pack_start(appAlign)

        # Add application name.
        pkgName = utils.getPkgName(pkg)

        appNameLabel = DynamicLabel(
            parent,
            pkgName,
            appTheme.getDynamicLabelColor("appName"),
            LABEL_FONT_SIZE,
        )
        appName = appNameLabel.getLabel()

        appName.set_single_line_mode(True)
        appName.set_alignment(0.0, 0.0)

        self.appNameBox = gtk.HBox()
        self.appNameBox.pack_start(appName, False, False)

        self.appCommentNumBox = gtk.VBox()
        self.appNameBox.pack_start(self.appCommentNumBox, True, True)

        appNameEventBox = gtk.EventBox()
        appNameEventBox.add(self.appNameBox)
        appNameEventBox.set_visible_window(False)
        appNameEventBox.connect("button-press-event",
                                lambda w, e: entryDetailCallback())
        appBox.pack_start(appNameEventBox, False, False)

        utils.showVersionTooltip(appNameEventBox, pkg)

        setClickableDynamicLabel(
            appNameEventBox,
            appNameLabel,
        )

        # Add application summary.
        summary = utils.getPkgShortDesc(pkg)
        appSummaryBox = gtk.HBox()
        appSummaryLabel = DynamicSimpleLabel(
            parent, summary, appTheme.getDynamicColor("appSummary"),
            LABEL_FONT_SIZE)
        appSummary = appSummaryLabel.getLabel()
        parent.connect(
            "size-allocate", lambda w, e: adjustLabelWidth(
                parent, appSummary, LABEL_FONT_SIZE / 1000, maxWidth))

        appSummary.set_single_line_mode(True)
        appSummary.set_ellipsize(pango.ELLIPSIZE_END)
        appSummary.set_alignment(0.0, 0.5)
        appSummaryBox.pack_start(appSummary, False, False)
        appBox.pack_start(appSummaryBox, False, False)
    def __init__(self, appInfo, entryDetailCallback, sendVoteCallback, index,
                 getSelectIndex, setSelectIndex, selectPkgCallback,
                 unselectPkgCallback, getSelectStatusCallback,
                 removeIgnorePkgCallback):
        '''Init for application item.'''
        self.appInfo = appInfo
        self.entryDetailCallback = entryDetailCallback
        self.sendVoteCallback = sendVoteCallback
        self.selectPkgCallback = selectPkgCallback
        self.unselectPkgCallback = unselectPkgCallback
        self.getSelectStatusCallback = getSelectStatusCallback
        self.removeIgnorePkgCallback = removeIgnorePkgCallback
        self.checkButton = None
        self.index = index
        self.setSelectIndex = setSelectIndex

        # Init.
        self.itemBox = gtk.HBox()
        self.itemEventBox = gtk.EventBox()
        self.itemEventBox.connect("button-press-event", self.clickItem)
        self.itemEventBox.add(self.itemBox)
        drawListItem(self.itemEventBox, index, getSelectIndex)

        self.itemFrame = gtk.Alignment()
        self.itemFrame.set(0.0, 0.5, 1.0, 1.0)
        self.itemFrame.add(self.itemEventBox)

        # Add check box.
        checkPaddingLeft = 20
        checkPaddingRight = 15
        checkPaddingY = 10
        self.checkButton = gtk.CheckButton()
        self.checkButton.set_active(
            self.getSelectStatusCallback(utils.getPkgName(self.appInfo.pkg)))
        self.checkButton.connect("toggled",
                                 lambda w: self.toggleSelectStatus())
        checkButtonSetBackground(
            self.checkButton,
            False,
            False,
            "cell/select.png",
            "cell/selected.png",
        )
        self.checkAlign = gtk.Alignment()
        self.checkAlign.set(0.5, 0.5, 0.0, 0.0)
        self.checkAlign.set_padding(checkPaddingY, checkPaddingY,
                                    checkPaddingLeft, checkPaddingRight)
        self.checkAlign.add(self.checkButton)
        self.itemBox.pack_start(self.checkAlign, False, False)

        self.appBasicView = AppBasicView(self.appInfo,
                                         300 + APP_BASIC_WIDTH_ADJUST,
                                         self.itemBox, self.entryDetailView)
        self.itemBox.pack_start(self.appBasicView.align, True, True)

        self.appAdditionBox = gtk.HBox()
        self.appAdditionAlign = gtk.Alignment()
        self.appAdditionAlign.set(1.0, 0.5, 0.0, 0.0)
        self.appAdditionAlign.add(self.appAdditionBox)
        self.itemBox.pack_start(self.appAdditionAlign, False, False)

        self.initAdditionStatus()

        self.itemFrame.show_all()
    def show(self, scrollToTop=True):
        '''Show application view.'''
        # Remove child widgets first.
        utils.containerRemoveAll(self.box)
        self.itemDict.clear()

        # If i don't re-connect self.eventbox and self.box,
        # update view will show nothing.
        # I still can't understand why?
        # Maybe this is bug of GtkEventBox?
        utils.containerRemoveAll(self.eventbox)
        self.eventbox.add(self.box)

        if self.appNum == 0:
            if (getDefaultLanguage() == "default"):
                paddingX = 10
            else:
                paddingX = 0

            notifyBox = gtk.VBox()
            notifyAlign = gtk.Alignment()
            notifyAlign.set(0.5, 0.5, 0.0, 0.0)
            notifyAlign.add(notifyBox)
            self.box.pack_start(notifyAlign)

            tipImage = gtk.image_new_from_pixbuf(
                gtk.gdk.pixbuf_new_from_file("../icon/tips/%s/updateTip.png" %
                                             (getDefaultLanguage())))
            tipAlign = gtk.Alignment()
            tipAlign.set_padding(0, 0, paddingX, 0)
            tipAlign.add(tipImage)
            notifyBox.pack_start(tipAlign)

            penguinImage = gtk.image_new_from_pixbuf(
                gtk.gdk.pixbuf_new_from_file("../icon/tips/penguin.png"))
            penguinAlign = gtk.Alignment()
            penguinAlign.set_padding(0, 0, 0, paddingX)
            penguinAlign.add(penguinImage)
            notifyBox.pack_start(penguinAlign)

            self.box.show_all()
        else:
            # Get application list.
            appList = self.getListFunc((self.pageIndex - 1) * self.defaultRows,
                                       min(self.pageIndex * self.defaultRows,
                                           self.appNum))

            # Create application view.
            self.box.pack_start(self.createAppList(appList))

            # Create index view.
            indexbar = self.createIndexbar()
            if not indexbar == None:
                self.box.pack_start(indexbar)

            self.box.show_all()

            # Request vote data.
            self.fetchVoteCallback(
                PAGE_UPGRADE,
                map(lambda appInfo: utils.getPkgName(appInfo.pkg), appList))

        # Scroll ScrolledWindow to top after render.
        if scrollToTop:
            utils.scrollToTop(self.scrolledwindow)
 def switchToDownloadPause(self):
     '''Switch to pause.'''
     pkgName = utils.getPkgName(self.appInfo.pkg)
     self.downloadQueue.stopDownload(pkgName)
     self.switchStatus(pkgName, APP_STATE_DOWNLOAD_PAUSE)