/* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */ /* AbiSource Application Framework * Copyright (C) 2005 Francis James Franklin * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. */ #import #import "AbiSite_Controller.h" #import "AbiSite_ExportOptions.h" #import "AbiSite_SiteController.h" #import "AbiSite_Toolbar.h" @implementation AbiSite_SiteController - (id)initWithAbiWord:(XAP_CocoaPlugin *)AbiWord withController:(AbiSite_Controller *)controller { if (self = [super initWithWindowNibName:@"SiteManager"]) { m_AbiWord = AbiWord; m_Controller = controller; m_Toolbar = 0; m_SourceRoot = @""; m_DestinationRoot = @""; m_SiteFile = nil; [m_SourceRoot retain]; [m_DestinationRoot retain]; m_Untitled = YES; } return self; } - (void)dealloc { if (m_Toolbar) { [m_Toolbar release]; m_Toolbar = 0; } if (m_SiteFile) { [m_SiteFile release]; m_SiteFile = 0; } [m_SourceRoot release]; [m_DestinationRoot release]; [super dealloc]; } - (void)windowDidLoad { m_Toolbar = [[AbiSite_Toolbar alloc] initWithController:m_Controller withSite:self]; [oSourceRoot setStringValue:m_SourceRoot]; [oDestinationRoot setStringValue:m_DestinationRoot]; } - (IBAction)destinationSelect:(id)sender { NSString * path = [m_Controller chooseDirectory]; if (path) { [self setDestinationRoot:path]; } } - (void)setUntitled:(unsigned)number { m_Untitled = YES; [[self window] setTitle:[NSString stringWithFormat:@"AbiSite %u", number]]; } - (void)setSourceRoot:(NSString *)path { if (path) if ([path isEqualToString:m_SourceRoot] == NO) { [m_SourceRoot release]; m_SourceRoot = path; [m_SourceRoot retain]; [oSourceRoot setStringValue:m_SourceRoot]; } } - (NSString *)sourceRoot { return m_SourceRoot; } - (void)setDestinationRoot:(NSString *)path { if (path) if ([path isEqualToString:m_DestinationRoot] == NO) { [m_DestinationRoot release]; m_DestinationRoot = path; [m_DestinationRoot retain]; [oDestinationRoot setStringValue:m_DestinationRoot]; } } - (NSString *)destinationRoot { return m_DestinationRoot; } - (void)logEntry:(NSString *)aString forMethod:(NSString *)method { NSString * title = [NSString stringWithFormat:@"[%@] ", [[self window] title]]; NSDictionary * attr = [NSDictionary dictionaryWithObject:[NSColor blueColor] forKey:NSForegroundColorAttributeName]; NSAttributedString * str = [[NSAttributedString alloc] initWithString:title attributes:attr]; [m_Controller appendToLog:str]; [str release]; [m_Controller logEntry:aString forMethod:method]; } - (void)logError:(NSString *)aString forMethod:(NSString *)method { NSDictionary * attr = [NSDictionary dictionaryWithObject:[NSColor redColor] forKey:NSForegroundColorAttributeName]; NSAttributedString * str = [[NSAttributedString alloc] initWithString:@"Error: " attributes:attr]; [m_Controller appendToLog:str]; [str release]; [self logEntry:aString forMethod:method]; } @end