aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2010-07-12 17:07:19 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2010-07-12 17:07:19 +0000
commite2bb8aa49243734ea094c0c81a072f7570507d95 (patch)
treee484921bc047c953593819787ff91f49af2daa20
parent4d5b01da0879f09e3777cf423bed5d3db5d2e149 (diff)
[Author: rsesek]
Add support for NSSegmentedControl to GTMUILocalizer. This fixes http://code.google.com/p/google-toolbox-for-mac/issues/detail?id=53. R=dmaclach APPROVED=dmaclach DELTA=142 (137 added, 1 deleted, 4 changed)
-rw-r--r--AppKit/GTMUILocalizer.m10
-rw-r--r--AppKit/GTMUILocalizerTestWindow.xib79
-rw-r--r--AppKit/TestData/GTMUILocalizerWindow3State.gtmUTState32
-rw-r--r--AppKit/TestData/Resources/English.lproj/Localizable.strings3
-rw-r--r--UnitTesting/GTMAppKit+UnitTesting.m20
5 files changed, 140 insertions, 4 deletions
diff --git a/AppKit/GTMUILocalizer.m b/AppKit/GTMUILocalizer.m
index 16d00dd..56b0b7d 100644
--- a/AppKit/GTMUILocalizer.m
+++ b/AppKit/GTMUILocalizer.m
@@ -276,6 +276,16 @@
[self localizeObject:[column headerCell] recursively:recursive];
}
}
+
+ // Do NSSegmentedControl segments.
+ if ([view isKindOfClass:[NSSegmentedControl class]]) {
+ NSSegmentedControl *segmentedControl = (NSSegmentedControl *)view;
+ for (NSInteger i = 0; i < [segmentedControl segmentCount]; ++i) {
+ NSString *label = [segmentedControl labelForSegment:i];
+ [segmentedControl setLabel:[self localizedStringForString:label]
+ forSegment:i];
+ }
+ }
}
- (void)localizeMenu:(NSMenu *)menu recursively:(BOOL)recursive {
diff --git a/AppKit/GTMUILocalizerTestWindow.xib b/AppKit/GTMUILocalizerTestWindow.xib
index 923c61b..6161945 100644
--- a/AppKit/GTMUILocalizerTestWindow.xib
+++ b/AppKit/GTMUILocalizerTestWindow.xib
@@ -12,9 +12,9 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <integer value="52"/>
<integer value="22"/>
<integer value="41"/>
- <integer value="58"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1168,6 +1168,42 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string key="NSFrame">{{42, 66}, {106, 45}}</string>
<reference key="NSSuperview" ref="405137086"/>
</object>
+ <object class="NSSegmentedControl" id="632547328">
+ <reference key="NSNextResponder" ref="405137086"/>
+ <int key="NSvFlags">268</int>
+ <string key="NSFrame">{{198, 38}, {185, 24}}</string>
+ <reference key="NSSuperview" ref="405137086"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSSegmentedCell" key="NSCell" id="907223470">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <object class="NSFont" key="NSSupport">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">13</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ <reference key="NSControlView" ref="632547328"/>
+ <object class="NSMutableArray" key="NSSegmentImages">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSSegmentItem">
+ <string key="NSSegmentItemLabel">^Seg1</string>
+ <int key="NSSegmentItemImageScaling">0</int>
+ </object>
+ <object class="NSSegmentItem">
+ <string key="NSSegmentItemLabel">^Seg2</string>
+ <int key="NSSegmentItemTag">1</int>
+ <bool key="NSSegmentItemSelected">YES</bool>
+ <int key="NSSegmentItemImageScaling">0</int>
+ </object>
+ <object class="NSSegmentItem">
+ <string key="NSSegmentItemLabel">^Seg3</string>
+ <int key="NSSegmentItemImageScaling">0</int>
+ </object>
+ </object>
+ <int key="NSSelectedSegment">1</int>
+ <int key="NSSegmentStyle">1</int>
+ </object>
+ </object>
</object>
<string key="NSFrameSize">{480, 270}</string>
<reference key="NSSuperview"/>
@@ -1594,6 +1630,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<reference ref="735149545"/>
<reference ref="846591189"/>
<reference ref="161950549"/>
+ <reference ref="632547328"/>
</object>
<reference key="parent" ref="158765462"/>
</object>
@@ -1822,6 +1859,20 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<reference key="object" ref="926559351"/>
<reference key="parent" ref="207474363"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">169</int>
+ <reference key="object" ref="632547328"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="907223470"/>
+ </object>
+ <reference key="parent" ref="405137086"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">170</int>
+ <reference key="object" ref="907223470"/>
+ <reference key="parent" ref="632547328"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -1847,6 +1898,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>151.IBPluginDependency</string>
<string>152.IBPluginDependency</string>
<string>16.IBPluginDependency</string>
+ <string>169.IBPluginDependency</string>
+ <string>170.IBPluginDependency</string>
<string>2.IBPluginDependency</string>
<string>22.IBEditorWindowLastContentRect</string>
<string>22.IBPluginDependency</string>
@@ -1909,9 +1962,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{126, 451}, {480, 270}}</string>
+ <string>{{329, 451}, {480, 270}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{126, 451}, {480, 270}}</string>
+ <string>{{329, 451}, {480, 270}}</string>
<boolean value="NO"/>
<string>{196, 240}</string>
<string>{{357, 418}, {480, 270}}</string>
@@ -1926,6 +1979,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{960, 479}, {480, 270}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{960, 479}, {480, 270}}</string>
@@ -1999,7 +2054,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">168</int>
+ <int key="maxID">170</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -2664,6 +2719,22 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
</object>
<object class="IBPartialClassDescription">
+ <string key="className">NSSegmentedCell</string>
+ <string key="superclassName">NSActionCell</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSSegmentedCell.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSSegmentedControl</string>
+ <string key="superclassName">NSControl</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSSegmentedControl.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
<string key="className">NSSplitView</string>
<string key="superclassName">NSView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
diff --git a/AppKit/TestData/GTMUILocalizerWindow3State.gtmUTState b/AppKit/TestData/GTMUILocalizerWindow3State.gtmUTState
index ed88b68..8352b5e 100644
--- a/AppKit/TestData/GTMUILocalizerWindow3State.gtmUTState
+++ b/AppKit/TestData/GTMUILocalizerWindow3State.gtmUTState
@@ -293,6 +293,38 @@
<false/>
</dict>
</dict>
+ <key>ViewSubView 3</key>
+ <dict>
+ <key>ControlIsEnabled</key>
+ <true/>
+ <key>ControlSelectedCell</key>
+ <dict>
+ <key>CellState</key>
+ <integer>0</integer>
+ <key>CellTag</key>
+ <integer>0</integer>
+ <key>CellTitle</key>
+ <string></string>
+ <key>CellValue</key>
+ <string>1</string>
+ </dict>
+ <key>ControlTag</key>
+ <integer>0</integer>
+ <key>ControlType</key>
+ <string>NSSegmentedControl</string>
+ <key>ControlValue</key>
+ <string>1</string>
+ <key>Segment 0</key>
+ <string>Localized Segment 1</string>
+ <key>Segment 1</key>
+ <string>Localized Segment 2</string>
+ <key>Segment 2</key>
+ <string>Localized Segment 3</string>
+ <key>SegmentCount</key>
+ <integer>3</integer>
+ <key>ViewIsHidden</key>
+ <false/>
+ </dict>
</dict>
<key>WindowIsMain</key>
<false/>
diff --git a/AppKit/TestData/Resources/English.lproj/Localizable.strings b/AppKit/TestData/Resources/English.lproj/Localizable.strings
index d70d574..e6452a8 100644
--- a/AppKit/TestData/Resources/English.lproj/Localizable.strings
+++ b/AppKit/TestData/Resources/English.lproj/Localizable.strings
@@ -37,6 +37,9 @@
"Radio 1" = "Localized Radio 1";
"Radio 2" = "Localized Radio 2";
"Box" = "Localized Box";
+"Seg1" = "Localized Segment 1";
+"Seg2" = "Localized Segment 2";
+"Seg3" = "Localized Segment 3";
// Binding localization strings.
"MultipleValuesPlaceholder" = "MultipleValuesPlaceholder";
diff --git a/UnitTesting/GTMAppKit+UnitTesting.m b/UnitTesting/GTMAppKit+UnitTesting.m
index ad883e4..1fc0dc1 100644
--- a/UnitTesting/GTMAppKit+UnitTesting.m
+++ b/UnitTesting/GTMAppKit+UnitTesting.m
@@ -425,6 +425,26 @@ GTM_METHOD_CHECK(NSObject, gtm_unitTestEncodeState:);
@end
+@implementation NSSegmentedControl (GTMUnitTestingAdditions)
+
+// Encodes the state of an NSSegmentedControl and all its segments.
+//
+// Arguments:
+// inCoder - the coder to encode state into
+- (void)gtm_unitTestEncodeState:(NSCoder*)inCoder {
+ [super gtm_unitTestEncodeState:inCoder];
+
+ NSInteger segmentCount = [self segmentCount];
+ ENCODE_NSINTEGER(inCoder, segmentCount, @"SegmentCount");
+
+ for (NSInteger i = 0; i < segmentCount; ++i) {
+ NSString *key = [NSString stringWithFormat:@"Segment %d", i];
+ [inCoder encodeObject:[self labelForSegment:i] forKey:key];
+ }
+}
+
+@end
+
@implementation NSView (GTMUnitTestingAdditions)
// Returns an image containing a representation of the object