mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-22 12:04:38 +00:00
Add an UpdateCommandState method to the command maanger.
This commit is contained in:
parent
79d35d4d27
commit
18e706dc0d
@ -131,6 +131,14 @@ interface nsIControllerCommandManager : nsISupports
|
||||
*/
|
||||
boolean isCommandEnabled(in wstring aCommandName, in nsISupports aCommandRefCon);
|
||||
|
||||
/**
|
||||
* Tell the command to udpate its state (if it is a state updating command)
|
||||
*
|
||||
* @param aCommandName the name of the command to update
|
||||
* @param aCommandRefCon the command context data
|
||||
*/
|
||||
void updateCommandState(in wstring aCommandName, in nsISupports aCommandRefCon);
|
||||
|
||||
/**
|
||||
* Get whether the named command is supported.
|
||||
*
|
||||
|
@ -118,7 +118,39 @@ nsControllerCommandManager::IsCommandEnabled(const PRUnichar *aCommandName, nsIS
|
||||
return commandHandler->IsCommandEnabled(aCommandName, aCommandRefCon, aResult);
|
||||
}
|
||||
|
||||
/* boolean supportsCommand (in wstring command); */
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsControllerCommandManager::UpdateCommandState(const PRUnichar *aCommandName, nsISupports *aCommandRefCon)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCommandName);
|
||||
|
||||
// find the command
|
||||
nsCOMPtr<nsIControllerCommand> commandHandler;
|
||||
FindCommandHandler(aCommandName, getter_AddRefs(commandHandler));
|
||||
if (!commandHandler)
|
||||
{
|
||||
#if DEBUG
|
||||
nsCAutoString msg("Controller command manager asked to update the state of a command that it does not handle -- ");
|
||||
msg.AppendWithConversion(aCommandName);
|
||||
NS_WARNING(msg);
|
||||
#endif
|
||||
return NS_OK; // we don't handle this command
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIStateUpdatingControllerCommand> stateCommand = do_QueryInterface(commandHandler);
|
||||
if (!stateCommand)
|
||||
{
|
||||
#if DEBUG
|
||||
nsCAutoString msg("Controller command manager asked to update the state of a command that doesn't do state updating -- ");
|
||||
msg.AppendWithConversion(aCommandName);
|
||||
NS_WARNING(msg);
|
||||
#endif
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
return stateCommand->UpdateCommandState(aCommandName, aCommandRefCon);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsControllerCommandManager::SupportsCommand(const PRUnichar *aCommandName, nsISupports *aCommandRefCon, PRBool *aResult)
|
||||
{
|
||||
|
@ -131,6 +131,14 @@ interface nsIControllerCommandManager : nsISupports
|
||||
*/
|
||||
boolean isCommandEnabled(in wstring aCommandName, in nsISupports aCommandRefCon);
|
||||
|
||||
/**
|
||||
* Tell the command to udpate its state (if it is a state updating command)
|
||||
*
|
||||
* @param aCommandName the name of the command to update
|
||||
* @param aCommandRefCon the command context data
|
||||
*/
|
||||
void updateCommandState(in wstring aCommandName, in nsISupports aCommandRefCon);
|
||||
|
||||
/**
|
||||
* Get whether the named command is supported.
|
||||
*
|
||||
|
@ -118,7 +118,39 @@ nsControllerCommandManager::IsCommandEnabled(const PRUnichar *aCommandName, nsIS
|
||||
return commandHandler->IsCommandEnabled(aCommandName, aCommandRefCon, aResult);
|
||||
}
|
||||
|
||||
/* boolean supportsCommand (in wstring command); */
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsControllerCommandManager::UpdateCommandState(const PRUnichar *aCommandName, nsISupports *aCommandRefCon)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCommandName);
|
||||
|
||||
// find the command
|
||||
nsCOMPtr<nsIControllerCommand> commandHandler;
|
||||
FindCommandHandler(aCommandName, getter_AddRefs(commandHandler));
|
||||
if (!commandHandler)
|
||||
{
|
||||
#if DEBUG
|
||||
nsCAutoString msg("Controller command manager asked to update the state of a command that it does not handle -- ");
|
||||
msg.AppendWithConversion(aCommandName);
|
||||
NS_WARNING(msg);
|
||||
#endif
|
||||
return NS_OK; // we don't handle this command
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIStateUpdatingControllerCommand> stateCommand = do_QueryInterface(commandHandler);
|
||||
if (!stateCommand)
|
||||
{
|
||||
#if DEBUG
|
||||
nsCAutoString msg("Controller command manager asked to update the state of a command that doesn't do state updating -- ");
|
||||
msg.AppendWithConversion(aCommandName);
|
||||
NS_WARNING(msg);
|
||||
#endif
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
return stateCommand->UpdateCommandState(aCommandName, aCommandRefCon);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsControllerCommandManager::SupportsCommand(const PRUnichar *aCommandName, nsISupports *aCommandRefCon, PRBool *aResult)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user