/* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */

/* CarbonToolbar / Cocoa front-end / AbiWord Plug-in
 * 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 "AbiCarbonToolbar.h"
#import "AbiCarbonToolbar_LogController.h"

@implementation AbiCarbonToolbar

- (id)init
{
	if (self = [super init])
		{
			m_AbiWord = 0;
			m_Controller = 0;
		}
	return self;
}

- (void)dealloc
{
	if (m_Controller)
		{
			[m_Controller release];
			m_Controller = 0;
		}
	[super dealloc];
}

- (BOOL)pluginCanRegisterForAbiWord:(XAP_CocoaPlugin *)AbiWord version:(NSString *)version interface:(unsigned long)interface
{
	m_AbiWord = AbiWord;

	return ((interface >= 20050925) ? YES : NO);
}

- (BOOL)pluginIsActive
{
	return (m_Controller != 0);
}

- (void)pluginActivate
{
	if (m_Controller) return;
	if (m_Controller = [[AbiCarbonToolbar_LogController alloc] initWithAbiWord:m_AbiWord])
		{
			[m_Controller window];
		}
}

- (void)pluginDeactivate
{
	if (!m_Controller) return;
	[m_Controller close];
	[m_Controller release];
	m_Controller = 0;
}

- (BOOL)pluginCanDeactivate
{
	return YES;
}

- (void)pluginCurrentDocumentHasChanged
{
	/* hmm... */
}

- (NSString *)pluginName
{
	return @"CarbonToolbar";
}

- (NSString *)pluginAuthor;
{
	return @"CarbonToolbar by Francis Franklin (fjf)";
}

- (NSString *)pluginVersion;
{
	return @"1.0";
}

- (NSString *)pluginDescription;
{
	return @"Toolbar implementation in Carbon.";
}

- (NSString *)pluginUsage;
{
	return @"Use via the Windows->Panels menu.";
}

@end