@@ -143,20 +143,18 @@ - (NSImage *)buttonImage
143
143
//
144
144
- (void )fillRateButton
145
145
{
146
- NSString *resBtnTitle = [resolutionBtn titleOfSelectedItem ];
147
- NSArray *m = [selectedDisplay allResolutions ];
146
+ NSString *resBtnTitle;
148
147
NSString *rateTitle;
149
148
NSString *resolutionTitle;
150
149
NSDictionary *res;
151
150
float rateValue = 0.0 ;
152
151
NSString *rateFormat = @" %.2f Hz" ;
153
152
154
- // [m writeToFile:[NSString stringWithFormat:@"%@.displayResolutions", [selectedDisplay outputName]]
155
- // atomically:NO];
156
153
[rateBtn removeAllItems ];
157
154
158
155
// Fill the buttion with items
159
- for (res in m) {
156
+ resBtnTitle = [resolutionBtn titleOfSelectedItem ];
157
+ for (res in [selectedDisplay allResolutions ]) {
160
158
resolutionTitle = [res objectForKey: OSEDisplayResolutionNameKey];
161
159
if ([resolutionTitle isEqualToString: resBtnTitle]) {
162
160
rateValue = [[res objectForKey: OSEDisplayResolutionRateKey] floatValue ];
@@ -165,24 +163,37 @@ - (void)fillRateButton
165
163
[[rateBtn itemWithTitle: rateTitle] setRepresentedObject: res];
166
164
}
167
165
}
166
+ }
167
+
168
+ - (void )updateRateButton
169
+ {
170
+ NSString *rateFormat = @" %.2f Hz" ;
171
+ NSString *rateTitle;
168
172
169
173
if ([[rateBtn itemArray ] count ] == 1 ) {
170
174
[rateBtn setEnabled: NO ];
171
175
} else {
172
176
// Select actual value of selected resolution
173
- res = [selectedDisplay activeResolution ] ;
174
- rateValue = [[res objectForKey: OSEDisplayResolutionRateKey] floatValue ];
175
- rateTitle = [ NSString stringWithFormat: rateFormat, rateValue] ;
177
+ NSLog ( @" %s - resoltion rate %f " , __func__, selectedDisplay. activeRate ) ;
178
+ rateTitle = [NSString stringWithFormat: rateFormat, selectedDisplay.activeRate ];
179
+ NSLog ( @" %s - rate title %@ " , __func__, rateTitle) ;
176
180
[rateBtn selectItemWithTitle: rateTitle];
177
181
[rateBtn setEnabled: YES ];
178
- }
182
+ }
179
183
}
180
184
181
185
- (void )setResolution
182
186
{
187
+ NSDictionary *resolution = [[rateBtn selectedCell ] representedObject ];
188
+ if (resolution == nil ) {
189
+ NSLog (@" %s - resolution dictionary is nil! Resolution button is %@ " , __func__,
190
+ [resolutionBtn title ]);
191
+ return ;
192
+ }
183
193
// Set resolution only to active display.
184
194
// Display activating implemented in 'Screen' Preferences' module.
185
195
if ([selectedDisplay isActive ]) {
196
+ NSLog (@" %s - %@ " , __func__, [[rateBtn selectedCell ] representedObject ]);
186
197
[systemScreen setDisplay: selectedDisplay resolution: [[rateBtn selectedCell ] representedObject ]];
187
198
}
188
199
}
@@ -257,12 +268,11 @@ - (IBAction)monitorsListClicked:(id)sender
257
268
258
269
- (IBAction )resolutionClicked : (id )sender
259
270
{
260
- [self fillRateButton ];
261
- // NSLog(@"resolutionClicked: Selected resolution: %@", [[rateBtn selectedCell] representedObject]);
262
-
263
271
[[NSNotificationCenter defaultCenter ] removeObserver: self ];
264
272
273
+ [self fillRateButton ];
265
274
[self setResolution ];
275
+ [self updateRateButton ];
266
276
267
277
[[NSNotificationCenter defaultCenter ] addObserver: self
268
278
selector: @selector (screenDidUpdate: )
@@ -273,8 +283,6 @@ - (IBAction)resolutionClicked:(id)sender
273
283
- (IBAction )rateClicked : (id )sender
274
284
{
275
285
[self setResolution ];
276
-
277
- NSLog (@" rateClicked: Selected resolution: %@ " , [[rateBtn selectedCell ] representedObject ]);
278
286
}
279
287
280
288
- (IBAction )sliderMoved : (id )sender
@@ -393,13 +401,9 @@ - (void)controlTextDidEndEditing:(NSNotification *)aNotification
393
401
// Notifications
394
402
- (void )screenDidUpdate : (NSNotification *)aNotif
395
403
{
396
- NSLog (@" Display : XRandR screen resources was updated, refreshing..." );
404
+ NSLog (@" %s : XRandR screen resources was updated, refreshing..." , __func__ );
397
405
[monitorsList reloadColumn: 0 ];
398
406
[self selectFirstEnabledMonitor ];
399
407
}
400
408
401
- //
402
- // Utility methods
403
- //
404
-
405
409
@end
0 commit comments