def __init__(self, repoCache, 
              selectAllPkgCallback, unselectAllPkgCallback, 
              getSelectListCallback, upgradeSelectedPkgsCallback,
              showIgnorePageCallback):
     '''Init for top bar.'''
     # Init.
     self.repoCache = repoCache
     self.paddingX = 5
     self.selectAllPkgCallback = selectAllPkgCallback
     self.unselectAllPkgCallback = unselectAllPkgCallback
     self.showIgnorePageCallback = showIgnorePageCallback
     
     self.box = gtk.HBox()
     self.boxAlign = gtk.Alignment()
     self.boxAlign.set(0.0, 0.5, 1.0, 1.0)
     self.boxAlign.set_padding(0, 0, TOPBAR_PADDING_LEFT, TOPBAR_PADDING_UPDATE_RIGHT)
     self.boxAlign.add(self.box)
     self.eventbox = gtk.EventBox()
     drawTopbar(self.eventbox)
     
     upgradeBox = gtk.HBox()
     upgradeAlign = gtk.Alignment()
     upgradeAlign.set(1.0, 0.0, 0.0, 1.0)
     upgradeAlign.add(upgradeBox)
     
     self.numLabel = gtk.Label()
     
     self.ignoreNumBox = gtk.HBox()
     self.ignoreNumAlign = gtk.Alignment()
     self.ignoreNumAlign.set(0.0, 0.5, 0.0, 0.0)
     self.ignoreNumAlign.add(self.ignoreNumBox)
     
     self.selectAllId = "selectAll"
     self.unselectAllId = "unselectAll"
     self.labelId = self.selectAllId
     
     (self.selectAllBox, self.selectAllEventBox) = setDefaultRadioButton(
         __("Select All"), self.selectAllId, self.setLabelId, self.getLabelId, self.selectAllPkgStatus
         )
     upgradeBox.pack_start(self.selectAllBox, False, False, self.paddingX)
     
     (self.unselectAllBox, self.unselectAllEventBox) = setDefaultRadioButton(
         __("Unselect All"), self.unselectAllId, self.setLabelId, self.getLabelId, self.unselectAllPkgStatus
         )
     upgradeBox.pack_start(self.unselectAllBox, False, False, self.paddingX)
     
     (self.upgradeButton, upgradeButtonAlign) = newActionButton(
          "search", 0.0, 0.5, "cell", False, __("Action Update"), BUTTON_FONT_SIZE_MEDIUM, "bigButtonFont")
     upgradeBox.pack_start(upgradeButtonAlign, False, False, 26)
     self.upgradeButton.connect("button-press-event", lambda w, e: upgradeSelectedPkgsCallback(getSelectListCallback()))
     
     # Connect.
     self.updateNum(self.repoCache.getUpgradableNum())
     self.numLabel.set_alignment(0.0, 0.5)
     self.box.pack_start(self.numLabel, False, False, self.paddingX)
     self.box.pack_start(self.ignoreNumAlign, True, True, self.paddingX)
     self.box.pack_start(upgradeAlign, True, True, self.paddingX)
     self.eventbox.add(self.boxAlign)
     
     self.updateIgnoreNum(self.repoCache.getIgnoreNum())
Exemple #2
0
    def __init__(self):
        '''Init for navigate bar.'''
        # Init.
        self.getUpgradableNumCallback = None
        self.selectPageCallback = None
        self.getRunningNumCallback = None
        self.iconPadding = 8
        self.animationFrames = 8
        self.updateAnimationCount = 0
        self.downloadAnimationCount = 0

        self.pageId = PAGE_RECOMMEND

        self.box = gtk.HBox()

        self.logoIcon = self.createLogoIcon()
        self.logoAlign = gtk.Alignment()
        self.logoAlign.set_padding(10, 0, 40, 0)
        self.logoAlign.add(self.logoIcon)
        self.box.pack_start(self.logoAlign, False, False)

        self.navBox = gtk.HBox()
        self.navAlign = gtk.Alignment()
        self.navAlign.set(0.3, 0.5, 0.0, 0.0)
        self.navAlign.set_padding(0, 0, 0, 120)
        self.navAlign.add(self.navBox)
        self.box.pack_start(self.navAlign, True, True)

        self.recommendIcon = self.createNavIcon(__("Nav Recommend"),
                                                "navigate/nav_recommend.png",
                                                PAGE_RECOMMEND)
        self.navBox.pack_start(self.recommendIcon, False, False,
                               self.iconPadding)

        self.repositoryIcon = self.createNavIcon(__("Nav Repository"),
                                                 "navigate/nav_repo.png",
                                                 PAGE_REPO)
        self.navBox.pack_start(self.repositoryIcon, False, False,
                               self.iconPadding)

        self.updateIcon = self.createUpdateIcon(__("Nav Update"),
                                                "navigate/nav_update.png",
                                                PAGE_UPGRADE,
                                                self.getUpgradableNum)
        self.navBox.pack_start(self.updateIcon, False, False, self.iconPadding)

        self.uninstallIcon = self.createNavIcon(__("Nav Uninstall"),
                                                "navigate/nav_uninstall.png",
                                                PAGE_UNINSTALL)
        self.navBox.pack_start(self.uninstallIcon, False, False,
                               self.iconPadding)

        self.downloadIcon = self.createUpdateIcon(__("Nav Download Manage"),
                                                  "navigate/nav_download.png",
                                                  PAGE_DOWNLOAD_MANAGE,
                                                  self.getRunningNum)
        self.navBox.pack_start(self.downloadIcon, False, False,
                               self.iconPadding)

        self.box.show_all()
 def start_update(self):
     '''Start update.'''
     if self.actionType == ACTION_INSTALL:
         self.updateCallback(self.actionType, self.pkgName, 0, __("Action Install Start"))
     elif self.actionType == ACTION_UPGRADE:
         self.updateCallback(self.actionType, self.pkgName, 0, __("Action Update Start"))
     elif self.actionType == ACTION_UNINSTALL:
         self.updateCallback(self.actionType, self.pkgName, 0, __("Action Uninstall Start"))
    def __init__(self, repoCache, 
                 selectAllPkgCallback, unselectAllPkgCallback, 
                 getSelectListCallback,
                 removeIgnorePkgsCallback,
                 exitIgnorePageCallback):
        '''Init for top bar.'''
        # Init.
        self.repoCache = repoCache
        self.paddingX = 5
        self.box = gtk.HBox()
        self.boxAlign = gtk.Alignment()
        self.boxAlign.set(0.0, 0.5, 1.0, 1.0)
        self.boxAlign.set_padding(0, 0, TOPBAR_PADDING_LEFT, TOPBAR_PADDING_UPDATE_RIGHT)
        self.boxAlign.add(self.box)
        self.eventbox = gtk.EventBox()
        self.selectAllPkgCallback = selectAllPkgCallback
        self.unselectAllPkgCallback = unselectAllPkgCallback
        drawTopbar(self.eventbox)
        
        upgradeBox = gtk.HBox()
        upgradeAlign = gtk.Alignment()
        upgradeAlign.set(1.0, 0.0, 0.0, 1.0)
        upgradeAlign.add(upgradeBox)
        
        self.numLabel = gtk.Label()
        
        self.selectAllId = "selectAll"
        self.unselectAllId = "unselectAll"
        self.labelId = self.selectAllId
        
        (self.selectAllBox, self.selectAllEventBox) = setDefaultRadioButton(
            __("Select All"), self.selectAllId, self.setLabelId, self.getLabelId, self.selectAllPkgStatus
            )
        upgradeBox.pack_start(self.selectAllBox, False, False, self.paddingX)
        
        (self.unselectAllBox, self.unselectAllEventBox) = setDefaultRadioButton(
            __("Unselect All"), self.unselectAllId, self.setLabelId, self.getLabelId, self.unselectAllPkgStatus
            )
        upgradeBox.pack_start(self.unselectAllBox, False, False, self.paddingX)

        (self.upgradeButton, upgradeButtonAlign) = newActionButton(
             "update_selected", 0.0, 0.5, "cell", True, __("Notify again"), BUTTON_FONT_SIZE_MEDIUM, "bigButtonFont")
        upgradeBox.pack_start(upgradeButtonAlign, False, False, self.paddingX)
        self.upgradeButton.connect("button-press-event", lambda w, e: removeIgnorePkgsCallback(getSelectListCallback()))
        
        # Add return button.
        (returnButton, returnButtonAlign) = newActionButton(
            "search", 1.0, 0.5, "cell", False, __("Return"), BUTTON_FONT_SIZE_MEDIUM, "bigButtonFont",
            0, 10)
        returnButton.connect("button-release-event", lambda w, e: exitIgnorePageCallback())
        
        self.updateNum(self.repoCache.getIgnoreNum())
        self.numLabel.set_alignment(0.0, 0.5)
        self.box.pack_start(self.numLabel, False, False)
        self.box.pack_start(upgradeAlign, True, True)
        self.box.pack_start(returnButtonAlign, False, False)
        self.eventbox.add(self.boxAlign)
    def run(self):
        '''Run'''
        # Build command line.
        cmdline = ['aria2c',
                   '--dir=%s' % (self.partialDir),
                   '--file-allocation=none',
                   '--auto-file-renaming=false',
                   '--summary-interval=0',
                   '--remote-time=true',
                   '--auto-save-interval=%s' % (self.autoSaveInterval),
                   '--max-concurrent-downloads=%s' % (self.maxConcurrentDownloads),
                   '--metalink-servers=%s' % (self.metalinkServers),
                   '--check-integrity=true',
                   '--disable-ipv6=true',
                   # '--max-overall-download-limit=%s' % (self.maxOverallDownloadLimit),
                   ]
        
        # Compatible with aria2c 1.12.x, damn Japanese, why change options every version? Damn you!
        if ARIA2_MAJOR_VERSION >= 1 and ARIA2_MINOR_VERSION >= 12:
            cmdline.append('--enable-rpc=true')
            cmdline.append('--rpc-listen-port=%s' % (self.rpcListenPort))
        else:
            cmdline.append('--enable-xml-rpc=true')
            cmdline.append('--xml-rpc-listen-port=%s' % (self.rpcListenPort))
            
        # Add `max-connection-per-server` and `min-split-size` options if aria2c >= 1.10.x.
        if ARIA2_MAJOR_VERSION >= 1 and ARIA2_MINOR_VERSION >= 10:
            cmdline.append('--max-connection-per-server=%s' % (self.maxConnectionPerServer))
            cmdline.append('--min-split-size=%s' % (self.minSplitSize))
            
        # Make software center can work with aria2c 1.9.x.
        if ARIA2_MAJOR_VERSION >= 1 and ARIA2_MINOR_VERSION <= 9:
            cmdline.append("--no-conf")
            cmdline.append("--continue")
        else:
            cmdline.append("--no-conf=true")
            cmdline.append("--continue=true")

        # Append proxy configuration.
        # proxyString = utils.parseProxyString()
        # if proxyString != None:
        #     cmdline.append("=".join(["--all-proxy", proxyString]))

        # Start child process.
        self.proc = subprocess.Popen(cmdline)
        
        # Get process result.
        result = DOWNLOAD_STATUS_FAILED
        try:
            result = self.download([self.pkgName])
            self.server.aria2.shutdown()
        except Exception, e:
            self.messageCallback((__("% s: Download failed, please check your network link.") % self.pkgName))
            self.updateCallback(self.pkgName, self.progress, __("Download failed"))
            result = DOWNLOAD_STATUS_FAILED
            print "Download error: ", e
    def __init__(self, searchQuery, category, itemNum, appInfos, 
                 entrySearchCallback, updateCategoryCallback):
        '''Init for top bar.'''
        self.searchQuery = searchQuery
        self.paddingX = 5
        self.box = gtk.HBox()
        self.boxAlign = gtk.Alignment()
        self.boxAlign.set(0.0, 0.5, 1.0, 1.0)
        self.boxAlign.set_padding(0, 0, TOPBAR_PADDING_LEFT, TOPBAR_PADDING_RIGHT)
        self.boxAlign.add(self.box)
        self.eventbox = gtk.EventBox()
        self.eventbox.add(self.boxAlign)
        drawTopbar(self.eventbox)
        self.numLabel = gtk.Label()
        self.entrySearchCallback = entrySearchCallback
        self.updateCategoryCallback = updateCategoryCallback
        
        # Add classify number.
        self.box.pack_start(self.numLabel)
        
        # Add sort buttons.
        self.sortBox = gtk.HBox()
        self.sortAlign = gtk.Alignment()
        self.sortAlign.set(0.0, 0.5, 1.0, 1.0)
        self.sortAlign.add(self.sortBox)
        
        self.sortRecommendId = "sortRecommend"
        self.sortDownloadId = "sortDownload"
        self.sortVoteId = "sortVote"
        self.sortType = self.sortRecommendId

        (self.sortRecommendBox, self.sortRecommendEventBox) = setDefaultRadioButton(
            __("Sort By Recommend"), self.sortRecommendId, self.setSortType, self.getSortType, self.updateRadioStatus
            )

        (self.sortDownloadBox, self.sortDownloadEventBox) = setDefaultRadioButton(
            __("Sort By Download"), self.sortDownloadId, self.setSortType, self.getSortType, self.updateRadioStatus
            )
        
        (self.sortVoteBox, self.sortVoteEventBox) = setDefaultRadioButton(
            __("Sort By Vote"), self.sortVoteId, self.setSortType, self.getSortType, self.updateRadioStatus
            )
        
        self.sortButtonPaddingX = 10
        self.sortBox.pack_start(self.sortRecommendBox, False, False, self.sortButtonPaddingX)
        self.sortBox.pack_start(self.sortDownloadBox, False, False, self.sortButtonPaddingX)
        self.sortBox.pack_start(self.sortVoteBox, False, False, self.sortButtonPaddingX)
        self.box.pack_start(self.sortAlign)
        
        # Add search entry and label.
        (self.searchEntry, searchAlign, self.searchCompletion) = newSearchUI(
            __("Please enter the name you want to search for software, version or other information"),
            lambda text: getCandidates(map (lambda appInfo: appInfo.pkg.name, appInfos), text),
            self.clickCandidate,
            self.search)
        self.box.pack_start(searchAlign)
 def failed(self):
     '''Action failed.'''
     if self.actionType == ACTION_INSTALL:
         self.updateCallback(self.actionType, self.pkgName, 100, __("Action Install Failed"))
     elif self.actionType == ACTION_UPGRADE:
         self.updateCallback(self.actionType, self.pkgName, 100, __("Action Update Failed"))
     elif self.actionType == ACTION_UNINSTALL:
         self.updateCallback(self.actionType, self.pkgName, 100, __("Action Uninstall Failed"))
     
     self.scanCallback(self.pkgName, self.actionType)
     self.failedCallback(self.actionType, self.pkgName)
 def start_update(self):
     '''Start update.'''
     if self.actionType == ACTION_INSTALL:
         self.updateCallback(self.actionType, self.pkgName, 0,
                             __("Action Install Start"))
     elif self.actionType == ACTION_UPGRADE:
         self.updateCallback(self.actionType, self.pkgName, 0,
                             __("Action Update Start"))
     elif self.actionType == ACTION_UNINSTALL:
         self.updateCallback(self.actionType, self.pkgName, 0,
                             __("Action Uninstall Start"))
 def finish(self):
     '''Progress finish update.'''
     if self.actionType == ACTION_INSTALL:
         self.updateCallback(self.actionType, self.pkgName, 100, __("Action Install Finish"))
     elif self.actionType == ACTION_UPGRADE:
         self.updateCallback(self.actionType, self.pkgName, 100, __("Action Update Finish"))
     elif self.actionType == ACTION_UNINSTALL:
         self.updateCallback(self.actionType, self.pkgName, 100, __("Action Uninstall Finish"))
     
     self.scanCallback(self.pkgName, self.actionType)
     self.finishCallback(self.actionType, self.pkgList)
def showVersionTooltip(widget, pkg):
    '''Show version tooltip.'''
    newestVersion = getPkgNewestVersion(pkg)
    currentVersion = getPkgVersion(pkg)
    if newestVersion == currentVersion:
        setHelpTooltip(
            widget, "%s\n%s: %s" %
            (__("Click Show Detail"), __("Current Version"), currentVersion))
    else:
        setHelpTooltip(
            widget, "%s\n%s: %s\n%s: %s" %
            (__("Click Show Detail"), __("Current Version"), currentVersion,
             __("Upgrade Version"), newestVersion))
    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 finish(self):
        '''Progress finish update.'''
        if self.actionType == ACTION_INSTALL:
            self.updateCallback(self.actionType, self.pkgName, 100,
                                __("Action Install Finish"))
        elif self.actionType == ACTION_UPGRADE:
            self.updateCallback(self.actionType, self.pkgName, 100,
                                __("Action Update Finish"))
        elif self.actionType == ACTION_UNINSTALL:
            self.updateCallback(self.actionType, self.pkgName, 100,
                                __("Action Uninstall Finish"))

        self.scanCallback(self.pkgName, self.actionType)
        self.finishCallback(self.actionType, self.pkgList)
    def failed(self):
        '''Action failed.'''
        if self.actionType == ACTION_INSTALL:
            self.updateCallback(self.actionType, self.pkgName, 100,
                                __("Action Install Failed"))
        elif self.actionType == ACTION_UPGRADE:
            self.updateCallback(self.actionType, self.pkgName, 100,
                                __("Action Update Failed"))
        elif self.actionType == ACTION_UNINSTALL:
            self.updateCallback(self.actionType, self.pkgName, 100,
                                __("Action Uninstall Failed"))

        self.scanCallback(self.pkgName, self.actionType)
        self.failedCallback(self.actionType, self.pkgName)
Exemple #14
0
 def __init__(self, itemNum, cleanDownloadCacheCallback):
     '''Init for top bar.'''
     # Init.
     self.paddingX = 5
     
     self.box = gtk.HBox()
     self.boxAlign = gtk.Alignment()
     self.boxAlign.set(0.0, 0.5, 1.0, 1.0)
     self.boxAlign.set_padding(0, 0, TOPBAR_PADDING_LEFT - 10, TOPBAR_PADDING_UPDATE_RIGHT + 5)
     self.boxAlign.add(self.box)
     self.eventbox = gtk.EventBox()
     drawTopbar(self.eventbox)
     
     self.numLabel = gtk.Label()
     self.numLabelAlign = gtk.Alignment()
     self.numLabelAlign.set(0.0, 0.5, 0.0, 0.0)
     self.numLabelAlign.set_padding(0, 0, self.paddingX, 0)
     self.numLabelAlign.add(self.numLabel)
     self.iconPadding = 5
     
     self.openDirEventBox = setIconLabelButton(
         __("Open download directory"), 
         appTheme.getDynamicPixbuf("topbar/open_normal.png"),
         appTheme.getDynamicPixbuf("topbar/open_hover.png"),
         self.iconPadding)
     
     self.openDirAlign = gtk.Alignment()
     self.openDirAlign.set(0.0, 0.5, 0.0, 0.0)
     self.openDirAlign.add(self.openDirEventBox)
     self.openDirEventBox.connect("button-press-event", lambda w, e: utils.sendCommand("xdg-open /var/cache/apt/archives/"))
     
     self.cleanEventBox = setIconLabelButton(
         __("Clean download cache"), 
         appTheme.getDynamicPixbuf("topbar/clean_normal.png"),
         appTheme.getDynamicPixbuf("topbar/clean_hover.png"),
         self.iconPadding)
     
     self.cleanEventBox.connect("button-press-event", lambda w, e: cleanDownloadCacheCallback())
     self.cleanAlign = gtk.Alignment()
     self.cleanAlign.set(1.0, 0.5, 0.0, 0.0)
     self.cleanAlign.add(self.cleanEventBox)
     utils.setHelpTooltip(self.cleanEventBox, __("Clean download cache, save your disk space!"))
     
     # Connect.
     self.updateNum(itemNum)
     self.box.pack_start(self.numLabelAlign, True, True, self.paddingX)
     self.box.pack_start(self.openDirAlign, False, False, self.paddingX)
     self.box.pack_start(self.cleanAlign, False, False, self.paddingX)
     self.eventbox.add(self.boxAlign)
Exemple #15
0
 def initNormalStatus(self):
     '''Init normal status.'''
     pkg = self.appInfo.pkg
     
     # Clean feedback box.
     utils.containerRemoveAll(self.appFeedbackBox)
     utils.containerRemoveAll(self.appActionBox)
     utils.containerRemoveAll(self.appStatusBox)
     
     # Add summary.
     self.appStatusBox.pack_start(self.appSummaryBox, False, False)
     
     # Add action button.
     appButtonBox = gtk.VBox()
     self.appActionBox.pack_start(appButtonBox, False, False, self.APP_RIGHT_PADDING_X)
     if self.appInfo.status == APP_STATE_NORMAL:
         (appButton, appButtonAlign) = newActionButton(
             "install", 0.5, 0.5, 
             "cell", False, __("Action Install"), BUTTON_FONT_SIZE_SMALL, "buttonFont"
             )
         appButton.connect("button-release-event", lambda widget, event: self.switchToDownloading())
         appButtonBox.pack_start(appButtonAlign)
     elif self.appInfo.status == APP_STATE_UPGRADE:
         (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())
         appButtonBox.pack_start(appButtonAlign)
     else:
         execPath = self.appInfo.execPath
         if execPath:
             (appButton, appButtonAlign) = newActionButton(
                 "update", 0.5, 0.5, 
                 "cell", False, __("Action Startup"), BUTTON_FONT_SIZE_SMALL, "buttonFont"
                 )
             appButton.connect("button-release-event", lambda widget, event: self.launchApplicationCallback(execPath))
             appButtonBox.pack_start(appButtonAlign)
         else:
             appInstalledDynamicLabel = DynamicSimpleLabel(
                 appButtonBox,
                 __("Action Installed"),
                 appTheme.getDynamicColor("installed"),
                 LABEL_FONT_SIZE,
                 )
             appInstalledLabel = appInstalledDynamicLabel.getLabel()
             buttonImage = appTheme.getDynamicPixbuf("cell/update_hover.png").getPixbuf()
             appInstalledLabel.set_size_request(buttonImage.get_width(), buttonImage.get_height())
             appButtonBox.pack_start(appInstalledLabel)
 def initStatus(self):
     '''Init status.'''
     self.downloadingFeedback = __("Action Wait Download")
     self.downloadingProgress = 0
     
     self.downloadPauseFeedback = ''
     
     self.installingFeedback = __("Action Wait Install")
     self.installingProgress = 0
     
     self.upgradingFeedback = __("Action Wait Update")
     self.upgradingProgress = 0
     
     self.uninstallingFeedback = __("Action Wait Uninstall")
     self.uninstallingProgress = 0
 def initStatus(self):
     '''Init status.'''
     self.downloadingFeedback = __("Action Wait Download")
     self.downloadingProgress = 0
     
     self.downloadPauseFeedback = ''
     
     self.installingFeedback = __("Action Wait Install")
     self.installingProgress = 0
     
     self.upgradingFeedback = __("Action Wait Update")
     self.upgradingProgress = 0
     
     self.uninstallingFeedback = __("Action Wait Uninstall")
     self.uninstallingProgress = 0
 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_DOWNLOAD_MANAGE, 
         self.sendVoteCallback)
     self.appAdditionBox.pack_start(self.appVoteView.eventbox, False, False)
     
     # Add application size.
     size = utils.getPkgSize(pkg)
     appSize = gtk.Label()
     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.LIKE_PADDING_X)
     
     # Add action button.
     (actionButtonBox, actionButtonAlign) = createActionButton()
     self.appAdditionBox.pack_start(actionButtonAlign, False, False)
     if self.appInfo.status == APP_STATE_NORMAL:
         (appButton, appButtonAlign) = newActionButton(
             "install", 0.5, 0.5, 
             "cell", False, __("Action Install"), BUTTON_FONT_SIZE_SMALL, "buttonFont"
             )
         appButton.connect("button-release-event", lambda widget, event: self.switchToDownloading())
         actionButtonBox.pack_start(appButtonAlign)
     elif self.appInfo.status == APP_STATE_UPGRADE:
         (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)
     else:
         appInstalledDynamicLabel = DynamicSimpleLabel(
             actionButtonBox,
             __("Action Installed"),
             appTheme.getDynamicColor("installed"),
             LABEL_FONT_SIZE,
             )
         appInstalledLabel = appInstalledDynamicLabel.getLabel()
         buttonImage = appTheme.getDynamicPixbuf("cell/update_hover.png").getPixbuf()
         appInstalledLabel.set_size_request(buttonImage.get_width(), buttonImage.get_height())
         actionButtonBox.pack_start(appInstalledLabel)
 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_DOWNLOAD_MANAGE, 
         self.sendVoteCallback)
     self.appAdditionBox.pack_start(self.appVoteView.eventbox, False, False)
     
     # Add application size.
     size = utils.getPkgSize(pkg)
     appSize = gtk.Label()
     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.LIKE_PADDING_X)
     
     # Add action button.
     (actionButtonBox, actionButtonAlign) = createActionButton()
     self.appAdditionBox.pack_start(actionButtonAlign, False, False)
     if self.appInfo.status == APP_STATE_NORMAL:
         (appButton, appButtonAlign) = newActionButton(
             "install", 0.5, 0.5, 
             "cell", False, __("Action Install"), BUTTON_FONT_SIZE_SMALL, "buttonFont"
             )
         appButton.connect("button-release-event", lambda widget, event: self.switchToDownloading())
         actionButtonBox.pack_start(appButtonAlign)
     elif self.appInfo.status == APP_STATE_UPGRADE:
         (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)
     else:
         appInstalledDynamicLabel = DynamicSimpleLabel(
             actionButtonBox,
             __("Action Installed"),
             appTheme.getDynamicColor("installed"),
             LABEL_FONT_SIZE,
             )
         appInstalledLabel = appInstalledDynamicLabel.getLabel()
         buttonImage = appTheme.getDynamicPixbuf("cell/update_hover.png").getPixbuf()
         appInstalledLabel.set_size_request(buttonImage.get_width(), buttonImage.get_height())
         actionButtonBox.pack_start(appInstalledLabel)
 def __init__(self, upgradeNum, repoCache, entrySearchCallback, messageCallback, searchQuery):
     '''Init for top bar.'''
     # Init.
     self.searchQuery = searchQuery
     self.paddingX = 5
     self.repoCache = repoCache
     self.messageCallback = messageCallback
     self.entrySearchCallback = entrySearchCallback
     
     self.box = gtk.HBox()
     self.boxAlign = gtk.Alignment()
     self.boxAlign.set(0.0, 0.5, 1.0, 1.0)
     self.boxAlign.set_padding(0, 0, TOPBAR_PADDING_LEFT, TOPBAR_PADDING_RIGHT)
     self.boxAlign.add(self.box)
     self.eventbox = gtk.EventBox()
     drawTopbar(self.eventbox)
     self.numLabel = gtk.Label()
     
     # Add search entry and label.
     (self.searchEntry, searchAlign, self.searchCompletion) = newSearchUI(
         __("Please enter the name you want to uninstall the software, version or other information"),
         lambda text: getCandidates(self.repoCache.uninstallablePkgs, text),
         self.clickCandidate,
         self.search)
     
     # Connect.
     self.updateNum(upgradeNum)
     self.numLabel.set_alignment(0.0, 0.5)
     self.box.pack_start(self.numLabel, True, True, self.paddingX)
     self.box.pack_start(searchAlign)
     self.eventbox.add(self.boxAlign)
    def finishCallback(self):
        '''Finish callback for progress.'''
        # Update status.
        self.statusbar.setStatus(__("Update sources list completed."))

        # Reset statusbar after 2 seconds.
        glib.timeout_add_seconds(5, self.resetStatus)
Exemple #22
0
 def initStatus(self):
     '''Init status.'''
     self.name.set_markup("<span foreground='%s' size='%s'>%s %s</span>" % (
             appTheme.getDynamicColor("statusText").getColor(),
             LABEL_FONT_SIZE,
             __("TeaLinuxOS Software Center"), 
             VERSION))
 def query(self, args):
     '''Query.'''
     if self.database == None:
         self.messageCallback((__("Indexing, search capabilities please try again later.")))
         return []
     else:
         self.database.set_query_args(args)
         self.database.build_query()
         
         matches = self.database.enquire.get_mset(0, self.database.db.get_doccount())
         results = map(lambda m: m.document.get_data(), matches)
         
         if results == []:
             self.messageCallback((__("No search packages related %s") % (" ".join(args))))
         
         return self.repoCache.sortPackages(results, " ".join(args))
 def finishCallback(self):
     '''Finish callback for progress.'''
     # Update status.
     self.statusbar.setStatus(__("Update sources list completed."))
     
     # Reset statusbar after 2 seconds.
     glib.timeout_add_seconds(5, self.resetStatus)
def showVersionTooltip(widget, pkg):
    '''Show version tooltip.'''
    newestVersion = getPkgNewestVersion(pkg)
    currentVersion = getPkgVersion(pkg)
    if newestVersion == currentVersion:
        setHelpTooltip(
            widget,
            "%s\n%s: %s" % (__("Click Show Detail"), __("Current Version"), currentVersion))
    else:    
        setHelpTooltip(
            widget,
            "%s\n%s: %s\n%s: %s" % (__("Click Show Detail"), 
                                    __("Current Version"), 
                                    currentVersion, 
                                    __("Upgrade Version"),
                                    newestVersion))
 def initStatus(self):
     '''Init status.'''
     self.name.set_markup("<span foreground='%s' size='%s'>%s %s</span>" % (
             appTheme.getDynamicColor("statusText").getColor(),
             LABEL_FONT_SIZE,
             __("Deepin Software Center"), 
             VERSION))
 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, upgradeNum, repoCache, entrySearchCallback,
                 messageCallback, searchQuery):
        '''Init for top bar.'''
        # Init.
        self.searchQuery = searchQuery
        self.paddingX = 5
        self.repoCache = repoCache
        self.messageCallback = messageCallback
        self.entrySearchCallback = entrySearchCallback

        self.box = gtk.HBox()
        self.boxAlign = gtk.Alignment()
        self.boxAlign.set(0.0, 0.5, 1.0, 1.0)
        self.boxAlign.set_padding(0, 0, TOPBAR_PADDING_LEFT,
                                  TOPBAR_PADDING_RIGHT)
        self.boxAlign.add(self.box)
        self.eventbox = gtk.EventBox()
        drawTopbar(self.eventbox)
        self.numLabel = gtk.Label()

        # Add search entry and label.
        (self.searchEntry, searchAlign, self.searchCompletion) = newSearchUI(
            __("Please enter the name you want to uninstall the software, version or other information"
               ),
            lambda text: getCandidates(self.repoCache.uninstallablePkgs, text),
            self.clickCandidate, self.search)

        # Connect.
        self.updateNum(upgradeNum)
        self.numLabel.set_alignment(0.0, 0.5)
        self.box.pack_start(self.numLabel, True, True, self.paddingX)
        self.box.pack_start(searchAlign)
        self.eventbox.add(self.boxAlign)
 def updateNum(self, upgradeNum):
     '''Update number.'''
     self.numLabel.set_markup(
         __("Topbar UninstallPage") % (LABEL_FONT_SIZE, 
                                       appTheme.getDynamicColor("topbarNum").getColor(),
                                       LABEL_FONT_SIZE, 
                                       str(upgradeNum), 
                                       LABEL_FONT_SIZE))
    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 #31
0
    def initNormalStatus(self):
        '''Init normal status.'''
        # Clean right box first.
        utils.containerRemoveAll(self.appAdditionBox)

        # Add action button.
        (actionButtonBox, actionButtonAlign) = createActionButton()
        self.appAdditionBox.pack_start(actionButtonAlign, False, False)
        if self.appInfo.status == APP_STATE_NORMAL:
            (appButton, appButtonAlign) = newActionButton(
                "search", 0.5, 0.5, "cell", False, __("Action Install"),
                BUTTON_FONT_SIZE_LARGE, "bigButtonFont")
            appButton.connect("button-release-event",
                              lambda widget, event: self.switchToDownloading())
            actionButtonBox.pack_start(appButtonAlign)
        elif self.appInfo.status == APP_STATE_UPGRADE:
            (appButton, appButtonAlign) = newActionButton(
                "search", 0.5, 0.5, "cell", False, __("Action Update"),
                BUTTON_FONT_SIZE_LARGE, "bigButtonFont")
            appButton.connect("button-release-event",
                              lambda widget, event: self.switchToDownloading())
            actionButtonBox.pack_start(appButtonAlign)
        else:
            execPath = self.appInfo.execPath
            if execPath:
                (appButton, appButtonAlign) = newActionButton(
                    "search", 0.5, 0.5, "cell", False, __("Action Startup"),
                    BUTTON_FONT_SIZE_LARGE, "bigButtonFont")
                appButton.connect(
                    "button-release-event", lambda widget, event: self.
                    launchApplicationCallback(execPath))
                actionButtonBox.pack_start(appButtonAlign)
            else:
                appInstalledDynamicLabel = DynamicSimpleLabel(
                    actionButtonBox,
                    __("Action Installed"),
                    appTheme.getDynamicColor("slideText"),
                    LABEL_FONT_LARGE_SIZE,
                )
                appInstalledLabel = appInstalledDynamicLabel.getLabel()
                buttonImage = appTheme.getDynamicPixbuf(
                    "cell/update_hover.png").getPixbuf()
                appInstalledLabel.set_size_request(buttonImage.get_width(),
                                                   buttonImage.get_height())
                actionButtonBox.pack_start(appInstalledLabel)
    def updateUninstallingStatus(self, progress, feedback):
        """Update un installing status."""
        if self.appInfo.status == APP_STATE_UNINSTALLING:
            if self.uninstallingProgressbar != None and self.uninstallingFeedbackLabel != None:
                self.uninstallingProgressbar.setProgress(progress)
                self.uninstallingFeedbackLabel.set_markup(
                    "<span size='%s'>%s</span>" % (LABEL_FONT_SIZE, __("Action Uninstalling"))
                )

                self.itemFrame.show_all()
 def updateNum(self, upgradeNum):
     '''Update number.'''
     if upgradeNum == 0:
         markup = ""
     else:
         markup = (__("Topbar UpdatePage") %
                   (LABEL_FONT_SIZE,
                    appTheme.getDynamicColor("topbarNum").getColor(),
                    LABEL_FONT_SIZE, str(upgradeNum), LABEL_FONT_SIZE))
     self.numLabel.set_markup(markup)
 def initDB(self):
     '''Init DB.'''
     self.database = DB()
     self.statusbar.setStatus((__("Build the search index file is completed.")))
     
     # Touch lock file.
     if not os.path.exists(self.lockFile):
         touchFile(self.lockFile)
     
     glib.timeout_add_seconds(2, self.resetStatus)
Exemple #35
0
    def query(self, args):
        '''Query.'''
        if self.database == None:
            self.messageCallback(
                (__("Indexing, search capabilities please try again later.")))
            return []
        else:
            self.database.set_query_args(args)
            self.database.build_query()

            matches = self.database.enquire.get_mset(
                0, self.database.db.get_doccount())
            results = map(lambda m: m.document.get_data(), matches)

            if results == []:
                self.messageCallback(
                    (__("No search packages related %s") % (" ".join(args))))

            return self.repoCache.sortPackages(results, " ".join(args))
    def cancelProxy(self):
        '''Cancel proxy.'''
        # Save proxy setup.
        writeFile("./proxy", "{}")

        # Hide window.
        self.hide()

        # Display message.
        self.messageCallback(__("Cancel proxy!"))
 def cancelProxy(self):
     '''Cancel proxy.'''
     # Save proxy setup.
     writeFile("./proxy", "{}")
     
     # Hide window.
     self.hide()
     
     # Display message.
     self.messageCallback(__("Cancel proxy!"))
Exemple #38
0
    def updateTopbar(self, keyword, itemNum):
        '''Set number label.'''

        self.keywordLabel.set_markup(
            __("Topbar SearchPage") %
            (LABEL_FONT_SIZE,
             appTheme.getDynamicColor("topbarKeyword").getColor(),
             LABEL_FONT_SIZE, keyword.strip(), LABEL_FONT_SIZE,
             appTheme.getDynamicColor("topbarNum").getColor(), LABEL_FONT_SIZE,
             str(itemNum), LABEL_FONT_SIZE))
 def finishCallback(self):
     '''Finish callback for progress.'''
     # Update status.
     self.statusbar.setStatus(__("Update sources list completed."))
     
     # Reset statusbar after 2 seconds.
     glib.timeout_add_seconds(2, self.resetStatus)
     
     # Download update data from server, this must execute after list update complete.
     downloadUpdateData.DownloadUpdateData().start()
    def updateUninstallingStatus(self, progress, feedback):
        '''Update un installing status.'''
        if self.appInfo.status == APP_STATE_UNINSTALLING:
            if self.uninstallingProgressbar != None and self.uninstallingFeedbackLabel != None:
                self.uninstallingProgressbar.setProgress(progress)
                self.uninstallingFeedbackLabel.set_markup(
                    "<span size='%s'>%s</span>" %
                    (LABEL_FONT_SIZE, __("Action Uninstalling")))

                self.itemFrame.show_all()
    def __init__(self):
        '''Init for status bar.'''
        # Init.
        self.paddingX = 10
        self.paddingY = 5

        self.eventbox = gtk.EventBox()
        drawStatusbarBackground(
            self.eventbox,
            appTheme.getDynamicPixbuf("statusbar/background.png"),
            appTheme.getDynamicDrawType("statusbar"),
            appTheme.getDynamicAlphaColor("frameLigtht"),
            appTheme.getDynamicAlphaColor("statusbarTop"),
        )

        self.box = gtk.HBox()

        self.name = gtk.Label()
        self.initStatus()
        self.nameEventBox = gtk.EventBox()
        self.nameEventBox.set_visible_window(False)
        self.nameEventBox.add(self.name)
        self.nameEventBox.connect(
            "button-press-event", lambda w, e: sendCommand(
                "xdg-open http://www.linuxdeepin.com/feature#software"))
        self.nameAlignment = gtk.Alignment()
        self.nameAlignment.set_padding(self.paddingY, self.paddingY,
                                       self.paddingX, self.paddingX)
        self.nameAlignment.set(0.0, 0.0, 0.0, 1.0)
        self.nameAlignment.add(self.nameEventBox)
        self.box.pack_start(self.nameAlignment)

        self.joinUs = gtk.Label()
        self.joinUs.set_markup(
            "<span foreground='%s' size='%s'>%s</span>" %
            (appTheme.getDynamicColor("statusText").getColor(),
             LABEL_FONT_SIZE, __("Join Us")))
        self.joinUsEventBox = gtk.EventBox()
        self.joinUsEventBox.set_visible_window(False)
        self.joinUsEventBox.add(self.joinUs)
        self.joinUsEventBox.connect(
            "button-press-event", lambda w, e: sendCommand(
                "xdg-open http://www.linuxdeepin.com/joinus/job"))
        setClickableCursor(self.nameEventBox)
        setClickableCursor(self.joinUsEventBox)
        self.joinUsAlign = gtk.Alignment()
        self.joinUsAlign.set_padding(0, 0, 0, self.paddingX)
        self.joinUsAlign.set(1.0, 0.5, 0.0, 0.0)
        self.joinUsAlign.add(self.joinUsEventBox)
        self.box.pack_start(self.joinUsAlign)

        # Connect components.
        self.eventbox.add(self.box)
        self.eventbox.show_all()
Exemple #42
0
    def initDB(self):
        '''Init DB.'''
        self.database = DB()
        self.statusbar.setStatus(
            (__("Build the search index file is completed.")))

        # Touch lock file.
        if not os.path.exists(self.lockFile):
            touchFile(self.lockFile)

        glib.timeout_add_seconds(2, self.resetStatus)
 def switchStatus(self, appStatus):
     '''Switch status.'''
     self.status = appStatus
     
     if appStatus in [APP_STATE_NORMAL, APP_STATE_INSTALLED]:
         self.initStatus()
     elif appStatus == APP_STATE_DOWNLOADING:
         self.downloadingProgress = 0
         self.downloadingFeedback = __("Action Wait Download")
     elif appStatus == APP_STATE_DOWNLOAD_PAUSE:
         self.downloadPauseFeedback = __("Pause")
     elif appStatus == APP_STATE_INSTALLING:
         self.installingProgress = 0
         self.installingFeedback = __("Action Wait Install")
     elif appStatus == APP_STATE_UPGRADING:
         self.upgradingProgress = 0
         self.upgradingFeedback = __("Action Wait Update")
     elif appStatus == APP_STATE_UNINSTALLING:
         self.uninstallingProgress = 0
         self.uninstallingFeedback = __("Action Wait Uninstall")
 def handleRightClick(self, icon, button, time):
     menu = gtk.Menu()
     
     quitItem = gtk.ImageMenuItem()
     quitItem.set_label(__("Exit"))
     quitItem.connect("activate", lambda w: self.exit())
     menu.append(quitItem)
     
     menu.show_all()
     
     menu.popup(None, None, gtk.status_icon_position_menu, button, time, self.trayIcon)
 def switchStatus(self, appStatus):
     '''Switch status.'''
     self.status = appStatus
     
     if appStatus in [APP_STATE_NORMAL, APP_STATE_INSTALLED]:
         self.initStatus()
     elif appStatus == APP_STATE_DOWNLOADING:
         self.downloadingProgress = 0
         self.downloadingFeedback = __("Action Wait Download")
     elif appStatus == APP_STATE_DOWNLOAD_PAUSE:
         self.downloadPauseFeedback = __("Pause")
     elif appStatus == APP_STATE_INSTALLING:
         self.installingProgress = 0
         self.installingFeedback = __("Action Wait Install")
     elif appStatus == APP_STATE_UPGRADING:
         self.upgradingProgress = 0
         self.upgradingFeedback = __("Action Wait Update")
     elif appStatus == APP_STATE_UNINSTALLING:
         self.uninstallingProgress = 0
         self.uninstallingFeedback = __("Action Wait Uninstall")
 def handleRightClick(self, icon, button, time):
     menu = gtk.Menu()
     
     quitItem = gtk.ImageMenuItem()
     quitItem.set_label(__("Exit"))
     quitItem.connect("activate", lambda w: self.exit())
     menu.append(quitItem)
     
     menu.show_all()
     
     menu.popup(None, None, gtk.status_icon_position_menu, button, time, self.trayIcon)
 def initStatus(self):
     """Init status."""
     self.name.set_markup(
         "<span foreground='%s' size='%s'>%s %s</span>"
         % (
             appTheme.getDynamicColor("statusText").getColor(),
             LABEL_FONT_SIZE,
             __("TeaLinuxOS Software Center"),
             VERSION,
         )
     )
 def updateNum(self, upgradeNum):
     '''Update number.'''
     if upgradeNum == 0:
         markup = ""
     else:
         markup = (__("Topbar UpdatePage") % (LABEL_FONT_SIZE, 
                                              appTheme.getDynamicColor("topbarNum").getColor(),
                                              LABEL_FONT_SIZE, 
                                              str(upgradeNum), 
                                              LABEL_FONT_SIZE))
     self.numLabel.set_markup(markup)
 def initNormalStatus(self):
     '''Init normal status.'''
     # Clean right box first.
     utils.containerRemoveAll(self.appAdditionBox)
     
     # Add action button.
     (actionButtonBox, actionButtonAlign) = createActionButton()
     self.appAdditionBox.pack_start(actionButtonAlign, False, False)
     if self.appInfo.status == APP_STATE_NORMAL:
         (appButton, appButtonAlign) = newActionButton(
             "search", 0.5, 0.5,  "cell", False, __("Action Install"), BUTTON_FONT_SIZE_LARGE, "bigButtonFont"
             )
         appButton.connect("button-release-event", lambda widget, event: self.switchToDownloading())
         actionButtonBox.pack_start(appButtonAlign)
     elif self.appInfo.status == APP_STATE_UPGRADE:
         (appButton, appButtonAlign) = newActionButton(
             "search", 0.5, 0.5, 
             "cell", False, __("Action Update"), BUTTON_FONT_SIZE_LARGE, "bigButtonFont"
             )
         appButton.connect("button-release-event", lambda widget, event: self.switchToDownloading())
         actionButtonBox.pack_start(appButtonAlign)
     else:
         execPath = self.appInfo.execPath
         if execPath:
             (appButton, appButtonAlign) = newActionButton(
                 "search", 0.5, 0.5, 
                 "cell", False, __("Action Startup"), BUTTON_FONT_SIZE_LARGE, "bigButtonFont"
                 )
             appButton.connect("button-release-event", lambda widget, event: self.launchApplicationCallback(execPath))
             actionButtonBox.pack_start(appButtonAlign)
         else:
             appInstalledDynamicLabel = DynamicSimpleLabel(
                 actionButtonBox,
                 __("Action Installed"),
                 appTheme.getDynamicColor("slideText"),
                 LABEL_FONT_LARGE_SIZE,
                 )
             appInstalledLabel = appInstalledDynamicLabel.getLabel()
             buttonImage = appTheme.getDynamicPixbuf("cell/update_hover.png").getPixbuf()
             appInstalledLabel.set_size_request(buttonImage.get_width(), buttonImage.get_height())
             actionButtonBox.pack_start(appInstalledLabel)
Exemple #50
0
    def updateNum(self, upgradeNum):
        '''Update number.'''
        # Don't show label if nothing to ignore.
        if upgradeNum == 0:
            markup = ""
        else:
            markup = (__("Topbar IgnorePage") %
                      (LABEL_FONT_SIZE,
                       appTheme.getDynamicColor("topbarNum").getColor(),
                       LABEL_FONT_SIZE, str(upgradeNum), LABEL_FONT_SIZE))

        self.numLabel.set_markup(markup)
    def initDownloadPauseStatus(self,
                                appAdditionBox,
                                withoutBorder=False,
                                color=None):
        if (color == None):
            color = appTheme.getDynamicColor("statusUpdate").getColor()
        '''Init download pause status.'''
        # Clean right box first.
        utils.containerRemoveAll(appAdditionBox)

        # Add progress.
        progress = self.appInfo.downloadingProgress
        if withoutBorder:
            progressbar = drawProgressbarWithoutBorder(self.PROGRESS_WIDTH)
        else:
            progressbar = drawProgressbar(self.PROGRESS_WIDTH)
        progressbar.setProgress(progress)
        appAdditionBox.pack_start(progressbar.box)

        # Alignment box.
        (actionBox, actionAlign) = createActionButton()
        appAdditionBox.pack_start(actionAlign)

        # Add play icon.
        buttonBox = gtk.HBox()
        buttonAlign = gtk.Alignment()
        buttonAlign.set(0.5, 0.5, 0.0, 0.0)
        buttonAlign.set_padding(ACTION_BUTTON_PADDING_Y,
                                ACTION_BUTTON_PADDING_Y, 0, 0)
        buttonAlign.add(buttonBox)
        actionBox.pack_start(buttonAlign)

        continueIcon = gtk.Button()
        drawSimpleButton(continueIcon, "continue")
        continueIcon.connect("button-release-event",
                             lambda widget, event: self.switchToDownloading())
        buttonBox.pack_start(continueIcon, False, False, self.BUTTON_PADDING_X)

        # Add stop icon.
        stopIcon = gtk.Button()
        drawSimpleButton(stopIcon, "stop")
        stopIcon.connect("button-release-event",
                         lambda widget, event: self.switchToNormal())
        buttonBox.pack_start(stopIcon, False, False, self.BUTTON_PADDING_X)

        # Add pause label.
        pauseLabel = gtk.Label()
        pauseLabel.set_markup("<span foreground='%s' size='%s'>%s</span>" %
                              (color, LABEL_FONT_SIZE, __("Action Pause")))
        pauseLabel.set_width_chars(self.PROGRESS_LABEL_WIDTH_CHARS)
        pauseLabel.set_ellipsize(pango.ELLIPSIZE_END)
        pauseLabel.set_alignment(0.5, 0.5)
        actionBox.pack_start(pauseLabel)
 def updateIgnoreNum(self, ignoreNum):
     '''Update ignore number label.'''
     utils.containerRemoveAll(self.ignoreNumBox)
     
     if ignoreNum > 0:
         (ignoreLabel, ignoreEventBox) = setDefaultClickableDynamicLabel(
             __("No Notify UpdatePage") % (ignoreNum),
             "topbarButton",
             )
         ignoreEventBox.connect("button-press-event", lambda w, e: self.showIgnorePageCallback())
         self.ignoreNumBox.add(ignoreEventBox)
         self.ignoreNumBox.show_all()
    def __init__(self, pageId, keyword, itemNum, repoCache,
                 exitSearchPageCallback, searchCallback,
                 clickCandidateCallback):
        '''Init for top bar.'''
        self.repoCache = repoCache
        self.paddingX = 5
        self.box = gtk.HBox()
        self.boxAlign = gtk.Alignment()
        self.boxAlign.set(0.0, 0.5, 1.0, 1.0)
        if itemNum > 20:
            paddingRight = TOPBAR_SEARCH_RIGHT
        else:
            paddingRight = TOPBAR_SEARCH_ADJUST_RIGHT
        self.boxAlign.set_padding(0, 0, TOPBAR_PADDING_LEFT, paddingRight)
        self.boxAlign.add(self.box)
        self.eventbox = gtk.EventBox()
        drawTopbar(self.eventbox)
        self.eventbox.add(self.boxAlign)
        self.keywordLabel = gtk.Label()
        self.updateTopbar(keyword, itemNum)

        # Add search entry and label.
        (self.searchEntry, searchAlign, self.searchCompletion) = newSearchUI(
            __("Please enter the name you want to uninstall the software, version or other information"
               ),
            lambda text: getCandidates(self.repoCache.uninstallablePkgs, text),
            clickCandidateCallback, searchCallback)

        # Add return button.
        (returnButton, returnButtonAlign) = newActionButton(
            "search", 1.0, 0.5, "cell", False, __("Return"),
            BUTTON_FONT_SIZE_MEDIUM, "bigButtonFont", 0, 10)
        returnButton.connect(
            "button-release-event",
            lambda widget, event: exitSearchPageCallback(pageId))

        # Connect widgets.
        self.box.pack_start(self.keywordLabel, False, False)
        self.box.pack_start(searchAlign, True, True, self.paddingX)
        self.box.pack_start(returnButtonAlign, False, False)
    def updateIgnoreNum(self, ignoreNum):
        '''Update ignore number label.'''
        utils.containerRemoveAll(self.ignoreNumBox)

        if ignoreNum > 0:
            (ignoreLabel, ignoreEventBox) = setDefaultClickableDynamicLabel(
                __("No Notify UpdatePage") % (ignoreNum),
                "topbarButton",
            )
            ignoreEventBox.connect("button-press-event",
                                   lambda w, e: self.showIgnorePageCallback())
            self.ignoreNumBox.add(ignoreEventBox)
            self.ignoreNumBox.show_all()
 def updateNum(self, upgradeNum):
     '''Update number.'''
     # Don't show label when nothing to download.
     if upgradeNum == 0:
         markup = ""
     else:
         markup = (__("Topbar DownloadManagePage") % (LABEL_FONT_SIZE, 
                                                      appTheme.getDynamicColor("topbarNum").getColor(),
                                                      LABEL_FONT_SIZE, 
                                                      str(upgradeNum), 
                                                      LABEL_FONT_SIZE))
                            
     self.numLabel.set_markup(markup)
 def updateTopbar(self, keyword, itemNum):
     '''Set number label.'''
     
     self.keywordLabel.set_markup(
         __("Topbar SearchUninstallPage") % (LABEL_FONT_SIZE, 
                                             appTheme.getDynamicColor("topbarKeyword").getColor(),
                                             LABEL_FONT_SIZE, 
                                             keyword.strip(), 
                                             LABEL_FONT_SIZE, 
                                             appTheme.getDynamicColor("topbarNum").getColor(),
                                             LABEL_FONT_SIZE, 
                                             str(itemNum), 
                                             LABEL_FONT_SIZE))
 def showTooltip(self):
     '''Show tooltip.'''
     # Clean widget first.
     containerRemoveAll(self.tooltipEventBox)
     
     # Draw.
     label = gtk.Label()
     label.set_markup("<span size='%s'>%s</span>" % (LABEL_FONT_SIZE, 
                                                     (__("There are %s software packages can be upgraded") % (self.updateNum))))
     
     self.tooltipEventBox.add(label)
     self.tooltipWindow.queue_draw()
     self.tooltipWindow.show_all()
    def updateUpgradingStatus(self, progress, feedback, color=None):
        '''Update upgrading status.'''
        if self.appInfo.status == APP_STATE_UPGRADING:
            if (color == None):
                color = appTheme.getDynamicColor("statusUpdate").getColor()

            if self.upgradingProgressbar != None and self.upgradingFeedbackLabel != None:
                self.upgradingProgressbar.setProgress(progress)
                self.upgradingFeedbackLabel.set_markup(
                    "<span foreground='%s' size='%s'>%s</span>" %
                    (color, LABEL_FONT_SIZE, __("Action Updating")))

                self.itemFrame.show_all()