void SjMyMusicModule::DoneConfigPage(wxWindow* configPage__, int doneAction__) { SjMyMusicConfigPage* configPage = (SjMyMusicConfigPage*)configPage__; // apply/cancel this module if( configPage->m_idxChanged ) { g_mainFrame->UpdateIndex(SjDialog::FindTopLevel(configPage), FALSE); } // apply/cancel all embedded modules int moduleIndex = 1; for( int type=0; type<=1; type++ ) { SjModuleList* moduleList = g_mainFrame->m_moduleSystem.GetModules(type==0? SJ_MODULETYPE_COL : SJ_MODULETYPE_COMMON); SjModuleList::Node* moduleNode = moduleList->GetFirst(); while( moduleNode ) { SjCommonModule* commonModule = (SjCommonModule*)moduleNode->GetData(); if( commonModule->EmbedTo() == SJ_EMBED_TO_MUSICLIB ) { wxWindow* commonPage = configPage->m_notebook->GetPage(moduleIndex); if( commonPage ) { commonModule->DoneConfigPage(commonPage, doneAction__); } moduleIndex++; } // next moduleNode = moduleNode->GetNext(); } } }
void SjMyMusicConfigPage::OnAddSources(wxCommandEvent& event) { SjModuleList* list = g_mainFrame->m_moduleSystem.GetModules(SJ_MODULETYPE_SCANNER); wxASSERT(list); // find the correct module SjModuleList::Node* moduleNode = list->GetFirst(); SjScannerModule* scannerModule = NULL; int typeCount = 0, typeIndex = -1; while( moduleNode && typeIndex == -1 ) { scannerModule = (SjScannerModule*)moduleNode->GetData(); wxASSERT(scannerModule); wxASSERT(scannerModule->IsLoaded()); size_t i; for( i = 0; i < scannerModule->m_addSourceTypes_.GetCount(); i++ ) { if( IDC_MODULE00+typeCount == event.GetId() ) { typeIndex = i; // exit outer loop break; } typeCount++; } // next moduleNode = moduleNode->GetNext(); } // add by module if( typeIndex != -1 && scannerModule ) { long newIndex; { wxWindow* topLevelWindow = SjDialog::FindTopLevel(this); SJ_WINDOW_DISABLER(topLevelWindow); newIndex = scannerModule->AddSources(typeIndex, topLevelWindow); } if( newIndex != -1 ) { InitPage(scannerModule->GetSourceUrl(newIndex)); m_idxChanged = TRUE; UpdateButtons(); } } }
SjMyMusicConfigPage::SjMyMusicConfigPage(SjMyMusicModule* myMusicModule, wxWindow* parent, int selectedPage) : wxPanel(parent) { // save given objects m_idxChanged = FALSE; m_configMenuButton = NULL; m_addButton = NULL; m_removeButton = NULL; m_currSortCol = 0; // init dialog wxSizer* dialogSizer = new wxBoxSizer(wxVERTICAL); SetSizer(dialogSizer); m_notebook = new wxNotebook(this, IDC_NOTEBOOK, wxDefaultPosition, wxDefaultSize, 0/*wxCLIP_CHILDREN - problems with wxChoice/wxComboBox*/); wxNotebook* notebookSizer = m_notebook; m_notebook->AddPage(CreatePage(m_notebook), _("Music library")); for( int type=0; type<=1; type++ ) { SjModuleList* moduleList = g_mainFrame->m_moduleSystem.GetModules(type==0? SJ_MODULETYPE_COL : SJ_MODULETYPE_COMMON); SjModuleList::Node* moduleNode = moduleList->GetFirst(); while( moduleNode ) { SjCommonModule* commonModule = (SjCommonModule*)moduleNode->GetData(); if( commonModule->EmbedTo() == SJ_EMBED_TO_MUSICLIB ) { m_notebook->AddPage(commonModule->GetConfigPage(m_notebook, 0), commonModule->m_name); } moduleNode = moduleNode->GetNext(); } } if( selectedPage < 0 || selectedPage >= (int)m_notebook->GetPageCount() ) { selectedPage = 0; } m_notebook->SetSelection(selectedPage); dialogSizer->Add(notebookSizer, 1, wxALL|wxGROW, SJ_DLG_SPACE); dialogSizer->SetSizeHints(this); // init data InitPage(g_tools->m_config->Read("settings/selSource", "")); }
bool SjInterfaceBase::IsModuleAdded(SjModuleList& list, const wxString& file, int fileIndex, const wxString& name) { SjModuleList::Node* currModuleNode = list.GetFirst(); while( currModuleNode ) { SjModule* currModule = currModuleNode->GetData(); wxASSERT(currModule); if( currModule->m_interface == this ) { if( currModule->m_file.CmpNoCase(file)==0 && currModule->m_fileIndex == fileIndex ) { return TRUE; } if( currModule->m_name == name ) { /*wxLogWarning("The Modules \"%s\" and \"%s\" seems to be identical." n/t, currModule->m_file.c_str(), file.c_str()); */ return TRUE; } } // next currModuleNode = currModuleNode->GetNext(); } return FALSE; }
SjScannerModule* SjModuleSystem::FindScannerModuleByUrl(const wxString& url) { SjModuleList* scannerList = GetModules(SJ_MODULETYPE_SCANNER); SjModuleList::Node* scannerNode = scannerList->GetFirst(); while( scannerNode ) { SjScannerModule* scannerModule = (SjScannerModule*)scannerNode->GetData(); wxASSERT( scannerModule ); wxASSERT( scannerModule->IsLoaded() ); if( scannerModule->IsMyUrl(url) ) { return scannerModule; } scannerNode = scannerNode->GetNext(); } return NULL; }
SjModule* SjModuleSystem::FindModuleByFile(const wxString& file, int fileIndex) { SjModuleList* list = GetModules(SJ_MODULETYPE_ALL); SjModuleList::Node* moduleNode = list->GetFirst(); SjModule* module; while( moduleNode ) { module = moduleNode->GetData(); wxASSERT(module); if( module->m_file.CmpNoCase(file) == 0 && module->m_fileIndex == fileIndex ) { return module; } moduleNode = moduleNode->GetNext(); } return NULL; }
void SjColumnMixer::LoadModules(SjModuleSystem* moduleSystem) { wxASSERT(m_moduleCount==0); wxASSERT(m_libraryModule==NULL); SjModuleList* moduleList = moduleSystem->GetModules(SJ_MODULETYPE_COL); SjModuleList::Node* moduleNode = moduleList->GetFirst(); while( moduleNode ) { SjColModule* module = (SjColModule*)moduleNode->GetData(); wxASSERT(module); if( module->Load() ) { if( module->m_file == wxT("memory:library.lib") ) { m_libraryModule = module; } m_modules[m_moduleCount] = module; m_moduleMaskedColCount[m_moduleCount] = -1; m_moduleUnmaskedColCount[m_moduleCount] = -1; m_moduleCount++; if( m_moduleCount>=SJ_COLUNMMIXER_MAX_MODULES ) { wxLogError(wxT("Too many column modules.")); break; // out of while } } moduleNode = moduleNode->GetNext(); } SetColCount__(); }
void SjCInterface::LoadModulesFastHack(SjModuleList& list, const wxArrayString& possibleDlls) { size_t i, iCount = possibleDlls.GetCount(); wxDynamicLibrary* dynlib; dllMainEntryFuncType entryPoint; SjInterface* cinterf; for( i = 0; i < iCount; i++ ) { // load a DLL { wxLogNull null; dynlib = new wxDynamicLibrary(possibleDlls[i]); if( dynlib == NULL ) continue; // nothing to log - this is no SjDll if( !dynlib->IsLoaded() ) { delete dynlib; continue; // nothing to log - this is no SjDll } entryPoint = (dllMainEntryFuncType)dynlib->GetSymbol(wxT("SjGetInterface")); if( entryPoint == NULL ) { delete dynlib; continue; // nothing to log - this is no SjDll } } wxLogInfo(wxT("Loading %s"), possibleDlls.Item(i).c_str()); cinterf = entryPoint(); if( cinterf == NULL || cinterf->CallPlugin == NULL ) { wxLogError(wxT("SjGetInterface returns 0 or CallPlugin set to 0.")); wxLogError(_("Cannot open \"%s\"."), possibleDlls.Item(i).c_str()); delete dynlib; continue; // error } // success so far - create the plugin and add it to the list list.Append(new SjCPlugin(this, possibleDlls[i], dynlib, cinterf)); } }
void SjMyMusicConfigPage::ShowContextMenu(wxWindow* window, const wxPoint& pt) { SjMenu m(0); SjSettingsSourceItem* source = GetSelFromDialog(); // may be NULL! if( window == this || window == m_addButton ) { SjModuleList* list = g_mainFrame->m_moduleSystem.GetModules(SJ_MODULETYPE_SCANNER); wxASSERT(list); SjModuleList::Node* moduleNode = list->GetFirst(); SjScannerModule* scannerModule; int typeCount = 0; while( moduleNode ) { scannerModule = (SjScannerModule*)moduleNode->GetData(); wxASSERT(scannerModule); wxASSERT(scannerModule->IsLoaded()); size_t i; wxASSERT( scannerModule->m_addSourceTypes_.GetCount() == scannerModule->m_addSourceIcons_.GetCount() ); for( i = 0; i < scannerModule->m_addSourceTypes_.GetCount(); i++ ) { m.Append(IDC_MODULE00+typeCount, scannerModule->m_addSourceTypes_.Item(i)+"..."); typeCount++; } // next moduleNode = moduleNode->GetNext(); } } if( window == this ) { m.Append(IDC_IDXDELSOURCE, _("Remove source")); m.Enable(IDC_IDXDELSOURCE, source!=NULL); } if( window == this || window == m_configMenuButton ) { if( m.GetMenuItemCount() ) { m.AppendSeparator(); } if( source ) { m.Append(IDC_IDXCONFIGSOURCE, wxString::Format(_("Options for \"%s\""), SjTools::ShortenUrl(source->GetUrl()).c_str())+"..."); } else { m.Append(IDC_IDXCONFIGSOURCE, _("Options...")); m.Enable(IDC_IDXCONFIGSOURCE, FALSE); } m.Append(IDM_EXPLORE); m.Enable(IDM_EXPLORE, source!=NULL); } if( window == this || window == m_updateButton ) { if( m.GetMenuItemCount() ) { m.AppendSeparator(); } m.Append(IDT_UPDATE_INDEX); m.Append(IDT_DEEP_UPDATE_INDEX); } window->PopupMenu(&m, pt); }
void SjMyMusicConfigPage::InitPage(const wxString& selSourceUrl) { // create index list m_listOfSources.Clear(); m_listOfSources.DeleteContents(TRUE); SjModuleList* list = g_mainFrame->m_moduleSystem.GetModules(SJ_MODULETYPE_SCANNER); wxASSERT(list); SjModuleList::Node* moduleNode = list->GetFirst(); SjScannerModule* scannerModule; while( moduleNode ) { scannerModule = (SjScannerModule*)moduleNode->GetData(); wxASSERT(scannerModule); wxASSERT(scannerModule->IsLoaded()); long sourceCount = scannerModule->GetSourceCount(); long currSourceIndex; for( currSourceIndex = 0; currSourceIndex < sourceCount; currSourceIndex++ ) { SjSettingsSourceItem* item = new SjSettingsSourceItem(scannerModule, currSourceIndex, scannerModule->GetSourceUrl(currSourceIndex), scannerModule->GetSourceIcon(currSourceIndex)); m_listOfSources.Append(item); } // next moduleNode = moduleNode->GetNext(); } // get list control m_listCtrl->Freeze(); m_listCtrl->DeleteAllItems(); // go through all search directories SjSettingsSourceItem* item; SjSettingsSourceItemList::Node* itemnode = m_listOfSources.GetFirst(); int i = 0; wxString sourceNotes; while( itemnode ) { item = itemnode->GetData(); wxASSERT(item); wxListItem listitem; listitem.m_mask = wxLIST_MASK_IMAGE | wxLIST_MASK_TEXT | wxLIST_MASK_DATA; listitem.m_itemId = i; listitem.m_text = item->GetUrl(); listitem.SetData((void*)item); listitem.m_image = item->GetScannerModule()->GetSourceIcon(item->GetIndex()); sourceNotes = item->GetScannerModule()->GetSourceNotes(item->GetIndex()); if( !sourceNotes.IsEmpty() ) { listitem.m_text.Append(" ("); listitem.m_text.Append(sourceNotes); listitem.m_text.Append(')'); } m_listCtrl->InsertItem(listitem); itemnode = itemnode->GetNext(); i++; } m_listCtrl->SortItems(ListCtrlCompareFunction, m_currSortCol); m_listCtrl->Thaw(); // select the correct item // (should be done after SortItems() on GTK this may remove the selection ...) int i_cnt = m_listCtrl->GetItemCount(); for( i = 0; i < i_cnt; i ++ ) { item = (SjSettingsSourceItem*)m_listCtrl->GetItemData(i); if( item->GetUrl() == selSourceUrl ) { m_listCtrl->SetItemState(i, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED); break; } } UpdateButtons(); }
void SjInternalInterface::LoadModules(SjModuleList& list) { // add COMMON modules list.Append (new SjSettingsModule (this)); list.Append (new SjTagEditorModule (this)); list.Append (new SjOpenFilesModule (this)); list.Append (new SjMyMusicModule (this)); list.Append (new SjBasicSettingsModule (this)); list.Append (new SjPlaybackSettingsModule (this)); list.Append (new SjViewSettingsModule (this)); list.Append (new SjHelpModule (this)); list.Append (new SjArtEditorModule (this)); list.Append (new SjAccelModule (this)); list.Append (new SjKioskModule (this)); list.Append (new SjAdvSearchModule (this)); list.Append (new SjVirtKeybdModule (this)); // add MLR modules list.Append (new SjFolderScannerModule (this)); list.Append (new SjServerScannerModule (this)); // add COL modules list.Append (new SjLibraryModule (this)); // add PLAYER and VIS modules list.Append (new SjPlayerModule (this)); list.Append (new SjVisModule (this)); list.Append (new SjOscModule (this)); list.Append (new SjKaraokeModule (this)); #if SJ_USE_VIDEO list.Append (new SjVidoutModule (this)); #endif }