From: Jay Freeman (saurik) Date: Tue, 14 Oct 2008 22:53:14 +0000 (+0000) Subject: Sections should have icons displayed, too. X-Git-Tag: v1.0.3366~372 X-Git-Url: https://git.saurik.com/cydia.git/commitdiff_plain/dec6029f07c75ffe08b7edcfa26455c3ee7692e8?ds=sidebyside Sections should have icons displayed, too. --- diff --git a/Cydia.app/package.html b/Cydia.app/package.html index 710b87a9..46da6adf 100644 --- a/Cydia.app/package.html +++ b/Cydia.app/package.html @@ -231,6 +231,7 @@
+
diff --git a/Cydia.app/package.js b/Cydia.app/package.js index e409aa98..762167af 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) diff --git a/Cydia.mm b/Cydia.mm index 8d48ac06..f94557ab 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -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];