mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 15:12:21 +00:00
Merge pull request #182 from dennisbolio/master
Implementation of fix for issue #118
This commit is contained in:
@@ -73,9 +73,15 @@ typedef NS_ENUM(NSUInteger, MPIconType) {
|
||||
+ (NSDictionary *)availableIconNames;
|
||||
|
||||
/**
|
||||
* List of all availabel DatabaseIcons as Images. Sorted by IconIndex
|
||||
* List of all available DatabaseIcons as an array of Images. Sorted by IconIndex.
|
||||
* @return Array of Icons as NSImage objects
|
||||
*/
|
||||
+ (NSArray *)databaseIcons;
|
||||
|
||||
/**
|
||||
* List of all available DatabaseIcons as an array of MPIconType. Sorted by IconIndex.
|
||||
* @return Array of MPIconType as NSNumber objects
|
||||
*/
|
||||
+ (NSArray *)databaseIconTypes;
|
||||
|
||||
@end
|
||||
|
||||
@@ -29,7 +29,12 @@
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSDictionary *imageNames = [MPIconHelper availableIconNames];
|
||||
NSMutableArray *mutableIcons = [[NSMutableArray alloc] initWithCapacity:[imageNames count]];
|
||||
for(NSNumber *iconNumber in [imageNames allKeys]) {
|
||||
|
||||
NSArray *sortedImageNames = [[imageNames allKeys] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
|
||||
return [[imageNames objectForKey:obj1] compare:[imageNames objectForKey:obj2]];
|
||||
}];
|
||||
|
||||
for(NSNumber *iconNumber in sortedImageNames) {
|
||||
if([iconNumber integerValue] > MPCustomIconTypeBegin) {
|
||||
continue; // Skip all non-db Keys
|
||||
}
|
||||
@@ -41,6 +46,30 @@
|
||||
return icons;
|
||||
}
|
||||
|
||||
|
||||
+ (NSArray *)databaseIconTypes {
|
||||
static NSArray *iconTypes;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSDictionary *imageNames = [MPIconHelper availableIconNames];
|
||||
NSMutableArray *mutableIcons = [[NSMutableArray alloc] initWithCapacity:[imageNames count]];
|
||||
|
||||
NSArray *sortedImageNames = [[imageNames allKeys] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
|
||||
return [[imageNames objectForKey:obj1] compare:[imageNames objectForKey:obj2]];
|
||||
}];
|
||||
|
||||
for(NSNumber *iconNumber in sortedImageNames) {
|
||||
if([iconNumber integerValue] > MPCustomIconTypeBegin) {
|
||||
continue; // Skip all non-db Keys
|
||||
}
|
||||
[mutableIcons addObject:iconNumber];
|
||||
}
|
||||
iconTypes = mutableIcons;
|
||||
});
|
||||
return iconTypes;
|
||||
}
|
||||
|
||||
|
||||
+ (NSDictionary *)availableIconNames {
|
||||
static NSDictionary *imageNames;
|
||||
static dispatch_once_t onceToken;
|
||||
|
||||
@@ -58,7 +58,7 @@ NSInteger const kMPDefaultIcon = -1;
|
||||
NSButton *button = sender;
|
||||
NSImage *image = [button image];
|
||||
NSUInteger buttonIndex = [[self.iconCollectionView content] indexOfObject:image];
|
||||
self.selectedIcon = [[[MPIconHelper availableIconNames] allKeys][buttonIndex] integerValue];
|
||||
self.selectedIcon = [[MPIconHelper databaseIconTypes] [buttonIndex] integerValue];
|
||||
[self.popover performClose:self];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user