diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2008-10-14 22:53:14 +0000 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2010-09-30 07:08:50 +0000 |
commit | dec6029f07c75ffe08b7edcfa26455c3ee7692e8 (patch) | |
tree | 5fc3e3edacba51afde847f04deaf0626b8dae71c | |
parent | 807ae6d7d376189cbf17271686d8389c541c7975 (diff) |
Sections should have icons displayed, too.
-rw-r--r-- | Cydia.app/package.html | 1 | ||||
-rw-r--r-- | Cydia.app/package.js | 6 | ||||
-rw-r--r-- | Cydia.mm | 37 |
3 files changed, 35 insertions, 9 deletions
diff --git a/Cydia.app/package.html b/Cydia.app/package.html index 710b87a..46da6ad 100644 --- a/Cydia.app/package.html +++ b/Cydia.app/package.html @@ -231,6 +231,7 @@ </div> <div class="section"> + <img id="section-src" class="icon"/> <label>Section</label> <div id="section"></div> </div> diff --git a/Cydia.app/package.js b/Cydia.app/package.js index e409aa9..762167a 100644 --- a/Cydia.app/package.js +++ b/Cydia.app/package.js @@ -142,8 +142,10 @@ $(function () { var section = package.section; if (section == null) $(".section").remove(); - else - $("#section").html(package.section); + else { + $("#section-src").src("cydia://section-icon/" + encodeURIComponent(section)); + $("#section").html(section); + } var size = package.size; if (size == 0) @@ -1170,6 +1170,8 @@ NSString *Scour(const char *field, const char *begin, const char *end) { - (pkgCache::PkgIterator) iterator; - (NSString *) section; +- (NSString *) simpleSection; + - (Address *) maintainer; - (size_t) size; - (NSString *) description; @@ -1425,6 +1427,14 @@ NSString *Scour(const char *field, const char *begin, const char *end) { return section_; } +- (NSString *) simpleSection { + if (NSString *section = [self section]) + return Simplify(section); + else + return nil; + +} + - (Address *) maintainer { if (file_.end()) return nil; @@ -1594,9 +1604,7 @@ NSString *Scour(const char *field, const char *begin, const char *end) { } - (UIImage *) icon { - NSString *section = [self section]; - if (section != nil) - section = Simplify(section); + NSString *section = [self simpleSection]; UIImage *icon(nil); if (NSString *icon = icon_) @@ -3366,9 +3374,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [self clearPackage]; Source *source = [package source]; - NSString *section = [package section]; - if (section != nil) - section = Simplify(section); + NSString *section = [package simpleSection]; icon_ = [[package icon] retain]; @@ -5447,15 +5453,32 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { if ([command isEqualToString:@"package-icon"]) { if (path == nil) goto fail; + path = [path stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; Package *package([database packageWithName:path]); if (package == nil) goto fail; + UIImage *icon([package icon]); + + NSData *data(UIImagePNGRepresentation(icon)); + NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:@"image/png" expectedContentLength:-1 textEncodingName:nil] autorelease]); + [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed]; + [client URLProtocol:self didLoadData:data]; + [client URLProtocolDidFinishLoading:self]; + } else if ([command isEqualToString:@"section-icon"]) { + if (path == nil) + goto fail; + path = [path stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; + NSString *section(Simplify(path)); + + UIImage *icon([UIImage imageAtPath:[NSString stringWithFormat:@"%@/Sections/%@.png", App_, section]]); + if (icon == nil) + icon = [UIImage applicationImageNamed:@"unknown.png"]; - UIImage *icon([package icon]); NSData *data(UIImagePNGRepresentation(icon)); + NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:@"image/png" expectedContentLength:-1 textEncodingName:nil] autorelease]); [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed]; [client URLProtocol:self didLoadData:data]; [client URLProtocolDidFinishLoading:self]; |