const PopupMenu MainHostWindow::getMenuForIndex (int topLevelMenuIndex, const String& /*menuName*/) { PopupMenu menu; if (topLevelMenuIndex == 0) { // "File" menu menu.addCommandItem (commandManager, CommandIDs::open); RecentlyOpenedFilesList recentFiles; recentFiles.restoreFromString (ApplicationProperties::getInstance()->getUserSettings() ->getValue ("recentFilterGraphFiles")); PopupMenu recentFilesMenu; recentFiles.createPopupMenuItems (recentFilesMenu, 100, true, true); menu.addSubMenu (T("Open recent file"), recentFilesMenu); menu.addCommandItem (commandManager, CommandIDs::save); menu.addCommandItem (commandManager, CommandIDs::saveAs); menu.addSeparator(); menu.addCommandItem (commandManager, StandardApplicationCommandIDs::quit); } else if (topLevelMenuIndex == 1) { // "Plugins" menu PopupMenu pluginsMenu; addPluginsToMenu (pluginsMenu); menu.addSubMenu (T("Create plugin"), pluginsMenu); menu.addSeparator(); menu.addItem (250, T("Delete all plugins")); } else if (topLevelMenuIndex == 2) { // "Options" menu menu.addCommandItem (commandManager, CommandIDs::showPluginListEditor); PopupMenu sortTypeMenu; sortTypeMenu.addItem (200, "List plugins in default order", true, pluginSortMethod == KnownPluginList::defaultOrder); sortTypeMenu.addItem (201, "List plugins in alphabetical order", true, pluginSortMethod == KnownPluginList::sortAlphabetically); sortTypeMenu.addItem (202, "List plugins by category", true, pluginSortMethod == KnownPluginList::sortByCategory); sortTypeMenu.addItem (203, "List plugins by manufacturer", true, pluginSortMethod == KnownPluginList::sortByManufacturer); sortTypeMenu.addItem (204, "List plugins based on the directory structure", true, pluginSortMethod == KnownPluginList::sortByFileSystemLocation); menu.addSubMenu ("Plugin menu type", sortTypeMenu); menu.addSeparator(); menu.addCommandItem (commandManager, CommandIDs::showAudioSettings); menu.addSeparator(); menu.addCommandItem (commandManager, CommandIDs::aboutBox); } return menu; }
/* public */ MMSSwitcher::MMSSwitcher(MMSPluginData *plugindata) : osdhandler(NULL), centralhandler(NULL) { /* switcher instantiated by plugin */ if(plugindata) { /* get access to the plugin handler */ this->plugindata = plugindata; if (this->plugindata->getType()->getName()=="OSD_PLUGIN") { this->osdhandler = this->pluginmanager->getOSDPluginHandler(this->plugindata->getId()); this->showPreviewThread = new MMSSwitcherThread(this); } else if (this->plugindata->getType()->getName()=="CENTRAL_PLUGIN") { this->centralhandler = this->pluginmanager->getCentralPluginHandler(this->plugindata->getId()); this->showPreviewThread = new MMSSwitcherThread(this); } plugin_data_t *pd = new plugin_data_t; pd->plugindata = *plugindata; pd->switcher = this; plugins.insert(std::make_pair(plugindata->getId(), pd)); return; } /* switcher start */ DEBUGMSG("MMSSwitcher", "startup"); this->windowmanager = NULL; this->pluginmanager = NULL; this->inputmanager = NULL; this->curr_plugin = -1; this->window = NULL; try { /* get the active osd and central plugins */ DataSource source = DataSource(config.getConfigDBDBMS(), config.getConfigDBDatabase(), config.getConfigDBAddress(), config.getConfigDBPort(), config.getConfigDBUser(), config.getConfigDBPassword()); /* load switcher dialog */ this->window = (MMSMainWindow*)dm.loadDialog(config.getData() + "/themes/" + config.getTheme() + "/switcher.xml"); if(!this->window) throw MMSError(0, "Error loading switchers root window"); /* get access to the menu bar */ this->menuBar = (MMSChildWindow *)this->window->findWindow(SWITCHER_MENUBAR); if(!this->menuBar) throw MMSError(0, "Error loading switchers menuBar childwindow"); this->menu = dynamic_cast<MMSMenuWidget*>(this->menuBar->findWidget(SWITCHER_MENU)); if(!this->menu) throw MMSError(0, "Error loading switchers menu"); /* get access to the static menu bar */ this->menuBar_static = (MMSChildWindow *)this->window->findWindow(SWITCHER_MENUBAR_STATIC); if (this->menuBar_static) this->menu_static = dynamic_cast<MMSMenuWidget*>(this->menuBar_static->findWidget(SWITCHER_MENU_STATIC)); else this->menu_static = NULL; /* fill the menu */ MMSPluginService service(&source); addPluginsToMenu(service.getOSDPlugins()); addPluginsToMenu(service.getCentralPlugins()); /* show the menu bar */ if (this->menuBar_static) { this->menuBar_static->show(); this->menuBar_static->waitUntilShown(); } this->menuBar->show(); /* connect onBeforeScroll callback of the menu widget */ menu->onBeforeScroll->connect(sigc::mem_fun(this,&MMSSwitcher::onBeforeScroll)); /* connect onSelectItem callback of the menu widget */ menu->onSelectItem->connect(sigc::mem_fun(this,&MMSSwitcher::onSelectItem)); /* connect onReturn callback of the menu widget */ menu->onReturn->connect(sigc::mem_fun(this,&MMSSwitcher::onReturn)); /* create inputs */ // subscribeKey(MMSKEY_MENU); // subscribeKey(MMSKEY_BACKSPACE); /* start my update thread */ this->switcherThread = new MMSSwitcherThread(this, NULL, NULL, NULL, NULL); this->switcherThread->start(); } catch(MMSError &error) { DEBUGMSG("Switcher", "Abort due to: " + error.getMessage()); throw error; } }