From c9e416c3c74910d79fd548180584491b257b833b Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Mon, 27 Jul 2009 17:00:45 +0000 Subject: [Author: thomasvl] Support for NSMatrix in uistate files (dumps the cells and row/column counts). Support for NSMatrix in GTMUILocalizer. Added checkboxes and radio groups to the GTMUILocalizer unittest. R=dmaclach DELTA=551 (541 added, 0 deleted, 10 changed) --- AppKit/GTMUILocalizer.m | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'AppKit/GTMUILocalizer.m') diff --git a/AppKit/GTMUILocalizer.m b/AppKit/GTMUILocalizer.m index 1782159..8f7d467 100644 --- a/AppKit/GTMUILocalizer.m +++ b/AppKit/GTMUILocalizer.m @@ -97,6 +97,8 @@ // Do the main menu NSMenu *menu = [object mainMenu]; [self localizeMenu:menu recursively:recursive]; + } else if ([object isKindOfClass:[NSCell class]]) { + [self localizeCell:(NSCell *)object recursively:recursive]; } } } @@ -215,6 +217,24 @@ [[(NSSearchField *)view cell] setPlaceholderString:localizedPlaceholer]; } } + + // Do any NSMatrix placeholders + if ([view isKindOfClass:[NSMatrix class]]) { + NSMatrix *matrix = (NSMatrix *)view; + // Process the prototype + id cell = [matrix prototype]; + [self localizeCell:cell recursively:recursive]; + // Process the cells + GTM_FOREACH_OBJECT(cell, [matrix cells]) { + [self localizeCell:cell recursively:recursive]; + // The tooltip isn't on a cell, so we do it via the matrix. + NSString *toolTip = [matrix toolTipForCell:cell]; + NSString *localizedToolTip = [self localizedStringForString:toolTip]; + if (localizedToolTip) { + [matrix setToolTip:localizedToolTip forCell:cell]; + } + } + } } - (void)localizeMenu:(NSMenu *)menu recursively:(BOOL)recursive { @@ -238,4 +258,18 @@ } } } + +- (void)localizeCell:(NSCell *)cell recursively:(BOOL)recursive { + if (cell) { + NSString *title = [cell title]; + NSString *localizedTitle = [self localizedStringForString:title]; + if (localizedTitle) { + [cell setTitle:localizedTitle]; + } + [self localizeMenu:[cell menu] recursively:recursive]; + id obj = [cell representedObject]; + [self localizeObject:obj recursively:recursive]; + } +} + @end -- cgit v1.2.3