From 9c181cc9c980ba3c425cbc8a7eb7145efcce1b7b Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Thu, 5 May 2011 08:06:31 -0400 Subject: [PATCH] Allow class to be used with +themeForView, fix to image load notification --- AppKit/CPTheme.j | 19 +++++++++++++------ AppKit/_CPImageAndTextView.j | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/AppKit/CPTheme.j b/AppKit/CPTheme.j index 1383fa831..9766863a3 100644 --- a/AppKit/CPTheme.j +++ b/AppKit/CPTheme.j @@ -86,7 +86,8 @@ var CPThemesByName = { }, } /*! - Returns the closest matching theme for a given view. The matching proceeds as follows: + Returns the closest matching theme for a given view or view class. + The matching proceeds as follows: - The default theme class name for the class is retrieved. - Starting with the last loaded theme and proceeding towards the default theme, @@ -94,16 +95,22 @@ var CPThemesByName = { }, - If the theme defines the class name, that theme is returned. - If no themes match, the default theme is returned. - @param aView The view to match with a theme - @return The first matching theme + @param aViewOrClass The view or view class to match with a theme + @return The first matching theme */ -+ (CPTheme)themeForView:(CPView)aView ++ (CPTheme)themeForView:(id)aViewOrClass { - var count = CPThemeNamesByInheritance.length, - themeClass = [aView themeClass]; + var themeClass = nil; + + if (class_isMetaClass(aViewOrClass.isa)) + themeClass = [aViewOrClass defaultThemeClass]; + else + themeClass = [aViewOrClass themeClass]; if (themeClass) { + var count = CPThemeNamesByInheritance.length; + while (count--) { var theme = CPThemesByName[CPThemeNamesByInheritance[count]]; diff --git a/AppKit/_CPImageAndTextView.j b/AppKit/_CPImageAndTextView.j index 5e3e78b80..275b0e051 100644 --- a/AppKit/_CPImageAndTextView.j +++ b/AppKit/_CPImageAndTextView.j @@ -294,7 +294,7 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0, return; if ([_image delegate] === self) - [[CPNotificationCenter defaultCenter] removeObserver:_image name:CPImageDidLoadNotification object:_image]; + [[CPNotificationCenter defaultCenter] removeObserver:self name:CPImageDidLoadNotification object:_image]; _image = anImage; _flags |= _CPImageAndTextViewImageChangedFlag;