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 getPkgLongDesc(pkg): '''Get package's long description.''' pkgPath = "../pkgData/pkgInfo/" + pkg.name if os.path.exists(pkgPath): longDescDict = evalFile(pkgPath) if longDescDict.has_key(getDefaultLanguage()): return ((evalFile(pkgPath))[getDefaultLanguage()])["longDesc"] else: return pkg.candidate.description else: return pkg.candidate.description
def getPkgShortDesc(pkg): '''Get package's short description.''' pkgPath = "../pkgData/pkgInfo/" + pkg.name if os.path.exists(pkgPath): shortDescDict = evalFile(pkgPath) if shortDescDict.has_key(getDefaultLanguage()): return ((evalFile(pkgPath))[getDefaultLanguage()])["shortDesc"] else: return pkg.candidate.summary else: return pkg.candidate.summary
def getPkgLongDesc(pkg): '''Get package's long description.''' pkgPath = "../pkgData/pkgInfo/" + pkg.name if os.path.exists(pkgPath): longDescDict = evalFile(pkgPath) if longDescDict.has_key(getDefaultLanguage()): return ((evalFile(pkgPath))[getDefaultLanguage()])["longDesc"] else: return pkg.candidate.description else: return pkg.candidate.description
def getPkgShortDesc(pkg): '''Get package's short description.''' pkgPath = "../pkgData/pkgInfo/" + pkg.name if os.path.exists(pkgPath): shortDescDict = evalFile(pkgPath) if shortDescDict.has_key(getDefaultLanguage()): return ((evalFile(pkgPath))[getDefaultLanguage()])["shortDesc"] else: return pkg.candidate.summary else: return pkg.candidate.summary
def createLogoIcon(self): '''Create navigate icon.''' eventBox = gtk.EventBox() eventBox.set_visible_window(False) navBox = gtk.VBox() navImage = gtk.image_new_from_pixbuf(gtk.gdk.pixbuf_new_from_file( "../icon/logo/%s/logo.png" % (getDefaultLanguage()))) navBox.pack_start(navImage, False) eventBox.add(navBox) eventBox.show_all() return eventBox
def createLogoIcon(self): '''Create navigate icon.''' eventBox = gtk.EventBox() eventBox.set_visible_window(False) navBox = gtk.VBox() navImage = gtk.image_new_from_pixbuf( gtk.gdk.pixbuf_new_from_file("../icon/logo/%s/logo.png" % (getDefaultLanguage()))) navBox.pack_start(navImage, False) eventBox.add(navBox) eventBox.show_all() return eventBox
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 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_UNINSTALL, self.sendVoteCallback) self.appAdditionBox.pack_start(self.appVoteView.eventbox, False, False) # Add application installed size. size = utils.getPkgInstalledSize(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 action button. (actionButtonBox, actionButtonAlign) = createActionButton() self.appAdditionBox.pack_start(actionButtonAlign, False, False) if self.confirmUninstall: appUninstallLabel = gtk.Label() appUninstallLabel.set_markup( "<span foreground='%s' size='%s'>%s</span>" % ( appTheme.getDynamicColor("uninstallConfirm").getColor(), LABEL_FONT_SIZE, __("Are you sure uninstall?"))) actionButtonBox.pack_start(appUninstallLabel, False, False) appUninstallBox = gtk.HBox() appUninstallAlign = gtk.Alignment() appUninstallAlign.set(0.5, 0.5, 1.0, 1.0) appUninstallAlign.set_padding(ACTION_BUTTON_PADDING_Y, ACTION_BUTTON_PADDING_Y, 0, 0) appUninstallAlign.add(appUninstallBox) actionButtonBox.pack_start(appUninstallAlign, False, False) if getDefaultLanguage() == "default": buttonName = "uninstall_confirm" else: buttonName = "uninstall_confirm_cn" (appConfirmButton, appConfirmAlign) = newActionButton( buttonName, 0.0, 0.5, "cell", False, __("Action Uninstall"), BUTTON_FONT_SIZE_SMALL, "buttonFont" ) appConfirmButton.connect("button-release-event", lambda widget, event: self.switchToUninstalling()) (appCancelButton, appCancelAlign) = newActionButton( buttonName, 1.0, 0.5, "cell", False, __("Action Cancel"), BUTTON_FONT_SIZE_SMALL, "buttonFont" ) appCancelButton.connect("button-release-event", lambda widget, event: self.switchToNormal(False)) appUninstallBox.pack_start(appConfirmAlign) appUninstallBox.pack_start(appCancelAlign) else: (appUninstallBox, appUninstallAlign) = newActionButton( "uninstall", 0.5, 0.5, "cell", False, __("Action Uninstall"), BUTTON_FONT_SIZE_SMALL, "buttonFont" ) appUninstallBox.connect("button-release-event", lambda widget, event: self.switchToNormal(True)) actionButtonBox.pack_start(appUninstallAlign)
def __init__(self, repoCache, switchStatus, downloadQueue, entryDetailCallback, selectCategoryCallback, launchApplicationCallback, updateDataDir): '''Init for recommend view.''' # Init. self.repoCache = repoCache self.switchStatus = switchStatus self.downloadQueue = downloadQueue self.entryDetailCallback = entryDetailCallback self.selectCategoryCallback = selectCategoryCallback self.launchApplicationCallback = launchApplicationCallback self.updateDataDir = updateDataDir self.box = gtk.VBox() self.itemDict = {} self.index = -1 self.ticker = 0 # Create container box. listLen = 12 self.pkgRecomments = evalFile(self.updateDataDir + "pkgRecommend/%s/recommendList.txt" % (getDefaultLanguage())) boxlist = map (lambda n: gtk.HBox(), range(0, listLen / 2 + listLen % 2)) for box in boxlist: self.box.pack_start(box, False, False) # Add home recommend list. boxIndex = 0 for (index, itemName) in enumerate([CLASSIFY_NEWS, CLASSIFY_RECOMMEND]): appList = self.pkgRecomments[index] recommendList = self.createRecommendList(itemName, False, appList) box = boxlist[boxIndex / 2] boxIndex += 1 box.pack_start(recommendList, False, False) # Add classify recommend list. for categoryName in self.repoCache.getCategoryNames(): (_, (sortRecommendList, sortDownloadList, sortVoteList)) = self.repoCache.categoryDict[categoryName] appList = sortRecommendList[0:5] recommendList = self.createRecommendList(categoryName, True, appList) box = boxlist[boxIndex / 2] boxIndex += 1 box.pack_start(recommendList, False, False) self.box.show_all()
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_UNINSTALL, self.sendVoteCallback) self.appAdditionBox.pack_start(self.appVoteView.eventbox, False, False) # Add application installed size. size = utils.getPkgInstalledSize(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 action button. (actionButtonBox, actionButtonAlign) = createActionButton() self.appAdditionBox.pack_start(actionButtonAlign, False, False) if self.confirmUninstall: appUninstallLabel = gtk.Label() appUninstallLabel.set_markup( "<span foreground='%s' size='%s'>%s</span>" % (appTheme.getDynamicColor("uninstallConfirm").getColor(), LABEL_FONT_SIZE, __("Are you sure uninstall?"))) actionButtonBox.pack_start(appUninstallLabel, False, False) appUninstallBox = gtk.HBox() appUninstallAlign = gtk.Alignment() appUninstallAlign.set(0.5, 0.5, 1.0, 1.0) appUninstallAlign.set_padding(ACTION_BUTTON_PADDING_Y, ACTION_BUTTON_PADDING_Y, 0, 0) appUninstallAlign.add(appUninstallBox) actionButtonBox.pack_start(appUninstallAlign, False, False) if getDefaultLanguage() == "default": buttonName = "uninstall_confirm" else: buttonName = "uninstall_confirm_cn" (appConfirmButton, appConfirmAlign) = newActionButton( buttonName, 0.0, 0.5, "cell", False, __("Action Uninstall"), BUTTON_FONT_SIZE_SMALL, "buttonFont") appConfirmButton.connect( "button-release-event", lambda widget, event: self.switchToUninstalling()) (appCancelButton, appCancelAlign) = newActionButton( buttonName, 1.0, 0.5, "cell", False, __("Action Cancel"), BUTTON_FONT_SIZE_SMALL, "buttonFont") appCancelButton.connect( "button-release-event", lambda widget, event: self.switchToNormal(False)) appUninstallBox.pack_start(appConfirmAlign) appUninstallBox.pack_start(appCancelAlign) else: (appUninstallBox, appUninstallAlign) = newActionButton( "uninstall", 0.5, 0.5, "cell", False, __("Action Uninstall"), BUTTON_FONT_SIZE_SMALL, "buttonFont") appUninstallBox.connect( "button-release-event", lambda widget, event: self.switchToNormal(True)) actionButtonBox.pack_start(appUninstallAlign)
def __init__(self, cache, updateDataDir): '''Init for repository cache.''' # Init. self.cache = {} self.updateDataDir = updateDataDir self.upgradablePkgs = [] ignorePkgs = evalFile("./ignorePkgs", True) if ignorePkgs == None: self.ignorePkgs = [] else: self.ignorePkgs = ignorePkgs self.uninstallablePkgs = [] self.categoryDict = sortedDict.SortedDict(CLASSIFY_LIST) # Scan category dict. whiteList = [] sortRecommendDir = self.updateDataDir + "pkgClassify/sortByDefault/%s/" % (getDefaultLanguage()) sortDownloadDir = self.updateDataDir + "pkgClassify/sortByDownload/" sortVoteDir = self.updateDataDir + "pkgClassify/sortByVote/" for (categoryType, categoryFile) in CLASSIFY_FILES: sortRecommendList = [] sortDownloadList = [] sortVoteList = [] # Scan default sort list. for line in open(sortRecommendDir + categoryFile).readlines(): pkgName = line.rstrip("\n") if cache.has_key(pkgName) and cache[pkgName].candidate != None: # Append in default sort list. sortRecommendList.append(pkgName) # Add in white list. whiteList.append(pkgName) else: print pkgName # print "Haven't found package '%s' in current system (%s). Make sure you use Linux Deepin or add deepin sourcelist." % (pkgName, sortRecommendDir + categoryFile) # Scan download sort list. for line in open(sortDownloadDir + categoryFile).readlines(): pkgName = line.rstrip("\n") if cache.has_key(pkgName) and cache[pkgName].candidate != None: # Append in download sort list. sortDownloadList.append(pkgName) else: print pkgName # print "Haven't found package '%s' in current system (%s). Make sure you use Linux Deepin or add deepin sourcelist." % (pkgName, sortDownloadDir + categoryFile) # Scan vote sort list. for line in open(sortVoteDir + categoryFile).readlines(): pkgName = line.rstrip("\n") if cache.has_key(pkgName) and cache[pkgName].candidate != None: # Append in vote sort list. sortVoteList.append(pkgName) else: print pkgName # print "Haven't found package '%s' in current system (%s). Make sure you use Linux Deepin or add deepin sourcelist." % (pkgName, sortVoteDir + categoryFile) # Add sort list in category dict. (classifyIcon, _) = self.categoryDict[categoryType] self.categoryDict[categoryType] = (classifyIcon, (sortRecommendList, sortDownloadList, sortVoteList)) # Build white list dict. self.whiteListDict = dict.fromkeys(whiteList) # Scan all packages to store and rank. for pkg in cache: if pkg.candidate == None: print "Can't find candidate information for %s, skip it." % (pkg.name) else: # Add AppInfo. self.cache[pkg.name] = AppInfo(pkg) # Add upgradable packages. if pkg.is_upgradable and pkg.name not in self.ignorePkgs: self.upgradablePkgs.append(pkg.name) # Add uninstall packages. # Package must not essential and not library packages. if self.isPkgUninstallable(pkg): self.uninstallablePkgs.append(pkg.name) # Resort. self.upgradablePkgs = self.sortPackages(self.upgradablePkgs) self.ignorePkgs = self.sortPackages(self.ignorePkgs)
BUTTON_FONT_SIZE_MEDIUM = 11 BUTTON_FONT_SIZE_LARGE = 12 LABEL_FONT_SIZE = 10 * 1000 LABEL_FONT_MEDIUM_SIZE = 11 * 1000 LABEL_FONT_LARGE_SIZE = 12 * 1000 LABEL_FONT_X_LARGE_SIZE = 13 * 1000 LABEL_FONT_XX_LARGE_SIZE = 15 * 1000 LABEL_FONT_XXX_LARGE_SIZE = 20 * 1000 DOWNLOAD_TIMEOUT = 120 # times POST_TIMEOUT = 10 # seconds GET_TIMEOUT = 10 # seconds ACTION_BUTTON_PADDING_X = 5 ACTION_BUTTON_PADDING_Y = 5 lang = getDefaultLanguage() if lang == "default": ACTION_BUTTON_WIDTH = 140 APP_BASIC_WIDTH_ADJUST = 120 else: ACTION_BUTTON_WIDTH = 100 APP_BASIC_WIDTH_ADJUST = 0 DEFAULT_WINDOW_WIDTH = 890 DEFAULT_WINDOW_HEIGHT = 631 TOPBAR_PADDING_LEFT = 10 TOPBAR_PADDING_RIGHT = 40 TOPBAR_PADDING_UPDATE_RIGHT = 10 TOPBAR_SEARCH_RIGHT = 30 TOPBAR_SEARCH_ADJUST_RIGHT = 15
def __init__(self, repoCache, switchStatus, downloadQueue, entryDetailCallback, launchApplicationCallback, updateDataDir): '''Init for slide bar.''' # Init. self.entryDetailCallback = entryDetailCallback self.launchApplicationCallback = launchApplicationCallback self.padding = 10 self.imageWidth = 600 self.imageHeight = 300 self.maskHeight = 50 self.times = 10 self.interval = 300 / self.times self.smallImagePaddingY = 10 self.hoverTimeoutIds = {} self.hoverTimeout = 100 self.repoCache = repoCache self.slideDir = updateDataDir + "slide/%s" % (getDefaultLanguage()) self.infoList = evalFile("%s/index.txt" % (self.slideDir)) self.itemDict = sortedDict.SortedDict(map(lambda (pkgName, _): (pkgName, None), self.infoList)) self.initItems(switchStatus, downloadQueue) self.sourceIndex = 1 self.targetIndex = 0 self.sourceImage = self.createSlideImage(self.sourceIndex) self.targetImage = self.createSlideImage(self.targetIndex) self.maskPixbuf = appTheme.getDynamicPixbuf("recommend/mask.png") self.stop = True self.ticker = self.times self.index = 0 self.alphaInterval = 1 self.align = gtk.Alignment() self.align.set(0.5, 0.5, 0.0, 0.0) self.align.set_padding(self.padding, self.padding, self.padding, self.padding) # Add slide label. self.labelBox = gtk.VBox() for (index, _) in enumerate(self.infoList): self.createSlideLabel(index) # Add slide area. self.drawingArea = gtk.EventBox() self.drawingArea.set_visible_window(False) self.drawingArea.set_size_request(self.imageWidth, self.imageHeight) self.drawingArea.connect("expose_event", self.exposeBigArea) self.drawingArea.connect( "button-press-event", lambda w, e: self.entryDetailView()) setClickableCursor(self.drawingArea) self.drawingArea.queue_draw() self.slideItemBox = gtk.VBox() self.slideItemAlign = gtk.Alignment() self.slideItemAlign.set(0.0, 1.0, 0.0, 0.0) self.slideItemAlign.add(self.slideItemBox) self.drawingArea.add(self.slideItemAlign) self.slideItemBox.pack_start(self.getSlideItem(self.targetIndex).itemFrame) # Connect widgets. self.box = gtk.HBox() self.box.pack_start(self.drawingArea, False, False) self.box.pack_start(self.labelBox, False, False) self.align.add(self.box)
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, repoCache, switchStatus, downloadQueue, entryDetailCallback, launchApplicationCallback, updateDataDir): '''Init for slide bar.''' # Init. self.entryDetailCallback = entryDetailCallback self.launchApplicationCallback = launchApplicationCallback self.padding = 10 self.imageWidth = 600 self.imageHeight = 300 self.maskHeight = 50 self.times = 10 self.interval = 300 / self.times self.smallImagePaddingY = 10 self.hoverTimeoutIds = {} self.hoverTimeout = 100 self.repoCache = repoCache self.slideDir = updateDataDir + "slide/%s" % (getDefaultLanguage()) self.infoList = evalFile("%s/index.txt" % (self.slideDir)) self.itemDict = sortedDict.SortedDict( map(lambda (pkgName, _): (pkgName, None), self.infoList)) self.initItems(switchStatus, downloadQueue) self.sourceIndex = 1 self.targetIndex = 0 self.sourceImage = self.createSlideImage(self.sourceIndex) self.targetImage = self.createSlideImage(self.targetIndex) self.maskPixbuf = appTheme.getDynamicPixbuf("recommend/mask.png") self.stop = True self.ticker = self.times self.index = 0 self.alphaInterval = 1 self.align = gtk.Alignment() self.align.set(0.5, 0.5, 0.0, 0.0) self.align.set_padding(self.padding, self.padding, self.padding, self.padding) # Add slide label. self.labelBox = gtk.VBox() for (index, _) in enumerate(self.infoList): self.createSlideLabel(index) # Add slide area. self.drawingArea = gtk.EventBox() self.drawingArea.set_visible_window(False) self.drawingArea.set_size_request(self.imageWidth, self.imageHeight) self.drawingArea.connect("expose_event", self.exposeBigArea) self.drawingArea.connect("button-press-event", lambda w, e: self.entryDetailView()) setClickableCursor(self.drawingArea) self.drawingArea.queue_draw() self.slideItemBox = gtk.VBox() self.slideItemAlign = gtk.Alignment() self.slideItemAlign.set(0.0, 1.0, 0.0, 0.0) self.slideItemAlign.add(self.slideItemBox) self.drawingArea.add(self.slideItemAlign) self.slideItemBox.pack_start( self.getSlideItem(self.targetIndex).itemFrame) # Connect widgets. self.box = gtk.HBox() self.box.pack_start(self.drawingArea, False, False) self.box.pack_start(self.labelBox, False, False) self.align.add(self.box)
def __init__(self, cache, updateDataDir): '''Init for repository cache.''' # Init. self.cache = {} self.updateDataDir = updateDataDir self.upgradablePkgs = [] ignorePkgs = evalFile("./ignorePkgs", True) if ignorePkgs == None: self.ignorePkgs = [] else: self.ignorePkgs = ignorePkgs self.uninstallablePkgs = [] self.categoryDict = sortedDict.SortedDict(CLASSIFY_LIST) # Scan category dict. whiteList = [] sortRecommendDir = self.updateDataDir + "pkgClassify/sortByDefault/%s/" % (getDefaultLanguage()) sortDownloadDir = self.updateDataDir + "pkgClassify/sortByDownload/" sortVoteDir = self.updateDataDir + "pkgClassify/sortByVote/" for (categoryType, categoryFile) in CLASSIFY_FILES: sortRecommendList = [] sortDownloadList = [] sortVoteList = [] # Scan default sort list. for line in open(sortRecommendDir + categoryFile).readlines(): pkgName = line.rstrip("\n") if cache.has_key(pkgName) and cache[pkgName].candidate != None: # Append in default sort list. sortRecommendList.append(pkgName) # Add in white list. whiteList.append(pkgName) else: print pkgName # print "Haven't found package '%s' in current system (%s). Make sure you use Linux Deepin or add deepin sourcelist." % (pkgName, sortRecommendDir + categoryFile) # Scan download sort list. for line in open(sortDownloadDir + categoryFile).readlines(): pkgName = line.rstrip("\n") if cache.has_key(pkgName) and cache[pkgName].candidate != None: # Append in download sort list. sortDownloadList.append(pkgName) else: print pkgName # print "Haven't found package '%s' in current system (%s). Make sure you use Linux Deepin or add deepin sourcelist." % (pkgName, sortDownloadDir + categoryFile) # Scan vote sort list. for line in open(sortVoteDir + categoryFile).readlines(): pkgName = line.rstrip("\n") if cache.has_key(pkgName) and cache[pkgName].candidate != None: # Append in vote sort list. sortVoteList.append(pkgName) else: print pkgName # print "Haven't found package '%s' in current system (%s). Make sure you use Linux Deepin or add deepin sourcelist." % (pkgName, sortVoteDir + categoryFile) # Add sort list in category dict. (classifyIcon, _) = self.categoryDict[categoryType] self.categoryDict[categoryType] = (classifyIcon, (sortRecommendList, sortDownloadList, sortVoteList)) # Build white list dict. self.whiteListDict = dict.fromkeys(whiteList) # Scan all packages to store and rank. for pkg in cache: if pkg.candidate == None: print "Can't find candidate information for %s, skip it." % (pkg.name) else: # Add AppInfo. self.cache[pkg.name] = AppInfo(pkg) # Add upgradable packages. if pkg.is_upgradable and pkg.name not in self.ignorePkgs: self.upgradablePkgs.append(pkg.name) # Add uninstall packages. # Package must not essential and not library packages. if self.isPkgUninstallable(pkg): self.uninstallablePkgs.append(pkg.name) # Resort. self.upgradablePkgs = self.sortPackages(self.upgradablePkgs) self.ignorePkgs = self.sortPackages(self.ignorePkgs)
BUTTON_FONT_SIZE_MEDIUM = 11 BUTTON_FONT_SIZE_LARGE = 12 LABEL_FONT_SIZE = 10 * 1000 LABEL_FONT_MEDIUM_SIZE = 11 * 1000 LABEL_FONT_LARGE_SIZE = 12 * 1000 LABEL_FONT_X_LARGE_SIZE = 13 * 1000 LABEL_FONT_XX_LARGE_SIZE = 15 * 1000 LABEL_FONT_XXX_LARGE_SIZE = 20 * 1000 DOWNLOAD_TIMEOUT = 120 # times POST_TIMEOUT = 10 # seconds GET_TIMEOUT = 10 # seconds ACTION_BUTTON_PADDING_X = 5 ACTION_BUTTON_PADDING_Y = 5 lang = getDefaultLanguage() if lang == "default": ACTION_BUTTON_WIDTH = 140 APP_BASIC_WIDTH_ADJUST = 120 else: ACTION_BUTTON_WIDTH = 100 APP_BASIC_WIDTH_ADJUST = 0 DEFAULT_WINDOW_WIDTH = 890 DEFAULT_WINDOW_HEIGHT = 631 TOPBAR_PADDING_LEFT = 10 TOPBAR_PADDING_RIGHT = 40 TOPBAR_PADDING_UPDATE_RIGHT = 10 TOPBAR_SEARCH_RIGHT = 30 TOPBAR_SEARCH_ADJUST_RIGHT = 15