def copyThemeFilesToConfigDir(widget): # Copy files for file in Globals().nsCGuiFiles: source = karamba.readThemeFile( widget, file ) dest = open( os.path.join( Globals().nsCGuiBaseDir, file ), "w" ) tools.msgDebug("Copying file: %s" % file, __name__) print >> dest, source dest.close()
def copyThemeFilesToConfigDir(widget): # Copy files for file in Globals().nsCGuiFiles: source = karamba.readThemeFile(widget, file) dest = open(os.path.join(Globals().nsCGuiBaseDir, file), "w") tools.msgDebug("Copying file: %s" % file, __name__) print >> dest, source dest.close()
def _readThemeInfos(self, theme): self.themeName = theme self.themePath = os.path.join("themes", self.themeName) themeInfo = os.path.join( self.themePath, "theme.info" ) themeInfoContent = karamba.readThemeFile( Applet.widget, themeInfo ) if themeInfoContent == "": tools.msgDebug("Error finding/reading %s..." % themeInfo, __name__) # Try to fallback to the default theme self.themeName = Globals().defaultThemeName self.themePath = os.path.join("themes", self.themeName) themeInfo = os.path.join( self.themePath, "theme.info" ) themeInfoContent = karamba.readThemeFile( Applet.widget, themeInfo ) if themeInfoContent == "": tools.msgDebug("Error finding/reading %s..." % themeInfo, __name__) return False ####################################################################### # FIXME: Unfortunately, it is not possible to directly feed ConfigParser # with a str().... # Yep! That's another ugly hack! ####################################################################### tempName = os.tempnam() fp = open( tempName, "w" ) fp.write( themeInfoContent ) fp.close() fp = open( tempName, "r" ) scp = SafeConfigParser() scp.readfp( fp ) fp.close() os.unlink( tempName ) ####################################################################### self.themeHeaderImg = os.path.join( self.themePath, scp.get( "images", "header" ) ) self.themeHeaderTxtTitle = scp.get( "header", "title_text" ) X = scp.getint( "header", "title_pos_x" ) Y = scp.getint( "header", "title_pos_y" ) self.themeHeaderTxtTitleXY = ( X, Y ) W = scp.getint( "header", "title_width" ) H = 0 self.themeHeaderTxtTitleWH = ( W, H ) self.themeHeaderTxtWhen = scp.get( "header", "when_text" ) X = scp.getint( "header", "when_pos_x" ) Y = scp.getint( "header", "when_pos_y" ) self.themeHeaderTxtWhenXY = ( X, Y ) W = scp.getint( "header", "when_width" ) H = 0 self.themeHeaderTxtWhenWH = ( W, H ) self.themeBodyImg = os.path.join( self.themePath, scp.get( "images", "body" ) ) X = scp.getint( "body", "title_pos_x" ) Y = scp.getint( "body", "title_pos_y" ) self.themeBodyTitleXY = ( X, Y ) W = scp.getint( "body", "title_width" ) H = scp.getint( "body", "title_height" ) self.themeBodyTitleWH = ( W, H ) X = scp.getint( "body", "when_pos_x" ) Y = scp.getint( "body", "when_pos_y" ) self.themeBodyWhenXY = ( X, Y ) W = scp.getint( "body", "when_width" ) H = scp.getint( "body", "when_height" ) self.themeBodyWhenWH = ( W, H ) self.themeFooterImg = os.path.join( self.themePath, scp.get( "images", "footer" ) )
def _readThemeInfos(self, theme): self.themeName = theme self.themePath = os.path.join("themes", self.themeName) themeInfo = os.path.join(self.themePath, "theme.info") themeInfoContent = karamba.readThemeFile(Applet.widget, themeInfo) if themeInfoContent == "": tools.msgDebug("Error finding/reading %s..." % themeInfo, __name__) # Try to fallback to the default theme self.themeName = Globals().defaultThemeName self.themePath = os.path.join("themes", self.themeName) themeInfo = os.path.join(self.themePath, "theme.info") themeInfoContent = karamba.readThemeFile(Applet.widget, themeInfo) if themeInfoContent == "": tools.msgDebug("Error finding/reading %s..." % themeInfo, __name__) return False ####################################################################### # FIXME: Unfortunately, it is not possible to directly feed ConfigParser # with a str().... # Yep! That's another ugly hack! ####################################################################### tempName = os.tempnam() fp = open(tempName, "w") fp.write(themeInfoContent) fp.close() fp = open(tempName, "r") scp = SafeConfigParser() scp.readfp(fp) fp.close() os.unlink(tempName) ####################################################################### self.themeHeaderImg = os.path.join(self.themePath, scp.get("images", "header")) self.themeHeaderTxtTitle = scp.get("header", "title_text") X = scp.getint("header", "title_pos_x") Y = scp.getint("header", "title_pos_y") self.themeHeaderTxtTitleXY = (X, Y) W = scp.getint("header", "title_width") H = 0 self.themeHeaderTxtTitleWH = (W, H) self.themeHeaderTxtWhen = scp.get("header", "when_text") X = scp.getint("header", "when_pos_x") Y = scp.getint("header", "when_pos_y") self.themeHeaderTxtWhenXY = (X, Y) W = scp.getint("header", "when_width") H = 0 self.themeHeaderTxtWhenWH = (W, H) self.themeBodyImg = os.path.join(self.themePath, scp.get("images", "body")) X = scp.getint("body", "title_pos_x") Y = scp.getint("body", "title_pos_y") self.themeBodyTitleXY = (X, Y) W = scp.getint("body", "title_width") H = scp.getint("body", "title_height") self.themeBodyTitleWH = (W, H) X = scp.getint("body", "when_pos_x") Y = scp.getint("body", "when_pos_y") self.themeBodyWhenXY = (X, Y) W = scp.getint("body", "when_width") H = scp.getint("body", "when_height") self.themeBodyWhenWH = (W, H) self.themeFooterImg = os.path.join(self.themePath, scp.get("images", "footer"))