Various 'content' options

This commit is contained in:
anthony 2021-08-05 19:26:04 +01:00
parent 26fdf229e2
commit 87e33083da
3 changed files with 91 additions and 0 deletions

View File

@ -30,6 +30,14 @@ typedef NS_ENUM(NSInteger, LoadImages) {
LoadImagesNone
};
typedef NS_ENUM(NSInteger, FontType) {
FontTypeSansSerif = 0,
FontTypeSerif,
FontTypeMonospace,
FontTypeCursive,
FontTypeFantasy
};
// Certain preferences will notify that they have been updated using this key.
#define PreferencesUpdatedNotificationName @"PreferencesUpdatedNotification"
typedef NS_ENUM(NSInteger, PreferenceType) {
@ -85,5 +93,20 @@ typedef NS_ENUM(NSInteger, PreferenceType) {
-(LoadImages)loadImages;
-(void)setLoadImages: (LoadImages)loadImages;
-(BOOL)disablePopups;
-(void)setDisablePopups: (BOOL)value;
-(BOOL)hideAds;
-(void)setHideAds: (BOOL)value;
-(BOOL)enableJavascript;
-(void)setEnableJavascript: (BOOL)value;
-(BOOL)enableAnimation;
-(void)setEnableAnimation: (BOOL)value;
-(FontType)defaultFont;
-(void)setDefaultFont: (FontType)value;
+(Preferences*)defaultPreferences;
@end

View File

@ -242,6 +242,54 @@
[self saveNetsurfPrefsFile];
}
-(BOOL)disablePopups {
// return (BOOL)nsoption_bool(disable_popups);
return NO;
}
-(void)setDisablePopups: (BOOL)value {
// nsoption_set_bool(disable_popups, (bool)value);
[self saveNetsurfPrefsFile];
}
-(BOOL)hideAds {
return (BOOL)nsoption_bool(block_advertisements);
}
-(void)setHideAds: (BOOL)value {
nsoption_set_bool(block_advertisements, (bool)value);
[self saveNetsurfPrefsFile];
}
-(BOOL)enableJavascript {
return (BOOL)nsoption_bool(enable_javascript);
}
-(void)setEnableJavascript: (BOOL)value {
nsoption_set_bool(enable_javascript, (bool)value);
[self saveNetsurfPrefsFile];
}
-(BOOL)enableAnimation {
return (BOOL)nsoption_bool(animate_images);
}
-(void)setEnableAnimation: (BOOL)value {
nsoption_set_bool(animate_images, (bool)value);
[self saveNetsurfPrefsFile];
}
-(FontType)defaultFont {
return (FontType)nsoption_int(font_default);
}
-(void)setDefaultFont: (FontType)value {
nsoption_set_int(font_default, (NSInteger)value);
[self saveNetsurfPrefsFile];
}
+(Preferences*)defaultPreferences {
static Preferences *prefs;
if (prefs == nil) {

View File

@ -264,6 +264,16 @@
-(void)configureContentTab {
LoadImages loadImages = [[Preferences defaultPreferences] loadImages];
[displayImagesButton selectItemAtIndex: (NSInteger)loadImages];
[preventPopupsButton setState: [[Preferences defaultPreferences] disablePopups]
? NSOnState : NSOffState];
[hideAdvertsButton setState: [[Preferences defaultPreferences] hideAds]
? NSOnState : NSOffState];
[enableJavascriptButton setState: [[Preferences defaultPreferences] enableJavascript]
? NSOnState : NSOffState];
[enableAnimationButton setState: [[Preferences defaultPreferences] enableAnimation]
? NSOnState : NSOffState];
FontType fontType = [[Preferences defaultPreferences] defaultFont];
[defaultFontButton selectItemAtIndex: (NSInteger)fontType];
}
-(void)didChangeFontSizeStepper: (id)sender {
@ -276,6 +286,8 @@
-(void)didPickDefaultFont: (id)sender {
NSLog(@"didPickDefualtFont");
FontType fontType = (FontType)[sender indexOfItem: [sender selectedItem]];
[[Preferences defaultPreferences] setDefaultFont: fontType];
}
-(void)didPickLoadImages: (id)sender {
@ -287,18 +299,26 @@
-(void)didPressEnableAnimations: (id)sender {
NSLog(@"didPressEnableAnimations");
BOOL checked = [sender state] == NSOnState;
[[Preferences defaultPreferences] setEnableAnimation: checked];
}
-(void)didPressEnableJavascript: (id)sender {
NSLog(@"didPressEnableJavascript");
BOOL checked = [sender state] == NSOnState;
[[Preferences defaultPreferences] setEnableJavascript: checked];
}
-(void)didPressHideAdverts: (id)sender {
NSLog(@"didPressHideAdverts");
BOOL checked = [sender state] == NSOnState;
[[Preferences defaultPreferences] setHideAds: checked];
}
-(void)didPressPreventPopups: (id)sender {
NSLog(@"didPressPreventPopups");
BOOL checked = [sender state] == NSOnState;
[[Preferences defaultPreferences] setDisablePopups: checked];
}
-(void)didPressPreviewFont: (id)sender {