Author: rmottola
Date: Fri Jan 15 16:49:18 2016
New Revision: 39279
URL: http://svn.gna.org/viewcvs/gnustep?rev=39279&view=rev
Log:
Listen to GSThemeDidActivateNotification to detect a theme change and refetch
all cached icons
Modified:
apps/gworkspace/trunk/ChangeLog
apps/gworkspace/trunk/FSNode/FSNodeRep.m
Modified: apps/gworkspace/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/apps/gworkspace/trunk/ChangeLog?rev=39279&r1=39278&r2=39279&view=diff
==============================================================================
--- apps/gworkspace/trunk/ChangeLog (original)
+++ apps/gworkspace/trunk/ChangeLog Fri Jan 15 16:49:18 2016
@@ -1,3 +1,8 @@
+2016-01-16 Riccardo Mottola <[email protected]>
+
+ * FSNode/FSNodeRep.m
+ Listen to GSThemeDidActivateNotification to detect a theme change and
refetch all cached icons.
+
2016-01-14 Riccardo Mottola <[email protected]>
* GWorkspace/Preferences/DesktopPref.h
Modified: apps/gworkspace/trunk/FSNode/FSNodeRep.m
URL:
http://svn.gna.org/viewcvs/gnustep/apps/gworkspace/trunk/FSNode/FSNodeRep.m?rev=39279&r1=39278&r2=39279&view=diff
==============================================================================
--- apps/gworkspace/trunk/FSNode/FSNodeRep.m (original)
+++ apps/gworkspace/trunk/FSNode/FSNodeRep.m Fri Jan 15 16:49:18 2016
@@ -27,6 +27,8 @@
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
+#import <GNUstepGUI/GSTheme.h>
+
#import "FSNodeRep.h"
#import "FSNFunctions.h"
#import "ExtendedInfo.h"
@@ -89,6 +91,20 @@
}
}
+/*
+ * Loads and caches named images
+ * Images coming from GSTheme need to be recached on a theme change
+ */
+- (void)cacheIcons
+{
+ [multipleSelIcon release];
+ multipleSelIcon = [[NSImage imageNamed:NSImageNameMultipleDocuments] retain];
+ [trashIcon release];
+ trashIcon = [[NSImage imageNamed:NSImageNameTrashEmpty] retain];
+ [trashFullIcon retain];
+ trashFullIcon = [[NSImage imageNamed:NSImageNameTrashFull] retain];
+}
+
- (id)initSharedInstance
{
self = [super init];
@@ -108,15 +124,16 @@
oldresize = [[NSUserDefaults standardUserDefaults] boolForKey:
@"old_resize"];
- multipleSelIcon = [[NSImage imageNamed:NSImageNameMultipleDocuments]
retain];
+ /* images coming form GSTheme */
+ [self cacheIcons];
+
+ /* images for which we provide our own resources */
imagepath = [bundle pathForImageResource: @"FolderOpen"];
openFolderIcon = [[NSImage alloc] initWithContentsOfFile: imagepath];
imagepath = [bundle pathForImageResource: @"HardDisk"];
hardDiskIcon = [[NSImage alloc] initWithContentsOfFile: imagepath];
imagepath = [bundle pathForImageResource: @"HardDiskOpen"];
openHardDiskIcon = [[NSImage alloc] initWithContentsOfFile: imagepath];
- trashIcon = [[NSImage imageNamed:NSImageNameTrashEmpty] retain];
- trashFullIcon = [[NSImage imageNamed:NSImageNameTrashFull] retain];
iconsCache = [NSMutableDictionary new];
rootPath = path_separator();
@@ -153,6 +170,9 @@
[self loadExtendedInfoModules];
systype = [[NSProcessInfo processInfo] operatingSystem];
+
+ /* we observe a theme change to re-cache icons */
+ [nc addObserver:self selector:@selector(themeDidActivate:)
name:GSThemeDidActivateNotification object:nil];
}
return self;
@@ -234,6 +254,13 @@
}
return bundleList;
+}
+
+- (void)themeDidActivate:(id)sender
+{
+ /* we clean the cache of theme-derived images */
+ [iconsCache removeAllObjects];
+ [self cacheIcons];
}
@end
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs