]> git.saurik.com Git - cydia.git/commitdiff
Sections should have icons displayed, too.
authorJay Freeman (saurik) <saurik@saurik.com>
Tue, 14 Oct 2008 22:53:14 +0000 (22:53 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Thu, 30 Sep 2010 07:08:50 +0000 (07:08 +0000)
Cydia.app/package.html
Cydia.app/package.js
Cydia.mm

index 710b87a929833810a0208d978f22ff86932b7e00..46da6adffefe15a30d5a14dd86c45bab7ec15f41 100644 (file)
     </div>
 
     <div class="section">
     </div>
 
     <div class="section">
+        <img id="section-src" class="icon"/>
         <label>Section</label>
         <div id="section"></div>
     </div>
         <label>Section</label>
         <div id="section"></div>
     </div>
index e409aa988851f8c9e14f6c846d31ddce1f7f82f0..762167af0ad9a893bfaff23befc5d51a475e0e9e 100644 (file)
@@ -142,8 +142,10 @@ $(function () {
     var section = package.section;
     if (section == null)
         $(".section").remove();
     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)
 
     var size = package.size;
     if (size == 0)
index 8d48ac068dfff4925f4ede6a827fd023bf8c5c30..f94557abda15942a59a436d9b366a013de5e8c19 100644 (file)
--- 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;
 - (pkgCache::PkgIterator) iterator;
 
 - (NSString *) section;
+- (NSString *) simpleSection;
+
 - (Address *) maintainer;
 - (size_t) size;
 - (NSString *) description;
 - (Address *) maintainer;
 - (size_t) size;
 - (NSString *) description;
@@ -1425,6 +1427,14 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
     return section_;
 }
 
     return section_;
 }
 
+- (NSString *) simpleSection {
+    if (NSString *section = [self section])
+        return Simplify(section);
+    else
+        return nil;
+
+}
+
 - (Address *) maintainer {
     if (file_.end())
         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 {
 }
 
 - (UIImage *) icon {
-    NSString *section = [self section];
-    if (section != nil)
-        section = Simplify(section);
+    NSString *section = [self simpleSection];
 
     UIImage *icon(nil);
     if (NSString *icon = icon_)
 
     UIImage *icon(nil);
     if (NSString *icon = icon_)
@@ -3366,9 +3374,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
     [self clearPackage];
 
     Source *source = [package source];
     [self clearPackage];
 
     Source *source = [package source];
-    NSString *section = [package section];
-    if (section != nil)
-        section = Simplify(section);
+    NSString *section = [package simpleSection];
 
     icon_ = [[package icon] retain];
 
 
     icon_ = [[package icon] retain];
 
@@ -5447,15 +5453,32 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
     if ([command isEqualToString:@"package-icon"]) {
         if (path == nil)
             goto fail;
     if ([command isEqualToString:@"package-icon"]) {
         if (path == nil)
             goto fail;
+        path = [path stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
         Package *package([database packageWithName:path]);
         if (package == nil)
             goto fail;
 
         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]);
         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));
 
         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];
         [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
         [client URLProtocol:self didLoadData:data];
         [client URLProtocolDidFinishLoading:self];