Skip to content

Commit

Permalink
Moar polish.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Gorbach committed Jan 2, 2010
1 parent f40f477 commit eb7dcfd
Show file tree
Hide file tree
Showing 24 changed files with 558 additions and 816 deletions.
33 changes: 12 additions & 21 deletions FTPFS/ftpfs_askpass.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,28 @@ int main(int argc, char *argv[])
NSString* token = [[[NSProcessInfo processInfo] environment] objectForKey: @"FTPFS_TOKEN"];
NSString* password;

if (!token)
{
if (!token) {
MFLogS(self, @"Could not find token");
return -1;
}
else
{
MFClientFS* fs = (MFClientFS*)mfsecGetFilesystemForToken( token );
if (!fs)
{
} else {
MFClientFS* fs = (MFClientFS *)mfsecGetFilesystemForToken(token);
if (!fs) {
MFLogS(self, @"Could not get fs for token");
return -1;
}

NSDictionary* secrets = mfsecGetSecretsDictionaryForFilesystem( fs );
if (!secrets)
{
password = mfsecQueryForFSNetworkPassword( fs );
}
else
{
password = [secrets objectForKey: kNetFSPasswordParameter];
NSDictionary *secrets = mfsecGetSecretsDictionaryForFilesystem(fs);
if (!secrets) {
password = mfsecQueryForFSNetworkPassword(fs);
} else {
password = [secrets objectForKey:kNetFSPasswordParameter];
}

if (!password)
{
password = mfsecQueryForFSNetworkPassword( fs );
if (!password) {
password = mfsecQueryForFSNetworkPassword(fs);
}

if (password && [password length] > 0)
{
if (password && [password length] > 0) {
printf("%s\n", [password UTF8String]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion MFAdvancedViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@class MFIconSettingImageView;
@interface MFAdvancedViewController : NSViewController {
IBOutlet MFIconSettingImageView* iconView;
IBOutlet MFIconSettingImageView *iconView;
}

- (IBAction)chooseIcon:(id)sender;
Expand Down
26 changes: 12 additions & 14 deletions MFAdvancedViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,21 @@
#import "MFClientFS.h"

@implementation MFAdvancedViewController
- (void)awakeFromNib
{
- (void)awakeFromNib {
[iconView bind:@"fs" toObject:self withKeyPath:@"representedObject" options:nil];
}

- (IBAction)chooseIcon:(id)sender
{
NSOpenPanel* panel = [NSOpenPanel openPanel];
[panel setAllowsMultipleSelection: NO];
[panel setAllowedFileTypes: [NSArray arrayWithObject: @"icns"]];
NSInteger returnValue = [panel runModalForTypes: [NSArray arrayWithObject: @"icns"]];
if (returnValue == NSOKButton && [[panel filenames] count] > 0)
{
NSString* filename = [[panel filenames] objectAtIndex: 0];
NSImage* iconImage = [[NSImage alloc] initWithContentsOfFile: filename];
if (iconImage)
[(MFClientFS*)[self representedObject] setIconImage: iconImage];
- (IBAction)chooseIcon:(id)sender {
NSOpenPanel *panel = [NSOpenPanel openPanel];
[panel setAllowsMultipleSelection:NO];
[panel setAllowedFileTypes:[NSArray arrayWithObject: @"icns"]];
NSInteger returnValue = [panel runModalForTypes:[NSArray arrayWithObject: @"icns"]];
if (returnValue == NSOKButton && [[panel filenames] count] > 0) {
NSString *filename = [[panel filenames] objectAtIndex:0];
NSImage *iconImage = [[NSImage alloc] initWithContentsOfFile:filename];
if (iconImage) {
[(MFClientFS*)[self representedObject] setIconImage:iconImage];
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion MFClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ - (NSString *)createMountIconForFilesystem:(MFClientFS *)fs atPath:(NSURL *)dirP
NSString *dirPath = [dirPathURL path];
NSString *filename = [NSString stringWithFormat: @"%@.fusion", [fs name]];
NSString *fullPath = [dirPath stringByAppendingPathComponent: filename];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[fs uuid], KMFFSUUIDParameter, nil];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[fs uuid], kMFFSUUIDParameter, nil];
[dict writeToFile: fullPath atomically: YES];
NSImage *iconImage = [NSImage imageNamed:@"macfusionIcon.icns"];
[[NSWorkspace sharedWorkspace] setIcon:iconImage forFile:fullPath options:0];
Expand Down
4 changes: 2 additions & 2 deletions MFEditingController.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
@class MFClientFS;

@interface MFEditingController : NSWindowController {
MFClientFS* fsBeingEdited;
MFClientFS* _fsBeingEdited;

}

+ (NSInteger)editFilesystem:(MFClientFS*)fs onWindow:(NSWindow*)window;
+ (NSInteger)editFilesystem:(MFClientFS *)fs onWindow:(NSWindow *)window;
@end
142 changes: 60 additions & 82 deletions MFEditingController.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,108 +22,90 @@
#import "MFClientFSUI.h"

@interface MFEditingController(PrivateAPI)
- (id)initWithFilesystem:(MFClientFS*)fs;
- (id)initWithFilesystem:(MFClientFS *)fs;
- (void)beginEditing;
- (void)filesystemEditOKClicked:(id)sender;
- (void)filesystemEditCancelClicked:(id)sender;
- (NSView*)wrapViewInOKCancel:(NSView*)innerView;
- (NSView *)wrapViewInOKCancel:(NSView *)innerView;
@end

@implementation MFEditingController

+ (NSInteger)editFilesystem:(MFClientFS*)fs
onWindow:(NSWindow*)parentWindow
{
MFEditingController* editController = [[MFEditingController alloc] initWithFilesystem: fs];
NSWindow* editWindow = [editController window];
+ (NSInteger)editFilesystem:(MFClientFS *)fs onWindow:(NSWindow *)parentWindow {
MFEditingController *editController = [[MFEditingController alloc] initWithFilesystem: fs];
NSWindow *editWindow = [editController window];
[editController beginEditing];

if (parentWindow)
{
[NSApp beginSheet: editWindow
modalForWindow: parentWindow
modalDelegate: editController
didEndSelector: @selector(editSheetDidEnd:returnCode:contextInfo:)
contextInfo: fs];
if (parentWindow) {
[NSApp beginSheet:editWindow
modalForWindow:parentWindow
modalDelegate:editController
didEndSelector:@selector(editSheetDidEnd:returnCode:contextInfo:)
contextInfo:fs];
NSInteger editReturn = [NSApp runModalForWindow: editWindow];
[NSApp endSheet: editWindow];
[editWindow orderOut: self];
[NSApp endSheet:editWindow];
[editWindow orderOut:self];
return editReturn;
}
else
{
[editController showWindow: self];
NSInteger editReturn = [NSApp runModalForWindow: editWindow];
} else {
[editController showWindow:self];
NSInteger editReturn = [NSApp runModalForWindow:editWindow];
[editWindow close];
return editReturn;
}
}

- (id)initWithFilesystem:(MFClientFS*)fs
{
if (self = [super initWithWindow: nil])
{
fsBeingEdited = fs;
NSWindow* editWindow = [[NSWindow alloc] init];
NSView* editingViewForFS = [fs editingView];
[(MGTransitioningTabView*)editingViewForFS setDelegate: self];
- (id)initWithFilesystem:(MFClientFS *)fs {
if (self = [super initWithWindow: nil]) {
_fsBeingEdited = fs;
NSWindow *editWindow = [[NSWindow alloc] init];
NSView *editingViewForFS = [fs editingView];
[(MGTransitioningTabView *)editingViewForFS setDelegate:self];

if (!editingViewForFS)
{
if (!editingViewForFS) {
MFLogSO(self, fs, @"Filesystem returned nil view for editing");
return nil;
}

NSView* fullEditView = [self wrapViewInOKCancel:
[fs addTopViewToView: editingViewForFS]];
[editWindow setFrame: [fullEditView frame] display:YES];
[editWindow setContentSize: [fullEditView frame].size];
[editWindow setContentView: fullEditView];
[self setWindow: editWindow];
NSView *fullEditView = [self wrapViewInOKCancel:[fs addTopViewToView: editingViewForFS]];
[editWindow setFrame:[fullEditView frame] display:YES];
[editWindow setContentSize:[fullEditView frame].size];
[editWindow setContentView:fullEditView];
[self setWindow:editWindow];
}

return self;
}

- (void)beginEditing
{
[fsBeingEdited beginEditing];
- (void)beginEditing {
[_fsBeingEdited beginEditing];
}

# pragma mark Editing Mechanics
- (void)filesystemEditOKClicked:(id)sender
{
NSError* error = [fsBeingEdited endEditingAndCommitChanges: YES];
if (error)
{
- (void)filesystemEditOKClicked:(id)sender {
NSError *error = [_fsBeingEdited endEditingAndCommitChanges:YES];
if (error) {
[NSApp presentError: error
modalForWindow: [self window]
delegate: nil
didPresentSelector: nil
contextInfo: nil];
}
else
{
[NSApp stopModalWithCode: kMFEditReturnOK];
} else {
[NSApp stopModalWithCode:kMFEditReturnOK];
}
}


- (void)filesystemEditCancelClicked:(id)sender
{
[fsBeingEdited endEditingAndCommitChanges: NO];
[NSApp stopModalWithCode: kMFEditReturnCancel];
- (void)filesystemEditCancelClicked:(id)sender {
[_fsBeingEdited endEditingAndCommitChanges:NO];
[NSApp stopModalWithCode:kMFEditReturnCancel];
}

- (void)editSheetDidEnd:(NSWindow*)sheet returnCode:(NSInteger)code contextInfo:(void*)info
{
- (void)editSheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)code contextInfo:(void *)info {
[sheet orderOut:self];
}

# pragma mark View Construction

- (NSView*)wrapViewInOKCancel:(NSView*)innerView
{
- (NSView *)wrapViewInOKCancel:(NSView *)innerView {
NSInteger buttonWidth = 80;
NSInteger buttonHeight = 32;
NSInteger buttonRightPadding = 10;
Expand All @@ -133,60 +115,56 @@ - (NSView*)wrapViewInOKCancel:(NSView*)innerView
NSInteger buttonAreaHeight = 2*buttonBottomPadding + buttonHeight;
NSInteger margin = 20;

NSView* outerView = [[NSView alloc] init];
NSView *outerView = [[NSView alloc] init];

[outerView setFrameSize: NSMakeSize([innerView frame].size.width + margin,
[innerView frame].size.height + buttonAreaHeight)];
[outerView setFrameSize:NSMakeSize([innerView frame].size.width + margin,[innerView frame].size.height + buttonAreaHeight)];

[outerView addSubview: innerView];
[innerView setFrame: NSMakeRect(margin/2, buttonAreaHeight - ySpacingShift, [innerView frame].size.width,
[innerView frame].size.height)];
[outerView addSubview:innerView];
[innerView setFrame:NSMakeRect(margin/2, buttonAreaHeight - ySpacingShift, [innerView frame].size.width,[innerView frame].size.height)];

NSRect okButtonFrame = NSMakeRect([outerView frame].size.width-buttonRightPadding-buttonWidth,
NSRect okButtonFrame = NSMakeRect([outerView frame].size.width-buttonRightPadding-buttonWidth,
buttonBottomPadding,
buttonWidth,
buttonHeight);
NSButton* okButton = [[NSButton alloc] initWithFrame: okButtonFrame];
[okButton setBezelStyle: NSRoundedBezelStyle];
NSButton *okButton = [[NSButton alloc] initWithFrame: okButtonFrame];
[okButton setBezelStyle:NSRoundedBezelStyle];
[okButton setTitle:@"OK"];
[okButton setTarget: self];
[okButton setTarget:self];
[okButton setAction:@selector(filesystemEditOKClicked:)];
[okButton setKeyEquivalent:@"\r"];
[okButton setAutoresizingMask: NSViewMaxYMargin | NSViewMinXMargin];
[okButton setAutoresizingMask:NSViewMaxYMargin | NSViewMinXMargin];


NSRect cancelButtonFrame = NSMakeRect(okButtonFrame.origin.x - buttonXDistance- buttonWidth,
buttonBottomPadding,
buttonWidth, buttonHeight);
NSButton* cancelButton = [[NSButton alloc] initWithFrame: cancelButtonFrame];
[cancelButton setBezelStyle: NSRoundedBezelStyle];
NSButton *cancelButton = [[NSButton alloc] initWithFrame: cancelButtonFrame];
[cancelButton setBezelStyle:NSRoundedBezelStyle];
[cancelButton setTitle:@"Cancel"];
[cancelButton setTarget: self];
[cancelButton setTarget:self];
[cancelButton setAction:@selector(filesystemEditCancelClicked:)];
[cancelButton setKeyEquivalent:@"\e"];
[cancelButton setAutoresizingMask: NSViewMaxYMargin | NSViewMinXMargin];
[cancelButton setAutoresizingMask:NSViewMaxYMargin | NSViewMinXMargin];

[outerView setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable];
[outerView setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
[outerView addSubview:cancelButton];
[outerView addSubview: okButton];
[outerView addSubview:okButton];

return outerView;
}

- (void)tabView:(NSTabView *)tabView
didSelectTabViewItem:(NSTabViewItem *)tabViewItem
{
MGTransitioningTabView* myTabView = (MGTransitioningTabView*)tabView;
NSWindow* sheetWindow = [NSApp keyWindow];
- (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem {
MGTransitioningTabView *myTabView = (MGTransitioningTabView *)tabView;
NSWindow *sheetWindow = [NSApp keyWindow];
NSRect oldSheetFrame = [sheetWindow frame];
NSSize oldTabViewSize = [tabView frame].size;
CGFloat deltaX = [sheetWindow frame].size.width - oldTabViewSize.width;
CGFloat deltaY = [sheetWindow frame].size.height - oldTabViewSize.height;
NSSize newtabViewSize = [myTabView sizeWithTabviewItem: tabViewItem];
NSSize newSize = NSMakeSize(newtabViewSize.width+deltaX, newtabViewSize.height+deltaY);
[sheetWindow setFrame: NSMakeRect(oldSheetFrame.origin.x-0.5*(newSize.width-oldSheetFrame.size.width),
[sheetWindow setFrame:NSMakeRect(oldSheetFrame.origin.x-0.5*(newSize.width-oldSheetFrame.size.width),
oldSheetFrame.origin.y-(newSize.height-oldSheetFrame.size.height),
newSize.width, newSize.height)
newSize.width, newSize.height)
display:YES
animate:YES];
}
Expand Down
2 changes: 1 addition & 1 deletion MFFilesystem.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ - (NSString *)mountPath {
}

- (NSString *)uuid {
return [self valueForParameterNamed:KMFFSUUIDParameter];
return [self valueForParameterNamed:kMFFSUUIDParameter];
}

- (NSString *)status {
Expand Down
26 changes: 13 additions & 13 deletions MFLogViewerController.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@
@class MFLogReader, MFClientFS;

@interface MFLogViewerController : NSWindowController {
MFLogReader* logReader;
IBOutlet NSTableView* logTableView;
IBOutlet NSArrayController* logArrayController;
IBOutlet NSPopUpButton* filesystemFilterPopup;
IBOutlet NSButton* autoScrollButton;
IBOutlet NSSearchField* logSearchField;
IBOutlet NSTableView *logTableView;
IBOutlet NSArrayController *logArrayController;
IBOutlet NSPopUpButton *filesystemFilterPopup;
IBOutlet NSButton *autoScrollButton;
IBOutlet NSSearchField *logSearchField;

NSInteger searchCategory;
NSPredicate* filterPredicate;
NSPredicate* searchPredicate;
MFLogReader *_logReader;
NSInteger _searchCategory;
NSPredicate *_filterPredicate;
NSPredicate *_searchPredicate;
}

- (IBAction)filterForFilesystem:(MFClientFS*)fs;
- (IBAction)filterForFilesystem:(MFClientFS *)fs;
- (IBAction)searchCategoryChanged:(id)sender;


@property(readonly) NSPredicate* fullLogPredicate;
@property(readwrite, retain) NSPredicate* filterPredicate;
@property(readwrite, retain) NSPredicate* searchPredicate;
@property(readonly) NSPredicate *fullLogPredicate;
@property(readwrite, retain) NSPredicate *filterPredicate;
@property(readwrite, retain) NSPredicate *searchPredicate;

@end
Loading

0 comments on commit eb7dcfd

Please sign in to comment.