Ejemplo n.º 1
0
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();
		}
	}
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
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);
}
Ejemplo n.º 4
0
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();
}