ref: order code by appearance in UI

This commit is contained in:
relikd
2025-10-24 00:15:14 +02:00
parent 63509faef6
commit 46fa898807
3 changed files with 19 additions and 17 deletions

View File

@@ -3,8 +3,8 @@
NS_ASSUME_NONNULL_BEGIN
@interface SettingsGeneral : NSViewController
- (void)changeHttpApplication:(NSPopUpButton *)sender;
- (void)clickHowToDefaults:(NSButton *)sender;
- (void)changeHttpApplication:(NSPopUpButton *)sender;
@end
NS_ASSUME_NONNULL_END

View File

@@ -13,19 +13,21 @@
- (void)loadView {
self.view = [[SettingsGeneralView alloc] initWithController:self];
// Default http application for opening the feed urls
NSPopUpButton *pop = self.view.popupHttpApplication;
[pop removeAllItems];
[pop addItemWithTitle:NSLocalizedString(@"System Default", @"Default web browser application")];
NSArray<NSString*> *browsers = CFBridgingRelease(LSCopyAllHandlersForURLScheme(CFSTR("https")));
for (NSString *bundleID in browsers) {
[pop addItemWithTitle: [self applicationNameForBundleId:bundleID]];
pop.lastItem.representedObject = bundleID;
}
[pop selectItemAtIndex:[pop indexOfItemWithRepresentedObject:UserPrefsString(Pref_defaultHttpApplication)]];
// Default RSS Reader application
NSString *feedBundleId = CFBridgingRelease(LSCopyDefaultHandlerForURLScheme(CFSTR("feed")));
self.view.defaultReader.objectValue = [self applicationNameForBundleId:feedBundleId];
// Default http application for opening the feed urls
NSPopUpButton *defaultApp = self.view.popupHttpApplication;
[defaultApp removeAllItems];
[defaultApp addItemWithTitle:NSLocalizedString(@"System Default", @"Default web browser application")];
NSArray<NSString*> *browsers = CFBridgingRelease(LSCopyAllHandlersForURLScheme(CFSTR("https")));
for (NSString *bundleID in browsers) {
[defaultApp addItemWithTitle: [self applicationNameForBundleId:bundleID]];
defaultApp.lastItem.representedObject = bundleID;
}
[defaultApp selectItemAtIndex:[defaultApp indexOfItemWithRepresentedObject:UserPrefsString(Pref_defaultHttpApplication)]];
}
/// Get human readable application name such as 'Safari' or 'baRSS'
@@ -41,11 +43,6 @@
#pragma mark - User interaction
// Callback method fired when user selects a different item from popup list
- (void)changeHttpApplication:(NSPopUpButton *)sender {
UserPrefsSet(Pref_defaultHttpApplication, sender.selectedItem.representedObject);
}
// Callback method from round help button right of default feed reader text
- (void)clickHowToDefaults:(NSButton *)sender {
NSAlert *alert = [[NSAlert alloc] init];
@@ -63,4 +60,9 @@
// x-apple.systempreferences:com.apple.preferences.users?startupItemsPref
// Callback method fired when user selects a different item from popup list
- (void)changeHttpApplication:(NSPopUpButton *)sender {
UserPrefsSet(Pref_defaultHttpApplication, sender.selectedItem.representedObject);
}
@end

View File

@@ -4,8 +4,8 @@
NS_ASSUME_NONNULL_BEGIN
@interface SettingsGeneralView : NSView
@property (strong) IBOutlet NSPopUpButton* popupHttpApplication;
@property (strong) IBOutlet NSTextField *defaultReader;
@property (strong) IBOutlet NSPopUpButton* popupHttpApplication;
- (instancetype)initWithController:(SettingsGeneral*)controller NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithFrame:(NSRect)frameRect NS_UNAVAILABLE;