Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions AppController.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
// The main controller for the SelfControl app, which includes several methods
// to handle command flow and acts as delegate for the initial window.
@interface AppController : NSObject {
IBOutlet id blockTimeUnitsSegmentedControl_;
IBOutlet id blockDurationSlider_;
IBOutlet id blockSliderTimeDisplayLabel_;
IBOutlet id submitButton_;
Expand All @@ -58,6 +59,10 @@
// SelfControl's bundle
- (char*)selfControlHelperToolPathUTF8String;

// Called when the block time units is updated. Updates the unit of time that
// gives the block time units in words (hour, day and week).
- (IBAction)updateTimeUnitsSelection:(id)sender;

// Called when the block duration slider is moved. Updates the label that gives
// the block duration in words (hours and minutes).
- (IBAction)updateTimeSliderDisplay:(id)sender;
Expand Down
34 changes: 33 additions & 1 deletion AppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,38 @@ - (char*)selfControlHelperToolPathUTF8String {
return path;
}

- (IBAction)updateTimeUnitsSelection:(id)sender
{
int selectedIndex = [blockTimeUnitsSegmentedControl_ selectedSegment];

switch (selectedIndex) {
case 0:
{
[blockDurationSlider_ setMaxValue:1440.0f];
[blockDurationSlider_ setNumberOfTickMarks:97];
}
break;

case 1:
{
[blockDurationSlider_ setMaxValue:(1440.0 * 7)];
[blockDurationSlider_ setNumberOfTickMarks:8];
}
break;

case 2:
{
[blockDurationSlider_ setMaxValue:(1440.0 * 7 * 4)];
[blockDurationSlider_ setNumberOfTickMarks:5];
}
break;

default:
break;
}
[self updateTimeSliderDisplay:blockDurationSlider_];
}

- (IBAction)updateTimeSliderDisplay:(id)sender {
int numMinutes = floor([blockDurationSlider_ intValue]);

Expand All @@ -111,7 +143,7 @@ - (IBAction)updateTimeSliderDisplay:(id)sender {
if(formatHours > 0) {
timeString = [NSString stringWithFormat: @"%@%@%d %@", timeString, (formatDays > 0 ? @", " : @""), formatHours, (formatHours == 1 ? NSLocalizedString(@"hour", @"Single hour time string") : NSLocalizedString(@"hours", @"Plural hours time string"))];
}
if(formatMinutes > 0) {
if(formatMinutes > 0 && formatDays <= 0) {
timeString = [NSString stringWithFormat:@"%@%@%d %@", timeString, (formatHours > 0 || formatDays > 0 ? @", " : @""), formatMinutes, (formatMinutes == 1 ? NSLocalizedString(@"minute", @"Single minute time string") : NSLocalizedString(@"minutes", @"Plural minutes time string"))];
}
}
Expand Down
11 changes: 10 additions & 1 deletion DomainListWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,16 @@ - (void)tableView:(NSTableView *)aTableView
str = [splitString objectAtIndex: i];
break;
}
}
}

// Remove "telnet://" if a user tried to put that in
splitString = [str componentsSeparatedByString: @"telnet://"];
for(int i = 0; i < [splitString count]; i++) {
if(![[splitString objectAtIndex: i] isEqual: @""]) {
str = [splitString objectAtIndex: i];
break;
}
}

// Remove URL login names/passwords (username:password@host) if a user tried to put that in
splitString = [str componentsSeparatedByString: @"@"];
Expand Down
Loading