Skip to content

Commit 474a95a

Browse files
committed
smc panel initial commit
1 parent 28922fa commit 474a95a

25 files changed

+583
-191
lines changed

CPUPreferences.xib

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,13 @@
173173
<font key="font" size="12" name="Helvetica"/>
174174
</sliderCell>
175175
<connections>
176-
<binding destination="8Tl-Bt-w0i" name="maxValue" keyPath="values.kCPUGraphWidthMax" id="eZI-1X-Eya"/>
177-
<binding destination="8Tl-Bt-w0i" name="minValue" keyPath="values.kCPUGraphWidthMin" previousBinding="eZI-1X-Eya" id="bg3-qu-h18"/>
178176
<binding destination="8Tl-Bt-w0i" name="value" keyPath="values.kCPUGraphWidth" previousBinding="bg3-qu-h18" id="8pi-o6-qNx">
179177
<dictionary key="options">
180178
<bool key="NSConditionallySetsEnabled" value="NO"/>
181179
</dictionary>
182180
</binding>
181+
<binding destination="8Tl-Bt-w0i" name="maxValue" keyPath="values.kCPUGraphWidthMax" id="eZI-1X-Eya"/>
182+
<binding destination="8Tl-Bt-w0i" name="minValue" keyPath="values.kCPUGraphWidthMin" previousBinding="eZI-1X-Eya" id="bg3-qu-h18"/>
183183
</connections>
184184
</slider>
185185
<slider verticalHuggingPriority="750" id="BDf-rO-e7F">
@@ -189,9 +189,9 @@
189189
<font key="font" size="12" name="Helvetica"/>
190190
</sliderCell>
191191
<connections>
192+
<binding destination="8Tl-Bt-w0i" name="value" keyPath="values.kCPUHorizontalRows" previousBinding="eTR-p1-u6a" id="WAq-hv-zK4"/>
192193
<binding destination="8Tl-Bt-w0i" name="maxValue" keyPath="values.kCPUHorizontalRowsMax" id="3dW-z4-wyh"/>
193194
<binding destination="8Tl-Bt-w0i" name="minValue" keyPath="values.kCPUHorizontalRowsMin" previousBinding="3dW-z4-wyh" id="eTR-p1-u6a"/>
194-
<binding destination="8Tl-Bt-w0i" name="value" keyPath="values.kCPUHorizontalRows" previousBinding="eTR-p1-u6a" id="WAq-hv-zK4"/>
195195
</connections>
196196
</slider>
197197
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="9g7-tz-zyN">
@@ -210,13 +210,13 @@
210210
<font key="font" size="12" name="Helvetica"/>
211211
</sliderCell>
212212
<connections>
213+
<binding destination="8Tl-Bt-w0i" name="value" keyPath="values.kCPUHorizontalWidth" previousBinding="ldx-79-Gem" id="LK2-xL-3Ax"/>
213214
<binding destination="8Tl-Bt-w0i" name="maxValue" keyPath="values.kCPUHorizontalWidthMax" id="vMa-0g-Mev"/>
214215
<binding destination="8Tl-Bt-w0i" name="minValue" keyPath="values.kCPUHorizontalWidthMin" previousBinding="vMa-0g-Mev" id="ldx-79-Gem"/>
215-
<binding destination="8Tl-Bt-w0i" name="value" keyPath="values.kCPUHorizontalWidth" previousBinding="ldx-79-Gem" id="LK2-xL-3Ax"/>
216216
</connections>
217217
</slider>
218218
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="a4X-Xl-ji0">
219-
<rect key="frame" x="233" y="57" width="100" height="14"/>
219+
<rect key="frame" x="303" y="57" width="100" height="14"/>
220220
<autoresizingMask key="autoresizingMask"/>
221221
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="center" title="System" id="qHH-be-0Pd">
222222
<font key="font" metaFont="smallSystem"/>
@@ -225,7 +225,7 @@
225225
</textFieldCell>
226226
</textField>
227227
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="8Sw-yy-aVG">
228-
<rect key="frame" x="93" y="57" width="100" height="14"/>
228+
<rect key="frame" x="163" y="57" width="100" height="14"/>
229229
<autoresizingMask key="autoresizingMask"/>
230230
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="center" title="User" id="Hfw-1H-fqM">
231231
<font key="font" metaFont="smallSystem"/>
@@ -234,7 +234,7 @@
234234
</textFieldCell>
235235
</textField>
236236
<colorWell id="ftQ-Bg-hWv">
237-
<rect key="frame" x="117" y="19" width="53" height="30"/>
237+
<rect key="frame" x="187" y="19" width="53" height="30"/>
238238
<autoresizingMask key="autoresizingMask"/>
239239
<color key="color" red="0.058130499000000002" green="0.055541898999999999" blue="1" alpha="1" colorSpace="calibratedRGB"/>
240240
<connections>
@@ -246,7 +246,7 @@
246246
</connections>
247247
</colorWell>
248248
<colorWell id="8zb-43-RDF">
249-
<rect key="frame" x="257" y="19" width="53" height="30"/>
249+
<rect key="frame" x="327" y="19" width="53" height="30"/>
250250
<autoresizingMask key="autoresizingMask"/>
251251
<color key="color" red="0.058130499000000002" green="0.055541898999999999" blue="1" alpha="1" colorSpace="calibratedRGB"/>
252252
<connections>
@@ -280,14 +280,14 @@
280280
<font key="font" size="12" name="Helvetica"/>
281281
</sliderCell>
282282
<connections>
283-
<binding destination="8Tl-Bt-w0i" name="maxValue" keyPath="values.kCPUUpdateIntervalMax" id="zOe-QH-tRa"/>
284-
<binding destination="8Tl-Bt-w0i" name="minValue" keyPath="values.kCPUUpdateIntervalMin" previousBinding="zOe-QH-tRa" id="H7G-RJ-yhY"/>
285283
<binding destination="8Tl-Bt-w0i" name="value" keyPath="values.kCPUUpdateInterval" previousBinding="H7G-RJ-yhY" id="WfT-1F-m4O">
286284
<dictionary key="options">
287285
<bool key="NSAllowsEditingMultipleValuesSelection" value="NO"/>
288286
<bool key="NSConditionallySetsEnabled" value="NO"/>
289287
</dictionary>
290288
</binding>
289+
<binding destination="8Tl-Bt-w0i" name="maxValue" keyPath="values.kCPUUpdateIntervalMax" id="zOe-QH-tRa"/>
290+
<binding destination="8Tl-Bt-w0i" name="minValue" keyPath="values.kCPUUpdateIntervalMin" previousBinding="zOe-QH-tRa" id="H7G-RJ-yhY"/>
291291
</connections>
292292
</slider>
293293
<popUpButton verticalHuggingPriority="750" id="Uxb-Ou-7ts">
@@ -365,32 +365,11 @@
365365
<font key="font" size="12" name="Helvetica"/>
366366
</sliderCell>
367367
<connections>
368+
<binding destination="8Tl-Bt-w0i" name="value" keyPath="values.kCPUProcessCount" previousBinding="ARU-tx-E43" id="D4I-he-yZf"/>
368369
<binding destination="8Tl-Bt-w0i" name="maxValue" keyPath="values.kCPUProcessCountMax" id="P7Q-Sm-Jzl"/>
369370
<binding destination="8Tl-Bt-w0i" name="minValue" keyPath="values.kCPUProcessCountMin" previousBinding="P7Q-Sm-Jzl" id="ARU-tx-E43"/>
370-
<binding destination="8Tl-Bt-w0i" name="value" keyPath="values.kCPUProcessCount" previousBinding="ARU-tx-E43" id="D4I-he-yZf"/>
371371
</connections>
372372
</slider>
373-
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="wfz-n8-gWH">
374-
<rect key="frame" x="367" y="57" width="100" height="14"/>
375-
<autoresizingMask key="autoresizingMask"/>
376-
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="center" title="Temperature" id="0tZ-yw-wYO">
377-
<font key="font" metaFont="smallSystem"/>
378-
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
379-
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
380-
</textFieldCell>
381-
</textField>
382-
<colorWell id="B61-z7-4dB">
383-
<rect key="frame" x="391" y="19" width="53" height="30"/>
384-
<autoresizingMask key="autoresizingMask"/>
385-
<color key="color" red="0.058130499000000002" green="0.055541898999999999" blue="1" alpha="1" colorSpace="calibratedRGB"/>
386-
<connections>
387-
<binding destination="8Tl-Bt-w0i" name="value" keyPath="values.kCPUTemperatureColor" id="h05-Rq-7ki">
388-
<dictionary key="options">
389-
<string key="NSValueTransformerName">NSUnarchiveFromData</string>
390-
</dictionary>
391-
</binding>
392-
</connections>
393-
</colorWell>
394373
<button verticalHuggingPriority="750" id="eju-3i-Qti">
395374
<rect key="frame" x="99" y="116" width="178" height="18"/>
396375
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>

MenuExtras/MenuMeterCPU/MenuMeterCPUConstants.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#define kCPUPercentDisplayBorderWidth 2
3333
#define kCPUThermometerDisplayWidth 10
3434
#define kCPUDisplayMultiProcGapWidth 5
35-
#define kCPUTemperatureDisplayWidth 26
3635

3736
// Menu item indexes
3837
#define kCPUUptimeInfoMenuIndex 3
@@ -69,10 +68,4 @@ enum {
6968
#define kCPUSystemColorDefault [NSColor colorWithDeviceRed:1.0f green:0.0f blue:0.0f alpha:1.0f]
7069
// Midnight blue
7170
#define kCPUUserColorDefault [NSColor colorWithDeviceRed:0.0f green:0.0f blue:0.5f alpha:1.0f]
72-
// Orange
73-
#define kCPUTemperatureColorDefault [NSColor colorWithDeviceRed:1.0f green:0.647f blue:0.0f alpha:1.0f]
74-
75-
76-
77-
7871

MenuExtras/MenuMeterCPU/MenuMeterCPUExtra.m

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
///////////////////////////////////////////////////////////////
3131

3232
@interface MenuMeterCPUExtra (PrivateMethods)
33-
-(NSDictionary*)defaults;
3433

3534
// Image renderers
3635
- (void)renderHistoryGraphIntoImage:(NSImage *)image forProcessor:(uint32_t)processor atOffset:(float)offset;
@@ -120,7 +119,6 @@ -(NSDictionary*)defaults {
120119

121120
@"kCPUSystemColor": [NSArchiver archivedDataWithRootObject:kCPUSystemColorDefault],
122121
@"kCPUUserColor": [NSArchiver archivedDataWithRootObject:kCPUUserColorDefault],
123-
@"kCPUTemperatureColor": [NSArchiver archivedDataWithRootObject:kCPUTemperatureColorDefault],
124122

125123
@"kCPUHorizontalWidthMin": @60,
126124
@"kCPUHorizontalWidthMax": @400,
@@ -129,7 +127,6 @@ -(NSDictionary*)defaults {
129127
@"kCPUAvgAllProcs": @NO,
130128
@"kCPUAvgLowerHalfProcs": @NO,
131129
@"kCPUSortByUsage": @NO,
132-
@"kCPUShowTemperature": @YES,
133130
};
134131
}
135132
return defaults;
@@ -285,11 +282,6 @@ - (NSImage *)image {
285282
// Horizontal CPU thermometer is handled differently because it has to
286283
// manage rows and columns in a very different way from normal horizontal
287284
// layout
288-
BOOL cpuShowTemperature = [[NSUserDefaults standardUserDefaults] boolForKey:@"kCPUShowTemperature"];
289-
if (cpuShowTemperature) {
290-
[self renderSingleTemperatureIntoImage:currentImage atOffset:renderOffset];
291-
renderOffset += kCPUTemperatureDisplayWidth;
292-
}
293285
long mode = [[NSUserDefaults standardUserDefaults] integerForKey:@"kCPUDisplayMode"]+1;
294286
if (mode & kCPUDisplayHorizontalThermometer) {
295287
// Calculate the minimum number of columns that will be needed
@@ -298,9 +290,6 @@ - (NSImage *)image {
298290
long columnCount = (cpuCount+rowCount-1)/rowCount;
299291
// Calculate a column width
300292
float columnWidth = (menuWidth - 1.0f) / columnCount;
301-
if (cpuShowTemperature) {
302-
columnWidth -= kCPUTemperatureDisplayWidth;
303-
}
304293
// Image height
305294
float imageHeight = (float) ([currentImage size].height);
306295
// Calculate a thermometer height
@@ -581,21 +570,6 @@ - (void)renderSplitPercentIntoImage:(NSImage *)image forProcessor:(uint32_t)proc
581570

582571
} // renderSplitPercentIntoImage:forProcessor:atOffset:
583572

584-
- (void)renderSingleTemperatureIntoImage:(NSImage *)image atOffset:(float)offset {
585-
float_t celsius = [cpuInfo cpuProximityTemperature];
586-
[image lockFocus];
587-
NSAttributedString *renderTemperatureString = [[NSAttributedString alloc]
588-
initWithString:[NSString stringWithFormat:@"%.1f°", celsius]
589-
attributes:[NSDictionary dictionaryWithObjectsAndKeys:[NSFont systemFontOfSize:9.5f],
590-
NSFontAttributeName, temperatureColor, NSForegroundColorAttributeName,
591-
nil]];
592-
[renderTemperatureString drawAtPoint:NSMakePoint(
593-
kCPUTemperatureDisplayWidth - (float)round([renderTemperatureString size].width) - 1,
594-
(float)floor(([image size].height-[renderTemperatureString size].height) / 2)
595-
)];
596-
[image unlockFocus];
597-
} // renderSingleTemperatureIntoImage:atOffset:
598-
599573

600574
- (void)renderThermometerIntoImage:(NSImage *)image forProcessor:(uint32_t)processor atOffset:(float)offset {
601575

@@ -743,16 +717,12 @@ - (void)configFromPrefs:(NSNotification *)notification {
743717
// Cache colors to skip archiver
744718
userColor = kCPUUserColorDefault;
745719
systemColor = kCPUSystemColorDefault;
746-
temperatureColor = kCPUTemperatureColorDefault;
747720
if ([[NSUserDefaults standardUserDefaults] dataForKey:@"kCPUUserColor"]) {
748721
userColor = [NSUnarchiver unarchiveObjectWithData:[[NSUserDefaults standardUserDefaults] dataForKey:@"kCPUUserColor"]];
749722
}
750723
if ([[NSUserDefaults standardUserDefaults] dataForKey:@"kCPUSystemColor"]) {
751724
systemColor = [NSUnarchiver unarchiveObjectWithData:[[NSUserDefaults standardUserDefaults] dataForKey:@"kCPUSystemColor"]];
752725
}
753-
if ([[NSUserDefaults standardUserDefaults] dataForKey:@"kCPUTemperatureColor"]) {
754-
temperatureColor = [NSUnarchiver unarchiveObjectWithData:[[NSUserDefaults standardUserDefaults] dataForKey:@"kCPUTemperatureColor"]];
755-
}
756726

757727
// It turns out that text drawing is _much_ slower than compositing images together
758728
// so we render several arrays of images, each representing a different percent value
@@ -857,9 +827,6 @@ - (void)configFromPrefs:(NSNotification *)notification {
857827
menuWidth += ((numberOfCPUs - 1) * kCPUDisplayMultiProcGapWidth);
858828
}
859829
}
860-
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"kCPUShowTemperature"]) {
861-
menuWidth += kCPUTemperatureDisplayWidth;
862-
}
863830

864831
// Resize the view
865832
[extraView setFrameSize:NSMakeSize(menuWidth, [extraView frame].size.height)];

MenuExtras/MenuMeterCPU/MenuMeterCPUStats.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
//
2323

2424
#import <sys/sysctl.h>
25-
#import "../../smc_reader/smc_reader.h"
2625

2726
@interface MenuMeterCPULoad : NSObject
2827
@property(nonatomic) double system;
@@ -58,6 +57,5 @@
5857
- (NSString *)currentProcessorTasks;
5958
- (NSString *)loadAverage;
6059
- (NSArray *)currentLoadBySorting:(BOOL)sorted andCombineLowerHalf:(BOOL)combine;
61-
- (float_t)cpuProximityTemperature;
6260

6361
@end

MenuExtras/MenuMeterCPU/MenuMeterCPUStats.m

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -337,20 +337,6 @@ - (NSArray *)currentLoadBySorting: (BOOL)sorted andCombineLowerHalf:(BOOL)combin
337337

338338
} // currentLoad
339339

340-
- (float_t)cpuProximityTemperature {
341-
float_t celsius = -273.15F;
342-
if (kIOReturnSuccess == SMCOpen()) {
343-
SMCKeyValue value;
344-
//use harcoded value for a while
345-
//TODO: implement SMC tab to allow setup smc gauges in toolbar
346-
if (kIOReturnSuccess == SMCReadKey(toSMCCode("TC0P"), &value)) {
347-
celsius = SP78_TO_CELSIUS(value.bytes);
348-
}
349-
SMCClose();
350-
}
351-
return celsius;
352-
} // cpuProximityTemperature
353-
354340
///////////////////////////////////////////////////////////////
355341
//
356342
// Utility

MenuExtras/MenuMeterDisk/MenuMeterDiskExtra.m

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,6 @@ -(NSDictionary*)defaults {
109109
return defaults;
110110
}
111111

112-
- (void)observeValueForKeyPath:(NSString *)keyPath
113-
ofObject:(id)object
114-
change:(NSDictionary *)change
115-
context:(void *)context {
116-
[self configFromPrefs:nil];
117-
}
118-
119112
- initWithBundle:(NSBundle *)bundle {
120113

121114
self = [super initWithBundle:bundle];

MenuExtras/MenuMeterMem/MenuMeterMemExtra.m

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,6 @@ - (BOOL)enabled {
284284

285285
} // initWithBundle
286286

287-
- (void)observeValueForKeyPath:(NSString *)keyPath
288-
ofObject:(id)object
289-
change:(NSDictionary *)change
290-
context:(void *)context {
291-
[self configFromPrefs:nil];
292-
}
293-
294-
295287
// dealloc
296288

297289
///////////////////////////////////////////////////////////////

MenuExtras/MenuMeterNet/MenuMeterNetExtra.m

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,6 @@ -(id)getConfigPane {
165165
break;
166166
}
167167
}
168-
// Configure the scale menu to contain images and enough space
169-
[[netScaleCalc itemAtIndex:kNetScaleCalcLinear] setImage:[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"LinearScale" ofType:@"tiff"]]];
170-
[[netScaleCalc itemAtIndex:kNetScaleCalcLinear] setTitle:[NSString stringWithFormat:@" %@", [[netScaleCalc itemAtIndex:kNetScaleCalcLinear] title]]];
171-
[[netScaleCalc itemAtIndex:kNetScaleCalcSquareRoot] setImage:[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"SquareRootScale" ofType:@"tiff"]]];
172-
[[netScaleCalc itemAtIndex:kNetScaleCalcSquareRoot] setTitle:[NSString stringWithFormat:@" %@", [[netScaleCalc itemAtIndex:kNetScaleCalcSquareRoot] title]]];
173-
[[netScaleCalc itemAtIndex:kNetScaleCalcCubeRoot] setImage:[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"CubeRootScale" ofType:@"tiff"]]];
174-
[[netScaleCalc itemAtIndex:kNetScaleCalcCubeRoot] setTitle:[NSString stringWithFormat:@" %@", [[netScaleCalc itemAtIndex:kNetScaleCalcCubeRoot] title]]];
175-
[[netScaleCalc itemAtIndex:kNetScaleCalcLog] setImage:[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"LogScale" ofType:@"tiff"]]];
176-
[[netScaleCalc itemAtIndex:kNetScaleCalcLog] setTitle:[NSString stringWithFormat:@" %@", [[netScaleCalc itemAtIndex:kNetScaleCalcLog] title]]];
177168

178169
NSTabViewItem*prefView = [[NSTabViewItem alloc] init];
179170
[prefView setLabel:@"Net"];
@@ -188,13 +179,6 @@ - (BOOL)enabled {
188179
return [[NSUserDefaults standardUserDefaults] boolForKey:@"kNetMenuBundleID"];
189180
}
190181

191-
- (void)observeValueForKeyPath:(NSString *)keyPath
192-
ofObject:(id)object
193-
change:(NSDictionary *)change
194-
context:(void *)context {
195-
[self configFromPrefs:nil];
196-
}
197-
198182
- initWithBundle:(NSBundle *)bundle {
199183

200184
self = [super initWithBundle:bundle];
-521 Bytes
Binary file not shown.
-487 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)