Esempio n. 1
0
/* Load the definitions from the XMLRegistry
 */
void ToolbarManager::initialise() {
	try {
		// Query the registry
		loadToolbars();
	}
	catch (std::runtime_error& e) {
		std::cout << "ToolbarManager: Warning: " << e.what() << std::endl;
	}
}
Esempio n. 2
0
	/* Constructor: Load the definitions from the XMLRegistry
	 */
	ToolbarCreator::ToolbarCreator()
	{
		globalOutputStream() << "ToolbarCreator: Loading toolbar information from registry.\n";
		try {
			// Query the registry
			loadToolbars();
		}
		catch (std::runtime_error &e) {
			globalOutputStream() << "ToolbarCreator: Warning: " << e.what() << "\n";
		}
		globalOutputStream() << "ToolbarCreator: Finished loading toolbar information.\n";
	}
Esempio n. 3
0
bool LLToolBarView::loadToolbars(bool force_default)
{
	LLToolBarView::ToolbarSet toolbar_set;
	bool err = false;
	
	// Load the toolbars.xml file
	std::string toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "toolbars.xml");
	if (force_default)
	{
		toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml");
	}
	else if (!gDirUtilp->fileExists(toolbar_file)) 
	{
		llwarns << "User toolbars def not found -> use default" << llendl;
		toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml");
	}
	
	LLXMLNodePtr root;
	if(!LLXMLNode::parseFile(toolbar_file, root, NULL))
	{
		llwarns << "Unable to load toolbars from file: " << toolbar_file << llendl;
		err = true;
	}
	
	if (!err && !root->hasName("toolbars"))
	{
		llwarns << toolbar_file << " is not a valid toolbars definition file" << llendl;
		err = true;
	}
	
	// Parse the toolbar settings
	LLXUIParser parser;
	if (!err)
	{
	parser.readXUI(root, toolbar_set, toolbar_file);
	}
	if (!err && !toolbar_set.validateBlock())
	{
		llwarns << "Unable to validate toolbars from file: " << toolbar_file << llendl;
		err = true;
	}
	
	if (err)
	{
		if (force_default)
		{
			llerrs << "Unable to load toolbars from default file : " << toolbar_file << llendl;
		return false;
	}
		// Try to load the default toolbars
		return loadToolbars(true);
	}
	
	// Clear the toolbars now before adding the loaded commands and settings
	for (S32 i = TOOLBAR_FIRST; i <= TOOLBAR_LAST; i++)
	{
		if (mToolbars[i])
		{
			mToolbars[i]->clearCommandsList();
		}
	}
	
	// Add commands to each toolbar
	if (toolbar_set.left_toolbar.isProvided() && mToolbars[TOOLBAR_LEFT])
	{
		if (toolbar_set.left_toolbar.button_display_mode.isProvided())
		{
			LLToolBarEnums::ButtonType button_type = toolbar_set.left_toolbar.button_display_mode;
			mToolbars[TOOLBAR_LEFT]->setButtonType(button_type);
		}
		BOOST_FOREACH(const LLCommandId::Params& command_params, toolbar_set.left_toolbar.commands)
		{
			if (addCommandInternal(LLCommandId(command_params), mToolbars[TOOLBAR_LEFT]))
			{
				llwarns << "Error adding command '" << command_params.name() << "' to left toolbar." << llendl;
			}
		}
	}
	if (toolbar_set.right_toolbar.isProvided() && mToolbars[TOOLBAR_RIGHT])
	{
		if (toolbar_set.right_toolbar.button_display_mode.isProvided())
		{
			LLToolBarEnums::ButtonType button_type = toolbar_set.right_toolbar.button_display_mode;
			mToolbars[TOOLBAR_RIGHT]->setButtonType(button_type);
		}
		BOOST_FOREACH(const LLCommandId::Params& command_params, toolbar_set.right_toolbar.commands)
		{
			if (addCommandInternal(LLCommandId(command_params), mToolbars[TOOLBAR_RIGHT]))
			{
				llwarns << "Error adding command '" << command_params.name() << "' to right toolbar." << llendl;
			}
		}
	}
	if (toolbar_set.bottom_toolbar.isProvided() && mToolbars[TOOLBAR_BOTTOM])
	{
		if (toolbar_set.bottom_toolbar.button_display_mode.isProvided())
		{
			LLToolBarEnums::ButtonType button_type = toolbar_set.bottom_toolbar.button_display_mode;
			mToolbars[TOOLBAR_BOTTOM]->setButtonType(button_type);
		}
		BOOST_FOREACH(const LLCommandId::Params& command_params, toolbar_set.bottom_toolbar.commands)
		{
			if (addCommandInternal(LLCommandId(command_params), mToolbars[TOOLBAR_BOTTOM]))
			{
				llwarns << "Error adding command '" << command_params.name() << "' to bottom toolbar." << llendl;
			}
		}
	}
	mToolbarsLoaded = true;
	return true;
}
bool LLToolBarView::loadToolbars(bool force_default)
{
	LLToolBarView::ToolbarSet toolbar_set;
	bool err = false;
	
	// Load the toolbars.xml file
	std::string toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "toolbars.xml");
	if (force_default)
	{
		toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_TOP_SKIN, "toolbars.xml"); // FS:AO - Look in skin directory, not settings
	}
	else if (!gDirUtilp->fileExists(toolbar_file)) 
	{
		LL_WARNS() << "User toolbars def not found -> use selected skin" << LL_ENDL;
		toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_TOP_SKIN, "toolbars.xml"); // FS:AO - Look in skin directory, not settings
	}
	if (!gDirUtilp->fileExists(toolbar_file)) // FS:AO - Look in skin default dir as fallback
	{
		LL_WARNS() << "Skin toolbars def not found -> use default skin" << LL_ENDL;
                toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_DEFAULT_SKIN, "toolbars.xml");
	}
	
	LLXMLNodePtr root;
	if(!LLXMLNode::parseFile(toolbar_file, root, NULL))
	{
		LL_WARNS() << "Unable to load toolbars from file: " << toolbar_file << LL_ENDL;
		err = true;
	}
	
	if (!err && !root->hasName("toolbars"))
	{
		LL_WARNS() << toolbar_file << " is not a valid toolbars definition file" << LL_ENDL;
		err = true;
	}
	
	// Parse the toolbar settings
	LLXUIParser parser;
	if (!err)
	{
	    parser.readXUI(root, toolbar_set, toolbar_file);
	}

	if (!err && !toolbar_set.validateBlock())
	{
		LL_WARNS() << "Unable to validate toolbars from file: " << toolbar_file << LL_ENDL;
		err = true;
	}
	
	if (err)
	{
		if (force_default)
		{
			LL_ERRS() << "Unable to load toolbars from default file : " << toolbar_file << LL_ENDL;
		    return false;
	    }

		// Try to load the default toolbars
		return loadToolbars(true);
	}
	
	// Clear the toolbars now before adding the loaded commands and settings
	for (S32 i = LLToolBarEnums::TOOLBAR_FIRST; i <= LLToolBarEnums::TOOLBAR_LAST; i++)
	{
		if (mToolbars[i])
		{
			mToolbars[i]->clearCommandsList();
		}
	}
	
	// Add commands to each toolbar
	if (toolbar_set.left_toolbar.isProvided() && mToolbars[LLToolBarEnums::TOOLBAR_LEFT])
	{
		if (toolbar_set.left_toolbar.button_display_mode.isProvided())
		{
			LLToolBarEnums::ButtonType button_type = toolbar_set.left_toolbar.button_display_mode;
			mToolbars[LLToolBarEnums::TOOLBAR_LEFT]->setButtonType(button_type);
		}
		// <FS:Zi> Load left toolbar layout and alignment from XML
		if (toolbar_set.left_toolbar.button_alignment.isProvided())
		{
			LLToolBarEnums::Alignment alignment = toolbar_set.left_toolbar.button_alignment;
			mToolbars[LLToolBarEnums::TOOLBAR_LEFT]->setAlignment(alignment);
		}

		if (toolbar_set.left_toolbar.button_layout_style.isProvided())
		{
			LLToolBarEnums::LayoutStyle layout_style = toolbar_set.left_toolbar.button_layout_style;
			mToolbars[LLToolBarEnums::TOOLBAR_LEFT]->setLayoutStyle(layout_style);
		}
		// </FS:Zi>
		BOOST_FOREACH(const LLCommandId::Params& command_params, toolbar_set.left_toolbar.commands)
		{
			if (addCommandInternal(LLCommandId(command_params), mToolbars[LLToolBarEnums::TOOLBAR_LEFT]))
			{
				LL_WARNS() << "Error adding command '" << command_params.name() << "' to left toolbar." << LL_ENDL;
			}
		}
	}
	if (toolbar_set.right_toolbar.isProvided() && mToolbars[LLToolBarEnums::TOOLBAR_RIGHT])
	{
		if (toolbar_set.right_toolbar.button_display_mode.isProvided())
		{
			LLToolBarEnums::ButtonType button_type = toolbar_set.right_toolbar.button_display_mode;
			mToolbars[LLToolBarEnums::TOOLBAR_RIGHT]->setButtonType(button_type);
		}
		// <FS:Zi> Load left toolbar layout and alignment from XML
		if (toolbar_set.right_toolbar.button_alignment.isProvided())
		{
			LLToolBarEnums::Alignment alignment = toolbar_set.right_toolbar.button_alignment;
			mToolbars[LLToolBarEnums::TOOLBAR_RIGHT]->setAlignment(alignment);
		}

		if (toolbar_set.right_toolbar.button_layout_style.isProvided())
		{
			LLToolBarEnums::LayoutStyle layout_style = toolbar_set.right_toolbar.button_layout_style;
			mToolbars[LLToolBarEnums::TOOLBAR_RIGHT]->setLayoutStyle(layout_style);
		}
		// </FS:Zi>
		BOOST_FOREACH(const LLCommandId::Params& command_params, toolbar_set.right_toolbar.commands)
		{
			if (addCommandInternal(LLCommandId(command_params), mToolbars[LLToolBarEnums::TOOLBAR_RIGHT]))
			{
				LL_WARNS() << "Error adding command '" << command_params.name() << "' to right toolbar." << LL_ENDL;
			}
		}
	}
	if (toolbar_set.bottom_toolbar.isProvided() && mToolbars[LLToolBarEnums::TOOLBAR_BOTTOM])
	{
		if (toolbar_set.bottom_toolbar.button_display_mode.isProvided())
		{
			LLToolBarEnums::ButtonType button_type = toolbar_set.bottom_toolbar.button_display_mode;
			mToolbars[LLToolBarEnums::TOOLBAR_BOTTOM]->setButtonType(button_type);
		}
		// <FS:Zi> Load left toolbar layout and alignment from XML
		if (toolbar_set.bottom_toolbar.button_alignment.isProvided())
		{
			LLToolBarEnums::Alignment alignment = toolbar_set.bottom_toolbar.button_alignment;
			mToolbars[LLToolBarEnums::TOOLBAR_BOTTOM]->setAlignment(alignment);
		}

		if (toolbar_set.bottom_toolbar.button_layout_style.isProvided())
		{
			LLToolBarEnums::LayoutStyle layout_style = toolbar_set.bottom_toolbar.button_layout_style;
			mToolbars[LLToolBarEnums::TOOLBAR_BOTTOM]->setLayoutStyle(layout_style);
		}
		// </FS:Zi>
		BOOST_FOREACH(const LLCommandId::Params& command_params, toolbar_set.bottom_toolbar.commands)
		{
			if (addCommandInternal(LLCommandId(command_params), mToolbars[LLToolBarEnums::TOOLBAR_BOTTOM]))
			{
				LL_WARNS() << "Error adding command '" << command_params.name() << "' to bottom toolbar." << LL_ENDL;
			}
		}
	}
	mToolbarsLoaded = true;
	return true;
}