gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC] [PATCH]: Icon themability patch for -GUI images/icons


From: Alex Perez
Subject: [RFC] [PATCH]: Icon themability patch for -GUI images/icons
Date: Sat, 30 Oct 2004 06:35:28 -0700
User-agent: Mozilla Thunderbird 0.8 (X11/20040913)

This patch builds upon a previous non-behavior-changing patch which I wrote and Alexander Malmberg comitted this morning on my behalf. For some background:

NSWorkspace had a private convenience class called _getImageWithName: which, with the permission of Alexander Malmberg, we moved to NSImage and renamed to -standardImageWithName: and modified slightly so the alternate: argument was not necessary (it now intelligently looks for "ImageName" and then for "common_ImageName" (and anything else for that matter, like "camaelon_ImageName", if you override the method.) In any event, What this patch does is enable icon themability. You can have sets of icons which you can use by simply having a very small bundle override the -getImageWithName: method.

This patch builds upon the previous one, by making nearly every single image which was previously loaded directly via NSImage -imageNamed: "common_ImageName" load with the new convenience NSImage method.

Unless you want your own icon set, you will notice zero behavioral change.

Everyone, please comment on this...If I don't hear anything negative from anyone by tuesday or so of next week, I will commit it as-is. It works on my machine.

Alexander Malmberg, anything you feel you need to add?

Cheers,
Alex Perez
--- core/gui/Headers/AppKit/NSImage.h   2004-10-30 03:28:39.000000000 -0700
+++ core/gui/Headers/AppKit/NSImage.h   2004-10-30 03:28:09.000000000 -0700
@@ -102,6 +102,11 @@
 // Referring to Images by Name 
 //
 + (id) imageNamed: (NSString*)aName;
+#ifndef STRICT_OPENSTEP
+#ifndef NO_GNUSTEP
++ (NSImage*) _standardImageWithName: (NSString*)name;
+#endif
+#endif
 - (BOOL) setName: (NSString*)aName;
 - (NSString*) name;

--- core/gui/Source/NSImage.m   2004-10-30 03:32:33.000000000 -0700
+++ core/gui/Source/NSImage.m   2004-10-30 03:12:52.000000000 -0700
@@ -273,6 +273,20 @@
   return image;
 }
 
++ (NSImage*) _standardImageWithName: (NSString*)name
+{
+  NSImage      *image = nil;
+
+  image = [NSImage imageNamed: name];
+  if (image == nil)
+    image = [NSImage imageNamed: [@"common_" stringByAppendingString: name]];
+  return image;
+}
+
 - (id) init
 {
   return [self initWithSize: NSMakeSize(0, 0)];
 
--- core/gui/Source/NSWorkspace.m       2004-10-30 03:21:24.000000000 -0700
+++ core/gui/Source/NSWorkspace.m       2004-10-30 03:25:48.000000000 -0700
@@ -175,14 +175,11 @@
 
 @end
 
-
 
 @interface NSWorkspace (Private)
 
 // Icon handling
 - (NSImage*) _extIconForApp: (NSString*)appName info: (NSDictionary*)extInfo;
-- (NSImage*) _getImageWithName: (NSString*)name
-                    alternate: (NSString*)alternate;
 - (NSImage*) unknownFiletypeImage;
 - (NSImage*) _saveImageFor: (NSString*)iconPath;
 - (NSString*) thumbnailForFile: (NSString *)file;
@@ -853,9 +850,8 @@
                {
                  if (rootImage == nil)
                    {
-                     rootImage = RETAIN([self _getImageWithName:
-                       @"Root_PC.tiff"
-                       alternate: @"common_Root_PC.tiff"]);
+                     rootImage = RETAIN([NSImage _standardImageWithName:
+                       @"Root_PC.tiff"]);
                    }
 
                  image = rootImage;
@@ -864,9 +860,8 @@
                {
                  if (homeImage == nil)
                    {
-                     homeImage = RETAIN([self _getImageWithName:
-                       @"HomeDirectory.tiff"
-                       alternate: @"common_HomeDirectory.tiff"]);
+                     homeImage = RETAIN([NSImage _standardImageWithName:
+                       @"HomeDirectory.tiff"]);
                    }
                  image = homeImage;
                }
@@ -874,8 +869,8 @@
                {
                  if (folderImage == nil)
                    {
-                     folderImage = RETAIN([self _getImageWithName:
-                       @"Folder.tiff" alternate: @"common_Folder.tiff"]);
+                     folderImage = RETAIN([NSImage _standardImageWithName:
+                       @"Folder.tiff"]);
                    }
                  image = folderImage;
                }
@@ -916,9 +911,8 @@
                {
                  if (unknownTool == nil)
                    {
-                     unknownTool = RETAIN([self _getImageWithName:
-                       @"UnknownTool.tiff" alternate:
-                       @"common_UnknownTool.tiff"]);
+                     unknownTool = RETAIN([NSImage _standardImageWithName:
+                       @"UnknownTool.tiff"]);
                    }
                  image = unknownTool;
                }
@@ -1679,17 +1673,6 @@
   return nil;
 }
 
-- (NSImage*) _getImageWithName: (NSString*)name
-                    alternate: (NSString*)alternate
-{
-  NSImage      *image = nil;
-
-  image = [NSImage imageNamed: name];
-  if (image == nil)
-    image = [NSImage imageNamed: alternate];
-  return image;
-}
-
 /** Returns the default icon to display for a directory */
 - (NSImage*) unknownFiletypeImage
 {
@@ -1697,8 +1680,7 @@
 
   if (image == nil)
     {
-      image = RETAIN([self _getImageWithName: @"Unknown.tiff"
-                                  alternate: @"common_Unknown.tiff"]);
+      image = RETAIN([NSImage _standardImageWithName: @"Unknown.tiff"]);
     }
 
   return image;
@@ -1830,9 +1812,8 @@
            {
              if (unknownApplication == nil)
                {
-                 unknownApplication = RETAIN([self _getImageWithName:
-                   @"UnknownApplication.tiff" alternate:
-                   @"common_UnknownApplication.tiff"]);
+                 unknownApplication = RETAIN([NSImage _standardImageWithName:
+                   @"UnknownApplication.tiff"]);
                }
              icon = unknownApplication;
            }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]