id
int64 0
755k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
65
| repo_stars
int64 100
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 9
values | repo_extraction_date
stringclasses 92
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
750,638
|
RadioPanel.cpp
|
anonbeat_guayadeque/src/ui/radios/RadioPanel.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "RadioPanel.h"
#include "Accelerators.h"
#include "AuiDockArt.h"
#include "EventCommandIds.h"
#include "Config.h"
#include "Images.h"
#include "LabelEditor.h"
#include "MainFrame.h"
#include "PlayListFile.h"
#include "Preferences.h"
//#include "RadioGenreEditor.h"
#include "RadioEditor.h"
#include "StatusBar.h"
#include "Settings.h"
#include "ShoutcastRadio.h"
#include "TagInfo.h"
#include "TuneInRadio.h"
#include "UserRadio.h"
#include "Utils.h"
#include <wx/wfstream.h>
#include <wx/tokenzr.h>
#include <wx/xml/xml.h>
namespace Guayadeque {
#define guRADIO_TIMER_TEXTSEARCH 1
#define guRADIO_TIMER_GENRESELECTED 2
#define guRADIO_TIMER_TEXTSEARCH_VALUE 500
// -------------------------------------------------------------------------------- //
// guRadioStationListBox
// -------------------------------------------------------------------------------- //
class guRadioStationListBox : public guListView
{
protected :
guRadioPanel * m_RadioPanel;
guRadioStations m_Radios;
int m_StationsOrder;
bool m_StationsOrderDesc;
virtual void CreateContextMenu( wxMenu * Menu ) const;
virtual wxString OnGetItemText( const int row, const int column ) const;
virtual void GetItemsList( void );
virtual wxArrayString GetColumnNames( void );
void OnConfigUpdated( wxCommandEvent &event );
void CreateAcceleratorTable();
public :
guRadioStationListBox( wxWindow * parent, guRadioPanel * radiopanel );
~guRadioStationListBox();
virtual void ReloadItems( bool reset = true );
virtual int inline GetItemId( const int row ) const;
virtual wxString inline GetItemName( const int row ) const;
void SetStationsOrder( int order );
bool GetSelected( guRadioStation * radiostation ) const;
void RefreshStations( void );
};
// -------------------------------------------------------------------------------- //
// guRadioGenreTreeCtrl
// -------------------------------------------------------------------------------- //
guRadioGenreTreeCtrl::guRadioGenreTreeCtrl( wxWindow * parent, guRadioPanel * radiopanel ) :
wxTreeCtrl( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
wxTR_DEFAULT_STYLE|wxTR_SINGLE|wxTR_HIDE_ROOT|wxTR_FULL_ROW_HIGHLIGHT|wxNO_BORDER )
{
m_RadioPanel = radiopanel;
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->RegisterObject( this );
m_ImageList = NULL;
m_RootId = AddRoot( wxT( "Radios" ), -1, -1, NULL );
SetIndent( 10 );
Bind( wxEVT_TREE_ITEM_MENU, &guRadioGenreTreeCtrl::OnContextMenu, this );
Bind( wxEVT_KEY_DOWN, &guRadioGenreTreeCtrl::OnKeyDown, this );
Bind( guConfigUpdatedEvent, &guRadioGenreTreeCtrl::OnConfigUpdated, this, ID_CONFIG_UPDATED );
CreateAcceleratorTable();
}
// -------------------------------------------------------------------------------- //
guRadioGenreTreeCtrl::~guRadioGenreTreeCtrl()
{
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->UnRegisterObject( this );
}
// -------------------------------------------------------------------------------- //
void guRadioGenreTreeCtrl::OnConfigUpdated( wxCommandEvent &event )
{
int Flags = event.GetInt();
if( Flags & guPREFERENCE_PAGE_FLAG_ACCELERATORS )
{
CreateAcceleratorTable();
}
}
// -------------------------------------------------------------------------------- //
void guRadioGenreTreeCtrl::CreateAcceleratorTable( void )
{
wxAcceleratorTable AccelTable;
wxArrayInt AliasAccelCmds;
wxArrayInt RealAccelCmds;
AliasAccelCmds.Add( ID_PLAYER_PLAYLIST_SEARCH );
RealAccelCmds.Add( ID_RADIO_SEARCH );
if( guAccelDoAcceleratorTable( AliasAccelCmds, RealAccelCmds, AccelTable ) )
{
SetAcceleratorTable( AccelTable );
}
}
// -------------------------------------------------------------------------------- //
void guRadioGenreTreeCtrl::ReloadProviders( guRadioProviderArray * radioproviders )
{
m_ImageList = new wxImageList();
DeleteChildren( m_RootId );
int Count = m_RadioPanel->GetProviderCount();
for( int Index = 0; Index < Count; Index++ )
{
guRadioProvider * RadioProvider = m_RadioPanel->GetProvider( Index );
RadioProvider->RegisterImages( m_ImageList );
RadioProvider->RegisterItems( this, m_RootId );
}
AssignImageList( m_ImageList );
}
// -------------------------------------------------------------------------------- //
void guRadioGenreTreeCtrl::OnContextMenu( wxTreeEvent &event )
{
wxMenu Menu;
m_RadioPanel->OnContextMenu( &Menu );
if( Menu.GetMenuItemCount() )
{
wxPoint Point = event.GetPoint();
PopupMenu( &Menu, Point );
}
event.Skip();
}
// -------------------------------------------------------------------------------- //
wxTreeItemId guRadioGenreTreeCtrl::GetItemId( wxTreeItemId * itemid, const int id )
{
wxTreeItemIdValue Cookie;
wxTreeItemId CurItem = GetFirstChild( * itemid, Cookie );
while( CurItem.IsOk() )
{
guRadioItemData * ItemData = ( guRadioItemData * ) GetItemData( CurItem );
if( ItemData )
{
if( ItemData->GetId() == id )
return CurItem;
}
else
{
wxTreeItemId ChildItem = GetItemId( &CurItem, id );
if( ChildItem.IsOk() )
return ChildItem;
}
CurItem = GetNextChild( * itemid, Cookie );
}
return CurItem;
}
// -------------------------------------------------------------------------------- //
void guRadioGenreTreeCtrl::OnKeyDown( wxKeyEvent &event )
{
if( event.GetKeyCode() == WXK_DELETE )
{
// TODO : Limit to genres and searches
wxCommandEvent CmdEvent( wxEVT_MENU, ID_RADIO_GENRE_DELETE );
wxPostEvent( this, CmdEvent );
return;
}
event.Skip();
}
// -------------------------------------------------------------------------------- //
// guRadioStationListBox
// -------------------------------------------------------------------------------- //
guRadioStationListBox::guRadioStationListBox( wxWindow * parent, guRadioPanel * radiopanel ) :
guListView( parent, wxLB_SINGLE | guLISTVIEW_COLUMN_SELECT|guLISTVIEW_COLUMN_SORTING )
{
m_RadioPanel = radiopanel;
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->RegisterObject( this );
m_StationsOrder = m_RadioPanel->GetStationsOrder();
m_StationsOrderDesc = m_RadioPanel->GetStationsOrderDesc();
wxArrayString ColumnNames = GetColumnNames();
// Create the Columns
int count = ColumnNames.Count();
for( int index = 0; index < count; index++ )
{
int ColId = Config->ReadNum( wxString::Format( wxT( "id%u" ), index ), index, wxT( "radios/columns/ids" ) );
wxString ColName = ColumnNames[ ColId ];
ColName += ( ( ColId == m_StationsOrder ) ? ( m_StationsOrderDesc ? wxT( " ▼" ) : wxT( " ▲" ) ) : wxEmptyString );
guListViewColumn * Column = new guListViewColumn(
ColName,
ColId,
Config->ReadNum( wxString::Format( wxT( "width%u" ), index ), 80, wxT( "radios/columns/widths" ) ),
Config->ReadBool( wxString::Format( wxT( "show%u" ), index ), true, wxT( "radios/columns/shows" ) )
);
InsertColumn( Column );
}
Bind( guConfigUpdatedEvent, &guRadioStationListBox::OnConfigUpdated, this, ID_CONFIG_UPDATED );
CreateAcceleratorTable();
ReloadItems();
}
// -------------------------------------------------------------------------------- //
guRadioStationListBox::~guRadioStationListBox()
{
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->UnRegisterObject( this );
int count = guRADIOSTATIONS_COLUMN_COUNT;
for( int index = 0; index < count; index++ )
{
Config->WriteNum( wxString::Format( wxT( "id%u" ), index ), ( * m_Columns )[ index ].m_Id, wxT( "radios/columns/ids" ) );
Config->WriteNum( wxString::Format( wxT( "width%u" ), index ), ( * m_Columns )[ index ].m_Width, wxT( "radios/columns/widths" ) );
Config->WriteBool( wxString::Format( wxT( "show%u" ), index ), ( * m_Columns )[ index ].m_Enabled, wxT( "radios/columns/shows" ) );
}
}
// -------------------------------------------------------------------------------- //
void guRadioStationListBox::OnConfigUpdated( wxCommandEvent &event )
{
int Flags = event.GetInt();
if( Flags & guPREFERENCE_PAGE_FLAG_ACCELERATORS )
{
CreateAcceleratorTable();
}
}
// -------------------------------------------------------------------------------- //
void guRadioStationListBox::CreateAcceleratorTable( void )
{
wxAcceleratorTable AccelTable;
wxArrayInt AliasAccelCmds;
wxArrayInt RealAccelCmds;
AliasAccelCmds.Add( ID_PLAYER_PLAYLIST_EDITTRACKS );
AliasAccelCmds.Add( ID_PLAYER_PLAYLIST_EDITLABELS );
AliasAccelCmds.Add( ID_TRACKS_PLAY );
AliasAccelCmds.Add( ID_TRACKS_ENQUEUE_AFTER_ALL );
AliasAccelCmds.Add( ID_TRACKS_ENQUEUE_AFTER_TRACK );
AliasAccelCmds.Add( ID_TRACKS_ENQUEUE_AFTER_ALBUM );
AliasAccelCmds.Add( ID_TRACKS_ENQUEUE_AFTER_ARTIST );
AliasAccelCmds.Add( ID_PLAYER_PLAYLIST_SEARCH );
RealAccelCmds.Add( ID_RADIO_USER_EDIT );
RealAccelCmds.Add( ID_RADIO_EDIT_LABELS );
RealAccelCmds.Add( ID_RADIO_PLAY );
RealAccelCmds.Add( ID_RADIO_ENQUEUE_AFTER_ALL );
RealAccelCmds.Add( ID_RADIO_ENQUEUE_AFTER_TRACK );
RealAccelCmds.Add( ID_RADIO_ENQUEUE_AFTER_ALBUM );
RealAccelCmds.Add( ID_RADIO_ENQUEUE_AFTER_ARTIST );
RealAccelCmds.Add( ID_RADIO_SEARCH );
if( guAccelDoAcceleratorTable( AliasAccelCmds, RealAccelCmds, AccelTable ) )
{
SetAcceleratorTable( AccelTable );
}
}
// -------------------------------------------------------------------------------- //
wxArrayString guRadioStationListBox::GetColumnNames( void )
{
wxArrayString ColumnNames;
ColumnNames.Add( _( "Name" ) );
ColumnNames.Add( _( "BitRate" ) );
ColumnNames.Add( _( "Listeners" ) );
ColumnNames.Add( _( "Format" ) );
ColumnNames.Add( _( "Now Playing" ) );
return ColumnNames;
}
// -------------------------------------------------------------------------------- //
wxString guRadioStationListBox::OnGetItemText( const int row, const int col ) const
{
guRadioStation * Radio;
Radio = &m_Radios[ row ];
switch( ( * m_Columns )[ col ].m_Id )
{
case guRADIOSTATIONS_COLUMN_NAME :
return Radio->m_Name;
case guRADIOSTATIONS_COLUMN_BITRATE :
if( Radio->m_BitRate )
return wxString::Format( wxT( "%u" ), Radio->m_BitRate );
break;
case guRADIOSTATIONS_COLUMN_LISTENERS :
if( Radio->m_Listeners )
return wxString::Format( wxT( "%u" ), Radio->m_Listeners );
break;
case guRADIOSTATIONS_COLUMN_TYPE :
return Radio->m_Type;
case guRADIOSTATIONS_COLUMN_NOWPLAYING :
return Radio->m_NowPlaying;
}
return wxEmptyString;
}
// -------------------------------------------------------------------------------- //
void guRadioStationListBox::GetItemsList( void )
{
m_RadioPanel->GetProviderStations( &m_Radios );
wxCommandEvent event( wxEVT_MENU, ID_MAINFRAME_UPDATE_SELINFO );
AddPendingEvent( event );
}
// -------------------------------------------------------------------------------- //
void guRadioStationListBox::ReloadItems( bool reset )
{
//
wxArrayInt Selection;
int FirstVisible = GetVisibleRowsBegin();
if( reset )
SetSelection( -1 );
else
Selection = GetSelectedItems( false );
m_Radios.Empty();
GetItemsList();
SetItemCount( m_Radios.Count() );
if( !reset )
{
SetSelectedItems( Selection );
ScrollToRow( FirstVisible );
}
RefreshAll();
}
// -------------------------------------------------------------------------------- //
void guRadioStationListBox::RefreshStations( void )
{
SetItemCount( m_Radios.Count() );
RefreshAll();
wxCommandEvent event( wxEVT_MENU, ID_MAINFRAME_UPDATE_SELINFO );
AddPendingEvent( event );
}
// -------------------------------------------------------------------------------- //
void guRadioStationListBox::CreateContextMenu( wxMenu * Menu ) const
{
wxMenuItem * MenuItem;
int SelCount = GetSelectedCount();
if( SelCount )
{
// Menu->AppendSeparator();
MenuItem = new wxMenuItem( Menu, ID_RADIO_PLAY,
wxString( _( "Play" ) ) + guAccelGetCommandKeyCodeString( ID_TRACKS_PLAY ),
_( "Play current selected songs" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_player_tiny_light_play ) );
Menu->Append( MenuItem );
MenuItem = new wxMenuItem( Menu, ID_RADIO_ENQUEUE_AFTER_ALL,
wxString( _( "Enqueue" ) ) + guAccelGetCommandKeyCodeString( ID_TRACKS_ENQUEUE_AFTER_ALL ),
_( "Add current selected songs to playlist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
Menu->Append( MenuItem );
wxMenu * EnqueueMenu = new wxMenu();
MenuItem = new wxMenuItem( EnqueueMenu, ID_RADIO_ENQUEUE_AFTER_TRACK,
wxString( _( "Current Track" ) ) + guAccelGetCommandKeyCodeString( ID_TRACKS_ENQUEUE_AFTER_TRACK ),
_( "Add current selected tracks to playlist after the current track" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem->Enable( SelCount );
MenuItem = new wxMenuItem( EnqueueMenu, ID_RADIO_ENQUEUE_AFTER_ALBUM,
wxString( _( "Current Album" ) ) + guAccelGetCommandKeyCodeString( ID_TRACKS_ENQUEUE_AFTER_ALBUM ),
_( "Add current selected tracks to playlist after the current album" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem->Enable( SelCount );
MenuItem = new wxMenuItem( EnqueueMenu, ID_RADIO_ENQUEUE_AFTER_ARTIST,
_( "Current Artist" ) + guAccelGetCommandKeyCodeString( ID_TRACKS_ENQUEUE_AFTER_ARTIST ),
_( "Add current selected tracks to playlist after the current artist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem->Enable( SelCount );
Menu->Append( wxID_ANY, _( "Enqueue After" ), EnqueueMenu );
Menu->AppendSeparator();
MenuItem = new wxMenuItem( Menu, ID_RADIO_ADD_TO_USER,
_( "Add to User Radio" ),
_( "Add selected radios as user radios" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_doc_save ) );
Menu->Append( MenuItem );
}
m_RadioPanel->OnContextMenu( Menu, true, SelCount );
}
// -------------------------------------------------------------------------------- //
int inline guRadioStationListBox::GetItemId( const int row ) const
{
return m_Radios[ row ].m_Id;
}
// -------------------------------------------------------------------------------- //
wxString inline guRadioStationListBox::GetItemName( const int row ) const
{
return m_Radios[ row ].m_Name;
}
// -------------------------------------------------------------------------------- //
void guRadioStationListBox::SetStationsOrder( int order )
{
if( m_StationsOrder != order )
{
m_StationsOrder = order;
m_StationsOrderDesc = ( order != 0 );
}
else
m_StationsOrderDesc = !m_StationsOrderDesc;
// m_Db->SetRadioStationsOrder( m_StationsOrder );
m_RadioPanel->SetStationsOrder( m_StationsOrder, m_StationsOrderDesc );
wxArrayString ColumnNames = GetColumnNames();
int count = ColumnNames.Count();
for( int index = 0; index < count; index++ )
{
int CurColId = GetColumnId( index );
SetColumnLabel( index,
ColumnNames[ CurColId ] + ( ( order == CurColId ) ? ( m_StationsOrderDesc ? wxT( " ▼" ) : wxT( " ▲" ) ) : wxEmptyString ) );
}
ReloadItems();
}
// -------------------------------------------------------------------------------- //
bool guRadioStationListBox::GetSelected( guRadioStation * radiostation ) const
{
if( !m_Radios.Count() )
return false;
int Selected = GetSelection();
if( Selected == wxNOT_FOUND )
{
Selected = 0;
}
radiostation->m_Id = m_Radios[ Selected ].m_Id;
radiostation->m_SCId = m_Radios[ Selected ].m_SCId;
radiostation->m_BitRate = m_Radios[ Selected ].m_BitRate;
radiostation->m_GenreId = m_Radios[ Selected ].m_GenreId;
radiostation->m_Source = m_Radios[ Selected ].m_Source;
radiostation->m_Link = m_Radios[ Selected ].m_Link;
radiostation->m_Listeners = m_Radios[ Selected ].m_Listeners;
radiostation->m_Name = m_Radios[ Selected ].m_Name;
radiostation->m_Type = m_Radios[ Selected ].m_Type;
return true;
}
// -------------------------------------------------------------------------------- //
// guRadioPanel
// -------------------------------------------------------------------------------- //
guRadioPanel::guRadioPanel( wxWindow * parent, guDbLibrary * db, guPlayerPanel * playerpanel ) :
guAuiManagerPanel( parent ),
m_GenreSelectTimer( this, guRADIO_TIMER_GENRESELECTED ),
m_TextChangedTimer( this, guRADIO_TIMER_TEXTSEARCH )
{
m_Db = new guDbRadios( guPATH_RADIOS_DBNAME );
m_PlayerPanel = playerpanel;
m_RadioPlayListLoadThread = NULL;
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->RegisterObject( this );
m_MinBitRate = Config->ReadNum( CONFIG_KEY_RADIOS_MIN_BITRATE, 128, CONFIG_PATH_RADIOS );
m_StationsOrder = Config->ReadNum( CONFIG_KEY_RADIOS_STATIONS_ORDER, 0, CONFIG_PATH_RADIOS );
m_StationsOrderDesc = Config->ReadNum( CONFIG_KEY_RADIOS_STATIONS_ORDERDESC, false, CONFIG_PATH_RADIOS );;
m_RadioProviders = new guRadioProviderArray();
InitPanelData();
m_VisiblePanels = Config->ReadNum( CONFIG_KEY_RADIOS_VISIBLE_PANELS, guPANEL_RADIO_VISIBLE_DEFAULT, CONFIG_PATH_RADIOS );
m_InstantSearchEnabled = Config->ReadBool( CONFIG_KEY_GENERAL_INSTANT_TEXT_SEARCH, true, CONFIG_PATH_GENERAL );
m_EnterSelectSearchEnabled = !Config->ReadBool( CONFIG_KEY_GENERAL_TEXT_SEARCH_ENTER, false, CONFIG_PATH_GENERAL );
wxBoxSizer * SearchSizer = new wxBoxSizer( wxHORIZONTAL );
wxPanel * SearchPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_InputTextCtrl = new wxSearchCtrl( SearchPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1, 28 ), wxTE_PROCESS_ENTER );
SearchSizer->Add( m_InputTextCtrl, 1, wxALIGN_CENTER|wxTOP|wxBOTTOM, 5 );
SearchPanel->SetSizer( SearchSizer );
//SearchPanel->Layout();
//SearchSizer->Fit( SearchPanel );
m_AuiManager.AddPane( SearchPanel,
wxAuiPaneInfo().Name( wxT( "RadioTextSearch" ) ).Caption( _( "Text Search" ) ).
Direction( 1 ).Layer( 2 ).Row( 0 ).Position( 0 ).BestSize( 111, 26 ).MinSize( 60, 26 ).MaxSize( -1, 26 ).
CloseButton( Config->ReadBool( CONFIG_KEY_GENERAL_SHOW_CLOSE_BUTTON, true, CONFIG_PATH_GENERAL ) ).
Dockable( true ).Top() );
wxPanel * GenrePanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer * GenreSizer = new wxBoxSizer( wxVERTICAL );
m_GenresTreeCtrl = new guRadioGenreTreeCtrl( GenrePanel, this );
GenreSizer->Add( m_GenresTreeCtrl, 1, wxEXPAND, 5 );
GenrePanel->SetSizer( GenreSizer );
//GenrePanel->Layout();
//GenreSizer->Fit( GenrePanel );
m_AuiManager.AddPane( GenrePanel,
wxAuiPaneInfo().Name( wxT( "RadioGenres" ) ).Caption( _( "Genre" ) ).
Direction( 4 ).Layer( 1 ).Row( 0 ).Position( 0 ).BestSize( 220, 60 ).MinSize( 60, 60 ).
CloseButton( Config->ReadBool( CONFIG_KEY_GENERAL_SHOW_CLOSE_BUTTON, true, CONFIG_PATH_GENERAL ) ).
Dockable( true ).Left() );
wxPanel * StationsPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer * StationsSizer = new wxBoxSizer( wxVERTICAL );
m_StationsListBox = new guRadioStationListBox( StationsPanel, this );
StationsSizer->Add( m_StationsListBox, 1, wxEXPAND, 5 );
StationsPanel->SetSizer( StationsSizer );
//StationsPanel->Layout();
//StationsSizer->Fit( StationsPanel );
m_AuiManager.AddPane( StationsPanel, wxAuiPaneInfo().Name( wxT( "RadioStations" ) ).Caption( _( "Stations" ) ).
MinSize( 50, 50 ).
CenterPane() );
wxString RadioLayout = Config->ReadStr( CONFIG_KEY_RADIOS_LAST_LAYOUT, wxEmptyString, CONFIG_PATH_RADIOS );
if( Config->GetIgnoreLayouts() || RadioLayout.IsEmpty() )
{
m_VisiblePanels = guPANEL_RADIO_VISIBLE_DEFAULT;
RadioLayout = wxT( "layout2|name=RadioTextSearch;caption=" ) + wxString( _( "Text Search" ) );
RadioLayout += wxT( ";state=2099196;dir=1;layer=2;row=0;pos=0;prop=100000;bestw=111;besth=26;minw=60;minh=26;maxw=-1;maxh=26;floatx=-1;floaty=-1;floatw=-1;floath=-1|" );
RadioLayout += wxT( "name=RadioGenres;caption=" ) + wxString( _( "Genres" ) ) + wxT( ";state=2099196;dir=4;layer=1;row=0;pos=0;prop=100000;bestw=220;besth=60;minw=60;minh=60;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|" );
// RadioLayout += wxT( "name=RadioLabels;caption=" ) + wxString( _( "Labels" ) ) + wxT( ";state=2099196;dir=4;layer=1;row=0;pos=1;prop=100000;bestw=220;besth=60;minw=60;minh=60;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|" );
RadioLayout += wxT( "name=RadioStations;caption=" ) + wxString( _( "Stations" ) ) + wxT( ";state=768;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=50;besth=50;minw=50;minh=50;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|" );
RadioLayout += wxT( "dock_size(1,2,0)=47|dock_size(4,1,0)=179|dock_size(5,0,0)=52|" );
//m_AuiManager.Update();
}
m_AuiManager.LoadPerspective( RadioLayout, true );
Bind( wxEVT_TIMER, &guRadioPanel::OnTextChangedTimer, this, guRADIO_TIMER_TEXTSEARCH );
Bind( wxEVT_TREE_SEL_CHANGED, &guRadioPanel::OnRadioGenreListSelected, this );
Bind( wxEVT_MENU, &guRadioPanel::OnRadioUpdate, this, ID_RADIO_DOUPDATE );
Bind( wxEVT_MENU, &guRadioPanel::OnRadioUpdated, this, ID_RADIO_UPDATED );
Bind( wxEVT_MENU, &guRadioPanel::OnRadioUpdateEnd, this, ID_RADIO_UPDATE_END );
Bind( wxEVT_MENU, &guRadioPanel::OnRadioCreateItems, this, ID_RADIO_CREATE_TREE_ITEM );
Bind( wxEVT_MENU, &guRadioPanel::OnLoadStationsFinished, this, ID_RADIO_LOADING_STATIONS_FINISHED );
m_StationsListBox->Bind( wxEVT_LISTBOX_DCLICK, &guRadioPanel::OnStationListActivated, this );
m_StationsListBox->Bind( wxEVT_LIST_COL_CLICK, &guRadioPanel::OnStationListBoxColClick, this );
m_InputTextCtrl->Bind( wxEVT_TEXT_ENTER, &guRadioPanel::OnSearchSelected, this );
m_InputTextCtrl->Bind( wxEVT_TEXT, &guRadioPanel::OnSearchActivated, this );
m_InputTextCtrl->Bind( wxEVT_SEARCHCTRL_CANCEL_BTN, &guRadioPanel::OnSearchCancelled, this );
Bind( wxEVT_MENU, &guRadioPanel::OnRadioStationsPlay, this, ID_RADIO_PLAY );
Bind( wxEVT_MENU, &guRadioPanel::OnRadioStationsEnqueue, this, ID_RADIO_ENQUEUE_AFTER_ALL, ID_RADIO_ENQUEUE_AFTER_ARTIST );
Bind( wxEVT_MENU, &guRadioPanel::OnStationPlayListLoaded, this, ID_RADIO_PLAYLIST_LOADED );
Bind( guConfigUpdatedEvent, &guRadioPanel::OnConfigUpdated, this, ID_CONFIG_UPDATED );
Bind( wxEVT_TIMER, &guRadioPanel::OnGenreSelectTimeout , this, guRADIO_TIMER_GENRESELECTED );
Bind( wxEVT_MENU, &guRadioPanel::OnRadioStationsAddToUser, this, ID_RADIO_ADD_TO_USER );
// Create shoutcast radio provider
RegisterRadioProvider( new guShoutcastRadioProvider( this, m_Db ) );
// Create tunein radio provider
RegisterRadioProvider( new guTuneInRadioProvider( this, m_Db ) );
// Create user radio provider
RegisterRadioProvider( new guUserRadioProvider( this, m_Db ), true );
}
// -------------------------------------------------------------------------------- //
guRadioPanel::~guRadioPanel()
{
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->UnRegisterObject( this );
Config->WriteNum( CONFIG_KEY_RADIOS_VISIBLE_PANELS, m_VisiblePanels, CONFIG_PATH_RADIOS );
Config->WriteStr( CONFIG_KEY_RADIOS_LAST_LAYOUT, m_AuiManager.SavePerspective(), CONFIG_PATH_RADIOS );
Config->WriteNum( CONFIG_KEY_RADIOS_STATIONS_ORDER, m_StationsOrder, CONFIG_PATH_RADIOS );
Config->WriteBool( CONFIG_KEY_RADIOS_STATIONS_ORDERDESC, m_StationsOrderDesc, CONFIG_PATH_RADIOS );;
m_RadioPlayListLoadThreadMutex.Lock();
if( m_RadioPlayListLoadThread )
{
m_RadioPlayListLoadThread->Pause();
m_RadioPlayListLoadThread->Delete();
}
m_RadioPlayListLoadThreadMutex.Unlock();
if( m_RadioProviders )
{
delete m_RadioProviders;
}
if( m_Db )
{
delete m_Db;
}
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::InitPanelData( void )
{
m_PanelNames.Add( wxT( "RadioTextSearch" ) );
m_PanelNames.Add( wxT( "RadioLabels" ) );
m_PanelNames.Add( wxT( "RadioGenres" ) );
m_PanelIds.Add( guPANEL_RADIO_TEXTSEARCH );
// m_PanelIds.Add( guPANEL_RADIO_LABELS );
m_PanelIds.Add( guPANEL_RADIO_GENRES );
m_PanelCmdIds.Add( ID_MENU_VIEW_RAD_TEXTSEARCH );
// m_PanelCmdIds.Add( ID_MENU_VIEW_RAD_LABELS );
m_PanelCmdIds.Add( ID_MENU_VIEW_RAD_GENRES );
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::OnConfigUpdated( wxCommandEvent &event )
{
int Flags = event.GetInt();
if( Flags & guPREFERENCE_PAGE_FLAG_GENERAL )
{
guConfig * Config = ( guConfig * ) guConfig::Get();
m_InstantSearchEnabled = Config->ReadBool( CONFIG_KEY_GENERAL_INSTANT_TEXT_SEARCH, true, CONFIG_PATH_GENERAL );
m_EnterSelectSearchEnabled = !Config->ReadBool( CONFIG_KEY_GENERAL_TEXT_SEARCH_ENTER, false, CONFIG_PATH_GENERAL );
}
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::RegisterRadioProvider( guRadioProvider * radioprovider, const bool reload )
{
m_RadioProviders->Add( radioprovider );
if( reload )
{
ReloadProviders();
}
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::UnRegisterRadioProvider( guRadioProvider * radioprovider, const bool reload )
{
// This makes de radioprovider to be destroyed
m_RadioProviders->Remove( radioprovider );
delete radioprovider;
if( reload )
{
ReloadProviders();
}
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::SetStationsOrder( const int columnid, const bool desc )
{
m_StationsOrder = columnid;
m_StationsOrderDesc = desc;
int Count = GetProviderCount();
for( int Index = 0; Index < Count; Index++ )
{
guRadioProvider * RadioProvider = GetProvider( Index );
RadioProvider->SetStationsOrder( columnid, desc );
}
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::ReloadProviders( void )
{
m_GenresTreeCtrl->ReloadProviders( m_RadioProviders );
}
// -------------------------------------------------------------------------------- //
guRadioProvider * guRadioPanel::GetProvider( const wxTreeItemId &itemid )
{
int Count = GetProviderCount();
for( int Index = 0; Index < Count; Index++ )
{
guRadioProvider * RadioProvider = GetProvider( Index );
if( RadioProvider->HasItemId( itemid ) )
{
return RadioProvider;
}
}
return NULL;
}
// -------------------------------------------------------------------------------- //
wxTreeItemId guRadioPanel::GetSelectedGenre( void )
{
return m_GenresTreeCtrl->GetSelection();
}
// -------------------------------------------------------------------------------- //
guRadioItemData * guRadioPanel::GetSelectedData( const wxTreeItemId &itemid )
{
return ( guRadioItemData * ) m_GenresTreeCtrl->GetItemData( itemid );
}
// -------------------------------------------------------------------------------- //
guRadioItemData * guRadioPanel::GetSelectedData( void )
{
return GetSelectedData( GetSelectedGenre() );
}
// -------------------------------------------------------------------------------- //
wxTreeItemId guRadioPanel::GetItemParent( const wxTreeItemId &item ) const
{
return m_GenresTreeCtrl->GetItemParent( item );
}
// -------------------------------------------------------------------------------- //
int guRadioPanel::GetProviderStations( guRadioStations * stations )
{
wxTreeItemId SelectedItemId = m_GenresTreeCtrl->GetSelection();
if( SelectedItemId.IsOk() )
{
guRadioProvider * RadioProvider = GetProvider( SelectedItemId );
if( RadioProvider )
{
return RadioProvider->GetStations( stations, m_MinBitRate );
}
}
return 0;
}
// -------------------------------------------------------------------------------- //
bool guRadioPanel::OnContextMenu( wxMenu * menu, const bool forstations, const int selcount )
{
wxTreeItemId SelectedItemId = m_GenresTreeCtrl->GetSelection();
if( SelectedItemId.IsOk() )
{
guRadioProvider * RadioProvider = GetProvider( SelectedItemId );
if( RadioProvider )
{
return RadioProvider->OnContextMenu( menu, SelectedItemId, forstations, selcount );
}
}
return false;
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::OnSearchActivated( wxCommandEvent& event )
{
if( m_TextChangedTimer.IsRunning() )
m_TextChangedTimer.Stop();
if( !m_InstantSearchEnabled )
return;
m_TextChangedTimer.Start( guRADIO_TIMER_TEXTSEARCH_VALUE, wxTIMER_ONE_SHOT );
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::OnSearchSelected( wxCommandEvent& event )
{
guConfig * Config = ( guConfig * ) guConfig::Get();
if( m_TextChangedTimer.IsRunning() )
m_TextChangedTimer.Stop();
if( !DoTextSearch() || !m_EnterSelectSearchEnabled || !m_InstantSearchEnabled )
return;
OnSelectStations( Config->ReadBool( CONFIG_KEY_GENERAL_ACTION_ENQUEUE, false, CONFIG_PATH_GENERAL ) );
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::OnSearchCancelled( wxCommandEvent &event ) // CLEAN SEARCH STR
{
m_InputTextCtrl->Clear();
if( !m_InstantSearchEnabled )
DoTextSearch();
}
// -------------------------------------------------------------------------------- //
bool guRadioPanel::DoTextSearch( void )
{
wxString SearchString = m_InputTextCtrl->GetValue();
guLogMessage( wxT( "Should do the search now: '%s'" ), SearchString.c_str() );
if( !SearchString.IsEmpty() )
{
wxArrayString Words = guSplitWords( SearchString );
int Count = m_RadioProviders->Count();
for( int Index = 0; Index < Count; Index++ )
{
guRadioProvider * RadioProvicer = GetProvider( Index );
RadioProvicer->SetSearchText( Words );
}
m_StationsListBox->ReloadItems();
m_InputTextCtrl->ShowCancelButton( true );
return true;
}
else
{
wxArrayString Words;
int Count = m_RadioProviders->Count();
for( int Index = 0; Index < Count; Index++ )
{
guRadioProvider * RadioProvicer = GetProvider( Index );
RadioProvicer->SetSearchText( Words );
}
m_StationsListBox->ReloadItems();
m_InputTextCtrl->ShowCancelButton( false );
}
return false;
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::OnTextChangedTimer( wxTimerEvent &event )
{
guLogMessage( wxT( "OnTextChangedTimer..." ) );
DoTextSearch();
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::OnStationListBoxColClick( wxListEvent &event )
{
int ColId = m_StationsListBox->GetColumnId( event.m_col );
m_StationsListBox->SetStationsOrder( ColId );
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::OnStationListActivated( wxCommandEvent &event )
{
guConfig * Config = ( guConfig * ) guConfig::Get();
OnSelectStations( Config->ReadBool( CONFIG_KEY_GENERAL_ACTION_ENQUEUE, false, CONFIG_PATH_GENERAL ) );
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::RefreshStations( void )
{
m_StationsListBox->RefreshStations();
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::OnRadioCreateItems( wxCommandEvent &event )
{
wxTreeItemId SelectedItemId = m_GenresTreeCtrl->GetSelection();
if( SelectedItemId.IsOk() )
{
guRadioProvider * RadioProvider = GetProvider( SelectedItemId );
if( RadioProvider )
{
wxArrayString Items = RadioProvider->GetPendingItems();
int Count = Items.Count();
//guLogMessage( wxT( "Processing %i Pending Items" ), Count );
for( int Index = 0; Index < Count; Index++ )
{
wxArrayString StationParam = wxStringTokenize( Items[ Index ], wxT( "|" ) );
if( StationParam.Count() == 2 )
{
m_GenresTreeCtrl->AppendItem( SelectedItemId, StationParam[ 0 ], -1, -1,
new guRadioItemData( -1, guRADIO_SOURCE_TUNEIN, StationParam[ 0 ], StationParam[ 1 ], 0 ) );
}
}
m_GenresTreeCtrl->Expand( SelectedItemId );
}
}
}
// -------------------------------------------------------------------------------- //
bool guRadioPanel::GetSelectedStation( guRadioStation * station )
{
return m_StationsListBox->GetSelected( station );
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::StartLoadingStations( void )
{
wxSetCursor( * wxHOURGLASS_CURSOR );
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::EndLoadingStations( void )
{
wxSetCursor( * wxSTANDARD_CURSOR );
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::OnLoadStationsFinished( wxCommandEvent &event )
{
EndLoadingStations();
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::OnGenreSelectTimeout( wxTimerEvent &event )
{
ReloadStations();
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::ReloadStations( void )
{
StartLoadingStations();
guRadioProvider * SelectedProvider = GetProvider( GetSelectedGenre() );
// If there was a previos search in progress from other provider cancell it...
int Count = m_RadioProviders->Count();
for( int Index = 0; Index < Count; Index++ )
{
guRadioProvider * RadioProvider = m_RadioProviders->Item( Index );
if( RadioProvider != SelectedProvider )
RadioProvider->CancellSearchStations();
}
m_StationsListBox->ReloadItems();
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::OnRadioGenreListSelected( wxTreeEvent &event )
{
m_GenreSelectTimer.Start( 50, wxTIMER_ONE_SHOT );
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::OnRadioUpdate( wxCommandEvent &event )
{
wxTreeItemId ItemId = GetSelectedGenre();
guRadioProvider * RadioProvider = GetProvider( ItemId );
if( RadioProvider )
{
RadioProvider->DoUpdate();
}
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::OnRadioUpdated( wxCommandEvent &event )
{
RefreshStations();
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::OnRadioUpdateEnd( wxCommandEvent &event )
{
//wxSetCursor( * wxSTANDARD_CURSOR );
//GenresListBox->Enable();
ReloadStations();
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::OnRadioStationsPlay( wxCommandEvent &event )
{
OnSelectStations( false );
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::OnRadioStationsEnqueue( wxCommandEvent &event )
{
OnSelectStations( true, event.GetId() - ID_RADIO_ENQUEUE_AFTER_ALL );
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::OnSelectStations( bool enqueue, const int aftercurrent )
{
wxString StationUrl;
guRadioStation RadioStation;
if( GetSelectedStation( &RadioStation ) )
{
guLogMessage( wxT( "Selected %s" ), RadioStation.m_Name.c_str() );
if( RadioStation.m_SCId != wxNOT_FOUND )
{
guShoutCast ShoutCast;
StationUrl = ShoutCast.GetStationUrl( RadioStation.m_SCId );
}
else
{
StationUrl = RadioStation.m_Link;
}
if( !StationUrl.IsEmpty() )
{
LoadStationUrl( StationUrl, enqueue, aftercurrent );
}
}
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::OnRadioStationsAddToUser( wxCommandEvent &event )
{
guRadioStation RadioStation;
if( GetSelectedStation( &RadioStation ) )
{
RadioStation.m_Id = wxNOT_FOUND;
if( RadioStation.m_SCId != wxNOT_FOUND )
{
guShoutCast ShoutCast;
RadioStation.m_Link = ShoutCast.GetStationUrl( RadioStation.m_SCId );
}
RadioStation.m_SCId = wxNOT_FOUND;
RadioStation.m_BitRate = 0;
RadioStation.m_GenreId = wxNOT_FOUND;
RadioStation.m_Source = 1;
RadioStation.m_Listeners = 0;
RadioStation.m_Type = wxEmptyString;
m_Db->SetRadioStation( &RadioStation );
}
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::EndStationPlayListLoaded( void )
{
wxMutexLocker MutexLocker( m_RadioPlayListLoadThreadMutex );
m_RadioPlayListLoadThread = NULL;
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::LoadStationUrl( const wxString &stationurl, const bool enqueue, const int aftercurrent )
{
wxMutexLocker MutexLocker( m_RadioPlayListLoadThreadMutex );
if( m_RadioPlayListLoadThread )
{
m_RadioPlayListLoadThread->Pause();
m_RadioPlayListLoadThread->Delete();
}
m_StationPlayListTracks.Empty();
m_RadioPlayListLoadThread = new guRadioPlayListLoadThread( this, stationurl.c_str(), &m_StationPlayListTracks, enqueue, aftercurrent );
if( !m_RadioPlayListLoadThread )
{
guLogError( wxT( "Could not create the download radio playlist thread" ) );
}
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::OnStationPlayListLoaded( wxCommandEvent &event )
{
bool Enqueue = event.GetInt();
int AfterCurrent = event.GetExtraLong();
if( m_StationPlayListTracks.Count() )
{
if( Enqueue )
{
m_PlayerPanel->AddToPlayList( m_StationPlayListTracks, true, AfterCurrent );
}
else
{
m_PlayerPanel->SetPlayList( m_StationPlayListTracks );
}
}
else
{
wxMessageBox( _( "There are not entries for this Radio Station" ) );
}
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::GetRadioCounter( wxLongLong * count )
{
* count = m_StationsListBox->GetItemCount();
}
// -------------------------------------------------------------------------------- //
void guRadioPanel::OnGoToSearch( wxCommandEvent &event )
{
if( !( m_VisiblePanels & guPANEL_RADIO_TEXTSEARCH ) )
{
ShowPanel( guPANEL_RADIO_TEXTSEARCH, true );
}
if( FindFocus() != m_InputTextCtrl )
m_InputTextCtrl->SetFocus();
}
// -------------------------------------------------------------------------------- //
bool guRadioPanel::GetListViewColumnData( const int id, int * index, int * width, bool * enabled )
{
return m_StationsListBox->GetColumnData( id, index, width, enabled );
}
// -------------------------------------------------------------------------------- //
bool guRadioPanel::SetListViewColumnData( const int id, const int index, const int width, const bool enabled, const bool refresh )
{
return m_StationsListBox->SetColumnData( id, index, width, enabled, refresh );
}
// -------------------------------------------------------------------------------- //
// guShoutcastSearch
// -------------------------------------------------------------------------------- //
guShoutcastSearch::guShoutcastSearch( wxWindow * parent, guRadioItemData * itemdata ) :
wxDialog( parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 435,237 ), wxDEFAULT_DIALOG_STYLE )
{
m_ItemData = itemdata;
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* MainSizer;
MainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* LabelSizer;
LabelSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _(" Radio Search ") ), wxVERTICAL );
wxBoxSizer* SearchSizer;
SearchSizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticText * SearchLabel = new wxStaticText( this, wxID_ANY, _("Search:"), wxDefaultPosition, wxDefaultSize, 0 );
SearchLabel->Wrap( -1 );
SearchSizer->Add( SearchLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_SearchTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_SearchTextCtrl->SetValue( m_ItemData->GetName() );
SearchSizer->Add( m_SearchTextCtrl, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
LabelSizer->Add( SearchSizer, 0, wxEXPAND, 5 );
m_SearchPlayChkBox = new wxCheckBox( this, wxID_ANY, _("Search in now playing info"), wxDefaultPosition, wxDefaultSize, 0 );
m_SearchPlayChkBox->SetValue( m_ItemData->GetFlags() & guRADIO_SEARCH_FLAG_NOWPLAYING );
LabelSizer->Add( m_SearchPlayChkBox, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_SearchGenreChkBox = new wxCheckBox( this, wxID_ANY, _("Search in genre names"), wxDefaultPosition, wxDefaultSize, 0 );
m_SearchGenreChkBox->SetValue( m_ItemData->GetFlags() & guRADIO_SEARCH_FLAG_GENRE );
LabelSizer->Add( m_SearchGenreChkBox, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_SearchNameChkBox = new wxCheckBox( this, wxID_ANY, _("Search in station names"), wxDefaultPosition, wxDefaultSize, 0 );
m_SearchNameChkBox->SetValue( m_ItemData->GetFlags() & guRADIO_SEARCH_FLAG_STATION );
LabelSizer->Add( m_SearchNameChkBox, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_AllGenresChkBox = new wxCheckBox( this, wxID_ANY, _("Include results from all genres"), wxDefaultPosition, wxDefaultSize, 0 );
m_AllGenresChkBox->SetValue( m_ItemData->GetFlags() & guRADIO_SEARCH_FLAG_ALLGENRES );
LabelSizer->Add( m_AllGenresChkBox, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
MainSizer->Add( LabelSizer, 1, wxEXPAND|wxALL, 5 );
wxStdDialogButtonSizer * ButtonsSizer = new wxStdDialogButtonSizer();
wxButton * ButtonsSizerOK = new wxButton( this, wxID_OK );
ButtonsSizer->AddButton( ButtonsSizerOK );
wxButton * ButtonsSizerCancel = new wxButton( this, wxID_CANCEL );
ButtonsSizer->AddButton( ButtonsSizerCancel );
ButtonsSizer->SetAffirmativeButton( ButtonsSizerOK );
ButtonsSizer->SetCancelButton( ButtonsSizerCancel );
ButtonsSizer->Realize();
MainSizer->Add( ButtonsSizer, 0, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
this->SetSizer( MainSizer );
this->Layout();
ButtonsSizerOK->SetDefault();
Bind( wxEVT_BUTTON, &guShoutcastSearch::OnOkButton, this, wxID_OK );
m_SearchTextCtrl->SetFocus();
}
// -------------------------------------------------------------------------------- //
guShoutcastSearch::~guShoutcastSearch()
{
Unbind( wxEVT_BUTTON, &guShoutcastSearch::OnOkButton, this, wxID_OK );
}
// -------------------------------------------------------------------------------- //
void guShoutcastSearch::OnOkButton( wxCommandEvent &event )
{
m_ItemData->SetName( m_SearchTextCtrl->GetValue() );
int flags = guRADIO_SEARCH_FLAG_NONE;
if( m_SearchPlayChkBox->IsChecked() )
flags |= guRADIO_SEARCH_FLAG_NOWPLAYING;
if( m_SearchGenreChkBox->IsChecked() )
flags |= guRADIO_SEARCH_FLAG_GENRE;
if( m_SearchNameChkBox->IsChecked() )
flags |= guRADIO_SEARCH_FLAG_STATION;
if( m_AllGenresChkBox->IsChecked() )
flags |= guRADIO_SEARCH_FLAG_ALLGENRES;
m_ItemData->SetFlags( flags );
event.Skip();
}
// -------------------------------------------------------------------------------- //
// guRadioPlayListLoadThread
// -------------------------------------------------------------------------------- //
guRadioPlayListLoadThread::guRadioPlayListLoadThread( guRadioPanel * radiopanel,
const wxChar * stationurl, guTrackArray * tracks, const bool enqueue, const int aftercurrent ) :
m_StationUrl( stationurl )
{
m_RadioPanel = radiopanel;
//m_StationUrl = stationurl;
m_Tracks = tracks;
m_Enqueue = enqueue;
m_AfterCurrent = aftercurrent;
if( Create() == wxTHREAD_NO_ERROR )
{
SetPriority( WXTHREAD_DEFAULT_PRIORITY - 10 );
Run();
}
}
// -------------------------------------------------------------------------------- //
guRadioPlayListLoadThread::~guRadioPlayListLoadThread()
{
if( !TestDestroy() )
{
m_RadioPanel->EndStationPlayListLoaded();
}
}
// -------------------------------------------------------------------------------- //
guRadioPlayListLoadThread::ExitCode guRadioPlayListLoadThread::Entry()
{
guTrack * NewSong;
guPlaylistFile PlayListFile;
if( TestDestroy() )
return 0;
guLogMessage( wxT( "StationUrl: '%s'" ), m_StationUrl.c_str() );
PlayListFile.Load( m_StationUrl );
int Count = PlayListFile.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( TestDestroy() )
break;
NewSong = new guTrack();
if( NewSong )
{
guPlaylistItem PlayListItem = PlayListFile.GetItem( Index );
NewSong->m_Type = guTRACK_TYPE_RADIOSTATION;
NewSong->m_FileName = PlayListItem.m_Location;
//NewSong->m_SongName = PlayList[ index ].m_Name;
NewSong->m_SongName = PlayListItem.m_Name;
//NewSong->m_AlbumName = RadioStation.m_Name;
NewSong->m_Length = 0;
NewSong->m_Rating = -1;
NewSong->m_Bitrate = 0;
//NewSong->CoverId = guPLAYLIST_RADIOSTATION;
NewSong->m_CoverId = 0;
NewSong->m_Year = 0;
m_Tracks->Add( NewSong );
}
}
if( !TestDestroy() )
{
//m_RadioPanel->StationUrlLoaded( Tracks, m_Enqueue, m_AsNext );
//guLogMessage( wxT( "Send Event for station '%s'" ), m_StationUrl.c_str() );
wxCommandEvent Event( wxEVT_MENU, ID_RADIO_PLAYLIST_LOADED );
Event.SetInt( m_Enqueue );
Event.SetExtraLong( m_AfterCurrent );
wxPostEvent( m_RadioPanel, Event );
}
return 0;
}
}
// -------------------------------------------------------------------------------- //
| 49,590
|
C++
|
.cpp
| 1,107
| 39.491418
| 244
| 0.579015
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
750,639
|
RadioProvider.cpp
|
anonbeat_guayadeque/src/ui/radios/RadioProvider.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "RadioProvider.h"
#include "RadioPanel.h"
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
guRadioProvider::guRadioProvider( guRadioPanel * radiopanel, guDbRadios * dbradios )
{
m_RadioPanel = radiopanel;
m_Db = dbradios;
}
// -------------------------------------------------------------------------------- //
guRadioProvider::~guRadioProvider()
{
}
}
// -------------------------------------------------------------------------------- //
| 1,569
|
C++
|
.cpp
| 36
| 42.194444
| 86
| 0.527177
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,640
|
RadioEditor.cpp
|
anonbeat_guayadeque/src/ui/radios/RadioEditor.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "RadioEditor.h"
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
guRadioEditor::guRadioEditor( wxWindow* parent, const wxString& title, const wxString &name, const wxString &link ) :
wxDialog( parent, wxID_ANY, title, wxDefaultPosition, wxSize( 400,150 ), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* MainSizer;
wxStaticText * NameLabel;
wxStaticText * LinkLabel;
wxStdDialogButtonSizer * StdBtnSizer;
wxButton* StdBtnSizerOK;
wxButton* StdBtnSizerCancel;
MainSizer = new wxBoxSizer( wxVERTICAL );
wxFlexGridSizer * FlexGridSizer;
FlexGridSizer = new wxFlexGridSizer( 2, 0, 0 );
FlexGridSizer->AddGrowableCol( 1 );
FlexGridSizer->SetFlexibleDirection( wxBOTH );
FlexGridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
NameLabel = new wxStaticText( this, wxID_ANY, _( "Name:" ), wxDefaultPosition, wxDefaultSize, 0 );
NameLabel->Wrap( -1 );
FlexGridSizer->Add( NameLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
m_NameTextCtrl = new wxTextCtrl( this, wxID_ANY, name, wxDefaultPosition, wxDefaultSize, 0 );
m_NameTextCtrl->SetFocus();
FlexGridSizer->Add( m_NameTextCtrl, 1, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 );
LinkLabel = new wxStaticText( this, wxID_ANY, _( "Link:" ), wxDefaultPosition, wxDefaultSize, 0 );
LinkLabel->Wrap( -1 );
FlexGridSizer->Add( LinkLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
m_LinkTextCtrl = new wxTextCtrl( this, wxID_ANY, link, wxDefaultPosition, wxDefaultSize, 0 );
FlexGridSizer->Add( m_LinkTextCtrl, 1, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 );
MainSizer->Add( FlexGridSizer, 1, wxEXPAND, 5 );
StdBtnSizer = new wxStdDialogButtonSizer();
StdBtnSizerOK = new wxButton( this, wxID_OK );
StdBtnSizer->AddButton( StdBtnSizerOK );
StdBtnSizerCancel = new wxButton( this, wxID_CANCEL );
StdBtnSizer->AddButton( StdBtnSizerCancel );
StdBtnSizer->SetAffirmativeButton( StdBtnSizerOK );
StdBtnSizer->SetCancelButton( StdBtnSizerCancel );
StdBtnSizer->Realize();
MainSizer->Add( StdBtnSizer, 0, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
this->SetSizer( MainSizer );
this->Layout();
StdBtnSizerOK->SetDefault();
m_NameTextCtrl->SetFocus();
}
// -------------------------------------------------------------------------------- //
guRadioEditor::~guRadioEditor()
{
}
}
// -------------------------------------------------------------------------------- //
| 3,669
|
C++
|
.cpp
| 72
| 47.555556
| 136
| 0.642458
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,641
|
ShoutcastRadio.cpp
|
anonbeat_guayadeque/src/ui/radios/ShoutcastRadio.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "ShoutcastRadio.h"
#include "Accelerators.h"
#include "Config.h"
#include "DbCache.h"
#include "DbRadios.h"
#include "Http.h"
#include "Images.h"
#include "MainFrame.h"
#include "RadioPanel.h"
#include "RadioEditor.h"
#include "RadioGenreEditor.h"
#include "StatusBar.h"
#include <wx/wfstream.h>
#include <wx/tokenzr.h>
#include <wx/xml/xml.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
guShoutcastRadioProvider::guShoutcastRadioProvider( guRadioPanel * radiopanel, guDbRadios * dbradios ) :
guRadioProvider( radiopanel, dbradios )
{
radiopanel->Bind( wxEVT_MENU, &guShoutcastRadioProvider::OnGenreAdd, this, ID_RADIO_GENRE_ADD );
radiopanel->Bind( wxEVT_MENU, &guShoutcastRadioProvider::OnGenreEdit, this, ID_RADIO_GENRE_EDIT );
radiopanel->Bind( wxEVT_MENU, &guShoutcastRadioProvider::OnGenreDelete, this, ID_RADIO_GENRE_DELETE );
radiopanel->Bind( wxEVT_MENU, &guShoutcastRadioProvider::OnSearchAdd, this, ID_RADIO_SEARCH_ADD );
radiopanel->Bind( wxEVT_MENU, &guShoutcastRadioProvider::OnSearchEdit, this, ID_RADIO_SEARCH_EDIT );
radiopanel->Bind( wxEVT_MENU, &guShoutcastRadioProvider::OnSearchDelete, this, ID_RADIO_SEARCH_DELETE );
}
// -------------------------------------------------------------------------------- //
guShoutcastRadioProvider::~guShoutcastRadioProvider()
{
}
// -------------------------------------------------------------------------------- //
bool guShoutcastRadioProvider::OnContextMenu( wxMenu * menu, const wxTreeItemId &itemid, const bool forstations, const int selcount )
{
guRadioItemData * ItemData = m_RadioPanel->GetSelectedData( itemid );
wxMenuItem * MenuItem;
if( ( ItemData && ( ItemData->GetSource() == guRADIO_SOURCE_SHOUTCAST_GENRE ) ) || ( itemid == m_ShoutcastGenreId ) )
{
if( selcount )
{
menu->AppendSeparator();
}
MenuItem = new wxMenuItem( menu, ID_RADIO_GENRE_ADD, _( "Add Genre" ), _( "Create a new genre" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
menu->Append( MenuItem );
if( ItemData )
{
MenuItem = new wxMenuItem( menu, ID_RADIO_GENRE_EDIT, _( "Edit genre" ), _( "Change the selected genre" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_edit ) );
menu->Append( MenuItem );
MenuItem = new wxMenuItem( menu, ID_RADIO_GENRE_DELETE, _( "Delete genre" ), _( "Delete the selected search" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_edit_clear ) );
menu->Append( MenuItem );
}
if( !selcount )
{
menu->AppendSeparator();
}
}
else if( ( ItemData && ( ItemData->GetSource() == guRADIO_SOURCE_SHOUTCAST_SEARCH ) ) || ( itemid == m_ShoutcastSearchId ) )
{
if( selcount )
{
menu->AppendSeparator();
}
MenuItem = new wxMenuItem( menu, ID_RADIO_SEARCH_ADD, _( "Add Search" ), _( "Create a new search" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
menu->Append( MenuItem );
if( ItemData )
{
MenuItem = new wxMenuItem( menu, ID_RADIO_SEARCH_EDIT, _( "Edit search" ), _( "Change the selected search" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_edit ) );
menu->Append( MenuItem );
MenuItem = new wxMenuItem( menu, ID_RADIO_SEARCH_DELETE, _( "Delete search" ), _( "Delete the selected search" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_edit_clear ) );
menu->Append( MenuItem );
}
if( !selcount )
{
menu->AppendSeparator();
}
}
if( selcount )
{
menu->AppendSeparator();
}
MenuItem = new wxMenuItem( menu, ID_RADIO_DOUPDATE, _( "Update Radio Stations" ), _( "Update the radio station lists" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_reload ) );
menu->Append( MenuItem );
return true;
}
// -------------------------------------------------------------------------------- //
void guShoutcastRadioProvider::RegisterImages( wxImageList * imagelist )
{
imagelist->Add( guImage( guIMAGE_INDEX_tiny_shoutcast ) );
m_ImageIds.Add( imagelist->GetImageCount() - 1 );
imagelist->Add( guImage( guIMAGE_INDEX_search ) );
m_ImageIds.Add( imagelist->GetImageCount() - 1 );
}
// -------------------------------------------------------------------------------- //
void guShoutcastRadioProvider::RegisterItems( guRadioGenreTreeCtrl * genretreectrl, wxTreeItemId &rootitem )
{
m_ShoutcastId = genretreectrl->AppendItem( rootitem, wxT( "Shoutcast" ), m_ImageIds[ 0 ], m_ImageIds[ 0 ], NULL );
m_ShoutcastGenreId = genretreectrl->AppendItem( m_ShoutcastId, _( "Genre" ), m_ImageIds[ 0 ], m_ImageIds[ 0 ], NULL );
m_ShoutcastSearchId = genretreectrl->AppendItem( m_ShoutcastId, _( "Searches" ), m_ImageIds[ 1 ], m_ImageIds[ 1 ], NULL );
}
// -------------------------------------------------------------------------------- //
bool guShoutcastRadioProvider::HasItemId( const wxTreeItemId &itemid )
{
wxTreeItemId ItemId = itemid;
while( ItemId.IsOk() )
{
if( ItemId == m_ShoutcastId )
return true;
ItemId = m_RadioPanel->GetItemParent( ItemId );
}
return false;
}
// -------------------------------------------------------------------------------- //
int guShoutcastRadioProvider::GetStations( guRadioStations * stations, const long minbitrate )
{
wxTreeItemId SelectedItem = m_RadioPanel->GetSelectedGenre();
guRadioGenreTreeCtrl * RadioTreeCtrl = m_RadioPanel->GetTreeCtrl();
if( SelectedItem == m_ShoutcastId )
{
m_Db->SetRadioSourceFilter( guRADIO_SOURCE_SHOUTCAST_GENRE );
}
else if( SelectedItem == m_ShoutcastGenreId )
{
RadioTreeCtrl->DeleteChildren( m_ShoutcastGenreId );
guListItems RadioGenres;
m_Db->GetRadioGenres( guRADIO_SOURCE_SHOUTCAST_GENRE, &RadioGenres );
int Count = RadioGenres.Count();
for( int Index = 0; Index < Count; Index++ )
{
RadioTreeCtrl->AppendItem( m_ShoutcastGenreId, RadioGenres[ Index ].m_Name, -1, -1,
new guRadioItemData( RadioGenres[ Index ].m_Id, guRADIO_SOURCE_SHOUTCAST_GENRE, RadioGenres[ Index ].m_Name, 0 ) );
}
m_Db->SetRadioSourceFilter( guRADIO_SOURCE_SHOUTCAST_GENRE );
}
else if( SelectedItem == m_ShoutcastSearchId )
{
RadioTreeCtrl->DeleteChildren( m_ShoutcastSearchId );
guListItems RadioSearchs;
wxArrayInt RadioFlags;
m_Db->GetRadioGenres( guRADIO_SOURCE_SHOUTCAST_SEARCH, &RadioSearchs, true, &RadioFlags );
int Count = RadioSearchs.Count();
for( int Index = 0; Index < Count; Index++ )
{
RadioTreeCtrl->AppendItem( m_ShoutcastSearchId, RadioSearchs[ Index ].m_Name, -1, -1,
new guRadioItemData( RadioSearchs[ Index ].m_Id, guRADIO_SOURCE_SHOUTCAST_SEARCH, RadioSearchs[ Index ].m_Name, RadioFlags[ Index ] ) );
}
m_Db->SetRadioSourceFilter( guRADIO_SOURCE_SHOUTCAST_SEARCH );
}
else
{
guRadioItemData * ItemData = m_RadioPanel->GetSelectedData( SelectedItem );
if( ItemData )
{
m_Db->SetRadioSourceFilter( ItemData->GetSource() );
wxArrayInt RadioGenres;
RadioGenres.Add( ItemData->GetId() );
m_Db->SetRadioGenresFilters( RadioGenres );
}
}
// if( RadioTreeCtrl->ItemHasChildren( SelectedItem ) )
// {
// if( !RadioTreeCtrl->IsExpanded( SelectedItem ) )
// RadioTreeCtrl->Expand( SelectedItem );
// }
m_Db->GetRadioStations( stations );
m_RadioPanel->EndLoadingStations();
return stations->Count();
}
// -------------------------------------------------------------------------------- //
void guShoutcastRadioProvider::DoUpdate( void )
{
guLogMessage( wxT( "ShoutcastRadioProvider::DoUpdate" ) );
wxTreeItemId ItemId;
wxArrayInt GenresIds;
guRadioItemData * ItemData;
int Source = guRADIO_SOURCE_SHOUTCAST_GENRE;
ItemId = m_RadioPanel->GetSelectedGenre();
if( ItemId.IsOk() )
{
ItemData = m_RadioPanel->GetSelectedData( ItemId );
if( ItemData )
{
Source = ItemData->GetSource();
GenresIds.Add( ItemData->GetId() );
}
else if( ItemId == m_ShoutcastSearchId )
{
Source = guRADIO_SOURCE_SHOUTCAST_SEARCH;
guListItems Genres;
m_Db->GetRadioGenres( Source, &Genres );
int count = Genres.Count();
for( int index = 0; index < count; index++ )
{
GenresIds.Add( Genres[ index ].m_Id );
}
}
}
if( !GenresIds.Count() )
{
guListItems Genres;
m_Db->GetRadioGenres( guRADIO_SOURCE_SHOUTCAST_GENRE, &Genres );
int count = Genres.Count();
for( int index = 0; index < count; index++ )
{
GenresIds.Add( Genres[ index ].m_Id );
}
}
if( GenresIds.Count() )
{
guMainFrame * MainFrame = ( guMainFrame * ) guMainFrame::GetMainFrame();
int GaugeId = ( ( guStatusBar * ) MainFrame->GetStatusBar() )->AddGauge( _( "Radios" ) );
guShoutcastUpdateThread * UpdateRadiosThread = new guShoutcastUpdateThread( m_Db, m_RadioPanel, GenresIds, Source, GaugeId );
if( !UpdateRadiosThread )
{
guLogError( wxT( "Could not create the radio update thread" ) );
}
}
}
// -------------------------------------------------------------------------------- //
void guShoutcastRadioProvider::SetSearchText( const wxArrayString &texts )
{
guLogMessage( wxT( "SetSearchText" ) );
m_Db->SetRaTeFilters( texts );
}
// -------------------------------------------------------------------------------- //
void guShoutcastRadioProvider::OnGenreAdd( wxCommandEvent &event )
{
guRadioGenreEditor * RadioGenreEditor = new guRadioGenreEditor( m_RadioPanel, m_Db );
if( RadioGenreEditor )
{
bool NeedReload = false;
//
if( RadioGenreEditor->ShowModal() == wxID_OK )
{
wxArrayString NewGenres;
wxArrayInt DelGenres;
RadioGenreEditor->GetGenres( NewGenres, DelGenres );
int Count = NewGenres.Count();
if( Count )
{
//
for( int Index = 0; Index < Count; Index++ )
{
m_Db->AddRadioGenre( NewGenres[ Index ], guRADIO_SOURCE_SHOUTCAST_GENRE, guRADIO_SEARCH_FLAG_NONE );
}
NeedReload = true;
}
if( ( Count = DelGenres.Count() ) )
{
for( int Index = 0; Index < Count; Index++ )
{
m_Db->DelRadioGenre( DelGenres[ Index ] );
}
NeedReload = true;
}
if( NeedReload )
m_RadioPanel->ReloadStations();
}
//
RadioGenreEditor->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guShoutcastRadioProvider::OnGenreEdit( wxCommandEvent &event )
{
wxTreeItemId ItemId = m_RadioPanel->GetSelectedGenre();
if( ItemId.IsOk() )
{
guRadioItemData * RadioGenreData = m_RadioPanel->GetSelectedData( ItemId );
if( RadioGenreData )
{
// Get the Index of the First Selected Item
wxTextEntryDialog * EntryDialog = new wxTextEntryDialog( m_RadioPanel, _( "Genre Name: " ), _( "Enter the new Genre Name" ), RadioGenreData->GetName() );
if( EntryDialog->ShowModal() == wxID_OK )
{
m_Db->SetRadioGenre( RadioGenreData->GetId(), EntryDialog->GetValue() );
guRadioGenreTreeCtrl * RadioTreeCtrl = m_RadioPanel->GetTreeCtrl();
RadioTreeCtrl->SelectItem( m_ShoutcastGenreId );
m_RadioPanel->ReloadStations();
}
EntryDialog->Destroy();
}
}
}
// -------------------------------------------------------------------------------- //
void guShoutcastRadioProvider::OnGenreDelete( wxCommandEvent &event )
{
wxArrayTreeItemIds ItemIds;
guRadioGenreTreeCtrl * RadioTreeCtrl = m_RadioPanel->GetTreeCtrl();
int count = RadioTreeCtrl->GetSelections( ItemIds );
if( count )
{
if( wxMessageBox( _( "Are you sure to delete the selected radio genres?" ),
_( "Confirm" ),
wxICON_QUESTION|wxYES_NO|wxNO_DEFAULT, m_RadioPanel ) == wxYES )
{
guRadioItemData * RadioGenreData;
for( int index = 0; index < count; index++ )
{
RadioGenreData = m_RadioPanel->GetSelectedData( ItemIds[ index ] );
if( RadioGenreData )
{
m_Db->DelRadioGenre( RadioGenreData->GetId() );
}
}
RadioTreeCtrl->SelectItem( m_ShoutcastGenreId );
m_RadioPanel->ReloadStations();
}
}
}
// -------------------------------------------------------------------------------- //
void guShoutcastRadioProvider::OnSearchAdd( wxCommandEvent &event )
{
guRadioItemData ShoutcastItem( 0, guRADIO_SOURCE_SHOUTCAST_SEARCH, wxEmptyString, guRADIO_SEARCH_FLAG_DEFAULT );
guShoutcastSearch * ShoutcastSearch = new guShoutcastSearch( m_RadioPanel, &ShoutcastItem );
if( ShoutcastSearch )
{
if( ShoutcastSearch->ShowModal() == wxID_OK )
{
int RadioSearchId = m_Db->AddRadioGenre( ShoutcastItem.GetName(), guRADIO_SOURCE_SHOUTCAST_SEARCH, ShoutcastItem.GetFlags() );
m_RadioPanel->ReloadStations();
guRadioGenreTreeCtrl * RadioTreeCtrl = m_RadioPanel->GetTreeCtrl();
RadioTreeCtrl->Expand( m_ShoutcastSearchId );
wxTreeItemId ItemId = RadioTreeCtrl->GetItemId( &m_ShoutcastSearchId, RadioSearchId );
if( ItemId.IsOk() )
{
RadioTreeCtrl->SelectItem( ItemId );
// OnRadioUpdate( event );
}
}
ShoutcastSearch->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guShoutcastRadioProvider::OnSearchEdit( wxCommandEvent &event )
{
guRadioItemData * ItemData = m_RadioPanel->GetSelectedData();
if( ItemData && ItemData->GetSource() == guRADIO_SOURCE_SHOUTCAST_SEARCH )
{
guShoutcastSearch * ShoutcastSearch = new guShoutcastSearch( m_RadioPanel, ItemData );
if( ShoutcastSearch )
{
if( ShoutcastSearch->ShowModal() == wxID_OK )
{
m_Db->SetRadioGenre( ItemData->GetId(), ItemData->GetName(), guRADIO_SOURCE_SHOUTCAST_SEARCH, ItemData->GetFlags() );
m_RadioPanel->ReloadStations();
}
ShoutcastSearch->Destroy();
}
}
}
// -------------------------------------------------------------------------------- //
void guShoutcastRadioProvider::OnSearchDelete( wxCommandEvent &event )
{
wxArrayTreeItemIds ItemIds;
guRadioGenreTreeCtrl * RadioTreeCtrl = m_RadioPanel->GetTreeCtrl();
int count = RadioTreeCtrl->GetSelections( ItemIds );
if( count )
{
if( wxMessageBox( _( "Are you sure to delete the selected radio searches?" ),
_( "Confirm" ),
wxICON_QUESTION|wxYES_NO|wxNO_DEFAULT, m_RadioPanel ) == wxYES )
{
guRadioItemData * RadioGenreData;
for( int index = 0; index < count; index++ )
{
RadioGenreData = m_RadioPanel->GetSelectedData( ItemIds[ index ] );
if( RadioGenreData )
{
m_Db->DelRadioGenre( RadioGenreData->GetId() );
}
}
m_RadioPanel->ReloadStations();
}
}
}
// -------------------------------------------------------------------------------- //
// guShoutcastUpdateThread
// -------------------------------------------------------------------------------- //
bool inline guListItemsSearchName( guListItems &items, const wxString &name )
{
int Count = items.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( items[ Index ].m_Name.Lower() == name )
{
return true;
}
}
return false;
}
// -------------------------------------------------------------------------------- //
guShoutcastUpdateThread::guShoutcastUpdateThread( guDbRadios * db, guRadioPanel * radiopanel,
const wxArrayInt &ids, const int source, int gaugeid )
{
m_Db = db;
m_RadioPanel = radiopanel;
m_Ids = ids;
m_Source = source;
m_GaugeId = gaugeid;
if( Create() == wxTHREAD_NO_ERROR )
{
SetPriority( WXTHREAD_DEFAULT_PRIORITY - 30 );
Run();
}
}
// -------------------------------------------------------------------------------- //
void guShoutcastUpdateThread::CheckRadioStationsFilters( const int flags, const wxString &text, guRadioStations &stations )
{
guListItems RadioGenres;
m_Db->GetRadioGenres( guRADIO_SOURCE_SHOUTCAST_GENRE, &RadioGenres );
int Count = stations.Count();
if( Count )
{
for( int Index = Count - 1; Index >= 0; Index-- )
{
if( ( flags & guRADIO_SEARCH_FLAG_NOWPLAYING ) )
{
if( stations[ Index ].m_NowPlaying.Lower().Find( text ) == wxNOT_FOUND )
{
stations.RemoveAt( Index );
continue;
}
}
if( ( flags & guRADIO_SEARCH_FLAG_GENRE ) )
{
if( stations[ Index ].m_GenreName.Lower().Find( text ) == wxNOT_FOUND )
{
stations.RemoveAt( Index );
continue;
}
}
if( ( flags & guRADIO_SEARCH_FLAG_STATION ) )
{
if( stations[ Index ].m_Name.Lower().Find( text ) == wxNOT_FOUND )
{
stations.RemoveAt( Index );
continue;
}
}
// Need to check if the station genre already existed
if( !( flags & guRADIO_SEARCH_FLAG_ALLGENRES ) )
{
if( !guListItemsSearchName( RadioGenres, stations[ Index ].m_GenreName.Lower() ) )
{
stations.RemoveAt( Index );
}
}
}
}
}
// -------------------------------------------------------------------------------- //
guShoutcastUpdateThread::ExitCode guShoutcastUpdateThread::Entry()
{
// guListItems Genres;
wxCommandEvent event( wxEVT_MENU, ID_STATUSBAR_GAUGE_SETMAX );
guShoutCast * ShoutCast = new guShoutCast();
guRadioStations RadioStations;
if( ShoutCast )
{
//
guConfig * Config = ( guConfig * ) guConfig::Get();
long MinBitRate;
MinBitRate = Config->ReadNum( CONFIG_KEY_RADIOS_MIN_BITRATE, 128, CONFIG_PATH_RADIOS );
// m_Db->GetRadioGenres( &Genres, false );
// guLogMessage( wxT ( "Loaded the genres" ) );
guListItems Genres;
wxArrayInt Flags;
m_Db->GetRadioGenresList( m_Source, m_Ids, &Genres, &Flags );
//
m_Db->DelRadioStations( m_Source, m_Ids );
//guLogMessage( wxT( "Deleted all radio stations" ) );
int count = Genres.Count();
event.SetInt( m_GaugeId );
event.SetExtraLong( count );
wxPostEvent( guMainFrame::GetMainFrame(), event );
for( int index = 0; index < count; index++ )
{
guLogMessage( wxT( "Updating radiostations for genre '%s'" ), Genres[ index ].m_Name.c_str() );
ShoutCast->GetStations( m_Source, Flags[ index ], Genres[ index ].m_Name, Genres[ index ].m_Id, &RadioStations, MinBitRate );
if( m_Source == guRADIO_SOURCE_SHOUTCAST_SEARCH )
{
CheckRadioStationsFilters( Flags[ index ], Genres[ index ].m_Name.Lower(), RadioStations );
}
m_Db->SetRadioStations( &RadioStations );
RadioStations.Clear();
//wxCommandEvent event( wxEVT_MENU, ID_RADIO_UPDATED );
event.SetId( ID_RADIO_UPDATED );
wxPostEvent( m_RadioPanel, event );
Sleep( 30 ); // Its wxThread::Sleep
// wxCommandEvent event2( wxEVT_MENU, ID_STATUSBAR_GAUGE_UPDATE );
event.SetId( ID_STATUSBAR_GAUGE_UPDATE );
event.SetInt( m_GaugeId );
event.SetExtraLong( index );
wxPostEvent( guMainFrame::GetMainFrame(), event );
}
delete ShoutCast;
}
// wxCommandEvent event( wxEVT_MENU, ID_RADIO_UPDATE_END );
event.SetId( ID_RADIO_UPDATE_END );
wxPostEvent( m_RadioPanel, event );
// wxMilliSleep( 1 );
// wxCommandEvent event2( wxEVT_MENU, ID_STATUSBAR_GAUGE_REMOVE );
event.SetId( ID_STATUSBAR_GAUGE_REMOVE );
event.SetInt( m_GaugeId );
wxPostEvent( guMainFrame::GetMainFrame(), event );
//
return 0;
}
}
// -------------------------------------------------------------------------------- //
| 22,607
|
C++
|
.cpp
| 538
| 33.95539
| 165
| 0.554176
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
750,642
|
RadioGenreEditor.cpp
|
anonbeat_guayadeque/src/ui/radios/RadioGenreEditor.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "RadioGenreEditor.h"
#include "Shoutcast.h"
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
guRadioGenreEditor::guRadioGenreEditor( wxWindow * parent, guDbRadios * db ) :
wxDialog( parent, wxID_ANY, _("Radio Genre Editor"), wxDefaultPosition, wxSize( 280,360 ), wxDEFAULT_DIALOG_STYLE )
{
m_Db = db;
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* MainSizer;
MainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* ListBoxSizer;
ListBoxSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _(" Genres ") ), wxVERTICAL );
guShoutCast ShoutCast;
m_RadioGenres = ShoutCast.GetGenres();
m_CheckListBox = new wxCheckListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_RadioGenres, wxLB_MULTIPLE|wxLB_NEEDED_SB|wxNO_BORDER );
ListBoxSizer->Add( m_CheckListBox, 1, wxALL|wxEXPAND, 5 );
wxBoxSizer* InputSizer;
InputSizer = new wxBoxSizer( wxHORIZONTAL );
m_InputStaticText = new wxStaticText( this, wxID_ANY, _("Other:"), wxDefaultPosition, wxDefaultSize, 0 );
m_InputStaticText->Wrap( -1 );
InputSizer->Add( m_InputStaticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_InputTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
InputSizer->Add( m_InputTextCtrl, 1, wxALL, 5 );
ListBoxSizer->Add( InputSizer, 0, wxEXPAND, 5 );
MainSizer->Add( ListBoxSizer, 1, wxEXPAND|wxALL, 5 );
wxStdDialogButtonSizer* TagEditorBtnSizer;
wxButton* TagEditorBtnSizerOK;
wxButton* TagEditorBtnSizerCancel;
TagEditorBtnSizer = new wxStdDialogButtonSizer();
TagEditorBtnSizerOK = new wxButton( this, wxID_OK );
TagEditorBtnSizer->AddButton( TagEditorBtnSizerOK );
TagEditorBtnSizerCancel = new wxButton( this, wxID_CANCEL );
TagEditorBtnSizer->AddButton( TagEditorBtnSizerCancel );
TagEditorBtnSizer->SetAffirmativeButton( TagEditorBtnSizerOK );
TagEditorBtnSizer->SetCancelButton( TagEditorBtnSizerCancel );
TagEditorBtnSizer->Realize();
MainSizer->Add( TagEditorBtnSizer, 0, wxRIGHT|wxBOTTOM|wxEXPAND, 5 );
this->SetSizer( MainSizer );
this->Layout();
TagEditorBtnSizerOK->SetDefault();
// By default enable already added items
m_Db->GetRadioGenres( guRADIO_SOURCE_SHOUTCAST_GENRE, &m_AddedGenres, false );
int count = m_AddedGenres.Count();
for( int index = 0; index < count; index ++ )
{
int item = m_RadioGenres.Index( m_AddedGenres[ index ].m_Name );
if( item != wxNOT_FOUND )
m_CheckListBox->Check( item );
}
m_CheckListBox->SetFocus();
}
// -------------------------------------------------------------------------------- //
int guListItemsFind( guListItems &items, const wxString &name )
{
int Count = items.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( items[ Index ].m_Name == name )
return Index;
}
return wxNOT_FOUND;
}
// -------------------------------------------------------------------------------- //
int guListItemsFind( guListItems &items, const int &id )
{
int Count = items.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( items[ Index ].m_Id == id )
return Index;
}
return wxNOT_FOUND;
}
// -------------------------------------------------------------------------------- //
void guRadioGenreEditor::GetGenres( wxArrayString &addedgenres, wxArrayInt &deletedgenres )
{
int count = m_CheckListBox->GetCount();
for( int index = 0; index < count; index++ )
{
if( m_CheckListBox->IsChecked( index ) )
{
if( guListItemsFind( m_AddedGenres, m_RadioGenres[ index ] ) == wxNOT_FOUND )
addedgenres.Add( m_RadioGenres[ index ] );
}
else
{
int Pos;
if( ( Pos = guListItemsFind( m_AddedGenres, m_RadioGenres[ index ] ) ) != wxNOT_FOUND )
{
deletedgenres.Add( m_AddedGenres[ Pos ].m_Id );
}
}
}
if( !m_InputTextCtrl->IsEmpty() )
{
if( guListItemsFind( m_AddedGenres, m_InputTextCtrl->GetValue() ) == wxNOT_FOUND )
addedgenres.Add( m_InputTextCtrl->GetValue() );
}
}
// -------------------------------------------------------------------------------- //
guRadioGenreEditor::~guRadioGenreEditor()
{
}
}
// -------------------------------------------------------------------------------- //
| 5,529
|
C++
|
.cpp
| 127
| 39.338583
| 146
| 0.602307
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
750,643
|
TuneInRadio.cpp
|
anonbeat_guayadeque/src/ui/radios/TuneInRadio.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "TuneInRadio.h"
#include "Accelerators.h"
#include "DbCache.h"
#include "DbRadios.h"
#include "Http.h"
#include "Images.h"
#include "RadioPanel.h"
#include "RadioEditor.h"
#include <wx/sstream.h>
#include <wx/tokenzr.h>
#include <wx/wfstream.h>
#include <wx/xml/xml.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
guTuneInRadioProvider::guTuneInRadioProvider( guRadioPanel * radiopanel, guDbRadios * dbradios ) :
guRadioProvider( radiopanel, dbradios )
{
m_ReadStationsThread = NULL;
}
// -------------------------------------------------------------------------------- //
guTuneInRadioProvider::~guTuneInRadioProvider()
{
}
// -------------------------------------------------------------------------------- //
bool guTuneInRadioProvider::OnContextMenu( wxMenu * menu, const wxTreeItemId &itemid, const bool forstations, const int selcount )
{
return true;
}
// -------------------------------------------------------------------------------- //
void guTuneInRadioProvider::RegisterImages( wxImageList * imagelist )
{
imagelist->Add( guImage( guIMAGE_INDEX_tiny_tunein ) );
m_ImageIds.Add( imagelist->GetImageCount() - 1 );
}
// -------------------------------------------------------------------------------- //
void guTuneInRadioProvider::RegisterItems( guRadioGenreTreeCtrl * genretreectrl, wxTreeItemId &rootitem )
{
guRadioItemData * TuneInData = new guRadioItemData( -1, guRADIO_SOURCE_TUNEIN, wxT( "tunein" ), wxT( guTUNEIN_BASE_URL ), 0 );
m_TuneInId = genretreectrl->AppendItem( rootitem, wxT( "tunein" ), m_ImageIds[ 0 ], m_ImageIds[ 0 ], TuneInData );
}
// -------------------------------------------------------------------------------- //
bool guTuneInRadioProvider::HasItemId( const wxTreeItemId &itemid )
{
wxTreeItemId ItemId = itemid;
while( ItemId.IsOk() )
{
if( ItemId == m_TuneInId )
return true;
ItemId = m_RadioPanel->GetItemParent( ItemId );
}
return false;
}
// -------------------------------------------------------------------------------- //
void guTuneInRadioProvider::EndReadStationsThread( void )
{
wxMutexLocker MutexLocker( m_ReadStationsThreadMutex );
m_ReadStationsThread = NULL;
// m_RadioPanel->EndLoadingStations();
wxCommandEvent Event( wxEVT_MENU, ID_RADIO_LOADING_STATIONS_FINISHED );
wxPostEvent( m_RadioPanel, Event );
}
// -------------------------------------------------------------------------------- //
int guTuneInRadioProvider::GetStations( guRadioStations * stations, const long minbitrate )
{
m_PendingItems.Empty();
guRadioItemData * ItemData = m_RadioPanel->GetSelectedData();
if( ItemData )
{
guRadioGenreTreeCtrl * RadioTreeCtrl = m_RadioPanel->GetTreeCtrl();
wxTreeItemId SelectedItem = m_RadioPanel->GetSelectedGenre();
RadioTreeCtrl->DeleteChildren( SelectedItem );
//AddStations( ItemData->GetUrl(), stations, minbitrate );
CancellSearchStations();
m_ReadStationsThreadMutex.Lock();
m_ReadStationsThread = new guTuneInReadStationsThread( this, m_RadioPanel, ItemData->GetUrl(), stations, minbitrate );
m_ReadStationsThreadMutex.Unlock();
}
return stations->Count();
}
// -------------------------------------------------------------------------------- //
void guTuneInRadioProvider::CancellSearchStations( void )
{
wxMutexLocker MutexLocker( m_ReadStationsThreadMutex );
if( m_ReadStationsThread )
{
m_ReadStationsThread->Pause();
m_ReadStationsThread->Delete();
m_ReadStationsThread = NULL;
}
}
// -------------------------------------------------------------------------------- //
void guTuneInRadioProvider::SetSearchText( const wxArrayString &texts )
{
m_SearchTexts = texts;
}
// -------------------------------------------------------------------------------- //
guTuneInReadStationsThread::guTuneInReadStationsThread( guTuneInRadioProvider * tuneinprovider,
guRadioPanel * radiopanel, const wxString &url, guRadioStations * stations, const long minbitrate ) :
wxThread()
{
m_TuneInProvider = tuneinprovider;
m_RadioPanel = radiopanel;
m_RadioStations = stations;
m_Url = wxString::FromUTF8( url.char_str() );
m_MinBitRate = minbitrate;
if( Create() == wxTHREAD_NO_ERROR )
{
SetPriority( WXTHREAD_DEFAULT_PRIORITY - 30 );
Run();
}
}
// -------------------------------------------------------------------------------- //
guTuneInReadStationsThread::~guTuneInReadStationsThread()
{
if( !TestDestroy() )
{
m_TuneInProvider->EndReadStationsThread();
}
}
// -------------------------------------------------------------------------------- //
wxString GetTuneInUrl( const wxString &url )
{
guDbCache * DbCache = guDbCache::GetDbCache();
wxString Content = DbCache->GetContent( url );
if( Content.IsEmpty() )
{
char * Buffer = NULL;
guHttp Http;
// Only with a UserAgent is accepted the Charset requested
//http.AddHeader( wxT( "User-Agent: " "Dalvik/1.6.0.(Linux;.U;.Android.4.1.1;.Galaxy.Nexus.Build/JRO03L)" ) );
Http.AddHeader( wxT( "User-Agent" ), guDEFAULT_BROWSER_USER_AGENT );
Http.AddHeader( wxT( "Accept" ), wxT( "text/html" ) );
Http.AddHeader( wxT( "Accept-Charset" ), wxT( "utf-8" ) );
Http.Get( Buffer, url );
if( Buffer )
{
Content = wxString( Buffer, wxConvUTF8 );
if( !Content.IsEmpty() )
{
DbCache->SetContent( url, Content, guDBCACHE_TYPE_TUNEIN );
}
free( Buffer );
}
}
return Content;
}
// -------------------------------------------------------------------------------- //
static int wxCMPFUNC_CONV CompareNameA( guRadioStation ** item1, guRadioStation ** item2 )
{
return ( * item1 )->m_Name.Cmp( ( * item2 )->m_Name );
}
// -------------------------------------------------------------------------------- //
static int wxCMPFUNC_CONV CompareNameD( guRadioStation ** item1, guRadioStation ** item2 )
{
return ( * item2 )->m_Name.Cmp( ( * item1 )->m_Name );
}
// -------------------------------------------------------------------------------- //
static int wxCMPFUNC_CONV CompareBitRateA( guRadioStation ** item1, guRadioStation ** item2 )
{
if( ( * item1 )->m_BitRate == ( * item2 )->m_BitRate )
return 0;
else if( ( * item1 )->m_BitRate > ( * item2 )->m_BitRate )
return 1;
else
return -1;
}
// -------------------------------------------------------------------------------- //
static int wxCMPFUNC_CONV CompareBitRateD( guRadioStation ** item1, guRadioStation ** item2 )
{
if( ( * item1 )->m_BitRate == ( * item2 )->m_BitRate )
return 0;
else if( ( * item2 )->m_BitRate > ( * item1 )->m_BitRate )
return 1;
else
return -1;
}
// -------------------------------------------------------------------------------- //
static int wxCMPFUNC_CONV CompareTypeA( guRadioStation ** item1, guRadioStation ** item2 )
{
return ( * item1 )->m_Type.Cmp( ( * item2 )->m_Type );
}
// -------------------------------------------------------------------------------- //
static int wxCMPFUNC_CONV CompareTypeD( guRadioStation ** item1, guRadioStation ** item2 )
{
return ( * item2 )->m_Type.Cmp( ( * item1 )->m_Type );
}
// -------------------------------------------------------------------------------- //
static int wxCMPFUNC_CONV CompareNowPlayingA( guRadioStation ** item1, guRadioStation ** item2 )
{
return ( * item1 )->m_NowPlaying.Cmp( ( * item2 )->m_NowPlaying );
}
// -------------------------------------------------------------------------------- //
static int wxCMPFUNC_CONV CompareNowPlayingD( guRadioStation ** item1, guRadioStation ** item2 )
{
return ( * item2 )->m_NowPlaying.Cmp( ( * item1 )->m_NowPlaying );
}
// -------------------------------------------------------------------------------- //
void guTuneInReadStationsThread::SortStations( void )
{
int StationsOrder = m_RadioPanel->GetStationsOrder();
bool StationsOrderDesc = m_RadioPanel->GetStationsOrderDesc();
switch( StationsOrder )
{
case guRADIOSTATIONS_COLUMN_NAME :
m_RadioStations->Sort( StationsOrderDesc ? CompareNameD : CompareNameA );
break;
case guRADIOSTATIONS_COLUMN_BITRATE :
m_RadioStations->Sort( StationsOrderDesc ? CompareBitRateD : CompareBitRateA );
case guRADIOSTATIONS_COLUMN_LISTENERS :
break;
case guRADIOSTATIONS_COLUMN_TYPE :
m_RadioStations->Sort( StationsOrderDesc ? CompareTypeD : CompareTypeA );
break;
case guRADIOSTATIONS_COLUMN_NOWPLAYING :
m_RadioStations->Sort( StationsOrderDesc ? CompareNowPlayingD : CompareNowPlayingA );
break;
}
}
// -------------------------------------------------------------------------------- //
bool SearchFilterTexts( wxArrayString &texts, const wxString &name )
{
int Count = texts.Count();
for( int Index = 0; Index < Count; Index++ )
{
//guLogMessage( wxT( "%s = > '%s'" ), name.c_str(), texts[ Index ].Lower().c_str() );
if( name.Find( texts[ Index ].Lower() ) == wxNOT_FOUND )
return false;
}
return true;
}
// -------------------------------------------------------------------------------- //
void guTuneInReadStationsThread::ReadStations( wxXmlNode * xmlnode, guRadioStations * stations, const long minbitrate )
{
// wxString MoreStationsUrl;
while( xmlnode && !TestDestroy() )
{
wxString Type;
wxString Name;
wxString Url;
xmlnode->GetAttribute( wxT( "type" ), &Type );
if( Type == wxT( "" ) )
{
ReadStations( xmlnode->GetChildren(), stations, minbitrate );
}
else if( Type == wxT( "link" ) )
{
xmlnode->GetAttribute( wxT( "text" ), &Name );
xmlnode->GetAttribute( wxT( "URL" ), &Url );
//guLogMessage( wxT( "ReadStations -> Type : '%s' Name : '%s' " ), Type.c_str(), Name.c_str() );
if( Name == wxT( "Find by Name" ) )
{
}
else if( Name == wxT( "More Stations" ) )
{
//MoreStationsUrl = Url;
m_MoreStations.Add( Url );
}
else
{
//guLogMessage( wxT( "AddPendingItem '%s' '%s'" ), Name.c_str(), Url.c_str() );
m_TuneInProvider->AddPendingItem( Name + wxT( "|" ) + Url );
wxCommandEvent Event( wxEVT_MENU, ID_RADIO_CREATE_TREE_ITEM );
wxPostEvent( m_RadioPanel, Event );
Sleep( 20 );
}
}
else if( Type == wxT( "audio" ) )
{
// <outline type="audio"
// text="Talk Radio Europe (Cartagena)"
// URL="http://opml.radiotime.com/Tune.ashx?id=s111270"
// bitrate="64"
// reliability="96"
// guide_id="s111270"
// subtext="your voice in spain"
// genre_id="g32"
// formats="mp3"
// item="station"
// image="http://radiotime-logos.s3.amazonaws.com/s111270q.png"
// now_playing_id="s111270"
// preset_id="s111270"/>
guRadioStation * RadioStation = new guRadioStation();
long lBitRate = 0;
wxString BitRate;
xmlnode->GetAttribute( wxT( "bitrate" ), &BitRate );
if( !BitRate.IsEmpty() )
{
BitRate.ToLong( &lBitRate );
}
xmlnode->GetAttribute( wxT( "text" ), &RadioStation->m_Name );
if( ( BitRate.IsEmpty() || ( lBitRate >= minbitrate ) ) && SearchFilterTexts( m_TuneInProvider->GetSearchTexts(), RadioStation->m_Name.Lower() ) )
{
RadioStation->m_BitRate = lBitRate;
RadioStation->m_Id = -1;
RadioStation->m_SCId = wxNOT_FOUND;
xmlnode->GetAttribute( wxT( "URL" ), &RadioStation->m_Link );
xmlnode->GetAttribute( wxT( "formats" ), &RadioStation->m_Type );
xmlnode->GetAttribute( wxT( "subtext" ), &RadioStation->m_NowPlaying );
RadioStation->m_Source = guRADIO_SOURCE_TUNEIN;
RadioStation->m_Listeners = 0;
stations->Add( RadioStation );
//guLogMessage( wxT( "Adding station %s" ), RadioStation->m_Name.c_str() );
}
else
{
delete RadioStation;
}
}
xmlnode = xmlnode->GetNext();
}
if( !TestDestroy() )
{
SortStations();
wxCommandEvent Event( wxEVT_MENU, ID_RADIO_UPDATED );
wxPostEvent( m_RadioPanel, Event );
}
}
// -------------------------------------------------------------------------------- //
int guTuneInReadStationsThread::AddStations( const wxString &url, guRadioStations * stations, const long minbitrate )
{
wxString Content = GetTuneInUrl( url );
//guLogMessage( wxT( "AddStations: %s" ), url.c_str() );
if( !Content.IsEmpty() )
{
wxStringInputStream Ins( Content );
wxXmlDocument XmlDoc( Ins );
wxXmlNode * XmlNode = XmlDoc.GetRoot();
if( XmlNode )
{
if( XmlNode->GetName() == wxT( "opml" ) )
{
XmlNode = XmlNode->GetChildren();
while( XmlNode && !TestDestroy() )
{
//guLogMessage( wxT( "XmlNode: '%s'" ), XmlNode->GetName().c_str() );
if( XmlNode->GetName() == wxT( "outline" ) )
{
wxString Type;
XmlNode->GetAttribute( wxT( "type" ), &Type );
if( Type == wxT( "" ) )
{
ReadStations( XmlNode->GetChildren(), stations, minbitrate );
}
else
{
ReadStations( XmlNode, stations, minbitrate );
break;
}
}
else if( XmlNode->GetName() == wxT( "body" ) )
{
XmlNode = XmlNode->GetChildren();
continue;
}
XmlNode = XmlNode->GetNext();
}
}
}
}
if( !TestDestroy() )
{
SortStations();
wxCommandEvent Event( wxEVT_MENU, ID_RADIO_UPDATED );
wxPostEvent( m_RadioPanel, Event );
return stations->Count();
}
return 0;
}
// -------------------------------------------------------------------------------- //
guTuneInReadStationsThread::ExitCode guTuneInReadStationsThread::Entry()
{
if( TestDestroy() )
return 0;
if( !TestDestroy() )
{
AddStations( m_Url, m_RadioStations, m_MinBitRate );
while( !TestDestroy() && m_MoreStations.Count() )
{
AddStations( m_MoreStations[ 0 ], m_RadioStations, m_MinBitRate );
m_MoreStations.RemoveAt( 0 );
}
}
return 0;
}
}
// -------------------------------------------------------------------------------- //
| 16,652
|
C++
|
.cpp
| 407
| 33.577396
| 158
| 0.505129
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
750,644
|
UserRadio.cpp
|
anonbeat_guayadeque/src/ui/radios/UserRadio.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "UserRadio.h"
#include "Accelerators.h"
#include "DbRadios.h"
#include "Images.h"
#include "RadioPanel.h"
#include "RadioEditor.h"
#include <wx/wfstream.h>
#include <wx/tokenzr.h>
#include <wx/xml/xml.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
guUserRadioProvider::guUserRadioProvider( guRadioPanel * radiopanel, guDbRadios * dbradios ) :
guRadioProvider( radiopanel, dbradios )
{
radiopanel->Bind( wxEVT_MENU, &guUserRadioProvider::OnRadioAdd, this, ID_RADIO_USER_ADD );
radiopanel->Bind( wxEVT_MENU, &guUserRadioProvider::OnRadioEdit, this, ID_RADIO_USER_EDIT );
radiopanel->Bind( wxEVT_MENU, &guUserRadioProvider::OnRadioDelete, this, ID_RADIO_USER_DEL );
radiopanel->Bind( wxEVT_MENU, &guUserRadioProvider::OnRadioImport, this, ID_RADIO_USER_IMPORT );
radiopanel->Bind( wxEVT_MENU, &guUserRadioProvider::OnRadioExport, this, ID_RADIO_USER_EXPORT );
}
// -------------------------------------------------------------------------------- //
guUserRadioProvider::~guUserRadioProvider()
{
}
// -------------------------------------------------------------------------------- //
bool guUserRadioProvider::OnContextMenu( wxMenu * menu, const wxTreeItemId &itemid, const bool forstations, const int selcount )
{
if( selcount )
menu->AppendSeparator();
wxMenuItem * MenuItem = new wxMenuItem( menu, ID_RADIO_USER_ADD, _( "Add Radio" ), _( "Create a new radio" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
menu->Append( MenuItem );
if( forstations && selcount )
{
MenuItem = new wxMenuItem( menu, ID_RADIO_USER_EDIT,
wxString( _( "Edit Radio" ) ) + guAccelGetCommandKeyCodeString( ID_PLAYER_PLAYLIST_EDITTRACKS ),
_( "Change the selected radio" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_edit ) );
menu->Append( MenuItem );
MenuItem = new wxMenuItem( menu, ID_RADIO_USER_DEL, _( "Delete Radio" ), _( "Delete the selected radio" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_edit_clear ) );
menu->Append( MenuItem );
}
menu->AppendSeparator();
MenuItem = new wxMenuItem( menu, ID_RADIO_USER_IMPORT, _( "Import" ), _( "Import the radio stations" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
menu->Append( MenuItem );
MenuItem = new wxMenuItem( menu, ID_RADIO_USER_EXPORT, _( "Export" ), _( "Export all the radio stations" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_doc_save ) );
menu->Append( MenuItem );
return true;
}
// -------------------------------------------------------------------------------- //
void guUserRadioProvider::RegisterImages( wxImageList * imagelist )
{
imagelist->Add( guImage( guIMAGE_INDEX_tiny_net_radio ) );
m_ImageIds.Add( imagelist->GetImageCount() - 1 );
}
// -------------------------------------------------------------------------------- //
void guUserRadioProvider::RegisterItems( guRadioGenreTreeCtrl * genretreectrl, wxTreeItemId &rootitem )
{
m_ManualId = genretreectrl->AppendItem( rootitem, _( "User Defined" ), m_ImageIds[ 0 ], m_ImageIds[ 0 ], NULL );
}
// -------------------------------------------------------------------------------- //
int guUserRadioProvider::GetStations( guRadioStations * stations, const long minbitrate )
{
m_Db->SetRadioSourceFilter( guRADIO_SOURCE_USER );
m_Db->GetRadioStations( stations );
m_RadioPanel->EndLoadingStations();
return stations->Count();
}
// -------------------------------------------------------------------------------- //
void guUserRadioProvider::OnRadioAdd( wxCommandEvent &event )
{
wxArrayString * Params = ( wxArrayString * ) event.GetClientData();
wxString Name;
wxString Link;
if( Params && ( Params->GetCount() == 2 ) )
{
Name = Params->Item( 0 );
Link = Params->Item( 1 );
}
guRadioEditor * RadioEditor = new guRadioEditor( m_RadioPanel, _( "Edit Radio" ), Name, Link );
if( RadioEditor )
{
if( RadioEditor->ShowModal() == wxID_OK )
{
guRadioStation RadioStation;
RadioStation.m_Id = wxNOT_FOUND;
RadioStation.m_SCId = wxNOT_FOUND;
RadioStation.m_BitRate = 0;
RadioStation.m_GenreId = wxNOT_FOUND;
RadioStation.m_Source = 1;
RadioStation.m_Name = RadioEditor->GetName();
RadioStation.m_Link = RadioEditor->GetLink();
RadioStation.m_Listeners = 0;
RadioStation.m_Type = wxEmptyString;
//
m_Db->SetRadioStation( &RadioStation );
//
m_RadioPanel->ReloadStations();
}
RadioEditor->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guUserRadioProvider::OnRadioEdit( wxCommandEvent &event )
{
guRadioStation RadioStation;
m_RadioPanel->GetSelectedStation( &RadioStation );
guRadioEditor * RadioEditor = new guRadioEditor( m_RadioPanel, _( "Edit Radio" ), RadioStation.m_Name, RadioStation.m_Link );
if( RadioEditor )
{
if( RadioEditor->ShowModal() == wxID_OK )
{
RadioStation.m_Name = RadioEditor->GetName();
RadioStation.m_Link = RadioEditor->GetLink();
m_Db->SetRadioStation( &RadioStation );
//
m_RadioPanel->ReloadStations();
}
RadioEditor->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guUserRadioProvider::OnRadioDelete( wxCommandEvent &event )
{
guRadioStation RadioStation;
m_RadioPanel->GetSelectedStation( &RadioStation );
m_Db->DelRadioStation( RadioStation.m_Id );
m_RadioPanel->ReloadStations();
}
// -------------------------------------------------------------------------------- //
void ReadXmlRadioStation( wxXmlNode * node, guRadioStation * station )
{
while( node )
{
if( node->GetName() == wxT( "Name" ) )
{
station->m_Name = node->GetNodeContent();
}
else if( node->GetName() == wxT( "Url" ) )
{
station->m_Link = node->GetNodeContent();
}
node = node->GetNext();
}
}
// -------------------------------------------------------------------------------- //
void ReadXmlRadioStations( wxXmlNode * node, guRadioStations * stations )
{
while( node && node->GetName() == wxT( "RadioStation" ) )
{
guRadioStation * RadioStation = new guRadioStation();
RadioStation->m_Id = wxNOT_FOUND;
RadioStation->m_SCId = wxNOT_FOUND;
RadioStation->m_BitRate = 0;
RadioStation->m_GenreId = wxNOT_FOUND;
RadioStation->m_Source = 1;
RadioStation->m_Listeners = 0;
RadioStation->m_Type = wxEmptyString;
ReadXmlRadioStation( node->GetChildren(), RadioStation );
if( !RadioStation->m_Name.IsEmpty() && !RadioStation->m_Link.IsEmpty() )
stations->Add( RadioStation );
else
delete RadioStation;
node = node->GetNext();
}
}
// -------------------------------------------------------------------------------- //
void guUserRadioProvider::OnRadioImport( wxCommandEvent &event )
{
guRadioStations UserStations;
wxFileDialog * FileDialog = new wxFileDialog( m_RadioPanel,
wxT( "Select the xml file" ),
wxGetHomeDir(),
wxEmptyString,
wxT( "*.xml;*.xml" ),
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
if( FileDialog )
{
if( FileDialog->ShowModal() == wxID_OK )
{
wxFileInputStream Ins( FileDialog->GetPath() );
wxXmlDocument XmlDoc( Ins );
wxXmlNode * XmlNode = XmlDoc.GetRoot();
if( XmlNode && XmlNode->GetName() == wxT( "RadioStations" ) )
{
ReadXmlRadioStations( XmlNode->GetChildren(), &UserStations );
int Count = UserStations.Count();
if( Count )
{
for( int Index = 0; Index < Count; Index++ )
{
m_Db->SetRadioStation( &UserStations[ Index ] );
}
//
m_RadioPanel->ReloadStations();
}
}
}
FileDialog->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guUserRadioProvider::OnRadioExport( wxCommandEvent &event )
{
guRadioStations UserStations;
m_Db->GetUserRadioStations( &UserStations );
int Count = UserStations.Count();
if( Count )
{
wxFileDialog * FileDialog = new wxFileDialog( m_RadioPanel,
wxT( "Select the output xml filename" ),
wxGetHomeDir(),
wxT( "RadioStations.xml" ),
wxT( "*.xml;*.xml" ),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( FileDialog )
{
if( FileDialog->ShowModal() == wxID_OK )
{
wxXmlDocument OutXml;
//OutXml.SetRoot( );
wxXmlNode * RootNode = new wxXmlNode( wxXML_ELEMENT_NODE, wxT( "RadioStations" ) );
for( int Index = 0; Index < Count; Index++ )
{
//guLogMessage( wxT( "Adding %s" ), UserStations[ Index ].m_Name.c_str() );
wxXmlNode * RadioNode = new wxXmlNode( wxXML_ELEMENT_NODE, wxT( "RadioStation" ) );
wxXmlNode * RadioName = new wxXmlNode( wxXML_ELEMENT_NODE, wxT( "Name" ) );
wxXmlNode * RadioNameVal = new wxXmlNode( wxXML_TEXT_NODE, wxT( "Name" ), UserStations[ Index ].m_Name );
RadioName->AddChild( RadioNameVal );
RadioNode->AddChild( RadioName );
wxXmlNode * RadioUrl = new wxXmlNode( wxXML_ELEMENT_NODE, wxT( "Url" ) );
wxXmlNode * RadioUrlVal = new wxXmlNode( wxXML_TEXT_NODE, wxT( "Url" ), UserStations[ Index ].m_Link );
RadioUrl->AddChild( RadioUrlVal );
RadioNode->AddChild( RadioUrl );
RootNode->AddChild( RadioNode );
}
OutXml.SetRoot( RootNode );
OutXml.Save( FileDialog->GetPath() );
}
FileDialog->Destroy();
}
}
}
}
// -------------------------------------------------------------------------------- //
| 11,640
|
C++
|
.cpp
| 269
| 35.773234
| 129
| 0.542847
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
750,645
|
VolumeFrame.cpp
|
anonbeat_guayadeque/src/ui/volumeframe/VolumeFrame.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "VolumeFrame.h"
//#include "Utils.h"
namespace Guayadeque {
#define guVOLUMEN_AUTOCLOSE_TIMEOUT 3000
// -------------------------------------------------------------------------------- //
guVolumeFrame::guVolumeFrame( guPlayerPanel * Player, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) :
wxFrame( parent, id, title, pos, size, style|wxFRAME_NO_TASKBAR )
{
m_PlayerPanel = Player;
m_MouseTimer = new wxTimer( this );
m_MouseTimer->Start( guVOLUMEN_AUTOCLOSE_TIMEOUT, wxTIMER_ONE_SHOT );
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* SetVolSizer;
SetVolSizer = new wxBoxSizer( wxVERTICAL );
m_IncVolButton = new wxButton( this, wxID_ANY, wxT("+"), wxDefaultPosition, wxSize( 24,28 ), wxNO_BORDER );
SetVolSizer->Add( m_IncVolButton, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 0 );
m_VolSlider = new wxSlider( this, wxID_ANY, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_INVERSE|wxSL_VERTICAL );
SetVolSizer->Add( m_VolSlider, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 2 );
if( m_PlayerPanel )
{
m_VolSlider->SetValue( m_PlayerPanel->GetVolume() );
//VolSlider->Refresh();
}
m_DecVolButton = new wxButton( this, wxID_ANY, wxT("-"), wxDefaultPosition, wxSize( 24,28 ), wxNO_BORDER );
SetVolSizer->Add( m_DecVolButton, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 0 );
this->SetSizer( SetVolSizer );
this->Layout();
// Bind Events
Bind( wxEVT_ACTIVATE, &guVolumeFrame::VolFrameActivate, this );
Bind( wxEVT_MOUSEWHEEL, &guVolumeFrame::OnMouseWheel, this );
m_VolSlider->Bind( wxEVT_MOUSEWHEEL, &guVolumeFrame::OnMouseWheel, this );
m_IncVolButton->Bind( wxEVT_BUTTON, &guVolumeFrame::IncVolButtonClick, this );
m_VolSlider->Bind( wxEVT_SCROLL_CHANGED, &guVolumeFrame::VolSliderChanged, this );
m_VolSlider->Bind( wxEVT_SCROLL_THUMBTRACK, &guVolumeFrame::VolSliderChanged, this );
m_DecVolButton->Bind( wxEVT_BUTTON, &guVolumeFrame::DecVolButtonClick, this );
Bind( wxEVT_MOTION, &guVolumeFrame::OnMouse, this );
m_IncVolButton->Bind( wxEVT_MOTION, &guVolumeFrame::OnMouse, this );
m_VolSlider->Bind( wxEVT_MOTION, &guVolumeFrame::OnMouse, this );
m_DecVolButton->Bind( wxEVT_MOTION, &guVolumeFrame::OnMouse, this );
Bind( wxEVT_TIMER, &guVolumeFrame::OnTimer, this );
}
// -------------------------------------------------------------------------------- //
guVolumeFrame::~guVolumeFrame()
{
// Unbind Events
Unbind( wxEVT_ACTIVATE, &guVolumeFrame::VolFrameActivate, this );
Unbind( wxEVT_MOUSEWHEEL, &guVolumeFrame::OnMouseWheel, this );
m_VolSlider->Unbind( wxEVT_MOUSEWHEEL, &guVolumeFrame::OnMouseWheel, this );
m_IncVolButton->Unbind( wxEVT_BUTTON, &guVolumeFrame::IncVolButtonClick, this );
m_VolSlider->Unbind( wxEVT_SCROLL_CHANGED, &guVolumeFrame::VolSliderChanged, this );
m_VolSlider->Unbind( wxEVT_SCROLL_THUMBTRACK, &guVolumeFrame::VolSliderChanged, this );
m_DecVolButton->Unbind( wxEVT_BUTTON, &guVolumeFrame::DecVolButtonClick, this );
Unbind( wxEVT_MOTION, &guVolumeFrame::OnMouse, this );
m_IncVolButton->Unbind( wxEVT_MOTION, &guVolumeFrame::OnMouse, this );
m_VolSlider->Unbind( wxEVT_MOTION, &guVolumeFrame::OnMouse, this );
m_DecVolButton->Unbind( wxEVT_MOTION, &guVolumeFrame::OnMouse, this );
Unbind( wxEVT_TIMER, &guVolumeFrame::OnTimer, this );
if( m_MouseTimer )
delete m_MouseTimer;
}
// -------------------------------------------------------------------------------- //
void guVolumeFrame::SetVolume( void )
{
if( m_PlayerPanel )
m_PlayerPanel->SetVolume( m_VolSlider->GetValue() );
}
// -------------------------------------------------------------------------------- //
void guVolumeFrame::VolFrameActivate( wxActivateEvent& event )
{
if( !event.GetActive() )
Close();
}
// -------------------------------------------------------------------------------- //
void guVolumeFrame::IncVolButtonClick( wxCommandEvent& event )
{
m_VolSlider->SetValue( m_VolSlider->GetValue() + 5 );
SetVolume();
}
// -------------------------------------------------------------------------------- //
void guVolumeFrame::VolSliderChanged( wxScrollEvent& event )
{
SetVolume();
}
// -------------------------------------------------------------------------------- //
void guVolumeFrame::DecVolButtonClick( wxCommandEvent& event )
{
m_VolSlider->SetValue( m_VolSlider->GetValue() - 5 );
SetVolume();
}
// -------------------------------------------------------------------------------- //
void guVolumeFrame::OnMouseWheel( wxMouseEvent &event )
{
if( m_MouseTimer->IsRunning() )
m_MouseTimer->Stop();
m_MouseTimer->Start( guVOLUMEN_AUTOCLOSE_TIMEOUT, wxTIMER_ONE_SHOT );
int Rotation = event.GetWheelRotation() / event.GetWheelDelta();
m_VolSlider->SetValue( m_VolSlider->GetValue() + ( Rotation * 2 ) );
SetVolume();
}
// -------------------------------------------------------------------------------- //
void guVolumeFrame::OnMouse( wxMouseEvent &event )
{
if( m_MouseTimer->IsRunning() )
m_MouseTimer->Stop();
m_MouseTimer->Start( guVOLUMEN_AUTOCLOSE_TIMEOUT, wxTIMER_ONE_SHOT );
event.Skip();
}
// -------------------------------------------------------------------------------- //
void guVolumeFrame::OnTimer( wxTimerEvent &event )
{
Close();
}
}
// -------------------------------------------------------------------------------- //
| 6,543
|
C++
|
.cpp
| 135
| 45.377778
| 164
| 0.598244
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,646
|
Magnatune.cpp
|
anonbeat_guayadeque/src/ui/magnatune/Magnatune.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "Magnatune.h"
#include "LyricsPanel.h"
#include "MainFrame.h"
#include "SelCoverFile.h"
#include "StatusBar.h"
#include "TagInfo.h"
#include "Utils.h"
#include <wx/wfstream.h>
#include <wx/mstream.h>
#include <wx/tokenzr.h>
#include <wx/zstream.h>
#include <wx/xml/xml.h>
#include <id3v1genres.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
// guMagnatuneLibrary
// -------------------------------------------------------------------------------- //
guMagnatuneLibrary::guMagnatuneLibrary( const wxString &dbname ) :
guDbLibrary( dbname )
{
}
// -------------------------------------------------------------------------------- //
guMagnatuneLibrary::~guMagnatuneLibrary()
{
}
// -------------------------------------------------------------------------------- //
void guMagnatuneLibrary::UpdateArtistsLabels( const guArrayListItems &labelsets )
{
guListItems LaItems;
// The ArtistLabels string is the same for all songs so done out of the loop
GetLabels( &LaItems, true );
int ArIndex;
int ArCount = labelsets.Count();
for( ArIndex = 0; ArIndex < ArCount; ArIndex++ )
{
wxArrayInt ArLabels = labelsets[ ArIndex ].GetData();
//guLogMessage( wxT( "Artist Labels : '%s'" ), ArtistLabelStr.c_str() );
// Update the Database
wxArrayInt Artists;
Artists.Add( labelsets[ ArIndex ].GetId() );
SetArtistsLabels( Artists, ArLabels );
}
}
// -------------------------------------------------------------------------------- //
void guMagnatuneLibrary::UpdateSongsLabels( const guArrayListItems &labelsets )
{
guListItems LaItems;
// The ArtistLabels string is the same for all songs so done out of the loop
GetLabels( &LaItems, true );
int ItemIndex;
int ItemCount = labelsets.Count();
for( ItemIndex = 0; ItemIndex < ItemCount; ItemIndex++ )
{
wxArrayInt ItemLabels = labelsets[ ItemIndex ].GetData();
//guLogMessage( wxT( "Artist Labels : '%s'" ), ArtistLabelStr.c_str() );
// Update the Database
wxArrayInt ItemIds;
ItemIds.Add( labelsets[ ItemIndex ].GetId() );
SetSongsLabels( ItemIds, ItemLabels );
}
}
// -------------------------------------------------------------------------------- //
void guMagnatuneLibrary::UpdateAlbumsLabels( const guArrayListItems &labelsets )
{
guListItems LaItems;
// The ArtistLabels string is the same for all songs so done out of the loop
GetLabels( &LaItems, true );
int ItemIndex;
int ItemCount = labelsets.Count();
for( ItemIndex = 0; ItemIndex < ItemCount; ItemIndex++ )
{
wxArrayInt ItemLabels = labelsets[ ItemIndex ].GetData();
//guLogMessage( wxT( "Artist Labels : '%s'" ), ArtistLabelStr.c_str() );
// Update the Database
wxArrayInt ItemIds;
ItemIds.Add( labelsets[ ItemIndex ].GetId() );
SetAlbumsLabels( ItemIds, ItemLabels );
}
}
// -------------------------------------------------------------------------------- //
void guMagnatuneLibrary::CreateNewSong( guTrack * track, const wxString &albumsku, const wxString &coverlink )
{
wxString query;
//wxSQLite3ResultSet dbRes;
track->m_SongId = FindTrack( track->m_ArtistName, track->m_SongName );
if( track->m_SongId != wxNOT_FOUND )
{
query = wxString::Format( wxT( "UPDATE songs SET song_name = '%s', " \
"song_genreid = %u, song_genre = '%s', " \
"song_artistid = %u, song_artist = '%s', " \
"song_albumid = %u, song_album = '%s', " \
"song_pathid = %u, song_path = '%s', " \
"song_filename = '%s', " \
"song_number = %u, song_year = %u, " \
"song_length = %u, " \
"song_albumsku = '%s', " \
"song_coverlink = '%s' " \
"WHERE song_id = %u;" ),
escape_query_str( track->m_SongName ).c_str(),
track->m_GenreId,
escape_query_str( track->m_GenreName ).c_str(),
track->m_ArtistId,
escape_query_str( track->m_ArtistName ).c_str(),
track->m_AlbumId,
escape_query_str( track->m_AlbumName ).c_str(),
track->m_PathId,
escape_query_str( track->m_Path ).c_str(),
escape_query_str( track->m_FileName ).c_str(),
track->m_Number,
track->m_Year,
track->m_Length,
escape_query_str( albumsku ).c_str(),
escape_query_str( coverlink ).c_str(),
track->m_SongId );
ExecuteUpdate( query );
}
else
{
wxString query = wxString::Format( wxT( "INSERT INTO songs( " \
"song_id, song_playcount, song_addedtime, " \
"song_name, song_genreid, song_genre, song_artistid, song_artist, " \
"song_albumid, song_album, song_pathid, song_path, song_filename, song_format, song_number, song_year, " \
"song_coverid, song_disk, song_length, song_offset, song_bitrate, song_rating, " \
"song_filesize, song_albumsku, song_coverlink ) VALUES( NULL, 0, %lu, '%s', %u, '%s', %u, '%s', %u, '%s', " \
"%u, '%s', '%s', 'mp3,ogg', %u, %u, %u, '%s', %u, 0, 0, -1, 0, '%s', '%s' )" ),
wxDateTime::GetTimeNow(),
escape_query_str( track->m_SongName ).c_str(),
track->m_GenreId,
escape_query_str( track->m_GenreName ).c_str(),
track->m_ArtistId,
escape_query_str( track->m_ArtistName ).c_str(),
track->m_AlbumId,
escape_query_str( track->m_AlbumName ).c_str(),
track->m_PathId,
escape_query_str( track->m_Path ).c_str(),
escape_query_str( track->m_FileName ).c_str(),
track->m_Number,
track->m_Year,
track->m_CoverId,
escape_query_str( track->m_Disk ).c_str(),
track->m_Length,
escape_query_str( albumsku ).c_str(),
escape_query_str( coverlink ).c_str() );
//guLogMessage( wxT( "%s" ), query.c_str() );
ExecuteUpdate( query );
}
// guLogMessage( wxT( "%s/%s/%s/%i - %s" ),
// track->m_GenreName.c_str(),
// track->m_ArtistName.c_str(),
// track->m_AlbumName.c_str(),
// track->m_Number,
// track->m_SongName.c_str() );
}
// -------------------------------------------------------------------------------- //
int guMagnatuneLibrary::GetTrackId( const wxString &url, guTrack * track )
{
wxString query;
wxSQLite3ResultSet dbRes;
int RetVal = wxNOT_FOUND;
query = GU_TRACKS_QUERYSTR +
wxString::Format( wxT( " WHERE song_filename = '%s' LIMIT 1;" ),
escape_query_str( url.BeforeLast( '.' ) ).c_str() );
//guLogMessage( wxT( "Searching:\n%s" ), query.c_str() );
dbRes = ExecuteQuery( query );
if( dbRes.NextRow() )
{
RetVal = dbRes.GetInt( 0 );
if( track )
{
FillTrackFromDb( track, &dbRes );
}
}
dbRes.Finalize();
return RetVal;
}
// -------------------------------------------------------------------------------- //
wxString guMagnatuneLibrary::GetAlbumSku( const int albumid )
{
wxString query;
wxSQLite3ResultSet dbRes;
wxString RetVal;
query = wxString::Format( wxT( "SELECT song_albumsku FROM songs WHERE song_albumid = %i LIMIT 1;" ), albumid );
//guLogMessage( wxT( "Searching:\n%s" ), query.c_str() );
dbRes = ExecuteQuery( query );
if( dbRes.NextRow() )
{
RetVal = dbRes.GetString( 0 );
}
dbRes.Finalize();
return RetVal;
}
// -------------------------------------------------------------------------------- //
// guMagnatunePanel
// -------------------------------------------------------------------------------- //
guMagnatunePanel::guMagnatunePanel( wxWindow * parent, guMediaViewerMagnatune * mediaviewer ) :
guLibPanel( parent, mediaviewer )
{
Bind( wxEVT_MENU, &guMagnatunePanel::OnDownloadAlbum, this, ID_MAGNATUNE_DOWNLOAD_DIRECT_ALBUM );
Bind( wxEVT_MENU, &guMagnatunePanel::OnDownloadTrackAlbum, this, ID_MAGNATUNE_DOWNLOAD_DIRECT_TRACK_ALBUM );
}
// -------------------------------------------------------------------------------- //
guMagnatunePanel::~guMagnatunePanel()
{
Unbind( wxEVT_MENU, &guMagnatunePanel::OnDownloadAlbum, this, ID_MAGNATUNE_DOWNLOAD_DIRECT_ALBUM );
Unbind( wxEVT_MENU, &guMagnatunePanel::OnDownloadTrackAlbum, this, ID_MAGNATUNE_DOWNLOAD_DIRECT_TRACK_ALBUM );
}
// -------------------------------------------------------------------------------- //
void guMagnatunePanel::OnDownloadAlbum( wxCommandEvent &event )
{
wxArrayInt Albums = m_AlbumListCtrl->GetSelectedItems();
( ( guMediaViewerMagnatune * ) m_MediaViewer )->DownloadAlbums( Albums );
}
// -------------------------------------------------------------------------------- //
void guMagnatunePanel::OnDownloadTrackAlbum( wxCommandEvent &event )
{
guTrackArray Tracks;
m_SongListCtrl->GetSelectedSongs( &Tracks );
wxArrayInt Albums;
int Count = Tracks.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( Albums.Index( Tracks[ Index ].m_AlbumId ) == wxNOT_FOUND )
Albums.Add( Tracks[ Index ].m_AlbumId );
}
( ( guMediaViewerMagnatune * ) m_MediaViewer )->DownloadAlbums( Albums );
}
// -------------------------------------------------------------------------------- //
// guMagnatuneAlbumBrowser
// -------------------------------------------------------------------------------- //
guMagnatuneAlbumBrowser::guMagnatuneAlbumBrowser( wxWindow * parent, guMediaViewer * mediaviewer ) :
guAlbumBrowser( parent, mediaviewer )
{
Bind( wxEVT_MENU, &guMagnatuneAlbumBrowser::OnDownloadAlbum, this, ID_MAGNATUNE_DOWNLOAD_DIRECT_ALBUM );
}
// -------------------------------------------------------------------------------- //
guMagnatuneAlbumBrowser::~guMagnatuneAlbumBrowser()
{
Unbind( wxEVT_MENU, &guMagnatuneAlbumBrowser::OnDownloadAlbum, this, ID_MAGNATUNE_DOWNLOAD_DIRECT_ALBUM );
}
// -------------------------------------------------------------------------------- //
void guMagnatuneAlbumBrowser::OnDownloadAlbum( wxCommandEvent &event )
{
guLogMessage( wxT( "OnDownloadAlbum" ) );
if( m_LastAlbumBrowserItem )
{
wxArrayInt Albums;
Albums.Add( m_LastAlbumBrowserItem->m_AlbumId );
( ( guMediaViewerMagnatune * ) m_MediaViewer )->DownloadAlbums( Albums );
}
}
// -------------------------------------------------------------------------------- //
// guMagnatuneTreePanel
// -------------------------------------------------------------------------------- //
guMagnatuneTreePanel::guMagnatuneTreePanel( wxWindow * parent, guMediaViewer * mediaviewer ) :
guTreeViewPanel( parent, mediaviewer )
{
Bind( wxEVT_MENU, &guMagnatuneTreePanel::OnDownloadAlbum, this, ID_MAGNATUNE_DOWNLOAD_DIRECT_ALBUM );
Bind( wxEVT_MENU, &guMagnatuneTreePanel::OnDownloadTrackAlbum, this, ID_MAGNATUNE_DOWNLOAD_DIRECT_TRACK_ALBUM );
}
// -------------------------------------------------------------------------------- //
guMagnatuneTreePanel::~guMagnatuneTreePanel()
{
Unbind( wxEVT_MENU, &guMagnatuneTreePanel::OnDownloadAlbum, this, ID_MAGNATUNE_DOWNLOAD_DIRECT_ALBUM );
Unbind( wxEVT_MENU, &guMagnatuneTreePanel::OnDownloadTrackAlbum, this, ID_MAGNATUNE_DOWNLOAD_DIRECT_TRACK_ALBUM );
}
// -------------------------------------------------------------------------------- //
void guMagnatuneTreePanel::OnDownloadAlbum( wxCommandEvent &event )
{
guLogMessage( wxT( "OnDownloadAlbum" ) );
const wxTreeItemId &CurItemId = m_TreeViewCtrl->GetSelection();
guTreeViewData * TreeViewData = ( guTreeViewData * ) m_TreeViewCtrl->GetItemData( CurItemId );
int ItemType = TreeViewData->GetType();
if( ItemType == guLIBRARY_ELEMENT_ALBUMS )
{
wxArrayInt Albums;
Albums.Add( TreeViewData->m_Id );
( ( guMediaViewerMagnatune * ) m_MediaViewer )->DownloadAlbums( Albums );
}
}
// -------------------------------------------------------------------------------- //
void guMagnatuneTreePanel::OnDownloadTrackAlbum( wxCommandEvent &event )
{
guLogMessage( wxT( "OnDownloadTrackAlbum" ) );
guTrackArray Tracks;
m_TVTracksListBox->GetSelectedSongs( &Tracks );
wxArrayInt Albums;
int Count = Tracks.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( Albums.Index( Tracks[ Index ].m_AlbumId ) == wxNOT_FOUND )
Albums.Add( Tracks[ Index ].m_AlbumId );
}
( ( guMediaViewerMagnatune * ) m_MediaViewer )->DownloadAlbums( Albums );
}
// -------------------------------------------------------------------------------- //
// guMagnatunePlayListPanel
// -------------------------------------------------------------------------------- //
guMagnatunePlayListPanel::guMagnatunePlayListPanel( wxWindow * parent, guMediaViewer * mediaviewer ) :
guPlayListPanel( parent, mediaviewer )
{
Bind( wxEVT_MENU, &guMagnatunePlayListPanel::OnDownloadTrackAlbum, this, ID_MAGNATUNE_DOWNLOAD_DIRECT_TRACK_ALBUM );
}
// -------------------------------------------------------------------------------- //
guMagnatunePlayListPanel::~guMagnatunePlayListPanel()
{
Unbind( wxEVT_MENU, &guMagnatunePlayListPanel::OnDownloadTrackAlbum, this, ID_MAGNATUNE_DOWNLOAD_DIRECT_TRACK_ALBUM );
}
// -------------------------------------------------------------------------------- //
void guMagnatunePlayListPanel::OnDownloadTrackAlbum( wxCommandEvent &event )
{
guLogMessage( wxT( "OnDownloadTrackAlbum" ) );
guTrackArray Tracks;
m_PLTracksListBox->GetSelectedSongs( &Tracks );
wxArrayInt Albums;
int Count = Tracks.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( Albums.Index( Tracks[ Index ].m_AlbumId ) == wxNOT_FOUND )
Albums.Add( Tracks[ Index ].m_AlbumId );
}
( ( guMediaViewerMagnatune * ) m_MediaViewer )->DownloadAlbums( Albums );
}
// -------------------------------------------------------------------------------- //
// guMagnatuneDownloadThread
// -------------------------------------------------------------------------------- //
guMagnatuneDownloadThread::guMagnatuneDownloadThread( guMediaViewerMagnatune * mediaviewer,
const int albumid, const wxString &artist, const wxString &album )
{
m_MediaViewer = mediaviewer;
m_Db = ( guMagnatuneLibrary * ) mediaviewer->GetDb();
m_ArtistName = artist;
m_AlbumName = album;
m_AlbumId = albumid;
if( Create() == wxTHREAD_NO_ERROR )
{
SetPriority( WXTHREAD_DEFAULT_PRIORITY - 30 );
Run();
}
}
// -------------------------------------------------------------------------------- //
guMagnatuneDownloadThread::~guMagnatuneDownloadThread()
{
}
// -------------------------------------------------------------------------------- //
guMagnatuneDownloadThread::ExitCode guMagnatuneDownloadThread::Entry()
{
wxFileName CoverFile = wxFileName( guPATH_MAGNATUNE_COVERS +
wxString::Format( wxT( "%s-%s.jpg" ), m_ArtistName.c_str(), m_AlbumName.c_str() ) );
if( CoverFile.Normalize( wxPATH_NORM_ALL|wxPATH_NORM_CASE ) )
{
wxString CoverUrl = wxString::Format( wxT( "http://he3.magnatune.com/music/%s/%s/cover_600.jpg" ),
guURLEncode( m_ArtistName, false ).c_str(),
guURLEncode( m_AlbumName, false ).c_str() );
if( !wxDirExists( wxPathOnly( CoverFile.GetFullPath() ) + wxT( "/" ) ) )
{
wxMkdir( wxPathOnly( CoverFile.GetFullPath() ) + wxT( "/" ), 0770 );
}
if( !CoverFile.FileExists() )
{
guLogMessage( wxT( "Downloading: '%s'" ), CoverUrl.c_str() );
DownloadImage( CoverUrl, CoverFile.GetFullPath(), 300 );
}
if( CoverFile.FileExists() )
{
int CoverId = m_Db->AddCoverFile( CoverFile.GetFullPath() );
wxString query = wxString::Format( wxT( "UPDATE songs SET song_coverid = %u WHERE song_albumid = %u" ),
CoverId, m_AlbumId );
m_Db->ExecuteUpdate( query );
// Notify the panel that the cover is downloaded
wxCommandEvent event( wxEVT_MENU, ID_MAGNATUNE_COVER_DOWNLAODED );
event.SetInt( m_AlbumId );
wxPostEvent( m_MediaViewer, event );
}
else
{
guLogMessage( wxT( "Could not get the magnatune cover art %s" ), CoverFile.GetFullPath().c_str() );
}
}
return 0;
}
// -------------------------------------------------------------------------------- //
// guMagnatuneUpdateThread
// -------------------------------------------------------------------------------- //
guMagnatuneUpdateThread::guMagnatuneUpdateThread( guMediaViewer * mediaviewer, int action, int gaugeid )
{
m_MediaViewer = mediaviewer;
m_Db = ( guMagnatuneLibrary * ) mediaviewer->GetDb();
m_MainFrame = mediaviewer->GetMainFrame();
m_Action = action;
m_GaugeId = gaugeid;
guConfig * Config = ( guConfig * ) guConfig::Get();
m_AllowedGenres = Config->ReadAStr( CONFIG_KEY_MAGNATUNE_GENRES_GENRE, wxEmptyString, CONFIG_PATH_MAGNATUNE_GENRES );
if( Create() == wxTHREAD_NO_ERROR )
{
SetPriority( WXTHREAD_DEFAULT_PRIORITY - 10 );
Run();
}
}
// -------------------------------------------------------------------------------- //
guMagnatuneUpdateThread::~guMagnatuneUpdateThread()
{
wxCommandEvent event( wxEVT_MENU, ID_STATUSBAR_GAUGE_REMOVE );
event.SetInt( m_GaugeId );
wxPostEvent( m_MainFrame, event );
if( !TestDestroy() )
{
guConfig * Config = ( guConfig * ) guConfig::Get();
if( Config )
{
wxDateTime Now = wxDateTime::Now();
Config->WriteNum( CONFIG_KEY_MAGNATUNE_LAST_UPDATE, Now.GetTicks(), CONFIG_PATH_MAGNATUNE );
Config->Flush();
}
event.SetId( ID_MAGNATUNE_UPDATE_FINISHED );
event.SetEventObject( ( wxObject * ) this );
wxPostEvent( m_MediaViewer, event );
}
}
#if 0
<AllAlbums>
<Album>
<artist>Dr Kuch</artist>
<artistdesc>Fun electro-poppy dance up and down tempo chill out</artistdesc>
<cover_small>http://he3.magnatune.com/music/Dr%20Kuch/We%20Can't%20Stop%20Progress/cover_200.jpg</cover_small>
<artistphoto>http://magnatune.com//artists/img/drkuch_cover_small.jpg</artistphoto>
<albumname>We Can't Stop Progress</albumname>
<year>2009</year>
<album_notes></album_notes>
<mp3genre>(52)</mp3genre>
<home>http://magnatune.com/artists/dr_kuch</home>
<buy>https://magnatune.com/artists/buy_album?artist=Dr+Kuch&album=We+Can%27t+Stop+Progress&genre=Electronica</buy>
<magnatunegenres>Electronica,Euro-Techno</magnatunegenres>
<launchdate>2009-10-08</launchdate>
<albumsku>drkuch-progress</albumsku>
<Track>
<artist>Dr Kuch</artist>
<artistphoto>http://magnatune.com//artists/img/drkuch_cover_small.jpg</artistphoto>
<artistdesc>Fun electro-poppy dance up and down tempo chill out</artistdesc>
<albumname>We Can't Stop Progress</albumname>
<trackname>Intro</trackname>
<tracknum>1</tracknum>
<year>2009</year>
<mp3genre>(52)</mp3genre>
<magnatunegenres>Electronica,Euro-Techno</magnatunegenres>
<license>http://creativecommons.org/licenses/by-nc-sa/1.0/</license>
<seconds>18</seconds>
<url>http://he3.magnatune.com/all/01-Intro-Dr%20Kuch.mp3</url>
<mp3lofi>http://he3.magnatune.com/all/01-Intro-Dr%20Kuch-lofi.mp3</mp3lofi>
<oggurl>http://he3.magnatune.com/all/01-Intro-Dr%20Kuch.ogg</oggurl>
<buy>https://magnatune.com/artists/buy_album?artist=Dr+Kuch&album=We+Can%27t+Stop+Progress&genre=Electronica</buy>
<home>http://magnatune.com/artists/dr_kuch</home>
<launchdate>2009-10-08</launchdate>
<cover_small>http://he3.magnatune.com/music/Dr%20Kuch/We%20Can't%20Stop%20Progress/cover_200.jpg</cover_small>
<albumsku>drkuch-progress</albumsku>
</Track>
...
</Album>
...
</AllAlbums>
#endif
// -------------------------------------------------------------------------------- //
bool inline IsGenreEnabled( const wxArrayString &genrelist, const wxString ¤t )
{
wxArrayString CurrentGenres = wxStringTokenize( current, wxT( "," ) );
int Count = CurrentGenres.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( genrelist.Index( CurrentGenres[ Index ] ) != wxNOT_FOUND )
return true;
}
return false;
}
// -------------------------------------------------------------------------------- //
void guMagnatuneUpdateThread::AddGenres( const wxString &genres )
{
wxArrayString Genres = wxStringTokenize( genres, wxT( "," ) );
int Count = Genres.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( m_GenreList.Index( Genres[ Index ] ) == wxNOT_FOUND )
{
m_GenreList.Add( Genres[ Index ] );
}
}
}
// -------------------------------------------------------------------------------- //
void guMagnatuneUpdateThread::ReadMagnatuneXmlTrack( wxXmlNode * xmlnode )
{
long Id;
while( xmlnode && !TestDestroy() )
{
wxString ItemName = xmlnode->GetName();
if( ItemName == wxT( "trackname" ) )
{
m_CurrentTrack.m_SongName = xmlnode->GetNodeContent().Trim( true ).Trim( false );
}
else if( ItemName == wxT( "tracknum" ) )
{
xmlnode->GetNodeContent().ToLong( &Id );
m_CurrentTrack.m_Number = Id;
}
else if( ItemName == wxT( "year" ) )
{
xmlnode->GetNodeContent().ToLong( &Id );
m_CurrentTrack.m_Year = Id;
}
else if( ItemName == wxT( "seconds" ) )
{
xmlnode->GetNodeContent().ToLong( &Id );
m_CurrentTrack.m_Length = Id * 1000;
}
else if( ItemName == wxT( "url" ) )
{
m_CurrentTrack.m_FileName = xmlnode->GetNodeContent();
m_CurrentTrack.m_FileName.Replace( wxT( ".mp3" ), wxT( "" ) );
}
else if( ItemName == wxT( "magnatunegenres" ) )
{
m_CurrentTrack.m_GenreName = xmlnode->GetNodeContent();
m_CurrentTrack.m_GenreId = m_Db->GetGenreId( m_CurrentTrack.m_GenreName );
AddGenres( m_CurrentTrack.m_GenreName );
}
else if( ItemName == wxT( "cover_small" ) )
{
//<cover_small>http://he3.magnatune.com/music/Dr%20Kuch/We%20Can't%20Stop%20Progress/cover_200.jpg</cover_small>
m_CoverLink = xmlnode->GetNodeContent();
m_CoverLink.Replace( wxT( "cover_200" ), wxT( "cover_600" ) );
}
else if( ItemName == wxT( "albumsku" ) )
{
m_AlbumSku = xmlnode->GetNodeContent();
}
xmlnode = xmlnode->GetNext();
}
}
// -------------------------------------------------------------------------------- //
void guMagnatuneUpdateThread::ReadMagnatuneXmlAlbum( wxXmlNode * xmlnode )
{
long Id;
while( xmlnode && !TestDestroy() )
{
wxString ItemName = xmlnode->GetName();
if( ItemName == wxT( "artist" ) )
{
m_CurrentTrack.m_ArtistName = xmlnode->GetNodeContent().Trim( true ).Trim( false );
m_CurrentTrack.m_ArtistId = m_Db->GetArtistId( m_CurrentTrack.m_ArtistName );
}
else if( ItemName == wxT( "albumname" ) )
{
m_CurrentTrack.m_AlbumName = xmlnode->GetNodeContent().Trim( true ).Trim( false );
m_CurrentTrack.m_AlbumId = 0;
//guLogMessage( wxT( "%s" ), m_CurrentTrack.m_AlbumName.c_str() );
}
else if( ItemName == wxT( "year" ) )
{
xmlnode->GetNodeContent().ToLong( &Id );
m_CurrentTrack.m_Year = Id;
}
else if( ItemName == wxT( "magnatunegenres" ) )
{
m_CurrentTrack.m_GenreName = xmlnode->GetNodeContent();
m_CurrentTrack.m_GenreId = m_Db->GetGenreId( m_CurrentTrack.m_GenreName );
AddGenres( m_CurrentTrack.m_GenreName );
}
else if( ItemName == wxT( "Track" ) )
{
m_AlbumSku = wxEmptyString;
m_CoverLink = wxEmptyString;
if( !m_CurrentTrack.m_AlbumId )
{
m_CurrentTrack.m_Path = m_CurrentTrack.m_GenreName + wxT( "/" ) +
m_CurrentTrack.m_ArtistName + wxT( "/" ) +
m_CurrentTrack.m_AlbumName + wxT( "/" );
m_CurrentTrack.m_PathId = m_Db->GetPathId( m_CurrentTrack.m_Path );
m_CurrentTrack.m_AlbumId = m_Db->GetAlbumId( m_CurrentTrack.m_AlbumName, m_CurrentTrack.m_ArtistId, m_CurrentTrack.m_PathId, m_CurrentTrack.m_Path );
}
ReadMagnatuneXmlTrack( xmlnode->GetChildren() );
if( IsGenreEnabled( m_AllowedGenres, m_CurrentTrack.m_GenreName ) )
{
m_Db->CreateNewSong( &m_CurrentTrack, m_AlbumSku, m_CoverLink );
}
}
xmlnode = xmlnode->GetNext();
}
}
// -------------------------------------------------------------------------------- //
bool guMagnatuneUpdateThread::UpgradeDatabase( void )
{
if( DownloadFile( guMAGNATUNE_DATABASE_DUMP_URL, guPATH_MAGNATUNE wxT( "album_info_xml.gz" ) ) )
{
wxFileInputStream Ins( guPATH_MAGNATUNE wxT( "album_info_xml.gz" ) );
if( Ins.IsOk() )
{
wxZlibInputStream ZIn( Ins );
if( ZIn.IsOk() )
{
wxFileOutputStream ZOuts( guPATH_MAGNATUNE wxT( "album_info.xml" ) );
if( ZOuts.IsOk() )
{
ZIn.Read( ZOuts );
return true;
}
}
}
else
{
guLogError( wxT( "Could not open the Magnatune local database copy" ) );
}
}
return false;
}
// -------------------------------------------------------------------------------- //
guMagnatuneUpdateThread::ExitCode guMagnatuneUpdateThread::Entry()
{
wxString query;
wxCommandEvent evtup( wxEVT_MENU, ID_STATUSBAR_GAUGE_UPDATE );
evtup.SetInt( m_GaugeId );
wxCommandEvent evtmax( wxEVT_MENU, ID_STATUSBAR_GAUGE_SETMAX );
evtmax.SetInt( m_GaugeId );
if( m_Action == guMAGNATUNE_ACTION_UPDATE &&
!wxFileExists( guPATH_MAGNATUNE wxT( "album_info.xml" ) ) )
{
m_Action = guMAGNATUNE_ACTION_UPGRADE;
}
guLogMessage( wxT( "Starting the Magnatune Update process..." ) );
if( !TestDestroy() && ( m_Action == guMAGNATUNE_ACTION_UPDATE || UpgradeDatabase() ) )
{
wxFile XmlFile( guPATH_MAGNATUNE wxT( "album_info.xml" ), wxFile::read );
if( XmlFile.IsOpened() )
{
guListItems CurrentGenres;
m_Db->GetGenres( &CurrentGenres, true );
wxArrayInt GenresToDel;
int Count = CurrentGenres.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( !IsGenreEnabled( m_AllowedGenres, CurrentGenres[ Index ].m_Name ) )
{
GenresToDel.Add( CurrentGenres[ Index ].m_Id );
}
}
query = wxT( "BEGIN TRANSACTION" );
m_Db->ExecuteUpdate( query );
if( GenresToDel.Count() )
{
query = wxT( "DELETE FROM songs WHERE " ) + ArrayToFilter( GenresToDel, wxT( "song_genreid" ) );
//guLogMessage( wxT( "%s" ), query.c_str() );
m_Db->ExecuteUpdate( query );
}
evtmax.SetExtraLong( XmlFile.Length() );
wxPostEvent( guMainFrame::GetMainFrame(), evtmax );
wxFileOffset CurPos;
if( m_AllowedGenres.Count() )
{
wxString AlbumChunk = guGetNextXMLChunk( XmlFile, CurPos, "<Album>", "</Album>", wxConvISO8859_1 );
while( !TestDestroy() && !AlbumChunk.IsEmpty() )
{
// wxHtmlEntitiesParser EntitiesParser;
// AlbumChunk = EntitiesParser.Parse( AlbumChunk );
// AlbumChunk.Replace( wxT( "&" ), wxT( "&" ) );
wxStringInputStream Ins( AlbumChunk );
wxXmlDocument XmlDoc( Ins );
if( XmlDoc.IsOk() )
{
wxXmlNode * XmlNode = XmlDoc.GetRoot();
if( XmlNode && XmlNode->GetName() == wxT( "Album" ) )
{
ReadMagnatuneXmlAlbum( XmlNode->GetChildren() );
}
}
else
{
guLogMessage( wxT( "Error in album chunk:\n%s" ), AlbumChunk.c_str() );
}
AlbumChunk = guGetNextXMLChunk( XmlFile, CurPos, "<Album>", "</Album>", wxConvISO8859_1 );
//guLogMessage( wxT( "Chunk : '%s ... %s'" ), AlbumChunk.Left( 35 ).c_str(), AlbumChunk.Right( 35 ).c_str() );
evtup.SetExtraLong( CurPos );
wxPostEvent( guMainFrame::GetMainFrame(), evtup );
}
if( m_GenreList.Count() )
{
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->WriteAStr( CONFIG_KEY_MAGNATUNE_GENRES_GENRE, m_GenreList, CONFIG_PATH_MAGNATUNE_GENRELIST );
Config->Flush();
}
}
query = wxT( "END TRANSACTION" );
m_Db->ExecuteUpdate( query );
XmlFile.Close();
}
}
return 0;
}
// -------------------------------------------------------------------------------- //
//
// -------------------------------------------------------------------------------- //
guMediaViewerMagnatune::guMediaViewerMagnatune( wxWindow * parent, guMediaCollection &mediacollection,
const int basecmd, guMainFrame * mainframe, const int mode, guPlayerPanel * playerpanel ) :
guMediaViewer( parent, mediacollection, basecmd, mainframe, mode, playerpanel )
{
// m_DownloadThread = NULL;
m_ContextMenuFlags = ( guCONTEXTMENU_DOWNLOAD_COVERS | guCONTEXTMENU_LINKS );
guConfig * Config = ( guConfig * ) guConfig::Get();
m_Membership = Config->ReadNum( CONFIG_KEY_MAGNATUNE_MEMBERSHIP, 0, CONFIG_PATH_MAGNATUNE );
m_UserName = Config->ReadStr( CONFIG_KEY_MAGNATUNE_USERNAME, wxEmptyString, CONFIG_PATH_MAGNATUNE );
m_Password = Config->ReadStr( CONFIG_KEY_MAGNATUNE_PASSWORD, wxEmptyString, CONFIG_PATH_MAGNATUNE );
Bind( wxEVT_MENU, &guMediaViewerMagnatune::OnCoverDownloaded, this, ID_MAGNATUNE_COVER_DOWNLAODED );
Bind( wxEVT_MENU, &guMediaViewerMagnatune::OnUpdateFinished, this, ID_MAGNATUNE_UPDATE_FINISHED );
InitMediaViewer( mode );
}
// -------------------------------------------------------------------------------- //
guMediaViewerMagnatune::~guMediaViewerMagnatune()
{
Unbind( wxEVT_MENU, &guMediaViewerMagnatune::OnCoverDownloaded, this, ID_MAGNATUNE_COVER_DOWNLAODED );
Unbind( wxEVT_MENU, &guMediaViewerMagnatune::OnUpdateFinished, this, ID_MAGNATUNE_UPDATE_FINISHED );
}
// -------------------------------------------------------------------------------- //
void guMediaViewerMagnatune::LoadMediaDb( void )
{
guLogMessage( wxT( "LoadMediaDb... MAGNATUNE..." ) );
m_Db = new guJamendoLibrary( guPATH_COLLECTIONS + m_MediaCollection->m_UniqueId + wxT( "/guayadeque.db" ) );
m_Db->SetMediaViewer( this );
}
// -------------------------------------------------------------------------------- //
void guMediaViewerMagnatune::OnConfigUpdated( wxCommandEvent &event )
{
guMediaViewer::OnConfigUpdated( event );
if( event.GetInt() & guPREFERENCE_PAGE_FLAG_MAGNATUNE )
{
guConfig * Config = ( guConfig * ) guConfig::Get();
m_Membership = Config->ReadNum( CONFIG_KEY_MAGNATUNE_MEMBERSHIP, guMAGNATUNE_MEMBERSHIP_FREE, CONFIG_PATH_MAGNATUNE );
m_UserName = Config->ReadStr( CONFIG_KEY_MAGNATUNE_USERNAME, wxEmptyString, CONFIG_PATH_MAGNATUNE );
m_Password = Config->ReadStr( CONFIG_KEY_MAGNATUNE_PASSWORD, wxEmptyString, CONFIG_PATH_MAGNATUNE );
if( m_UserName.IsEmpty() || m_Password.IsEmpty() )
{
m_Membership = guMAGNATUNE_MEMBERSHIP_FREE;
}
if( Config->ReadBool( CONFIG_KEY_MAGNATUNE_NEED_UPGRADE, false, CONFIG_PATH_MAGNATUNE ) )
{
UpdateLibrary();
}
}
}
// -------------------------------------------------------------------------------- //
void guMediaViewerMagnatune::UpdateLibrary( void )
{
int GaugeId;
GaugeId = m_MainFrame->AddGauge( m_MediaCollection->m_Name );
if( m_UpdateThread )
{
m_UpdateThread->Pause();
m_UpdateThread->Delete();
}
m_UpdateThread = new guMagnatuneUpdateThread( this, guMAGNATUNE_ACTION_UPDATE, GaugeId );
}
// -------------------------------------------------------------------------------- //
void guMediaViewerMagnatune::UpgradeLibrary( void )
{
int GaugeId;
GaugeId = m_MainFrame->AddGauge( m_MediaCollection->m_Name );
if( m_UpdateThread )
{
m_UpdateThread->Pause();
m_UpdateThread->Delete();
}
m_UpdateThread = new guMagnatuneUpdateThread( this, guMAGNATUNE_ACTION_UPGRADE, GaugeId );
}
// -------------------------------------------------------------------------------- //
void guMediaViewerMagnatune::NormalizeTracks( guTrackArray * tracks, const bool isdrag )
{
int Count;
if( tracks && ( Count = tracks->Count() ) )
{
guConfig * Config = ( guConfig * ) guConfig::Get();
int AudioFormat = Config->ReadNum( CONFIG_KEY_MAGNATUNE_AUDIO_FORMAT, 1, CONFIG_PATH_MAGNATUNE );
for( int Index = 0; Index < Count; Index++ )
{
guTrack * Track = &( * tracks )[ Index ];
//guLogMessage( wxT( "'%s'" ), Track->m_FileName.c_str() );
guLogMessage( wxT( "The AlbumName: '%s'" ), Track->m_AlbumName.c_str() );
if( !Track->m_FileName.EndsWith( AudioFormat ? guMAGNATUNE_STREAM_FORMAT_OGG : guMAGNATUNE_STREAM_FORMAT_MP3 ) )
{
Track->m_FileName = Track->m_FileName.Mid( Track->m_FileName.Find( wxT( "http://he3." ) ) );
if( m_Membership > guMAGNATUNE_MEMBERSHIP_FREE ) // Streaming or Downloading
{
Track->m_FileName.Replace( wxT( "//he3." ), wxT( "//" ) + m_UserName + wxT( ":" ) +
m_Password + ( ( m_Membership == guMAGNATUNE_MEMBERSHIP_STREAM ) ? wxT( "@stream." ) : wxT( "@download." ) ) );
Track->m_FileName += wxT( "_nospeech" );
}
Track->m_FileName += AudioFormat ? guMAGNATUNE_STREAM_FORMAT_OGG : guMAGNATUNE_STREAM_FORMAT_MP3;
Track->m_Type = guTRACK_TYPE_MAGNATUNE;
if( isdrag )
Track->m_FileName.Replace( wxT( "http://" ), wxT( "/" ) );
}
}
}
}
// -------------------------------------------------------------------------------- //
void guMediaViewerMagnatune::AddDownload( const int albumid, const wxString &artist, const wxString &album )
{
guMagnatuneDownloadThread * DownloadThread = new guMagnatuneDownloadThread( this, albumid, artist, album );
if( !DownloadThread )
{
guLogMessage( wxT( "Could not create the magnatune download thread" ) );
}
}
// -------------------------------------------------------------------------------- //
void guMediaViewerMagnatune::OnCoverDownloaded( wxCommandEvent &event )
{
AlbumCoverChanged( event.GetInt() );
}
// -------------------------------------------------------------------------------- //
void guMediaViewerMagnatune::EndUpdateThread( void )
{
m_UpdateThread = NULL;
}
// -------------------------------------------------------------------------------- //
void guMediaViewerMagnatune::OnUpdateFinished( wxCommandEvent &event )
{
EndUpdateThread();
LibraryUpdated();
}
// -------------------------------------------------------------------------------- //
void guMediaViewerMagnatune::DownloadAlbumCover( const int albumid )
{
wxString Artist;
wxString Album;
if( m_Db->GetAlbumInfo( albumid, &Album, &Artist, NULL ) )
{
guLogMessage( wxT( "Starting download for %i '%s' '%s'" ), albumid, Artist.c_str(), Album.c_str() );
AddDownload( albumid, Artist, Album );
}
}
// -------------------------------------------------------------------------------- //
void guMediaViewerMagnatune::CreateContextMenu( wxMenu * menu, const int windowid )
{
wxMenu * Menu = new wxMenu();
wxMenuItem * MenuItem;
int BaseCommand = GetBaseCommand();
if( m_Membership == guMAGNATUNE_MEMBERSHIP_DOWNLOAD )
{
if( ( windowid == guLIBRARY_ELEMENT_ALBUMS ) )
{
MenuItem = new wxMenuItem( menu, ID_MAGNATUNE_DOWNLOAD_DIRECT_ALBUM, _( "Download Albums" ), _( "Download the current selected album" ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
}
else if( ( windowid == guLIBRARY_ELEMENT_TRACKS ) )
{
MenuItem = new wxMenuItem( menu, ID_MAGNATUNE_DOWNLOAD_DIRECT_TRACK_ALBUM, _( "Download Albums" ), _( "Download the current selected album" ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
}
}
MenuItem = new wxMenuItem( Menu, BaseCommand + guCOLLECTION_ACTION_UPDATE_LIBRARY, _( "Update" ), _( "Update the collection library" ), wxITEM_NORMAL );
Menu->Append( MenuItem );
MenuItem = new wxMenuItem( Menu, BaseCommand + guCOLLECTION_ACTION_RESCAN_LIBRARY, _( "Rescan" ), _( "Rescan the collection library" ), wxITEM_NORMAL );
Menu->Append( MenuItem );
MenuItem = new wxMenuItem( Menu, BaseCommand + guCOLLECTION_ACTION_SEARCH_COVERS, _( "Search Covers" ), _( "Search the collection missing covers" ), wxITEM_NORMAL );
Menu->Append( MenuItem );
Menu->AppendSeparator();
MenuItem = new wxMenuItem( Menu, BaseCommand + guCOLLECTION_ACTION_VIEW_PROPERTIES, _( "Properties" ), _( "Show collection properties" ), wxITEM_NORMAL );
Menu->Append( MenuItem );
menu->AppendSeparator();
menu->AppendSubMenu( Menu, wxT( "Magnatune" ) );
}
// -------------------------------------------------------------------------------- //
bool guMediaViewerMagnatune::CreateLibraryView( void )
{
guLogMessage( wxT( "CreateLibraryView... Magnatune...") );
m_LibPanel = new guMagnatunePanel( this, this );
m_LibPanel->SetBaseCommand( m_BaseCommand + 1 );
return true;
}
// -------------------------------------------------------------------------------- //
bool guMediaViewerMagnatune::CreateAlbumBrowserView( void )
{
m_AlbumBrowser = new guMagnatuneAlbumBrowser( this, this );
return true;
}
// -------------------------------------------------------------------------------- //
bool guMediaViewerMagnatune::CreateTreeView( void )
{
m_TreeViewPanel = new guMagnatuneTreePanel( this, this );
return true;
}
// -------------------------------------------------------------------------------- //
bool guMediaViewerMagnatune::CreatePlayListView( void )
{
m_PlayListPanel = new guMagnatunePlayListPanel( this, this );
return true;
}
// -------------------------------------------------------------------------------- //
wxImage * guMediaViewerMagnatune::GetAlbumCover( const int albumid, int &coverid,
wxString &coverpath, const wxString &artistname, const wxString &albumname )
{
wxImage * CoverImage = guMediaViewer::GetAlbumCover( albumid, coverid, coverpath, artistname, albumname );
if( CoverImage )
return CoverImage;
wxFileName CoverFile = wxFileName( guPATH_MAGNATUNE_COVERS +
wxString::Format( wxT( "%s-%s.jpg" ), artistname.c_str(), albumname.c_str() ) );
if( CoverFile.Normalize( wxPATH_NORM_ALL|wxPATH_NORM_CASE ) )
{
if( CoverFile.FileExists() )
{
wxImage * CoverImage = new wxImage( CoverFile.GetFullPath(), wxBITMAP_TYPE_JPEG );
if( CoverImage )
{
if( CoverImage->IsOk() )
{
coverpath = CoverFile.GetFullPath();
SetAlbumCover( albumid, guPATH_MAGNATUNE_COVERS, coverpath );
coverid = m_Db->GetAlbumCoverId( albumid );
return CoverImage;
}
delete CoverImage;
}
}
}
AddDownload( albumid, artistname, albumname );
return NULL;
}
// -------------------------------------------------------------------------------- //
wxString guMediaViewerMagnatune::GetCoverName( const int albumid )
{
wxString Artist;
wxString Album;
if( m_Db->GetAlbumInfo( albumid, &Album, &Artist, NULL ) )
{
return wxString::Format( wxT( "%s-%s" ), Artist.c_str(), Album.c_str() );
}
return wxEmptyString;
}
// -------------------------------------------------------------------------------- //
void guMediaViewerMagnatune::SelectAlbumCover( const int albumid )
{
guSelCoverFile * SelCoverFile = new guSelCoverFile( this, this, albumid );
if( SelCoverFile )
{
if( SelCoverFile->ShowModal() == wxID_OK )
{
wxString CoverFile = SelCoverFile->GetSelFile();
if( !CoverFile.IsEmpty() )
{
if( SetAlbumCover( albumid, guPATH_MAGNATUNE_COVERS, CoverFile ) )
{
if( SelCoverFile->EmbedToFiles() )
{
EmbedAlbumCover( albumid );
}
}
}
}
SelCoverFile->Destroy();
}
}
//<RESULT>
// <CC_AMOUNT>$</CC_AMOUNT>
// <CC_TRANSID></CC_TRANSID>
// <DL_PAGE>http://download.magnatune.com/artists/albums/satori-rainsleep/download</DL_PAGE>
// <URL_WAVZIP>http://download.magnatune.com/member/api_download.php?sku=satori-rainsleep&filename=wav.zip&path=http://download.magnatune.com/artists/music/Ambient/Satori/Sleep%20Under%20The%20Rain/wav.zip</URL_WAVZIP>
// <URL_128KMP3ZIP>http://download.magnatune.com/member/api_download.php?sku=satori-rainsleep&filename=mp3.zip&path=http://download.magnatune.com/artists/music/Ambient/Satori/Sleep%20Under%20The%20Rain/mp3.zip</URL_128KMP3ZIP>
// <URL_OGGZIP>http://download.magnatune.com/member/api_download.php?sku=satori-rainsleep&filename=Satori%20-%20Sleep%20Under%20The%20Rain%20-%20ogg.zip&path=http://download.magnatune.com/artists/music/Ambient/Satori/Sleep%20Under%20The%20Rain/satori-rainsleep-ogg.zip</URL_OGGZIP>
// <URL_VBRZIP>http://download.magnatune.com/member/api_download.php?sku=satori-rainsleep&filename=Satori%20-%20Sleep%20Under%20The%20Rain%20-%20vbr.zip&path=http://download.magnatune.com/artists/music/Ambient/Satori/Sleep%20Under%20The%20Rain/satori-rainsleep-vbr.zip</URL_VBRZIP>
// <URL_FLACZIP>http://download.magnatune.com/member/api_download.php?sku=satori-rainsleep&filename=Satori%20-%20Sleep%20Under%20The%20Rain%20-%20flac.zip&path=http://download.magnatune.com/artists/music/Ambient/Satori/Sleep%20Under%20The%20Rain/satori-rainsleep-flac.zip</URL_FLACZIP>
// <DL_MSG>
//Go here to download your music:
//http://download.magnatune.com/artists/albums/satori-rainsleep/download
//----------
//Give this album away for free!
//You can pass these download instructions on to 3 friends. It's completely legal
//and you'll be helping us fight the evil music industry! Complete details here:
//http://magnatune.com/info/give
//Help spread the word of Magnatune, with our free recruiting cards!
//http://magnatune.com/cards
//Podcasters, use our music:<br>
//http://magnatune.com/info/podcast
//To send us email:
//https://magnatune.com/info/email_us
// </DL_MSG>
//</RESULT>
// -------------------------------------------------------------------------------- //
void guMediaViewerMagnatune::DownloadAlbums( const wxArrayInt &albumids )
{
wxString StartLabel[] = {
wxT( "<DL_PAGE>" ),
wxT( "<URL_VBRZIP>" ),
wxT( "<URL_128KMP3ZIP>" ),
wxT( "<URL_OGGZIP>" ),
wxT( "<URL_FLACZIP>" ),
wxT( "<URL_WAVZIP>" ),
};
int Count;
if( ( Count = albumids.Count() ) )
{
guConfig * Config = ( guConfig * ) guConfig::Get();
int DownloadFormat = Config->ReadNum( CONFIG_KEY_MAGNATUNE_DOWNLOAD_FORMAT, 0, CONFIG_PATH_MAGNATUNE );
//guLogMessage( wxT( "DownloadFormat: %i %s" ), DownloadFormat, StartLabel[ DownloadFormat ].c_str() );
if( ( DownloadFormat < 0 ) || ( DownloadFormat > 5 ) )
{
DownloadFormat = 0;
}
for( int Index = 0; Index < Count; Index++ )
{
wxString DownloadUrl = wxString::Format( guMAGNATUNE_DOWNLOAD_URL,
m_UserName.c_str(), m_Password.c_str(),
( ( guMagnatuneLibrary * ) m_Db )->GetAlbumSku( albumids[ Index ] ).c_str() );
//guLogMessage( wxT( "Trying to download %s" ), DownloadUrl.c_str() );
wxString Content = GetUrlContent( DownloadUrl );
if( !Content.IsEmpty() )
{
//guLogMessage( wxT( "Result:\n%s" ), Content.c_str() );
DownloadUrl = DoExtractTag( Content, StartLabel[ DownloadFormat ] );
//guLogMessage( wxT( "Extracted url: %s" ), DownloadUrl.c_str() );
if( !DownloadUrl.IsEmpty() )
{
DownloadUrl = wxString::Format( wxT( "http://%s:%s@" ), m_UserName.c_str(), m_Password.c_str() ) + DownloadUrl.Mid( 7 );
//guLogMessage( wxT( "Trying to download the url : '%s'" ), DownloadUrl.c_str() );
guWebExecute( DownloadUrl );
}
}
else
{
guLogError( wxT( "Could not get the album download info" ) );
}
}
}
}
// -------------------------------------------------------------------------------- //
bool guMediaViewerMagnatune::FindMissingCover( const int albumid, const wxString &artistname, const wxString &albumname, const wxString &albumpath )
{
AddDownload( albumid, artistname, albumname );
return true;
}
// -------------------------------------------------------------------------------- //
void guMediaViewerMagnatune::EditProperties( void )
{
wxCommandEvent CmdEvent( wxEVT_MENU, ID_MENU_PREFERENCES );
CmdEvent.SetInt( guPREFERENCE_PAGE_MAGNATUNE );
wxPostEvent( m_MainFrame, CmdEvent );
}
}
// -------------------------------------------------------------------------------- //
| 48,811
|
C++
|
.cpp
| 1,064
| 38.18609
| 294
| 0.544086
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
750,647
|
AutoPulseGauge.cpp
|
anonbeat_guayadeque/src/ui/autopulsegauge/AutoPulseGauge.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "AutoPulseGauge.h"
#include "Utils.h"
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
guAutoPulseGauge::guAutoPulseGauge( wxWindow * parent, wxWindowID id, int range, const wxPoint &pos,
const wxSize &size, long style, const wxValidator& validator, const wxString &name ) :
wxGauge( parent, id, range, pos, size, style, validator, name )
{
m_Timer = new guGaugeTimer( this );
m_Timer->Start( 300 );
}
// -------------------------------------------------------------------------------- //
guAutoPulseGauge::~guAutoPulseGauge( void )
{
if( m_Timer )
delete m_Timer;
}
// -------------------------------------------------------------------------------- //
void guAutoPulseGauge::StopPulse( int range, int value )
{
m_Timer->Stop();
SetRange( range );
SetValue( value );
}
// -------------------------------------------------------------------------------- //
void guAutoPulseGauge::StartPulse( void )
{
m_Timer->Start( 300 );
}
// -------------------------------------------------------------------------------- //
bool guAutoPulseGauge::IsPulsing( void )
{
return m_Timer->IsRunning();
}
}
// -------------------------------------------------------------------------------- //
| 2,356
|
C++
|
.cpp
| 57
| 39.192982
| 100
| 0.497163
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,648
|
Vumeters.cpp
|
anonbeat_guayadeque/src/ui/vumeters/Vumeters.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "Vumeters.h"
#include "Utils.h"
namespace Guayadeque {
#define guVUMETERS_LEVEL_TIMEOUT 300
#define guVUMETERS_LEVEL_TIMERID 9
// -------------------------------------------------------------------------------- //
BEGIN_EVENT_TABLE( guVumeter, wxControl )
EVT_PAINT( guVumeter::OnPaint )
END_EVENT_TABLE()
// -------------------------------------------------------------------------------- //
// guVumter
// -------------------------------------------------------------------------------- //
guVumeter::guVumeter( wxWindow * parent, wxWindowID id, const int style ) :
wxControl( parent, id, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE )
{
m_Style = style;
m_PeakLevel = -INFINITY;
m_RmsLevel = -INFINITY;
m_DecayLevel = -INFINITY;
m_Green = guVumeterColour( wxColour( 0, 128, 0 ),
wxColour( 0, 255, 0 ),
wxColour( 0, 230, 0 ) );
m_Orange = guVumeterColour( wxColour( 191, 95, 0 ),
wxColour( 255, 128, 0 ),
wxColour( 230, 128, 0 ) );
m_Red = guVumeterColour( wxColour( 128, 0, 0 ),
wxColour( 255, 0, 0 ),
wxColour( 230, 0, 0 ) );
m_OffBitmap = NULL;
m_PeakBitmap = NULL;
m_RmsBitmap = NULL;
m_LastHeight = wxNOT_FOUND;
m_LastWidth = wxNOT_FOUND;
Bind( wxEVT_SIZE, &guVumeter::OnChangedSize, this );
}
// -------------------------------------------------------------------------------- //
guVumeter::~guVumeter()
{
wxMutexLocker Locker( m_BitmapMutex );
if( m_OffBitmap )
{
delete m_OffBitmap;
m_OffBitmap = NULL;
}
if( m_PeakBitmap )
{
delete m_PeakBitmap;
m_PeakBitmap = NULL;
}
if( m_RmsBitmap )
{
delete m_RmsBitmap;
m_RmsBitmap = NULL;
}
Unbind( wxEVT_SIZE, &guVumeter::OnChangedSize, this );
}
// -------------------------------------------------------------------------------- //
wxSize guVumeter::DoGetBestSize() const
{
if( m_Style == guVU_HORIZONTAL )
return wxSize( 20, 4 );
else
return wxSize( 4, 20 );
}
// -------------------------------------------------------------------------------- //
static inline float IEC_Scale( float db )
{
float fScale = 1.0f;
if( db < -70.0f )
fScale = 0.0f;
else if( db < -60.0f )
fScale = ( db + 70.0f ) * 0.0025f;
else if( db < -50.0f )
fScale = ( db + 60.0f ) * 0.005f + 0.025f;
else if( db < -40.0 )
fScale = ( db + 50.0f ) * 0.0075f + 0.075f;
else if( db < -30.0f )
fScale = ( db + 40.0f ) * 0.015f + 0.15f;
else if( db < -20.0f )
fScale = ( db + 30.0f ) * 0.02f + 0.3f;
else if( db < -0.001f || db > 0.001f )
fScale = ( db + 20.0f ) * 0.025f + 0.5f;
return fScale;
}
//// -------------------------------------------------------------------------------- //
//double TestValues[] = {
// -60.0,
// -55.0,
// -50.0,
// -45.0,
// -40.0,
// -35.0,
// -30.0,
// -25.0,
// -20.0,
// -15.0,
// -10.0,
// -8.0,
// -6.0,
// -5.0,
// -4.0,
// -3.0,
// -2.0,
// -1.0,
// -0.0
//};
// -------------------------------------------------------------------------------- //
void guVumeter::PaintHoriz( void )
{
wxPaintDC dc( this );
wxCoord Width;
wxCoord Height;
GetClientSize( &Width, &Height );
//m_PeakLevel = TestValues[ wxGetUTCTime() % 19 ];
//guLogMessage( wxT( "%0.2f -> %0.2f" ), m_PeakLevel, IEC_Scale( m_PeakLevel ) );
int PeakLevel = IEC_Scale( m_PeakLevel ) * 100;
int RmsLevel = IEC_Scale( m_RmsLevel ) * 100;
int DecayLevel = IEC_Scale( m_DecayLevel ) * 100;
//guLogMessage( wxT( "Peak: %i %i" ), PeakLevel, DecayLevel );
dc.SetPen( * wxTRANSPARENT_PEN );
dc.DrawBitmap( * m_OffBitmap, 0, 0, false );
wxRect ClipRect;
ClipRect.height = Height;
if( PeakLevel )
{
ClipRect.y = 0;
ClipRect.x = 0;
ClipRect.width = ( PeakLevel * Width ) / 100;
dc.SetClippingRegion( ClipRect );
dc.DrawBitmap( * m_PeakBitmap, 0, 0, false );
dc.DestroyClippingRegion();
}
if( RmsLevel )
{
ClipRect.y = 0;
ClipRect.x = 0;
ClipRect.width = ( RmsLevel * Width ) / 100;
dc.SetClippingRegion( ClipRect );
dc.DrawBitmap( * m_RmsBitmap, 0, 0, false );
dc.DestroyClippingRegion();
}
if( DecayLevel && ( DecayLevel > PeakLevel ) && ( DecayLevel < 100 ) )
{
ClipRect.x = ( DecayLevel * Width ) / 100;;
ClipRect.width = 2;
dc.SetClippingRegion( ClipRect );
dc.DrawBitmap( * m_PeakBitmap, 0, 0, false );
dc.DestroyClippingRegion();
}
dc.SetPen( * wxBLACK_PEN );
dc.DrawText( wxString::Format( wxT( "%02.1f" ), m_PeakLevel ), 2, ( Height / 2 ) - 8 );
}
// -------------------------------------------------------------------------------- //
void guVumeter::PaintVert( void )
{
wxPaintDC dc( this );
wxCoord Width;
wxCoord Height;
GetClientSize( &Width, &Height );
//guLogMessage( wxT( "%0.2f -> %0.2f" ), m_PeakLevel, IEC_Scale( m_PeakLevel ) );
//m_PeakLevel = TestValues[ wxGetUTCTime() % 20 ];
int PeakLevel = IEC_Scale( m_PeakLevel ) * 100;
int RmsLevel = IEC_Scale( m_RmsLevel ) * 100;
int DecayLevel = IEC_Scale( m_DecayLevel ) * 100;
//guLogMessage( wxT( "Peak: %i" ), PeakLevel );
dc.SetPen( * wxTRANSPARENT_PEN );
dc.DrawBitmap( * m_OffBitmap, 0, 0, false );
wxRect ClipRect;
ClipRect.width = Width;
if( PeakLevel )
{
ClipRect.x = 0;
ClipRect.height = ( PeakLevel * Height ) / 100;
ClipRect.y = Height - ClipRect.height;
dc.SetClippingRegion( ClipRect );
dc.DrawBitmap( * m_PeakBitmap, 0, 0, false );
dc.DestroyClippingRegion();
}
if( RmsLevel )
{
ClipRect.x = 0;
ClipRect.height = ( RmsLevel * Height ) / 100;
ClipRect.y = Height - ClipRect.height;
dc.SetClippingRegion( ClipRect );
dc.DrawBitmap( * m_RmsBitmap, 0, 0, false );
dc.DestroyClippingRegion();
}
if( DecayLevel && ( DecayLevel > PeakLevel ) && ( DecayLevel < 100 ) )
{
ClipRect.height = 2;
ClipRect.y = Height - ( DecayLevel * Height ) / 100;
dc.SetClippingRegion( ClipRect );
dc.DrawBitmap( * m_PeakBitmap, 0, 0, false );
dc.DestroyClippingRegion();
}
dc.SetPen( * wxBLACK_PEN );
dc.DrawRotatedText( wxString::Format( wxT( "%02.1f" ), m_PeakLevel ), ( Width / 2 ) - 7, Height - 2, 90 );
}
// -------------------------------------------------------------------------------- //
void guVumeter::DrawHVumeter( wxBitmap * bitmap, int width, int height, wxColour &green, wxColour &orange, wxColour &red )
{
if( bitmap && bitmap->IsOk() )
{
wxRect Rect;
wxMemoryDC MemDC;
MemDC.SelectObject( * bitmap );
MemDC.SetPen( * wxTRANSPARENT_PEN );
Rect.x = 0;
Rect.y = 0;
Rect.height = height;
Rect.width = ( 92 * width ) / 100;
MemDC.GradientFillLinear( Rect, green, orange );
Rect.x += Rect.width;
Rect.width = width - Rect.x;
MemDC.GradientFillLinear( Rect, orange, red );
}
}
// -------------------------------------------------------------------------------- //
void guVumeter::DrawVVumeter( wxBitmap * bitmap, int width, int height, wxColour &green, wxColour &orange, wxColour &red )
{
if( bitmap && bitmap->IsOk() )
{
wxRect Rect;
wxMemoryDC MemDC;
MemDC.SelectObject( * bitmap );
MemDC.SetPen( * wxTRANSPARENT_PEN );
Rect.x = 0;
Rect.width = width;
Rect.y = ( height * 8 ) / 100;
Rect.height = height - Rect.y;
MemDC.GradientFillLinear( Rect, green, orange, wxNORTH );
Rect.height = Rect.y;
Rect.y = 0;
MemDC.GradientFillLinear( Rect, orange, red, wxNORTH );
}
}
// -------------------------------------------------------------------------------- //
void guVumeter::RefreshBitmaps( void )
{
wxMutexLocker Locker( m_BitmapMutex );
if( m_OffBitmap )
delete m_OffBitmap;
if( m_PeakBitmap )
delete m_PeakBitmap;
if( m_RmsBitmap )
delete m_RmsBitmap;
wxCoord Width;
wxCoord Height;
GetClientSize( &Width, &Height );
if( !Width )
Width = 10;
if( !Height )
Height = 10;
//guLogMessage( wxT( "RefreshBitmaps %i %i " ), Width, Height );
if( m_Style == guVU_HORIZONTAL )
{
m_OffBitmap = new wxBitmap( Width, Height, -1 );
DrawHVumeter( m_OffBitmap, Width, Height, m_Green.m_Off, m_Orange.m_Off, m_Red.m_Off );
m_PeakBitmap = new wxBitmap( Width, Height, -1 );
DrawHVumeter( m_PeakBitmap, Width, Height, m_Green.m_Peak, m_Orange.m_Peak, m_Red.m_Peak);
m_RmsBitmap = new wxBitmap( Width, Height, -1 );
DrawHVumeter( m_RmsBitmap, Width, Height, m_Green.m_Rms, m_Orange.m_Rms, m_Red.m_Rms );
}
else
{
m_OffBitmap = new wxBitmap( Width, Height, -1 );
DrawVVumeter( m_OffBitmap, Width, Height, m_Green.m_Off, m_Orange.m_Off, m_Red.m_Off );
m_PeakBitmap = new wxBitmap( Width, Height, -1 );
DrawVVumeter( m_PeakBitmap, Width, Height, m_Green.m_Peak, m_Orange.m_Peak, m_Red.m_Peak);
m_RmsBitmap = new wxBitmap( Width, Height, -1 );
DrawVVumeter( m_RmsBitmap, Width, Height, m_Green.m_Rms, m_Orange.m_Rms, m_Red.m_Rms );
}
}
// -------------------------------------------------------------------------------- //
void guVumeter::OnPaint( wxPaintEvent &WXUNUSED(event) )
{
wxMutexLocker Locker( m_BitmapMutex );
if( m_Style == guVU_HORIZONTAL )
PaintHoriz();
else
PaintVert();
}
// -------------------------------------------------------------------------------- //
void guVumeter::OnChangedSize( wxSizeEvent &event )
{
wxSize Size = event.GetSize();
if( ( Size.GetWidth() != m_LastWidth ) || ( Size.GetHeight() != m_LastHeight ) )
{
m_LastWidth = Size.GetWidth();
m_LastHeight = Size.GetHeight();
RefreshBitmaps();
}
event.Skip();
}
// -------------------------------------------------------------------------------- //
void guVumeter::SetLevel( const double peak, const double rms, const double decay )
{
if( ( m_PeakLevel != peak ) ||
( m_RmsLevel != rms ) ||
( m_DecayLevel != decay ) )
{
m_PeakLevel = peak;
m_RmsLevel = rms;
m_DecayLevel = decay;
Refresh();
//Update();
}
}
// -------------------------------------------------------------------------------- //
// guPlayerVumeters
// -------------------------------------------------------------------------------- //
guPlayerVumeters::guPlayerVumeters( wxWindow * parent ) :
wxPanel( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
m_LevelsTimer( this, guVUMETERS_LEVEL_TIMERID )
{
m_LastWidth = wxNOT_FOUND;
m_LastHeight = wxNOT_FOUND;
wxFont CurrentFont = wxSystemSettings::GetFont( wxSYS_SYSTEM_FONT );
m_VumMainSizer = new wxBoxSizer( wxVERTICAL );
//
// Create the Horizontal vumeter layout
//
m_HVumFlexSizer = new wxFlexGridSizer( 2, 0, 0 );
m_HVumFlexSizer->AddGrowableCol( 1 );
m_HVumFlexSizer->AddGrowableRow( 0 );
m_HVumFlexSizer->AddGrowableRow( 2 );
m_HVumFlexSizer->SetFlexibleDirection( wxBOTH );
m_HVumFlexSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
CurrentFont.SetPointSize( CurrentFont.GetPointSize() - 3 );
wxStaticText * HVumLeftLabel = new wxStaticText( this, wxID_ANY, wxT("L:"), wxDefaultPosition, wxDefaultSize, 0 );
HVumLeftLabel->Wrap( -1 );
HVumLeftLabel->SetFont( CurrentFont );
m_HVumFlexSizer->Add( HVumLeftLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxTOP, 5 );
m_HVumLeft = new guVumeter( this, wxID_ANY ); //, 100, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL|wxGA_SMOOTH );
m_HVumFlexSizer->Add( m_HVumLeft, 1, wxEXPAND|wxTOP|wxRIGHT, 5 );
wxBoxSizer * HLabelsSizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticText * HDbLabel = new wxStaticText( this, wxID_ANY, wxT("db"), wxDefaultPosition, wxDefaultSize, 0 );
HDbLabel->Wrap( -1 );
HDbLabel->SetFont( CurrentFont );
m_HVumFlexSizer->Add( HDbLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
wxStaticText * HSixtyLevel = new wxStaticText( this, wxID_ANY, wxT("-60"), wxDefaultPosition, wxDefaultSize, 0 );
HSixtyLevel->Wrap( -1 );
HSixtyLevel->SetFont( CurrentFont );
HLabelsSizer->Add( HSixtyLevel, 13, wxALIGN_CENTER_VERTICAL, 5 );
wxStaticText * HFortyLevel = new wxStaticText( this, wxID_ANY, wxT("-40"), wxDefaultPosition, wxDefaultSize, 0 );
HFortyLevel->Wrap( -1 );
HFortyLevel->SetFont( CurrentFont );
HLabelsSizer->Add( HFortyLevel, 17, wxALIGN_CENTER_VERTICAL, 5 );
wxStaticText * HThirtyLevel = new wxStaticText( this, wxID_ANY, wxT("-30"), wxDefaultPosition, wxDefaultSize, 0 );
HThirtyLevel->Wrap( -1 );
HThirtyLevel->SetFont( CurrentFont );
HLabelsSizer->Add( HThirtyLevel, 23, wxALIGN_CENTER_VERTICAL, 5 );
wxStaticText * HTwentyLevel = new wxStaticText( this, wxID_ANY, wxT("-20"), wxDefaultPosition, wxDefaultSize, 0 );
HTwentyLevel->Wrap( -1 );
HTwentyLevel->SetFont( CurrentFont );
HLabelsSizer->Add( HTwentyLevel, 27, wxALIGN_CENTER_VERTICAL, 5 );
wxStaticText * HTenLevel = new wxStaticText( this, wxID_ANY, wxT("-10"), wxDefaultPosition, wxDefaultSize, 0 );
HTenLevel->Wrap( -1 );
HTenLevel->SetFont( CurrentFont );
HLabelsSizer->Add( HTenLevel, 13, wxALIGN_CENTER_VERTICAL, 5 );
wxStaticText * HOrangeLevel = new wxStaticText( this, wxID_ANY, wxT("-6"), wxDefaultPosition, wxDefaultSize, 0 );
HOrangeLevel->Wrap( -1 );
HOrangeLevel->SetFont( CurrentFont );
HLabelsSizer->Add( HOrangeLevel, 7, wxALIGN_CENTER_VERTICAL, 5 );
wxStaticText * HRedLabel = new wxStaticText( this, wxID_ANY, wxT("-3"), wxDefaultPosition, wxDefaultSize, 0 );
HRedLabel->Wrap( -1 );
HRedLabel->SetFont( CurrentFont );
HLabelsSizer->Add( HRedLabel, 7, wxALIGN_CENTER_VERTICAL, 5 );
wxStaticText * HClipLabel = new wxStaticText( this, wxID_ANY, wxT("0"), wxDefaultPosition, wxDefaultSize, 0 );
HClipLabel->Wrap( -1 );
HClipLabel->SetFont( CurrentFont );
HLabelsSizer->Add( HClipLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
m_HVumFlexSizer->Add( HLabelsSizer, 0, wxEXPAND, 5 );
wxStaticText * HVumRightLabel = new wxStaticText( this, wxID_ANY, wxT("R:"), wxDefaultPosition, wxDefaultSize, 0 );
HVumRightLabel->Wrap( -1 );
HVumRightLabel->SetFont( CurrentFont );
m_HVumFlexSizer->Add( HVumRightLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
m_HVumRight = new guVumeter( this, wxID_ANY ); //, 100, wxDefaultPosition, wxSize( -1,-1 ), wxGA_HORIZONTAL );
m_HVumFlexSizer->Add( m_HVumRight, 1, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
m_VumMainSizer->Add( m_HVumFlexSizer, 1, wxEXPAND, 5 );
//
// Create the Vertical vumeter layout
//
m_VVumFlexSizer = new wxFlexGridSizer( 3, 0, 0 );
m_VVumFlexSizer->AddGrowableCol( 0 );
m_VVumFlexSizer->AddGrowableCol( 2 );
m_VVumFlexSizer->AddGrowableRow( 0 );
m_VVumFlexSizer->SetFlexibleDirection( wxBOTH );
m_VVumFlexSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_VVumLeft = new guVumeter( this, wxID_ANY, guVU_VERTICAL );
m_VVumFlexSizer->Add( m_VVumLeft, 1, wxEXPAND|wxTOP|wxLEFT, 5 );
wxBoxSizer * VLabelsSizer = new wxBoxSizer( wxVERTICAL );
wxStaticText * VClipLabel = new wxStaticText( this, wxID_ANY, wxT("0"), wxDefaultPosition, wxDefaultSize, 0 );
VClipLabel->Wrap( -1 );
VClipLabel->SetFont( CurrentFont );
VLabelsSizer->Add( VClipLabel, 8, wxALIGN_CENTER_HORIZONTAL|wxTOP, 5 );
wxStaticText * VRedLabel = new wxStaticText( this, wxID_ANY, wxT("-3"), wxDefaultPosition, wxDefaultSize, 0 );
VRedLabel->Wrap( -1 );
VRedLabel->SetFont( CurrentFont );
VLabelsSizer->Add( VRedLabel, 8, wxALIGN_CENTER_HORIZONTAL, 5 );
wxStaticText * VOrangeLabel = new wxStaticText( this, wxID_ANY, wxT("-6"), wxDefaultPosition, wxDefaultSize, 0 );
VOrangeLabel->Wrap( -1 );
VOrangeLabel->SetFont( CurrentFont );
VLabelsSizer->Add( VOrangeLabel, 12, wxALIGN_CENTER_HORIZONTAL, 5 );
wxStaticText * VTenLabel = new wxStaticText( this, wxID_ANY, wxT("-10"), wxDefaultPosition, wxDefaultSize, 0 );
VTenLabel->Wrap( -1 );
VTenLabel->SetFont( CurrentFont );
VLabelsSizer->Add( VTenLabel, 27, wxALIGN_CENTER_HORIZONTAL, 5 );
wxStaticText * VTwentyLabel = new wxStaticText( this, wxID_ANY, wxT("-20"), wxDefaultPosition, wxDefaultSize, 0 );
VTwentyLabel->Wrap( -1 );
VTwentyLabel->SetFont( CurrentFont );
VLabelsSizer->Add( VTwentyLabel, 23, wxALIGN_CENTER_HORIZONTAL, 5 );
wxStaticText * VThirtyLabel = new wxStaticText( this, wxID_ANY, wxT("-30"), wxDefaultPosition, wxDefaultSize, 0 );
VThirtyLabel->Wrap( -1 );
VThirtyLabel->SetFont( CurrentFont );
VLabelsSizer->Add( VThirtyLabel, 17, wxALIGN_CENTER_HORIZONTAL, 5 );
wxStaticText * VFortyLabel = new wxStaticText( this, wxID_ANY, wxT("-40"), wxDefaultPosition, wxDefaultSize, 0 );
VFortyLabel->Wrap( -1 );
VFortyLabel->SetFont( CurrentFont );
VLabelsSizer->Add( VFortyLabel, 15, wxALIGN_CENTER_HORIZONTAL, 5 );
wxStaticText * VSixtyLabel = new wxStaticText( this, wxID_ANY, wxT("-60"), wxDefaultPosition, wxDefaultSize, 0 );
VSixtyLabel->Wrap( -1 );
VSixtyLabel->SetFont( CurrentFont );
VLabelsSizer->Add( VSixtyLabel, 0, wxALIGN_CENTER_HORIZONTAL, 5 );
m_VVumFlexSizer->Add( VLabelsSizer, 0, wxEXPAND, 5 );
m_VVumRight = new guVumeter( this, wxID_ANY, guVU_VERTICAL );
m_VVumFlexSizer->Add( m_VVumRight, 1, wxEXPAND|wxTOP|wxRIGHT, 5 );
wxStaticText * VVumLeftLabel = new wxStaticText( this, wxID_ANY, wxT("L:"), wxDefaultPosition, wxDefaultSize, 0 );
VVumLeftLabel->Wrap( -1 );
VVumLeftLabel->SetFont( CurrentFont );
m_VVumFlexSizer->Add( VVumLeftLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL|wxLEFT, 5 );
wxStaticText * VDbLabel = new wxStaticText( this, wxID_ANY, wxT("db"), wxDefaultPosition, wxDefaultSize, 0 );
VDbLabel->Wrap( -1 );
VDbLabel->SetFont( CurrentFont );
m_VVumFlexSizer->Add( VDbLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 );
wxStaticText * VVumRightLabel = new wxStaticText( this, wxID_ANY, wxT("R:"), wxDefaultPosition, wxDefaultSize, 0 );
VVumRightLabel->Wrap( -1 );
VVumRightLabel->SetFont( CurrentFont );
m_VVumFlexSizer->Add( VVumRightLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL|wxRIGHT, 5 );
m_VumMainSizer->Add( m_VVumFlexSizer, 1, wxEXPAND, 5 );
m_VumMainSizer->Hide( m_VVumFlexSizer, false );
this->SetSizer( m_VumMainSizer );
this->Layout();
m_VumMainSizer->Fit( this );
Bind( wxEVT_SIZE, &guPlayerVumeters::OnChangedSize, this );
Bind( wxEVT_TIMER, &guPlayerVumeters::OnLevelsTimeout, this, guVUMETERS_LEVEL_TIMERID );
m_VumLeft = m_HVumLeft;
m_VumRight = m_HVumRight;
}
// -------------------------------------------------------------------------------- //
guPlayerVumeters::~guPlayerVumeters()
{
Unbind( wxEVT_SIZE, &guPlayerVumeters::OnChangedSize, this );
Unbind( wxEVT_TIMER, &guPlayerVumeters::OnLevelsTimeout, this, guVUMETERS_LEVEL_TIMERID );
}
// -------------------------------------------------------------------------------- //
void guPlayerVumeters::OnChangedSize( wxSizeEvent &event )
{
wxSize Size = event.GetSize();
if( ( Size.GetWidth() != m_LastWidth ) || ( Size.GetHeight() != m_LastHeight ) )
{
bool ChangedOrientation = false;
m_LastWidth = Size.GetWidth();
m_LastHeight = Size.GetHeight();
//guLogMessage( wxT( "%i, %i" ), Size.GetWidth(), Size.GetHeight() );
if( m_LastWidth >= m_LastHeight )
{
if( m_VumMainSizer->IsShown( m_VVumFlexSizer ) )
{
m_VumMainSizer->Hide( m_VVumFlexSizer );
m_VumMainSizer->Show( m_HVumFlexSizer );
m_VumLeft = m_HVumLeft;
m_VumRight = m_HVumRight;
ChangedOrientation = true;
}
}
else if( m_VumMainSizer->IsShown( m_HVumFlexSizer ) )
{
m_VumMainSizer->Hide( m_HVumFlexSizer );
m_VumMainSizer->Show( m_VVumFlexSizer );
m_VumLeft = m_VVumLeft;
m_VumRight = m_VVumRight;
ChangedOrientation = true;
}
if( ChangedOrientation )
{
m_VumMainSizer->Layout();
}
}
event.Skip();
}
// -------------------------------------------------------------------------------- //
void guPlayerVumeters::SetLevels( const guLevelInfo &levels )
{
m_LevelsTimer.Start( guVUMETERS_LEVEL_TIMEOUT, wxTIMER_ONE_SHOT );
m_VumLeft->SetLevel( levels.m_Peak_L, levels.m_RMS_L, levels.m_Decay_L );
if( levels.m_Channels > 1 )
m_VumRight->SetLevel( levels.m_Peak_R, levels.m_RMS_R, levels.m_Decay_R );
else
m_VumRight->SetLevel( levels.m_Peak_L, levels.m_RMS_L, levels.m_Decay_L );
}
// -------------------------------------------------------------------------------- //
void guPlayerVumeters::OnLevelsTimeout( wxTimerEvent &event )
{
double DecayL = m_VumLeft->DecayLevel();
double DecayR = m_VumRight->DecayLevel();
m_VumLeft->SetLevel( -99.0, -99.0, DecayL - 4.00 );
m_VumRight->SetLevel( -99.0, -99.0, DecayR - 4.00 );
if( ( DecayL > -70.0 ) || ( DecayR > -70.0 ) )
{
m_LevelsTimer.Start( guVUMETERS_LEVEL_TIMEOUT, wxTIMER_ONE_SHOT );
}
}
}
// -------------------------------------------------------------------------------- //
| 22,934
|
C++
|
.cpp
| 536
| 37.807836
| 122
| 0.587414
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,649
|
FileBrowser.cpp
|
anonbeat_guayadeque/src/ui/filebrowser/FileBrowser.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "FileBrowser.h"
#include "Accelerators.h"
#include "AuiDockArt.h"
#include "Config.h"
#include "FileRenamer.h"
#include "Images.h"
#include "LibUpdate.h"
#include "MainFrame.h"
#include "PlayListAppend.h"
#include "TagInfo.h"
#include "TrackEdit.h"
#include "Utils.h"
#include <wx/aui/aui.h>
#include <wx/arrimpl.cpp>
#include <wx/artprov.h>
#include <wx/clipbrd.h>
#include <wx/gtk/tglbtn.h>
namespace Guayadeque {
WX_DEFINE_OBJARRAY( guFileItemArray )
// -------------------------------------------------------------------------------- //
guMediaViewer * FindMediaViewerByPath( guMainFrame * mainframe, const wxString curpath )
{
const guMediaCollectionArray &Collections = mainframe->GetMediaCollections();
int Count = Collections.Count();
for( int Index = 0; Index < Count; Index++ )
{
const guMediaCollection & Collection = Collections[ Index ];
if( mainframe->IsCollectionActive( Collection.m_UniqueId ) )
{
int PathIndex;
int PathCount = Collection.m_Paths.Count();
for( PathIndex = 0; PathIndex < PathCount; PathIndex++ )
{
guLogMessage( wxT( "%s == %s" ), curpath.c_str(), Collection.m_Paths[ PathIndex ].c_str() );
if( curpath.StartsWith( Collection.m_Paths[ PathIndex ] ) )
{
return mainframe->FindCollectionMediaViewer( Collection.m_UniqueId );
}
}
}
}
return NULL;
}
// -------------------------------------------------------------------------------- //
// guGenericDirCtrl
// -------------------------------------------------------------------------------- //
wxBEGIN_EVENT_TABLE( guGenericDirCtrl, wxGenericDirCtrl )
EVT_TREE_BEGIN_LABEL_EDIT( wxID_ANY, guGenericDirCtrl::OnBeginRenameDir )
EVT_TREE_END_LABEL_EDIT( wxID_ANY, guGenericDirCtrl::OnEndRenameDir )
wxEND_EVENT_TABLE()
// -------------------------------------------------------------------------------- //
guGenericDirCtrl::guGenericDirCtrl( wxWindow * parent, guMainFrame * mainframe, const int showpaths ) :
wxGenericDirCtrl( parent, wxID_ANY, wxDirDialogDefaultFolderStr,
wxDefaultPosition, wxDefaultSize, wxDIRCTRL_SELECT_FIRST|wxDIRCTRL_DIR_ONLY|wxNO_BORDER|wxDIRCTRL_EDIT_LABELS ,
wxEmptyString, 0, wxTreeCtrlNameStr )
{
m_MainFrame = mainframe;
m_ShowPaths = showpaths;
m_FileBrowserDirCtrl = ( guFileBrowserDirCtrl * ) parent;
wxImageList * ImageList = GetTreeCtrl()->GetImageList();
ImageList->Add( guImage( guIMAGE_INDEX_tiny_library ) );
ImageList->Add( guImage( guIMAGE_INDEX_tiny_podcast ) );
ImageList->Add( guImage( guIMAGE_INDEX_tiny_record ) );
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->RegisterObject( this );
Bind( guConfigUpdatedEvent, &guGenericDirCtrl::OnConfigUpdated, this, ID_CONFIG_UPDATED );
}
// -------------------------------------------------------------------------------- //
guGenericDirCtrl::~guGenericDirCtrl()
{
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->UnRegisterObject( this );
Unbind( guConfigUpdatedEvent, &guGenericDirCtrl::OnConfigUpdated, this, ID_CONFIG_UPDATED );
}
// -------------------------------------------------------------------------------- //
void guGenericDirCtrl::OnConfigUpdated( wxCommandEvent &event )
{
int Flags = event.GetInt();
if( Flags & ( guPREFERENCE_PAGE_FLAG_LIBRARY | guPREFERENCE_PAGE_FLAG_RECORD | guPREFERENCE_PAGE_FLAG_PODCASTS ) )
{
if( m_ShowPaths != guFILEBROWSER_SHOWPATH_SYSTEM )
{
wxString CurPath = GetPath();
ReCreateTree();
SetPath( CurPath );
}
}
}
// -------------------------------------------------------------------------------- //
void guGenericDirCtrl::SetupSections()
{
guConfig * Config = ( guConfig * ) guConfig::Get();
if( m_ShowPaths & guFILEBROWSER_SHOWPATH_LOCATIONS )
{
const guMediaCollectionArray & Collections = m_MainFrame->GetMediaCollections();
int Count = Collections.Count();
for( int Index = 0; Index < Count; Index++ )
{
const guMediaCollection & Collection = Collections[ Index ];
if( m_MainFrame->IsCollectionActive( Collection.m_UniqueId ) )
{
int PathIndex;
int PathCount = Collection.m_Paths.Count();
for( PathIndex = 0; PathIndex < PathCount; PathIndex++ )
{
wxString LibName = Collection.m_Paths[ PathIndex ];
if( LibName.EndsWith( wxT( "/" ) ) )
LibName.RemoveLast();
AddSection( LibName, wxFileNameFromPath( LibName ), guDIR_IMAGE_INDEX_LIBRARY );
}
}
}
wxString Path = Config->ReadStr( CONFIG_KEY_PODCASTS_PATH, wxEmptyString, CONFIG_PATH_PODCASTS );
if( !Path.IsEmpty() )
{
wxString Name = Path;
if( Name.EndsWith( wxT( "/" ) ) )
Name.RemoveLast();
AddSection( Path, wxFileNameFromPath( Name ), guDIR_IMAGE_INDEX_PODCASTS );
}
Path = Config->ReadStr( CONFIG_KEY_RECORD_PATH, wxEmptyString, CONFIG_PATH_RECORD );
if( !Path.IsEmpty() )
{
wxString Name = Path;
if( Name.EndsWith( wxT( "/" ) ) )
Name.RemoveLast();
AddSection( Path, wxFileNameFromPath( Name ), guDIR_IMAGE_INDEX_RECORDS );
}
}
else //if( m_ShowPaths & guFILEBROWSER_SHOWPATH_SYSTEM )
{
AddSection( wxT( "/" ), wxT( "/" ), guDIR_IMAGE_INDEX_FOLDER );
}
}
// -------------------------------------------------------------------------------- //
void guGenericDirCtrl::OnBeginRenameDir( wxTreeEvent &event )
{
wxTreeCtrl * TreeCtrl = GetTreeCtrl();
m_RenameItemId = TreeCtrl->GetSelection();
m_RenameName = GetPath();
OnBeginEditItem( event );
}
// -------------------------------------------------------------------------------- //
void guGenericDirCtrl::OnEndRenameDir( wxTreeEvent &event )
{
OnEndEditItem( event );
wxTreeCtrl * TreeCtrl = GetTreeCtrl();
TreeCtrl->SelectItem( m_RenameItemId );
m_FileBrowserDirCtrl->RenamedDir( m_RenameName, GetPath() );
}
// -------------------------------------------------------------------------------- //
void guGenericDirCtrl::FolderRename( void )
{
wxTreeCtrl * TreeCtrl = GetTreeCtrl();
m_RenameItemId = TreeCtrl->GetSelection();
m_RenameName = GetPath();
TreeCtrl->EditLabel( m_RenameItemId );
}
// -------------------------------------------------------------------------------- //
// guFileBrowserDirCtrl
// -------------------------------------------------------------------------------- //
guFileBrowserDirCtrl::guFileBrowserDirCtrl( wxWindow * parent, guMainFrame * mainframe, guDbLibrary * db, const wxString &dirpath ) :
wxPanel( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxNO_BORDER )
{
m_MainFrame = mainframe;
m_DefaultDb = db;
m_Db = NULL;
m_MediaViewer = NULL;
m_AddingFolder = false;
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->RegisterObject( this );
wxBoxSizer * MainSizer;
MainSizer = new wxBoxSizer( wxVERTICAL );
int ShowPaths = Config->ReadNum( CONFIG_KEY_FILE_BROWSER_SHOW_LIB_PATHS, guFILEBROWSER_SHOWPATH_LOCATIONS, CONFIG_PATH_FILE_BROWSER );
m_DirCtrl = new guGenericDirCtrl( this, m_MainFrame, ShowPaths );
m_DirCtrl->ShowHidden( false );
SetPath( dirpath, FindMediaViewerByPath( m_MainFrame, dirpath ) );
MainSizer->Add( m_DirCtrl, 1, wxEXPAND, 5 );
wxBoxSizer * DirBtnSizer = new wxBoxSizer( wxHORIZONTAL );
DirBtnSizer->Add( 0, 0, 1, wxEXPAND, 5 );
m_ShowLibPathsBtn = new wxBitmapToggleButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_library ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_ShowLibPathsBtn->SetToolTip( ShowPaths == guFILEBROWSER_SHOWPATH_SYSTEM ?
_( "See used locations" ) :
_( "See system files" ) );
m_ShowLibPathsBtn->SetValue( ShowPaths & guFILEBROWSER_SHOWPATH_LOCATIONS );
DirBtnSizer->Add( m_ShowLibPathsBtn, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 );
MainSizer->Add( DirBtnSizer, 0, wxEXPAND, 5 );
this->SetSizer( MainSizer );
this->Layout();
m_DirCtrl->Bind( wxEVT_TREE_ITEM_MENU, &guFileBrowserDirCtrl::OnContextMenu, this );
m_ShowLibPathsBtn->Bind( wxEVT_TOGGLEBUTTON, &guFileBrowserDirCtrl::OnShowLibPathsClick, this );
Bind( guConfigUpdatedEvent, &guFileBrowserDirCtrl::OnConfigUpdated, this, ID_CONFIG_UPDATED );
CreateAcceleratorTable();
}
// -------------------------------------------------------------------------------- //
guFileBrowserDirCtrl::~guFileBrowserDirCtrl()
{
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->UnRegisterObject( this );
Config->WriteNum( CONFIG_KEY_FILE_BROWSER_SHOW_LIB_PATHS, m_ShowLibPathsBtn->GetValue(), CONFIG_PATH_FILE_BROWSER );
m_DirCtrl->Unbind( wxEVT_TREE_ITEM_MENU, &guFileBrowserDirCtrl::OnContextMenu, this );
m_ShowLibPathsBtn->Unbind( wxEVT_TOGGLEBUTTON, &guFileBrowserDirCtrl::OnShowLibPathsClick, this );
Unbind( guConfigUpdatedEvent, &guFileBrowserDirCtrl::OnConfigUpdated, this, ID_CONFIG_UPDATED );
}
// -------------------------------------------------------------------------------- //
void guFileBrowserDirCtrl::OnConfigUpdated( wxCommandEvent &event )
{
int Flags = event.GetInt();
if( Flags & guPREFERENCE_PAGE_FLAG_ACCELERATORS )
{
CreateAcceleratorTable();
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowserDirCtrl::CreateAcceleratorTable( void )
{
wxAcceleratorTable AccelTable;
wxArrayInt AliasAccelCmds;
wxArrayInt RealAccelCmds;
AliasAccelCmds.Add( ID_PLAYER_PLAYLIST_SAVE );
AliasAccelCmds.Add( ID_PLAYER_PLAYLIST_EDITTRACKS );
AliasAccelCmds.Add( ID_TRACKS_PLAY );
AliasAccelCmds.Add( ID_TRACKS_ENQUEUE_AFTER_ALL );
AliasAccelCmds.Add( ID_TRACKS_ENQUEUE_AFTER_TRACK );
AliasAccelCmds.Add( ID_TRACKS_ENQUEUE_AFTER_ALBUM );
AliasAccelCmds.Add( ID_TRACKS_ENQUEUE_AFTER_ARTIST );
RealAccelCmds.Add( ID_FILESYSTEM_FOLDER_SAVEPLAYLIST );
RealAccelCmds.Add( ID_FILESYSTEM_FOLDER_EDITTRACKS );
RealAccelCmds.Add( ID_FILESYSTEM_FOLDER_PLAY );
RealAccelCmds.Add( ID_FILESYSTEM_FOLDER_ENQUEUE_AFTER_ALL );
RealAccelCmds.Add( ID_FILESYSTEM_FOLDER_ENQUEUE_AFTER_TRACK );
RealAccelCmds.Add( ID_FILESYSTEM_FOLDER_ENQUEUE_AFTER_ALBUM );
RealAccelCmds.Add( ID_FILESYSTEM_FOLDER_ENQUEUE_AFTER_ARTIST );
if( guAccelDoAcceleratorTable( AliasAccelCmds, RealAccelCmds, AccelTable ) )
{
SetAcceleratorTable( AccelTable );
}
}
// -------------------------------------------------------------------------------- //
void AppendFolderCommands( wxMenu * menu )
{
wxMenu * SubMenu;
wxMenuItem * MenuItem;
SubMenu = new wxMenu();
guConfig * Config = ( guConfig * ) guConfig::Get();
wxArrayString Commands = Config->ReadAStr( CONFIG_KEY_COMMANDS_EXEC, wxEmptyString, CONFIG_PATH_COMMANDS_EXECS );
wxArrayString Names = Config->ReadAStr( CONFIG_KEY_COMMANDS_NAME, wxEmptyString, CONFIG_PATH_COMMANDS_NAMES );
int Count = Commands.Count();
if( Count )
{
for( int Index = 0; Index < Count; Index++ )
{
if( ( Commands[ Index ].Find( guCOMMAND_COVERPATH ) == wxNOT_FOUND ) )
{
MenuItem = new wxMenuItem( menu, ID_COMMANDS_BASE + Index, Names[ Index ], Commands[ Index ] );
SubMenu->Append( MenuItem );
}
}
SubMenu->AppendSeparator();
}
else
{
MenuItem = new wxMenuItem( SubMenu, ID_MENU_PREFERENCES_COMMANDS, _( "Preferences" ), _( "Add commands in preferences" ) );
SubMenu->Append( MenuItem );
}
menu->AppendSubMenu( SubMenu, _( "Commands" ) );
}
// -------------------------------------------------------------------------------- //
void guFileBrowserDirCtrl::OnContextMenu( wxTreeEvent &event )
{
wxMenu Menu;
wxMenuItem * MenuItem;
wxPoint Point = event.GetPoint();
MenuItem = new wxMenuItem( &Menu, ID_FILESYSTEM_FOLDER_PLAY,
wxString( _( "Play" ) ) + guAccelGetCommandKeyCodeString( ID_TRACKS_PLAY ),
_( "Play the selected folder" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_player_tiny_light_play ) );
Menu.Append( MenuItem );
MenuItem = new wxMenuItem( &Menu, ID_FILESYSTEM_FOLDER_ENQUEUE_AFTER_ALL,
wxString( _( "Enqueue" ) ) + guAccelGetCommandKeyCodeString( ID_TRACKS_ENQUEUE_AFTER_ALL ),
_( "Add the selected folder to playlist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
Menu.Append( MenuItem );
wxMenu * EnqueueMenu = new wxMenu();
MenuItem = new wxMenuItem( EnqueueMenu, ID_FILESYSTEM_FOLDER_ENQUEUE_AFTER_TRACK,
wxString( _( "Current Track" ) ) + guAccelGetCommandKeyCodeString( ID_TRACKS_ENQUEUE_AFTER_TRACK ),
_( "Add current selected tracks to playlist after the current track" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem = new wxMenuItem( EnqueueMenu, ID_FILESYSTEM_FOLDER_ENQUEUE_AFTER_ALBUM,
wxString( _( "Current Album" ) ) + guAccelGetCommandKeyCodeString( ID_TRACKS_ENQUEUE_AFTER_ALBUM ),
_( "Add current selected tracks to playlist after the current album" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem = new wxMenuItem( EnqueueMenu, ID_FILESYSTEM_FOLDER_ENQUEUE_AFTER_ARTIST,
wxString( _( "Current Artist" ) ) + guAccelGetCommandKeyCodeString( ID_TRACKS_ENQUEUE_AFTER_ARTIST ),
_( "Add current selected tracks to playlist after the current artist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
Menu.Append( wxID_ANY, _( "Enqueue After" ), EnqueueMenu );
Menu.AppendSeparator();
MenuItem = new wxMenuItem( &Menu, ID_FILESYSTEM_FOLDER_EDITTRACKS,
wxString( _( "Edit Tracks" ) ) + guAccelGetCommandKeyCodeString( ID_PLAYER_PLAYLIST_EDITTRACKS ),
_( "Edit the tracks in the selected folder" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_edit ) );
Menu.Append( MenuItem );
Menu.AppendSeparator();
MenuItem = new wxMenuItem( &Menu, ID_FILESYSTEM_FOLDER_SAVEPLAYLIST,
wxString( _( "Save to Playlist" ) ) + guAccelGetCommandKeyCodeString( ID_PLAYER_PLAYLIST_SAVE ),
_( "Add the tracks in the selected folder to a playlist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_doc_save ) );
Menu.Append( MenuItem );
Menu.AppendSeparator();
MenuItem = new wxMenuItem( &Menu, ID_FILESYSTEM_FOLDER_COPY,
_( "Copy" ),
_( "Copy the selected folder to clipboard" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_edit_copy ) );
Menu.Append( MenuItem );
//MenuItem->Enable( false );
MenuItem = new wxMenuItem( &Menu, ID_FILESYSTEM_FOLDER_PASTE,
_( "Paste" ),
_( "Paste to the selected folder" ) );
Menu.Append( MenuItem );
wxTheClipboard->UsePrimarySelection( false );
if( wxTheClipboard->Open() )
{
if( wxTheClipboard->IsSupported( wxDF_FILENAME ) )
{
wxFileDataObject data;
MenuItem->Enable( wxTheClipboard->GetData( data ) );
}
wxTheClipboard->Close();
}
if( m_DirCtrl->GetShowPaths() & guFILEBROWSER_SHOWPATH_LOCATIONS )
{
MenuItem = new wxMenuItem( &Menu, ID_FILESYSTEM_FOLDER_UPDATE,
_( "Update" ),
_( "Update the selected folder" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_reload ) );
Menu.Append( MenuItem );
}
Menu.AppendSeparator();
MenuItem = new wxMenuItem( &Menu, ID_FILESYSTEM_FOLDER_NEW, _( "New Folder" ), _( "Create a new folder" ) );
Menu.Append( MenuItem );
MenuItem = new wxMenuItem( &Menu, ID_FILESYSTEM_FOLDER_RENAME, _( "Rename" ), _( "Rename the selected folder" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_edit ) );
Menu.Append( MenuItem );
MenuItem = new wxMenuItem( &Menu, ID_FILESYSTEM_FOLDER_DELETE, _( "Remove" ), _( "Remove the selected folder" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_edit_clear ) );
Menu.Append( MenuItem );
Menu.AppendSeparator();
m_MainFrame->CreateCopyToMenu( &Menu );
AppendFolderCommands( &Menu );
PopupMenu( &Menu, Point );
event.Skip();
}
// -------------------------------------------------------------------------------- //
void guFileBrowserDirCtrl::RenamedDir( const wxString &oldname, const wxString &newname )
{
guLogMessage( wxT( "'%s' -> '%s' (%i)" ), oldname.c_str(), newname.c_str(), m_Db != NULL );
if( m_AddingFolder )
{
wxTreeCtrl * TreeCtrl = m_DirCtrl->GetTreeCtrl();
if( newname.IsEmpty() )
{
TreeCtrl->Delete( TreeCtrl->GetSelection() );
}
//m_DirCtrl->ReCreateTree();
m_AddingFolder = false;
}
else
{
if( oldname != newname )
{
if( m_Db )
m_Db->UpdatePaths( oldname, newname );
else
m_DefaultDb->UpdatePaths( oldname, newname );
}
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowserDirCtrl::FolderNew( void )
{
wxTreeCtrl * TreeCtrl = m_DirCtrl->GetTreeCtrl();
wxTreeItemId FolderParent = TreeCtrl->GetSelection();
if( FolderParent.IsOk() )
{
m_AddingFolder = true;
wxString NewDirName = GetPath() + _( "New Folder" );
int Index = 1;
while( wxDirExists( NewDirName ) )
{
NewDirName = GetPath() + _( "New Folder" );
NewDirName += wxString::Format( wxT( "%i" ), Index++ );
}
if( wxMkdir( NewDirName, 0770 ) )
{
TreeCtrl->Collapse( FolderParent );
//TreeCtrl->Expand( m_AddFolderParent );
if( m_DirCtrl->ExpandPath( NewDirName ) )
{
wxTreeItemId Selected = TreeCtrl->GetSelection();
if( Selected.IsOk() )
{
wxTextCtrl * TextCtrl = TreeCtrl->EditLabel( Selected );
if( TextCtrl )
{
TextCtrl->SetSelection( -1, -1 );
}
}
else
{
guLogMessage( wxT( "No Selected item" ) );
}
}
}
else
{
guLogError( wxT( "Could not create the new directory" ) );
}
}
}
// -------------------------------------------------------------------------------- //
bool RemoveDirItems( const wxString &path, wxArrayString * deletefiles )
{
wxString FileName;
wxString CurPath = path;
if( !CurPath.EndsWith( wxT( "/" ) ) )
CurPath += wxT( "/" );
//guLogMessage( wxT( "Deleting folder %s" ), CurPath.c_str() );
wxDir Dir( CurPath );
if( Dir.IsOpened() )
{
if( Dir.GetFirst( &FileName, wxEmptyString, wxDIR_FILES | wxDIR_HIDDEN | wxDIR_DIRS | wxDIR_DOTDOT ) )
{
do {
if( FileName != wxT( "." ) && FileName != wxT( ".." ) )
{
if( wxDirExists( CurPath + FileName ) )
{
if( !RemoveDirItems( CurPath + FileName, deletefiles ) )
return false;
//guLogMessage( wxT( "Removing Dir: %s" ), ( CurPath + FileName ).c_str() );
if( !wxRmdir( CurPath + FileName ) )
return false;
}
else
{
//guLogMessage( wxT( "Removing file: %s" ), ( CurPath + FileName ).c_str() );
if( !wxRemoveFile( CurPath + FileName ) )
return false;
deletefiles->Add( CurPath + FileName );
}
}
} while( Dir.GetNext( &FileName ) );
}
return true;
}
return false;
}
// -------------------------------------------------------------------------------- //
void guFileBrowserDirCtrl::FolderDelete( void )
{
wxTreeCtrl * TreeCtrl = m_DirCtrl->GetTreeCtrl();
wxTreeItemId FolderId = TreeCtrl->GetSelection();
wxDirItemData * FolderData = ( wxDirItemData * ) TreeCtrl->GetItemData( FolderId );
if( wxMessageBox( _( "Are you sure to delete the selected path ?" ),
_( "Confirm" ),
wxICON_QUESTION | wxYES_NO, this ) == wxYES )
{
wxArrayString DeleteFiles;
if( RemoveDirItems( FolderData->m_path, &DeleteFiles ) && wxRmdir( FolderData->m_path ) )
{
TreeCtrl->Delete( FolderId );
}
else
{
wxMessageBox( _( "Error deleting the folder " ) + FolderData->m_path,
_( "Error" ), wxICON_ERROR | wxOK, this );
}
//m_Db->DoCleanUp();
if( m_Db )
m_Db->CleanFiles( DeleteFiles );
else
m_DefaultDb->CleanFiles( DeleteFiles );
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowserDirCtrl::OnShowLibPathsClick( wxCommandEvent& event )
{
int ShowPaths = m_ShowLibPathsBtn->GetValue();
wxString CurPath = GetPath();
m_DirCtrl->SetShowPaths( ShowPaths );
m_DirCtrl->ReCreateTree();
m_DirCtrl->SetPath( CurPath );
m_ShowLibPathsBtn->SetToolTip( ShowPaths == guFILEBROWSER_SHOWPATH_SYSTEM ?
_( "See used locations" ) :
_( "See system files" ) );
}
// -------------------------------------------------------------------------------- //
void guFileBrowserDirCtrl::CollectionsUpdated( void )
{
if( m_DirCtrl->GetShowPaths() & guFILEBROWSER_SHOWPATH_LOCATIONS )
{
wxString CurPath = GetPath();
m_DirCtrl->ReCreateTree();
m_DirCtrl->SetPath( CurPath );
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowserDirCtrl::SetPath( const wxString &path, guMediaViewer * mediaviewer )
{
//guLogMessage( wxT( "guFileBrowserDirCtrl::SetPath( %s )" ), path.c_str() );
m_MediaViewer = mediaviewer;
m_Db = mediaviewer ? mediaviewer->GetDb() : NULL;
m_DirCtrl->SetPath( path );
}
// -------------------------------------------------------------------------------- //
void guFileBrowserDirCtrl::SetMediaViewer( guMediaViewer * mediaviewer )
{
m_MediaViewer = mediaviewer;
m_Db = mediaviewer ? mediaviewer->GetDb() : NULL;
}
// -------------------------------------------------------------------------------- //
// guFilesListBox
// -------------------------------------------------------------------------------- //
bool guAddDirItems( const wxString &path, wxArrayString &files )
{
wxString FileName;
wxString CurPath = path;
if( !CurPath.EndsWith( wxT( "/" ) ) )
CurPath += wxT( "/" );
guLogMessage( wxT( "Searching in folder %s" ), CurPath.c_str() );
wxDir Dir( CurPath );
if( Dir.IsOpened() )
{
if( Dir.GetFirst( &FileName, wxEmptyString, wxDIR_FILES | wxDIR_HIDDEN | wxDIR_DIRS | wxDIR_DOTDOT ) )
{
do {
if( FileName != wxT( "." ) && FileName != wxT( ".." ) )
{
if( wxDirExists( CurPath + FileName ) )
{
if( !guAddDirItems( CurPath + FileName, files ) )
return false;
}
else
{
files.Add( CurPath + FileName );
}
}
} while( Dir.GetNext( &FileName ) );
}
return true;
}
return false;
}
// -------------------------------------------------------------------------------- //
guFilesListBox::guFilesListBox( wxWindow * parent, guDbLibrary * db ) :
guListView( parent, wxLB_MULTIPLE | guLISTVIEW_COLUMN_SELECT | guLISTVIEW_COLUMN_SORTING | guLISTVIEW_ALLOWDRAG )
{
m_Db = db;
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->RegisterObject( this );
m_Order = Config->ReadNum( CONFIG_KEY_FILE_BROWSER_ORDER, 0, CONFIG_PATH_FILE_BROWSER );
m_OrderDesc = Config->ReadNum( CONFIG_KEY_FILE_BROWSER_ORDERDESC, false, CONFIG_PATH_FILE_BROWSER );
int ColId;
wxString ColName;
wxArrayString ColumnNames = GetColumnNames();
int count = ColumnNames.Count();
for( int index = 0; index < count; index++ )
{
ColId = Config->ReadNum( wxString::Format( wxT( "Id%u" ), index ), index, CONFIG_PATH_FILE_BROWSER_COLUMNS_IDS );
ColName = ColumnNames[ ColId ];
ColName += ( ( ColId == m_Order ) ? ( m_OrderDesc ? wxT( " ▼" ) : wxT( " ▲" ) ) : wxEmptyString );
guListViewColumn * Column = new guListViewColumn(
ColName,
ColId,
Config->ReadNum( wxString::Format( wxT( "Width%u" ), index ), 80, CONFIG_PATH_FILE_BROWSER_COLUMNS_WIDTHS ),
Config->ReadBool( wxString::Format( wxT( "Show%u" ), index ), true, CONFIG_PATH_FILE_BROWSER_COLUMNS_SHOWS )
);
InsertColumn( Column );
}
Bind( guConfigUpdatedEvent, &guFilesListBox::OnConfigUpdated, this, ID_CONFIG_UPDATED );
CreateAcceleratorTable();
ReloadItems();
}
// -------------------------------------------------------------------------------- //
guFilesListBox::~guFilesListBox()
{
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->UnRegisterObject( this );
wxArrayString ColumnNames = GetColumnNames();
int count = ColumnNames.Count();
for( int index = 0; index < count; index++ )
{
Config->WriteNum( wxString::Format( wxT( "Id%u" ), index ),
( * m_Columns )[ index ].m_Id, CONFIG_PATH_FILE_BROWSER_COLUMNS_IDS );
Config->WriteNum( wxString::Format( wxT( "Width%u" ), index ),
( * m_Columns )[ index ].m_Width, CONFIG_PATH_FILE_BROWSER_COLUMNS_WIDTHS );
Config->WriteBool( wxString::Format( wxT( "Show%u" ), index ),
( * m_Columns )[ index ].m_Enabled, CONFIG_PATH_FILE_BROWSER_COLUMNS_SHOWS );
}
Config->WriteNum( CONFIG_KEY_FILE_BROWSER_ORDER, m_Order, CONFIG_PATH_FILE_BROWSER );
Config->WriteBool( CONFIG_KEY_FILE_BROWSER_ORDERDESC, m_OrderDesc, CONFIG_PATH_FILE_BROWSER );
Unbind( guConfigUpdatedEvent, &guFilesListBox::OnConfigUpdated, this, ID_CONFIG_UPDATED );
}
// -------------------------------------------------------------------------------- //
void guFilesListBox::OnConfigUpdated( wxCommandEvent &event )
{
int Flags = event.GetInt();
if( Flags & guPREFERENCE_PAGE_FLAG_ACCELERATORS )
{
CreateAcceleratorTable();
}
}
// -------------------------------------------------------------------------------- //
void guFilesListBox::CreateAcceleratorTable( void )
{
wxAcceleratorTable AccelTable;
wxArrayInt AliasAccelCmds;
wxArrayInt RealAccelCmds;
AliasAccelCmds.Add( ID_PLAYER_PLAYLIST_SAVE );
AliasAccelCmds.Add( ID_PLAYER_PLAYLIST_EDITTRACKS );
AliasAccelCmds.Add( ID_TRACKS_PLAY );
AliasAccelCmds.Add( ID_TRACKS_ENQUEUE_AFTER_ALL );
AliasAccelCmds.Add( ID_TRACKS_ENQUEUE_AFTER_TRACK );
AliasAccelCmds.Add( ID_TRACKS_ENQUEUE_AFTER_ALBUM );
AliasAccelCmds.Add( ID_TRACKS_ENQUEUE_AFTER_ARTIST );
RealAccelCmds.Add( ID_FILESYSTEM_ITEMS_SAVEPLAYLIST );
RealAccelCmds.Add( ID_FILESYSTEM_ITEMS_EDITTRACKS );
RealAccelCmds.Add( ID_FILESYSTEM_ITEMS_PLAY );
RealAccelCmds.Add( ID_FILESYSTEM_ITEMS_ENQUEUE_AFTER_ALL );
RealAccelCmds.Add( ID_FILESYSTEM_ITEMS_ENQUEUE_AFTER_TRACK );
RealAccelCmds.Add( ID_FILESYSTEM_ITEMS_ENQUEUE_AFTER_ALBUM );
RealAccelCmds.Add( ID_FILESYSTEM_ITEMS_ENQUEUE_AFTER_ARTIST );
if( guAccelDoAcceleratorTable( AliasAccelCmds, RealAccelCmds, AccelTable ) )
{
SetAcceleratorTable( AccelTable );
}
}
// -------------------------------------------------------------------------------- //
wxArrayString guFilesListBox::GetColumnNames( void )
{
wxArrayString ColumnNames;
ColumnNames.Add( _( "Name" ) );
ColumnNames.Add( _( "Size" ) );
ColumnNames.Add( _( "Modified" ) );
return ColumnNames;
}
// -------------------------------------------------------------------------------- //
wxString guFilesListBox::OnGetItemText( const int row, const int col ) const
{
// guLogMessage( wxT( "GetItem: %i %i" ), row, col );
// if( row < 0 || col < 0 )
// return wxEmptyString;
guFileItem * FileItem;
FileItem = &m_Files[ row ];
switch( ( * m_Columns )[ col ].m_Id )
{
// case guFILEBROWSER_COLUMN_TYPE :
// return wxEmptyString;
case guFILEBROWSER_COLUMN_NAME :
return FileItem->m_Name;
case guFILEBROWSER_COLUMN_SIZE :
return SizeToString( FileItem->m_Size );
case guFILEBROWSER_COLUMN_TIME :
{
wxDateTime FileTime;
FileTime.Set( ( time_t ) FileItem->m_Time );
return FileTime.FormatDate();
}
}
return wxEmptyString;
}
// -------------------------------------------------------------------------------- //
void guFilesListBox::DrawItem( wxDC &dc, const wxRect &rect, const int row, const int col ) const
{
if( ( * m_Columns )[ col ].m_Id == guFILEBROWSER_COLUMN_NAME )
{
guFileItem * FileItem = &m_Files[ row ];
dc.SetBackgroundMode( wxTRANSPARENT );
int ImageIndex = guDIR_IMAGE_INDEX_OTHER;
if( FileItem->m_Type == guFILEITEM_TYPE_FOLDER )
{
ImageIndex = guDIR_IMAGE_INDEX_FOLDER;
}
else if( FileItem->m_Type == guFILEITEM_TYPE_AUDIO )
{
ImageIndex = guDIR_IMAGE_INDEX_AUDIO;
}
else if( FileItem->m_Type == guFILEITEM_TYPE_IMAGE )
{
ImageIndex = guDIR_IMAGE_INDEX_IMAGE;
}
m_TreeImageList->Draw( ImageIndex, dc, rect.x + 1, rect.y + 1, wxIMAGELIST_DRAW_TRANSPARENT );
wxRect TextRect = rect;
TextRect.x += 20; // 16 + 4
TextRect.width -= 20;
guListView::DrawItem( dc, TextRect, row, col );
}
else
{
guListView::DrawItem( dc, rect, row, col );
}
}
// -------------------------------------------------------------------------------- //
void inline GetFileDetails( const wxString &filename, guFileItem * fileitem )
{
wxStructStat St;
wxStat( filename, &St );
fileitem->m_Type = ( ( St.st_mode & S_IFMT ) == S_IFDIR ) ? 0 : 3;
fileitem->m_Size = St.st_size;
fileitem->m_Time = St.st_ctime;
}
//// -------------------------------------------------------------------------------- //
//static int wxCMPFUNC_CONV CompareFileTypeA( guFileItem ** item1, guFileItem ** item2 )
//{
// if( ( * item1 )->m_Name == wxT( ".." ) )
// return -1;
// else if( ( * item2 )->m_Name == wxT( ".." ) )
// return 1;
//
// if( ( * item1 )->m_Type == ( * item2 )->m_Type )
// return 0;
// else if( ( * item1 )->m_Type > ( * item2 )->m_Type )
// return -1;
// else
// return 1;
//}
// -------------------------------------------------------------------------------- //
static int wxCMPFUNC_CONV CompareFileTypeD( guFileItem ** item1, guFileItem ** item2 )
{
if( ( * item1 )->m_Name == wxT( ".." ) )
return -1;
else if( ( * item2 )->m_Name == wxT( ".." ) )
return 1;
if( ( * item1 )->m_Type == ( * item2 )->m_Type )
return 0;
else if( ( * item1 )->m_Type > ( * item2 )->m_Type )
return 1;
else
return -1;
}
// -------------------------------------------------------------------------------- //
static int wxCMPFUNC_CONV CompareFileNameA( guFileItem ** item1, guFileItem ** item2 )
{
int type = CompareFileTypeD( item1, item2 );
if( !type )
return ( * item1 )->m_Name.Cmp( ( * item2 )->m_Name );
return type;
}
// -------------------------------------------------------------------------------- //
static int wxCMPFUNC_CONV CompareFileNameD( guFileItem ** item1, guFileItem ** item2 )
{
int type = CompareFileTypeD( item1, item2 );
if( !type )
return ( * item2 )->m_Name.Cmp( ( * item1 )->m_Name );
return type;
}
// -------------------------------------------------------------------------------- //
static int wxCMPFUNC_CONV CompareFileSizeA( guFileItem ** item1, guFileItem ** item2 )
{
int type = CompareFileTypeD( item1, item2 );
if( !type )
{
if( ( * item1 )->m_Size == ( * item2 )->m_Size )
return 0;
else if( ( * item1 )->m_Size > ( * item2 )->m_Size )
return 1;
else
return -1;
}
return type;
}
// -------------------------------------------------------------------------------- //
static int wxCMPFUNC_CONV CompareFileSizeD( guFileItem ** item1, guFileItem ** item2 )
{
int type = CompareFileTypeD( item1, item2 );
if( !type )
{
if( ( * item1 )->m_Size == ( * item2 )->m_Size )
return 0;
else if( ( * item2 )->m_Size > ( * item1 )->m_Size )
return 1;
else
return -1;
}
return type;
}
// -------------------------------------------------------------------------------- //
static int wxCMPFUNC_CONV CompareFileTimeA( guFileItem ** item1, guFileItem ** item2 )
{
int type = CompareFileTypeD( item1, item2 );
if( !type )
{
if( ( * item1 )->m_Time == ( * item2 )->m_Time )
return 0;
else if( ( * item1 )->m_Time > ( * item2 )->m_Time )
return 1;
else
return -1;
}
return type;
}
// -------------------------------------------------------------------------------- //
static int wxCMPFUNC_CONV CompareFileTimeD( guFileItem ** item1, guFileItem ** item2 )
{
int type = CompareFileTypeD( item1, item2 );
if( !type )
{
if( ( * item1 )->m_Time == ( * item2 )->m_Time )
return 0;
else if( ( * item2 )->m_Time > ( * item1 )->m_Time )
return 1;
else
return -1;
}
return type;
}
// -------------------------------------------------------------------------------- //
int guFilesListBox::GetPathSordedItems( const wxString &path, guFileItemArray * items,
const int order, const bool orderdesc, const bool recursive ) const
{
wxString Path = path;
if( !Path.EndsWith( wxT( "/" ) ) )
Path += wxT( "/" );
if( !path.IsEmpty() && wxDirExists( Path ) )
{
wxDir Dir( Path );
if( Dir.IsOpened() )
{
wxString FileName;
if( Dir.GetFirst( &FileName, wxEmptyString, wxDIR_FILES | wxDIR_DIRS | wxDIR_DOTDOT ) )
{
do {
if( FileName != wxT( "." ) )
{
if( recursive && wxDirExists( Path + FileName ) )
{
if( FileName != wxT( ".." ) )
{
GetPathSordedItems( Path + FileName, items, order, orderdesc, recursive );
}
}
else
{
guFileItem * FileItem = new guFileItem();
if( recursive )
FileItem->m_Name = Path;
FileItem->m_Name += FileName;
GetFileDetails( Path + FileName, FileItem );
if( !wxDirExists( Path + FileName ) )
{
if( guIsValidAudioFile( FileName.Lower() ) )
FileItem->m_Type = guFILEITEM_TYPE_AUDIO;
else if( guIsValidImageFile( FileName.Lower() ) )
FileItem->m_Type = guFILEITEM_TYPE_IMAGE;
}
items->Add( FileItem );
}
}
} while( Dir.GetNext( &FileName ) );
}
switch( order )
{
case guFILEBROWSER_COLUMN_NAME :
{
items->Sort( orderdesc ? CompareFileNameD : CompareFileNameA );
break;
}
case guFILEBROWSER_COLUMN_SIZE :
{
items->Sort( orderdesc ? CompareFileSizeD : CompareFileSizeA );
break;
}
case guFILEBROWSER_COLUMN_TIME :
{
items->Sort( orderdesc ? CompareFileTimeD : CompareFileTimeA );
break;
}
}
}
}
return items->Count();
}
// -------------------------------------------------------------------------------- //
void guFilesListBox::GetItemsList( void )
{
GetPathSordedItems( m_CurDir, &m_Files, m_Order, m_OrderDesc );
wxCommandEvent event( wxEVT_MENU, ID_MAINFRAME_UPDATE_SELINFO );
AddPendingEvent( event );
}
// -------------------------------------------------------------------------------- //
void guFilesListBox::ReloadItems( bool reset )
{
//
wxArrayInt Selection;
int FirstVisible = 0;
if( reset )
{
SetSelection( -1 );
}
else
{
Selection = GetSelectedItems( false );
FirstVisible = GetVisibleRowsBegin();
}
m_Files.Empty();
GetItemsList();
SetItemCount( m_Files.Count() );
if( !reset )
{
SetSelectedItems( Selection );
ScrollToRow( FirstVisible );
}
RefreshAll();
}
// -------------------------------------------------------------------------------- //
void AppendItemsCommands( wxMenu * menu, int selcount, int seltype )
{
wxMenu * SubMenu;
wxMenuItem * MenuItem;
SubMenu = new wxMenu();
guLogMessage( wxT( "AppendItemCommands: %i %i" ), selcount, seltype );
guConfig * Config = ( guConfig * ) guConfig::Get();
wxArrayString Commands = Config->ReadAStr( CONFIG_KEY_COMMANDS_EXEC, wxEmptyString, CONFIG_PATH_COMMANDS_EXECS );
wxArrayString Names = Config->ReadAStr( CONFIG_KEY_COMMANDS_NAME, wxEmptyString, CONFIG_PATH_COMMANDS_NAMES );
int Count = Commands.Count();
if( Count )
{
for( int Index = 0; Index < Count; Index++ )
{
if( ( Commands[ Index ].Find( guCOMMAND_COVERPATH ) == wxNOT_FOUND ) ||
( ( selcount == 1 ) && ( seltype == guFILEITEM_TYPE_IMAGE ) ) )
{
MenuItem = new wxMenuItem( menu, ID_COMMANDS_BASE + Index, Names[ Index ], Commands[ Index ] );
SubMenu->Append( MenuItem );
}
}
SubMenu->AppendSeparator();
}
else
{
MenuItem = new wxMenuItem( SubMenu, ID_MENU_PREFERENCES_COMMANDS, _( "Preferences" ), _( "Add commands in preferences" ) );
SubMenu->Append( MenuItem );
}
menu->AppendSubMenu( SubMenu, _( "Commands" ) );
}
// -------------------------------------------------------------------------------- //
void guFilesListBox::CreateContextMenu( wxMenu * Menu ) const
{
wxMenuItem * MenuItem;
wxArrayInt Selection = GetSelectedItems( false );
int SelCount;
if( ( SelCount = Selection.Count() ) )
{
MenuItem = new wxMenuItem( Menu, ID_FILESYSTEM_ITEMS_PLAY,
wxString( _( "Play" ) ) + guAccelGetCommandKeyCodeString( ID_TRACKS_PLAY ),
_( "Play current selected files" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_player_tiny_light_play ) );
Menu->Append( MenuItem );
MenuItem = new wxMenuItem( Menu, ID_FILESYSTEM_ITEMS_ENQUEUE_AFTER_ALL,
wxString( _( "Enqueue" ) ) + guAccelGetCommandKeyCodeString( ID_TRACKS_ENQUEUE_AFTER_ALL ),
_( "Add current selected files to playlist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
Menu->Append( MenuItem );
wxMenu * EnqueueMenu = new wxMenu();
MenuItem = new wxMenuItem( EnqueueMenu, ID_FILESYSTEM_ITEMS_ENQUEUE_AFTER_TRACK,
wxString( _( "Current Track" ) ) + guAccelGetCommandKeyCodeString( ID_TRACKS_ENQUEUE_AFTER_TRACK ),
_( "Add current selected tracks to playlist after the current track" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem->Enable( SelCount );
MenuItem = new wxMenuItem( EnqueueMenu, ID_FILESYSTEM_ITEMS_ENQUEUE_AFTER_ALBUM,
wxString( _( "Current Album" ) ) + guAccelGetCommandKeyCodeString( ID_TRACKS_ENQUEUE_AFTER_ALBUM ),
_( "Add current selected tracks to playlist after the current album" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem->Enable( SelCount );
MenuItem = new wxMenuItem( EnqueueMenu, ID_FILESYSTEM_ITEMS_ENQUEUE_AFTER_ARTIST,
wxString( _( "Current Artist" ) ) + guAccelGetCommandKeyCodeString( ID_TRACKS_ENQUEUE_AFTER_ARTIST ),
_( "Add current selected tracks to playlist after the current artist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem->Enable( SelCount );
Menu->Append( wxID_ANY, _( "Enqueue After" ), EnqueueMenu );
}
if( SelCount )
{
Menu->AppendSeparator();
MenuItem = new wxMenuItem( Menu, ID_FILESYSTEM_ITEMS_EDITTRACKS,
wxString( _( "Edit Tracks" ) ) + guAccelGetCommandKeyCodeString( ID_PLAYER_PLAYLIST_EDITTRACKS ),
_( "Edit the current selected files" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_edit ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
MenuItem = new wxMenuItem( Menu, ID_FILESYSTEM_ITEMS_SAVEPLAYLIST,
wxString( _( "Save to Playlist" ) ) + guAccelGetCommandKeyCodeString( ID_PLAYER_PLAYLIST_SAVE ),
_( "Add the current selected tracks to a playlist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_doc_save ) );
Menu->Append( MenuItem );
}
Menu->AppendSeparator();
MenuItem = new wxMenuItem( Menu, ID_FILESYSTEM_ITEMS_COPY, _( "Copy" ), _( "Copy the selected folder to clipboard" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_edit_copy ) );
Menu->Append( MenuItem );
MenuItem = new wxMenuItem( Menu, ID_FILESYSTEM_ITEMS_PASTE, _( "Paste" ), _( "Paste to the selected dir" ) );
Menu->Append( MenuItem );
wxTheClipboard->UsePrimarySelection( false );
if( wxTheClipboard->Open() )
{
if( wxTheClipboard->IsSupported( wxDF_FILENAME ) )
{
wxFileDataObject data;
MenuItem->Enable( wxTheClipboard->GetData( data ) );
}
wxTheClipboard->Close();
}
if( SelCount )
{
Menu->AppendSeparator();
MenuItem = new wxMenuItem( Menu, ID_FILESYSTEM_ITEMS_RENAME, _( "Rename Files" ), _( "Rename the current selected file" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_edit ) );
Menu->Append( MenuItem );
MenuItem = new wxMenuItem( Menu, ID_FILESYSTEM_ITEMS_DELETE, _( "Remove" ), _( "Delete the selected files" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_edit_clear ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
guMainFrame * MainFrame = ( guMainFrame * ) guMainFrame::GetMainFrame();
MainFrame->CreateCopyToMenu( Menu );
AppendItemsCommands( Menu, SelCount, SelCount ? GetType( Selection[ 0 ] ) : guFILEITEM_TYPE_FILE );
}
}
// -------------------------------------------------------------------------------- //
int inline guFilesListBox::GetItemId( const int row ) const
{
return row;
}
// -------------------------------------------------------------------------------- //
wxString inline guFilesListBox::GetItemName( const int row ) const
{
return m_Files[ row ].m_Name;
}
// -------------------------------------------------------------------------------- //
void guFilesListBox::SetOrder( int columnid )
{
if( m_Order != columnid )
{
m_Order = columnid;
m_OrderDesc = ( columnid != 0 );
}
else
m_OrderDesc = !m_OrderDesc;
wxArrayString ColumnNames = GetColumnNames();
int CurColId;
int count = ColumnNames.Count();
for( int index = 0; index < count; index++ )
{
CurColId = GetColumnId( index );
SetColumnLabel( index,
ColumnNames[ CurColId ] + ( ( CurColId == m_Order ) ?
( m_OrderDesc ? wxT( " ▼" ) : wxT( " ▲" ) ) : wxEmptyString ) );
}
ReloadItems();
}
// -------------------------------------------------------------------------------- //
int guFilesListBox::GetSelectedSongs( guTrackArray * tracks, const bool isdrag ) const
{
wxArrayString Files = GetSelectedFiles( true );
return GetTracksFromFiles( Files, tracks );
}
// -------------------------------------------------------------------------------- //
int guFilesListBox::GetAllSongs( guTrackArray * tracks ) const
{
wxArrayString Files = GetAllFiles( true );
return GetTracksFromFiles( Files, tracks );
}
// -------------------------------------------------------------------------------- //
int guFilesListBox::GetTracksFromFiles( const wxArrayString &files, guTrackArray * tracks ) const
{
int Count = files.Count();
if( Count )
{
for( int Index = 0; Index < Count; Index++ )
{
wxString FileName = files[ Index ];
//guLogMessage( wxT( "GetTracksFromFiles: %s" ), FileName.c_str() );
wxURI Uri( FileName );
if( Uri.IsReference() )
{
if( guIsValidAudioFile( FileName ) )
{
guTrack * Track = new guTrack();
Track->m_FileName = FileName;
if( !m_Db || !m_Db->FindTrackFile( FileName, Track ) )
{
guPodcastItem PodcastItem;
guMainFrame * MainFrame = ( guMainFrame * ) guMainFrame::GetMainFrame();
guDbPodcasts * DbPodcasts = MainFrame->GetPodcastsDb();
if( DbPodcasts->GetPodcastItemFile( FileName, &PodcastItem ) )
{
delete Track;
continue;
}
else
{
if( Track->ReadFromFile( FileName ) )
{
Track->m_Type = guTRACK_TYPE_NOTDB;
}
else
{
guLogError( wxT( "Could not read tags from file '%s'" ), FileName.c_str() );
}
}
}
tracks->Add( Track );
}
}
}
}
return tracks->Count();
}
// -------------------------------------------------------------------------------- //
wxArrayString guFilesListBox::GetSelectedFiles( const bool recursive ) const
{
wxArrayString Files;
wxArrayInt Selection = GetSelectedItems( false );
int Count = Selection.Count();
if( Count )
{
for( int Index = 0; Index < Count; Index++ )
{
if( m_Files[ Selection[ Index ] ].m_Name != wxT( ".." ) )
{
if( recursive && ( m_Files[ Selection[ Index ] ].m_Type == guFILEITEM_TYPE_FOLDER ) )
{
//guAddDirItems( m_CurDir + m_Files[ Selection[ Index ] ].m_Name, Files );
guFileItemArray DirFiles;
if( GetPathSordedItems( m_CurDir + m_Files[ Selection[ Index ] ].m_Name,
&DirFiles, m_Order, m_OrderDesc, true ) )
{
int FileIndex;
int FileCount = DirFiles.Count();
for( FileIndex = 0; FileIndex < FileCount; FileIndex++ )
{
Files.Add( DirFiles[ FileIndex ].m_Name );
}
}
}
else
{
Files.Add( m_CurDir + m_Files[ Selection[ Index ] ].m_Name );
}
}
}
}
return Files;
}
// -------------------------------------------------------------------------------- //
wxArrayString guFilesListBox::GetAllFiles( const bool recursive ) const
{
wxArrayString Files;
int Count = m_Files.Count();
if( Count )
{
for( int Index = 0; Index < Count; Index++ )
{
if( m_Files[ Index ].m_Name != wxT( ".." ) )
{
if( recursive && ( m_Files[ Index ].m_Type == guFILEITEM_TYPE_FOLDER ) )
{
//guAddDirItems( m_CurDir + m_Files[ Selection[ Index ] ].m_Name, Files );
guFileItemArray DirFiles;
if( GetPathSordedItems( m_CurDir + m_Files[ Index ].m_Name,
&DirFiles, m_Order, m_OrderDesc, true ) )
{
int FileIndex;
int FileCount = DirFiles.Count();
for( FileIndex = 0; FileIndex < FileCount; FileIndex++ )
{
Files.Add( DirFiles[ FileIndex ].m_Name );
}
}
}
else
{
Files.Add( m_CurDir + m_Files[ Index ].m_Name );
}
}
}
}
return Files;
}
// -------------------------------------------------------------------------------- //
int guFilesListBox::GetDragFiles( guDataObjectComposite * files )
{
wxArrayString SelectFiles = GetSelectedFiles( true );
int Count = SelectFiles.Count();
for( int Index = 0; Index < Count; Index++ )
{
SelectFiles[ Index ] = guFileDnDEncode( SelectFiles[ Index ] );
}
files->SetFiles( SelectFiles );
return Count;
}
// -------------------------------------------------------------------------------- //
void guFilesListBox::SetPath( const wxString &path, guMediaViewer * mediaviewer )
{
//guLogMessage( wxT( "guFilesListBox::SetPath( %s )" ), path.c_str() );
m_CurDir = path;
if( !m_CurDir.EndsWith( wxT( "/" ) ) )
m_CurDir += wxT( "/" );
m_MediaViewer = mediaviewer;
m_Db = mediaviewer ? mediaviewer->GetDb() : NULL;
ReloadItems();
}
// -------------------------------------------------------------------------------- //
wxString guFilesListBox::GetPath( const int item, const bool absolute ) const
{
wxString RetVal;
//guLogMessage( wxT( "GetPath( %i )" ), item );
if( item >= 0 )
{
if( !absolute )
{
return m_CurDir + m_Files[ item ].m_Name;
}
else
{
if( m_Files[ item ].m_Name == wxT( ".." ) )
{
RetVal = m_CurDir.BeforeLast( wxT( '/' ) ).BeforeLast( wxT( '/' ) );
//guLogMessage( wxT( "1) Path : %s" ), RetVal.c_str() );
return RetVal;
}
wxFileName FileName( m_Files[ item ].m_Name );
FileName.MakeAbsolute( m_CurDir );
//guLogMessage( wxT( "Path : %s" ), FileName.GetFullPath().c_str() );
return FileName.GetFullPath();
}
}
return wxEmptyString;
}
// -------------------------------------------------------------------------------- //
int guFilesListBox::GetType( const int item ) const
{
if( item >= 0 )
{
return m_Files[ item ].m_Type;
}
return wxNOT_FOUND;
}
// -------------------------------------------------------------------------------- //
bool guFilesListBox::GetCounters( wxLongLong * count, wxLongLong * len, wxLongLong * size )
{
* count = * len = * size = 0;
int Count = m_Files.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( m_Files[ Index ].m_Type == guFILEITEM_TYPE_FOLDER )
{
if( ( m_Files[ Index ].m_Name != wxT( ".." ) ) )
( * len )++;
}
else
{
* size += m_Files[ Index ].m_Size;
( * count )++;
}
}
return true;
}
// -------------------------------------------------------------------------------- //
// guFileBrowserFileCtrl
// -------------------------------------------------------------------------------- //
guFileBrowserFileCtrl::guFileBrowserFileCtrl( wxWindow * parent, guDbLibrary * db, guFileBrowserDirCtrl * dirctrl ) :
wxPanel( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL|wxNO_BORDER )
{
m_DefaultDb = db;
m_Db = NULL;
m_MediaViewer = NULL;
m_DirCtrl = dirctrl;
wxImageList * ImageList = dirctrl->GetImageList();
ImageList->Add( wxArtProvider::GetBitmap( wxT( "audio-x-generic" ), wxART_OTHER, wxSize( 16, 16 ) ) );
ImageList->Add( wxArtProvider::GetBitmap( wxT( "image-x-generic" ), wxART_OTHER, wxSize( 16, 16 ) ) );
wxBoxSizer * MainSizer;
MainSizer = new wxBoxSizer( wxVERTICAL );
m_FilesListBox = new guFilesListBox( this, db );
m_FilesListBox->SetTreeImageList( ImageList );
MainSizer->Add( m_FilesListBox, 1, wxEXPAND, 5 );
this->SetSizer( MainSizer );
this->Layout();
}
// -------------------------------------------------------------------------------- //
guFileBrowserFileCtrl::~guFileBrowserFileCtrl()
{
}
// -------------------------------------------------------------------------------- //
void guFileBrowserFileCtrl::SetPath( const wxString &path, guMediaViewer * mediaviewer )
{
guLogMessage( wxT( "guFileBrowserFileCtrl::SetPath( %s )" ), path.c_str() );
m_MediaViewer = mediaviewer;
m_Db = mediaviewer ? mediaviewer->GetDb() : NULL;
m_FilesListBox->SetPath( path, mediaviewer );
}
// -------------------------------------------------------------------------------- //
// guFileBrowser
// -------------------------------------------------------------------------------- //
BEGIN_EVENT_TABLE( guFileBrowser, wxPanel )
EVT_TREE_BEGIN_DRAG( wxID_ANY, guFileBrowser::OnDirBeginDrag)
END_EVENT_TABLE()
// -------------------------------------------------------------------------------- //
guFileBrowser::guFileBrowser( wxWindow * parent, guMainFrame * mainframe, guDbLibrary * db, guPlayerPanel * playerpanel ) :
guAuiManagerPanel( parent )
{
m_MainFrame = mainframe;
m_DefaultDb = db;
m_Db = NULL;
m_MediaViewer = NULL;
m_PlayerPanel = playerpanel;
guConfig * Config = ( guConfig * ) guConfig::Get();
m_VisiblePanels = Config->ReadNum( CONFIG_KEY_FILE_BROWSER_VISIBLE_PANELS, guPANEL_FILEBROWSER_VISIBLE_DEFAULT, CONFIG_PATH_FILE_BROWSER );
wxString LastPath = Config->ReadStr( CONFIG_KEY_FILE_BROWSER_PATH, wxEmptyString, CONFIG_PATH_FILE_BROWSER );
m_DirCtrl = new guFileBrowserDirCtrl( this, m_MainFrame, db, LastPath );
guLogMessage( wxT( "LastPath: '%s'" ), LastPath.c_str() );
m_AuiManager.AddPane( m_DirCtrl,
wxAuiPaneInfo().Name( wxT( "FileBrowserDirCtrl" ) ).Caption( _( "Directories" ) ).
MinSize( 60, 28 ).Row( 0 ).Layer( 0 ).Position( 0 ).
CloseButton( false ).
Dockable( true ).Left() );
m_FilesCtrl = new guFileBrowserFileCtrl( this, db, m_DirCtrl );
m_FilesCtrl->SetPath( LastPath, NULL );
m_AuiManager.AddPane( m_FilesCtrl,
wxAuiPaneInfo().Name( wxT( "FileBrowserFilesCtrl" ) ).
Dockable( true ).CenterPane() );
wxString FileBrowserLayout = Config->ReadStr( CONFIG_KEY_FILE_BROWSER_LAST_LAYOUT, wxEmptyString, CONFIG_PATH_FILE_BROWSER );
if( Config->GetIgnoreLayouts() || FileBrowserLayout.IsEmpty() )
{
m_VisiblePanels = guPANEL_FILEBROWSER_VISIBLE_DEFAULT;
FileBrowserLayout = wxT( "layout2|name=FileBrowserDirCtrl;caption=" ) + wxString( _( "Directories" ) );
FileBrowserLayout += wxT( ";state=2044;dir=4;layer=0;row=0;pos=0;prop=100000;bestw=60;besth=28;minw=60;minh=28;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|" );
FileBrowserLayout += wxT( "name=FileBrowserFilesCtrl;caption=;state=768;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|" );
FileBrowserLayout += wxT( "dock_size(5,0,0)=10|dock_size(4,0,0)=266|" );
//m_AuiManager.Update();
}
m_AuiManager.LoadPerspective( FileBrowserLayout, true );
m_DirCtrl->Bind( wxEVT_TREE_SEL_CHANGED, &guFileBrowser::OnDirItemChanged, this );
m_FilesCtrl->Bind( wxEVT_LISTBOX_DCLICK, &guFileBrowser::OnFileItemActivated, this );
m_FilesCtrl->Bind( wxEVT_LIST_COL_CLICK, &guFileBrowser::OnFilesColClick, this );
Bind( wxEVT_MENU, &guFileBrowser::OnFolderPlay, this, ID_FILESYSTEM_FOLDER_PLAY );
Bind( wxEVT_MENU, &guFileBrowser::OnFolderEnqueue, this, ID_FILESYSTEM_FOLDER_ENQUEUE_AFTER_ALL, ID_FILESYSTEM_FOLDER_ENQUEUE_AFTER_ARTIST );
Bind( wxEVT_MENU, &guFileBrowser::OnFolderNew, this, ID_FILESYSTEM_FOLDER_NEW );
Bind( wxEVT_MENU, &guFileBrowser::OnFolderRename, this, ID_FILESYSTEM_FOLDER_RENAME );
Bind( wxEVT_MENU, &guFileBrowser::OnFolderDelete, this, ID_FILESYSTEM_FOLDER_DELETE );
Bind( wxEVT_MENU, &guFileBrowser::OnFolderCopy, this, ID_FILESYSTEM_FOLDER_COPY );
Bind( wxEVT_MENU, &guFileBrowser::OnFolderPaste, this, ID_FILESYSTEM_FOLDER_PASTE );
Bind( wxEVT_MENU, &guFileBrowser::OnFolderEditTracks, this, ID_FILESYSTEM_FOLDER_EDITTRACKS );
Bind( wxEVT_MENU, &guFileBrowser::OnFolderSaveToPlayList, this, ID_FILESYSTEM_FOLDER_SAVEPLAYLIST );
Bind( wxEVT_MENU, &guFileBrowser::OnFolderUpdate, this, ID_FILESYSTEM_FOLDER_UPDATE );
m_DirCtrl->Bind( wxEVT_MENU, &guFileBrowser::OnFolderCopyTo, this, ID_COPYTO_BASE, ID_COPYTO_BASE + guCOPYTO_MAXCOUNT );
m_DirCtrl->Bind( wxEVT_MENU, &guFileBrowser::OnFolderCommand, this, ID_COMMANDS_BASE, ID_COMMANDS_BASE + guCOMMANDS_MAXCOUNT );
Bind( wxEVT_MENU, &guFileBrowser::OnItemsPlay, this, ID_FILESYSTEM_ITEMS_PLAY );
Bind( wxEVT_MENU, &guFileBrowser::OnItemsEnqueue, this, ID_FILESYSTEM_ITEMS_ENQUEUE_AFTER_ALL, ID_FILESYSTEM_ITEMS_ENQUEUE_AFTER_ARTIST );
Bind( wxEVT_MENU, &guFileBrowser::OnItemsEditTracks, this, ID_FILESYSTEM_ITEMS_EDITTRACKS );
Bind( wxEVT_MENU, &guFileBrowser::OnItemsSaveToPlayList, this, ID_FILESYSTEM_ITEMS_SAVEPLAYLIST );
m_FilesCtrl->Bind( wxEVT_MENU, &guFileBrowser::OnItemsCopyTo, this, ID_COPYTO_BASE, ID_COPYTO_BASE + guCOPYTO_MAXCOUNT );
Bind( wxEVT_MENU, &guFileBrowser::OnItemsRename, this, ID_FILESYSTEM_ITEMS_RENAME );
Bind( wxEVT_MENU, &guFileBrowser::OnItemsDelete, this, ID_FILESYSTEM_ITEMS_DELETE );
Bind( wxEVT_MENU, &guFileBrowser::OnItemsCopy, this, ID_FILESYSTEM_ITEMS_COPY );
Bind( wxEVT_MENU, &guFileBrowser::OnItemsPaste, this, ID_FILESYSTEM_ITEMS_PASTE );
m_FilesCtrl->Bind( wxEVT_MENU, &guFileBrowser::OnItemsCommand, this, ID_COMMANDS_BASE, ID_COMMANDS_BASE + guCOMMANDS_MAXCOUNT );
}
// -------------------------------------------------------------------------------- //
guFileBrowser::~guFileBrowser()
{
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->WriteNum( CONFIG_KEY_FILE_BROWSER_VISIBLE_PANELS, m_VisiblePanels, CONFIG_PATH_FILE_BROWSER );
Config->WriteStr( CONFIG_KEY_FILE_BROWSER_LAST_LAYOUT, m_AuiManager.SavePerspective(), CONFIG_PATH_FILE_BROWSER );
Config->WriteStr( CONFIG_KEY_FILE_BROWSER_PATH, m_DirCtrl->GetPath(), CONFIG_PATH_FILE_BROWSER );
m_DirCtrl->Unbind( wxEVT_TREE_SEL_CHANGED, &guFileBrowser::OnDirItemChanged, this );
m_FilesCtrl->Unbind( wxEVT_LISTBOX_DCLICK, &guFileBrowser::OnFileItemActivated, this );
m_FilesCtrl->Unbind( wxEVT_LIST_COL_CLICK, &guFileBrowser::OnFilesColClick, this );
Unbind( wxEVT_MENU, &guFileBrowser::OnFolderPlay, this, ID_FILESYSTEM_FOLDER_PLAY );
Unbind( wxEVT_MENU, &guFileBrowser::OnFolderEnqueue, this, ID_FILESYSTEM_FOLDER_ENQUEUE_AFTER_ALL, ID_FILESYSTEM_FOLDER_ENQUEUE_AFTER_ARTIST );
Unbind( wxEVT_MENU, &guFileBrowser::OnFolderNew, this, ID_FILESYSTEM_FOLDER_NEW );
Unbind( wxEVT_MENU, &guFileBrowser::OnFolderRename, this, ID_FILESYSTEM_FOLDER_RENAME );
Unbind( wxEVT_MENU, &guFileBrowser::OnFolderDelete, this, ID_FILESYSTEM_FOLDER_DELETE );
Unbind( wxEVT_MENU, &guFileBrowser::OnFolderCopy, this, ID_FILESYSTEM_FOLDER_COPY );
Unbind( wxEVT_MENU, &guFileBrowser::OnFolderPaste, this, ID_FILESYSTEM_FOLDER_PASTE );
Unbind( wxEVT_MENU, &guFileBrowser::OnFolderEditTracks, this, ID_FILESYSTEM_FOLDER_EDITTRACKS );
Unbind( wxEVT_MENU, &guFileBrowser::OnFolderSaveToPlayList, this, ID_FILESYSTEM_FOLDER_SAVEPLAYLIST );
Unbind( wxEVT_MENU, &guFileBrowser::OnFolderUpdate, this, ID_FILESYSTEM_FOLDER_UPDATE );
m_DirCtrl->Unbind( wxEVT_MENU, &guFileBrowser::OnFolderCopyTo, this, ID_COPYTO_BASE, ID_COPYTO_BASE + guCOPYTO_MAXCOUNT );
m_DirCtrl->Unbind( wxEVT_MENU, &guFileBrowser::OnFolderCommand, this, ID_COMMANDS_BASE, ID_COMMANDS_BASE + guCOMMANDS_MAXCOUNT );
Unbind( wxEVT_MENU, &guFileBrowser::OnItemsPlay, this, ID_FILESYSTEM_ITEMS_PLAY );
Unbind( wxEVT_MENU, &guFileBrowser::OnItemsEnqueue, this, ID_FILESYSTEM_ITEMS_ENQUEUE_AFTER_ALL, ID_FILESYSTEM_ITEMS_ENQUEUE_AFTER_ARTIST );
Unbind( wxEVT_MENU, &guFileBrowser::OnItemsEditTracks, this, ID_FILESYSTEM_ITEMS_EDITTRACKS );
Unbind( wxEVT_MENU, &guFileBrowser::OnItemsSaveToPlayList, this, ID_FILESYSTEM_ITEMS_SAVEPLAYLIST );
m_FilesCtrl->Unbind( wxEVT_MENU, &guFileBrowser::OnItemsCopyTo, this, ID_COPYTO_BASE, ID_COPYTO_BASE + guCOPYTO_MAXCOUNT );
Unbind( wxEVT_MENU, &guFileBrowser::OnItemsRename, this, ID_FILESYSTEM_ITEMS_RENAME );
Unbind( wxEVT_MENU, &guFileBrowser::OnItemsDelete, this, ID_FILESYSTEM_ITEMS_DELETE );
Unbind( wxEVT_MENU, &guFileBrowser::OnItemsCopy, this, ID_FILESYSTEM_ITEMS_COPY );
Unbind( wxEVT_MENU, &guFileBrowser::OnItemsPaste, this, ID_FILESYSTEM_ITEMS_PASTE );
m_FilesCtrl->Unbind( wxEVT_MENU, &guFileBrowser::OnItemsCommand, this, ID_COMMANDS_BASE, ID_COMMANDS_BASE + guCOMMANDS_MAXCOUNT );
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnDirItemChanged( wxTreeEvent &event )
{
wxString CurPath = m_DirCtrl->GetPath();
if( !CurPath.EndsWith( wxT( "/" ) ) )
CurPath.Append( wxT( "/" ) );
guLogMessage( wxT( "guFileBrowser::OnDirItemChanged( '%s' )" ), CurPath.c_str() );
if( m_DirCtrl->GetShowPaths() & guFILEBROWSER_SHOWPATH_LOCATIONS )
{
m_MediaViewer = FindMediaViewerByPath( m_MainFrame, CurPath );
m_Db = m_MediaViewer ? m_MediaViewer->GetDb() : NULL;
if( m_MediaViewer )
{
guLogTrace( wxT( "'%s' ==>> '%i' '%s'" ), CurPath.c_str(), m_MediaViewer != NULL, m_MediaViewer->GetName().c_str() );
}
else
{
guLogTrace( wxT( "'%s' ==>> '%i' ''" ), CurPath.c_str(), m_MediaViewer != NULL );
}
}
else
{
m_Db = NULL;
}
m_FilesCtrl->SetPath( CurPath, m_MediaViewer );
m_DirCtrl->SetMediaViewer( m_MediaViewer );
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnFileItemActivated( wxCommandEvent &Event )
{
wxArrayInt Selection = m_FilesCtrl->GetSelectedItems( false );
if( Selection.Count() )
{
if( m_FilesCtrl->GetType( Selection[ 0 ] ) == guFILEITEM_TYPE_FOLDER )
{
m_DirCtrl->SetPath( m_FilesCtrl->GetPath( Selection[ 0 ] ), m_MediaViewer );
}
else
{
wxArrayString Files;
Files.Add( m_FilesCtrl->GetPath( Selection[ 0 ] ) );
guConfig * Config = ( guConfig * ) guConfig::Get();
if( Config )
{
if( Config->ReadBool( CONFIG_KEY_GENERAL_ACTION_ENQUEUE, false , CONFIG_PATH_GENERAL) )
{
m_PlayerPanel->AddToPlayList( Files );
}
else
{
m_PlayerPanel->SetPlayList( Files );
}
}
}
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnFilesColClick( wxListEvent &event )
{
int col = event.GetColumn();
if( col < 0 )
return;
m_FilesCtrl->SetOrder( col );
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnDirBeginDrag( wxTreeEvent &event )
{
wxFileDataObject Files;
wxArrayString FolderFiles = m_FilesCtrl->GetAllFiles( true );
int Count = FolderFiles.Count();
if( Count )
{
for( int Index = 0; Index < Count; Index++ )
{
Files.AddFile( FolderFiles[ Index ] );
}
wxDropSource source( Files, this );
wxDragResult Result = source.DoDragDrop();
if( Result )
{
}
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnFolderPlay( wxCommandEvent &event )
{
wxArrayString Files = m_FilesCtrl->GetAllFiles( true );
m_PlayerPanel->SetPlayList( Files );
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnFolderEnqueue( wxCommandEvent &event )
{
wxArrayString Files = m_FilesCtrl->GetAllFiles( true );
if( Files.Count() )
{
m_PlayerPanel->AddToPlayList( Files, true, event.GetId() - ID_FILESYSTEM_FOLDER_ENQUEUE_AFTER_ALL );
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnFolderNew( wxCommandEvent &event )
{
m_DirCtrl->FolderNew();
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnFolderRename( wxCommandEvent &event )
{
m_DirCtrl->FolderRename();
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnFolderDelete( wxCommandEvent &event )
{
m_DirCtrl->FolderDelete();
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnFolderCopy( wxCommandEvent &event )
{
//guLogMessage( wxT( "OnFolderCopy" ) );
wxTheClipboard->UsePrimarySelection( false );
if( wxTheClipboard->Open() )
{
wxTheClipboard->Clear();
wxFileDataObject * FileObject = new wxFileDataObject();
//wxCustomDataObject * GnomeCopiedObject = new wxCustomDataObject( wxDataFormat( wxT( "x-special/gnome-copied-files" ) ) );
//wxCustomDataObject * UriListObject = new wxCustomDataObject( wxDataFormat( wxT( "text/uri-list" ) ) );
wxTextDataObject * TextObject = new wxTextDataObject();
wxDataObjectComposite * CompositeObject = new wxDataObjectComposite();
wxString Path = m_DirCtrl->GetPath();
Path.Replace( wxT( "#" ), wxT( "%23" ) );
TextObject->SetText( Path );
FileObject->AddFile( Path );
//Path = wxT( "file://" ) + Path;
//UriListObject->SetData( Path.Length(), Path.char_str() );
//Path = wxT( "copy\n" ) + Path;
//GnomeCopiedObject->SetData( Path.Length(), Path.char_str() );
//guLogMessage( wxT( "Copy: '%s'" ), Path.c_str() );
CompositeObject->Add( FileObject );
//CompositeObject->Add( GnomeCopiedObject );
//CompositeObject->Add( UriListObject );
CompositeObject->Add( TextObject );
//if( !wxTheClipboard->AddData( CustomObject ) )
if( !wxTheClipboard->AddData( CompositeObject ) )
//if( !wxTheClipboard->AddData( TextObject ) )
{
delete FileObject;
delete TextObject;
//delete GnomeCopiedObject;
//delete UriListObject;
delete CompositeObject;
guLogError( wxT( "Can't copy the folder to the clipboard" ) );
}
guLogMessage( wxT( "Copied the data to the clipboard..." ) );
wxTheClipboard->Close();
}
else
{
guLogError( wxT( "Could not open the clipboard object" ) );
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnFolderPaste( wxCommandEvent &event )
{
guLogMessage( wxT( "OnFolderPaste" ) );
wxTheClipboard->UsePrimarySelection( false );
if( wxTheClipboard->Open() )
{
// if( wxTheClipboard->IsSupported( wxDataFormat( wxT( "text/uri-list" ) ) ) )
// {
// guLogMessage( wxT( "Supported format uri-list.." ) );
//
// wxCustomDataObject CustomDataObject( wxDataFormat( wxT( "text/uri-list" ) ) );
// if( wxTheClipboard->GetData( CustomDataObject ) )
// {
// guLogMessage( wxT( "Custom Data: (%i) '%s'" ), CustomDataObject.GetSize(), wxString( ( const char * ) CustomDataObject.GetData(), wxConvUTF8 ).c_str() );
// }
// }
//
// if( wxTheClipboard->IsSupported( wxDataFormat( wxT( "x-special/gnome-copied-files" ) ) ) )
// {
// guLogMessage( wxT( "Supported format x-special..." ) );
//
// wxCustomDataObject CustomDataObject( wxDataFormat( wxT( "x-special/gnome-copied-files" ) ) ); //( wxT( "Supported format x-special..." ) );
// if( wxTheClipboard->GetData( CustomDataObject ) )
// {
// guLogMessage( wxT( "Custom Data: (%i) '%s'" ), CustomDataObject.GetSize(), wxString( ( const char * ) CustomDataObject.GetData(), wxConvUTF8 ).c_str() );
// }
// }
// else if( wxTheClipboard->IsSupported( wxDF_FILENAME ) )
if( wxTheClipboard->IsSupported( wxDF_FILENAME ) )
{
wxFileDataObject FileObject;
if( wxTheClipboard->GetData( FileObject ) )
{
wxArrayString Files = FileObject.GetFilenames();
wxArrayString FromFiles;
//guLogMessage( wxT( "Pasted: %s" ), Files[ 0 ].c_str() );
int Count = Files.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( wxDirExists( Files[ Index ] ) )
{
//wxFileName::Mkdir( m_DirCtrl->GetPath() + wxT( "/" ) + wxFileNameFromPath( Files[ Index ] ), 0770, wxPATH_MKDIR_FULL );
guAddDirItems( Files[ Index ], FromFiles );
int FromIndex;
int FromCount = FromFiles.Count();
for( FromIndex = 0; FromIndex < FromCount; FromIndex++ )
{
wxString DestName = FromFiles[ FromIndex ];
DestName.Replace( wxPathOnly( Files[ Index ] ), m_DirCtrl->GetPath() );
wxFileName::Mkdir( wxPathOnly( DestName ), 0770, wxPATH_MKDIR_FULL );
guLogMessage( wxT( "Copy file %s to %s" ), FromFiles[ FromIndex ].c_str(), DestName.c_str() );
wxCopyFile( FromFiles[ FromIndex ], DestName );
}
}
else
{
wxCopyFile( Files[ Index ], m_DirCtrl->GetPath() + wxT( "/" ) + wxFileNameFromPath( Files[ Index ] ) );
}
}
wxString CurPath = m_DirCtrl->GetPath();
m_DirCtrl->CollapsePath( CurPath );
m_DirCtrl->ExpandPath( CurPath );
}
else
{
guLogError( wxT( "Can't paste the data from the clipboard" ) );
}
}
wxTheClipboard->Close();
}
else
{
guLogError( wxT( "Could not open the clipboard object" ) );
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnFolderEditTracks( wxCommandEvent &event )
{
guTrackArray Tracks;
guImagePtrArray Images;
wxArrayString Lyrics;
wxArrayInt ChangedFlags;
m_FilesCtrl->GetAllSongs( &Tracks );
if( Tracks.Count() )
{
guTrackEditor * TrackEditor = new guTrackEditor( this, m_Db ? m_Db : m_DefaultDb, &Tracks, &Images, &Lyrics, &ChangedFlags );
if( TrackEditor )
{
if( TrackEditor->ShowModal() == wxID_OK )
{
guUpdateTracks( Tracks, Images, Lyrics, ChangedFlags );
if( m_Db )
m_Db->UpdateSongs( &Tracks, ChangedFlags );
else
m_DefaultDb->UpdateSongs( &Tracks, ChangedFlags );
//guUpdateLyrics( Tracks, Lyrics, ChangedFlags );
//guUpdateImages( Tracks, Images, ChangedFlags );
// Update the track in database, playlist, etc
m_MainFrame->UpdatedTracks( guUPDATED_TRACKS_PLAYER_PLAYLIST, &Tracks );
}
guImagePtrArrayClean( &Images );
TrackEditor->Destroy();
}
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnFolderSaveToPlayList( wxCommandEvent &event )
{
guTrackArray Tracks;
m_FilesCtrl->GetAllSongs( &Tracks );
wxArrayInt TrackIds;
int Count = Tracks.Count();
for( int Index = 0; Index < Count; Index++ )
{
TrackIds.Add( Tracks[ Index ].m_SongId );
}
if( m_Db && TrackIds.Count() )
{
guListItems PlayLists;
m_Db->GetPlayLists( &PlayLists,guPLAYLIST_TYPE_STATIC );
guPlayListAppend * PlayListAppendDlg = new guPlayListAppend( m_MainFrame, m_Db, &TrackIds, &PlayLists );
if( PlayListAppendDlg->ShowModal() == wxID_OK )
{
int Selected = PlayListAppendDlg->GetSelectedPlayList();
if( Selected == -1 )
{
wxString PLName = PlayListAppendDlg->GetPlaylistName();
if( PLName.IsEmpty() )
{
PLName = _( "UnNamed" );
}
m_Db->CreateStaticPlayList( PLName, TrackIds );
}
else
{
int PLId = PlayLists[ Selected ].m_Id;
wxArrayInt OldSongs;
m_Db->GetPlayListSongIds( PLId, &OldSongs );
if( PlayListAppendDlg->GetSelectedPosition() == 0 ) // BEGIN
{
m_Db->UpdateStaticPlayList( PLId, TrackIds );
m_Db->AppendStaticPlayList( PLId, OldSongs );
}
else // END
{
m_Db->AppendStaticPlayList( PLId, TrackIds );
}
}
m_MediaViewer->UpdatePlaylists();
}
PlayListAppendDlg->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnFolderUpdate( wxCommandEvent &event )
{
if( m_MediaViewer )
{
m_MediaViewer->UpdateLibrary( m_DirCtrl->GetPath() );
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnFolderCopyTo( wxCommandEvent &event )
{
guTrackArray * Tracks = new guTrackArray();
m_FilesCtrl->GetAllSongs( Tracks );
int Index = event.GetId() - ID_COPYTO_BASE;
if( Index >= guCOPYTO_DEVICE_BASE )
{
Index -= guCOPYTO_DEVICE_BASE;
event.SetId( ID_MAINFRAME_COPYTODEVICE_TRACKS );
}
else
{
event.SetId( ID_MAINFRAME_COPYTO );
}
event.SetInt( Index );
event.SetClientData( ( void * ) Tracks );
wxPostEvent( m_MainFrame, event );
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnItemsPlay( wxCommandEvent &event )
{
wxArrayString Files = m_FilesCtrl->GetSelectedFiles( true );
int Count = Files.Count();
for( int Index = 0; Index < Count; Index++ )
{
guLogMessage( wxT( "File%i: '%s'" ), Index, Files[ Index ].c_str() );
}
if( Files.Count() )
{
m_PlayerPanel->SetPlayList( Files );
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnItemsEnqueue( wxCommandEvent &event )
{
wxArrayString Files = m_FilesCtrl->GetSelectedFiles( true );
if( Files.Count() )
{
m_PlayerPanel->AddToPlayList( Files, true, event.GetId() - ID_FILESYSTEM_ITEMS_ENQUEUE_AFTER_ALL );
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnItemsEditTracks( wxCommandEvent &event )
{
guTrackArray Tracks;
guImagePtrArray Images;
wxArrayString Lyrics;
wxArrayInt ChangedFlags;
m_FilesCtrl->GetSelectedSongs( &Tracks );
if( Tracks.Count() )
{
guTrackEditor * TrackEditor = new guTrackEditor( this, m_Db ? m_Db : m_DefaultDb, &Tracks, &Images, &Lyrics, &ChangedFlags );
if( TrackEditor )
{
if( TrackEditor->ShowModal() == wxID_OK )
{
guUpdateTracks( Tracks, Images, Lyrics, ChangedFlags );
if( m_Db )
m_Db->UpdateSongs( &Tracks, ChangedFlags );
else
m_DefaultDb->UpdateSongs( &Tracks, ChangedFlags );
//guUpdateLyrics( Tracks, Lyrics, ChangedFlags );
//guUpdateImages( Tracks, Images, ChangedFlags );
// Update the track in database, playlist, etc
m_MainFrame->UpdatedTracks( guUPDATED_TRACKS_PLAYER_PLAYLIST, &Tracks );
}
guImagePtrArrayClean( &Images );
TrackEditor->Destroy();
}
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnItemsSaveToPlayList( wxCommandEvent &event )
{
guTrackArray Tracks;
m_FilesCtrl->GetSelectedSongs( &Tracks );
wxArrayInt TrackIds;
int Count = Tracks.Count();
for( int Index = 0; Index < Count; Index++ )
{
TrackIds.Add( Tracks[ Index ].m_SongId );
}
if( m_Db && TrackIds.Count() )
{
guListItems PlayLists;
m_Db->GetPlayLists( &PlayLists, guPLAYLIST_TYPE_STATIC );
guPlayListAppend * PlayListAppendDlg = new guPlayListAppend( m_MainFrame, m_Db, &TrackIds, &PlayLists );
if( PlayListAppendDlg->ShowModal() == wxID_OK )
{
int Selected = PlayListAppendDlg->GetSelectedPlayList();
if( Selected == -1 )
{
wxString PLName = PlayListAppendDlg->GetPlaylistName();
if( PLName.IsEmpty() )
{
PLName = _( "UnNamed" );
}
m_Db->CreateStaticPlayList( PLName, TrackIds );
}
else
{
int PLId = PlayLists[ Selected ].m_Id;
wxArrayInt OldSongs;
m_Db->GetPlayListSongIds( PLId, &OldSongs );
if( PlayListAppendDlg->GetSelectedPosition() == 0 ) // BEGIN
{
m_Db->UpdateStaticPlayList( PLId, TrackIds );
m_Db->AppendStaticPlayList( PLId, OldSongs );
}
else // END
{
m_Db->AppendStaticPlayList( PLId, TrackIds );
}
}
m_MediaViewer->UpdatePlaylists();
}
PlayListAppendDlg->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnItemsCopyTo( wxCommandEvent &event )
{
guTrackArray * Tracks = new guTrackArray();
m_FilesCtrl->GetSelectedSongs( Tracks );
int Index = event.GetId() - ID_COPYTO_BASE;
if( Index >= guCOPYTO_DEVICE_BASE )
{
Index -= guCOPYTO_DEVICE_BASE;
event.SetId( ID_MAINFRAME_COPYTODEVICE_TRACKS );
}
else
{
event.SetId( ID_MAINFRAME_COPYTO );
}
event.SetInt( Index );
event.SetClientData( ( void * ) Tracks );
wxPostEvent( m_MainFrame, event );
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnItemsRename( wxCommandEvent &event )
{
wxArrayString Files = m_FilesCtrl->GetSelectedFiles( true );
if( Files.Count() )
{
guFileRenamer * FileRenamer = new guFileRenamer( this, m_Db ? m_Db : m_DefaultDb, Files );
if( FileRenamer )
{
if( FileRenamer->ShowModal() == wxID_OK )
{
wxArrayString RenamedFiles = FileRenamer->GetRenamedNames();
int Count = RenamedFiles.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( Files[ Index ] != RenamedFiles[ Index ] )
{
wxString NewDirName = wxPathOnly( RenamedFiles[ Index ] );
if( !wxDirExists( NewDirName ) )
{
wxFileName::Mkdir( NewDirName, 0770, wxPATH_MKDIR_FULL );
}
//if( wxFileExists( Files[ Index ] ) )
if( !guRenameFile( Files[ Index ], RenamedFiles[ Index ] ) )
{
guLogError( wxT( "Could no rename '%s' to '%s'" ),
Files[ Index ].c_str(),
RenamedFiles[ Index ].c_str() );
}
if( m_Db )
m_Db->UpdateTrackFileName( Files[ Index ], RenamedFiles[ Index ] );
else
m_DefaultDb->UpdateTrackFileName( Files[ Index ], RenamedFiles[ Index ] );
}
}
//m_DirCtrl->ExpandPath( m_DirCtrl->GetPath() );
m_FilesCtrl->SetPath( m_DirCtrl->GetPath(), m_MediaViewer );
}
FileRenamer->Destroy();
}
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnItemsDelete( wxCommandEvent &event )
{
wxArrayString Files = m_FilesCtrl->GetSelectedFiles();
bool Error = false;
int Count = Files.Count();
if( Count )
{
if( wxMessageBox( _( "Are you sure to delete the selected files ?" ),
_( "Confirm" ),
wxICON_QUESTION | wxYES_NO, this ) == wxYES )
{
wxArrayString DeleteFiles;
for( int Index = 0; Index < Count; Index++ )
{
if( wxDirExists( Files[ Index ] ) )
{
Error = !RemoveDirItems( Files[ Index ], &DeleteFiles ) || !wxRmdir( Files[ Index ] );
}
else
{
Error = !wxRemoveFile( Files[ Index ] );
DeleteFiles.Add( Files[ Index ] );
}
if( Error )
{
if( wxMessageBox( _( "There was an error deleting " ) + wxFileNameFromPath( Files[ Index ] ) +
_( "\nContinue deleting?" ),
_( "Continue" ),
wxICON_QUESTION | wxYES_NO, this ) == wxNO )
{
break;
}
//Error = false;
}
}
wxString CurrentFolder = m_DirCtrl->GetPath();
m_DirCtrl->CollapsePath( CurrentFolder );
m_DirCtrl->ExpandPath( CurrentFolder );
//
//m_Db->DoCleanUp();
if( m_Db )
m_Db->CleanFiles( DeleteFiles );
else
m_DefaultDb->CleanFiles( DeleteFiles );
}
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnFolderCommand( wxCommandEvent &event )
{
int CommandId = event.GetId();
guConfig * Config = ( guConfig * ) guConfig::Get();
if( Config )
{
wxArrayString Commands = Config->ReadAStr( CONFIG_KEY_COMMANDS_EXEC, wxEmptyString, CONFIG_PATH_COMMANDS_EXECS );
CommandId -= ID_COMMANDS_BASE;
wxString CurCmd = Commands[ CommandId ];
if( CurCmd.Find( guCOMMAND_ALBUMPATH ) != wxNOT_FOUND )
{
wxString DirPath = m_DirCtrl->GetPath();
DirPath.Replace( wxT( " " ), wxT( "\\ " ) );
CurCmd.Replace( guCOMMAND_ALBUMPATH, DirPath );
}
if( CurCmd.Find( guCOMMAND_TRACKPATH ) != wxNOT_FOUND )
{
wxString SongList;
wxArrayString Files = m_FilesCtrl->GetAllFiles( true );
int Count = Files.Count();
for( int Index = 0; Index < Count; Index++ )
{
SongList += wxT( " \"" ) + Files[ Index ] + wxT( "\"" );
}
CurCmd.Replace( guCOMMAND_TRACKPATH, SongList.Trim( false ) );
}
//guLogMessage( wxT( "Execute Command '%s'" ), CurCmd.c_str() );
guExecute( CurCmd );
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnItemsCommand( wxCommandEvent &event )
{
int CommandId = event.GetId();
guConfig * Config = ( guConfig * ) guConfig::Get();
if( Config )
{
wxArrayString Commands = Config->ReadAStr( CONFIG_KEY_COMMANDS_EXEC, wxEmptyString, CONFIG_PATH_COMMANDS_EXECS );
CommandId -= ID_COMMANDS_BASE;
wxString CurCmd = Commands[ CommandId ];
if( CurCmd.Find( guCOMMAND_ALBUMPATH ) != wxNOT_FOUND )
{
wxString DirPath = m_DirCtrl->GetPath();
DirPath.Replace( wxT( " " ), wxT( "\\ " ) );
CurCmd.Replace( guCOMMAND_ALBUMPATH, DirPath );
}
if( CurCmd.Find( guCOMMAND_COVERPATH ) != wxNOT_FOUND )
{
wxString SongList;
wxArrayString Files = m_FilesCtrl->GetSelectedFiles( false );
int Count = Files.Count();
for( int Index = 0; Index < Count; Index++ )
{
SongList += wxT( " \"" ) + Files[ Index ] + wxT( "\"" );
}
CurCmd.Replace( guCOMMAND_COVERPATH, SongList.Trim( false ) );
}
if( CurCmd.Find( guCOMMAND_TRACKPATH ) != wxNOT_FOUND )
{
wxString SongList;
wxArrayString Files = m_FilesCtrl->GetSelectedFiles( true );
int Count = Files.Count();
for( int Index = 0; Index < Count; Index++ )
{
SongList += wxT( " \"" ) + Files[ Index ] + wxT( "\"" );
}
CurCmd.Replace( guCOMMAND_TRACKPATH, SongList.Trim( false ) );
}
//guLogMessage( wxT( "Execute Command '%s'" ), CurCmd.c_str() );
guExecute( CurCmd );
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnItemsCopy( wxCommandEvent &event )
{
wxArrayString Files = m_FilesCtrl->GetSelectedFiles( false );
if( Files.Count() )
{
wxTheClipboard->UsePrimarySelection( false );
if( wxTheClipboard->Open() )
{
wxTheClipboard->Clear();
wxFileDataObject * FileObject = new wxFileDataObject();
wxTextDataObject * TextObject = new wxTextDataObject();
wxDataObjectComposite * CompositeObject = new wxDataObjectComposite();
wxString FilesText;
int Count = Files.Count();
for( int Index = 0; Index < Count; Index++ )
{
wxString CurFile = Files[ Index ];
FilesText += ( FilesText.IsEmpty() ? wxT( "" ) : wxT( "\n" ) ) + CurFile;
CurFile.Replace( wxT( "#" ), wxT( "%23" ) );
FileObject->AddFile( CurFile );
}
TextObject->SetText( FilesText );
CompositeObject->Add( FileObject );
CompositeObject->Add( TextObject );
if( !wxTheClipboard->AddData( CompositeObject ) )
{
delete FileObject;
delete TextObject;
delete CompositeObject;
guLogError( wxT( "Can't copy the selected files to the clipboard" ) );
}
wxTheClipboard->Close();
}
else
{
guLogError( wxT( "Could not open the clipboard object" ) );
}
}
}
// -------------------------------------------------------------------------------- //
void guFileBrowser::OnItemsPaste( wxCommandEvent &event )
{
wxString DestFolder;
wxTheClipboard->UsePrimarySelection( false );
if( wxTheClipboard->Open() )
{
if( wxTheClipboard->IsSupported( wxDF_FILENAME ) )
{
wxArrayString Selection = m_FilesCtrl->GetSelectedFiles( false );
if( ( Selection.Count() == 1 ) && wxDirExists( Selection[ 0 ] ) )
{
DestFolder = Selection[ 0 ];
}
else
{
DestFolder = m_DirCtrl->GetPath();
}
wxFileDataObject FileObject;
if( wxTheClipboard->GetData( FileObject ) )
{
wxArrayString Files = FileObject.GetFilenames();
wxArrayString FromFiles;
//guLogMessage( wxT( "Pasted: %s" ), Files[ 0 ].c_str() );
int Count = Files.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( wxDirExists( Files[ Index ] ) )
{
guAddDirItems( Files[ Index ], FromFiles );
int FromIndex;
int FromCount = FromFiles.Count();
for( FromIndex = 0; FromIndex < FromCount; FromIndex++ )
{
wxString DestName = FromFiles[ FromIndex ];
DestName.Replace( wxPathOnly( Files[ Index ] ), DestFolder );
wxFileName::Mkdir( wxPathOnly( DestName ), 0770, wxPATH_MKDIR_FULL );
guLogMessage( wxT( "Copy file %s to %s" ), FromFiles[ FromIndex ].c_str(), DestName.c_str() );
wxCopyFile( FromFiles[ FromIndex ], DestName );
}
}
else
{
wxCopyFile( Files[ Index ], m_DirCtrl->GetPath() + wxT( "/" ) + wxFileNameFromPath( Files[ Index ] ) );
}
}
wxString CurPath = m_DirCtrl->GetPath();
m_DirCtrl->CollapsePath( CurPath );
m_DirCtrl->ExpandPath( CurPath );
}
else
{
guLogError( wxT( "Can't paste the data from the clipboard" ) );
}
}
wxTheClipboard->Close();
}
else
{
guLogError( wxT( "Could not open the clipboard object" ) );
}
}
}
// -------------------------------------------------------------------------------- //
| 94,106
|
C++
|
.cpp
| 2,155
| 34.590719
| 212
| 0.530226
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
750,650
|
FileRenamer.cpp
|
anonbeat_guayadeque/src/ui/filebrowser/FileRenamer.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.h"tml
//
// -------------------------------------------------------------------------------- //
#include "FileRenamer.h"
#include "Config.h"
#include "Images.h"
#include "MainFrame.h"
#include "TagInfo.h"
#include "Utils.h"
#include <wx/uri.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
guFileRenamer::guFileRenamer( wxWindow * parent, guDbLibrary * db, const wxArrayString &files )
{
m_Db = db;
m_Files = files;
m_CurFile = wxNOT_FOUND;
guConfig * Config = ( guConfig * ) guConfig::Get();
wxPoint WindowPos;
WindowPos.x = Config->ReadNum( CONFIG_KEY_FILE_RENAMER_POS_X, -1, CONFIG_PATH_FILE_RENAMER );
WindowPos.y = Config->ReadNum( CONFIG_KEY_FILE_RENAMER_POS_Y, -1, CONFIG_PATH_FILE_RENAMER );
wxSize WindowSize;
WindowSize.x = Config->ReadNum( CONFIG_KEY_FILE_RENAMER_SIZE_WIDTH, 500, CONFIG_PATH_FILE_RENAMER );
WindowSize.y = Config->ReadNum( CONFIG_KEY_FILE_RENAMER_SIZE_HEIGHT, 320, CONFIG_PATH_FILE_RENAMER );
Create( parent, wxID_ANY, _( "Rename Files" ), WindowPos, WindowSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER | wxMAXIMIZE_BOX );
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* MainSizer;
MainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer * FilesSizer;
FilesSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _(" Names Preview ") ), wxVERTICAL );
m_FilesListBox = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_EXTENDED|wxLB_MULTIPLE );
m_FilesListBox->Append( files );
FilesSizer->Add( m_FilesListBox, 1, wxEXPAND|wxALL, 5 );
wxFlexGridSizer * EditSizer;
EditSizer = new wxFlexGridSizer( 2, 0, 0 );
EditSizer->AddGrowableCol( 1 );
EditSizer->SetFlexibleDirection( wxBOTH );
EditSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
wxStaticText * NameStaticText = new wxStaticText( this, wxID_ANY, _("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
NameStaticText->Wrap( -1 );
EditSizer->Add( NameStaticText, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_NameTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
EditSizer->Add( m_NameTextCtrl, 0, wxTOP|wxBOTTOM|wxRIGHT|wxEXPAND, 5 );
wxStaticText * PatternStaticText = new wxStaticText( this, wxID_ANY, _("Pattern:"), wxDefaultPosition, wxDefaultSize, 0 );
PatternStaticText->Wrap( -1 );
EditSizer->Add( PatternStaticText, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxBoxSizer* PatternSizer;
PatternSizer = new wxBoxSizer( wxHORIZONTAL );
m_PatTextCtrl = new wxTextCtrl( this, wxID_ANY, Config->ReadStr( CONFIG_KEY_FILE_RENAMER_PATTERN, wxT( "{n} - {a} - {t}" ), CONFIG_PATH_FILE_RENAMER ), wxDefaultPosition, wxDefaultSize, 0 );
m_PatTextCtrl->SetToolTip( _( "Pattern flags:\n{g} : Genre\n{a} : Artist\n{aa}: Album Artist\n{A} : {aa} or {a}\n{b} : Album\n{t} : Title\n{n} : Number\n{y} : Year\n{d} : Disk" ) );
PatternSizer->Add( m_PatTextCtrl, 1, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_PatApplyBtn = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_accept ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
PatternSizer->Add( m_PatApplyBtn, 0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_PatRevertBtn = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_reload ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
PatternSizer->Add( m_PatRevertBtn, 0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
EditSizer->Add( PatternSizer, 1, wxEXPAND, 5 );
FilesSizer->Add( EditSizer, 0, wxEXPAND, 5 );
MainSizer->Add( FilesSizer, 1, wxEXPAND|wxALL, 5 );
wxStdDialogButtonSizer * ButtonsSizer = new wxStdDialogButtonSizer();
wxButton * ButtonsSizerOK = new wxButton( this, wxID_OK );
ButtonsSizer->AddButton( ButtonsSizerOK );
wxButton * ButtonsSizerCancel = new wxButton( this, wxID_CANCEL );
ButtonsSizer->AddButton( ButtonsSizerCancel );
ButtonsSizer->SetAffirmativeButton( ButtonsSizerOK );
ButtonsSizer->SetCancelButton( ButtonsSizerCancel );
ButtonsSizer->Realize();
MainSizer->Add( ButtonsSizer, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
this->SetSizer( MainSizer );
this->Layout();
ButtonsSizerOK->SetDefault();
Bind( wxEVT_BUTTON, &guFileRenamer::OnOKButton, this, wxID_OK );
m_FilesListBox->Bind( wxEVT_LISTBOX, &guFileRenamer::OnFileSelected, this );
m_PatTextCtrl->Bind( wxEVT_TEXT, &guFileRenamer::OnPatternChanged, this );
m_PatApplyBtn->Bind( wxEVT_BUTTON, &guFileRenamer::OnPatternApply, this );
m_PatRevertBtn->Bind( wxEVT_BUTTON, &guFileRenamer::OnPattternRevert, this );
m_NameTextCtrl->SetFocus();
}
// -------------------------------------------------------------------------------- //
guFileRenamer::~guFileRenamer()
{
guConfig * Config = ( guConfig * ) guConfig::Get();
// Save the window position and size
wxPoint WindowPos = GetPosition();
Config->WriteNum( CONFIG_KEY_FILE_RENAMER_POS_X, WindowPos.x, CONFIG_PATH_FILE_RENAMER );
Config->WriteNum( CONFIG_KEY_FILE_RENAMER_POS_Y, WindowPos.y, CONFIG_PATH_FILE_RENAMER );
wxSize WindowSize = GetSize();
Config->WriteNum( CONFIG_KEY_FILE_RENAMER_SIZE_WIDTH, WindowSize.x, CONFIG_PATH_FILE_RENAMER );
Config->WriteNum( CONFIG_KEY_FILE_RENAMER_SIZE_HEIGHT, WindowSize.y, CONFIG_PATH_FILE_RENAMER );
Config->WriteStr( CONFIG_KEY_FILE_RENAMER_PATTERN, m_PatTextCtrl->GetValue(), CONFIG_PATH_FILE_RENAMER );
Unbind( wxEVT_BUTTON, &guFileRenamer::OnOKButton, this, wxID_OK );
m_FilesListBox->Unbind( wxEVT_LISTBOX, &guFileRenamer::OnFileSelected, this );
m_PatTextCtrl->Unbind( wxEVT_TEXT, &guFileRenamer::OnPatternChanged, this );
m_PatApplyBtn->Unbind( wxEVT_BUTTON, &guFileRenamer::OnPatternApply, this );
m_PatRevertBtn->Unbind( wxEVT_BUTTON, &guFileRenamer::OnPattternRevert, this );
}
// -------------------------------------------------------------------------------- //
void guFileRenamer::OnOKButton( wxCommandEvent& event )
{
if( m_CurFile != wxNOT_FOUND )
{
if( m_NameTextCtrl->IsModified() )
{
m_FilesListBox->SetString( m_CurFile, m_NameTextCtrl->GetValue() );
}
}
event.Skip();
}
// -------------------------------------------------------------------------------- //
void guFileRenamer::OnFileSelected( wxCommandEvent& event )
{
wxArrayInt Selection;
int SelCount = m_FilesListBox->GetSelections( Selection );
if( m_CurFile != wxNOT_FOUND )
{
if( m_NameTextCtrl->IsModified() )
{
m_FilesListBox->SetString( m_CurFile, m_NameTextCtrl->GetValue() );
}
}
m_NameTextCtrl->Enable( SelCount == 1 );
if( SelCount == 1 )
{
m_CurFile = Selection[ 0 ];
m_NameTextCtrl->SetValue( m_FilesListBox->GetString( m_CurFile ) );
}
else
{
m_CurFile = wxNOT_FOUND;
m_NameTextCtrl->SetValue( wxEmptyString );
}
}
// -------------------------------------------------------------------------------- //
void guFileRenamer::OnPatternChanged( wxCommandEvent& event )
{
bool Enabled = !event.GetString().IsEmpty();
m_PatApplyBtn->Enable( Enabled );
m_PatRevertBtn->Enable( Enabled );
}
// -------------------------------------------------------------------------------- //
void guFileRenamer::OnPatternApply( wxCommandEvent& event )
{
wxArrayInt Selection;
wxArrayString RenameFiles;
int Count = m_FilesListBox->GetSelections( Selection );
if( Count )
{
for( int Index = 0; Index < Count; Index++ )
{
RenameFiles.Add( m_Files[ Selection[ Index ] ] );
}
}
else
{
Count = m_Files.Count();
for( int Index = 0; Index < Count; Index++ )
Selection.Add( Index );
RenameFiles = m_Files;
}
if( ( Count = RenameFiles.Count() ) )
{
guMainFrame * MainFrame = ( guMainFrame * ) guMainFrame::GetMainFrame();
guDbPodcasts * DbPodcasts = MainFrame->GetPodcastsDb();
for( int Index = 0; Index < Count; Index++ )
{
wxString FileName = RenameFiles[ Index ];
if( guIsValidAudioFile( FileName ) )
{
wxURI Uri( FileName );
if( Uri.IsReference() )
{
guTrack * Track = new guTrack();
Track->m_FileName = FileName;
if( !m_Db->FindTrackFile( FileName, Track ) )
{
guPodcastItem PodcastItem;
if( DbPodcasts->GetPodcastItemFile( FileName, &PodcastItem ) )
{
delete Track;
continue;
}
else
{
//guLogMessage( wxT( "Reading tags from the file..." ) );
if( Track->ReadFromFile( FileName ) )
{
Track->m_Type = guTRACK_TYPE_NOTDB;
}
else
{
guLogError( wxT( "Could not read tags from file '%s'" ), FileName.c_str() );
delete Track;
continue;
}
}
}
if( !m_PatTextCtrl->GetValue().StartsWith( wxT( "/" ) ) )
{
FileName = wxPathOnly( FileName ) + wxT( "/" ) + m_PatTextCtrl->GetValue() +
wxT( '.' ) + FileName.AfterLast( wxT( '.' ) );
}
else
{
FileName = m_PatTextCtrl->GetValue() +
wxT( '.' ) + FileName.AfterLast( wxT( '.' ) );
}
FileName = guExpandTrackMacros( FileName, Track, Index );
m_FilesListBox->SetString( Selection[ Index ], FileName );
delete Track;
}
}
}
}
}
// -------------------------------------------------------------------------------- //
void guFileRenamer::OnPattternRevert( wxCommandEvent& event )
{
m_FilesListBox->Clear();
m_FilesListBox->Append( m_Files );
}
// -------------------------------------------------------------------------------- //
wxArrayString guFileRenamer::GetRenamedNames( void )
{
wxArrayString RetVal;
int Count = m_FilesListBox->GetCount();
for( int Index = 0; Index < Count; Index++ )
{
RetVal.Add( m_FilesListBox->GetString( Index ) );
}
return RetVal;
}
}
// -------------------------------------------------------------------------------- //
| 11,855
|
C++
|
.cpp
| 250
| 39.772
| 194
| 0.584336
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
750,651
|
LocationPanel.cpp
|
anonbeat_guayadeque/src/ui/locationpanel/LocationPanel.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "LocationPanel.h"
#include "Accelerators.h"
#include "Config.h"
#include "Images.h"
#include <wx/tokenzr.h>
#include <wx/artprov.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
// guLocationItemData
// -------------------------------------------------------------------------------- //
class guLocationItemData : public wxTreeItemData
{
private :
int m_Id;
bool m_IsOpen;
wxString m_CollectionId;
int m_CollectionType;
bool m_IsEnabled;
public :
guLocationItemData( const int id, const bool open, const wxString &uniqueid = wxEmptyString,
const int type = wxNOT_FOUND, const bool isenabled = true )
{
m_Id = id;
m_IsOpen = open;
m_CollectionId = uniqueid;
m_CollectionType = type;
m_IsEnabled = isenabled;
}
int GetId( void ) { return m_Id; }
void SetId( int id ) { m_Id = id; }
int GetOpen( void ) { return m_IsOpen; }
void SetOpen( const bool open ) { m_IsOpen = open; }
wxString GetCollectionId( void ) { return m_CollectionId; }
void SetCollectionId( const wxString &uniqueid ) { m_CollectionId = uniqueid; }
int GetCollectionType( void ) { return m_CollectionType; }
void SetCollectionType( const int type ) { m_CollectionType = type; }
bool GetIsEnabled( void ) { return m_IsEnabled; }
void SetIsEnabled( const bool enabled ) { m_IsEnabled = enabled; }
};
#define guLOCATION_PANEL_IMAGE_COUNT 9
// -------------------------------------------------------------------------------- //
// guLocationTreeCtrl
// -------------------------------------------------------------------------------- //
guLocationTreeCtrl::guLocationTreeCtrl( wxWindow * parent, guMainFrame * mainframe ) :
wxTreeCtrl( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
wxTR_DEFAULT_STYLE|wxTR_SINGLE|wxTR_HIDE_ROOT|wxTR_FULL_ROW_HIGHLIGHT|wxNO_BORDER )
{
m_MainFrame = mainframe;
m_LockCount = 0;
m_ImageList = new wxImageList();
m_ImageList->Add( guImage( guIMAGE_INDEX_loc_library ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_loc_portable_device ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_loc_net_radio ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_loc_podcast ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_loc_magnatune ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_loc_jamendo ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_loc_lastfm ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_tiny_shoutcast ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_loc_lyrics ) );
AssignImageList( m_ImageList );
m_RootId = AddRoot( wxT( "Sources" ), -1, -1, NULL );
wxFont FontBold = GetFont();
FontBold.SetWeight( wxFONTWEIGHT_BOLD );
m_LocalMusicId = AppendItem( m_RootId, _( "Local Music" ), 0 );
m_OnlineMusicId = AppendItem( m_RootId, _( "Online Music" ), 2 );
m_PortableDeviceId = AppendItem( m_RootId, _( "Portable Devices" ), 1 );
m_ContextId = AppendItem( m_RootId, _( "Context" ), -1 );
SetIndent( 5 );
Bind( wxEVT_TREE_ITEM_MENU, &guLocationTreeCtrl::OnContextMenu, this );
ReloadItems( true );
}
// -------------------------------------------------------------------------------- //
guLocationTreeCtrl::~guLocationTreeCtrl()
{
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->WriteBool( CONFIG_KEY_MAIN_SOURCES_LOCAL_MUSIC, IsExpanded( m_LocalMusicId ), CONFIG_PATH_MAIN_SOURCES );
Config->WriteBool( CONFIG_KEY_MAIN_SOURCES_ONLINE_MUSIC, IsExpanded( m_OnlineMusicId ), CONFIG_PATH_MAIN_SOURCES );
Config->WriteBool( CONFIG_KEY_MAIN_SOURCES_PORTABLE_DEVICES, IsExpanded( m_PortableDeviceId ), CONFIG_PATH_MAIN_SOURCES );
Config->WriteBool( CONFIG_KEY_MAIN_SOURCES_CONTEXT, IsExpanded( m_ContextId ), CONFIG_PATH_MAIN_SOURCES );
Unbind( wxEVT_TREE_ITEM_MENU, &guLocationTreeCtrl::OnContextMenu, this );
}
// -------------------------------------------------------------------------------- //
int guLocationTreeCtrl::GetIconIndex( const wxString &iconstring )
{
if( !iconstring.IsEmpty() )
{
//. GThemedIcon drive-removable-media-usb drive-removable-media drive-removable drive
wxArrayString IconNames = wxStringTokenize( iconstring, wxT( " " ) );
int Count = IconNames.Count();
for( int Index = 0; Index < Count; Index++ )
{
//guLogMessage( wxT( "Trying to load the icon '%s'" ), IconNames[ Index ].c_str() );
if( IconNames[ Index ] == wxT( "." ) || IconNames[ Index ] == wxT( "GThemedIcon" ) )
continue;
int IconPos = m_IconNames.Index( IconNames[ Index ] );
if( IconPos == wxNOT_FOUND )
{
wxBitmap IconBitmap = wxArtProvider::GetBitmap( IconNames[ Index ], wxART_OTHER, wxSize( 24, 24 ) );
if( IconBitmap.IsOk() )
{
//guLogMessage( wxT( "The Icon was found...") );
IconPos = m_IconNames.Count();
m_IconNames.Add( IconNames[ Index ] );
m_ImageList->Add( IconBitmap );
return guLOCATION_PANEL_IMAGE_COUNT + IconPos;
}
}
else
{
return guLOCATION_PANEL_IMAGE_COUNT + IconPos;
}
}
}
return 1;
}
// -------------------------------------------------------------------------------- //
void guLocationTreeCtrl::ReloadItems( const bool loadstate )
{
if( m_LockCount )
return;
wxTreeItemId CurrentItem;
int VisiblePanels = m_MainFrame->VisiblePanels();
bool LocalMusicExpanded;
bool OnlineMusicExpanded;
bool PortableDeviceExpanded;
bool ContextExpanded;
if( loadstate )
{
guConfig * Config = ( guConfig * ) guConfig::Get();
LocalMusicExpanded = Config->ReadBool( CONFIG_KEY_MAIN_SOURCES_LOCAL_MUSIC, true, CONFIG_PATH_MAIN_SOURCES );
OnlineMusicExpanded = Config->ReadBool( CONFIG_KEY_MAIN_SOURCES_ONLINE_MUSIC, true, CONFIG_PATH_MAIN_SOURCES );
PortableDeviceExpanded = Config->ReadBool( CONFIG_KEY_MAIN_SOURCES_PORTABLE_DEVICES, true, CONFIG_PATH_MAIN_SOURCES );
ContextExpanded = Config->ReadBool( CONFIG_KEY_MAIN_SOURCES_CONTEXT, true, CONFIG_PATH_MAIN_SOURCES );
}
else
{
LocalMusicExpanded = IsExpanded( m_LocalMusicId );
OnlineMusicExpanded = IsExpanded( m_OnlineMusicId );
PortableDeviceExpanded = IsExpanded( m_PortableDeviceId );
ContextExpanded = IsExpanded( m_ContextId );
}
wxFont BoldFont = GetFont();
BoldFont.SetWeight( wxFONTWEIGHT_BOLD );
wxColour DisableItemColor = wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT );
// Delete all the previous childrens
DeleteChildren( m_LocalMusicId );
DeleteChildren( m_OnlineMusicId );
DeleteChildren( m_PortableDeviceId );
DeleteChildren( m_ContextId );
//
// Online Music Locations
//
CurrentItem = AppendItem( m_OnlineMusicId, _( "Radios" ), 7, -1,
new guLocationItemData( ID_MENU_VIEW_RADIO, ( VisiblePanels & guPANEL_MAIN_RADIOS ) ) );
if( VisiblePanels & guPANEL_MAIN_RADIOS )
SetItemFont( CurrentItem, BoldFont );
CurrentItem = AppendItem( m_OnlineMusicId, _( "Podcasts" ), 3, -1,
new guLocationItemData( ID_MENU_VIEW_PODCASTS, ( VisiblePanels & guPANEL_MAIN_PODCASTS ) ) );
if( VisiblePanels & guPANEL_MAIN_PODCASTS )
SetItemFont( CurrentItem, BoldFont );
CurrentItem = AppendItem( m_PortableDeviceId, _( "Audio CD" ), GetIconIndex( "media-cdrom-audio" ), -1,
new guLocationItemData( ID_MENU_VIEW_AUDIOCD, ( VisiblePanels & guPANEL_MAIN_AUDIOCD ) ) );
if( VisiblePanels & guPANEL_MAIN_AUDIOCD )
SetItemFont( CurrentItem, BoldFont );
const guMediaCollectionArray & Collections = m_MainFrame->GetMediaCollections();
int Count = Collections.Count();
int CollectionBaseCommand = ID_COLLECTIONS_BASE;
for( int Index = 0; Index < Count; Index++ )
{
guMediaCollection &Collection = Collections[ Index ];
bool IsActive = m_MainFrame->IsCollectionActive( Collection.m_UniqueId );
bool IsPresent = true;
switch( Collection.m_Type )
{
case guMEDIA_COLLECTION_TYPE_NORMAL :
{
CurrentItem = AppendItem( m_LocalMusicId, Collection.m_Name, -1, -1,
new guLocationItemData( CollectionBaseCommand, IsActive, Collection.m_UniqueId, guMEDIA_COLLECTION_TYPE_NORMAL ) );
break;
}
case guMEDIA_COLLECTION_TYPE_JAMENDO :
{
CurrentItem = AppendItem( m_OnlineMusicId, wxT( "Jamendo" ), 5, -1,
new guLocationItemData( CollectionBaseCommand, IsActive, Collection.m_UniqueId, guMEDIA_COLLECTION_TYPE_JAMENDO ) );
break;
}
case guMEDIA_COLLECTION_TYPE_MAGNATUNE :
{
CurrentItem = AppendItem( m_OnlineMusicId, wxT( "Magnatune" ), 4, -1,
new guLocationItemData( CollectionBaseCommand, IsActive, Collection.m_UniqueId, guMEDIA_COLLECTION_TYPE_MAGNATUNE ) );
break;
}
case guMEDIA_COLLECTION_TYPE_PORTABLE_DEVICE :
case guMEDIA_COLLECTION_TYPE_IPOD :
{
IsPresent = m_MainFrame->IsCollectionPresent( Collection.m_UniqueId );
CurrentItem = AppendItem( m_PortableDeviceId, Collection.m_Name,
GetIconIndex( m_MainFrame->GetCollectionIconString( Collection.m_UniqueId ) ), -1,
new guLocationItemData( CollectionBaseCommand, IsActive && IsPresent, Collection.m_UniqueId, Collection.m_Type,
IsPresent ) );
break;
}
}
if( IsActive )
{
SetItemFont( CurrentItem, BoldFont );
}
else if( !IsPresent )
{
SetItemTextColour( CurrentItem, DisableItemColor );
}
CollectionBaseCommand += guCOLLECTION_ACTION_COUNT;
}
CurrentItem = AppendItem( m_LocalMusicId, _( "File Browser" ), -1, -1,
new guLocationItemData( ID_MENU_VIEW_FILEBROWSER, ( VisiblePanels & guPANEL_MAIN_FILEBROWSER ) ) );
if( VisiblePanels & guPANEL_MAIN_FILEBROWSER )
SetItemFont( CurrentItem, BoldFont );
//
// Context Locations
//
CurrentItem = AppendItem( m_ContextId, wxT( "Last.fm" ), 6, -1, new guLocationItemData( ID_MENU_VIEW_LASTFM, ( VisiblePanels & guPANEL_MAIN_LASTFM ) ) );
if( VisiblePanels & guPANEL_MAIN_LASTFM )
SetItemFont( CurrentItem, BoldFont );
CurrentItem = AppendItem( m_ContextId, _( "Lyrics" ), 8, -1, new guLocationItemData( ID_MENU_VIEW_LYRICS, ( VisiblePanels & guPANEL_MAIN_LYRICS ) ) );
if( VisiblePanels & guPANEL_MAIN_LYRICS )
SetItemFont( CurrentItem, BoldFont );
//
//
if( LocalMusicExpanded )
Expand( m_LocalMusicId );
if( OnlineMusicExpanded )
Expand( m_OnlineMusicId );
if( PortableDeviceExpanded )
Expand( m_PortableDeviceId );
if( ContextExpanded )
Expand( m_ContextId );
}
// -------------------------------------------------------------------------------- //
void CreateMenuRadio( wxMenu * menu, const int visiblepanels, guRadioPanel * radiopanel )
{
wxMenuItem * MenuItem;
MenuItem = new wxMenuItem( menu, ID_MENU_VIEW_RADIO,
wxString( _( "Show" ) ) + guAccelGetCommandKeyCodeString( ID_MENU_VIEW_RADIO ),
_( "Show/Hide the radio panel" ), wxITEM_CHECK );
menu->Append( MenuItem );
MenuItem->Check( visiblepanels & guPANEL_MAIN_RADIOS );
menu->AppendSeparator();
MenuItem = new wxMenuItem( menu, ID_MENU_VIEW_RAD_TEXTSEARCH, _( "Text Search" ), _( "Show/Hide the radio text search" ), wxITEM_CHECK );
menu->Append( MenuItem );
MenuItem->Check( radiopanel && radiopanel->IsPanelShown( guPANEL_RADIO_TEXTSEARCH ) );
MenuItem->Enable( visiblepanels & guPANEL_MAIN_RADIOS );
// MenuItem = new wxMenuItem( menu, ID_MENU_VIEW_RAD_LABELS, _( "Labels" ), _( "Show/Hide the radio labels" ), wxITEM_CHECK );
// menu->Append( MenuItem );
// MenuItem->Check( radiopanel && radiopanel->IsPanelShown( guPANEL_RADIO_LABELS ) );
// MenuItem->Enable( visiblepanels & guPANEL_MAIN_RADIOS );
MenuItem = new wxMenuItem( menu, ID_MENU_VIEW_RAD_GENRES, _( "Genres" ), _( "Show/Hide the radio genres" ), wxITEM_CHECK );
menu->Append( MenuItem );
MenuItem->Check( radiopanel && radiopanel->IsPanelShown( guPANEL_RADIO_GENRES ) );
MenuItem->Enable( visiblepanels & guPANEL_MAIN_RADIOS );
menu->AppendSeparator();
MenuItem = new wxMenuItem( menu, ID_RADIO_DOUPDATE, _( "Update" ), _( "Update the radio station lists" ) );
menu->Append( MenuItem );
MenuItem->Enable( visiblepanels & guPANEL_MAIN_RADIOS );
menu->AppendSeparator();
MenuItem = new wxMenuItem( menu, ID_MENU_VIEW_RAD_PROPERTIES,
_( "Properties" ),
_( "Set the radio preferences" ), wxITEM_NORMAL );
menu->Append( MenuItem );
}
// -------------------------------------------------------------------------------- //
void CreateMenuPodcasts( wxMenu * menu, const int visiblepanels, guPodcastPanel * podcastpanel )
{
wxMenuItem * MenuItem;
MenuItem = new wxMenuItem( menu, ID_MENU_VIEW_PODCASTS,
wxString( _( "Show" ) ) + guAccelGetCommandKeyCodeString( ID_MENU_VIEW_PODCASTS ),
_( "Show/Hide the podcasts panel" ), wxITEM_CHECK );
menu->Append( MenuItem );
MenuItem->Check( visiblepanels & guPANEL_MAIN_PODCASTS );
menu->AppendSeparator();
MenuItem = new wxMenuItem( menu, ID_MENU_VIEW_POD_CHANNELS, _( "Channels" ), _( "Show/Hide the podcasts channels" ), wxITEM_CHECK );
menu->Append( MenuItem );
MenuItem->Check( podcastpanel && podcastpanel->IsPanelShown( guPANEL_PODCASTS_CHANNELS ) );
MenuItem->Enable( visiblepanels & guPANEL_MAIN_PODCASTS );
MenuItem = new wxMenuItem( menu, ID_MENU_VIEW_POD_DETAILS, _( "Details" ), _( "Show/Hide the podcasts details" ), wxITEM_CHECK );
menu->Append( MenuItem );
MenuItem->Check( podcastpanel && podcastpanel->IsPanelShown( guPANEL_PODCASTS_DETAILS ) );
MenuItem->Enable( visiblepanels & guPANEL_MAIN_PODCASTS );
menu->AppendSeparator();
MenuItem = new wxMenuItem( menu, ID_MENU_UPDATE_PODCASTS,
wxString( _( "Update" ) ) + guAccelGetCommandKeyCodeString( ID_MENU_UPDATE_PODCASTS ),
_( "Update the podcasts added" ), wxITEM_NORMAL );
menu->Append( MenuItem );
MenuItem->Enable( visiblepanels & guPANEL_MAIN_PODCASTS );
menu->AppendSeparator();
MenuItem = new wxMenuItem( menu, ID_MENU_VIEW_POD_PROPERTIES,
_( "Properties" ),
_( "Set the podcasts preferences" ), wxITEM_NORMAL );
menu->Append( MenuItem );
MenuItem->Enable( visiblepanels & guPANEL_MAIN_PODCASTS );
}
// -------------------------------------------------------------------------------- //
void CreateMenuCollection( wxMenu * menu, const wxString &uniqueid, const int collectiontype,
guMediaViewer * mediaviewer, const bool ispresent, const int basecommand )
{
int ViewMode = mediaviewer ? mediaviewer->GetViewMode() : guMEDIAVIEWER_MODE_NONE;
bool IsEnabled = ( ViewMode != guMEDIAVIEWER_MODE_NONE );
int VisiblePanels = 0;
if( ViewMode == guMEDIAVIEWER_MODE_LIBRARY )
{
VisiblePanels = mediaviewer->GetLibPanel()->VisiblePanels();
}
wxMenuItem * MenuItem = new wxMenuItem( menu, basecommand, _( "Show" ), _( "Open the music collection" ), wxITEM_CHECK );
menu->Append( MenuItem );
MenuItem->Check( IsEnabled );
MenuItem->Enable( ispresent );
menu->AppendSeparator();
if( IsEnabled )
{
//
//
wxMenu * SubMenu = new wxMenu();
MenuItem = new wxMenuItem( SubMenu, basecommand + guCOLLECTION_ACTION_VIEW_LIBRARY, _( "Show" ), _( "View the collection library" ), wxITEM_CHECK );
SubMenu->Append( MenuItem );
//MenuItem->Enable( IsEnabled );
MenuItem->Check( ViewMode == guMEDIAVIEWER_MODE_LIBRARY );
SubMenu->AppendSeparator();
MenuItem = new wxMenuItem( SubMenu, basecommand + guCOLLECTION_ACTION_VIEW_LIB_LABELS, _( "Labels" ), _( "View the library labels" ), wxITEM_CHECK );
SubMenu->Append( MenuItem );
MenuItem->Enable( ViewMode == guMEDIAVIEWER_MODE_LIBRARY );
MenuItem->Check( VisiblePanels & guPANEL_LIBRARY_LABELS );
MenuItem = new wxMenuItem( SubMenu, basecommand + guCOLLECTION_ACTION_VIEW_LIB_GENRES, _( "Genres" ), _( "View the library genres" ), wxITEM_CHECK );
SubMenu->Append( MenuItem );
MenuItem->Enable( ViewMode == guMEDIAVIEWER_MODE_LIBRARY );
MenuItem->Check( VisiblePanels & guPANEL_LIBRARY_GENRES );
MenuItem = new wxMenuItem( SubMenu, basecommand + guCOLLECTION_ACTION_VIEW_LIB_ARTISTS, _( "Artists" ), _( "View the library artists" ), wxITEM_CHECK );
SubMenu->Append( MenuItem );
MenuItem->Enable( ViewMode == guMEDIAVIEWER_MODE_LIBRARY );
MenuItem->Check( VisiblePanels & guPANEL_LIBRARY_ARTISTS );
MenuItem = new wxMenuItem( SubMenu, basecommand + guCOLLECTION_ACTION_VIEW_LIB_COMPOSERS, _( "Composers" ), _( "View the library composers" ), wxITEM_CHECK );
SubMenu->Append( MenuItem );
MenuItem->Enable( ViewMode == guMEDIAVIEWER_MODE_LIBRARY );
MenuItem->Check( VisiblePanels & guPANEL_LIBRARY_COMPOSERS );
MenuItem = new wxMenuItem( SubMenu, basecommand + guCOLLECTION_ACTION_VIEW_LIB_ALBUMARTISTS, _( "Album Artists" ), _( "View the library album artists" ), wxITEM_CHECK );
SubMenu->Append( MenuItem );
MenuItem->Enable( ViewMode == guMEDIAVIEWER_MODE_LIBRARY );
MenuItem->Check( VisiblePanels & guPANEL_LIBRARY_ALBUMARTISTS );
MenuItem = new wxMenuItem( SubMenu, basecommand + guCOLLECTION_ACTION_VIEW_LIB_ALBUMS, _( "Albums" ), _( "View the library albums" ), wxITEM_CHECK );
SubMenu->Append( MenuItem );
MenuItem->Enable( ViewMode == guMEDIAVIEWER_MODE_LIBRARY );
MenuItem->Check( VisiblePanels & guPANEL_LIBRARY_ALBUMS );
MenuItem = new wxMenuItem( SubMenu, basecommand + guCOLLECTION_ACTION_VIEW_LIB_YEARS, _( "Years" ), _( "View the library years" ), wxITEM_CHECK );
SubMenu->Append( MenuItem );
MenuItem->Enable( ViewMode == guMEDIAVIEWER_MODE_LIBRARY );
MenuItem->Check( VisiblePanels & guPANEL_LIBRARY_YEARS );
MenuItem = new wxMenuItem( SubMenu, basecommand + guCOLLECTION_ACTION_VIEW_LIB_RATINGS, _( "Ratings" ), _( "View the library ratings" ), wxITEM_CHECK );
SubMenu->Append( MenuItem );
MenuItem->Enable( ViewMode == guMEDIAVIEWER_MODE_LIBRARY );
MenuItem->Check( VisiblePanels & guPANEL_LIBRARY_RATINGS );
MenuItem = new wxMenuItem( SubMenu, basecommand + guCOLLECTION_ACTION_VIEW_LIB_PLAYCOUNT, _( "Play Counts" ), _( "View the library play counts" ), wxITEM_CHECK );
SubMenu->Append( MenuItem );
MenuItem->Enable( ViewMode == guMEDIAVIEWER_MODE_LIBRARY );
MenuItem->Check( VisiblePanels & guPANEL_LIBRARY_PLAYCOUNT );
menu->AppendSubMenu( SubMenu, _( "Library" ) );
}
else
{
MenuItem = new wxMenuItem( menu, basecommand + guCOLLECTION_ACTION_VIEW_LIBRARY, _( "Library" ), _( "View the collection library" ), wxITEM_CHECK );
menu->Append( MenuItem );
MenuItem->Enable( false );
MenuItem->Check( ViewMode == guMEDIAVIEWER_MODE_LIBRARY );
}
MenuItem = new wxMenuItem( menu, basecommand + guCOLLECTION_ACTION_VIEW_ALBUMBROWSER, _( "Album Browser" ), _( "View the collection album browser" ), wxITEM_CHECK );
menu->Append( MenuItem );
MenuItem->Enable( IsEnabled );
MenuItem->Check( ViewMode == guMEDIAVIEWER_MODE_ALBUMBROWSER );
MenuItem = new wxMenuItem( menu, basecommand + guCOLLECTION_ACTION_VIEW_TREEVIEW, _( "Tree" ), _( "View the collection tree view" ), wxITEM_CHECK );
menu->Append( MenuItem );
MenuItem->Enable( IsEnabled );
MenuItem->Check( ViewMode == guMEDIAVIEWER_MODE_TREEVIEW );
MenuItem = new wxMenuItem( menu, basecommand + guCOLLECTION_ACTION_VIEW_PLAYLISTS, _( "Playlists" ), _( "View the collection playlists" ), wxITEM_CHECK );
menu->Append( MenuItem );
MenuItem->Enable( IsEnabled );
MenuItem->Check( ViewMode == guMEDIAVIEWER_MODE_PLAYLISTS );
if( ( collectiontype == guMEDIA_COLLECTION_TYPE_NORMAL ) ||
( collectiontype == guMEDIA_COLLECTION_TYPE_PORTABLE_DEVICE ) ||
( collectiontype == guMEDIA_COLLECTION_TYPE_IPOD ) )
{
menu->AppendSeparator();
MenuItem = new wxMenuItem( menu, basecommand + guCOLLECTION_ACTION_ADD_PATH, _( "Add Path" ), _( "Add path to the collection" ), wxITEM_NORMAL );
menu->Append( MenuItem );
MenuItem->Enable( IsEnabled );
MenuItem = new wxMenuItem( menu, basecommand + guCOLLECTION_ACTION_IMPORT, _( "Import Files" ), _( "Import files into the collection" ), wxITEM_NORMAL );
menu->Append( MenuItem );
MenuItem->Enable( IsEnabled );
}
menu->AppendSeparator();
MenuItem = new wxMenuItem( menu, basecommand + guCOLLECTION_ACTION_UPDATE_LIBRARY,
_( "Update" ),
_( "Update the collection library" ), wxITEM_NORMAL );
menu->Append( MenuItem );
MenuItem->Enable( IsEnabled );
MenuItem = new wxMenuItem( menu, basecommand + guCOLLECTION_ACTION_RESCAN_LIBRARY,
_( "Rescan" ),
_( "Rescan the collection library" ), wxITEM_NORMAL );
menu->Append( MenuItem );
MenuItem->Enable( IsEnabled );
MenuItem = new wxMenuItem( menu, basecommand + guCOLLECTION_ACTION_SEARCH_COVERS,
_( "Search Covers" ),
_( "Search the collection missing covers" ), wxITEM_NORMAL );
menu->Append( MenuItem );
MenuItem->Enable( IsEnabled );
if( ( collectiontype == guMEDIA_COLLECTION_TYPE_PORTABLE_DEVICE ) || ( collectiontype == guMEDIA_COLLECTION_TYPE_IPOD ) )
{
menu->AppendSeparator();
MenuItem = new wxMenuItem( menu, basecommand + guCOLLECTION_ACTION_UNMOUNT, _( "Unmount" ), _( "Unmount the device" ) );
menu->Append( MenuItem );
MenuItem->Enable( ispresent );
}
menu->AppendSeparator();
MenuItem = new wxMenuItem( menu, basecommand + guCOLLECTION_ACTION_VIEW_PROPERTIES, _( "Properties" ), _( "Show collection properties" ), wxITEM_NORMAL );
menu->Append( MenuItem );
if( ( collectiontype == guMEDIA_COLLECTION_TYPE_PORTABLE_DEVICE ) || ( collectiontype == guMEDIA_COLLECTION_TYPE_IPOD ) )
{
MenuItem->Enable( IsEnabled );
}
}
// -------------------------------------------------------------------------------- //
void guLocationTreeCtrl::OnContextMenu( wxTreeEvent &event )
{
wxTreeItemId ItemId = event.GetItem();
guLocationItemData * ItemData = ( guLocationItemData * ) GetItemData( ItemId );
if( ItemData )
{
wxMenu Menu;
switch( ItemData->GetId() )
{
case ID_MENU_VIEW_RADIO :
{
CreateMenuRadio( &Menu, m_MainFrame->VisiblePanels(), m_MainFrame->GetRadioPanel() );
break;
}
case ID_MENU_VIEW_PODCASTS :
{
CreateMenuPodcasts( &Menu, m_MainFrame->VisiblePanels(), m_MainFrame->GetPodcastsPanel() );
break;
}
case ID_MENU_VIEW_LASTFM :
case ID_MENU_VIEW_LYRICS :
case ID_MENU_VIEW_FILEBROWSER :
case ID_MENU_VIEW_AUDIOCD :
{
return;
}
default :
{
wxString CollectionId = ItemData->GetCollectionId();
int CollectionType = ItemData->GetCollectionType();
bool IsPresent = true;
if( ( CollectionType == guMEDIA_COLLECTION_TYPE_PORTABLE_DEVICE ) ||
( CollectionType == guMEDIA_COLLECTION_TYPE_IPOD ) )
{
IsPresent = m_MainFrame->IsCollectionPresent( CollectionId );
}
CreateMenuCollection( &Menu, CollectionId, CollectionType,
m_MainFrame->FindCollectionMediaViewer( CollectionId ),
IsPresent, ItemData->GetId() );
break;
}
}
wxPoint Point = event.GetPoint();
PopupMenu( &Menu, Point );
}
}
//// -------------------------------------------------------------------------------- //
//void guLocationTreeCtrl::OnKeyDown( wxKeyEvent &event )
//{
// event.Skip();
//}
// -------------------------------------------------------------------------------- //
// guLocationPanel
// -------------------------------------------------------------------------------- //
guLocationPanel::guLocationPanel( wxWindow * parent ) :
wxPanel( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL )
{
m_MainFrame = ( guMainFrame * ) parent;
wxBoxSizer * MainSizer = new wxBoxSizer( wxVERTICAL );
m_LocationTreeCtrl = new guLocationTreeCtrl( this, m_MainFrame );
MainSizer->Add( m_LocationTreeCtrl, 1, wxEXPAND, 5 );
SetSizer( MainSizer );
Layout();
MainSizer->Fit( this );
m_LocationTreeCtrl->Bind( wxEVT_TREE_ITEM_ACTIVATED, &guLocationPanel::OnLocationItemActivated, this );
m_LocationTreeCtrl->Bind( wxEVT_TREE_SEL_CHANGED, &guLocationPanel::OnLocationItemChanged, this );
}
// -------------------------------------------------------------------------------- //
guLocationPanel::~guLocationPanel()
{
m_LocationTreeCtrl->Unbind( wxEVT_TREE_ITEM_ACTIVATED, &guLocationPanel::OnLocationItemActivated, this );
m_LocationTreeCtrl->Unbind( wxEVT_TREE_SEL_CHANGED, &guLocationPanel::OnLocationItemChanged, this );
}
// -------------------------------------------------------------------------------- //
void guLocationPanel::CollectionsUpdated( void )
{
m_LocationTreeCtrl->ReloadItems();
}
// -------------------------------------------------------------------------------- //
void guLocationPanel::OnPanelVisibleChanged( void )
{
m_LocationTreeCtrl->ReloadItems();
}
// -------------------------------------------------------------------------------- //
void guLocationPanel::OnLocationItemActivated( wxTreeEvent &event )
{
wxTreeItemId ItemId = event.GetItem();
guLocationItemData * ItemData = ( guLocationItemData * ) m_LocationTreeCtrl->GetItemData( ItemId );
if( ItemData && ItemData->GetIsEnabled() )
{
wxCommandEvent event( wxEVT_MENU, ItemData->GetId() );
event.SetInt( !ItemData->GetOpen() );
wxPostEvent( m_MainFrame, event );
}
else
event.Skip();
}
// -------------------------------------------------------------------------------- //
void guLocationPanel::OnLocationItemChanged( wxTreeEvent &event )
{
wxTreeItemId ItemId = event.GetItem();
guLocationItemData * ItemData = ( guLocationItemData * ) m_LocationTreeCtrl->GetItemData( ItemId );
if( ItemData )
{
if( ItemData->GetOpen() && ItemData->GetId() )
{
wxCommandEvent event( wxEVT_MENU, ID_MAINFRAME_SELECT_LOCATION );
event.SetInt( ItemData->GetId() );
wxPostEvent( m_MainFrame, event );
}
}
event.Skip();
}
}
// -------------------------------------------------------------------------------- //
| 29,370
|
C++
|
.cpp
| 563
| 43.939609
| 177
| 0.599156
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,652
|
TrackEdit.cpp
|
anonbeat_guayadeque/src/ui/trackedit/TrackEdit.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "TrackEdit.h"
#include "EventCommandIds.h"
#include "Config.h"
#include "CoverEdit.h"
#include "Images.h"
#include "LastFM.h"
#include "MainFrame.h"
#include "Utils.h"
#include "wx/datetime.h"
#include <wx/notebook.h>
#include <wx/regex.h>
namespace Guayadeque {
#define guTRACKEDIT_TIMER_SELECTION_ID 10
#define guTRACKEDIT_TIMER_SELECTION_TIME 50
#define guTRACKEDIT_TIMER_TEXTCHANGED_TIME 500
#define guTRACKEDIT_TIMER_ARTIST_ID 11
#define guTRACKEDIT_TIMER_ALBUMARTIST_ID 12
#define guTRACKEDIT_TIMER_ALBUM_ID 13
#define guTRACKEDIT_TIMER_COMPOSER_ID 14
#define guTRACKEDIT_TIMER_GENRE_ID 15
const wxEventType guTrackEditEvent = wxNewEventType();
// -------------------------------------------------------------------------------- //
void guImagePtrArrayClean( guImagePtrArray * images )
{
int Count;
if( images && ( Count = images->Count() ) )
{
for( int Index = 0; Index < Count; Index++ )
{
if( ( * images )[ Index ] )
{
delete ( * images )[ Index ];
( * images )[ Index ] = NULL;
}
}
}
}
// -------------------------------------------------------------------------------- //
guTrackEditor::guTrackEditor( wxWindow * parent, guDbLibrary * db, guTrackArray * songs,
guImagePtrArray * images, wxArrayString * lyrics, wxArrayInt * changedflags ) :
m_SelectedTimer( this, guTRACKEDIT_TIMER_SELECTION_ID ),
m_ArtistChangedTimer( this, guTRACKEDIT_TIMER_ARTIST_ID ),
m_AlbumArtistChangedTimer( this, guTRACKEDIT_TIMER_ALBUMARTIST_ID ),
m_AlbumChangedTimer( this, guTRACKEDIT_TIMER_ALBUM_ID ),
m_ComposerChangedTimer( this, guTRACKEDIT_TIMER_COMPOSER_ID ),
m_GenreChangedTimer( this, guTRACKEDIT_TIMER_GENRE_ID )
{
m_Db = db;
wxPanel * SongListPanel;
wxStaticText * ArStaticText;
wxStaticText * AlStaticText;
wxStaticText * TiStaticText;
wxStaticText * NuStaticText;
wxStaticText * GeStaticText;
wxStaticText * YeStaticText;
wxPanel * PicturePanel;
wxPanel * MBrainzPanel;
wxStaticText * MBAlbumStaticText;
wxStaticLine * MBrainzStaticLine;
m_LyricSearchEngine = NULL;
m_LyricSearchContext = NULL;
m_GetComboDataThread = NULL;
guConfig * Config = ( guConfig * ) guConfig::Get();
wxPoint WindowPos;
WindowPos.x = Config->ReadNum( CONFIG_KEY_POSITIONS_TRACKEDIT_POSX, -1, CONFIG_PATH_POSITIONS );
WindowPos.y = Config->ReadNum( CONFIG_KEY_POSITIONS_TRACKEDIT_POSY, -1, CONFIG_PATH_POSITIONS );
wxSize WindowSize;
WindowSize.x = Config->ReadNum( CONFIG_KEY_POSITIONS_TRACKEDIT_WIDTH, 625, CONFIG_PATH_POSITIONS );
WindowSize.y = Config->ReadNum( CONFIG_KEY_POSITIONS_TRACKEDIT_HEIGHT, 440, CONFIG_PATH_POSITIONS );
//wxDialog( parent, wxID_ANY, _( "Songs Editor" ), wxDefaultPosition, wxSize( 625, 440 ), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
Create( parent, wxID_ANY, _( "Songs Editor" ), WindowPos, WindowSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX );
// this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer * MainSizer = new wxBoxSizer( wxVERTICAL );
m_SongListSplitter = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D );
m_SongListSplitter->SetMinimumPaneSize( 150 );
SongListPanel = new wxPanel( m_SongListSplitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer * SongsMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer * SongListSizer = new wxStaticBoxSizer( new wxStaticBox( SongListPanel, wxID_ANY, _( " Songs " ) ), wxHORIZONTAL );
m_SongListBox = new wxListBox( SongListPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE );
SongListSizer->Add( m_SongListBox, 1, wxALL|wxEXPAND, 2 );
wxBoxSizer * OrderSizer = new wxBoxSizer( wxVERTICAL );
m_MoveUpButton = new wxBitmapButton( SongListPanel, wxID_ANY, guImage( guIMAGE_INDEX_up ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_MoveUpButton->SetToolTip( _( "Move the track to the previous position" ) );
m_MoveUpButton->Enable( false );
OrderSizer->Add( m_MoveUpButton, 0, wxALL, 2 );
m_MoveDownButton = new wxBitmapButton( SongListPanel, wxID_ANY, guImage( guIMAGE_INDEX_down ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_MoveUpButton->SetToolTip( _( "Move the track to the next position" ) );
m_MoveDownButton->Enable( false );
OrderSizer->Add( m_MoveDownButton, 0, wxALL, 2 );
SongListSizer->Add( OrderSizer, 0, wxEXPAND, 5 );
SongsMainSizer->Add( SongListSizer, 1, wxEXPAND|wxALL, 5 );
SongListPanel->SetSizer( SongsMainSizer );
SongListPanel->Layout();
SongListSizer->Fit( SongListPanel );
//MainDetailPanel = new wxPanel( m_SongListSplitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxScrolledWindow * MainDetailPanel = new wxScrolledWindow( m_SongListSplitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer * DetailSizer = new wxBoxSizer( wxVERTICAL );
m_MainNotebook = new wxNotebook( MainDetailPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
//
// Details
//
wxPanel * DetailPanel = new wxPanel( m_MainNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxSizer * MainDetailSizer = new wxBoxSizer( wxVERTICAL );
wxFlexGridSizer * DataFlexSizer = new wxFlexGridSizer( 3, 0, 0 );
DataFlexSizer->AddGrowableCol( 2 );
DataFlexSizer->SetFlexibleDirection( wxBOTH );
DataFlexSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_ArCopyButton = new wxBitmapButton( DetailPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_copy ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_ArCopyButton->SetToolTip( _( "Copy the artist name to all the tracks you are editing" ) );
DataFlexSizer->Add( m_ArCopyButton, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
ArStaticText = new wxStaticText( DetailPanel, wxID_ANY, _( "Artist:" ), wxDefaultPosition, wxDefaultSize, 0 );
ArStaticText->Wrap( -1 );
DataFlexSizer->Add( ArStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxRIGHT, 5 );
wxArrayString DummyArray;
m_ArtistComboBox = new wxComboBox( DetailPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, DummyArray, wxCB_DROPDOWN );
DataFlexSizer->Add( m_ArtistComboBox, 1, wxEXPAND|wxTOP|wxRIGHT, 5 );
m_AACopyButton = new wxBitmapButton( DetailPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_copy ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_AACopyButton->SetToolTip( _( "Copy the album artist name to all the tracks you are editing" ) );
DataFlexSizer->Add( m_AACopyButton, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
wxStaticText * AAStaticText = new wxStaticText( DetailPanel, wxID_ANY, _( "A. Artist:" ), wxDefaultPosition, wxDefaultSize, 0 );
AAStaticText->SetToolTip( _( "shows the album artist of the track" ) );
AAStaticText->Wrap( -1 );
DataFlexSizer->Add( AAStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxRIGHT, 5 );
m_AlbumArtistComboBox = new wxComboBox( DetailPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, DummyArray, wxCB_DROPDOWN );
DataFlexSizer->Add( m_AlbumArtistComboBox, 1, wxEXPAND|wxTOP|wxRIGHT, 5 );
m_AlCopyButton = new wxBitmapButton( DetailPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_copy ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_AlCopyButton->SetToolTip( _( "Copy the album name to all the tracks you are editing" ) );
DataFlexSizer->Add( m_AlCopyButton, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
AlStaticText = new wxStaticText( DetailPanel, wxID_ANY, _( "Album:" ), wxDefaultPosition, wxDefaultSize, 0 );
AlStaticText->Wrap( -1 );
DataFlexSizer->Add( AlStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxRIGHT, 5 );
m_AlbumComboBox = new wxComboBox( DetailPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, DummyArray, wxCB_DROPDOWN );
DataFlexSizer->Add( m_AlbumComboBox, 1, wxEXPAND|wxTOP|wxRIGHT, 5 );
m_TiCopyButton = new wxBitmapButton( DetailPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_copy ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_TiCopyButton->SetToolTip( _( "Copy the title to all the tracks you are editing" ) );
DataFlexSizer->Add( m_TiCopyButton, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
TiStaticText = new wxStaticText( DetailPanel, wxID_ANY, _( "Title:" ), wxDefaultPosition, wxDefaultSize, 0 );
TiStaticText->Wrap( -1 );
DataFlexSizer->Add( TiStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxRIGHT, 5 );
m_TitleTextCtrl = new wxTextCtrl( DetailPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
DataFlexSizer->Add( m_TitleTextCtrl, 0, wxEXPAND|wxTOP|wxRIGHT, 5 );
m_CoCopyButton = new wxBitmapButton( DetailPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_copy ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_CoCopyButton->SetToolTip( _( "Copy the composer to all the tracks you are editing" ) );
DataFlexSizer->Add( m_CoCopyButton, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxStaticText * CoStaticText;
CoStaticText = new wxStaticText( DetailPanel, wxID_ANY, _( "Composer:" ), wxDefaultPosition, wxDefaultSize, 0 );
CoStaticText->Wrap( -1 );
DataFlexSizer->Add( CoStaticText, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
m_CompComboBox = new wxComboBox( DetailPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, DummyArray, wxCB_DROPDOWN );
DataFlexSizer->Add( m_CompComboBox, 1, wxEXPAND|wxTOP|wxRIGHT, 5 );
m_CommentCopyButton = new wxBitmapButton( DetailPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_copy ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_CommentCopyButton->SetToolTip( _( "Copy the comment to all the tracks you are editing" ) );
DataFlexSizer->Add( m_CommentCopyButton, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
wxStaticText * CommentStaticText;
CommentStaticText = new wxStaticText( DetailPanel, wxID_ANY, _( "Comment:" ), wxDefaultPosition, wxDefaultSize, 0 );
CommentStaticText->Wrap( -1 );
DataFlexSizer->Add( CommentStaticText, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
m_CommentText = new wxTextCtrl( DetailPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1, 54 ), wxTE_MULTILINE );
DataFlexSizer->Add( m_CommentText, 1, wxEXPAND|wxTOP|wxRIGHT, 5 );
m_NuCopyButton = new wxBitmapButton( DetailPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_copy ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_NuCopyButton->SetToolTip( _( "Copy the number to all the tracks you are editing" ) );
DataFlexSizer->Add( m_NuCopyButton, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
NuStaticText = new wxStaticText( DetailPanel, wxID_ANY, _( "Number:" ), wxDefaultPosition, wxDefaultSize, 0 );
NuStaticText->Wrap( -1 );
DataFlexSizer->Add( NuStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxRIGHT, 5 );
// m_NumberTextCtrl = new wxTextCtrl( DetailPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
// DataFlexSizer->Add( m_NumberTextCtrl, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 );
wxBoxSizer* DiskSizer;
DiskSizer = new wxBoxSizer( wxHORIZONTAL );
m_NumberTextCtrl = new wxTextCtrl( DetailPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
DiskSizer->Add( m_NumberTextCtrl, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 5 );
m_NuOrderButton= new wxBitmapButton( DetailPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_numerate ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_NuOrderButton->SetToolTip( _( "Enumerate the tracks in the order they were added for editing" ) );
DiskSizer->Add( m_NuOrderButton, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 );
DiskSizer->Add( 0, 0, 1, wxEXPAND, 5 );
m_DiCopyButton = new wxBitmapButton( DetailPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_copy ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_DiCopyButton->SetToolTip( _( "Copy the disk to all the tracks you are editing" ) );
DiskSizer->Add( m_DiCopyButton, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
wxStaticText * DiStaticText;
DiStaticText = new wxStaticText( DetailPanel, wxID_ANY, _("Disk:"), wxDefaultPosition, wxDefaultSize, 0 );
DiStaticText->Wrap( -1 );
DiskSizer->Add( DiStaticText, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 );
m_DiskTextCtrl = new wxTextCtrl( DetailPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
DiskSizer->Add( m_DiskTextCtrl, 0, wxTOP|wxRIGHT, 5 );
DataFlexSizer->Add( DiskSizer, 1, wxEXPAND, 5 );
m_GeCopyButton = new wxBitmapButton( DetailPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_copy ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_GeCopyButton->SetToolTip( _( "Copy the genre name to all songs you are editing" ) );
DataFlexSizer->Add( m_GeCopyButton, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
GeStaticText = new wxStaticText( DetailPanel, wxID_ANY, _( "Genre:" ), wxDefaultPosition, wxDefaultSize, 0 );
GeStaticText->Wrap( -1 );
DataFlexSizer->Add( GeStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxRIGHT, 5 );
m_GenreComboBox = new wxComboBox( DetailPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, DummyArray, wxCB_DROPDOWN );
DataFlexSizer->Add( m_GenreComboBox, 1, wxEXPAND|wxTOP|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_YeCopyButton = new wxBitmapButton( DetailPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_copy ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_YeCopyButton->SetToolTip( _( "Copy the year to all songs you are editing" ) );
DataFlexSizer->Add( m_YeCopyButton, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
YeStaticText = new wxStaticText( DetailPanel, wxID_ANY, _( "Year:" ), wxDefaultPosition, wxDefaultSize, 0 );
YeStaticText->Wrap( -1 );
DataFlexSizer->Add( YeStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxRIGHT, 5 );
wxBoxSizer * RatingSizer;
RatingSizer = new wxBoxSizer( wxHORIZONTAL );
m_YearTextCtrl = new wxTextCtrl( DetailPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
RatingSizer->Add( m_YearTextCtrl, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
RatingSizer->Add( 0, 0, 1, wxEXPAND, 5 );
m_RaCopyButton = new wxBitmapButton( DetailPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_copy ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
RatingSizer->Add( m_RaCopyButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxStaticText * RaStaticText;
RaStaticText = new wxStaticText( DetailPanel, wxID_ANY, _("Rating:"), wxDefaultPosition, wxDefaultSize, 0 );
RaStaticText->Wrap( -1 );
RatingSizer->Add( RaStaticText, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_Rating = new guRating( DetailPanel, GURATING_STYLE_BIG );
RatingSizer->Add( m_Rating, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
DataFlexSizer->Add( RatingSizer, 1, wxEXPAND, 5 );
MainDetailSizer->Add( DataFlexSizer, 0, wxEXPAND, 5 );
wxBoxSizer* MoreDetailsSizer;
MoreDetailsSizer = new wxBoxSizer( wxHORIZONTAL );
m_DetailLeftInfoStaticText = new wxStaticText( DetailPanel, wxID_ANY, wxT("File Type\t:\nLength\t:"), wxDefaultPosition, wxDefaultSize, 0 );
m_DetailLeftInfoStaticText->Wrap( -1 );
MoreDetailsSizer->Add( m_DetailLeftInfoStaticText, 1, wxALL|wxEXPAND, 5 );
m_DetailRightInfoStaticText = new wxStaticText( DetailPanel, wxID_ANY, wxT("BitRate\t:\nFileSize\t:"), wxDefaultPosition, wxDefaultSize, 0 );
m_DetailRightInfoStaticText->Wrap( -1 );
MoreDetailsSizer->Add( m_DetailRightInfoStaticText, 1, wxALL|wxEXPAND, 5 );
MainDetailSizer->Add( MoreDetailsSizer, 1, wxEXPAND, 5 );
DetailPanel->SetSizer( MainDetailSizer );
DetailPanel->Layout();
DataFlexSizer->Fit( DetailPanel );
m_MainNotebook->AddPage( DetailPanel, _( "Details" ), true );
//
// Pictures
//
PicturePanel = new wxPanel( m_MainNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* PictureSizer;
PictureSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* PictureBitmapSizer;
PictureBitmapSizer = new wxStaticBoxSizer( new wxStaticBox( PicturePanel, wxID_ANY, wxEmptyString ), wxVERTICAL );
m_PictureBitmap = new wxStaticBitmap( PicturePanel, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 250,250 ), wxSUNKEN_BORDER );
PictureBitmapSizer->Add( m_PictureBitmap, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
PictureSizer->Add( PictureBitmapSizer, 0, wxALIGN_CENTER_HORIZONTAL, 5 );
wxBoxSizer* PictureButtonSizer;
PictureButtonSizer = new wxBoxSizer( wxHORIZONTAL );
m_AddPicButton = new wxBitmapButton( PicturePanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_add ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_AddPicButton->SetToolTip( _( "Add a picture from file to the current track" ) );
PictureButtonSizer->Add( m_AddPicButton, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_DelPicButton = new wxBitmapButton( PicturePanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_del ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_DelPicButton->SetToolTip( _( "Delete the picture from the current track" ) );
PictureButtonSizer->Add( m_DelPicButton, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_SavePicButton = new wxBitmapButton( PicturePanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_doc_save ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_SavePicButton->SetToolTip( _( "Save the current picture to file" ) );
PictureButtonSizer->Add( m_SavePicButton, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_SearchPicButton = new wxBitmapButton( PicturePanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_search ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_SearchPicButton->SetToolTip( _( "Search the album cover" ) );
PictureButtonSizer->Add( m_SearchPicButton, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
// m_EditPicButton = new wxBitmapButton( PicturePanel, wxID_ANY, guImage( guIMAGE_INDEX_edit ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
// PictureButtonSizer->Add( m_EditPicButton, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
PictureButtonSizer->Add( 10, 0, 0, wxEXPAND, 5 );
m_CopyPicButton = new wxBitmapButton( PicturePanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_copy ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_CopyPicButton->SetToolTip( _( "Copy the current picture to all the tracks you are editing" ) );
PictureButtonSizer->Add( m_CopyPicButton, 0, wxALL, 5 );
PictureSizer->Add( PictureButtonSizer, 0, wxALIGN_CENTER_HORIZONTAL, 5 );
PicturePanel->SetSizer( PictureSizer );
PicturePanel->Layout();
PictureSizer->Fit( PicturePanel );
m_MainNotebook->AddPage( PicturePanel, _( "Pictures" ), false );
//
// Lyrics
//
wxPanel * LyricsPanel = new wxPanel( m_MainNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer * LyricsSizer;
LyricsSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* LyricsTopSizer;
LyricsTopSizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticText * ArtistStaticText = new wxStaticText( LyricsPanel, wxID_ANY, _( "Artist:" ), wxDefaultPosition, wxDefaultSize, 0 );
ArtistStaticText->Wrap( -1 );
LyricsTopSizer->Add( ArtistStaticText, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT, 5 );
m_LyricArtistTextCtrl = new wxTextCtrl( LyricsPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
LyricsTopSizer->Add( m_LyricArtistTextCtrl, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 );
wxStaticText * TrackStaticText = new wxStaticText( LyricsPanel, wxID_ANY, _( "Track:" ), wxDefaultPosition, wxDefaultSize, 0 );
TrackStaticText->Wrap( -1 );
LyricsTopSizer->Add( TrackStaticText, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT, 5 );
m_LyricTrackTextCtrl = new wxTextCtrl( LyricsPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
LyricsTopSizer->Add( m_LyricTrackTextCtrl, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 );
m_LyricReloadButton = new wxBitmapButton( LyricsPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_search_again ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LyricReloadButton->SetToolTip( _( "Search for lyrics" ) );
LyricsTopSizer->Add( m_LyricReloadButton, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
LyricsSizer->Add( LyricsTopSizer, 0, wxEXPAND, 5 );
m_LyricsTextCtrl = new wxTextCtrl( LyricsPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CENTRE|wxTE_DONTWRAP|wxTE_MULTILINE );
LyricsSizer->Add( m_LyricsTextCtrl, 1, wxALL|wxEXPAND, 5 );
LyricsPanel->SetSizer( LyricsSizer );
LyricsPanel->Layout();
LyricsSizer->Fit( LyricsPanel );
m_MainNotebook->AddPage( LyricsPanel, _( "Lyrics" ), false );
//
// MusicBrainz
//
MBrainzPanel = new wxPanel( m_MainNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* MBrainzSizer;
MBrainzSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* MBQuerySizer;
MBQuerySizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticText * MBQueryArtistStaticText;
wxStaticText * MBQueryTitleStaticText;
MBQueryArtistStaticText = new wxStaticText( MBrainzPanel, wxID_ANY, _("Artist:"), wxDefaultPosition, wxDefaultSize, 0 );
MBQueryArtistStaticText->Wrap( -1 );
MBQuerySizer->Add( MBQueryArtistStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_MBQueryArtistTextCtrl = new wxTextCtrl( MBrainzPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_MBQueryArtistTextCtrl->SetToolTip( _( "Type the artist name to search in musicbrainz" ) );
MBQuerySizer->Add( m_MBQueryArtistTextCtrl, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
MBQueryTitleStaticText = new wxStaticText( MBrainzPanel, wxID_ANY, _("Title:"), wxDefaultPosition, wxDefaultSize, 0 );
MBQueryTitleStaticText->Wrap( -1 );
MBQuerySizer->Add( MBQueryTitleStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_MBQueryTitleTextCtrl = new wxTextCtrl( MBrainzPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_MBQueryTitleTextCtrl->SetToolTip( _( "Type the album name to search in musicbrainz" ) );
MBQuerySizer->Add( m_MBQueryTitleTextCtrl, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_MBQueryClearButton = new wxBitmapButton( MBrainzPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_clear ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_MBQueryClearButton->SetToolTip( _( "Clear the search fields so it search using the music fingerprint" ) );
MBQuerySizer->Add( m_MBQueryClearButton, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 );
MBrainzSizer->Add( MBQuerySizer, 0, wxEXPAND, 5 );
wxBoxSizer* MBrainzTopSizer;
MBrainzTopSizer = new wxBoxSizer( wxHORIZONTAL );
MBAlbumStaticText = new wxStaticText( MBrainzPanel, wxID_ANY, _( "Album:" ), wxDefaultPosition, wxDefaultSize, 0 );
MBAlbumStaticText->Wrap( -1 );
MBrainzTopSizer->Add( MBAlbumStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxArrayString m_MBAlbumChoiceChoices;
m_MBAlbumChoice = new wxChoice( MBrainzPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_MBAlbumChoiceChoices, 0 );
m_MBAlbumChoice->SetToolTip( _( "Select the album found in musicbrainz" ) );
m_MBAlbumChoice->SetSelection( 0 );
MBrainzTopSizer->Add( m_MBAlbumChoice, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_MBAddButton = new wxBitmapButton( MBrainzPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_search ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_MBAddButton->SetToolTip( _( "Search albums in musicbrainz" ) );
//m_MBAddButton->Enable( false );
MBrainzTopSizer->Add( m_MBAddButton, 0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_MBCopyButton = new wxBitmapButton( MBrainzPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_copy ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_MBCopyButton->SetToolTip( _( "Copy the content of the album to the edited tracks" ) );
m_MBCopyButton->Enable( false );
MBrainzTopSizer->Add( m_MBCopyButton, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 );
MBrainzSizer->Add( MBrainzTopSizer, 0, wxEXPAND, 5 );
wxStaticBoxSizer* MBDetailSizer;
MBDetailSizer = new wxStaticBoxSizer( new wxStaticBox( MBrainzPanel, wxID_ANY, _( " Details " ) ), wxVERTICAL );
wxFlexGridSizer* MBDetailFlexGridSizer;
MBDetailFlexGridSizer = new wxFlexGridSizer( 3, 0, 0 );
MBDetailFlexGridSizer->AddGrowableCol( 1 );
MBDetailFlexGridSizer->SetFlexibleDirection( wxBOTH );
MBDetailFlexGridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_MBArtistStaticText = new wxStaticText( MBrainzPanel, wxID_ANY, _( "Artist:" ), wxDefaultPosition, wxDefaultSize, 0 );
m_MBArtistStaticText->Wrap( -1 );
MBDetailFlexGridSizer->Add( m_MBArtistStaticText, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_MBArtistTextCtrl = new wxTextCtrl( MBrainzPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
MBDetailFlexGridSizer->Add( m_MBArtistTextCtrl, 1, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
m_MBArCopyButton = new wxBitmapButton( MBrainzPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_copy ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_MBArCopyButton->SetToolTip( _( "Copy the artist to the edited tracks" ) );
MBDetailFlexGridSizer->Add( m_MBArCopyButton, 0, wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_MBAlbumArtistStaticText = new wxStaticText( MBrainzPanel, wxID_ANY, _( "A. Artist:" ), wxDefaultPosition, wxDefaultSize, 0 );
m_MBAlbumArtistStaticText->Wrap( -1 );
MBDetailFlexGridSizer->Add( m_MBAlbumArtistStaticText, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_MBAlbumArtistTextCtrl = new wxTextCtrl( MBrainzPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
MBDetailFlexGridSizer->Add( m_MBAlbumArtistTextCtrl, 1, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
m_MBAlArCopyButton = new wxBitmapButton( MBrainzPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_copy ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_MBAlArCopyButton->SetToolTip( _( "Copy the album artist to the edited tracks" ) );
MBDetailFlexGridSizer->Add( m_MBAlArCopyButton, 0, wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_MBAlbumStaticText = new wxStaticText( MBrainzPanel, wxID_ANY, _("Album:"), wxDefaultPosition, wxDefaultSize, 0 );
m_MBAlbumStaticText->Wrap( -1 );
MBDetailFlexGridSizer->Add( m_MBAlbumStaticText, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
m_MBAlbumTextCtrl = new wxTextCtrl( MBrainzPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
MBDetailFlexGridSizer->Add( m_MBAlbumTextCtrl, 1, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
m_MBAlCopyButton = new wxBitmapButton( MBrainzPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_copy ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_MBAlCopyButton->SetToolTip( _( "Copy the album to the edited tracks" ) );
MBDetailFlexGridSizer->Add( m_MBAlCopyButton, 0, wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_MBYearStaticText = new wxStaticText( MBrainzPanel, wxID_ANY, _( "Year:" ), wxDefaultPosition, wxDefaultSize, 0 );
m_MBYearStaticText->Wrap( -1 );
MBDetailFlexGridSizer->Add( m_MBYearStaticText, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
m_MBYearTextCtrl = new wxTextCtrl( MBrainzPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
MBDetailFlexGridSizer->Add( m_MBYearTextCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
m_MBDaCopyButton = new wxBitmapButton( MBrainzPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_copy ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_MBDaCopyButton->SetToolTip( _( "Copy the date to the edited tracks" ) );
MBDetailFlexGridSizer->Add( m_MBDaCopyButton, 0, wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_MBTitleStaticText = new wxStaticText( MBrainzPanel, wxID_ANY, _( "Title:" ), wxDefaultPosition, wxDefaultSize, 0 );
m_MBTitleStaticText->Wrap( -1 );
MBDetailFlexGridSizer->Add( m_MBTitleStaticText, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
m_MBTitleTextCtrl = new wxTextCtrl( MBrainzPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
MBDetailFlexGridSizer->Add( m_MBTitleTextCtrl, 1, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
m_MBTiCopyButton = new wxBitmapButton( MBrainzPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_copy ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_MBTiCopyButton->SetToolTip( _( "Copy the song names to the edited tracks" ) );
MBDetailFlexGridSizer->Add( m_MBTiCopyButton, 0, wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_MBLengthStaticText = new wxStaticText( MBrainzPanel, wxID_ANY, _("Length:"), wxDefaultPosition, wxDefaultSize, 0 );
m_MBLengthStaticText->Wrap( -1 );
MBDetailFlexGridSizer->Add( m_MBLengthStaticText, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
wxBoxSizer* MBNumberSizer;
MBNumberSizer = new wxBoxSizer( wxHORIZONTAL );
m_MBLengthTextCtrl = new wxTextCtrl( MBrainzPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
MBNumberSizer->Add( m_MBLengthTextCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
MBNumberSizer->Add( 0, 0, 1, wxEXPAND, 5 );
m_MBNumberStaticText = new wxStaticText( MBrainzPanel, wxID_ANY, _("Number:"), wxDefaultPosition, wxDefaultSize, 0 );
m_MBNumberStaticText->Wrap( -1 );
MBNumberSizer->Add( m_MBNumberStaticText, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_MBNumberTextCtrl = new wxTextCtrl( MBrainzPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
MBNumberSizer->Add( m_MBNumberTextCtrl, 0, wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
MBDetailFlexGridSizer->Add( MBNumberSizer, 1, wxEXPAND, 5 );
m_MBNuCopyButton = new wxBitmapButton( MBrainzPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_copy ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_MBNuCopyButton->SetToolTip( _( "Copy the number to the edited tracks" ) );
MBDetailFlexGridSizer->Add( m_MBNuCopyButton, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
MBDetailSizer->Add( MBDetailFlexGridSizer, 0, wxEXPAND, 5 );
MBrainzStaticLine = new wxStaticLine( MBrainzPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
MBDetailSizer->Add( MBrainzStaticLine, 0, wxEXPAND | wxALL, 5 );
m_MBInfoStaticText = new wxStaticText( MBrainzPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_NO_AUTORESIZE );
m_MBInfoStaticText->Wrap( 398 );
MBDetailSizer->Add( m_MBInfoStaticText, 1, wxALL|wxEXPAND, 5 );
MBrainzSizer->Add( MBDetailSizer, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
MBrainzPanel->SetSizer( MBrainzSizer );
MBrainzPanel->Layout();
MBrainzSizer->Fit( MBrainzPanel );
m_MainNotebook->AddPage( MBrainzPanel, wxT( "MusicBrainz" ), false );
DetailSizer->Add( m_MainNotebook, 1, wxEXPAND | wxALL, 5 );
MainDetailPanel->SetSizer( DetailSizer );
MainDetailPanel->Layout();
DetailSizer->Fit( MainDetailPanel );
m_SongListSplitter->SplitVertically( SongListPanel, MainDetailPanel, 200 );
MainSizer->Add( m_SongListSplitter, 1, wxEXPAND, 5 );
wxStdDialogButtonSizer * ButtonsSizer;
wxButton * ButtonsSizerOK;
wxButton * ButtonsSizerCancel;
ButtonsSizer = new wxStdDialogButtonSizer();
ButtonsSizerOK = new wxButton( this, wxID_OK );
ButtonsSizer->AddButton( ButtonsSizerOK );
ButtonsSizerCancel = new wxButton( this, wxID_CANCEL );
ButtonsSizer->AddButton( ButtonsSizerCancel );
ButtonsSizer->SetAffirmativeButton( ButtonsSizerOK );
ButtonsSizer->SetCancelButton( ButtonsSizerCancel );
ButtonsSizer->Realize();
MainSizer->Add( ButtonsSizer, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
this->SetSizer( MainSizer );
this->Layout();
MainDetailPanel->SetScrollRate( 20, 20 );
ButtonsSizerOK->SetDefault();
// --------------------------------------------------------------------
m_NormalColor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
m_ErrorColor = wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT );
m_AcousticId = NULL;
m_MBAlbums = NULL;
m_MBCurTrack = 0;
m_MBCurAlbum = wxNOT_FOUND;
m_MBQuerySetArtistEnabled = true;
m_CurItem = 0;
m_NextItem = wxNOT_FOUND;
m_Items = songs;
m_Images = images;
m_Lyrics = lyrics;
m_ChangedFlags = changedflags;
m_CurrentRating = -1;
m_RatingChanged = false;
m_GenreChanged = false;
wxArrayString ItemsText;
// Generate the list of tacks, pictures and lyrics
int count = m_Items->Count();
for( int index = 0; index < count; index++ )
{
ItemsText.Add( ( * m_Items )[ index ].m_FileName );
// Fill the initial Images of the files
m_Images->Add( guTagGetPicture( ( * m_Items )[ index ].m_FileName ) );
m_Lyrics->Add( guTagGetLyrics( ( * m_Items )[ index ].m_FileName ) );
m_ChangedFlags->Add( guTRACK_CHANGED_DATA_NONE );
}
m_SongListBox->InsertItems( ItemsText, 0 );
m_SongListBox->SetFocus();
// Idle Events
m_SongListSplitter->Bind( wxEVT_IDLE, &guTrackEditor::SongListSplitterOnIdle, this );
// Bind Events
Bind( wxEVT_BUTTON, &guTrackEditor::OnOKButton, this, wxID_OK );
m_MainNotebook->Bind( wxEVT_NOTEBOOK_PAGE_CHANGED, &guTrackEditor::OnPageChanged, this );
m_SongListBox->Bind( wxEVT_LISTBOX, &guTrackEditor::OnSongListBoxSelected, this );
m_MoveUpButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnMoveUpBtnClick, this );
m_MoveDownButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnMoveDownBtnClick, this );
m_ArCopyButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnArCopyButtonClicked, this );
m_AACopyButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnAACopyButtonClicked, this );
m_AlCopyButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnAlCopyButtonClicked, this );
m_TiCopyButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnTiCopyButtonClicked, this );
m_CoCopyButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnCoCopyButtonClicked, this );
m_NuCopyButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnNuCopyButtonClicked, this );
m_NuOrderButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnNuOrderButtonClicked, this );
m_DiCopyButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnDiCopyButtonClicked, this );
m_GeCopyButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnGeCopyButtonClicked, this );
m_YeCopyButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnYeCopyButtonClicked, this );
m_RaCopyButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnRaCopyButtonClicked, this );
m_Rating->Bind( guEVT_RATING_CHANGED, &guTrackEditor::OnRatingChanged, this );
m_CommentCopyButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnCommentCopyButtonClicked, this );
m_ArtistComboBox->Bind( wxEVT_TEXT, &guTrackEditor::OnArtistTextChanged, this );
m_AlbumArtistComboBox->Bind( wxEVT_TEXT, &guTrackEditor::OnAlbumArtistTextChanged, this );
m_AlbumComboBox->Bind( wxEVT_TEXT, &guTrackEditor::OnAlbumTextChanged, this );
m_CompComboBox->Bind( wxEVT_TEXT, &guTrackEditor::OnComposerTextChanged, this );
m_GenreComboBox->Bind( wxEVT_TEXT, &guTrackEditor::OnGenreTextChanged, this );
m_AddPicButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnAddImageClicked, this );
m_DelPicButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnDelImageClicked, this );
m_SavePicButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnSaveImageClicked, this );
m_SearchPicButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnSearchImageClicked, this );
m_CopyPicButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnCopyImageClicked, this );
m_LyricReloadButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnSearchLyrics, this );
m_LyricArtistTextCtrl->Bind( wxEVT_TEXT, &guTrackEditor::OnTextUpdated, this );
m_LyricTrackTextCtrl->Bind( wxEVT_TEXT, &guTrackEditor::OnTextUpdated, this );
m_MBQueryArtistTextCtrl->Bind( wxEVT_TEXT, &guTrackEditor::OnMBQueryTextCtrlChanged, this );
m_MBQueryTitleTextCtrl->Bind( wxEVT_TEXT, &guTrackEditor::OnMBQueryTextCtrlChanged, this );
m_MBQueryClearButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnMBQueryClearButtonClicked, this );
m_MBAddButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnMBrainzAddButtonClicked, this );
m_MBAlbumChoice->Bind( wxEVT_CHOICE, &guTrackEditor::OnMBrainzAlbumChoiceSelected, this );
m_MBCopyButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnMBrainzCopyButtonClicked, this );
m_MBArCopyButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnMBrainzArtistCopyButtonClicked, this );
m_MBAlArCopyButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnMBrainzAlbumArtistCopyButtonClicked, this );
m_MBAlCopyButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnMBrainzAlbumCopyButtonClicked, this );
m_MBDaCopyButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnMBrainzYearCopyButtonClicked, this );
m_MBTiCopyButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnMBrainzTitleCopyButtonClicked, this );
m_MBNuCopyButton->Bind( wxEVT_BUTTON, &guTrackEditor::OnMBrainzNumberCopyButtonClicked, this );
Bind( wxEVT_MENU, &guTrackEditor::OnDownloadedLyric, this, ID_LYRICS_LYRICFOUND );
Bind( wxEVT_TIMER, &guTrackEditor::OnSelectTimeout, this, guTRACKEDIT_TIMER_SELECTION_ID );
Bind( wxEVT_TIMER, &guTrackEditor::OnArtistChangedTimeout, this, guTRACKEDIT_TIMER_ARTIST_ID );
Bind( wxEVT_TIMER, &guTrackEditor::OnAlbumArtistChangedTimeout, this, guTRACKEDIT_TIMER_ALBUMARTIST_ID );
Bind( wxEVT_TIMER, &guTrackEditor::OnAlbumChangedTimeout, this, guTRACKEDIT_TIMER_ALBUM_ID );
Bind( wxEVT_TIMER, &guTrackEditor::OnComposerChangedTimeout, this, guTRACKEDIT_TIMER_COMPOSER_ID );
Bind( wxEVT_TIMER, &guTrackEditor::OnGenreChangedTimeout, this, guTRACKEDIT_TIMER_GENRE_ID );
//
// Force the 1st listbox item to be selected
m_SongListBox->SetSelection( 0 );
// wxCommandEvent event( wxEVT_LISTBOX, m_SongListBox->GetId() );
// event.SetEventObject( m_SongListBox );
// event.SetExtraLong( 1 );
// event.SetInt( 0 );
// wxPostEvent( m_SongListBox, event );
m_CurItem = 0;
ReadItemData();
}
// -------------------------------------------------------------------------------- //
guTrackEditor::~guTrackEditor()
{
// Save the window position and size
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->WriteNum( CONFIG_KEY_POSITIONS_TRACKEDIT_SASHPOS, m_SongListSplitter->GetSashPosition(), CONFIG_PATH_POSITIONS );
wxPoint WindowPos = GetPosition();
Config->WriteNum( CONFIG_KEY_POSITIONS_TRACKEDIT_POSX, WindowPos.x, CONFIG_PATH_POSITIONS );
Config->WriteNum( CONFIG_KEY_POSITIONS_TRACKEDIT_POSY, WindowPos.y, CONFIG_PATH_POSITIONS );
wxSize WindowSize = GetSize();
Config->WriteNum( CONFIG_KEY_POSITIONS_TRACKEDIT_WIDTH, WindowSize.x, CONFIG_PATH_POSITIONS );
Config->WriteNum( CONFIG_KEY_POSITIONS_TRACKEDIT_HEIGHT, WindowSize.y, CONFIG_PATH_POSITIONS );
// Unbind Events
Unbind( wxEVT_BUTTON, &guTrackEditor::OnOKButton, this, wxID_OK );
m_MainNotebook->Unbind( wxEVT_NOTEBOOK_PAGE_CHANGED, &guTrackEditor::OnPageChanged, this );
m_SongListBox->Unbind( wxEVT_LISTBOX, &guTrackEditor::OnSongListBoxSelected, this );
m_MoveUpButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnMoveUpBtnClick, this );
m_MoveDownButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnMoveDownBtnClick, this );
m_ArCopyButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnArCopyButtonClicked, this );
m_AACopyButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnAACopyButtonClicked, this );
m_AlCopyButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnAlCopyButtonClicked, this );
m_TiCopyButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnTiCopyButtonClicked, this );
m_CoCopyButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnCoCopyButtonClicked, this );
m_NuCopyButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnNuCopyButtonClicked, this );
m_NuOrderButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnNuOrderButtonClicked, this );
m_DiCopyButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnDiCopyButtonClicked, this );
m_GeCopyButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnGeCopyButtonClicked, this );
m_YeCopyButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnYeCopyButtonClicked, this );
m_RaCopyButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnRaCopyButtonClicked, this );
m_Rating->Unbind( guEVT_RATING_CHANGED, &guTrackEditor::OnRatingChanged, this );
m_CommentCopyButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnCommentCopyButtonClicked, this );
m_ArtistComboBox->Unbind( wxEVT_TEXT, &guTrackEditor::OnArtistTextChanged, this );
m_AlbumArtistComboBox->Unbind( wxEVT_TEXT, &guTrackEditor::OnAlbumArtistTextChanged, this );
m_AlbumComboBox->Unbind( wxEVT_TEXT, &guTrackEditor::OnAlbumTextChanged, this );
m_CompComboBox->Unbind( wxEVT_TEXT, &guTrackEditor::OnComposerTextChanged, this );
m_GenreComboBox->Unbind( wxEVT_TEXT, &guTrackEditor::OnGenreTextChanged, this );
m_AddPicButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnAddImageClicked, this );
m_DelPicButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnDelImageClicked, this );
m_SavePicButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnSaveImageClicked, this );
m_SearchPicButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnSearchImageClicked, this );
m_CopyPicButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnCopyImageClicked, this );
m_LyricReloadButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnSearchLyrics, this );
m_LyricArtistTextCtrl->Unbind( wxEVT_TEXT, &guTrackEditor::OnTextUpdated, this );
m_LyricTrackTextCtrl->Unbind( wxEVT_TEXT, &guTrackEditor::OnTextUpdated, this );
m_MBQueryArtistTextCtrl->Unbind( wxEVT_TEXT, &guTrackEditor::OnMBQueryTextCtrlChanged, this );
m_MBQueryTitleTextCtrl->Unbind( wxEVT_TEXT, &guTrackEditor::OnMBQueryTextCtrlChanged, this );
m_MBQueryClearButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnMBQueryClearButtonClicked, this );
m_MBAddButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnMBrainzAddButtonClicked, this );
m_MBAlbumChoice->Unbind( wxEVT_CHOICE, &guTrackEditor::OnMBrainzAlbumChoiceSelected, this );
m_MBCopyButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnMBrainzCopyButtonClicked, this );
m_MBArCopyButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnMBrainzArtistCopyButtonClicked, this );
m_MBAlArCopyButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnMBrainzAlbumArtistCopyButtonClicked, this );
m_MBAlCopyButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnMBrainzAlbumCopyButtonClicked, this );
m_MBDaCopyButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnMBrainzYearCopyButtonClicked, this );
m_MBTiCopyButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnMBrainzTitleCopyButtonClicked, this );
m_MBNuCopyButton->Unbind( wxEVT_BUTTON, &guTrackEditor::OnMBrainzNumberCopyButtonClicked, this );
Unbind( wxEVT_MENU, &guTrackEditor::OnDownloadedLyric, this, ID_LYRICS_LYRICFOUND );
Unbind( wxEVT_TIMER, &guTrackEditor::OnSelectTimeout, this, guTRACKEDIT_TIMER_SELECTION_ID );
Unbind( wxEVT_TIMER, &guTrackEditor::OnArtistChangedTimeout, this, guTRACKEDIT_TIMER_ARTIST_ID );
Unbind( wxEVT_TIMER, &guTrackEditor::OnAlbumArtistChangedTimeout, this, guTRACKEDIT_TIMER_ALBUMARTIST_ID );
Unbind( wxEVT_TIMER, &guTrackEditor::OnAlbumChangedTimeout, this, guTRACKEDIT_TIMER_ALBUM_ID );
Unbind( wxEVT_TIMER, &guTrackEditor::OnComposerChangedTimeout, this, guTRACKEDIT_TIMER_COMPOSER_ID );
Unbind( wxEVT_TIMER, &guTrackEditor::OnGenreChangedTimeout, this, guTRACKEDIT_TIMER_GENRE_ID );
if( m_GetComboDataThread )
{
m_GetComboDataThread->Pause();
m_GetComboDataThread->Delete();
}
if( m_LyricSearchContext )
delete m_LyricSearchContext;
if( m_AcousticId )
delete m_AcousticId;
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnPageChanged( wxNotebookEvent &event )
{
//WriteItemData();
wxCommandEvent CmdEvent;
CmdEvent.SetInt( m_CurItem );
OnSongListBoxSelected( CmdEvent );
event.Skip();
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnOKButton( wxCommandEvent& event )
{
WriteItemData();
event.Skip();
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnSongListBoxSelected( wxCommandEvent& event )
{
m_NextItem = event.GetInt();
m_SelectedTimer.Start( guTRACKEDIT_TIMER_SELECTION_TIME, wxTIMER_ONE_SHOT );
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnSelectTimeout( wxTimerEvent &event )
{
WriteItemData();
m_CurItem = m_NextItem;
if( m_LyricSearchContext )
{
delete m_LyricSearchContext;
m_LyricSearchContext = NULL;
}
ReadItemData();
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnMoveUpBtnClick( wxCommandEvent &event )
{
wxString FileName = m_SongListBox->GetString( m_CurItem );
guTrack * MovedTrack = m_Items->Detach( m_CurItem );
wxImage * MovedImage = ( * m_Images )[ m_CurItem ];
wxString MovedLyric = ( * m_Lyrics )[ m_CurItem ];
int MovedFlag = ( * m_ChangedFlags )[ m_CurItem ];
m_Images->RemoveAt( m_CurItem );
m_Lyrics->RemoveAt( m_CurItem );
m_ChangedFlags->RemoveAt( m_CurItem );
m_SongListBox->SetString( m_CurItem, m_SongListBox->GetString( m_CurItem - 1 ) );
m_CurItem--;
m_Items->Insert( MovedTrack, m_CurItem );
m_Images->Insert( MovedImage, m_CurItem );
m_Lyrics->Insert( MovedLyric, m_CurItem );
m_ChangedFlags->Insert( MovedFlag, m_CurItem );
m_SongListBox->SetString( m_CurItem, FileName );
m_SongListBox->SetSelection( m_CurItem );
event.SetInt( m_CurItem );
OnSongListBoxSelected( event );
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnMoveDownBtnClick( wxCommandEvent &event )
{
wxString FileName = m_SongListBox->GetString( m_CurItem );
guTrack * MovedTrack = m_Items->Detach( m_CurItem );
wxImage * MovedImage = ( * m_Images )[ m_CurItem ];
wxString MovedLyric = ( * m_Lyrics )[ m_CurItem ];
int MovedFlag = ( * m_ChangedFlags )[ m_CurItem ];
m_Images->RemoveAt( m_CurItem );
m_Lyrics->RemoveAt( m_CurItem );
m_ChangedFlags->RemoveAt( m_CurItem );
m_SongListBox->SetString( m_CurItem, m_SongListBox->GetString( m_CurItem + 1 ) );
m_CurItem++;
m_Items->Insert( MovedTrack, m_CurItem );
m_Images->Insert( MovedImage, m_CurItem );
m_Lyrics->Insert( MovedLyric, m_CurItem );
m_ChangedFlags->Insert( MovedFlag, m_CurItem );
m_SongListBox->SetString( m_CurItem, FileName );
m_SongListBox->SetSelection( m_CurItem );
event.SetInt( m_CurItem );
OnSongListBoxSelected( event );
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::ReadItemData( void )
{
//guLogMessage( wxT( "ReadItemData: %i" ), m_CurItem );
if( m_CurItem >= 0 )
{
guTrack * Track = &( * m_Items )[ m_CurItem ];
m_AlbumArtistComboBox->SetValue( Track->m_AlbumArtist );
m_ArtistComboBox->SetValue( Track->m_ArtistName );
m_AlbumComboBox->SetValue( Track->m_AlbumName );
m_TitleTextCtrl->SetValue( Track->m_SongName );
m_CompComboBox->SetValue( Track->m_Composer );
if( Track->m_Number )
m_NumberTextCtrl->SetValue( wxString::Format( wxT( "%u" ), Track->m_Number ) );
else
m_NumberTextCtrl->SetValue( wxEmptyString );
m_DiskTextCtrl->SetValue( Track->m_Disk );
m_GenreComboBox->SetValue( Track->m_GenreName );
if( Track->m_Year )
m_YearTextCtrl->SetValue( wxString::Format( wxT( "%u" ), Track->m_Year ) );
else
m_YearTextCtrl->SetValue( wxEmptyString );
m_Rating->SetRating( Track->m_Rating );
m_CommentText->SetValue( Track->m_Comments );
m_DetailLeftInfoStaticText->SetLabel( wxString::Format( _( "File Type\t: %s\n"
"Length\t: %s" ),
Track->m_FileName.AfterLast( wxT( '.' ) ).c_str(),
LenToString( Track->m_Length ).c_str() ) );
m_DetailRightInfoStaticText->SetLabel( wxString::Format( _( "BitRate\t: %u Kbps\n"
"File Size\t: %s" ),
Track->m_Bitrate,
SizeToString( guGetFileSize( Track->m_FileName ) ).c_str() ) );
if( m_MBQuerySetArtistEnabled )
{
m_MBQueryArtistTextCtrl->SetValue( Track->m_AlbumArtist.IsEmpty() ? Track->m_ArtistName : Track->m_AlbumArtist );
m_MBQueryTitleTextCtrl->SetValue( Track->m_AlbumName );
}
m_MoveUpButton->Enable( m_CurItem > 0 );
m_MoveDownButton->Enable( m_CurItem < ( int ) ( m_Items->Count() - 1 ) );
m_LyricArtistTextCtrl->SetValue( Track->m_ArtistName );
m_LyricTrackTextCtrl->SetValue( Track->m_SongName );
m_LyricsTextCtrl->SetValue( ( * m_Lyrics )[ m_CurItem ] );
}
else
{
m_AlbumArtistComboBox->SetValue( wxEmptyString );
m_ArtistComboBox->SetValue( wxEmptyString );
m_AlbumComboBox->SetValue( wxEmptyString );
m_TitleTextCtrl->SetValue( wxEmptyString );
m_CompComboBox->SetValue( wxEmptyString );
m_NumberTextCtrl->SetValue( wxEmptyString );
m_DiskTextCtrl->SetValue( wxEmptyString );
m_GenreComboBox->SetValue( wxEmptyString );
m_YearTextCtrl->SetValue( wxEmptyString );
m_Rating->SetRating( -1 );
m_CommentText->SetValue( wxEmptyString );
m_DetailLeftInfoStaticText->SetLabel( wxEmptyString );
m_DetailRightInfoStaticText->SetLabel( wxEmptyString );
m_MBQueryArtistTextCtrl->SetValue( wxEmptyString );
m_MBQueryTitleTextCtrl->SetValue( wxEmptyString );
m_MoveUpButton->Enable( false );
m_MoveDownButton->Enable( false );
m_LyricArtistTextCtrl->SetValue( wxEmptyString );
m_LyricTrackTextCtrl->SetValue( wxEmptyString );
m_LyricsTextCtrl->SetValue( wxEmptyString );
}
UpdateArtists();
UpdateAlbumArtists();
UpdateAlbums();
UpdateComposers();
UpdateGenres();
m_ArtistChanged = false;
m_AlbumArtistChanged = false;
m_AlbumChanged = false;
m_CompChanged = false;
m_GenreChanged = false;
m_RatingChanged = false;
RefreshImage();
UpdateMBrainzTrackInfo();
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::SetTagField( wxString &field, const wxString &newval, int &changedflags, const int flagval )
{
if( field != newval )
{
field = newval;
if( !( changedflags & flagval ) )
changedflags |= flagval;
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::SetTagField( int &field, const int newval, int &changedflags, const int flagval )
{
if( field != newval )
{
field = newval;
if( !( changedflags & flagval ) )
changedflags |= flagval;
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::WriteItemData( void )
{
//guLogMessage( wxT( "WriteItemData: %i" ), m_CurItem );
if( m_CurItem >= 0 )
{
int ChangedFlag = ( * m_ChangedFlags )[ m_CurItem ];
long LongValue;
guTrack &Track = ( * m_Items )[ m_CurItem ];
if( m_AlbumArtistChanged )
{
SetTagField( Track.m_AlbumArtist, m_AlbumArtistComboBox->GetValue(), ChangedFlag );
}
if( m_ArtistChanged )
{
SetTagField( Track.m_ArtistName, m_ArtistComboBox->GetValue(), ChangedFlag );
}
if( m_AlbumChanged )
{
SetTagField( Track.m_AlbumName, m_AlbumComboBox->GetValue(), ChangedFlag );
}
if( m_TitleTextCtrl->IsModified() )
{
SetTagField( Track.m_SongName, m_TitleTextCtrl->GetValue(), ChangedFlag );
}
if( m_CompChanged )
{
SetTagField( Track.m_Composer, m_CompComboBox->GetValue(), ChangedFlag );
}
if( m_NumberTextCtrl->IsModified() )
{
m_NumberTextCtrl->GetValue().ToLong( &LongValue );
SetTagField( Track.m_Number, LongValue, ChangedFlag );
}
if( m_DiskTextCtrl->IsModified() )
{
SetTagField( Track.m_Disk, m_DiskTextCtrl->GetValue(), ChangedFlag );
}
if( m_GenreChanged )
{
SetTagField( Track.m_GenreName, m_GenreComboBox->GetValue(), ChangedFlag );
}
if( m_YearTextCtrl->IsModified() )
{
m_YearTextCtrl->GetValue().ToLong( &LongValue );
SetTagField( Track.m_Year, LongValue, ChangedFlag );
}
if( m_RatingChanged )
{
bool EmbeddRatings = Track.m_MediaViewer && Track.m_MediaViewer->GetEmbeddMetadata();
SetTagField( Track.m_Rating, m_Rating->GetRating(), ChangedFlag,
EmbeddRatings ? guTRACK_CHANGED_DATA_TAGS | guTRACK_CHANGED_DATA_RATING : guTRACK_CHANGED_DATA_TAGS );
}
if( m_CommentText->IsModified() )
{
SetTagField( Track.m_Comments, m_CommentText->GetValue(), ChangedFlag );
}
if( m_LyricsTextCtrl->IsModified() )
{
SetTagField( ( * m_Lyrics )[ m_CurItem ], m_LyricsTextCtrl->GetValue(), ChangedFlag, guTRACK_CHANGED_DATA_LYRICS );
}
( * m_ChangedFlags )[ m_CurItem ] = ChangedFlag;
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnAACopyButtonClicked( wxCommandEvent& event )
{
wxString CurData = m_AlbumArtistComboBox->GetValue();
int count = m_Items->Count();
for( int index = 0; index < count; index++ )
{
SetTagField( ( * m_Items )[ index ].m_AlbumArtist, CurData, ( * m_ChangedFlags )[ index ] );
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnArCopyButtonClicked( wxCommandEvent& event )
{
wxString CurData = m_ArtistComboBox->GetValue();
int count = m_Items->Count();
for( int index = 0; index < count; index++ )
{
SetTagField( ( * m_Items )[ index ].m_ArtistName, CurData, ( * m_ChangedFlags )[ index ] );
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnAlCopyButtonClicked( wxCommandEvent& event )
{
wxString CurData = m_AlbumComboBox->GetValue();
int count = m_Items->Count();
for( int index = 0; index < count; index++ )
{
SetTagField( ( * m_Items )[ index ].m_AlbumName, CurData, ( * m_ChangedFlags )[ index ] );
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnTiCopyButtonClicked( wxCommandEvent& event )
{
wxString CurData = m_TitleTextCtrl->GetValue();
int count = m_Items->Count();
for( int index = 0; index < count; index++ )
{
SetTagField( ( * m_Items )[ index ].m_SongName, CurData, ( * m_ChangedFlags )[ index ] );
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnCoCopyButtonClicked( wxCommandEvent& event )
{
wxString CurData = m_CompComboBox->GetValue();
int count = m_Items->Count();
for( int index = 0; index < count; index++ )
{
SetTagField( ( * m_Items )[ index ].m_Composer, CurData, ( * m_ChangedFlags )[ index ] );
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnNuOrderButtonClicked( wxCommandEvent& event )
{
int count = m_Items->Count();
for( int index = 0; index < count; index++ )
{
SetTagField( ( * m_Items )[ index ].m_Number, ( index + 1 ), ( * m_ChangedFlags )[ index ] );
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnNuCopyButtonClicked( wxCommandEvent& event )
{
long CurData;
m_NumberTextCtrl->GetValue().ToLong( &CurData );
int count = m_Items->Count();
for( int index = 0; index < count; index++ )
{
SetTagField( ( * m_Items )[ index ].m_Number, CurData, ( * m_ChangedFlags )[ index ] );
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnDiCopyButtonClicked( wxCommandEvent& event )
{
wxString CurData = m_DiskTextCtrl->GetValue();
int count = m_Items->Count();
for( int index = 0; index < count; index++ )
{
SetTagField( ( * m_Items )[ index ].m_Disk, CurData, ( * m_ChangedFlags )[ index ] );
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnGeCopyButtonClicked( wxCommandEvent& event )
{
wxString CurData = m_GenreComboBox->GetValue();
int count = m_Items->Count();
for( int index = 0; index < count; index++ )
{
SetTagField( ( * m_Items )[ index ].m_GenreName, CurData, ( * m_ChangedFlags )[ index ] );
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnYeCopyButtonClicked( wxCommandEvent& event )
{
long Year;
wxString YearStr = m_YearTextCtrl->GetValue();
if( YearStr.IsEmpty() || !YearStr.ToLong( &Year ) )
{
Year = 0;
}
//guLogMessage( wxT( "Year set to : %u" ), Year );
int Count = m_Items->Count();
for( int Index = 0; Index < Count; Index++ )
{
SetTagField( ( * m_Items )[ Index ].m_Year, Year, ( * m_ChangedFlags )[ Index ] );
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnRaCopyButtonClicked( wxCommandEvent& event )
{
int count = m_Items->Count();
int CurData = m_Rating->GetRating();
for( int index = 0; index < count; index++ )
{
guTrack &Track = ( * m_Items )[ index ];
bool EmbeddRatings = Track.m_MediaViewer && Track.m_MediaViewer->GetEmbeddMetadata();
SetTagField( ( * m_Items )[ index ].m_Rating, CurData, ( * m_ChangedFlags )[ index ],
EmbeddRatings ? guTRACK_CHANGED_DATA_TAGS | guTRACK_CHANGED_DATA_RATING : guTRACK_CHANGED_DATA_TAGS );
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnCommentCopyButtonClicked( wxCommandEvent& event )
{
wxString CurData = m_CommentText->GetValue();
int count = m_Items->Count();
for( int index = 0; index < count; index++ )
{
SetTagField( ( * m_Items )[ index ].m_Comments, CurData, ( * m_ChangedFlags )[ index ] );
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnRatingChanged( guRatingEvent &event )
{
m_RatingChanged = true;
m_CurrentRating = event.GetInt();
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::RefreshImage( void )
{
wxImage Image;
wxImage * pCurImage = NULL;
if( ( m_CurItem >= 0 ) && ( pCurImage = ( * m_Images )[ m_CurItem ] ) )
{
Image = * pCurImage;
}
else
{
Image = guImage( guIMAGE_INDEX_no_cover );
}
Image.Rescale( 250, 250, wxIMAGE_QUALITY_HIGH );
m_PictureBitmap->SetBitmap( Image );
if( m_CurItem >= 0 )
{
if( pCurImage )
{
m_AddPicButton->Enable( false );
m_DelPicButton->Enable( true );
m_SavePicButton->Enable( true );
m_SearchPicButton->Enable( false );
}
else
{
m_AddPicButton->Enable( true );
m_DelPicButton->Enable( false );
m_SavePicButton->Enable( false );
m_SearchPicButton->Enable( true );
}
m_CopyPicButton->Enable( true );
}
else
{
m_AddPicButton->Enable( false );
m_DelPicButton->Enable( false );
m_SavePicButton->Enable( false );
m_SearchPicButton->Enable( false );
m_CopyPicButton->Enable( false );
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnAddImageClicked( wxCommandEvent &event )
{
wxASSERT( m_CurItem >= 0 );
wxFileDialog * FileDialog = new wxFileDialog( this,
wxT( "Select the filename to save" ),
wxPathOnly( ( * m_Items )[ m_CurItem ].m_FileName ),
wxT( "cover.jpg" ),
wxT( "*.jpg;*.png" ),
wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_PREVIEW );
if( FileDialog )
{
if( FileDialog->ShowModal() == wxID_OK )
{
//CoverImage->SaveFile( AlbumPath + wxT( "cover.jpg" ), wxBITMAP_TYPE_JPEG );
wxString FileName = FileDialog->GetPath();
//guLogMessage( wxT( "File Open : '%s'" ), FileName.c_str() );
wxImage * pCurImage = new wxImage();
pCurImage->LoadFile( FileName );
if( pCurImage->IsOk() )
{
( * m_Images )[ m_CurItem ] = pCurImage;
if( !( ( * m_ChangedFlags )[ m_CurItem ] & guTRACK_CHANGED_DATA_IMAGES ) )
( * m_ChangedFlags )[ m_CurItem ] |= guTRACK_CHANGED_DATA_IMAGES;
RefreshImage();
}
}
FileDialog->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnDelImageClicked( wxCommandEvent &event )
{
wxASSERT( m_CurItem >= 0 );
wxImage * pCurImage = ( * m_Images )[ m_CurItem ];
( * m_Images )[ m_CurItem ] = NULL;
if( !( ( * m_ChangedFlags )[ m_CurItem ] & guTRACK_CHANGED_DATA_IMAGES ) )
( * m_ChangedFlags )[ m_CurItem ] |= guTRACK_CHANGED_DATA_IMAGES;
delete pCurImage;
RefreshImage();
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnSaveImageClicked( wxCommandEvent &event )
{
wxASSERT( m_CurItem >= 0 );
wxImage * pCurImage = m_Images->Item( m_CurItem );
guTrack * CurTrack = &m_Items->Item( m_CurItem );
wxASSERT( pCurImage );
wxString CoverName;
if( CurTrack->m_MediaViewer )
{
CoverName = CurTrack->m_MediaViewer->CoverName();
}
if( CoverName.IsEmpty() )
{
CoverName = wxT( "cover" );
}
CoverName += wxT( ".jpg" );
wxFileDialog * FileDialog = new wxFileDialog( this,
wxT( "Select the filename to save" ),
wxPathOnly( ( * m_Items )[ m_CurItem ].m_FileName ),
CoverName,
wxT( "*.jpg;*.png" ),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( FileDialog )
{
if( FileDialog->ShowModal() == wxID_OK )
{
//CoverImage->SaveFile( AlbumPath + wxT( "cover.jpg" ), wxBITMAP_TYPE_JPEG );
wxString FileName = FileDialog->GetPath();
//guLogMessage( wxT( "File Save to : '%s'" ), FileName.c_str() );
if( FileName.EndsWith( wxT( ".png" ) ) )
{
pCurImage->SaveFile( FileName, wxBITMAP_TYPE_PNG );
}
else
{
pCurImage->SaveFile( FileName, wxBITMAP_TYPE_JPEG );
}
}
FileDialog->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnSearchImageClicked( wxCommandEvent &event )
{
wxASSERT( m_CurItem >= 0 );
wxString AlbumName = ( * m_Items )[ m_CurItem ].m_AlbumName;
wxString ArtistName = ( * m_Items )[ m_CurItem ].m_ArtistName;
AlbumName = RemoveSearchFilters( AlbumName );
guCoverEditor * CoverEditor = new guCoverEditor( this, ArtistName, AlbumName );
if( CoverEditor )
{
if( CoverEditor->ShowModal() == wxID_OK )
{
wxImage * SelectedCover = CoverEditor->GetSelectedCoverImage();
if( SelectedCover )
{
( * m_Images )[ m_CurItem ] = new wxImage( * SelectedCover );
if( !( ( * m_ChangedFlags )[ m_CurItem ] & guTRACK_CHANGED_DATA_IMAGES ) )
( * m_ChangedFlags )[ m_CurItem ] |= guTRACK_CHANGED_DATA_IMAGES;
RefreshImage();
}
}
CoverEditor->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnCopyImageClicked( wxCommandEvent &event )
{
wxASSERT( m_CurItem >= 0 );
wxImage * pCurImage = ( * m_Images )[ m_CurItem ];
wxASSERT( pCurImage );
int count = m_Images->Count();
for( int index = 0; index < count; index++ )
{
if( index != m_CurItem )
{
if( ( * m_Images )[ index ] )
delete ( * m_Images )[ index ];
( * m_Images )[ index ] = pCurImage ? ( new wxImage( * pCurImage ) ) : NULL;
if( !( ( * m_ChangedFlags )[ index ] & guTRACK_CHANGED_DATA_IMAGES ) )
( * m_ChangedFlags )[ index ] |= guTRACK_CHANGED_DATA_IMAGES;
}
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnMBrainzAddButtonClicked( wxCommandEvent &event )
{
guLogMessage( wxT( "OnMBrainzAddButtonClicked..." ) );
if( m_MBQuerySetArtistEnabled )
m_MBQuerySetArtistEnabled = false;
if( !m_MBQueryArtistTextCtrl->IsEmpty() ||
!m_MBQueryTitleTextCtrl->IsEmpty() )
{
wxSetCursor( * wxHOURGLASS_CURSOR );
guMusicBrainz * MusicBrainz = new guMusicBrainz();
m_MBAddButton->Enable( false );
if( !m_MBAlbums )
{
m_MBAlbums = new guMBReleaseArray();
}
MusicBrainz->GetRecordReleases( m_MBQueryArtistTextCtrl->GetValue(), m_MBQueryTitleTextCtrl->GetValue(), m_MBAlbums );
ReloadMBAlbums();
delete MusicBrainz;
m_MBAddButton->Enable( true );
wxSetCursor( * wxSTANDARD_CURSOR );
}
else if( m_MBCurTrack < ( int ) m_Items->Count() )
{
guTrack & CurTrack = m_Items->Item( m_MBCurTrack );
if( wxFileExists( CurTrack.m_FileName ) )
{
guLogMessage( wxT( "Searching for the acousticId for the current track " ) );
wxSetCursor( * wxHOURGLASS_CURSOR );
m_MBAddButton->Enable( false );
if( !m_AcousticId )
{
m_AcousticId = new guAcousticId( this );
}
m_MBRecordingId.Clear();
m_AcousticId->SearchTrack( &CurTrack );
// It will return on OnAcousticIdMBIdFound or OnAcousticIdError()
}
else
{
guLogError( wxT( "Could not find the track '%s'" ), CurTrack.m_FileName.c_str() );
}
m_MBCurTrack++;
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::ReloadMBAlbums()
{
int Count = m_MBAlbums->Count();
//guLogMessage( wxT( "Got %i releases" ), Count );
if( Count )
{
for( int Index = 0; Index < Count; Index++ )
{
guMBRelease * MBRelease = &m_MBAlbums->Item( Index );
m_MBAlbumChoice->Append( MBRelease->m_ArtistName + " " + MBRelease->m_Title );
}
if( m_MBAlbumChoice->GetSelection() == wxNOT_FOUND )
{
m_MBAlbumChoice->SetSelection( 0 );
wxCommandEvent event;
event.SetInt( 0 );
OnMBrainzAlbumChoiceSelected( event );
}
}
else
{
wxMessageBox( wxT( "MusicBrainz: Could not get any track information." ), wxT( "MusicBrainz Error" ) );
}
}
void guTrackEditor::OnAcousticIdMBIdFound( const wxString &mbid )
{
//guLogMessage( wxT( "TrackEditor::OnAcousticIdMBIdFound: %s" ), mbid.c_str() );
guMusicBrainz * MusicBrainz = new guMusicBrainz();
if( MusicBrainz )
{
if( !m_MBAlbums )
{
m_MBAlbums = new guMBReleaseArray();
}
if( m_MBAlbums )
{
m_MBAlbumChoice->Clear();
MusicBrainz->GetRecordReleases( mbid, m_MBAlbums );
ReloadMBAlbums();
}
else
{
guLogMessage( wxT( "Could not create the releases musibrainz object." ) );
}
delete MusicBrainz;
}
else
{
guLogMessage( wxT( "Could not create the MusicBrainz object." ) );
}
m_MBAddButton->SetBitmapLabel( guBitmap( guIMAGE_INDEX_tiny_search_again ) );
m_MBAddButton->Enable( true );
wxSetCursor( *wxSTANDARD_CURSOR );
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnAcousticIdError( const int status )
{
guLogMessage( wxT( "AcousticIdError: %i" ), status );
m_MBAddButton->Enable( true );
wxSetCursor( *wxSTANDARD_CURSOR );
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::UpdateMBrainzTrackInfo( void )
{
if( m_MBCurAlbum >= 0 && m_CurItem >= 0 )
{
guMBRelease &CurRelease = m_MBAlbums->Item( m_MBCurAlbum );
guMBRecordingArray * MBRecordings = &CurRelease.m_Recordings;
if( MBRecordings && ( m_CurItem < ( int ) MBRecordings->Count() ) )
{
guMBRecording * MBRecording = &MBRecordings->Item( m_CurItem );
guTrack * Track = &m_Items->Item( m_CurItem );
// Artist
if( !MBRecording->m_ArtistName.IsEmpty() )
{
m_MBArtistStaticText->SetForegroundColour( Track->m_ArtistName == MBRecording->m_ArtistName ?
m_NormalColor : m_ErrorColor );
m_MBArtistTextCtrl->SetValue( MBRecording->m_ArtistName );
}
else
{
m_MBArtistStaticText->SetForegroundColour( Track->m_ArtistName == CurRelease.m_ArtistName ?
m_NormalColor : m_ErrorColor );
m_MBArtistTextCtrl->SetValue( CurRelease.m_ArtistName );
}
// Album Artist
m_MBAlbumArtistStaticText->SetForegroundColour( Track->m_AlbumArtist == CurRelease.m_ArtistName ?
m_NormalColor : m_ErrorColor );
// ALbum
m_MBAlbumStaticText->SetForegroundColour( Track->m_AlbumName == CurRelease.m_Title ?
m_NormalColor : m_ErrorColor );
// Title
m_MBTitleStaticText->SetForegroundColour( Track->m_SongName == MBRecording->m_Title ?
m_NormalColor : m_ErrorColor );
m_MBTitleTextCtrl->SetValue( MBRecording->m_Title );
// Year
m_MBYearTextCtrl->SetValue( wxString::Format( wxT( "%u" ), CurRelease.m_Year ) );
if( Track->m_Year )
{
m_MBYearStaticText->SetForegroundColour( ( CurRelease.m_Year == Track->m_Year ) ?
m_ErrorColor : m_NormalColor );
}
else
{
m_MBYearStaticText->SetForegroundColour( m_MBYearTextCtrl->IsEmpty() ?
m_NormalColor : m_ErrorColor );
}
// Length
m_MBLengthStaticText->SetForegroundColour(
GetTrackLengthDiff( Track->m_Length, MBRecording->m_Length ) > guMBRAINZ_MAX_TIME_DIFF ?
m_ErrorColor : m_NormalColor );
m_MBLengthTextCtrl->SetValue( LenToString( MBRecording->m_Length ) );
// Number
m_MBNumberStaticText->SetForegroundColour( Track->m_Number == MBRecording->m_Number ?
m_NormalColor : m_ErrorColor );
m_MBNumberTextCtrl->SetValue( wxString::Format( wxT( "%u" ), MBRecording->m_Number ) );
return;
}
}
m_MBTitleTextCtrl->SetValue( wxEmptyString );
m_MBNumberTextCtrl->SetValue( wxEmptyString );
}
// -------------------------------------------------------------------------------- //
int guTrackEditor::CheckTracksLengths( guMBRecordingArray * mbtracks, guTrackArray * tracks )
{
int RetVal = 0;
int Count = wxMin( tracks->Count(), mbtracks->Count() );
for( int Index = 0; Index < Count; Index++ )
{
if( GetTrackLengthDiff( tracks->Item( Index ).m_Length,
mbtracks->Item( Index ).m_Length ) > guMBRAINZ_MAX_TIME_DIFF )
{
RetVal++;
}
}
return RetVal;
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::MBCheckCountAndLengths( void )
{
if( m_MBAlbums && m_MBAlbums->Count() )
{
guMBRelease &MBRelease = m_MBAlbums->Item( m_MBCurAlbum );
// Check the number of tracks
wxString InfoText;
if( MBRelease.m_Recordings.Count() != m_Items->Count() )
{
InfoText = wxString::Format( _( "Error: The album have %lu tracks and you are editing %lu" ),
MBRelease.m_Recordings.Count(), m_Items->Count() );
}
if( CheckTracksLengths( &MBRelease.m_Recordings, m_Items ) )
{
InfoText += "\n";
InfoText += _( "Warning: The length of some edited tracks don't match" );
}
if( InfoText.IsEmpty() )
{
InfoText += _( "Everything ok" );
}
m_MBInfoStaticText->SetLabel( InfoText );
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnMBrainzAlbumChoiceSelected( wxCommandEvent &event )
{
m_MBCurAlbum = event.GetInt();
guLogMessage( wxT( "MusicBrainzAlbumSelected... %i" ), m_MBCurAlbum );
if( m_MBCurAlbum >= 0 )
{
wxSetCursor( * wxHOURGLASS_CURSOR );
if( m_MBAlbums && m_MBAlbums->Count() )
{
guMBRelease &MBRelease = m_MBAlbums->Item( m_MBCurAlbum );
if( !MBRelease.m_Recordings.Count() )
{
guMusicBrainz * MusicBrainz = new guMusicBrainz();
if( MusicBrainz )
{
MusicBrainz->GetRecordings( MBRelease );
delete MusicBrainz;
}
else
{
guLogMessage( wxT( "Could not create the MusicBrainz object." ) );
}
}
m_MBArtistTextCtrl->SetValue( MBRelease.m_ArtistName );
m_MBAlbumArtistTextCtrl->SetValue( MBRelease.m_ArtistName );
UpdateMBrainzTrackInfo();
m_MBCopyButton->Enable( true );
m_MBAlbumTextCtrl->SetValue( MBRelease.m_Title );
MBCheckCountAndLengths();
}
wxSetCursor( * wxSTANDARD_CURSOR );
}
else
{
m_MBCopyButton->Enable( false );
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnMBrainzCopyButtonClicked( wxCommandEvent &event )
{
if( !( m_MBAlbums && m_MBAlbums->Count() && m_MBCurAlbum >= 0 ) )
return;
guMBRelease &MBRelease = m_MBAlbums->Item( m_MBCurAlbum );
int Count = wxMin( m_Items->Count(), MBRelease.m_Recordings.Count() );
for( int Index = 0; Index < Count; Index++ )
{
guTrack * Track = &m_Items->Item( Index );
guMBRecording &MBRecording = MBRelease.m_Recordings[ Index ];
SetTagField( Track->m_ArtistName, MBRecording.m_ArtistName.IsEmpty() ? MBRelease.m_ArtistName :
MBRecording.m_ArtistName, ( * m_ChangedFlags )[ Index ] );
SetTagField( Track->m_AlbumArtist, MBRelease.m_ArtistName, ( * m_ChangedFlags )[ Index ] );
SetTagField( Track->m_AlbumName, MBRelease.m_Title, ( * m_ChangedFlags )[ Index ] );
SetTagField( Track->m_SongName, MBRecording.m_Title, ( * m_ChangedFlags )[ Index ] );
SetTagField( Track->m_Number, MBRecording.m_Number, ( * m_ChangedFlags )[ Index ] );
SetTagField( Track->m_Year, MBRelease.m_Year, ( * m_ChangedFlags )[ Index ] );
}
// Refresh the Details Window
ReadItemData();
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnMBrainzArtistCopyButtonClicked( wxCommandEvent& event )
{
if( !( m_MBAlbums && m_MBAlbums->Count() && m_MBCurAlbum >= 0 ) )
return;
guMBRelease &MBRelease = m_MBAlbums->Item( m_MBCurAlbum );
int Count = wxMin( m_Items->Count(), MBRelease.m_Recordings.Count() );
for( int Index = 0; Index < Count; Index++ )
{
guTrack * Track = &m_Items->Item( Index );
guMBRecording &MBRecording = MBRelease.m_Recordings[ Index ];
SetTagField( Track->m_ArtistName, MBRecording.m_ArtistName.IsEmpty() ? MBRelease.m_ArtistName : MBRecording.m_ArtistName,
( * m_ChangedFlags )[ Index ] );
}
// Refresh the Details Window
ReadItemData();
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnMBrainzAlbumArtistCopyButtonClicked( wxCommandEvent& event )
{
if( !( m_MBAlbums && m_MBAlbums->Count() && m_MBCurAlbum >= 0 ) )
return;
guMBRelease &MBRelease = m_MBAlbums->Item( m_MBCurAlbum );
int Count = wxMin( m_Items->Count(), MBRelease.m_Recordings.Count() );
for( int Index = 0; Index < Count; Index++ )
{
guTrack * Track = &m_Items->Item( Index );
SetTagField( Track->m_AlbumArtist, MBRelease.m_ArtistName, ( * m_ChangedFlags )[ Index ] );
}
// Refresh the Details Window
ReadItemData();
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnMBrainzAlbumCopyButtonClicked( wxCommandEvent& event )
{
if( !( m_MBAlbums && m_MBAlbums->Count() && m_MBCurAlbum >= 0 ) )
return;
guMBRelease &MBRelease = m_MBAlbums->Item( m_MBCurAlbum );
int Count = wxMin( m_Items->Count(), MBRelease.m_Recordings.Count() );
for( int Index = 0; Index < Count; Index++ )
{
guTrack * Track = &m_Items->Item( Index );
SetTagField( Track->m_AlbumName, MBRelease.m_Title, ( * m_ChangedFlags )[ Index ] );
}
// Refresh the Details Window
ReadItemData();
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnMBrainzYearCopyButtonClicked( wxCommandEvent& event )
{
if( !( m_MBAlbums && m_MBAlbums->Count() && m_MBCurAlbum >= 0 ) )
return;
guMBRelease &MBRelease = m_MBAlbums->Item( m_MBCurAlbum );
int Count = wxMin( m_Items->Count(), MBRelease.m_Recordings.Count() );
for( int Index = 0; Index < Count; Index++ )
{
guTrack * Track = &m_Items->Item( Index );
SetTagField( Track->m_Year, MBRelease.m_Year, ( * m_ChangedFlags )[ Index ] );
}
// Refresh the Details Window
ReadItemData();
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnMBrainzTitleCopyButtonClicked( wxCommandEvent& event )
{
if( !( m_MBAlbums && m_MBAlbums->Count() && m_MBCurAlbum >= 0 ) )
return;
guMBRelease &MBRelease = m_MBAlbums->Item( m_MBCurAlbum );
int Count = wxMin( m_Items->Count(), MBRelease.m_Recordings.Count() );
for( int Index = 0; Index < Count; Index++ )
{
guTrack * Track = &m_Items->Item( Index );
guMBRecording &MBRecording = MBRelease.m_Recordings[ Index ];
SetTagField( Track->m_SongName, MBRecording.m_Title, ( * m_ChangedFlags )[ Index ] );
}
// Refresh the Details Window
ReadItemData();
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnMBrainzNumberCopyButtonClicked( wxCommandEvent& event )
{
if( !( m_MBAlbums && m_MBAlbums->Count() && m_MBCurAlbum >= 0 ) )
return;
guMBRelease &MBRelease = m_MBAlbums->Item( m_MBCurAlbum );
int Count = wxMin( m_Items->Count(), MBRelease.m_Recordings.Count() );
for( int Index = 0; Index < Count; Index++ )
{
guTrack * Track = &m_Items->Item( Index );
guMBRecording &MBRecording = MBRelease.m_Recordings[ Index ];
SetTagField( Track->m_Number, MBRecording.m_Number, ( * m_ChangedFlags )[ Index ] );
}
// Refresh the Details Window
ReadItemData();
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnMBQueryClearButtonClicked( wxCommandEvent &event )
{
if( m_MBQuerySetArtistEnabled )
m_MBQuerySetArtistEnabled = false;
m_MBQueryArtistTextCtrl->SetValue( wxEmptyString );
m_MBQueryTitleTextCtrl->SetValue( wxEmptyString );
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnMBQueryTextCtrlChanged( wxCommandEvent& event )
{
if( m_MBQuerySetArtistEnabled )
m_MBQuerySetArtistEnabled = false;
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::SongListSplitterOnIdle( wxIdleEvent& )
{
//guLogMessage( wxT( "SplitterOnIdle..." ) );
guConfig * Config = ( guConfig * ) guConfig::Get();
m_SongListSplitter->SetSashPosition( Config->ReadNum( CONFIG_KEY_POSITIONS_TRACKEDIT_SASHPOS, 200, CONFIG_PATH_POSITIONS ) );
// Idle Events
m_SongListSplitter->Unbind( wxEVT_IDLE, &guTrackEditor::SongListSplitterOnIdle, this );
m_GetComboDataThread = new guTrackEditorGetComboDataThread( this, m_Db );
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnTextUpdated( wxCommandEvent& event )
{
bool Enabled = !m_LyricArtistTextCtrl->GetValue().IsEmpty() &&
!m_LyricTrackTextCtrl->GetValue().IsEmpty();
m_LyricReloadButton->Enable( Enabled );
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnSearchLyrics( wxCommandEvent &event )
{
if( m_LyricArtistTextCtrl->IsEmpty() ||
m_LyricTrackTextCtrl->IsEmpty() )
return;
if( !m_LyricSearchEngine )
{
m_LyricSearchEngine = ( ( guMainFrame * ) guMainFrame::GetMainFrame() )->LyricSearchEngine();
}
if( m_LyricSearchEngine )
{
if( !m_LyricSearchContext )
{
guTrack Track = m_Items->Item( m_CurItem );
Track.m_ArtistName = m_LyricArtistTextCtrl->GetValue();
Track.m_SongName = m_LyricTrackTextCtrl->GetValue();
m_LyricSearchContext = m_LyricSearchEngine->CreateContext( this, &Track, false );
}
if( m_LyricSearchContext )
{
m_LyricSearchEngine->SearchStart( m_LyricSearchContext );
}
}
m_LyricReloadButton->Enable( false );
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnDownloadedLyric( wxCommandEvent &event )
{
wxString * Content = ( wxString * ) event.GetClientData();
if( Content )
{
m_LyricsTextCtrl->SetValue( * Content );
//( * m_Lyrics )[ m_CurItem ] = * Content;
SetTagField( ( * m_Lyrics )[ m_CurItem ], * Content, ( * m_ChangedFlags )[ m_CurItem ], guTRACK_CHANGED_DATA_LYRICS );
delete Content;
}
m_LyricReloadButton->Enable( true );
}
// -------------------------------------------------------------------------------- //
void inline guUpdateComboBoxEntries( wxComboBox * combobox, wxSortedArrayString &itemlist, int curitem, wxString &lastvalue )
{
//guLogMessage( wxT( "guUpdateComboBoxEntries: %li %i '%s'" ), itemlist.Count(), curitem, lastvalue.c_str() );
wxString FilterText = combobox->GetValue().Lower();
if( FilterText == lastvalue )
return;
// Seems Clear is used for clear text what makes a call to this method and so on...
// So call to the wxItemContainer method
combobox->wxItemContainer::Clear();
if( curitem == wxNOT_FOUND )
return;
wxArrayString SetItems;
if( FilterText.IsEmpty() )
{
#if wxUSE_STL
int Count = itemlist.Count();
for( int Index = 0; Index < Count; Index++ )
{
SetItems.Add( itemlist[ Index ] );
}
combobox->Append( SetItems );
#else
combobox->Append( itemlist );
#endif
}
else
{
int Count = itemlist.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( itemlist[ Index ].Lower().Find( FilterText ) != wxNOT_FOUND )
{
SetItems.Add( itemlist[ Index ] );
}
}
combobox->Append( SetItems );
}
lastvalue = FilterText;
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnArtistChangedTimeout( wxTimerEvent &event )
{
guUpdateComboBoxEntries( m_ArtistComboBox, m_Artists, m_CurItem, m_LastArtist );
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnAlbumArtistChangedTimeout( wxTimerEvent &event )
{
guUpdateComboBoxEntries( m_AlbumArtistComboBox, m_AlbumArtists, m_CurItem, m_LastAlbumArtist );
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnAlbumChangedTimeout( wxTimerEvent &event )
{
guUpdateComboBoxEntries( m_AlbumComboBox, m_Albums, m_CurItem, m_LastAlbum );
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnComposerChangedTimeout( wxTimerEvent &event )
{
guUpdateComboBoxEntries( m_CompComboBox, m_Composers, m_CurItem, m_LastComposer );
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnGenreChangedTimeout( wxTimerEvent &event )
{
guUpdateComboBoxEntries( m_GenreComboBox, m_Genres, m_CurItem, m_LastGenre );
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnArtistTextChanged( wxCommandEvent &event )
{
m_ArtistChanged = true;
m_ArtistChangedTimer.Start( guTRACKEDIT_TIMER_TEXTCHANGED_TIME, wxTIMER_ONE_SHOT );
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnAlbumArtistTextChanged( wxCommandEvent &event )
{
m_AlbumArtistChanged = true;
m_AlbumArtistChangedTimer.Start( guTRACKEDIT_TIMER_TEXTCHANGED_TIME, wxTIMER_ONE_SHOT );
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnAlbumTextChanged( wxCommandEvent &event )
{
m_AlbumChanged = true;
m_AlbumChangedTimer.Start( guTRACKEDIT_TIMER_TEXTCHANGED_TIME, wxTIMER_ONE_SHOT );
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnComposerTextChanged( wxCommandEvent &event )
{
m_CompChanged = true;
m_ComposerChangedTimer.Start( guTRACKEDIT_TIMER_TEXTCHANGED_TIME, wxTIMER_ONE_SHOT );
}
// -------------------------------------------------------------------------------- //
void guTrackEditor::OnGenreTextChanged( wxCommandEvent &event )
{
m_GenreChanged = true;
m_GenreChangedTimer.Start( guTRACKEDIT_TIMER_TEXTCHANGED_TIME, wxTIMER_ONE_SHOT );
}
// -------------------------------------------------------------------------------- //
guTrack * guTrackEditor::GetTrack( const int index )
{
if( m_Items && ( index >= 0 ) && ( index < ( int ) m_Items->Count() ) )
{
return &m_Items->Item( index );
}
return NULL;
}
// -------------------------------------------------------------------------------- //
// guTrackEditorGetComboDataThread
// -------------------------------------------------------------------------------- //
guTrackEditorGetComboDataThread::guTrackEditorGetComboDataThread( guTrackEditor * editor, guDbLibrary * db ) : wxThread()
{
m_TrackEditor = editor;
m_Db = db;
if( Create() == wxTHREAD_NO_ERROR )
{
SetPriority( WXTHREAD_DEFAULT_PRIORITY - 30 );
Run();
}
}
// -------------------------------------------------------------------------------- //
guTrackEditorGetComboDataThread::~guTrackEditorGetComboDataThread()
{
if( !TestDestroy() && m_TrackEditor )
{
m_TrackEditor->m_GetComboDataThread = NULL;
}
}
// -------------------------------------------------------------------------------- //
void guTrackEditorGetComboDataThread::FillArrayStrings( wxSortedArrayString &array, const guListItems &items )
{
int Count = items.Count();
for( int Index = 0; Index < Count; Index++ )
{
wxString CurText = items[ Index ].m_Name;
if( !CurText.IsEmpty() && array.Index( CurText ) == wxNOT_FOUND )
array.Add( CurText );
if( TestDestroy() )
break;
}
}
// -------------------------------------------------------------------------------- //
guTrackEditorGetComboDataThread::ExitCode guTrackEditorGetComboDataThread::Entry()
{
if( TestDestroy() )
return 0;
guListItems Artists;
m_Db->GetArtists( &Artists, true );
FillArrayStrings( m_TrackEditor->m_Artists, Artists );
if( TestDestroy() )
return 0;
m_TrackEditor->UpdateArtists();
//
guListItems AlbumArtists;
m_Db->GetAlbumArtists( &AlbumArtists, true );
if( TestDestroy() )
return 0;
FillArrayStrings( m_TrackEditor->m_AlbumArtists, AlbumArtists );
if( TestDestroy() )
return 0;
m_TrackEditor->UpdateAlbumArtists();
//
//
guListItems Albums;
m_Db->GetAlbums( &Albums, true );
if( TestDestroy() )
return 0;
FillArrayStrings( m_TrackEditor->m_Albums, Albums );
if( TestDestroy() )
return 0;
m_TrackEditor->UpdateAlbums();
//
//
guListItems Composers;
m_Db->GetComposers( &Composers, true );
if( TestDestroy() )
return 0;
FillArrayStrings( m_TrackEditor->m_Composers, Composers );
if( TestDestroy() )
return 0;
m_TrackEditor->UpdateComposers();
//
//
guListItems Genres;
m_Db->GetGenres( &Genres, true );
if( TestDestroy() )
return 0;
FillArrayStrings( m_TrackEditor->m_Genres, Genres );
if( TestDestroy() )
return 0;
m_TrackEditor->UpdateGenres();
return 0;
}
}
// -------------------------------------------------------------------------------- //
| 93,263
|
C++
|
.cpp
| 1,789
| 45.721073
| 163
| 0.634533
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
750,653
|
LabelEditor.cpp
|
anonbeat_guayadeque/src/ui/labeleditor/LabelEditor.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "LabelEditor.h"
#include "Config.h"
#include "Images.h"
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
guLabelEditor::guLabelEditor( wxWindow * parent, guDbLibrary * db, const wxString &title,
const bool isradiolabel, const guListItems * items, guArrayListItems * labelsets ) //wxDialog( parent, wxID_ANY, title, wxDefaultPosition, wxSize( 500,300 ), wxDEFAULT_DIALOG_STYLE )
{
m_SelectedItem = wxNOT_FOUND;
m_SelectedLabel = wxNOT_FOUND;
m_IsRadioLabel = isradiolabel;
if( isradiolabel )
{
m_Db = NULL;
m_RaDb = ( guDbRadios * ) db;
}
else
{
m_Db = db;
m_RaDb = NULL;
}
m_LabelSets = labelsets;
guConfig * Config = ( guConfig * ) guConfig::Get();
wxPoint WindowPos;
WindowPos.x = Config->ReadNum( CONFIG_KEY_POSITIONS_LABELEDIT_POSX, -1, CONFIG_PATH_POSITIONS );
WindowPos.y = Config->ReadNum( CONFIG_KEY_POSITIONS_LABELEDIT_POSY, -1, CONFIG_PATH_POSITIONS );
wxSize WindowSize;
WindowSize.x = Config->ReadNum( CONFIG_KEY_POSITIONS_LABELEDIT_WIDTH, 500, CONFIG_PATH_POSITIONS );
WindowSize.y = Config->ReadNum( CONFIG_KEY_POSITIONS_LABELEDIT_HEIGHT, 300, CONFIG_PATH_POSITIONS );
//wxDialog( parent, wxID_ANY, _( "Songs Editor" ), wxDefaultPosition, wxSize( 625, 440 ), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
Create( parent, wxID_ANY, title, WindowPos, WindowSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX );
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* MainSizer;
MainSizer = new wxBoxSizer( wxVERTICAL );
m_Splitter = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D );
m_Splitter->SetMinimumPaneSize( 50 );
m_ItemsPanel = new wxPanel( m_Splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* ItemsMainSizer;
ItemsMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* ItemsStaticBox;
ItemsStaticBox = new wxStaticBoxSizer( new wxStaticBox( m_ItemsPanel, wxID_ANY, _(" Items ") ), wxVERTICAL );
m_ItemsListBox = new wxListBox( m_ItemsPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
int Count = items->Count();
for( int Index = 0; Index < Count; Index++ )
{
m_ItemsListBox->Append( items->Item( Index ).m_Name );
}
ItemsStaticBox->Add( m_ItemsListBox, 1, wxEXPAND|wxALL, 5 );
ItemsMainSizer->Add( ItemsStaticBox, 1, wxEXPAND|wxALL, 5 );
m_ItemsPanel->SetSizer( ItemsMainSizer );
m_ItemsPanel->Layout();
ItemsMainSizer->Fit( m_ItemsPanel );
m_LabelsPanel = new wxPanel( m_Splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* LabelsMainSizer;
LabelsMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* LabelsStaticBox;
LabelsStaticBox = new wxStaticBoxSizer( new wxStaticBox( m_LabelsPanel, wxID_ANY, _(" Labels ") ), wxHORIZONTAL );
if( m_IsRadioLabel )
{
m_RaDb->GetRadioLabels( &m_Labels );
}
else
{
m_Db->GetLabels( &m_Labels );
}
m_LabelsListBox = new wxCheckListBox( m_LabelsPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
Count = m_Labels.Count();
for( int Index = 0; Index < Count; Index++ )
{
m_LabelsListBox->Append( m_Labels[ Index ].m_Name );
}
LabelsStaticBox->Add( m_LabelsListBox, 1, wxEXPAND|wxALL, 5 );
LabelsMainSizer->Add( LabelsStaticBox, 1, wxEXPAND|wxALL, 5 );
wxBoxSizer* ButtonsSizer;
ButtonsSizer = new wxBoxSizer( wxHORIZONTAL );
ButtonsSizer->Add( 0, 0, 1, wxEXPAND, 5 );
m_AddButton = new wxBitmapButton( m_LabelsPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_add ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_AddButton->SetToolTip( _("Add a new label") );
ButtonsSizer->Add( m_AddButton, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_DelButton = new wxBitmapButton( m_LabelsPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_del ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_DelButton->Enable( false );
m_DelButton->SetToolTip( _("Delete the current selected label") );
ButtonsSizer->Add( m_DelButton, 0, wxBOTTOM|wxRIGHT, 5 );
m_CopyButton = new wxBitmapButton( m_LabelsPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit_copy ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_CopyButton->SetToolTip( _("Copy the label selection to all the items") );
ButtonsSizer->Add( m_CopyButton, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
LabelsMainSizer->Add( ButtonsSizer, 0, wxEXPAND, 5 );
m_LabelsPanel->SetSizer( LabelsMainSizer );
m_LabelsPanel->Layout();
LabelsMainSizer->Fit( m_LabelsPanel );
m_Splitter->SplitVertically( m_ItemsPanel, m_LabelsPanel, 177 );
MainSizer->Add( m_Splitter, 1, wxEXPAND, 5 );
wxStdDialogButtonSizer * DialogButtons = new wxStdDialogButtonSizer();
wxButton * OkButton = new wxButton( this, wxID_OK );
DialogButtons->AddButton( OkButton );
wxButton * CancelButton = new wxButton( this, wxID_CANCEL );
DialogButtons->AddButton( CancelButton );
DialogButtons->SetAffirmativeButton( OkButton );
DialogButtons->SetCancelButton( CancelButton );
DialogButtons->Realize();
MainSizer->Add( DialogButtons, 0, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
this->SetSizer( MainSizer );
this->Layout();
OkButton->SetDefault();
// Bind Events
m_Splitter->Bind( wxEVT_IDLE, &guLabelEditor::OnIdle, this );
m_ItemsListBox->Bind( wxEVT_LISTBOX, &guLabelEditor::OnItemSelected, this );
m_LabelsListBox->Bind( wxEVT_LISTBOX, &guLabelEditor::OnLabelSelected, this );
m_LabelsListBox->Bind( wxEVT_CHECKLISTBOX, &guLabelEditor::OnLabelChecked, this );
m_LabelsListBox->Bind( wxEVT_LISTBOX_DCLICK, &guLabelEditor::OnLabelDoubleClicked, this );
m_AddButton->Bind( wxEVT_BUTTON, &guLabelEditor::OnAddLabelClicked, this );
m_DelButton->Bind( wxEVT_BUTTON, &guLabelEditor::OnDelLabelClicked, this );
m_CopyButton->Bind( wxEVT_BUTTON, &guLabelEditor::OnCopyLabelsClicked, this );
m_ItemsListBox->SetSelection( 0 );
wxCommandEvent event;
event.SetInt( 0 );
OnItemSelected( event );
m_ItemsListBox->SetFocus();
}
// -------------------------------------------------------------------------------- //
guLabelEditor::~guLabelEditor()
{
// Save the window position and size
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->WriteNum( CONFIG_KEY_POSITIONS_LABELEDIT_SASHPOS, m_Splitter->GetSashPosition(), CONFIG_PATH_POSITIONS );
wxPoint WindowPos = GetPosition();
Config->WriteNum( CONFIG_KEY_POSITIONS_LABELEDIT_POSX, WindowPos.x, CONFIG_PATH_POSITIONS );
Config->WriteNum( CONFIG_KEY_POSITIONS_LABELEDIT_POSY, WindowPos.y, CONFIG_PATH_POSITIONS );
wxSize WindowSize = GetSize();
Config->WriteNum( CONFIG_KEY_POSITIONS_LABELEDIT_WIDTH, WindowSize.x, CONFIG_PATH_POSITIONS );
Config->WriteNum( CONFIG_KEY_POSITIONS_LABELEDIT_HEIGHT, WindowSize.y, CONFIG_PATH_POSITIONS );
// Unbind Events
m_ItemsListBox->Unbind( wxEVT_LISTBOX, &guLabelEditor::OnItemSelected, this );
m_LabelsListBox->Unbind( wxEVT_LISTBOX, &guLabelEditor::OnLabelSelected, this );
m_LabelsListBox->Unbind( wxEVT_CHECKLISTBOX, &guLabelEditor::OnLabelChecked, this );
m_LabelsListBox->Unbind( wxEVT_LISTBOX_DCLICK, &guLabelEditor::OnLabelDoubleClicked, this );
m_AddButton->Unbind( wxEVT_BUTTON, &guLabelEditor::OnAddLabelClicked, this );
m_DelButton->Unbind( wxEVT_BUTTON, &guLabelEditor::OnDelLabelClicked, this );
m_CopyButton->Unbind( wxEVT_BUTTON, &guLabelEditor::OnCopyLabelsClicked, this );
}
// -------------------------------------------------------------------------------- //
void guLabelEditor::ClearCheckedItems( void )
{
int Count = m_Labels.Count();
for( int Index = 0; Index < Count; Index++ )
{
m_LabelsListBox->Check( Index, false );
}
}
// -------------------------------------------------------------------------------- //
void guLabelEditor::CheckLabelItems( const wxArrayInt &checkeditems )
{
if( checkeditems.Count() )
{
int Count = m_Labels.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( checkeditems.Index( m_Labels[ Index ].m_Id ) != wxNOT_FOUND )
{
m_LabelsListBox->Check( Index, true );
}
}
}
}
// -------------------------------------------------------------------------------- //
void guLabelEditor::OnItemSelected( wxCommandEvent &event )
{
m_SelectedItem = event.GetInt();
ClearCheckedItems();
if( m_SelectedItem >= 0 )
{
CheckLabelItems( m_LabelSets->Item( m_SelectedItem ).GetData() );
}
}
// -------------------------------------------------------------------------------- //
void guLabelEditor::OnLabelSelected( wxCommandEvent &event )
{
m_SelectedLabel = event.GetInt();
m_DelButton->Enable( m_SelectedLabel != wxNOT_FOUND );
}
// -------------------------------------------------------------------------------- //
void guLabelEditor::OnLabelChecked( wxCommandEvent &event )
{
m_SelectedLabel = event.GetInt();
m_DelButton->Enable( m_SelectedLabel != wxNOT_FOUND );
if( m_SelectedItem == wxNOT_FOUND )
return;
if( m_LabelsListBox->IsChecked( m_SelectedLabel ) )
{
m_LabelSets->Item( m_SelectedItem ).AddData( m_Labels[ m_SelectedLabel ].m_Id );
}
else
{
m_LabelSets->Item( m_SelectedItem ).DelData( m_Labels[ m_SelectedLabel ].m_Id );
}
}
// -------------------------------------------------------------------------------- //
void guLabelEditor::OnLabelDoubleClicked( wxCommandEvent &event )
{
int LabelIndex = event.GetInt();
if( LabelIndex != wxNOT_FOUND )
{
bool Enabled = m_LabelsListBox->IsChecked( event.GetInt() );
int LabelId = m_Labels[ LabelIndex ].m_Id;
if( Enabled )
{
AddToAllItems( LabelId );
}
else
{
DelToAllItems( LabelId );
}
}
}
// -------------------------------------------------------------------------------- //
void guLabelEditor::OnAddLabelClicked( wxCommandEvent &event )
{
wxTextEntryDialog * EntryDialog = new wxTextEntryDialog( this, _( "Label Name: " ), _( "Please enter the label name" ) );
if( EntryDialog->ShowModal() == wxID_OK )
{
int AddedId;
if( m_IsRadioLabel )
{
AddedId = m_RaDb->AddRadioLabel( EntryDialog->GetValue() );
}
else
{
AddedId = m_Db->AddLabel( EntryDialog->GetValue() );
}
m_LabelsListBox->Append( EntryDialog->GetValue() );
m_Labels.Add( new guListItem( AddedId, EntryDialog->GetValue() ) );
}
EntryDialog->Destroy();
}
// -------------------------------------------------------------------------------- //
void guLabelEditor::OnDelLabelClicked( wxCommandEvent &event )
{
if( m_SelectedLabel != wxNOT_FOUND )
{
if( wxMessageBox( _( "Are you sure to delete the selected labels?" ),
_( "Confirm" ),
wxICON_QUESTION|wxYES_NO|wxNO_DEFAULT, this ) == wxYES )
{
int LabelId = m_Labels[ m_SelectedLabel ].m_Id;
if( m_IsRadioLabel )
{
m_RaDb->DelRadioLabel( LabelId );
}
else
{
m_Db->DelLabel( LabelId );
}
m_LabelsListBox->Delete( m_SelectedLabel );
// Delete the label id from the items enabled labels
DelToAllItems( LabelId );
}
}
}
// -------------------------------------------------------------------------------- //
void guLabelEditor::OnCopyLabelsClicked( wxCommandEvent& event )
{
int Count = m_Labels.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( m_LabelsListBox->IsChecked( Index ) )
{
AddToAllItems( m_Labels[ Index ].m_Id );
}
else
{
DelToAllItems( m_Labels[ Index ].m_Id );
}
}
}
// -------------------------------------------------------------------------------- //
void guLabelEditor::OnIdle( wxIdleEvent &event )
{
guConfig * Config = ( guConfig * ) guConfig::Get();
m_Splitter->SetSashPosition( Config->ReadNum( CONFIG_KEY_POSITIONS_LABELEDIT_SASHPOS, 177, CONFIG_PATH_POSITIONS ) );
m_Splitter->Unbind( wxEVT_IDLE, &guLabelEditor::OnIdle, this );
}
// -------------------------------------------------------------------------------- //
void guLabelEditor::AddToAllItems( const int labelid )
{
int Count = m_LabelSets->Count();
for( int Index = 0; Index < Count; Index++ )
{
if( m_LabelSets->Item( Index ).Index( labelid ) == wxNOT_FOUND )
m_LabelSets->Item( Index ).AddData( labelid );
}
}
// -------------------------------------------------------------------------------- //
void guLabelEditor::DelToAllItems( const int labelid )
{
int Count = m_LabelSets->Count();
for( int Index = 0; Index < Count; Index++ )
{
m_LabelSets->Item( Index ).DelData( labelid );
}
}
}
// -------------------------------------------------------------------------------- //
| 14,207
|
C++
|
.cpp
| 323
| 39.126935
| 190
| 0.611919
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
750,654
|
RoundButton.cpp
|
anonbeat_guayadeque/src/ui/roundbutton/RoundButton.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "RoundButton.h"
#include "Images.h"
#include "Utils.h"
#include <wx/dcclient.h>
namespace Guayadeque {
BEGIN_EVENT_TABLE( guRoundButton, wxControl )
EVT_PAINT( guRoundButton::OnPaint )
EVT_MOUSE_EVENTS( guRoundButton::OnMouseEvents )
END_EVENT_TABLE()
// -------------------------------------------------------------------------------- //
guRoundButton::guRoundButton( wxWindow * parent, const wxImage &image, const wxImage &selimage ) :
wxControl( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE )
{
m_Bitmap = wxBitmap( image );
m_HoverBitmap = wxBitmap( selimage );
m_MouseIsOver = false;
m_IsClicked = false;
CreateRegion();
}
// -------------------------------------------------------------------------------- //
guRoundButton::~guRoundButton()
{
}
// -------------------------------------------------------------------------------- //
void guRoundButton::CreateRegion( void )
{
int Width = m_Bitmap.GetWidth();
int Height = m_Bitmap.GetHeight();
wxBitmap RegBmp( Width, Height );
wxMemoryDC dc;
dc.SelectObject( RegBmp );
dc.SetBackground( *wxWHITE_BRUSH );
dc.Clear();
dc.SetBrush( *wxBLACK_BRUSH );
dc.SetPen( *wxBLACK_PEN );
dc.DrawCircle( Width / 2, Height / 2, wxMin( ( int ) ( Width / 2 ), ( int ) ( Height / 2 ) ) );
dc.SelectObject( wxNullBitmap );
m_Region = wxRegion( RegBmp, *wxWHITE );
}
// -------------------------------------------------------------------------------- //
wxSize guRoundButton::DoGetBestSize( void ) const
{
wxSize RetVal;
RetVal.x = m_Bitmap.GetWidth();
RetVal.y = m_Bitmap.GetHeight();
return RetVal;
}
// -------------------------------------------------------------------------------- //
void guRoundButton::OnPaint( wxPaintEvent &event )
{
wxPaintDC dc( this );
PrepareDC( dc );
dc.SetBackgroundMode( wxTRANSPARENT );
dc.DrawBitmap( IsEnabled() || !m_DisBitmap.IsOk() ?
( m_MouseIsOver ? m_HoverBitmap : m_Bitmap ) : m_DisBitmap,
0 + m_IsClicked, 0 + m_IsClicked, true );
}
// -------------------------------------------------------------------------------- //
void guRoundButton::OnMouseEvents( wxMouseEvent &event )
{
bool NeedPaint = false;
if( m_Region.Contains( event.GetPosition() ) )
{
if( !m_MouseIsOver )
{
m_MouseIsOver = true;
//Refresh();
NeedPaint = true;
}
//guLogMessage( wxT( "Event %i %i %i" ), event.LeftDown(), event.LeftIsDown(), event.LeftUp() );
if( m_IsClicked != event.LeftIsDown() && m_IsClicked != event.RightIsDown() )
{
m_IsClicked = event.LeftIsDown() || event.RightIsDown();
//Refresh();
NeedPaint = true;
}
if( event.LeftUp() || event.RightUp() )
{
// Send Clicked event
wxCommandEvent ClickEvent( event.LeftUp() ? wxEVT_BUTTON : wxEVT_COMMAND_RIGHT_CLICK, GetId() );
ClickEvent.SetEventObject( this );
AddPendingEvent( ClickEvent );
m_IsClicked = false;
m_MouseIsOver = false;
NeedPaint = true;
}
}
else
{
if( m_MouseIsOver )
{
m_MouseIsOver = false;
//Refresh();
NeedPaint = true;
}
if( m_IsClicked )
{
m_IsClicked = false;
//Refresh();
NeedPaint = true;
}
}
if( event.Leaving() )
{
m_IsClicked = false;
m_MouseIsOver = false;
NeedPaint = true;
}
if( NeedPaint )
Refresh();
}
// -------------------------------------------------------------------------------- //
void guRoundButton::SetBitmapLabel( const wxImage &image )
{
m_Bitmap = wxBitmap( image );
Refresh();
}
// -------------------------------------------------------------------------------- //
void guRoundButton::SetBitmapHover( const wxImage &image )
{
m_HoverBitmap = wxBitmap( image );
Refresh();
}
// -------------------------------------------------------------------------------- //
void guRoundButton::SetBitmapDisabled( const wxImage &image )
{
m_DisBitmap = wxBitmap( image );
Refresh();
}
}
// -------------------------------------------------------------------------------- //
| 5,429
|
C++
|
.cpp
| 152
| 30.552632
| 108
| 0.504374
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,655
|
ConfirmExit.cpp
|
anonbeat_guayadeque/src/ui/confirmexit/ConfirmExit.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "ConfirmExit.h"
#include "Images.h"
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
guExitConfirmDlg::guExitConfirmDlg( wxWindow * parent ) :
wxDialog( parent, wxID_ANY, _( "Please confirm" ), wxDefaultPosition, wxSize( -1, 160 ), wxDEFAULT_DIALOG_STYLE )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer * MainSizer = new wxBoxSizer( wxVERTICAL );
MainSizer->Add( 0, 20, 0, wxEXPAND, 5 );
wxBoxSizer * TopSizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticBitmap * ExitBitmap = new wxStaticBitmap( this, wxID_ANY, guImage( guIMAGE_INDEX_exit ), wxDefaultPosition, wxDefaultSize, 0 );
TopSizer->Add( ExitBitmap, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
wxStaticText * MessageString = new wxStaticText( this, wxID_ANY, _("Are you sure you want to exit the application?"), wxDefaultPosition, wxDefaultSize, 0 );
MessageString->Wrap( -1 );
TopSizer->Add( MessageString, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
MainSizer->Add( TopSizer, 0, wxALIGN_CENTER_HORIZONTAL, 5 );
m_AskAgainCheckBox = new wxCheckBox( this, wxID_ANY, _("Don't ask again"), wxDefaultPosition, wxDefaultSize, 0 );
MainSizer->Add( m_AskAgainCheckBox, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
MainSizer->Add( 0, 0, 1, wxEXPAND, 5 );
wxStdDialogButtonSizer * ButtonsSizer = new wxStdDialogButtonSizer();
wxButton * ButtonsSizerOK = new wxButton( this, wxID_OK );
ButtonsSizer->AddButton( ButtonsSizerOK );
wxButton * ButtonsSizerCancel = new wxButton( this, wxID_CANCEL );
ButtonsSizer->AddButton( ButtonsSizerCancel );
ButtonsSizer->SetAffirmativeButton( ButtonsSizerOK );
ButtonsSizer->SetCancelButton( ButtonsSizerCancel );
ButtonsSizer->Realize();
MainSizer->Add( ButtonsSizer, 0, wxALL|wxEXPAND, 5 );
SetSizer( MainSizer );
Layout();
ButtonsSizerCancel->SetDefault();
m_AskAgainCheckBox->SetFocus();
}
// -------------------------------------------------------------------------------- //
guExitConfirmDlg::~guExitConfirmDlg()
{
}
// -------------------------------------------------------------------------------- //
bool guExitConfirmDlg::GetConfirmChecked( void )
{
return m_AskAgainCheckBox->IsChecked();
}
}
// -------------------------------------------------------------------------------- //
| 3,429
|
C++
|
.cpp
| 66
| 48.939394
| 160
| 0.616098
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,656
|
LastFMPanel.cpp
|
anonbeat_guayadeque/src/ui/lastfmpanel/LastFMPanel.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "LastFMPanel.h"
#include "EventCommandIds.h"
#include "Http.h"
#include "Images.h"
#include "MainApp.h"
#include "Settings.h"
#include "ShowImage.h"
#include "TagInfo.h"
#include "Utils.h"
#include "AuiNotebook.h"
#include "OnlineLinks.h"
#include "PlayListAppend.h"
#include "MainFrame.h"
#include <wx/arrimpl.cpp>
#include "wx/clipbrd.h"
#include <wx/statline.h>
#include <wx/uri.h>
namespace Guayadeque {
#define GULASTFM_TITLE_FONT_SIZE 12
#define GULASTFM_DOWNLOAD_IMAGE_DELAY 10
WX_DEFINE_OBJARRAY( guLastFMInfoArray )
WX_DEFINE_OBJARRAY( guLastFMSimilarArtistInfoArray )
WX_DEFINE_OBJARRAY( guLastFMTrackInfoArray )
WX_DEFINE_OBJARRAY( guLastFMAlbumInfoArray )
WX_DEFINE_OBJARRAY( guLastFMTopTrackInfoArray )
// -------------------------------------------------------------------------------- //
guHtmlWindow::guHtmlWindow( wxWindow * parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style ) :
wxHtmlWindow( parent, id, pos, size, style )
{
Bind( wxEVT_SIZE, &guHtmlWindow::OnChangedSize, this );
Bind( wxEVT_MENU, &guHtmlWindow::OnScrollTo, this, guEVT_USER_FIRST );
}
// -------------------------------------------------------------------------------- //
guHtmlWindow::~guHtmlWindow()
{
Unbind( wxEVT_SIZE, &guHtmlWindow::OnChangedSize, this );
Unbind( wxEVT_MENU, &guHtmlWindow::OnScrollTo, this, guEVT_USER_FIRST );
}
// -------------------------------------------------------------------------------- //
void guHtmlWindow::OnScrollTo( wxCommandEvent &event )
{
//guLogMessage( wxT( "Need to scroll to %i, %i" ), event.GetInt(), event.GetExtraLong() );
Scroll( event.GetInt(), event.GetExtraLong() );
}
// -------------------------------------------------------------------------------- //
void guHtmlWindow::OnChangedSize( wxSizeEvent &event )
{
//wxSize Size = event.GetSize();
//wxSize ClientSize = GetClientSize();
int ScrollX;
int ScrollY;
CalcUnscrolledPosition( 0, 0, &ScrollX, &ScrollY );
//guLogMessage( wxT( "Initial position : %i, %i" ), ScrollX, ScrollY );
wxHtmlWindow::OnSize( event );
if( ScrollX || ScrollY )
{
//guLogMessage( wxT( "Setting position to %i, %i" ), ScrollX, ScrollY );
wxCommandEvent SizeEvent( wxEVT_MENU, guEVT_USER_FIRST );
SizeEvent.SetInt( ScrollX / wxHTML_SCROLL_STEP );
SizeEvent.SetExtraLong( ScrollY / wxHTML_SCROLL_STEP );
AddPendingEvent( SizeEvent );
}
}
// -------------------------------------------------------------------------------- //
// guLastFMInfoCtrl
// -------------------------------------------------------------------------------- //
guLastFMInfoCtrl::guLastFMInfoCtrl( wxWindow * parent, guDbLibrary * db, guDbCache * dbcache, guPlayerPanel * playerpanel, bool createcontrols ) :
wxPanel( parent, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxTAB_TRAVERSAL )
{
m_DefaultDb = db;
m_Db = NULL;
m_MediaViewer = NULL;
m_DbCache = dbcache;
m_PlayerPanel = playerpanel;
m_NormalColor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
m_NotFoundColor = wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT );
if( createcontrols )
this->CreateControls( parent );
Bind( wxEVT_MENU, &guLastFMInfoCtrl::OnSearchLinkClicked, this, ID_LINKS_BASE, ID_LINKS_BASE + guLINKS_MAXCOUNT );
Bind( wxEVT_MENU, &guLastFMInfoCtrl::OnSearchLinkClicked, this, ID_LASTFM_VISIT_URL );
Bind( wxEVT_CONTEXT_MENU, &guLastFMInfoCtrl::OnContextMenu, this );
Bind( wxEVT_MENU, &guLastFMInfoCtrl::OnPlayClicked, this, ID_LASTFM_PLAY );
Bind( wxEVT_MENU, &guLastFMInfoCtrl::OnEnqueueClicked, this, ID_LASTFM_ENQUEUE_AFTER_ALL, ID_LASTFM_ENQUEUE_AFTER_ARTIST );
Bind( wxEVT_MENU, &guLastFMInfoCtrl::OnCopyToClipboard, this, ID_LASTFM_COPYTOCLIPBOARD );
Bind( wxEVT_MENU, &guLastFMInfoCtrl::OnSongSelectName, this, ID_TRACKS_SELECTNAME );
Bind( wxEVT_MENU, &guLastFMInfoCtrl::OnArtistSelectName, this, ID_ARTIST_SELECTNAME );
Bind( wxEVT_MENU, &guLastFMInfoCtrl::OnAlbumSelectName, this, ID_ALBUM_SELECTNAME );
Bind( wxEVT_MOTION, &guLastFMInfoCtrl::OnMouse, this );
Bind( wxEVT_ENTER_WINDOW, &guLastFMInfoCtrl::OnMouse, this );
Bind( wxEVT_LEAVE_WINDOW, &guLastFMInfoCtrl::OnMouse, this );
Bind( wxEVT_RIGHT_DOWN, &guLastFMInfoCtrl::OnMouse, this );
}
// -------------------------------------------------------------------------------- //
guLastFMInfoCtrl::~guLastFMInfoCtrl()
{
Unbind( wxEVT_MENU, &guLastFMInfoCtrl::OnSearchLinkClicked, this, ID_LINKS_BASE, ID_LINKS_BASE + guLINKS_MAXCOUNT );
Unbind( wxEVT_MENU, &guLastFMInfoCtrl::OnSearchLinkClicked, this, ID_LASTFM_VISIT_URL );
Unbind( wxEVT_CONTEXT_MENU, &guLastFMInfoCtrl::OnContextMenu, this );
Unbind( wxEVT_MENU, &guLastFMInfoCtrl::OnPlayClicked, this, ID_LASTFM_PLAY );
Unbind( wxEVT_MENU, &guLastFMInfoCtrl::OnEnqueueClicked, this, ID_LASTFM_ENQUEUE_AFTER_ALL, ID_LASTFM_ENQUEUE_AFTER_ARTIST );
Unbind( wxEVT_MENU, &guLastFMInfoCtrl::OnCopyToClipboard, this, ID_LASTFM_COPYTOCLIPBOARD );
Unbind( wxEVT_MENU, &guLastFMInfoCtrl::OnSongSelectName, this, ID_TRACKS_SELECTNAME );
Unbind( wxEVT_MENU, &guLastFMInfoCtrl::OnArtistSelectName, this, ID_ARTIST_SELECTNAME );
Unbind( wxEVT_MENU, &guLastFMInfoCtrl::OnAlbumSelectName, this, ID_ALBUM_SELECTNAME );
Unbind( wxEVT_MOTION, &guLastFMInfoCtrl::OnMouse, this );
Unbind( wxEVT_ENTER_WINDOW, &guLastFMInfoCtrl::OnMouse, this );
Unbind( wxEVT_LEAVE_WINDOW, &guLastFMInfoCtrl::OnMouse, this );
Unbind( wxEVT_RIGHT_DOWN, &guLastFMInfoCtrl::OnMouse, this );
m_Text->Unbind( wxEVT_LEFT_DCLICK, &guLastFMInfoCtrl::OnDoubleClicked, this );
m_Text->Unbind( wxEVT_MOTION, &guLastFMInfoCtrl::OnMouse, this );
m_Text->Unbind( wxEVT_ENTER_WINDOW, &guLastFMInfoCtrl::OnMouse, this );
m_Text->Unbind( wxEVT_LEAVE_WINDOW, &guLastFMInfoCtrl::OnMouse, this );
m_Text->Unbind( wxEVT_RIGHT_DOWN, &guLastFMInfoCtrl::OnMouse, this );
m_Bitmap->Unbind( wxEVT_LEFT_DOWN, &guLastFMInfoCtrl::OnBitmapClicked, this );
}
// -------------------------------------------------------------------------------- //
void guLastFMInfoCtrl::CreateControls( wxWindow * parent )
{
wxBoxSizer* MainSizer;
MainSizer = new wxBoxSizer( wxHORIZONTAL );
m_Bitmap = new wxStaticBitmap( this, wxID_ANY, guImage( guIMAGE_INDEX_default_lastfm_image ),
wxDefaultPosition, wxSize( 50, 50 ), 0 );
//Bitmap->SetCursor( wxCURSOR_HAND );
MainSizer->Add( m_Bitmap, 0, wxALL|wxALIGN_CENTER_VERTICAL, 2 );
m_Text = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 200, -1 ), 0 );
m_Text->Wrap( -1 );
//Text->SetCursor( wxCursor( wxCURSOR_HAND ) );
//m_Text->SetMaxSize( wxSize( 250, -1 ) );
MainSizer->Add( m_Text, 1, wxALL|wxEXPAND, 2 );
SetSizer( MainSizer );
Layout();
MainSizer->Fit( this );
m_Text->Bind( wxEVT_LEFT_DCLICK, &guLastFMInfoCtrl::OnDoubleClicked, this );
m_Text->Bind( wxEVT_MOTION, &guLastFMInfoCtrl::OnMouse, this );
m_Text->Bind( wxEVT_ENTER_WINDOW, &guLastFMInfoCtrl::OnMouse, this );
m_Text->Bind( wxEVT_LEAVE_WINDOW, &guLastFMInfoCtrl::OnMouse, this );
m_Text->Bind( wxEVT_RIGHT_DOWN, &guLastFMInfoCtrl::OnMouse, this );
m_Bitmap->Bind( wxEVT_LEFT_DOWN, &guLastFMInfoCtrl::OnBitmapClicked, this );
}
// -------------------------------------------------------------------------------- //
void guLastFMInfoCtrl::SetMediaViewer( guMediaViewer * mediaviewer )
{
wxMutexLocker Lock( m_DbMutex );
m_MediaViewer = mediaviewer;
m_Db = mediaviewer ? mediaviewer->GetDb() : NULL;
}
// -------------------------------------------------------------------------------- //
void guLastFMInfoCtrl::Clear( guMediaViewer * mediaviewer )
{
m_Bitmap->SetBitmap( guImage( guIMAGE_INDEX_default_lastfm_image ) );
m_Text->SetLabel( wxEmptyString );
//
SetMediaViewer( mediaviewer );
}
// -------------------------------------------------------------------------------- //
void guLastFMInfoCtrl::SetBitmap( const wxImage * image )
{
if( image )
{
m_Bitmap->SetBitmap( wxBitmap( * image ) );
}
else
{
m_Bitmap->SetBitmap( guImage( guIMAGE_INDEX_default_lastfm_image ) );
}
m_Bitmap->Refresh();
}
// -------------------------------------------------------------------------------- //
void guLastFMInfoCtrl::SetLabel( const wxString &label )
{
wxString Label = label;
Label.Replace( wxT( "&" ), wxT( "&&" ) );
m_Text->SetLabel( Label );
// Layout();
}
// -------------------------------------------------------------------------------- //
void guLastFMInfoCtrl::OnContextMenu( wxContextMenuEvent& event )
{
wxMenu Menu;
wxPoint Point = event.GetPosition();
// If from keyboard
if( Point.x == -1 && Point.y == -1 )
{
wxSize Size = GetSize();
Point.x = Size.x / 2;
Point.y = Size.y / 2;
}
else
{
Point = ScreenToClient( Point );
}
CreateContextMenu( &Menu );
PopupMenu( &Menu, Point.x, Point.y );
}
// -------------------------------------------------------------------------------- //
void guLastFMInfoCtrl::CreateContextMenu( wxMenu * Menu )
{
AddOnlineLinksMenu( Menu );
}
// -------------------------------------------------------------------------------- //
void guLastFMInfoCtrl::OnDoubleClicked( wxMouseEvent &event )
{
guTrackArray Tracks;
GetSelectedTracks( &Tracks );
if( Tracks.Count() )
{
guConfig * Config = ( guConfig * ) guConfig::Get();
if( m_PlayerPanel && Config )
{
if( Config->ReadBool( CONFIG_KEY_GENERAL_ACTION_ENQUEUE, false, CONFIG_PATH_GENERAL ) )
{
m_PlayerPanel->AddToPlayList( Tracks );
}
else
{
m_PlayerPanel->SetPlayList( Tracks );
}
}
}
}
// -------------------------------------------------------------------------------- //
void guLastFMInfoCtrl::OnSearchLinkClicked( wxCommandEvent &event )
{
int Index = event.GetId();
if( Index == ID_LASTFM_VISIT_URL )
{
guWebExecute( GetItemUrl() );
}
else
{
ExecuteOnlineLink( Index, GetSearchText() );
}
}
// -------------------------------------------------------------------------------- //
void guLastFMInfoCtrl::OnCopyToClipboard( wxCommandEvent &event )
{
//guLogMessage( wxT( "OnCopyToClipboard : %s" ), GetSearchText().c_str() );
wxTheClipboard->UsePrimarySelection( false );
if( wxTheClipboard->Open() )
{
wxTheClipboard->Clear();
if( !wxTheClipboard->AddData( new wxTextDataObject( GetSearchText() ) ) )
{
guLogError( wxT( "Can't copy data to the clipboard" ) );
}
wxTheClipboard->Close();
}
else
{
guLogError( wxT( "Could not open the clipboard object" ) );
}
}
// -------------------------------------------------------------------------------- //
void guLastFMInfoCtrl::OnPlayClicked( wxCommandEvent &event )
{
guTrackArray Tracks;
GetSelectedTracks( &Tracks );
if( m_PlayerPanel && Tracks.Count() )
{
m_PlayerPanel->SetPlayList( Tracks );
}
}
// -------------------------------------------------------------------------------- //
void guLastFMInfoCtrl::OnEnqueueClicked( wxCommandEvent &event )
{
guTrackArray Tracks;
GetSelectedTracks( &Tracks );
if( m_PlayerPanel && Tracks.Count() )
{
m_PlayerPanel->AddToPlayList( Tracks, true, event.GetId() - ID_LASTFM_ENQUEUE_AFTER_ALL );
}
}
// -------------------------------------------------------------------------------- //
void guLastFMInfoCtrl::OnBitmapClicked( wxMouseEvent &event )
{
wxBitmapType ImageType;
wxString ImageUrl = GetBitmapImageUrl();
if( !ImageUrl.IsEmpty() )
{
wxImage * Image = m_DbCache->GetImage( ImageUrl, ImageType, guDBCACHE_TYPE_IMAGE_SIZE_BIG );
if( Image )
{
guShowImage * ShowImage = new guShowImage( GetParent(), Image, ClientToScreen( m_Bitmap->GetPosition() ) );
if( ShowImage )
{
ShowImage->Show();
}
}
}
}
// -------------------------------------------------------------------------------- //
wxString guLastFMInfoCtrl::GetBitmapImageUrl( void )
{
return wxEmptyString;
}
// -------------------------------------------------------------------------------- //
void guLastFMInfoCtrl::OnMouse( wxMouseEvent &event )
{
//guLogMessage( wxT( "Mouse: %i %i" ), event.m_x, event.m_y );
if( !ItemWasFound() )
{
if( event.Entering() || event.Leaving() || event.RightDown() )
{
wxString LabelText = m_Text->GetLabel();
LabelText.Replace( wxT( "&" ), wxT( "&&" ) );
//guLogMessage( wxT( "Entering..." ) );
m_Text->SetForegroundColour( event.Entering() ? m_NormalColor : m_NotFoundColor );
m_Text->SetLabel( LabelText );
Layout();
}
}
event.Skip();
}
// -------------------------------------------------------------------------------- //
// guArtistInfoCtrl
// -------------------------------------------------------------------------------- //
guArtistInfoCtrl::guArtistInfoCtrl( wxWindow * parent, guDbLibrary * db, guDbCache * dbcache, guPlayerPanel * playerpanel ) :
guLastFMInfoCtrl( parent, db, dbcache, playerpanel, false )
{
m_Info = NULL;
guConfig * Config = ( guConfig * ) guConfig::Get();
m_ShowLongBioText = Config->ReadBool( CONFIG_KEY_LASTFM_SHOW_LONG_BIO, false, CONFIG_PATH_LASTFM );
CreateControls( parent );
m_ShowMoreHyperLink->Bind( wxEVT_HYPERLINK, &guArtistInfoCtrl::OnShowMoreLinkClicked, this );
m_ArtistDetails->Bind( wxEVT_HTML_LINK_CLICKED, &guArtistInfoCtrl::OnHtmlLinkClicked, this );
};
// -------------------------------------------------------------------------------- //
guArtistInfoCtrl::~guArtistInfoCtrl()
{
if( m_Info )
delete m_Info;
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->WriteBool( CONFIG_KEY_LASTFM_SHOW_LONG_BIO, m_ShowLongBioText, CONFIG_PATH_LASTFM );
m_ShowMoreHyperLink->Unbind( wxEVT_HYPERLINK, &guArtistInfoCtrl::OnShowMoreLinkClicked, this );
m_ArtistDetails->Unbind( wxEVT_HTML_LINK_CLICKED, &guArtistInfoCtrl::OnHtmlLinkClicked, this );
m_Text->Unbind( wxEVT_LEFT_DCLICK, &guArtistInfoCtrl::OnDoubleClicked, this );
m_Bitmap->Unbind( wxEVT_LEFT_DOWN, &guArtistInfoCtrl::OnBitmapClicked, this );
}
// -------------------------------------------------------------------------------- //
void guArtistInfoCtrl::CreateControls( wxWindow * parent )
{
m_MainSizer = new wxBoxSizer( wxHORIZONTAL );
m_Bitmap = new wxStaticBitmap( this, wxID_ANY, guImage( guIMAGE_INDEX_no_photo ), wxDefaultPosition, wxSize( 100,100 ), 0 );
m_MainSizer->Add( m_Bitmap, 0, wxALL, 5 );
// wxBoxSizer * DetailSizer;
m_DetailSizer = new wxBoxSizer( wxVERTICAL );
wxSizer * TopSizer = new wxBoxSizer( wxHORIZONTAL );
m_Text = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_Text->Wrap( -1 );
wxFont CurrentFont = wxSystemSettings::GetFont( wxSYS_SYSTEM_FONT );
CurrentFont.SetPointSize( CurrentFont.GetPointSize() + 2 );
CurrentFont.SetWeight( wxFONTWEIGHT_BOLD );
m_Text->SetFont( CurrentFont );
TopSizer->Add( m_Text, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
TopSizer->Add( 0, 0, 1, wxEXPAND, 5 );
m_ShowMoreHyperLink = new wxHyperlinkCtrl( this, wxID_ANY, m_ShowLongBioText ? _( "Less..." ) : _("More..."), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE );
m_ShowMoreHyperLink->SetNormalColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
m_ShowMoreHyperLink->SetVisitedColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
m_ShowMoreHyperLink->SetHoverColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
//m_DetailSizer->Add( m_ShowMoreHyperLink, 0, wxALL|wxALIGN_RIGHT, 5 );
TopSizer->Add( m_ShowMoreHyperLink, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
//m_DetailSizer->Add( m_Text, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_DetailSizer->Add( TopSizer, 0, wxEXPAND, 5 );
m_ArtistDetails = new guHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
m_ArtistDetails->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ) );
CurrentFont.SetPointSize( CurrentFont.GetPointSize() - 2 );
CurrentFont.SetWeight( wxFONTWEIGHT_NORMAL );
m_ArtistDetails->SetFonts( CurrentFont.GetFaceName(), wxEmptyString );
m_ArtistDetails->SetBackgroundColour( m_Text->GetBackgroundColour() );
m_ArtistDetails->SetBorders( 0 );
m_DetailSizer->Add( m_ArtistDetails, 1, wxALL|wxEXPAND, 5 );
m_MainSizer->Add( m_DetailSizer, 1, wxEXPAND, 5 );
SetSizer( m_MainSizer );
Layout();
//MainSizer->Fit( this );
m_Text->Bind( wxEVT_LEFT_DCLICK, &guArtistInfoCtrl::OnDoubleClicked, this );
m_Bitmap->Bind( wxEVT_LEFT_DOWN, &guArtistInfoCtrl::OnBitmapClicked, this );
}
// -------------------------------------------------------------------------------- //
void guArtistInfoCtrl::SetInfo( guLastFMArtistInfo * info )
{
if( m_Info )
delete m_Info;
m_Info = info;
m_DbMutex.Lock();
m_Info->m_ArtistId = m_Db ? m_Db->FindArtist( m_Info->m_Artist->m_Name ) :
m_DefaultDb->FindArtist( m_Info->m_Artist->m_Name );
m_DbMutex.Unlock();
m_Text->SetForegroundColour( m_Info->m_ArtistId == wxNOT_FOUND ?
m_NotFoundColor : m_NormalColor );
SetBitmap( m_Info->m_Image );
SetLabel( m_Info->m_Artist->m_Name );
UpdateArtistInfoText();
}
// -------------------------------------------------------------------------------- //
void guArtistInfoCtrl::SetMediaViewer( guMediaViewer * mediaviewer )
{
wxMutexLocker Lock( m_DbMutex );
m_MediaViewer = mediaviewer;
m_Db = mediaviewer ? mediaviewer->GetDb() : NULL;
if( m_Info )
{
m_Info->m_ArtistId = wxNOT_FOUND;
m_Text->SetForegroundColour( m_NotFoundColor );
}
}
// -------------------------------------------------------------------------------- //
void guArtistInfoCtrl::Clear( guMediaViewer * mediaviewer )
{
m_Bitmap->SetBitmap( guImage( guIMAGE_INDEX_no_photo ) );
m_Text->SetLabel( wxEmptyString );
if( m_Info )
delete m_Info;
m_Info = NULL;
SetMediaViewer( mediaviewer );
UpdateArtistInfoText();
}
// -------------------------------------------------------------------------------- //
void guArtistInfoCtrl::SetBitmap( const wxImage * image )
{
if( image )
{
m_Bitmap->SetBitmap( wxBitmap( * image ) );
}
else
{
m_Bitmap->SetBitmap( guImage( guIMAGE_INDEX_no_photo ) );
}
m_Bitmap->Refresh();
}
// -------------------------------------------------------------------------------- //
wxString guArtistInfoCtrl::GetSearchText( void )
{
return m_Info->m_Artist->m_Name;
}
// -------------------------------------------------------------------------------- //
wxString guArtistInfoCtrl::GetItemUrl( void )
{
return m_Info->m_Artist->m_Url;
}
// -------------------------------------------------------------------------------- //
void guArtistInfoCtrl::CreateContextMenu( wxMenu * Menu )
{
wxMenuItem * MenuItem;
if( m_Info->m_ArtistId != wxNOT_FOUND )
{
//guLogMessage( wxT( "The artist id = %i" ), m_Info->m_ArtistId );
MenuItem = new wxMenuItem( Menu, ID_LASTFM_PLAY, _( "Play" ), _( "Play the artist tracks" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_player_tiny_light_play ) );
Menu->Append( MenuItem );
MenuItem = new wxMenuItem( Menu, ID_LASTFM_ENQUEUE_AFTER_ALL, _( "Enqueue" ), _( "Enqueue the artist tracks to the playlist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
Menu->Append( MenuItem );
wxMenu * EnqueueMenu = new wxMenu();
MenuItem = new wxMenuItem( EnqueueMenu, ID_LASTFM_ENQUEUE_AFTER_TRACK,
wxString( _( "Current Track" ) ),
_( "Add current selected tracks to playlist after the current track" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem = new wxMenuItem( EnqueueMenu, ID_LASTFM_ENQUEUE_AFTER_ALBUM,
wxString( _( "Current Album" ) ),
_( "Add current selected tracks to playlist after the current album" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem = new wxMenuItem( EnqueueMenu, ID_LASTFM_ENQUEUE_AFTER_ARTIST,
wxString( _( "Current Artist" ) ),
_( "Add current selected tracks to playlist after the current artist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
Menu->Append( wxID_ANY, _( "Enqueue After" ), EnqueueMenu );
Menu->AppendSeparator();
if( m_MediaViewer )
{
MenuItem = new wxMenuItem( Menu, ID_ARTIST_SELECTNAME, _( "Search Artist" ), _( "Search the artist in the library" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_search ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
}
}
if( !GetSearchText().IsEmpty() )
{
MenuItem = new wxMenuItem( Menu, ID_LASTFM_COPYTOCLIPBOARD, _( "Copy to Clipboard" ), _( "Copy the artist name to clipboard" ) );
//MenuItem->SetBitmap( guImage( guIMAGE_INDEX_edit_copy ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
}
if( !m_Info->m_Artist->m_Url.IsEmpty() )
{
MenuItem = new wxMenuItem( Menu, ID_LASTFM_VISIT_URL, wxT( "Last.fm" ), _( "Visit last.fm page for this item" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_lastfm_as_on ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
}
guLastFMInfoCtrl::CreateContextMenu( Menu );
}
// -------------------------------------------------------------------------------- //
void guArtistInfoCtrl::OnContextMenu( wxContextMenuEvent& event )
{
// If the item have not been set we do nothing
if( !m_Info )
return;
guLastFMInfoCtrl::OnContextMenu( event );
}
// -------------------------------------------------------------------------------- //
void guArtistInfoCtrl::UpdateArtistInfoText( void )
{
wxString Content;
if( !m_Info )
{
Content = _( "There is no information available for this artist." );
}
else
{
Content = m_ShowLongBioText ? m_Info->m_Artist->m_BioContent.c_str() :
m_Info->m_Artist->m_BioSummary.c_str();
}
//guLogMessage( wxT( "HTML:\n%s\n" ), Content.c_str() );
while( Content.EndsWith( wxT( "\n" ) ) )
{
Content.Truncate( 1 );
}
Content.Replace( wxT( "\n" ), wxT( "<br>" ) );
wxString DetailsContent = wxT( "<html><body style=\"background-color: " ) +
m_Text->GetBackgroundColour().GetAsString( wxC2S_CSS_SYNTAX ) +
wxT( "; color: " ) +
wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ).GetAsString( wxC2S_CSS_SYNTAX ) +
wxT( "; a:link " ) +
wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ).GetAsString( wxC2S_CSS_SYNTAX ) +
wxT( ";\">" ) +
Content +
wxT( "</body></html>" );
m_ArtistDetails->SetPage( DetailsContent );
wxSize Size; // = wxDefaultSize; //ArtistDetails->GetSize();
wxHtmlContainerCell * Cell = m_ArtistDetails->GetInternalRepresentation();
Size.SetHeight( Cell->GetHeight() + 15 ); // This makes the scroll bar to not appear if not needed
Size.SetWidth( 100 );
if( Size.y > 300 )
{
Size.SetHeight( 300 );
}
m_ArtistDetails->SetMinSize( Size );
//guLogMessage( wxT( "*Size : %i - %i" ), Size.x, Size.y );
m_DetailSizer->Fit( m_ArtistDetails );
//Size = ArtistDetails->GetMinSize();
//guLogMessage( wxT( " Size : %i - %i" ), Size.x, Size.y );
///////// MainSizer->FitInside( this );
//DetailSizer->Layout();
Layout();
( ( guLastFMPanel * ) GetParent() )->UpdateLayout();
}
// -------------------------------------------------------------------------------- //
void guArtistInfoCtrl::OnShowMoreLinkClicked( wxHyperlinkEvent &event )
{
//guLogMessage( wxT( "OnShowMoreLinkClicked" ) );
m_ShowLongBioText = !m_ShowLongBioText;
m_ShowMoreHyperLink->SetLabel( m_ShowLongBioText ? _( "Less..." ) : _( "More..." ) );
UpdateArtistInfoText();
}
// -------------------------------------------------------------------------------- //
void guArtistInfoCtrl::OnHtmlLinkClicked( wxHtmlLinkEvent& event )
{
//guLogMessage( wxT( "OnHtmlLinkClicked" ) );
wxHtmlLinkInfo LinkInfo = event.GetLinkInfo();
//wxLaunchDefaultBrowser( LinkInfo.GetHref() );
guWebExecute( LinkInfo.GetHref().c_str() );
}
// -------------------------------------------------------------------------------- //
int guArtistInfoCtrl::GetSelectedTracks( guTrackArray * tracks )
{
if( m_Info->m_ArtistId != wxNOT_FOUND )
{
wxArrayInt Selections;
Selections.Add( m_Info->m_ArtistId );
wxMutexLocker Lock( m_DbMutex );
return m_Db ? m_Db->GetArtistsSongs( Selections, tracks ) :
m_DefaultDb->GetArtistsSongs( Selections, tracks );
}
return 0;
}
// -------------------------------------------------------------------------------- //
void guArtistInfoCtrl::OnArtistSelectName( wxCommandEvent &event )
{
if( m_MediaViewer )
{
wxCommandEvent evt( wxEVT_MENU, ID_MAINFRAME_SELECT_ARTIST );
evt.SetInt( m_Info->m_ArtistId );
evt.SetExtraLong( guTRACK_TYPE_DB );
evt.SetClientData( m_MediaViewer );
wxPostEvent( m_MediaViewer, evt );
}
}
// -------------------------------------------------------------------------------- //
void guArtistInfoCtrl::OnCopyToClipboard( wxCommandEvent &event )
{
if( !m_Info || !m_Info->m_Artist )
return;
wxTheClipboard->UsePrimarySelection( false );
if( wxTheClipboard->Open() )
{
wxTheClipboard->Clear();
wxString CopyText = m_ArtistDetails->SelectionToText();
if( CopyText.IsEmpty() )
{
CopyText = m_Info->m_Artist->m_Name + wxT( "\n" ) +
( m_ShowLongBioText ? m_Info->m_Artist->m_BioContent :
m_Info->m_Artist->m_BioSummary );
}
if( !wxTheClipboard->AddData( new wxTextDataObject( CopyText ) ) )
{
guLogError( wxT( "Can't copy data to the clipboard" ) );
}
wxTheClipboard->Close();
}
else
{
guLogError( wxT( "Could not open the clipboard object" ) );
}
}
// -------------------------------------------------------------------------------- //
// guAlbumInfoCtrl
// -------------------------------------------------------------------------------- //
guAlbumInfoCtrl::guAlbumInfoCtrl( wxWindow * parent, guDbLibrary * db, guDbCache * dbcache, guPlayerPanel * playerpanel ) :
guLastFMInfoCtrl( parent, db, dbcache, playerpanel )
{
m_Info = NULL;
};
// -------------------------------------------------------------------------------- //
guAlbumInfoCtrl::~guAlbumInfoCtrl()
{
if( m_Info )
delete m_Info;
}
// -------------------------------------------------------------------------------- //
void guAlbumInfoCtrl::SetInfo( guLastFMAlbumInfo * info )
{
if( m_Info )
delete m_Info;
m_Info = info;
m_DbMutex.Lock();
m_Info->m_AlbumId = m_Db ? m_Db->FindAlbum( m_Info->m_Album->m_Artist, m_Info->m_Album->m_Name ) :
m_DefaultDb->FindAlbum( m_Info->m_Album->m_Artist, m_Info->m_Album->m_Name );
m_DbMutex.Unlock();
m_Text->SetForegroundColour( m_Info->m_AlbumId == wxNOT_FOUND ?
m_NotFoundColor : m_NormalColor );
SetBitmap( m_Info->m_Image );
SetLabel( m_Info->m_Album->m_Name );
}
// -------------------------------------------------------------------------------- //
void guAlbumInfoCtrl::SetMediaViewer( guMediaViewer * mediaviewer )
{
wxMutexLocker Lock( m_DbMutex );
m_MediaViewer = mediaviewer;
m_Db = mediaviewer ? mediaviewer->GetDb() : NULL;
if( m_Info )
{
m_Info->m_AlbumId = wxNOT_FOUND;
m_Text->SetForegroundColour( m_NotFoundColor );
}
}
// -------------------------------------------------------------------------------- //
void guAlbumInfoCtrl::Clear( guMediaViewer * mediaviewer )
{
if( m_Info )
delete m_Info;
m_Info = NULL;
guLastFMInfoCtrl::Clear( mediaviewer );
}
// -------------------------------------------------------------------------------- //
wxString guAlbumInfoCtrl::GetSearchText( void )
{
return wxString::Format( wxT( "%s %s" ), m_Info->m_Album->m_Artist.c_str(), m_Info->m_Album->m_Name.c_str() );
}
// -------------------------------------------------------------------------------- //
wxString guAlbumInfoCtrl::GetItemUrl( void )
{
return m_Info->m_Album->m_Url;
}
// -------------------------------------------------------------------------------- //
void guAlbumInfoCtrl::CreateContextMenu( wxMenu * Menu )
{
wxMenuItem * MenuItem;
if( m_Info->m_AlbumId != wxNOT_FOUND )
{
MenuItem = new wxMenuItem( Menu, ID_LASTFM_PLAY, _( "Play" ), _( "Play the album tracks" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_player_tiny_light_play ) );
Menu->Append( MenuItem );
MenuItem = new wxMenuItem( Menu, ID_LASTFM_ENQUEUE_AFTER_ALL, _( "Enqueue" ), _( "Enqueue the album tracks to the playlist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
Menu->Append( MenuItem );
wxMenu * EnqueueMenu = new wxMenu();
MenuItem = new wxMenuItem( EnqueueMenu, ID_LASTFM_ENQUEUE_AFTER_TRACK,
wxString( _( "Current Track" ) ),
_( "Add current selected tracks to playlist after the current track" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem = new wxMenuItem( EnqueueMenu, ID_LASTFM_ENQUEUE_AFTER_ALBUM,
wxString( _( "Current Album" ) ),
_( "Add current selected tracks to playlist after the current album" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem = new wxMenuItem( EnqueueMenu, ID_LASTFM_ENQUEUE_AFTER_ARTIST,
wxString( _( "Current Artist" ) ),
_( "Add current selected tracks to playlist after the current artist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
Menu->Append( wxID_ANY, _( "Enqueue After" ), EnqueueMenu );
Menu->AppendSeparator();
if( m_MediaViewer )
{
MenuItem = new wxMenuItem( Menu, ID_ALBUM_SELECTNAME, _( "Search Album" ), _( "Search the album in the library" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_search ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
}
}
if( !GetSearchText().IsEmpty() )
{
MenuItem = new wxMenuItem( Menu, ID_LASTFM_COPYTOCLIPBOARD, _( "Copy to Clipboard" ), _( "Copy the album info to clipboard" ) );
//MenuItem->SetBitmap( guImage( guIMAGE_INDEX_edit_copy ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
}
if( !m_Info->m_Album->m_Url.IsEmpty() )
{
MenuItem = new wxMenuItem( Menu, ID_LASTFM_VISIT_URL, wxT( "Last.fm" ), _( "Visit last.fm page for this item" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_lastfm_as_on ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
}
guLastFMInfoCtrl::CreateContextMenu( Menu );
}
// -------------------------------------------------------------------------------- //
void guAlbumInfoCtrl::OnContextMenu( wxContextMenuEvent& event )
{
// If the item have not been set we do nothing
if( !m_Info )
return;
guLastFMInfoCtrl::OnContextMenu( event );
}
// -------------------------------------------------------------------------------- //
int guAlbumInfoCtrl::GetSelectedTracks( guTrackArray * tracks )
{
if( m_Info->m_AlbumId != wxNOT_FOUND )
{
wxArrayInt Selections;
Selections.Add( m_Info->m_AlbumId );
wxMutexLocker Lock( m_DbMutex );
return m_Db ? m_Db->GetAlbumsSongs( Selections, tracks ) :
m_DefaultDb->GetAlbumsSongs( Selections, tracks );
}
return 0;
}
// -------------------------------------------------------------------------------- //
void guAlbumInfoCtrl::OnAlbumSelectName( wxCommandEvent &event )
{
if( m_MediaViewer )
{
wxCommandEvent evt( wxEVT_MENU, ID_MAINFRAME_SELECT_ALBUM );
evt.SetInt( m_Info->m_AlbumId );
evt.SetExtraLong( guTRACK_TYPE_DB );
evt.SetClientData( m_MediaViewer );
wxPostEvent( m_MediaViewer, evt );
}
}
// -------------------------------------------------------------------------------- //
// guSimilarArtistInfoCtrl
// -------------------------------------------------------------------------------- //
guSimilarArtistInfoCtrl::guSimilarArtistInfoCtrl( wxWindow * parent, guDbLibrary * db,
guDbCache * dbcache, guPlayerPanel * playerpanel ) :
guLastFMInfoCtrl( parent, db, dbcache, playerpanel )
{
m_Info = NULL;
Bind( wxEVT_MENU, &guSimilarArtistInfoCtrl::OnSelectArtist, this, ID_LASTFM_SELECT_ARTIST );
}
// -------------------------------------------------------------------------------- //
guSimilarArtistInfoCtrl::~guSimilarArtistInfoCtrl()
{
if( m_Info )
delete m_Info;
Unbind( wxEVT_MENU, &guSimilarArtistInfoCtrl::OnSelectArtist, this, ID_LASTFM_SELECT_ARTIST );
}
// -------------------------------------------------------------------------------- //
void guSimilarArtistInfoCtrl::SetInfo( guLastFMSimilarArtistInfo * info )
{
if( m_Info )
delete m_Info;
m_Info = info;
m_DbMutex.Lock();
m_Info->m_ArtistId = m_Db ? m_Db->FindArtist( m_Info->m_Artist->m_Name ) :
m_DefaultDb->FindArtist( m_Info->m_Artist->m_Name );
m_DbMutex.Unlock();
//guLogMessage( wxT("Artist '%s' id: %i"), Info->Artist->Name.c_str(), Info->ArtistId );
m_Text->SetForegroundColour( m_Info->m_ArtistId == wxNOT_FOUND ?
m_NotFoundColor : m_NormalColor );
SetBitmap( m_Info->m_Image );
double Match;
if( !m_Info->m_Artist->m_Match.ToDouble( &Match ) )
{
m_Info->m_Artist->m_Match.Replace( wxT( "." ), wxT( "," ) );
m_Info->m_Artist->m_Match.ToDouble( &Match );
//guLogError( wxT( "Error converting %s to float" ), m_Info->m_Artist->m_Match.c_str() );
}
SetLabel( wxString::Format( wxT( "%s\n%i%%" ), m_Info->m_Artist->m_Name.c_str(), int( Match * 100 ) ) );
}
// -------------------------------------------------------------------------------- //
void guSimilarArtistInfoCtrl::SetMediaViewer( guMediaViewer * mediaviewer )
{
wxMutexLocker Lock( m_DbMutex );
m_MediaViewer = mediaviewer;
m_Db = mediaviewer ? mediaviewer->GetDb() : NULL;
if( m_Info )
{
m_Info->m_ArtistId = wxNOT_FOUND;
m_Text->SetForegroundColour( m_NotFoundColor );
}
}
// -------------------------------------------------------------------------------- //
void guSimilarArtistInfoCtrl::Clear( guMediaViewer * mediaviewer )
{
if( m_Info )
delete m_Info;
m_Info = NULL;
guLastFMInfoCtrl::Clear( mediaviewer );
}
// -------------------------------------------------------------------------------- //
void guSimilarArtistInfoCtrl::OnSelectArtist( wxCommandEvent &event )
{
guLastFMPanel * LastFMPanel = ( guLastFMPanel * ) GetParent();
LastFMPanel->SetUpdateEnable( false );
guTrackChangeInfo TrackChangeInfo( GetSearchText(), wxEmptyString, LastFMPanel->GetMediaViewer() );
LastFMPanel->AppendTrackChangeInfo( &TrackChangeInfo );
LastFMPanel->ShowCurrentTrack();
}
// -------------------------------------------------------------------------------- //
wxString guSimilarArtistInfoCtrl::GetSearchText( void )
{
return m_Info->m_Artist->m_Name;
}
// -------------------------------------------------------------------------------- //
wxString guSimilarArtistInfoCtrl::GetItemUrl( void )
{
return m_Info->m_Artist->m_Url;
}
// -------------------------------------------------------------------------------- //
void guSimilarArtistInfoCtrl::CreateContextMenu( wxMenu * Menu )
{
wxMenuItem * MenuItem;
if( m_Info->m_ArtistId != wxNOT_FOUND )
{
MenuItem = new wxMenuItem( Menu, ID_LASTFM_PLAY, _( "Play" ), _( "Play the artist tracks" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_player_tiny_light_play ) );
Menu->Append( MenuItem );
MenuItem = new wxMenuItem( Menu, ID_LASTFM_ENQUEUE_AFTER_ALL, _( "Enqueue" ), _( "Enqueue the artist tracks to the playlist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
Menu->Append( MenuItem );
wxMenu * EnqueueMenu = new wxMenu();
MenuItem = new wxMenuItem( EnqueueMenu, ID_LASTFM_ENQUEUE_AFTER_TRACK,
wxString( _( "Current Track" ) ),
_( "Add current selected tracks to playlist after the current track" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem = new wxMenuItem( EnqueueMenu, ID_LASTFM_ENQUEUE_AFTER_ALBUM,
wxString( _( "Current Album" ) ),
_( "Add current selected tracks to playlist after the current album" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem = new wxMenuItem( EnqueueMenu, ID_LASTFM_ENQUEUE_AFTER_ARTIST,
wxString( _( "Current Artist" ) ),
_( "Add current selected tracks to playlist after the current artist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
Menu->Append( wxID_ANY, _( "Enqueue After" ), EnqueueMenu );
Menu->AppendSeparator();
if( m_MediaViewer )
{
MenuItem = new wxMenuItem( Menu, ID_ARTIST_SELECTNAME, _( "Search Artist" ), _( "Search the artist in the library" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_search ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
}
}
if( !GetSearchText().IsEmpty() )
{
MenuItem = new wxMenuItem( Menu, ID_LASTFM_SELECT_ARTIST, _( "Show Artist Info" ), _( "Update the information with the current selected artist" ) );
Menu->Append( MenuItem );
MenuItem = new wxMenuItem( Menu, ID_LASTFM_COPYTOCLIPBOARD, _( "Copy to Clipboard" ), _( "Copy the artist info to clipboard" ) );
//MenuItem->SetBitmap( guImage( guIMAGE_INDEX_edit_copy ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
}
if( !m_Info->m_Artist->m_Url.IsEmpty() )
{
MenuItem = new wxMenuItem( Menu, ID_LASTFM_VISIT_URL, wxT( "Last.fm" ), _( "Visit last.fm page for this item" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_lastfm_as_on ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
}
guLastFMInfoCtrl::CreateContextMenu( Menu );
}
// -------------------------------------------------------------------------------- //
void guSimilarArtistInfoCtrl::OnContextMenu( wxContextMenuEvent& event )
{
// If the item have not been set we do nothing
if( !m_Info )
return;
guLastFMInfoCtrl::OnContextMenu( event );
}
// -------------------------------------------------------------------------------- //
int guSimilarArtistInfoCtrl::GetSelectedTracks( guTrackArray * tracks )
{
if( m_Info->m_ArtistId != wxNOT_FOUND )
{
wxArrayInt Selections;
Selections.Add( m_Info->m_ArtistId );
wxMutexLocker Lock( m_DbMutex );
return m_Db ? m_Db->GetArtistsSongs( Selections, tracks ) :
m_DefaultDb->GetArtistsSongs( Selections, tracks );
}
return 0;
}
// -------------------------------------------------------------------------------- //
void guSimilarArtistInfoCtrl::OnArtistSelectName( wxCommandEvent &event )
{
if( m_MediaViewer )
{
wxCommandEvent evt( wxEVT_MENU, ID_MAINFRAME_SELECT_ARTIST );
evt.SetInt( m_Info->m_ArtistId );
evt.SetExtraLong( guTRACK_TYPE_DB );
evt.SetClientData( m_MediaViewer );
wxPostEvent( m_MediaViewer, evt );
}
}
// -------------------------------------------------------------------------------- //
// guTrackInfoCtrl
// -------------------------------------------------------------------------------- //
guTrackInfoCtrl::guTrackInfoCtrl( wxWindow * parent, guDbLibrary * db, guDbCache * dbcache, guPlayerPanel * playerpanel ) :
guLastFMInfoCtrl( parent, db, dbcache, playerpanel )
{
m_Info = NULL;
Bind( wxEVT_MENU, &guTrackInfoCtrl::OnSelectArtist, this, ID_LASTFM_SELECT_ARTIST );
}
// -------------------------------------------------------------------------------- //
guTrackInfoCtrl::~guTrackInfoCtrl()
{
if( m_Info )
delete m_Info;
Unbind( wxEVT_MENU, &guTrackInfoCtrl::OnSelectArtist, this, ID_LASTFM_SELECT_ARTIST );
}
// -------------------------------------------------------------------------------- //
void guTrackInfoCtrl::SetInfo( guLastFMTrackInfo * info )
{
if( m_Info )
delete m_Info;
m_Info = info;
m_DbMutex.Lock();
guDbLibrary * Db = m_Db ? m_Db : m_DefaultDb;
m_Info->m_TrackId = Db->FindTrack( m_Info->m_Track->m_ArtistName, m_Info->m_Track->m_TrackName );
m_Info->m_ArtistId = Db->FindArtist( m_Info->m_Track->m_ArtistName );
m_DbMutex.Unlock();
m_Text->SetForegroundColour( m_Info->m_TrackId == wxNOT_FOUND ?
m_NotFoundColor : m_NormalColor );
SetBitmap( m_Info->m_Image );
double Match;
if( !m_Info->m_Track->m_Match.ToDouble( &Match ) )
{
m_Info->m_Track->m_Match.Replace( wxT( "." ), wxT( "," ) );
m_Info->m_Track->m_Match.ToDouble( &Match );
//guLogError( wxT( "Error converting %s to float" ), m_Info->m_Track->m_Match.c_str() );
}
SetLabel( wxString::Format( wxT( "%s\n%s\n%i%%" ),
m_Info->m_Track->m_TrackName.c_str(),
m_Info->m_Track->m_ArtistName.c_str(),
int( Match * 100 ) ) );
}
// -------------------------------------------------------------------------------- //
void guTrackInfoCtrl::SetMediaViewer( guMediaViewer * mediaviewer )
{
wxMutexLocker Lock( m_DbMutex );
m_MediaViewer = mediaviewer;
m_Db = mediaviewer ? mediaviewer->GetDb() : NULL;
if( m_Info )
{
m_Info->m_TrackId = wxNOT_FOUND;
m_Info->m_ArtistId = wxNOT_FOUND;
m_Text->SetForegroundColour( m_NotFoundColor );
}
}
// -------------------------------------------------------------------------------- //
void guTrackInfoCtrl::Clear( guMediaViewer * mediaviewer )
{
if( m_Info )
delete m_Info;
m_Info = NULL;
guLastFMInfoCtrl::Clear( mediaviewer );
}
// -------------------------------------------------------------------------------- //
void guTrackInfoCtrl::OnSelectArtist( wxCommandEvent &event )
{
guLastFMPanel * LastFMPanel = ( guLastFMPanel * ) GetParent();
LastFMPanel->SetUpdateEnable( false );
guTrackChangeInfo TrackChangeInfo( m_Info->m_Track->m_ArtistName, wxEmptyString, LastFMPanel->GetMediaViewer() );
LastFMPanel->AppendTrackChangeInfo( &TrackChangeInfo );
LastFMPanel->ShowCurrentTrack();
}
// -------------------------------------------------------------------------------- //
wxString guTrackInfoCtrl::GetSearchText( void )
{
return wxString::Format( wxT( "%s %s" ), m_Info->m_Track->m_ArtistName.c_str(), m_Info->m_Track->m_TrackName.c_str() );
}
// -------------------------------------------------------------------------------- //
wxString guTrackInfoCtrl::GetItemUrl( void )
{
return m_Info->m_Track->m_Url;
}
// -------------------------------------------------------------------------------- //
void guTrackInfoCtrl::CreateContextMenu( wxMenu * Menu )
{
wxMenuItem * MenuItem;
if( m_Info->m_TrackId != wxNOT_FOUND )
{
MenuItem = new wxMenuItem( Menu, ID_LASTFM_PLAY, _( "Play" ), _( "Play the artist tracks" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_player_tiny_light_play ) );
Menu->Append( MenuItem );
MenuItem = new wxMenuItem( Menu, ID_LASTFM_ENQUEUE_AFTER_ALL, _( "Enqueue" ), _( "Enqueue the artist tracks to the playlist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
Menu->Append( MenuItem );
wxMenu * EnqueueMenu = new wxMenu();
MenuItem = new wxMenuItem( EnqueueMenu, ID_LASTFM_ENQUEUE_AFTER_TRACK,
wxString( _( "Current Track" ) ),
_( "Add current selected tracks to playlist after the current track" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem = new wxMenuItem( EnqueueMenu, ID_LASTFM_ENQUEUE_AFTER_ALBUM,
wxString( _( "Current Album" ) ),
_( "Add current selected tracks to playlist after the current album" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem = new wxMenuItem( EnqueueMenu, ID_LASTFM_ENQUEUE_AFTER_ARTIST,
wxString( _( "Current Artist" ) ),
_( "Add current selected tracks to playlist after the current artist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
Menu->Append( wxID_ANY, _( "Enqueue After" ), EnqueueMenu );
Menu->AppendSeparator();
if( m_MediaViewer )
{
MenuItem = new wxMenuItem( Menu, ID_TRACKS_SELECTNAME, _( "Search Track" ), _( "Search the track in the library" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_search ) );
Menu->Append( MenuItem );
MenuItem = new wxMenuItem( Menu, ID_ARTIST_SELECTNAME, _( "Search Artist" ), _( "Search the artist in the library" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_search ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
}
}
if( !GetSearchText().IsEmpty() )
{
MenuItem = new wxMenuItem( Menu, ID_LASTFM_SELECT_ARTIST, _( "Show Artist Info" ), _( "Update the information with the current selected artist" ) );
Menu->Append( MenuItem );
MenuItem = new wxMenuItem( Menu, ID_LASTFM_COPYTOCLIPBOARD, _( "Copy to Clipboard" ), _( "Copy the track info to clipboard" ) );
//MenuItem->SetBitmap( guImage( guIMAGE_INDEX_edit_copy ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
}
if( !m_Info->m_Track->m_Url.IsEmpty() )
{
MenuItem = new wxMenuItem( Menu, ID_LASTFM_VISIT_URL, wxT( "Last.fm" ), _( "Visit last.fm page for this item" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_lastfm_as_on ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
}
guLastFMInfoCtrl::CreateContextMenu( Menu );
}
// -------------------------------------------------------------------------------- //
void guTrackInfoCtrl::OnContextMenu( wxContextMenuEvent& event )
{
// If the item have not been set we do nothing
if( !m_Info )
return;
guLastFMInfoCtrl::OnContextMenu( event );
}
// -------------------------------------------------------------------------------- //
int guTrackInfoCtrl::GetSelectedTracks( guTrackArray * tracks )
{
if( m_Info->m_TrackId != wxNOT_FOUND )
{
wxArrayInt Selections;
Selections.Add( m_Info->m_TrackId );
wxMutexLocker Lock( m_DbMutex );
return m_Db ? m_Db->GetSongs( Selections, tracks ) :
m_DefaultDb->GetSongs( Selections, tracks );
}
return 0;
}
// -------------------------------------------------------------------------------- //
void guTrackInfoCtrl::OnSongSelectName( wxCommandEvent &event )
{
if( m_MediaViewer )
{
wxCommandEvent evt( wxEVT_MENU, ID_MAINFRAME_SELECT_TRACK );
evt.SetInt( m_Info->m_TrackId );
evt.SetExtraLong( guTRACK_TYPE_DB );
evt.SetClientData( m_MediaViewer );
wxPostEvent( m_MediaViewer, evt );
}
}
// -------------------------------------------------------------------------------- //
void guTrackInfoCtrl::OnArtistSelectName( wxCommandEvent &event )
{
if( m_MediaViewer )
{
wxCommandEvent evt( wxEVT_MENU, ID_MAINFRAME_SELECT_ARTIST );
evt.SetInt( m_Info->m_ArtistId );
evt.SetExtraLong( guTRACK_TYPE_DB );
evt.SetClientData( m_MediaViewer );
wxPostEvent( m_MediaViewer, evt );
}
}
// -------------------------------------------------------------------------------- //
// guTopTrackInfoCtrl
// -------------------------------------------------------------------------------- //
guTopTrackInfoCtrl::guTopTrackInfoCtrl( wxWindow * parent, guDbLibrary * db, guDbCache * dbcache, guPlayerPanel * playerpanel ) :
guLastFMInfoCtrl( parent, db, dbcache, playerpanel )
{
m_Info = NULL;
Bind( wxEVT_MENU, &guTopTrackInfoCtrl::OnSelectArtist, this, ID_LASTFM_SELECT_ARTIST );
}
// -------------------------------------------------------------------------------- //
guTopTrackInfoCtrl::~guTopTrackInfoCtrl()
{
if( m_Info )
delete m_Info;
Unbind( wxEVT_MENU, &guTopTrackInfoCtrl::OnSelectArtist, this, ID_LASTFM_SELECT_ARTIST );
}
// -------------------------------------------------------------------------------- //
void guTopTrackInfoCtrl::SetInfo( guLastFMTopTrackInfo * info )
{
if( m_Info )
delete m_Info;
m_Info = info;
m_DbMutex.Lock();
guDbLibrary * Db = m_Db ? m_Db : m_DefaultDb;
m_Info->m_TrackId = Db->FindTrack( m_Info->m_TopTrack->m_ArtistName, m_Info->m_TopTrack->m_TrackName );
m_Info->m_ArtistId = Db->FindArtist( m_Info->m_TopTrack->m_ArtistName );
m_DbMutex.Unlock();
m_Text->SetForegroundColour( m_Info->m_TrackId == wxNOT_FOUND ?
m_NotFoundColor : m_NormalColor );
SetBitmap( m_Info->m_Image );
SetLabel( wxString::Format( _( "%s\n%i plays by %u users" ),
m_Info->m_TopTrack->m_TrackName.c_str(),
m_Info->m_TopTrack->m_PlayCount,
m_Info->m_TopTrack->m_Listeners ) );
}
// -------------------------------------------------------------------------------- //
void guTopTrackInfoCtrl::SetMediaViewer( guMediaViewer * mediaviewer )
{
wxMutexLocker Lock( m_DbMutex );
m_MediaViewer = mediaviewer;
m_Db = mediaviewer ? mediaviewer->GetDb() : NULL;
if( m_Info )
{
m_Info->m_TrackId = wxNOT_FOUND;
m_Info->m_ArtistId = wxNOT_FOUND;
m_Text->SetForegroundColour( m_NotFoundColor );
}
}
// -------------------------------------------------------------------------------- //
void guTopTrackInfoCtrl::Clear( guMediaViewer * mediaviewer )
{
if( m_Info )
delete m_Info;
m_Info = NULL;
guLastFMInfoCtrl::Clear( mediaviewer );
}
// -------------------------------------------------------------------------------- //
void guTopTrackInfoCtrl::OnSelectArtist( wxCommandEvent &event )
{
guLastFMPanel * LastFMPanel = ( guLastFMPanel * ) GetParent();
LastFMPanel->SetUpdateEnable( false );
guTrackChangeInfo TrackChangeInfo( m_Info->m_TopTrack->m_ArtistName, wxEmptyString, LastFMPanel->GetMediaViewer() );
LastFMPanel->AppendTrackChangeInfo( &TrackChangeInfo );
LastFMPanel->ShowCurrentTrack();
}
// -------------------------------------------------------------------------------- //
wxString guTopTrackInfoCtrl::GetSearchText( void )
{
return wxString::Format( wxT( "%s %s" ), m_Info->m_TopTrack->m_ArtistName.c_str(), m_Info->m_TopTrack->m_TrackName.c_str() );
}
// -------------------------------------------------------------------------------- //
wxString guTopTrackInfoCtrl::GetItemUrl( void )
{
return m_Info->m_TopTrack->m_Url;
}
// -------------------------------------------------------------------------------- //
void guTopTrackInfoCtrl::CreateContextMenu( wxMenu * Menu )
{
wxMenuItem * MenuItem;
if( m_Info->m_TrackId != wxNOT_FOUND )
{
MenuItem = new wxMenuItem( Menu, ID_LASTFM_PLAY, _( "Play" ), _( "Play the artist tracks" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_player_tiny_light_play ) );
Menu->Append( MenuItem );
MenuItem = new wxMenuItem( Menu, ID_LASTFM_ENQUEUE_AFTER_ALL, _( "Enqueue" ), _( "Enqueue the artist tracks to the playlist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
Menu->Append( MenuItem );
wxMenu * EnqueueMenu = new wxMenu();
MenuItem = new wxMenuItem( EnqueueMenu, ID_LASTFM_ENQUEUE_AFTER_TRACK,
wxString( _( "Current Track" ) ),
_( "Add current selected tracks to playlist after the current track" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem = new wxMenuItem( EnqueueMenu, ID_LASTFM_ENQUEUE_AFTER_ALBUM,
wxString( _( "Current Album" ) ),
_( "Add current selected tracks to playlist after the current album" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem = new wxMenuItem( EnqueueMenu, ID_LASTFM_ENQUEUE_AFTER_ARTIST,
wxString( _( "Current Artist" ) ),
_( "Add current selected tracks to playlist after the current artist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
Menu->Append( wxID_ANY, _( "Enqueue After" ), EnqueueMenu );
Menu->AppendSeparator();
if( m_MediaViewer )
{
MenuItem = new wxMenuItem( Menu, ID_TRACKS_SELECTNAME, _( "Search Track" ), _( "Search the track in the library" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_search ) );
Menu->Append( MenuItem );
MenuItem = new wxMenuItem( Menu, ID_ARTIST_SELECTNAME, _( "Search Artist" ), _( "Search the artist in the library" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_search ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
}
}
if( !GetSearchText().IsEmpty() )
{
MenuItem = new wxMenuItem( Menu, ID_LASTFM_COPYTOCLIPBOARD, _( "Copy to Clipboard" ), _( "Copy the track info to clipboard" ) );
//MenuItem->SetBitmap( guImage( guIMAGE_INDEX_edit_copy ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
}
if( !m_Info->m_TopTrack->m_Url.IsEmpty() )
{
MenuItem = new wxMenuItem( Menu, ID_LASTFM_VISIT_URL, wxT( "Last.fm" ), _( "Visit last.fm page for this item" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_lastfm_as_on ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
}
guLastFMInfoCtrl::CreateContextMenu( Menu );
}
// -------------------------------------------------------------------------------- //
void guTopTrackInfoCtrl::OnContextMenu( wxContextMenuEvent& event )
{
// If the item have not been set we do nothing
if( !m_Info )
return;
guLastFMInfoCtrl::OnContextMenu( event );
}
// -------------------------------------------------------------------------------- //
int guTopTrackInfoCtrl::GetSelectedTracks( guTrackArray * tracks )
{
if( m_Info->m_TrackId != wxNOT_FOUND )
{
wxArrayInt Selections;
Selections.Add( m_Info->m_TrackId );
wxMutexLocker Lock( m_DbMutex );
return m_Db ? m_Db->GetSongs( Selections, tracks ) :
m_DefaultDb->GetSongs( Selections, tracks );
}
return 0;
}
// -------------------------------------------------------------------------------- //
void guTopTrackInfoCtrl::OnSongSelectName( wxCommandEvent &event )
{
if( m_MediaViewer )
{
wxCommandEvent evt( wxEVT_MENU, ID_MAINFRAME_SELECT_TRACK );
evt.SetInt( m_Info->m_TrackId );
evt.SetExtraLong( guTRACK_TYPE_DB );
evt.SetClientData( m_MediaViewer );
wxPostEvent( m_MediaViewer, evt );
}
}
// -------------------------------------------------------------------------------- //
void guTopTrackInfoCtrl::OnArtistSelectName( wxCommandEvent &event )
{
if( m_MediaViewer )
{
wxCommandEvent evt( wxEVT_MENU, ID_MAINFRAME_SELECT_ARTIST );
evt.SetInt( m_Info->m_ArtistId );
evt.SetExtraLong( guTRACK_TYPE_DB );
evt.SetClientData( m_MediaViewer );
wxPostEvent( m_MediaViewer, evt );
}
}
// -------------------------------------------------------------------------------- //
// guEventInfoCtrl
// -------------------------------------------------------------------------------- //
guEventInfoCtrl::guEventInfoCtrl( wxWindow * parent, guDbLibrary * db, guDbCache * dbcache, guPlayerPanel * playerpanel ) :
guLastFMInfoCtrl( parent, db, dbcache, playerpanel )
{
m_Info = NULL;
}
// -------------------------------------------------------------------------------- //
guEventInfoCtrl::~guEventInfoCtrl()
{
if( m_Info )
delete m_Info;
}
// -------------------------------------------------------------------------------- //
void guEventInfoCtrl::SetInfo( guLastFMEventInfo * info )
{
if( m_Info )
delete m_Info;
m_Info = info;
SetBitmap( m_Info->m_Image );
SetLabel( wxString::Format( wxT( "%s\n%s (%s)\n%s %s" ),
m_Info->m_Event->m_Title.c_str(),
m_Info->m_Event->m_LocationCity.c_str(),
m_Info->m_Event->m_LocationCountry.c_str(),
m_Info->m_Event->m_Date.c_str(),
m_Info->m_Event->m_Time.c_str() ) );
}
// -------------------------------------------------------------------------------- //
void guEventInfoCtrl::Clear( guMediaViewer * mediaviewer )
{
if( m_Info )
delete m_Info;
m_Info = NULL;
guLastFMInfoCtrl::Clear( mediaviewer );
}
// -------------------------------------------------------------------------------- //
wxString guEventInfoCtrl::GetSearchText( void )
{
return m_Info->m_Event->m_Title + wxT( " " ) +
m_Info->m_Event->m_LocationName + wxT( " " ) +
m_Info->m_Event->m_LocationCity + wxT( " " ) +
m_Info->m_Event->m_LocationCountry;
}
// -------------------------------------------------------------------------------- //
wxString guEventInfoCtrl::GetItemUrl( void )
{
return m_Info->m_Event->m_Url;
}
// -------------------------------------------------------------------------------- //
void guEventInfoCtrl::CreateContextMenu( wxMenu * Menu )
{
wxMenuItem * MenuItem;
if( !GetSearchText().IsEmpty() )
{
MenuItem = new wxMenuItem( Menu, ID_LASTFM_COPYTOCLIPBOARD, _( "Copy to Clipboard" ), _( "Copy the event info to clipboard" ) );
//MenuItem->SetBitmap( guImage( guIMAGE_INDEX_edit_copy ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
}
if( !m_Info->m_Event->m_Url.IsEmpty() )
{
MenuItem = new wxMenuItem( Menu, ID_LASTFM_VISIT_URL, wxT( "Last.fm" ), _( "Visit last.fm page for this item" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_lastfm_as_on ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
}
guLastFMInfoCtrl::CreateContextMenu( Menu );
}
// -------------------------------------------------------------------------------- //
void guEventInfoCtrl::OnContextMenu( wxContextMenuEvent& event )
{
// If the item have not been set we do nothing
if( !m_Info )
return;
guLastFMInfoCtrl::OnContextMenu( event );
}
// -------------------------------------------------------------------------------- //
int guEventInfoCtrl::GetSelectedTracks( guTrackArray * tracks )
{
return 0;
}
// -------------------------------------------------------------------------------- //
// guLastFMPanel
// -------------------------------------------------------------------------------- //
guLastFMPanel::guLastFMPanel( wxWindow * Parent, guDbLibrary * db,
guDbCache * dbcache, guPlayerPanel * playerpanel ) :
wxScrolledWindow( Parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL|wxTAB_TRAVERSAL )
{
m_DefaultDb = db;
m_Db = NULL;
m_DbCache = dbcache;
m_PlayerPanel = playerpanel;
m_MediaViewer = NULL;
m_CurrentTrackInfo = wxNOT_FOUND;
m_ShowArtistDetails = true;
m_ShowAlbums = true;
m_ShowTopTracks = true;
m_ShowSimArtists = true;
m_ShowSimTracks = true;
m_ShowEvents = true;
guConfig * Config = ( guConfig * ) guConfig::Get();
if( Config )
{
m_ShowArtistDetails = Config->ReadBool( CONFIG_KEY_LASTFM_SHOW_ARTIST_INFO, true, CONFIG_PATH_LASTFM );
m_ShowAlbums = Config->ReadBool( CONFIG_KEY_LASTFM_SHOW_ALBUMS, true, CONFIG_PATH_LASTFM );
m_ShowTopTracks = Config->ReadBool( CONFIG_KEY_LASTFM_SHOW_TOP_TRACKS, true, CONFIG_PATH_LASTFM );
m_ShowSimArtists = Config->ReadBool( CONFIG_KEY_LASTFM_SHOW_ARTISTS, true, CONFIG_PATH_LASTFM );
m_ShowSimTracks = Config->ReadBool( CONFIG_KEY_LASTFM_SHOW_TRACKS, true, CONFIG_PATH_LASTFM );
m_ShowEvents = Config->ReadBool( CONFIG_KEY_LASTFM_SHOW_EVENTS, true, CONFIG_PATH_LASTFM );
}
m_UpdateEnabled = Config->ReadBool( CONFIG_KEY_LASTFM_FOLLOW_PLAYER, true, CONFIG_PATH_LASTFM );
wxFont CurrentFont = wxSystemSettings::GetFont( wxSYS_SYSTEM_FONT );
m_MainSizer = new wxBoxSizer( wxVERTICAL );
// Manual Artist Editor
wxBoxSizer * EditorSizer;
EditorSizer = new wxBoxSizer( wxHORIZONTAL );
m_UpdateCheckBox = new wxCheckBox( this, wxID_ANY, _( "Follow player" ), wxDefaultPosition, wxDefaultSize, 0 );
m_UpdateCheckBox->SetValue( m_UpdateEnabled );
EditorSizer->Add( m_UpdateCheckBox, 0, wxEXPAND|wxTOP|wxLEFT, 5 );
m_PrevButton = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_left ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_PrevButton->Enable( false );
EditorSizer->Add( m_PrevButton, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT, 5 );
m_NextButton = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_right ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_NextButton->Enable( false );
EditorSizer->Add( m_NextButton, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 5 );
m_ReloadButton = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_reload ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_ReloadButton->Enable( false );
EditorSizer->Add( m_ReloadButton, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
wxStaticText * ArtistStaticText;
ArtistStaticText = new wxStaticText( this, wxID_ANY, _( "Artist:" ), wxDefaultPosition, wxDefaultSize, 0 );
ArtistStaticText->Wrap( -1 );
EditorSizer->Add( ArtistStaticText, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT, 5 );
m_ArtistTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
m_ArtistTextCtrl->Enable( !m_UpdateEnabled );
EditorSizer->Add( m_ArtistTextCtrl, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 );
wxStaticText * TrackStaticText;
TrackStaticText = new wxStaticText( this, wxID_ANY, _( "Track:" ), wxDefaultPosition, wxDefaultSize, 0 );
TrackStaticText->Wrap( -1 );
EditorSizer->Add( TrackStaticText, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT, 5 );
m_TrackTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
m_TrackTextCtrl->Enable( false );
EditorSizer->Add( m_TrackTextCtrl, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 );
m_MainSizer->Add( EditorSizer, 0, wxEXPAND, 5 );
wxStaticLine * TopStaticLine;
TopStaticLine = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
m_MainSizer->Add( TopStaticLine, 0, wxEXPAND | wxALL, 5 );
// Artist Info
wxBoxSizer * ArInfoTitleSizer;
ArInfoTitleSizer = new wxBoxSizer( wxHORIZONTAL );
m_ArtistDetailsStaticText = new wxStaticText( this, wxID_ANY, _("Artist Info"), wxDefaultPosition, wxDefaultSize, 0 );
m_ArtistDetailsStaticText->Wrap( -1 );
CurrentFont.SetPointSize( GULASTFM_TITLE_FONT_SIZE );
CurrentFont.SetWeight( wxFONTWEIGHT_BOLD );
//wxFont( GULASTFM_TITLE_FONT_SIZE, 70, 90, 92, false, wxEmptyString ) );
m_ArtistDetailsStaticText->SetFont( CurrentFont );
ArInfoTitleSizer->Add( m_ArtistDetailsStaticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
wxStaticLine * ArInfoStaticLine = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
ArInfoTitleSizer->Add( ArInfoStaticLine, 1, wxEXPAND | wxALL, 5 );
m_MainSizer->Add( ArInfoTitleSizer, 0, wxEXPAND, 5 );
m_ArtistInfoMainSizer = new wxBoxSizer( wxVERTICAL );
m_ArtistInfoCtrl = new guArtistInfoCtrl( this, m_DefaultDb, m_DbCache, m_PlayerPanel );
m_ArtistInfoMainSizer->Add( m_ArtistInfoCtrl, 1, wxEXPAND, 5 );
m_MainSizer->Add( m_ArtistInfoMainSizer, 0, wxEXPAND, 5 );
if( m_ShowArtistDetails )
m_MainSizer->Show( m_ArtistInfoMainSizer );
else
m_MainSizer->Hide( m_ArtistInfoMainSizer );
m_MainSizer->FitInside( this );
//
// Top Albmus
//
wxBoxSizer* AlTitleSizer;
AlTitleSizer = new wxBoxSizer( wxHORIZONTAL );
m_AlbumsStaticText = new wxStaticText( this, wxID_ANY, _("Top Albums"), wxDefaultPosition, wxDefaultSize, 0 );
m_AlbumsStaticText->Wrap( -1 );
//AlbumsStaticText->SetCursor( wxCURSOR_HAND );
m_AlbumsStaticText->SetFont( CurrentFont ); //wxFont( GULASTFM_TITLE_FONT_SIZE, 70, 90, 92, false, wxEmptyString ) );
AlTitleSizer->Add( m_AlbumsStaticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
wxStaticLine * AlStaticLine = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
AlTitleSizer->Add( AlStaticLine, 1, wxEXPAND | wxALL, 5 );
m_AlbumsRangeLabel = new wxStaticText( this, wxID_ANY, wxT( "0 - 0 / 0" ), wxDefaultPosition, wxDefaultSize, 0 );
m_AlbumsStaticText->Wrap( -1 );
AlTitleSizer->Add( m_AlbumsRangeLabel, 0, wxLEFT|wxTOP|wxBOTTOM, 5 );
m_AlbumsPrevBtn = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_left ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_AlbumsPrevBtn->Enable( false );
AlTitleSizer->Add( m_AlbumsPrevBtn, 0, wxLEFT, 5 );
m_AlbumsNextBtn = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_right ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_AlbumsNextBtn->Enable( false );
AlTitleSizer->Add( m_AlbumsNextBtn, 0, wxRIGHT, 5 );
m_MainSizer->Add( AlTitleSizer, 0, wxEXPAND, 5 );
m_AlbumsSizer = new wxGridSizer( 4, 3, 0, 0 );
for( int index = 0; index < GULASTFMINFO_MAXITEMS; index++ )
{
m_AlbumsInfoCtrls.Add( new guAlbumInfoCtrl( this, m_DefaultDb, m_DbCache, m_PlayerPanel ) );
m_AlbumsSizer->Add( m_AlbumsInfoCtrls[ index ], 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
}
m_MainSizer->Add( m_AlbumsSizer, 0, wxEXPAND, 5 );
SetTopAlbumsVisible();
//
// Top Tracks
//
wxBoxSizer * TopTracksTitleSizer;
TopTracksTitleSizer = new wxBoxSizer( wxHORIZONTAL );
m_TopTracksStaticText = new wxStaticText( this, wxID_ANY, _("Top Tracks"), wxDefaultPosition, wxDefaultSize, 0 );
m_TopTracksStaticText->Wrap( -1 );
m_TopTracksStaticText->SetFont( CurrentFont ); //wxFont( GULASTFM_TITLE_FONT_SIZE, 70, 90, 92, false, wxEmptyString ) );
TopTracksTitleSizer->Add( m_TopTracksStaticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
wxStaticLine * TopTrStaticLine = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
TopTracksTitleSizer->Add( TopTrStaticLine, 1, wxEXPAND | wxALL, 5 );
m_TopTracksRangeLabel = new wxStaticText( this, wxID_ANY, wxT( "0 - 0 / 0" ), wxDefaultPosition, wxDefaultSize, 0 );
m_AlbumsStaticText->Wrap( -1 );
TopTracksTitleSizer->Add( m_TopTracksRangeLabel, 0, wxLEFT|wxTOP|wxBOTTOM, 5 );
m_TopTracksPrevBtn = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_left ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_TopTracksPrevBtn->Enable( false );
TopTracksTitleSizer->Add( m_TopTracksPrevBtn, 0, wxLEFT, 5 );
m_TopTracksNextBtn = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_right ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_TopTracksNextBtn->Enable( false );
TopTracksTitleSizer->Add( m_TopTracksNextBtn, 0, wxRIGHT, 5 );
m_MainSizer->Add( TopTracksTitleSizer, 0, wxEXPAND, 5 );
m_TopTracksSizer = new wxGridSizer( 4, 3, 0, 0 );
for( int index = 0; index < GULASTFMINFO_MAXITEMS; index++ )
{
m_TopTrackInfoCtrls.Add( new guTopTrackInfoCtrl( this, m_DefaultDb, m_DbCache, m_PlayerPanel ) );
m_TopTracksSizer->Add( m_TopTrackInfoCtrls[ index ], 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
}
m_MainSizer->Add( m_TopTracksSizer, 0, wxEXPAND, 5 );
//MainSizer->Add( new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ), 0, wxEXPAND, 5 );
SetTopTracksVisible();
//
// Similar Artists
//
wxBoxSizer* SimArTitleSizer;
SimArTitleSizer = new wxBoxSizer( wxHORIZONTAL );
m_SimArtistsStaticText = new wxStaticText( this, wxID_ANY, _("Similar Artists"), wxDefaultPosition, wxDefaultSize, 0 );
m_SimArtistsStaticText->Wrap( -1 );
m_SimArtistsStaticText->SetFont( CurrentFont ); //wxFont( GULASTFM_TITLE_FONT_SIZE, 70, 90, 92, false, wxEmptyString ) );
SimArTitleSizer->Add( m_SimArtistsStaticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
wxStaticLine * SimArStaticLine = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
SimArTitleSizer->Add( SimArStaticLine, 1, wxEXPAND | wxALL, 5 );
m_SimArtistsRangeLabel = new wxStaticText( this, wxID_ANY, wxT( "0 - 0 / 0" ), wxDefaultPosition, wxDefaultSize, 0 );
m_AlbumsStaticText->Wrap( -1 );
SimArTitleSizer->Add( m_SimArtistsRangeLabel, 0, wxLEFT|wxTOP|wxBOTTOM, 5 );
m_SimArtistsPrevBtn = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_left ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_SimArtistsPrevBtn->Enable( false );
SimArTitleSizer->Add( m_SimArtistsPrevBtn, 0, wxLEFT, 5 );
m_SimArtistsNextBtn = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_right ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_SimArtistsNextBtn->Enable( false );
SimArTitleSizer->Add( m_SimArtistsNextBtn, 0, wxRIGHT, 5 );
m_MainSizer->Add( SimArTitleSizer, 0, wxEXPAND, 5 );
m_SimArtistsSizer = new wxGridSizer( 4, 3, 0, 0 );
for( int index = 0; index < GULASTFMINFO_MAXITEMS; index++ )
{
m_SimArtistsInfoCtrls.Add( new guSimilarArtistInfoCtrl( this, m_DefaultDb, m_DbCache, m_PlayerPanel ) );
m_SimArtistsSizer->Add( m_SimArtistsInfoCtrls[ index ], 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
}
m_MainSizer->Add( m_SimArtistsSizer, 0, wxEXPAND, 5 );
SetSimArtistsVisible();
//
// Similar Tracks
//
wxBoxSizer * SimTracksTitleSizer;
SimTracksTitleSizer = new wxBoxSizer( wxHORIZONTAL );
m_SimTracksStaticText = new wxStaticText( this, wxID_ANY, _("Similar Tracks"), wxDefaultPosition, wxDefaultSize, 0 );
m_SimTracksStaticText->Wrap( -1 );
m_SimTracksStaticText->SetFont( CurrentFont ); //wxFont( GULASTFM_TITLE_FONT_SIZE, 70, 90, 92, false, wxEmptyString ) );
SimTracksTitleSizer->Add( m_SimTracksStaticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
wxStaticLine * SimTrStaticLine = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
SimTracksTitleSizer->Add( SimTrStaticLine, 1, wxEXPAND | wxALL, 5 );
m_SimTracksRangeLabel = new wxStaticText( this, wxID_ANY, wxT( "0 - 0 / 0" ), wxDefaultPosition, wxDefaultSize, 0 );
m_AlbumsStaticText->Wrap( -1 );
SimTracksTitleSizer->Add( m_SimTracksRangeLabel, 0, wxLEFT|wxTOP|wxBOTTOM, 5 );
m_SimTracksPrevBtn = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_left ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_SimTracksPrevBtn->Enable( false );
SimTracksTitleSizer->Add( m_SimTracksPrevBtn, 0, wxLEFT, 5 );
m_SimTracksNextBtn = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_right ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_SimTracksNextBtn->Enable( false );
SimTracksTitleSizer->Add( m_SimTracksNextBtn, 0, wxRIGHT, 5 );
m_MainSizer->Add( SimTracksTitleSizer, 0, wxEXPAND, 5 );
m_SimTracksSizer = new wxGridSizer( 4, 3, 0, 0 );
for( int index = 0; index < GULASTFMINFO_MAXITEMS; index++ )
{
m_SimTracksInfoCtrls.Add( new guTrackInfoCtrl( this, m_DefaultDb, m_DbCache, m_PlayerPanel ) );
m_SimTracksSizer->Add( m_SimTracksInfoCtrls[ index ], 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
}
m_MainSizer->Add( m_SimTracksSizer, 0, wxEXPAND, 5 );
//MainSizer->Add( new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ), 0, wxEXPAND, 5 );
SetSimTracksVisible();
//
// Artist Events
//
wxBoxSizer * EventsTitleSizer;
EventsTitleSizer = new wxBoxSizer( wxHORIZONTAL );
m_EventsStaticText = new wxStaticText( this, wxID_ANY, _( "Events" ), wxDefaultPosition, wxDefaultSize, 0 );
m_EventsStaticText->Wrap( -1 );
m_EventsStaticText->SetFont( CurrentFont ); //wxFont( GULASTFM_TITLE_FONT_SIZE, 70, 90, 92, false, wxEmptyString ) );
EventsTitleSizer->Add( m_EventsStaticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
wxStaticLine * EventsStaticLine = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
EventsTitleSizer->Add( EventsStaticLine, 1, wxEXPAND | wxALL, 5 );
m_EventsRangeLabel = new wxStaticText( this, wxID_ANY, wxT( "0 - 0 / 0" ), wxDefaultPosition, wxDefaultSize, 0 );
m_AlbumsStaticText->Wrap( -1 );
EventsTitleSizer->Add( m_EventsRangeLabel, 0, wxLEFT|wxTOP|wxBOTTOM, 5 );
m_EventsPrevBtn = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_left ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_EventsPrevBtn->Enable( false );
EventsTitleSizer->Add( m_EventsPrevBtn, 0, wxLEFT, 5 );
m_EventsNextBtn = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_right ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_EventsNextBtn->Enable( false );
EventsTitleSizer->Add( m_EventsNextBtn, 0, wxRIGHT, 5 );
m_MainSizer->Add( EventsTitleSizer, 0, wxEXPAND, 5 );
m_EventsSizer = new wxGridSizer( 4, 3, 0, 0 );
for( int index = 0; index < GULASTFMINFO_MAXITEMS; index++ )
{
m_EventsInfoCtrls.Add( new guEventInfoCtrl( this, m_DefaultDb, m_DbCache, m_PlayerPanel ) );
m_EventsSizer->Add( m_EventsInfoCtrls[ index ], 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
}
m_MainSizer->Add( m_EventsSizer, 0, wxEXPAND, 5 );
//MainSizer->Add( new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ), 0, wxEXPAND, 5 );
SetEventsVisible();
this->SetSizer( m_MainSizer );
this->Layout();
SetScrollRate( 21, 21 );
m_ContextMenuObject = NULL;
m_ArtistsUpdateThread = NULL;
m_AlbumsUpdateThread = NULL;
m_TopTracksUpdateThread = NULL;
m_SimTracksUpdateThread = NULL;
m_SimArtistsUpdateThread = NULL;
m_EventsUpdateThread = NULL;
m_AlbumsCount = 0;
m_AlbumsPageStart = 0;
m_TopTracksCount = 0;
m_TopTracksPageStart = 0;
m_SimArtistsCount = 0;
m_SimArtistsPageStart = 0;
m_SimTracksCount = 0;
m_SimTracksPageStart = 0;
SetDropTarget( new guLastFMPanelDropTarget( this ) );
Bind( wxEVT_MENU, &guLastFMPanel::OnUpdateArtistInfo, this, ID_LASTFM_UPDATE_ARTISTINFO );
Bind( wxEVT_MENU, &guLastFMPanel::OnUpdateAlbumItem, this, ID_LASTFM_UPDATE_ALBUMINFO );
Bind( wxEVT_MENU, &guLastFMPanel::OnAlbumsCountUpdated, this, ID_LASTFM_UPDATE_ALBUM_COUNT );
m_AlbumsPrevBtn->Bind( wxEVT_BUTTON, &guLastFMPanel::OnAlbumsPrevClicked, this );
m_AlbumsNextBtn->Bind( wxEVT_BUTTON, &guLastFMPanel::OnAlbumsNextClicked, this );
Bind( wxEVT_MENU, &guLastFMPanel::OnUpdateArtistItem, this, ID_LASTFM_UPDATE_SIMARTIST );
Bind( wxEVT_MENU, &guLastFMPanel::OnSimArtistsCountUpdated, this, ID_LASTFM_UPDATE_SIMARTIST_COUNT );
m_SimArtistsPrevBtn->Bind( wxEVT_BUTTON, &guLastFMPanel::OnSimArtistsPrevClicked, this );
m_SimArtistsNextBtn->Bind( wxEVT_BUTTON, &guLastFMPanel::OnSimArtistsNextClicked, this );
Bind( wxEVT_MENU, &guLastFMPanel::OnUpdateTrackItem, this, ID_LASTFM_UPDATE_SIMTRACK );
Bind( wxEVT_MENU, &guLastFMPanel::OnSimTracksCountUpdated, this, ID_LASTFM_UPDATE_SIMTRACK_COUNT );
m_SimTracksPrevBtn->Bind( wxEVT_BUTTON, &guLastFMPanel::OnSimTracksPrevClicked, this );
m_SimTracksNextBtn->Bind( wxEVT_BUTTON, &guLastFMPanel::OnSimTracksNextClicked, this );
Bind( wxEVT_MENU, &guLastFMPanel::OnUpdateTopTrackItem, this, ID_LASTFM_UPDATE_TOPTRACKS );
Bind( wxEVT_MENU, &guLastFMPanel::OnTopTracksCountUpdated, this, ID_LASTFM_UPDATE_TOPTRACKS_COUNT );
m_TopTracksPrevBtn->Bind( wxEVT_BUTTON, &guLastFMPanel::OnTopTracksPrevClicked, this );
m_TopTracksNextBtn->Bind( wxEVT_BUTTON, &guLastFMPanel::OnTopTracksNextClicked, this );
Bind( wxEVT_MENU, &guLastFMPanel::OnUpdateEventItem, this, ID_LASTFM_UPDATE_EVENTINFO );
Bind( wxEVT_MENU, &guLastFMPanel::OnEventsCountUpdated, this, ID_LASTFM_UPDATE_EVENTS_COUNT );
m_EventsPrevBtn->Bind( wxEVT_BUTTON, &guLastFMPanel::OnEventsPrevClicked, this );
m_EventsNextBtn->Bind( wxEVT_BUTTON, &guLastFMPanel::OnEventsNextClicked, this );
m_ArtistDetailsStaticText->Bind( wxEVT_LEFT_DCLICK, &guLastFMPanel::OnArInfoTitleDClicked, this );
m_UpdateCheckBox->Bind( wxEVT_CHECKBOX, &guLastFMPanel::OnUpdateChkBoxClick, this );
m_PrevButton->Bind( wxEVT_BUTTON, &guLastFMPanel::OnPrevBtnClick, this );
m_NextButton->Bind( wxEVT_BUTTON, &guLastFMPanel::OnNextBtnClick, this );
m_ReloadButton->Bind( wxEVT_BUTTON, &guLastFMPanel::OnReloadBtnClick, this );
m_ArtistTextCtrl->Bind( wxEVT_TEXT, &guLastFMPanel::OnTextUpdated, this );
m_TrackTextCtrl->Bind( wxEVT_TEXT, &guLastFMPanel::OnTextUpdated, this );
m_ArtistTextCtrl->Bind( wxEVT_KEY_DOWN, &guLastFMPanel::OnTextCtrlKeyDown, this );
m_TrackTextCtrl->Bind( wxEVT_KEY_DOWN, &guLastFMPanel::OnTextCtrlKeyDown, this );
m_ArtistTextCtrl->Bind( wxEVT_TEXT_ENTER, &guLastFMPanel::OnSearchSelected, this );
m_TrackTextCtrl->Bind( wxEVT_TEXT_ENTER, &guLastFMPanel::OnSearchSelected, this );
m_AlbumsStaticText->Bind( wxEVT_LEFT_DCLICK, &guLastFMPanel::OnTopAlbumsTitleDClick, this );
m_TopTracksStaticText->Bind( wxEVT_LEFT_DCLICK, &guLastFMPanel::OnTopTracksTitleDClick, this );
m_SimArtistsStaticText->Bind( wxEVT_LEFT_DCLICK, &guLastFMPanel::OnSimArTitleDClick, this );
m_SimTracksStaticText->Bind( wxEVT_LEFT_DCLICK, &guLastFMPanel::OnSimTrTitleDClick, this );
m_EventsStaticText->Bind( wxEVT_LEFT_DCLICK, &guLastFMPanel::OnEventsTitleDClick, this );
m_AlbumsStaticText->Bind( wxEVT_CONTEXT_MENU, &guLastFMPanel::OnContextMenu, this );
m_TopTracksStaticText->Bind( wxEVT_CONTEXT_MENU, &guLastFMPanel::OnContextMenu, this );
m_SimArtistsStaticText->Bind( wxEVT_CONTEXT_MENU, &guLastFMPanel::OnContextMenu, this );
m_SimTracksStaticText->Bind( wxEVT_CONTEXT_MENU, &guLastFMPanel::OnContextMenu, this );
Bind( wxEVT_MENU, &guLastFMPanel::OnPlayClicked, this, ID_LASTFM_PLAY );
Bind( wxEVT_MENU, &guLastFMPanel::OnEnqueueClicked, this, ID_LASTFM_ENQUEUE_AFTER_ALL, ID_LASTFM_ENQUEUE_AFTER_ARTIST );
Bind( wxEVT_MENU, &guLastFMPanel::OnSaveClicked, this, ID_LASTFM_SAVETOPLAYLIST );
Bind( wxEVT_MENU, &guLastFMPanel::OnCopyToClicked, this, ID_COPYTO_BASE, ID_COPYTO_BASE + guCOPYTO_MAXCOUNT );
}
// -------------------------------------------------------------------------------- //
guLastFMPanel::~guLastFMPanel()
{
m_ArtistsUpdateThreadMutex.Lock();
if( m_ArtistsUpdateThread )
{
m_ArtistsUpdateThread->Pause();
m_ArtistsUpdateThread->Delete();
m_ArtistsUpdateThread = NULL;
}
m_ArtistsUpdateThreadMutex.Unlock();
m_AlbumsUpdateThreadMutex.Lock();
if( m_AlbumsUpdateThread )
{
m_AlbumsUpdateThread->Pause();
m_AlbumsUpdateThread->Delete();
m_AlbumsUpdateThread = NULL;
}
m_AlbumsUpdateThreadMutex.Unlock();
m_TopTracksUpdateThreadMutex.Lock();
if( m_TopTracksUpdateThread )
{
m_TopTracksUpdateThread->Pause();
m_TopTracksUpdateThread->Delete();
m_TopTracksUpdateThread = NULL;
}
m_TopTracksUpdateThreadMutex.Unlock();
m_SimTracksUpdateThreadMutex.Lock();
if( m_SimTracksUpdateThread )
{
m_SimTracksUpdateThread->Pause();
m_SimTracksUpdateThread->Delete();
m_SimTracksUpdateThread = NULL;
}
m_SimTracksUpdateThreadMutex.Unlock();
m_SimArtistsUpdateThreadMutex.Lock();
if( m_SimArtistsUpdateThread )
{
m_SimArtistsUpdateThread->Pause();
m_SimArtistsUpdateThread->Delete();
m_SimArtistsUpdateThread = NULL;
}
m_SimArtistsUpdateThreadMutex.Unlock();
m_EventsUpdateThreadMutex.Lock();
if( m_EventsUpdateThread )
{
m_EventsUpdateThread->Pause();
m_EventsUpdateThread->Delete();
m_EventsUpdateThread = NULL;
}
m_EventsUpdateThreadMutex.Unlock();
guConfig * Config = ( guConfig * ) guConfig::Get();
if( Config )
{
Config->WriteBool( CONFIG_KEY_LASTFM_SHOW_ARTIST_INFO, m_ShowArtistDetails, CONFIG_PATH_LASTFM );
Config->WriteBool( CONFIG_KEY_LASTFM_SHOW_ALBUMS, m_ShowAlbums, CONFIG_PATH_LASTFM );
Config->WriteBool( CONFIG_KEY_LASTFM_SHOW_TOP_TRACKS, m_ShowTopTracks, CONFIG_PATH_LASTFM );
Config->WriteBool( CONFIG_KEY_LASTFM_SHOW_ARTISTS, m_ShowSimArtists, CONFIG_PATH_LASTFM );
Config->WriteBool( CONFIG_KEY_LASTFM_SHOW_TRACKS, m_ShowSimTracks, CONFIG_PATH_LASTFM );
Config->WriteBool( CONFIG_KEY_LASTFM_SHOW_EVENTS, m_ShowEvents, CONFIG_PATH_LASTFM );
Config->WriteBool( CONFIG_KEY_LASTFM_FOLLOW_PLAYER, m_UpdateCheckBox->GetValue(), CONFIG_PATH_LASTFM );
}
Unbind( wxEVT_MENU, &guLastFMPanel::OnUpdateArtistInfo, this, ID_LASTFM_UPDATE_ARTISTINFO );
Unbind( wxEVT_MENU, &guLastFMPanel::OnUpdateAlbumItem, this, ID_LASTFM_UPDATE_ALBUMINFO );
Unbind( wxEVT_MENU, &guLastFMPanel::OnAlbumsCountUpdated, this, ID_LASTFM_UPDATE_ALBUM_COUNT );
m_AlbumsPrevBtn->Unbind( wxEVT_BUTTON, &guLastFMPanel::OnAlbumsPrevClicked, this );
m_AlbumsNextBtn->Unbind( wxEVT_BUTTON, &guLastFMPanel::OnAlbumsNextClicked, this );
Unbind( wxEVT_MENU, &guLastFMPanel::OnUpdateArtistItem, this, ID_LASTFM_UPDATE_SIMARTIST );
Unbind( wxEVT_MENU, &guLastFMPanel::OnSimArtistsCountUpdated, this, ID_LASTFM_UPDATE_SIMARTIST_COUNT );
m_SimArtistsPrevBtn->Unbind( wxEVT_BUTTON, &guLastFMPanel::OnSimArtistsPrevClicked, this );
m_SimArtistsNextBtn->Unbind( wxEVT_BUTTON, &guLastFMPanel::OnSimArtistsNextClicked, this );
Unbind( wxEVT_MENU, &guLastFMPanel::OnUpdateTrackItem, this, ID_LASTFM_UPDATE_SIMTRACK );
Unbind( wxEVT_MENU, &guLastFMPanel::OnSimTracksCountUpdated, this, ID_LASTFM_UPDATE_SIMTRACK_COUNT );
m_SimTracksPrevBtn->Unbind( wxEVT_BUTTON, &guLastFMPanel::OnSimTracksPrevClicked, this );
m_SimTracksNextBtn->Unbind( wxEVT_BUTTON, &guLastFMPanel::OnSimTracksNextClicked, this );
Unbind( wxEVT_MENU, &guLastFMPanel::OnUpdateTopTrackItem, this, ID_LASTFM_UPDATE_TOPTRACKS );
Unbind( wxEVT_MENU, &guLastFMPanel::OnTopTracksCountUpdated, this, ID_LASTFM_UPDATE_TOPTRACKS_COUNT );
m_TopTracksPrevBtn->Unbind( wxEVT_BUTTON, &guLastFMPanel::OnTopTracksPrevClicked, this );
m_TopTracksNextBtn->Unbind( wxEVT_BUTTON, &guLastFMPanel::OnTopTracksNextClicked, this );
Unbind( wxEVT_MENU, &guLastFMPanel::OnUpdateEventItem, this, ID_LASTFM_UPDATE_EVENTINFO );
Unbind( wxEVT_MENU, &guLastFMPanel::OnEventsCountUpdated, this, ID_LASTFM_UPDATE_EVENTS_COUNT );
m_EventsPrevBtn->Unbind( wxEVT_BUTTON, &guLastFMPanel::OnEventsPrevClicked, this );
m_EventsNextBtn->Unbind( wxEVT_BUTTON, &guLastFMPanel::OnEventsNextClicked, this );
m_ArtistDetailsStaticText->Unbind( wxEVT_LEFT_DCLICK, &guLastFMPanel::OnArInfoTitleDClicked, this );
m_UpdateCheckBox->Unbind( wxEVT_CHECKBOX, &guLastFMPanel::OnUpdateChkBoxClick, this );
m_PrevButton->Unbind( wxEVT_BUTTON, &guLastFMPanel::OnPrevBtnClick, this );
m_NextButton->Unbind( wxEVT_BUTTON, &guLastFMPanel::OnNextBtnClick, this );
m_ReloadButton->Unbind( wxEVT_BUTTON, &guLastFMPanel::OnReloadBtnClick, this );
m_ArtistTextCtrl->Unbind( wxEVT_TEXT, &guLastFMPanel::OnTextUpdated, this );
m_TrackTextCtrl->Unbind( wxEVT_TEXT, &guLastFMPanel::OnTextUpdated, this );
m_ArtistTextCtrl->Unbind( wxEVT_KEY_DOWN, &guLastFMPanel::OnTextCtrlKeyDown, this );
m_TrackTextCtrl->Unbind( wxEVT_KEY_DOWN, &guLastFMPanel::OnTextCtrlKeyDown, this );
m_ArtistTextCtrl->Unbind( wxEVT_TEXT_ENTER, &guLastFMPanel::OnSearchSelected, this );
m_TrackTextCtrl->Unbind( wxEVT_TEXT_ENTER, &guLastFMPanel::OnSearchSelected, this );
m_AlbumsStaticText->Unbind( wxEVT_LEFT_DCLICK, &guLastFMPanel::OnTopAlbumsTitleDClick, this );
m_TopTracksStaticText->Unbind( wxEVT_LEFT_DCLICK, &guLastFMPanel::OnTopTracksTitleDClick, this );
m_SimArtistsStaticText->Unbind( wxEVT_LEFT_DCLICK, &guLastFMPanel::OnSimArTitleDClick, this );
m_SimTracksStaticText->Unbind( wxEVT_LEFT_DCLICK, &guLastFMPanel::OnSimTrTitleDClick, this );
m_EventsStaticText->Unbind( wxEVT_LEFT_DCLICK, &guLastFMPanel::OnEventsTitleDClick, this );
m_AlbumsStaticText->Unbind( wxEVT_CONTEXT_MENU, &guLastFMPanel::OnContextMenu, this );
m_TopTracksStaticText->Unbind( wxEVT_CONTEXT_MENU, &guLastFMPanel::OnContextMenu, this );
m_SimArtistsStaticText->Unbind( wxEVT_CONTEXT_MENU, &guLastFMPanel::OnContextMenu, this );
m_SimTracksStaticText->Unbind( wxEVT_CONTEXT_MENU, &guLastFMPanel::OnContextMenu, this );
Unbind( wxEVT_MENU, &guLastFMPanel::OnPlayClicked, this, ID_LASTFM_PLAY );
Unbind( wxEVT_MENU, &guLastFMPanel::OnEnqueueClicked, this, ID_LASTFM_ENQUEUE_AFTER_ALL, ID_LASTFM_ENQUEUE_AFTER_ARTIST );
Unbind( wxEVT_MENU, &guLastFMPanel::OnSaveClicked, this, ID_LASTFM_SAVETOPLAYLIST );
Unbind( wxEVT_MENU, &guLastFMPanel::OnCopyToClicked, this, ID_COPYTO_BASE, ID_COPYTO_BASE + guCOPYTO_MAXCOUNT );
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::ShowCurrentTrack( void )
{
m_ArtistName = m_TrackChangeItems[ m_CurrentTrackInfo ].m_ArtistName;
m_TrackName = m_TrackChangeItems[ m_CurrentTrackInfo ].m_TrackName;
m_MediaViewer = m_TrackChangeItems[ m_CurrentTrackInfo ].m_MediaViewer;
m_Db = m_MediaViewer ? m_MediaViewer->GetDb() : NULL;
//guLogMessage( wxT( ">> LastFMPanel:ShowCurrentTrack( '%s', '%s' )" ), m_ArtistName.c_str(), m_TrackName.c_str() );
if( m_LastArtistName != m_ArtistName )
{
m_ArtistsUpdateThreadMutex.Lock();
if( m_ArtistsUpdateThread )
{
m_ArtistsUpdateThread->Pause();
m_ArtistsUpdateThread->Delete();
m_ArtistsUpdateThread = NULL;
}
m_AlbumsUpdateThreadMutex.Lock();
if( m_AlbumsUpdateThread )
{
m_AlbumsUpdateThread->Pause();
m_AlbumsUpdateThread->Delete();
m_AlbumsUpdateThread = NULL;
}
m_TopTracksUpdateThreadMutex.Lock();
if( m_TopTracksUpdateThread )
{
m_TopTracksUpdateThread->Pause();
m_TopTracksUpdateThread->Delete();
m_TopTracksUpdateThread = NULL;
}
m_SimArtistsUpdateThreadMutex.Lock();
if( m_SimArtistsUpdateThread )
{
m_SimArtistsUpdateThread->Pause();
m_SimArtistsUpdateThread->Delete();
m_SimArtistsUpdateThread = NULL;
}
m_EventsUpdateThreadMutex.Lock();
if( m_EventsUpdateThread )
{
m_EventsUpdateThread->Pause();
m_EventsUpdateThread->Delete();
m_EventsUpdateThread = NULL;
}
// Clear the LastFM controls to default values
m_ArtistInfoCtrl->Clear( m_MediaViewer );
for( int index = 0; index < GULASTFMINFO_MAXITEMS; index++ )
{
m_AlbumsInfoCtrls[ index ]->Clear( m_MediaViewer );
m_TopTrackInfoCtrls[ index ]->Clear( m_MediaViewer );
m_SimArtistsInfoCtrls[ index ]->Clear( m_MediaViewer );
m_EventsInfoCtrls[ index ]->Clear( m_MediaViewer );
}
m_AlbumsCount = 0;
m_AlbumsPageStart = 0;
m_AlbumsPrevBtn->Enable( false );
m_AlbumsNextBtn->Enable( false );
UpdateAlbumsRangeLabel();
m_TopTracksCount = 0;
m_TopTracksPageStart = 0;
m_TopTracksPrevBtn->Enable( false );
m_TopTracksNextBtn->Enable( false );
UpdateTopTracksRangeLabel();
m_SimArtistsCount = 0;
m_SimArtistsPageStart = 0;
m_SimArtistsPrevBtn->Enable( false );
m_SimArtistsNextBtn->Enable( false );
UpdateSimArtistsRangeLabel();
m_EventsCount = 0;
m_EventsPageStart = 0;
m_EventsPrevBtn->Enable( false );
m_EventsNextBtn->Enable( false );
UpdateEventsRangeLabel();
m_LastArtistName = m_ArtistName;
if( !m_ArtistName.IsEmpty() )
{
m_ArtistsUpdateThread = new guFetchArtistInfoThread( this, m_DbCache, m_ArtistName.c_str() );
m_AlbumsUpdateThread = new guFetchAlbumInfoThread( this, m_DbCache, m_ArtistName.c_str(), m_AlbumsPageStart );
m_TopTracksUpdateThread = new guFetchTopTracksInfoThread( this, m_DbCache, m_ArtistName.c_str(), m_TopTracksPageStart );
m_SimArtistsUpdateThread = new guFetchSimilarArtistInfoThread( this, m_DbCache, m_ArtistName.c_str(), m_TopTracksPageStart );
m_EventsUpdateThread = new guFetchEventsInfoThread( this, m_DbCache, m_ArtistName.c_str(), m_EventsPageStart );
}
m_ArtistTextCtrl->SetValue( m_ArtistName );
m_EventsUpdateThreadMutex.Unlock();
m_SimArtistsUpdateThreadMutex.Unlock();
m_TopTracksUpdateThreadMutex.Unlock();
m_AlbumsUpdateThreadMutex.Unlock();
m_ArtistsUpdateThreadMutex.Unlock();
}
if( m_LastTrackName != m_TrackName )
{
m_SimTracksUpdateThreadMutex.Lock();
if( m_SimTracksUpdateThread )
{
m_SimTracksUpdateThread->Pause();
m_SimTracksUpdateThread->Delete();
m_SimTracksUpdateThread = NULL;
}
for( int index = 0; index < GULASTFMINFO_MAXITEMS; index++ )
{
m_SimTracksInfoCtrls[ index ]->Clear( m_MediaViewer );
}
m_SimTracksCount = 0;
m_SimTracksPageStart = 0;
m_SimTracksPrevBtn->Enable( false );
m_SimTracksNextBtn->Enable( false );
UpdateSimTracksRangeLabel();
m_LastTrackName = m_TrackName;
if( !m_ArtistName.IsEmpty() && !m_TrackName.IsEmpty() )
{
m_SimTracksUpdateThread = new guFetchSimTracksInfoThread( this, m_DbCache,
m_ArtistName.c_str(), m_TrackName.c_str(), m_SimTracksPageStart );
}
m_TrackTextCtrl->SetValue( m_TrackName );
m_SimTracksUpdateThreadMutex.Unlock();
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::UpdateAlbumsRangeLabel( void )
{
if( m_AlbumsCount )
{
int StartAlbumIndex = m_AlbumsPageStart * GULASTFMINFO_MAXITEMS;
m_AlbumsRangeLabel->SetLabel( wxString::Format( wxT( "%i - %i / %i" ),
StartAlbumIndex + 1,
wxMin( StartAlbumIndex + GULASTFMINFO_MAXITEMS, m_AlbumsCount ),
m_AlbumsCount ) );
}
else
{
m_AlbumsRangeLabel->SetLabel( wxT( "0 - 0 / 0"));
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnAlbumsCountUpdated( wxCommandEvent &event )
{
m_AlbumsCount = event.GetInt();
UpdateAlbumsRangeLabel();
m_AlbumsPrevBtn->Enable( m_AlbumsPageStart );
m_AlbumsNextBtn->Enable( ( ( m_AlbumsPageStart + 1 ) * GULASTFMINFO_MAXITEMS ) < m_AlbumsCount );
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnAlbumsPrevClicked( wxCommandEvent &event )
{
if( m_AlbumsPageStart )
{
m_AlbumsUpdateThreadMutex.Lock();
if( m_AlbumsUpdateThread )
{
m_AlbumsUpdateThread->Pause();
m_AlbumsUpdateThread->Delete();
m_AlbumsUpdateThread = NULL;
}
m_AlbumsPageStart--;
m_AlbumsPrevBtn->Enable( m_AlbumsPageStart );
m_AlbumsNextBtn->Enable( ( ( m_AlbumsPageStart + 1 ) * GULASTFMINFO_MAXITEMS ) < m_AlbumsCount );
for( int index = 0; index < GULASTFMINFO_MAXITEMS; index++ )
{
m_AlbumsInfoCtrls[ index ]->Clear( m_MediaViewer );
}
m_AlbumsUpdateThread = new guFetchAlbumInfoThread( this, m_DbCache, m_ArtistName.c_str(), m_AlbumsPageStart );
m_AlbumsUpdateThreadMutex.Unlock();
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnAlbumsNextClicked( wxCommandEvent &event )
{
if( ( ( m_AlbumsPageStart + 1 ) * GULASTFMINFO_MAXITEMS ) < m_AlbumsCount )
{
m_AlbumsUpdateThreadMutex.Lock();
if( m_AlbumsUpdateThread )
{
m_AlbumsUpdateThread->Pause();
m_AlbumsUpdateThread->Delete();
m_AlbumsUpdateThread = NULL;
}
m_AlbumsPageStart++;
m_AlbumsPrevBtn->Enable( m_AlbumsPageStart );
m_AlbumsNextBtn->Enable( ( ( m_AlbumsPageStart + 1 ) * GULASTFMINFO_MAXITEMS ) < m_AlbumsCount );
for( int index = 0; index < GULASTFMINFO_MAXITEMS; index++ )
{
m_AlbumsInfoCtrls[ index ]->Clear( m_MediaViewer );
}
m_AlbumsUpdateThread = new guFetchAlbumInfoThread( this, m_DbCache, m_ArtistName.c_str(), m_AlbumsPageStart );
m_AlbumsUpdateThreadMutex.Unlock();
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::UpdateTopTracksRangeLabel( void )
{
if( m_TopTracksCount )
{
int StartIndex = m_TopTracksPageStart * GULASTFMINFO_MAXITEMS;
m_TopTracksRangeLabel->SetLabel( wxString::Format( wxT( "%i - %i / %i" ),
StartIndex + 1,
wxMin( StartIndex + GULASTFMINFO_MAXITEMS, m_TopTracksCount ),
m_TopTracksCount ) );
}
else
{
m_TopTracksRangeLabel->SetLabel( wxT( "0 - 0 / 0"));
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnTopTracksCountUpdated( wxCommandEvent &event )
{
m_TopTracksCount = event.GetInt();
UpdateTopTracksRangeLabel();
m_TopTracksPrevBtn->Enable( m_TopTracksPageStart );
m_TopTracksNextBtn->Enable( ( ( m_TopTracksPageStart + 1 ) * GULASTFMINFO_MAXITEMS ) < m_TopTracksCount );
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnTopTracksPrevClicked( wxCommandEvent &event )
{
if( m_TopTracksPageStart )
{
m_TopTracksUpdateThreadMutex.Lock();
if( m_TopTracksUpdateThread )
{
m_TopTracksUpdateThread->Pause();
m_TopTracksUpdateThread->Delete();
m_TopTracksUpdateThread = NULL;
}
m_TopTracksPageStart--;
m_TopTracksPrevBtn->Enable( m_TopTracksPageStart );
m_TopTracksNextBtn->Enable( ( ( m_TopTracksPageStart + 1 ) * GULASTFMINFO_MAXITEMS ) < m_TopTracksCount );
for( int index = 0; index < GULASTFMINFO_MAXITEMS; index++ )
{
m_TopTrackInfoCtrls[ index ]->Clear( m_MediaViewer );
}
m_TopTracksUpdateThread = new guFetchTopTracksInfoThread( this, m_DbCache, m_ArtistName.c_str(), m_TopTracksPageStart );
m_TopTracksUpdateThreadMutex.Unlock();
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnTopTracksNextClicked( wxCommandEvent &event )
{
if( ( ( m_TopTracksPageStart + 1 ) * GULASTFMINFO_MAXITEMS ) < m_TopTracksCount )
{
m_TopTracksUpdateThreadMutex.Lock();
if( m_TopTracksUpdateThread )
{
m_TopTracksUpdateThread->Pause();
m_TopTracksUpdateThread->Delete();
m_TopTracksUpdateThread = NULL;
}
m_TopTracksPageStart++;
m_TopTracksPrevBtn->Enable( m_TopTracksPageStart );
m_TopTracksNextBtn->Enable( ( ( m_TopTracksPageStart + 1 ) * GULASTFMINFO_MAXITEMS ) < m_TopTracksCount );
for( int index = 0; index < GULASTFMINFO_MAXITEMS; index++ )
{
m_TopTrackInfoCtrls[ index ]->Clear( m_MediaViewer );
}
m_TopTracksUpdateThread = new guFetchTopTracksInfoThread( this, m_DbCache, m_ArtistName.c_str(), m_TopTracksPageStart );
m_TopTracksUpdateThreadMutex.Unlock();
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::UpdateSimArtistsRangeLabel( void )
{
if( m_SimArtistsCount )
{
int StartIndex = m_SimArtistsPageStart * GULASTFMINFO_MAXITEMS;
m_SimArtistsRangeLabel->SetLabel( wxString::Format( wxT( "%i - %i / %i" ),
StartIndex + 1,
wxMin( StartIndex + GULASTFMINFO_MAXITEMS, m_SimArtistsCount ),
m_SimArtistsCount ) );
}
else
{
m_SimArtistsRangeLabel->SetLabel( wxT( "0 - 0 / 0"));
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnSimArtistsCountUpdated( wxCommandEvent &event )
{
m_SimArtistsCount = event.GetInt();
UpdateSimArtistsRangeLabel();
m_SimArtistsPrevBtn->Enable( m_SimArtistsPageStart );
m_SimArtistsNextBtn->Enable( ( ( m_SimArtistsPageStart + 1 ) * GULASTFMINFO_MAXITEMS ) < m_SimArtistsCount );
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnSimArtistsPrevClicked( wxCommandEvent &event )
{
if( m_SimArtistsPageStart )
{
m_SimArtistsUpdateThreadMutex.Lock();
if( m_SimArtistsUpdateThread )
{
m_SimArtistsUpdateThread->Pause();
m_SimArtistsUpdateThread->Delete();
m_SimArtistsUpdateThread = NULL;
}
m_SimArtistsPageStart--;
m_SimArtistsPrevBtn->Enable( m_SimArtistsPageStart );
m_SimArtistsNextBtn->Enable( ( ( m_SimArtistsPageStart + 1 ) * GULASTFMINFO_MAXITEMS ) < m_SimArtistsCount );
for( int index = 0; index < GULASTFMINFO_MAXITEMS; index++ )
{
m_SimArtistsInfoCtrls[ index ]->Clear( m_MediaViewer );
}
m_SimArtistsUpdateThread = new guFetchSimilarArtistInfoThread( this, m_DbCache, m_ArtistName.c_str(), m_SimArtistsPageStart );
m_SimArtistsUpdateThreadMutex.Unlock();
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnSimArtistsNextClicked( wxCommandEvent &event )
{
if( ( ( m_SimArtistsPageStart + 1 ) * GULASTFMINFO_MAXITEMS ) < m_SimArtistsCount )
{
m_SimArtistsUpdateThreadMutex.Lock();
if( m_SimArtistsUpdateThread )
{
m_SimArtistsUpdateThread->Pause();
m_SimArtistsUpdateThread->Delete();
m_SimArtistsUpdateThread = NULL;
}
m_SimArtistsPageStart++;
m_SimArtistsPrevBtn->Enable( m_SimArtistsPageStart );
m_SimArtistsNextBtn->Enable( ( ( m_SimArtistsPageStart + 1 ) * GULASTFMINFO_MAXITEMS ) < m_SimArtistsCount );
for( int index = 0; index < GULASTFMINFO_MAXITEMS; index++ )
{
m_SimArtistsInfoCtrls[ index ]->Clear( m_MediaViewer );
}
m_SimArtistsUpdateThread = new guFetchSimilarArtistInfoThread( this, m_DbCache, m_ArtistName.c_str(), m_SimArtistsPageStart );
m_SimArtistsUpdateThreadMutex.Unlock();
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::UpdateEventsRangeLabel( void )
{
if( m_EventsCount )
{
int StartIndex = m_EventsPageStart * GULASTFMINFO_MAXITEMS;
m_EventsRangeLabel->SetLabel( wxString::Format( wxT( "%i - %i / %i" ),
StartIndex + 1,
wxMin( StartIndex + GULASTFMINFO_MAXITEMS, m_EventsCount ),
m_EventsCount ) );
}
else
{
m_EventsRangeLabel->SetLabel( wxT( "0 - 0 / 0"));
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnEventsCountUpdated( wxCommandEvent &event )
{
m_EventsCount = event.GetInt();
UpdateEventsRangeLabel();
m_EventsPrevBtn->Enable( m_EventsPageStart );
m_EventsNextBtn->Enable( ( ( m_EventsPageStart + 1 ) * GULASTFMINFO_MAXITEMS ) < m_EventsCount );
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnEventsPrevClicked( wxCommandEvent &event )
{
if( m_EventsPageStart )
{
m_EventsUpdateThreadMutex.Lock();
if( m_EventsUpdateThread )
{
m_EventsUpdateThread->Pause();
m_EventsUpdateThread->Delete();
m_EventsUpdateThread = NULL;
}
m_EventsPageStart--;
m_EventsPrevBtn->Enable( m_EventsPageStart );
m_EventsNextBtn->Enable( ( ( m_EventsPageStart + 1 ) * GULASTFMINFO_MAXITEMS ) < m_EventsCount );
for( int index = 0; index < GULASTFMINFO_MAXITEMS; index++ )
{
m_EventsInfoCtrls[ index ]->Clear( m_MediaViewer );
}
m_EventsUpdateThread = new guFetchEventsInfoThread( this, m_DbCache, m_ArtistName.c_str(), m_EventsPageStart );
m_EventsUpdateThreadMutex.Unlock();
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnEventsNextClicked( wxCommandEvent &event )
{
if( ( ( m_EventsPageStart + 1 ) * GULASTFMINFO_MAXITEMS ) < m_EventsCount )
{
m_EventsUpdateThreadMutex.Lock();
if( m_EventsUpdateThread )
{
m_EventsUpdateThread->Pause();
m_EventsUpdateThread->Delete();
m_EventsUpdateThread = NULL;
}
m_EventsPageStart++;
m_EventsPrevBtn->Enable( m_EventsPageStart );
m_EventsNextBtn->Enable( ( ( m_EventsPageStart + 1 ) * GULASTFMINFO_MAXITEMS ) < m_EventsCount );
for( int index = 0; index < GULASTFMINFO_MAXITEMS; index++ )
{
m_EventsInfoCtrls[ index ]->Clear( m_MediaViewer );
}
m_EventsUpdateThread = new guFetchEventsInfoThread( this, m_DbCache, m_ArtistName.c_str(), m_EventsPageStart );
m_EventsUpdateThreadMutex.Unlock();
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::UpdateSimTracksRangeLabel( void )
{
if( m_SimTracksCount )
{
int StartIndex = m_SimTracksPageStart * GULASTFMINFO_MAXITEMS;
m_SimTracksRangeLabel->SetLabel( wxString::Format( wxT( "%i - %i / %i" ),
StartIndex + 1,
wxMin( StartIndex + GULASTFMINFO_MAXITEMS, m_SimTracksCount ),
m_SimTracksCount ) );
}
else
{
m_SimTracksRangeLabel->SetLabel( wxT( "0 - 0 / 0"));
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnSimTracksCountUpdated( wxCommandEvent &event )
{
m_SimTracksCount = event.GetInt();
UpdateSimTracksRangeLabel();
m_SimTracksPrevBtn->Enable( m_SimTracksPageStart );
m_SimTracksNextBtn->Enable( ( ( m_SimTracksPageStart + 1 ) * GULASTFMINFO_MAXITEMS ) < m_SimTracksCount );
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnSimTracksPrevClicked( wxCommandEvent &event )
{
if( m_SimTracksPageStart )
{
m_SimTracksUpdateThreadMutex.Lock();
if( m_SimTracksUpdateThread )
{
m_SimTracksUpdateThread->Pause();
m_SimTracksUpdateThread->Delete();
m_SimTracksUpdateThread = NULL;
}
m_SimTracksPageStart--;
m_SimTracksPrevBtn->Enable( m_SimTracksPageStart );
m_SimTracksNextBtn->Enable( ( ( m_SimTracksPageStart + 1 ) * GULASTFMINFO_MAXITEMS ) < m_SimTracksCount );
for( int index = 0; index < GULASTFMINFO_MAXITEMS; index++ )
{
m_SimTracksInfoCtrls[ index ]->Clear( m_MediaViewer );
}
m_SimTracksUpdateThread = new guFetchSimTracksInfoThread( this, m_DbCache, m_ArtistName.c_str(), m_TrackName.c_str(), m_SimTracksPageStart );
m_SimTracksUpdateThreadMutex.Unlock();
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnSimTracksNextClicked( wxCommandEvent &event )
{
if( ( ( m_SimTracksPageStart + 1 ) * GULASTFMINFO_MAXITEMS ) < m_SimTracksCount )
{
m_SimTracksUpdateThreadMutex.Lock();
if( m_SimTracksUpdateThread )
{
m_SimTracksUpdateThread->Pause();
m_SimTracksUpdateThread->Delete();
m_SimTracksUpdateThread = NULL;
}
m_SimTracksPageStart++;
m_SimTracksPrevBtn->Enable( m_SimTracksPageStart );
m_SimTracksNextBtn->Enable( ( ( m_SimTracksPageStart + 1 ) * GULASTFMINFO_MAXITEMS ) < m_SimTracksCount );
for( int index = 0; index < GULASTFMINFO_MAXITEMS; index++ )
{
m_SimTracksInfoCtrls[ index ]->Clear( m_MediaViewer );
}
m_SimTracksUpdateThread = new guFetchSimTracksInfoThread( this, m_DbCache, m_ArtistName.c_str(), m_TrackName.c_str(), m_SimTracksPageStart );
m_SimTracksUpdateThreadMutex.Unlock();
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::SetUpdateEnable( bool value )
{
m_UpdateCheckBox->SetValue( value );
m_UpdateEnabled = value;
wxCommandEvent event;
OnUpdateChkBoxClick( event );
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnUpdateChkBoxClick( wxCommandEvent &event )
{
m_UpdateEnabled = m_UpdateCheckBox->IsChecked();
if( m_UpdateEnabled )
{
wxCommandEvent UpdateEvent( wxEVT_MENU, ID_MAINFRAME_REQUEST_CURRENTTRACK );
UpdateEvent.SetClientData( this );
wxPostEvent( guMainFrame::GetMainFrame(), UpdateEvent );
}
//
m_ArtistTextCtrl->Enable( !m_UpdateEnabled );
m_TrackTextCtrl->Enable( !m_UpdateEnabled );
// m_SearchButton->Enable( !m_UpdateEnabled &&
// !m_ArtistTextCtrl->IsEmpty() );
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnTextUpdated( wxCommandEvent& event )
{
m_TrackTextCtrl->Enable( !m_UpdateCheckBox->IsChecked() && !event.GetString().IsEmpty() );
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::AppendTrackChangeInfo( const guTrackChangeInfo * trackchangeinfo )
{
// Even when m_CurrentTrackInfo == -1 (wxNOT_FOUND)
// This is valid because its not < than 0 which is the count
// and it will be incremented to 0
// Delete all the itesm after the one we are showing
while( m_CurrentTrackInfo < ( int ) ( m_TrackChangeItems.Count() - 1 ) )
{
m_TrackChangeItems.RemoveAt( m_TrackChangeItems.Count() - 1 );
}
// Add the item
m_TrackChangeItems.Add( new guTrackChangeInfo( * trackchangeinfo ) );
m_CurrentTrackInfo++;
if( m_TrackChangeItems.Count() > guTRACKCHANGEINFO_MAXCOUNT )
{
m_TrackChangeItems.RemoveAt( 0 );
m_CurrentTrackInfo--;
}
UpdateTrackChangeButtons();
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::UpdateTrackChangeButtons( void )
{
m_PrevButton->Enable( m_CurrentTrackInfo > 0 );
m_NextButton->Enable( m_CurrentTrackInfo < ( int ) ( m_TrackChangeItems.Count() - 1 ) );
m_ReloadButton->Enable( m_TrackChangeItems.Count() );
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnUpdatedTrack( wxCommandEvent &event )
{
if( !m_UpdateEnabled )
return;
// Player informs there is a new track playing
//guLogMessage( wxT( "Received LastFMPanel::UpdateTrack event" ) );
const guTrack * Track = ( guTrack * ) event.GetClientData();
guTrackChangeInfo ChangeInfo;
if( Track )
{
ChangeInfo.m_ArtistName = Track->m_ArtistName;
ChangeInfo.m_TrackName = Track->m_SongName;
ChangeInfo.m_MediaViewer = Track->m_MediaViewer;
}
//guLogMessage( wxT( "%s - %s" ), TrackChangeInfo->m_ArtistName.c_str(), TrackChangeInfo->m_TrackName.c_str() );
AppendTrackChangeInfo( &ChangeInfo );
ShowCurrentTrack();
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnPrevBtnClick( wxCommandEvent& event )
{
SetUpdateEnable( false );
if( m_CurrentTrackInfo > 0 )
{
m_CurrentTrackInfo--;
}
UpdateTrackChangeButtons();
ShowCurrentTrack();
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnNextBtnClick( wxCommandEvent& event )
{
SetUpdateEnable( false );
if( m_CurrentTrackInfo < ( int ) ( m_TrackChangeItems.Count() - 1 ) )
{
m_CurrentTrackInfo++;
}
UpdateTrackChangeButtons();
ShowCurrentTrack();
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnReloadBtnClick( wxCommandEvent& event )
{
m_LastArtistName = wxEmptyString;
m_LastTrackName = wxEmptyString;
ShowCurrentTrack();
}
//// -------------------------------------------------------------------------------- //
//void guLastFMPanel::OnSearchBtnClick( wxCommandEvent& event )
//{
// guTrackChangeInfo TrackChangeInfo( m_ArtistTextCtrl->GetValue(), m_TrackTextCtrl->GetValue() );
// AppendTrackChangeInfo( &TrackChangeInfo );
// ShowCurrentTrack();
//}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnTextCtrlKeyDown( wxKeyEvent &event )
{
if( event.GetKeyCode() == WXK_RETURN )
{
wxCommandEvent CmdEvent( wxEVT_TEXT_ENTER );
m_ArtistTextCtrl->GetEventHandler()->AddPendingEvent( CmdEvent );
return;
}
event.Skip();
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnSearchSelected( wxCommandEvent &event )
{
if( !m_ArtistTextCtrl->IsEmpty() )
{
guTrackChangeInfo TrackChangeInfo( m_ArtistTextCtrl->GetValue(), m_TrackTextCtrl->GetValue(), m_MediaViewer );
AppendTrackChangeInfo( &TrackChangeInfo );
ShowCurrentTrack();
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnUpdateArtistInfo( wxCommandEvent &event )
{
wxMutexLocker Locker( m_UpdateInfoMutex );
//guLogMessage( wxT( "Got Event for BIO updating" ) );
guLastFMArtistInfo * ArtistInfo = ( guLastFMArtistInfo * ) event.GetClientData();
if( ArtistInfo )
{
m_ArtistInfoCtrl->SetInfo( ArtistInfo );
m_MainSizer->FitInside( this );
}
else
{
guLogError( wxT( "Received a LastFMInfo bio event with NULL Data" ) );
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnUpdateAlbumItem( wxCommandEvent &event )
{
wxMutexLocker Locker( m_UpdateInfoMutex );
// Player informs there is a new track playing
int index = event.GetInt();
//guLogMessage( wxT( "Received LastFMInfoItem %u" ), index );
guLastFMAlbumInfo * AlbumInfo = ( guLastFMAlbumInfo * ) event.GetClientData();
if( AlbumInfo )
{
m_AlbumsInfoCtrls[ index ]->SetInfo( AlbumInfo );
//Layout();
m_MainSizer->FitInside( this );
}
else
{
guLogError( wxT( "Received a LastFMInfo album event with NULL Data" ) );
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnUpdateArtistItem( wxCommandEvent &event )
{
wxMutexLocker Locker( m_UpdateInfoMutex );
// Player informs there is a new track playing
int index = event.GetInt();
//guLogMessage( wxT( "Received LastFMInfoItem %u" ), index );
guLastFMSimilarArtistInfo * ArtistInfo = ( guLastFMSimilarArtistInfo * ) event.GetClientData();
if( ArtistInfo )
{
m_SimArtistsInfoCtrls[ index ]->SetInfo( ArtistInfo );
//Layout();
m_MainSizer->FitInside( this );
}
else
{
guLogError( wxT( "Received a LastFMInfo artist event with NULL Data" ) );
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnUpdateTrackItem( wxCommandEvent &event )
{
wxMutexLocker Locker( m_UpdateInfoMutex );
// Player informs there is a new track playing
int index = event.GetInt();
//guLogMessage( wxT( "Received LastFMInfoItem %u" ), index );
guLastFMTrackInfo * TrackInfo = ( guLastFMTrackInfo * ) event.GetClientData();
if( TrackInfo )
{
m_SimTracksInfoCtrls[ index ]->SetInfo( TrackInfo );
//Layout();
m_MainSizer->FitInside( this );
}
else
{
guLogError( wxT( "Received a LastFMInfo track event with NULL Data" ) );
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnUpdateTopTrackItem( wxCommandEvent &event )
{
wxMutexLocker Locker( m_UpdateInfoMutex );
// Player informs there is a new track playing
int index = event.GetInt();
//guLogMessage( wxT( "Received LastFMInfoItem %u" ), index );
guLastFMTopTrackInfo * TrackInfo = ( guLastFMTopTrackInfo * ) event.GetClientData();
if( TrackInfo )
{
m_TopTrackInfoCtrls[ index ]->SetInfo( TrackInfo );
//Layout();
m_MainSizer->FitInside( this );
}
else
{
guLogError( wxT( "Received a LastFMInfo top track event with NULL Data" ) );
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnUpdateEventItem( wxCommandEvent &event )
{
wxMutexLocker Locker( m_UpdateInfoMutex );
// Player informs there is a new track playing
int index = event.GetInt();
//guLogMessage( wxT( "Received LastFMInfoItem %u" ), index );
guLastFMEventInfo * EventInfo = ( guLastFMEventInfo * ) event.GetClientData();
if( EventInfo )
{
m_EventsInfoCtrls[ index ]->SetInfo( EventInfo );
//Layout();
m_MainSizer->FitInside( this );
}
else
{
guLogError( wxT( "Received a LastFMInfo Event event with NULL Data" ) );
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnArInfoTitleDClicked( wxMouseEvent &event )
{
m_ShowArtistDetails = !m_ShowArtistDetails;
//ArtistDetailsSizer->Show( ShowArtistDetails );
if( m_ShowArtistDetails )
m_MainSizer->Show( m_ArtistInfoMainSizer );
else
m_MainSizer->Hide( m_ArtistInfoMainSizer );
m_MainSizer->FitInside( this );
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::SetTopAlbumsVisible( const bool dolayout )
{
if( m_ShowAlbums )
m_MainSizer->Show( m_AlbumsSizer );
else
m_MainSizer->Hide( m_AlbumsSizer );
m_AlbumsRangeLabel->Show( m_ShowAlbums );
m_AlbumsPrevBtn->Show( m_ShowAlbums );
m_AlbumsNextBtn->Show( m_ShowAlbums );
if( dolayout )
UpdateLayout();
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::SetTopTracksVisible( const bool dolayout )
{
if( m_ShowTopTracks )
m_MainSizer->Show( m_TopTracksSizer );
else
m_MainSizer->Hide( m_TopTracksSizer );
m_TopTracksRangeLabel->Show( m_ShowTopTracks );
m_TopTracksPrevBtn->Show( m_ShowTopTracks );
m_TopTracksNextBtn->Show( m_ShowTopTracks );
if( dolayout )
UpdateLayout();
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::SetSimArtistsVisible( const bool dolayout )
{
if( m_ShowSimArtists )
m_MainSizer->Show( m_SimArtistsSizer );
else
m_MainSizer->Hide( m_SimArtistsSizer );
m_SimArtistsRangeLabel->Show( m_ShowSimArtists );
m_SimArtistsPrevBtn->Show( m_ShowSimArtists );
m_SimArtistsNextBtn->Show( m_ShowSimArtists );
if( dolayout )
UpdateLayout();
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::SetSimTracksVisible( const bool dolayout )
{
if( m_ShowSimTracks )
m_MainSizer->Show( m_SimTracksSizer );
else
m_MainSizer->Hide( m_SimTracksSizer );
m_SimTracksRangeLabel->Show( m_ShowSimTracks );
m_SimTracksPrevBtn->Show( m_ShowSimTracks );
m_SimTracksNextBtn->Show( m_ShowSimTracks );
if( dolayout )
UpdateLayout();
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::SetEventsVisible( const bool dolayout )
{
if( m_ShowEvents )
m_MainSizer->Show( m_EventsSizer );
else
m_MainSizer->Hide( m_EventsSizer );
m_EventsRangeLabel->Show( m_ShowEvents );
m_EventsPrevBtn->Show( m_ShowEvents );
m_EventsNextBtn->Show( m_ShowEvents );
if( dolayout )
UpdateLayout();
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnTopAlbumsTitleDClick( wxMouseEvent &event )
{
m_ShowAlbums = !m_ShowAlbums;
SetTopAlbumsVisible( true );
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnTopTracksTitleDClick( wxMouseEvent &event )
{
m_ShowTopTracks = !m_ShowTopTracks;
SetTopTracksVisible( true );
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnSimArTitleDClick( wxMouseEvent &event )
{
m_ShowSimArtists = !m_ShowSimArtists;
SetSimArtistsVisible( true );
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnSimTrTitleDClick( wxMouseEvent &event )
{
m_ShowSimTracks = !m_ShowSimTracks;
SetSimTracksVisible( true );
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnEventsTitleDClick( wxMouseEvent &event )
{
m_ShowEvents = !m_ShowEvents;
SetEventsVisible( true );
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnDropFiles( const wxArrayString &files )
{
//guLogMessage( wxT( "guLastFMPanelDropTarget::OnDropFiles" ) );
if( !files.Count() )
return;
guTrackChangeInfo ChangeInfo;
guTrack Track;
guDbLibrary * Db = m_Db ? m_Db : m_DefaultDb;
if( !Db->FindTrackFile( files[ 0 ], &Track ) )
{
if( Track.ReadFromFile( files[ 0 ] ) )
{
Track.m_Type = guTRACK_TYPE_NOTDB;
Track.m_MediaViewer = NULL;
}
else
{
return;
}
}
else
{
Track.m_MediaViewer = m_MediaViewer;
}
ChangeInfo.m_ArtistName = Track.m_ArtistName;
ChangeInfo.m_TrackName = Track.m_SongName;
ChangeInfo.m_MediaViewer = Track.m_MediaViewer;
SetUpdateEnable( false );
AppendTrackChangeInfo( &ChangeInfo );
ShowCurrentTrack();
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnDropFiles( const guTrackArray * tracks )
{
//guLogMessage( wxT( "guLastFMPanelDropTarget::OnDropFiles" ) );
if( tracks && tracks->Count() )
{
guTrackChangeInfo ChangeInfo;
const guTrack & Track = tracks->Item( 0 );
if( Track.m_MediaViewer )
{
m_MediaViewer = Track.m_MediaViewer;
m_Db = m_MediaViewer->GetDb();
}
else
{
m_MediaViewer = NULL;
m_Db = NULL;
}
ChangeInfo.m_ArtistName = Track.m_ArtistName;
ChangeInfo.m_TrackName = Track.m_SongName;
SetUpdateEnable( false );
AppendTrackChangeInfo( &ChangeInfo );
ShowCurrentTrack();
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnContextMenu( wxContextMenuEvent &event )
{
m_ContextMenuObject = ( wxStaticText * ) event.GetEventObject();
wxMenu Menu;
wxPoint Point = event.GetPosition();
// If from keyboard
if( Point.x == -1 && Point.y == -1 )
{
wxSize Size = GetSize();
Point.x = Size.x / 2;
Point.y = Size.y / 2;
}
else
{
CalcUnscrolledPosition( Point.x, Point.y, &Point.x, &Point.y );
Point = ScreenToClient( Point );
}
wxMenuItem * MenuItem = new wxMenuItem( &Menu, ID_LASTFM_PLAY, _( "Play" ), _( "Play the artist tracks" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_player_tiny_light_play ) );
Menu.Append( MenuItem );
MenuItem = new wxMenuItem( &Menu, ID_LASTFM_ENQUEUE_AFTER_ALL, _( "Enqueue" ), _( "Enqueue the artist tracks to the playlist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
Menu.Append( MenuItem );
wxMenu * EnqueueMenu = new wxMenu();
MenuItem = new wxMenuItem( EnqueueMenu, ID_LASTFM_ENQUEUE_AFTER_TRACK,
wxString( _( "Current Track" ) ),
_( "Add current selected tracks to playlist after the current track" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem = new wxMenuItem( EnqueueMenu, ID_LASTFM_ENQUEUE_AFTER_ALBUM,
wxString( _( "Current Album" ) ),
_( "Add current selected tracks to playlist after the current album" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem = new wxMenuItem( EnqueueMenu, ID_LASTFM_ENQUEUE_AFTER_ARTIST,
wxString( _( "Current Artist" ) ),
_( "Add current selected tracks to playlist after the current artist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
Menu.Append( wxID_ANY, _( "Enqueue After" ), EnqueueMenu );
Menu.AppendSeparator();
MenuItem = new wxMenuItem( &Menu, ID_LASTFM_SAVETOPLAYLIST, _( "Save to Playlist" ), _( "Save the selected tracks to playlist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_doc_save ) );
Menu.Append( MenuItem );
Menu.AppendSeparator();
guMainFrame * MainFrame = ( guMainFrame * ) guMainFrame::GetMainFrame();
MainFrame->CreateCopyToMenu( &Menu );
PopupMenu( &Menu, Point.x, Point.y );
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::GetContextMenuTracks( guTrackArray * tracks )
{
guLastFM LastFM;
guDbLibrary * Db = m_Db ? m_Db : m_DefaultDb;
if( m_ContextMenuObject == m_AlbumsStaticText )
{
// Top Albums
guAlbumInfoArray TopAlbums = LastFM.ArtistGetTopAlbums( m_ArtistName );
wxArrayInt AlbumIds;
int Count = TopAlbums.Count();
for( int Index = 0; Index < Count; Index++ )
{
int AlbumId = Db->FindAlbum( m_ArtistName, TopAlbums[ Index ].m_Name );
if( AlbumId != wxNOT_FOUND )
{
AlbumIds.Empty();
AlbumIds.Add( AlbumId );
Db->GetAlbumsSongs( AlbumIds, tracks );
}
}
}
else if( m_ContextMenuObject == m_TopTracksStaticText )
{
// Top Tracks
guTopTrackInfoArray TopTracks = LastFM.ArtistGetTopTracks( m_ArtistName );
int Count = TopTracks.Count();
for( int Index = 0; Index < Count; Index++ )
{
guTrack * Track = Db->FindSong( m_ArtistName, TopTracks[ Index ].m_TrackName, 0, 0 );
if( Track )
{
tracks->Add( Track );
}
}
}
else if( m_ContextMenuObject == m_SimArtistsStaticText )
{
// Similar Artists
guSimilarArtistInfoArray SimilarArtists = LastFM.ArtistGetSimilar( m_ArtistName );
wxArrayInt ArtistIds;
int Count = SimilarArtists.Count();
for( int Index = 0; Index < Count; Index++ )
{
int ArtistId = Db->FindArtist( SimilarArtists[ Index ].m_Name );
if( ArtistId != wxNOT_FOUND )
{
ArtistIds.Empty();
ArtistIds.Add( ArtistId );
Db->GetArtistsSongs( ArtistIds, tracks );
}
}
}
else if( m_ContextMenuObject == m_SimTracksStaticText )
{
// Similar Tracks
guSimilarTrackInfoArray SimilarTracks = LastFM.TrackGetSimilar( m_ArtistName, m_TrackName );
int Count = SimilarTracks.Count();
for( int Index = 0; Index < Count; Index++ )
{
guTrack * Track = Db->FindSong( SimilarTracks[ Index ].m_ArtistName, SimilarTracks[ Index ].m_TrackName, 0, 0 );
if( Track )
{
tracks->Add( Track );
}
}
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnPlayClicked( wxCommandEvent &event )
{
guTrackArray Tracks;
GetContextMenuTracks( &Tracks );
if( m_PlayerPanel && Tracks.Count() )
{
m_PlayerPanel->SetPlayList( Tracks );
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnEnqueueClicked( wxCommandEvent &event )
{
guTrackArray Tracks;
GetContextMenuTracks( &Tracks );
if( m_PlayerPanel && Tracks.Count() )
{
m_PlayerPanel->AddToPlayList( Tracks, true, event.GetId() - ID_LASTFM_ENQUEUE_AFTER_ALL );
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnSaveClicked( wxCommandEvent &event )
{
guTrackArray Tracks;
GetContextMenuTracks( &Tracks );
int Count = Tracks.Count();
if( Count )
{
wxArrayInt TrackIds;
for( int Index = 0; Index < Count; Index++ )
{
TrackIds.Add( Tracks[ Index ].m_SongId );
}
guListItems PlayLists;
guDbLibrary * Db = m_Db ? m_Db : m_DefaultDb;
Db->GetPlayLists( &PlayLists, guPLAYLIST_TYPE_STATIC );
guPlayListAppend * PlayListAppendDlg = new guPlayListAppend( guMainFrame::GetMainFrame(), Db, &TrackIds, &PlayLists );
if( PlayListAppendDlg->ShowModal() == wxID_OK )
{
int Selected = PlayListAppendDlg->GetSelectedPlayList();
if( Selected == -1 )
{
wxString PLName = PlayListAppendDlg->GetPlaylistName();
if( PLName.IsEmpty() )
{
PLName = _( "Unnamed" );
}
Db->CreateStaticPlayList( PLName, TrackIds );
}
else
{
int PLId = PlayLists[ Selected ].m_Id;
wxArrayInt OldSongs;
Db->GetPlayListSongIds( PLId, &OldSongs );
if( PlayListAppendDlg->GetSelectedPosition() == 0 ) // BEGIN
{
Db->UpdateStaticPlayList( PLId, TrackIds );
Db->AppendStaticPlayList( PLId, OldSongs );
}
else // END
{
Db->AppendStaticPlayList( PLId, TrackIds );
}
}
wxCommandEvent evt( wxEVT_MENU, ID_PLAYLIST_UPDATED );
wxPostEvent( guMainFrame::GetMainFrame(), evt );
}
PlayListAppendDlg->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::OnCopyToClicked( wxCommandEvent &event )
{
guTrackArray * Tracks = new guTrackArray();
GetContextMenuTracks( Tracks );
wxCommandEvent CmdEvent( wxEVT_MENU, ID_MAINFRAME_COPYTO );
int CommandId = event.GetId() - ID_COPYTO_BASE;
if( CommandId >= guCOPYTO_DEVICE_BASE )
{
CommandId -= guCOPYTO_DEVICE_BASE;
CmdEvent.SetId( ID_MAINFRAME_COPYTODEVICE_TRACKS );
}
CmdEvent.SetInt( CommandId );
CmdEvent.SetClientData( ( void * ) Tracks );
wxPostEvent( guMainFrame::GetMainFrame(), CmdEvent );
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::SetMediaViewer( guMediaViewer * mediaviewer )
{
m_MediaViewer = mediaviewer;
m_Db = mediaviewer ? mediaviewer->GetDb() : NULL;
}
// -------------------------------------------------------------------------------- //
void guLastFMPanel::MediaViewerClosed( guMediaViewer * mediaviewer )
{
//
if( m_MediaViewer == mediaviewer )
{
guLogMessage( wxT( "Got MediaViewer Closed..." ) );
SetMediaViewer( NULL );
// Clear the LastFM controls to default values
m_ArtistInfoCtrl->SetMediaViewer( NULL );
for( int Index = 0; Index < GULASTFMINFO_MAXITEMS; Index++ )
{
m_AlbumsInfoCtrls[ Index ]->SetMediaViewer( NULL );
m_TopTrackInfoCtrls[ Index ]->SetMediaViewer( NULL );
m_SimArtistsInfoCtrls[ Index ]->SetMediaViewer( NULL );
m_EventsInfoCtrls[ Index ]->SetMediaViewer( NULL );
m_SimTracksInfoCtrls[ Index ]->SetMediaViewer( NULL );
}
}
}
// -------------------------------------------------------------------------------- //
// guFetchLastFMInfoThread
// -------------------------------------------------------------------------------- //
guFetchLastFMInfoThread::guFetchLastFMInfoThread( guLastFMPanel * lastfmpanel ) :
wxThread( wxTHREAD_DETACHED )
{
m_LastFMPanel = lastfmpanel;
}
// -------------------------------------------------------------------------------- //
guFetchLastFMInfoThread::~guFetchLastFMInfoThread()
{
m_DownloadThreadsMutex.Lock();
int count = m_DownloadThreads.Count();
if( count )
{
for( int index = 0; index < count; index++ )
{
m_DownloadThreads[ index ]->Pause();
m_DownloadThreads[ index ]->Delete();
}
}
m_DownloadThreadsMutex.Unlock();
}
// -------------------------------------------------------------------------------- //
void guFetchLastFMInfoThread::WaitDownloadThreads( void )
{
int count;
while( !TestDestroy() )
{
m_DownloadThreadsMutex.Lock();
count = m_DownloadThreads.Count();
m_DownloadThreadsMutex.Unlock();
if( !count )
break;
Sleep( GULASTFM_DOWNLOAD_IMAGE_DELAY );
}
}
// -------------------------------------------------------------------------------- //
// guDownloadImageThread
// -------------------------------------------------------------------------------- //
guDownloadImageThread::guDownloadImageThread( guLastFMPanel * lastfmpanel,
guFetchLastFMInfoThread * mainthread, guDbCache * dbcache, const int index, const wxChar * imageurl,
int commandid, void * commanddata, wxImage ** pimage, const int imagesize ) :
wxThread( wxTHREAD_DETACHED )
{
m_DbCache = dbcache;
m_LastFMPanel = lastfmpanel;
m_MainThread = mainthread;
m_CommandId = commandid;
m_CommandData = commanddata;
m_pImage = pimage;
m_Index = index;
m_ImageUrl = wxString( imageurl );
m_ImageSize = imagesize;
// We dont need to lock here as its locked in the Mainthread when the thread is created
m_MainThread->m_DownloadThreads.Add( this );
if( Create() == wxTHREAD_NO_ERROR )
{
SetPriority( WXTHREAD_DEFAULT_PRIORITY - 30 );
Run();
}
}
// -------------------------------------------------------------------------------- //
guDownloadImageThread::~guDownloadImageThread()
{
if( !TestDestroy() )
{
m_MainThread->m_DownloadThreadsMutex.Lock();
if( !TestDestroy() )
{
m_MainThread->m_DownloadThreads.Remove( this );
}
m_MainThread->m_DownloadThreadsMutex.Unlock();
}
}
// -------------------------------------------------------------------------------- //
guDownloadImageThread::ExitCode guDownloadImageThread::Entry()
{
wxBitmapType ImageType;
wxImage * Image = NULL;
if( !TestDestroy() && !m_ImageUrl.IsEmpty() )
{
// We could be running while the database have been closed
// in this case we are leaving the app so just leave thread
try {
Image = m_DbCache->GetImage( m_ImageUrl, ImageType, m_ImageSize );
if( !TestDestroy() && !Image )
{
Image = guGetRemoteImage( m_ImageUrl, ImageType );
if( Image )
m_DbCache->SetImage( m_ImageUrl, Image, ImageType );
else
guLogMessage( wxT( "Could not get '%s'" ), m_ImageUrl.c_str() );
if( !TestDestroy() && Image )
{
int Size;
switch( m_ImageSize )
{
case guDBCACHE_TYPE_IMAGE_SIZE_TINY :
{
Size = 50;
break;
}
case guDBCACHE_TYPE_IMAGE_SIZE_MID :
{
Size = 100;
break;
}
default : //case guDBCACHE_TYPE_IMAGE_SIZE_BIG :
{
Size = 150;
break;
}
}
guImageResize( Image, Size );
}
}
}
catch(...)
{
return 0;
}
}
//
if( !TestDestroy() )
{
if( m_pImage )
{
* m_pImage = Image;
}
//
m_LastFMPanel->m_UpdateEventsMutex.Lock();
wxCommandEvent event( wxEVT_MENU, m_CommandId );
event.SetInt( m_Index );
event.SetClientData( m_CommandData );
wxPostEvent( m_LastFMPanel, event );
m_LastFMPanel->m_UpdateEventsMutex.Unlock();
}
else
{
if( Image )
delete Image;
if( m_CommandData )
{
switch( m_CommandId )
{
case ID_LASTFM_UPDATE_ALBUMINFO :
{
delete ( guLastFMAlbumInfo * ) m_CommandData;
break;
}
case ID_LASTFM_UPDATE_ARTISTINFO :
{
delete ( guLastFMArtistInfo * ) m_CommandData;
break;
}
case ID_LASTFM_UPDATE_SIMARTIST :
{
delete ( guLastFMSimilarArtistInfo * ) m_CommandData;
break;
}
case ID_LASTFM_UPDATE_EVENTINFO :
{
delete ( guLastFMEventInfo * ) m_CommandData;
break;
}
case ID_LASTFM_UPDATE_TOPTRACKS :
{
delete ( guLastFMTopTrackInfo * ) m_CommandData;
break;
}
case ID_LASTFM_UPDATE_SIMTRACK :
{
delete ( guLastFMTrackInfo * ) m_CommandData;
break;
}
}
}
}
return 0;
}
// -------------------------------------------------------------------------------- //
// guFetchAlbumInfoThread
// -------------------------------------------------------------------------------- //
guFetchAlbumInfoThread::guFetchAlbumInfoThread( guLastFMPanel * lastfmpanel,
guDbCache * dbcache, const wxChar * artistname, const int start ) :
guFetchLastFMInfoThread( lastfmpanel )
{
m_DbCache = dbcache;
m_ArtistName = wxString( artistname );
m_Start = start * GULASTFMINFO_MAXITEMS;
if( Create() == wxTHREAD_NO_ERROR )
{
SetPriority( WXTHREAD_DEFAULT_PRIORITY - 30 );
Run();
}
}
// -------------------------------------------------------------------------------- //
guFetchAlbumInfoThread::~guFetchAlbumInfoThread()
{
if( !TestDestroy() )
{
m_LastFMPanel->m_AlbumsUpdateThreadMutex.Lock();
if( !TestDestroy() )
{
m_LastFMPanel->m_AlbumsUpdateThread = NULL;
}
m_LastFMPanel->m_AlbumsUpdateThreadMutex.Unlock();
}
}
// -------------------------------------------------------------------------------- //
guFetchAlbumInfoThread::ExitCode guFetchAlbumInfoThread::Entry()
{
guLastFM * LastFM = new guLastFM();
if( LastFM )
{
if( !TestDestroy() )
{
//guLogMessage( wxT( "==== Getting Top Albums ====" ) );
guAlbumInfoArray TopAlbums = LastFM->ArtistGetTopAlbums( m_ArtistName );
int count = TopAlbums.Count();
wxCommandEvent CountEvent( wxEVT_MENU, ID_LASTFM_UPDATE_ALBUM_COUNT );
CountEvent.SetInt( count );
wxPostEvent( m_LastFMPanel, CountEvent );
if( count )
{
count = wxMin( count, m_Start + GULASTFMINFO_MAXITEMS );
for( int index = m_Start; index < count; index++ )
{
m_DownloadThreadsMutex.Lock();
if( !TestDestroy() )
{
guLastFMAlbumInfo * LastFMAlbumInfo = new guLastFMAlbumInfo( index - m_Start, NULL,
new guAlbumInfo( TopAlbums[ index ] ) );
if( LastFMAlbumInfo )
{
LastFMAlbumInfo->m_ImageUrl = TopAlbums[ index ].m_ImageLink;
guDownloadImageThread * DownloadImageThread = new guDownloadImageThread(
m_LastFMPanel,
this,
m_DbCache,
index - m_Start,
TopAlbums[ index ].m_ImageLink.c_str(),
ID_LASTFM_UPDATE_ALBUMINFO,
LastFMAlbumInfo,
&LastFMAlbumInfo->m_Image,
guDBCACHE_TYPE_IMAGE_SIZE_TINY );
if( !DownloadImageThread )
{
guLogError( wxT( "Could not create the album image download thread %u" ), index );
}
}
}
m_DownloadThreadsMutex.Unlock();
if( TestDestroy() )
break;
Sleep( GULASTFM_DOWNLOAD_IMAGE_DELAY );
}
}
}
delete LastFM;
//
WaitDownloadThreads();
}
return 0;
}
// -------------------------------------------------------------------------------- //
// guFetchTopTracksInfoThread
// -------------------------------------------------------------------------------- //
guFetchTopTracksInfoThread::guFetchTopTracksInfoThread( guLastFMPanel * lastfmpanel,
guDbCache * dbcache, const wxChar * artistname, const int startpage ) :
guFetchLastFMInfoThread( lastfmpanel )
{
m_DbCache = dbcache;
m_ArtistName = wxString( artistname );
m_Start = startpage * GULASTFMINFO_MAXITEMS;
if( Create() == wxTHREAD_NO_ERROR )
{
SetPriority( WXTHREAD_DEFAULT_PRIORITY - 30 );
Run();
}
}
// -------------------------------------------------------------------------------- //
guFetchTopTracksInfoThread::~guFetchTopTracksInfoThread()
{
if( !TestDestroy() )
{
m_LastFMPanel->m_TopTracksUpdateThreadMutex.Lock();
if( !TestDestroy() )
{
m_LastFMPanel->m_TopTracksUpdateThread = NULL;
}
m_LastFMPanel->m_TopTracksUpdateThreadMutex.Unlock();
}
}
// -------------------------------------------------------------------------------- //
guFetchTopTracksInfoThread::ExitCode guFetchTopTracksInfoThread::Entry()
{
int count;
guLastFM * LastFM = new guLastFM();
if( LastFM )
{
if( !TestDestroy() )
{
//guLogMessage( wxT( "==== Getting Top Albums ====" ) );
guTopTrackInfoArray TopTracks = LastFM->ArtistGetTopTracks( m_ArtistName );
count = TopTracks.Count();
wxCommandEvent CountEvent( wxEVT_MENU, ID_LASTFM_UPDATE_TOPTRACKS_COUNT );
CountEvent.SetInt( count );
wxPostEvent( m_LastFMPanel, CountEvent );
if( count )
{
count = wxMin( count, m_Start + GULASTFMINFO_MAXITEMS );
for( int index = m_Start; index < count; index++ )
{
m_DownloadThreadsMutex.Lock();
if( !TestDestroy() )
{
guLastFMTopTrackInfo * LastFMTopTrackInfo = new guLastFMTopTrackInfo( index - m_Start, NULL,
new guTopTrackInfo( TopTracks[ index ] ) );
if( LastFMTopTrackInfo )
{
LastFMTopTrackInfo->m_ImageUrl = TopTracks[ index ].m_ImageLink;
guDownloadImageThread * DownloadImageThread = new guDownloadImageThread(
m_LastFMPanel,
this,
m_DbCache,
index - m_Start,
TopTracks[ index ].m_ImageLink.c_str(),
ID_LASTFM_UPDATE_TOPTRACKS,
LastFMTopTrackInfo,
&LastFMTopTrackInfo->m_Image,
guDBCACHE_TYPE_IMAGE_SIZE_TINY );
if( !DownloadImageThread )
{
guLogError( wxT( "Could not create the album image download thread %u" ), index );
}
}
}
m_DownloadThreadsMutex.Unlock();
if( TestDestroy() )
break;
Sleep( GULASTFM_DOWNLOAD_IMAGE_DELAY );
}
}
}
delete LastFM;
//
WaitDownloadThreads();
}
return 0;
}
// -------------------------------------------------------------------------------- //
// guFetchArtistInfoThread
// -------------------------------------------------------------------------------- //
guFetchArtistInfoThread::guFetchArtistInfoThread( guLastFMPanel * lastfmpanel,
guDbCache * dbcache, const wxChar * artistname ) :
guFetchLastFMInfoThread( lastfmpanel )
{
m_DbCache = dbcache;
//guLogMessage( wxT( "guFetchArtistInfoThread : '%s'" ), artistname );
m_ArtistName = wxString( artistname );
if( Create() == wxTHREAD_NO_ERROR )
{
SetPriority( WXTHREAD_DEFAULT_PRIORITY - 30 );
Run();
}
}
// -------------------------------------------------------------------------------- //
guFetchArtistInfoThread::~guFetchArtistInfoThread()
{
if( !TestDestroy() )
{
m_LastFMPanel->m_ArtistsUpdateThreadMutex.Lock();
if( !TestDestroy() )
{
m_LastFMPanel->m_ArtistsUpdateThread = NULL;
}
m_LastFMPanel->m_ArtistsUpdateThreadMutex.Unlock();
}
}
// -------------------------------------------------------------------------------- //
guFetchArtistInfoThread::ExitCode guFetchArtistInfoThread::Entry()
{
guLastFM * LastFM = new guLastFM();
if( LastFM )
{
if( !TestDestroy() )
{
// Get the Artist Info
//guLogMessage( wxT( "==== Getting Artists Description ====" ) );
guArtistInfo ArtistInfo = LastFM->ArtistGetInfo( m_ArtistName );
m_DownloadThreadsMutex.Lock();
if( !TestDestroy() )
{
guLastFMArtistInfo * LastFMArtistInfo = new guLastFMArtistInfo( 0, NULL,
new guArtistInfo( ArtistInfo ) );
if( LastFMArtistInfo )
{
LastFMArtistInfo->m_ImageUrl = ArtistInfo.m_ImageLink;
guDownloadImageThread * DownloadImageThread = new guDownloadImageThread(
m_LastFMPanel,
this,
m_DbCache,
0,
ArtistInfo.m_ImageLink.c_str(),
ID_LASTFM_UPDATE_ARTISTINFO,
LastFMArtistInfo,
&LastFMArtistInfo->m_Image,
guDBCACHE_TYPE_IMAGE_SIZE_MID );
if( !DownloadImageThread )
{
guLogError( wxT( "Could not create the artist image download thread" ) );
}
}
}
m_DownloadThreadsMutex.Unlock();
}
delete LastFM;
//
WaitDownloadThreads();
}
return 0;
}
// -------------------------------------------------------------------------------- //
// guFetchSimilarArtistInfoThread
// -------------------------------------------------------------------------------- //
guFetchSimilarArtistInfoThread::guFetchSimilarArtistInfoThread( guLastFMPanel * lastfmpanel,
guDbCache * dbcache, const wxChar * artistname, const int startpage ) :
guFetchLastFMInfoThread( lastfmpanel )
{
m_DbCache = dbcache;
//guLogMessage( wxT( "guFetchSimilarArtistInfoThread : '%s'" ), artistname );
m_ArtistName = wxString( artistname );
m_Start = startpage * GULASTFMINFO_MAXITEMS;
if( Create() == wxTHREAD_NO_ERROR )
{
SetPriority( WXTHREAD_DEFAULT_PRIORITY - 30 );
Run();
}
}
// -------------------------------------------------------------------------------- //
guFetchSimilarArtistInfoThread::~guFetchSimilarArtistInfoThread()
{
if( !TestDestroy() )
{
m_LastFMPanel->m_SimArtistsUpdateThreadMutex.Lock();
if( !TestDestroy() )
{
m_LastFMPanel->m_SimArtistsUpdateThread = NULL;
}
m_LastFMPanel->m_SimArtistsUpdateThreadMutex.Unlock();
}
}
// -------------------------------------------------------------------------------- //
guFetchSimilarArtistInfoThread::ExitCode guFetchSimilarArtistInfoThread::Entry()
{
guLastFM * LastFM = new guLastFM();
if( LastFM )
{
if( !TestDestroy() )
{
//guLogMessage( wxT( "==== Getting Similar Artists ====" ) );
guSimilarArtistInfoArray SimilarArtists = LastFM->ArtistGetSimilar( m_ArtistName );
int count = SimilarArtists.Count();
wxCommandEvent CountEvent( wxEVT_MENU, ID_LASTFM_UPDATE_SIMARTIST_COUNT );
CountEvent.SetInt( count );
wxPostEvent( m_LastFMPanel, CountEvent );
if( count )
{
//guLogMessage( wxT( "Similar Artists: %u" ), count );
count = wxMin( count, m_Start + GULASTFMINFO_MAXITEMS );
for( int index = m_Start; index < count; index++ )
{
m_DownloadThreadsMutex.Lock();
if( !TestDestroy() )
{
guLastFMSimilarArtistInfo * LastFMArtistInfo = new guLastFMSimilarArtistInfo( index - m_Start, NULL,
new guSimilarArtistInfo( SimilarArtists[ index ] ) );
if( LastFMArtistInfo )
{
LastFMArtistInfo->m_ImageUrl = SimilarArtists[ index ].m_ImageLink;
guDownloadImageThread* DownloadImageThread = new guDownloadImageThread(
m_LastFMPanel,
this,
m_DbCache,
index - m_Start,
SimilarArtists[ index ].m_ImageLink.c_str(),
ID_LASTFM_UPDATE_SIMARTIST,
LastFMArtistInfo,
&LastFMArtistInfo->m_Image,
guDBCACHE_TYPE_IMAGE_SIZE_TINY );
if( !DownloadImageThread )
{
guLogError( wxT( "Could not create the similar artist image download thread %u" ), index );
}
}
}
m_DownloadThreadsMutex.Unlock();
if( TestDestroy() )
break;
Sleep( GULASTFM_DOWNLOAD_IMAGE_DELAY );
}
}
}
delete LastFM;
//
WaitDownloadThreads();
}
return 0;
}
// -------------------------------------------------------------------------------- //
// guFetchEventsInfoThread
// -------------------------------------------------------------------------------- //
guFetchEventsInfoThread::guFetchEventsInfoThread( guLastFMPanel * lastfmpanel,
guDbCache * dbcache, const wxChar * artistname, const int startpage ) :
guFetchLastFMInfoThread( lastfmpanel )
{
m_DbCache = dbcache;
//guLogMessage( wxT( "guFetchEventsInfoThread : '%s'" ), artistname );
m_ArtistName = wxString( artistname );
m_Start = startpage * GULASTFMINFO_MAXITEMS;
if( Create() == wxTHREAD_NO_ERROR )
{
SetPriority( WXTHREAD_DEFAULT_PRIORITY - 30 );
Run();
}
}
// -------------------------------------------------------------------------------- //
guFetchEventsInfoThread::~guFetchEventsInfoThread()
{
if( !TestDestroy() )
{
m_LastFMPanel->m_EventsUpdateThreadMutex.Lock();
if( !TestDestroy() )
{
m_LastFMPanel->m_EventsUpdateThread = NULL;
}
m_LastFMPanel->m_EventsUpdateThreadMutex.Unlock();
}
}
// -------------------------------------------------------------------------------- //
guFetchEventsInfoThread::ExitCode guFetchEventsInfoThread::Entry()
{
guLastFM * LastFM = new guLastFM();
if( LastFM )
{
if( !TestDestroy() )
{
//guLogMessage( wxT( "==== Getting Artist Events ====" ) );
guEventInfoArray ArtistEvents = LastFM->ArtistGetEvents( m_ArtistName );
int count = ArtistEvents.Count();
wxCommandEvent CountEvent( wxEVT_MENU, ID_LASTFM_UPDATE_EVENTS_COUNT );
CountEvent.SetInt( count );
wxPostEvent( m_LastFMPanel, CountEvent );
if( count )
{
//guLogMessage( wxT( "Similar Artists: %u" ), count );
count = wxMin( count, m_Start + GULASTFMINFO_MAXITEMS );
for( int index = m_Start; index < count; index++ )
{
m_DownloadThreadsMutex.Lock();
if( !TestDestroy() )
{
guLastFMEventInfo * LastFMEventInfo = new guLastFMEventInfo( index - m_Start, NULL,
new guEventInfo( ArtistEvents[ index ] ) );
if( LastFMEventInfo )
{
LastFMEventInfo->m_ImageUrl = ArtistEvents[ index ].m_ImageLink;
guDownloadImageThread * DownloadImageThread = new guDownloadImageThread(
m_LastFMPanel,
this,
m_DbCache,
index - m_Start,
ArtistEvents[ index ].m_ImageLink.c_str(),
ID_LASTFM_UPDATE_EVENTINFO,
LastFMEventInfo,
&LastFMEventInfo->m_Image,
guDBCACHE_TYPE_IMAGE_SIZE_TINY );
if( !DownloadImageThread )
{
guLogError( wxT( "Could not create the event image download thread %u" ), index );
}
}
}
m_DownloadThreadsMutex.Unlock();
if( TestDestroy() )
break;
Sleep( GULASTFM_DOWNLOAD_IMAGE_DELAY );
}
}
}
delete LastFM;
//
WaitDownloadThreads();
}
return 0;
}
// -------------------------------------------------------------------------------- //
// guFetchSimTracksInfoThread
// -------------------------------------------------------------------------------- //
guFetchSimTracksInfoThread::guFetchSimTracksInfoThread( guLastFMPanel * lastfmpanel,
guDbCache * dbcache, const wxChar * artistname, const wxChar * trackname,
const int startpage ) :
guFetchLastFMInfoThread( lastfmpanel )
{
m_DbCache = dbcache;
m_ArtistName = wxString( artistname );
m_TrackName = wxString( trackname );
m_Start = startpage * GULASTFMINFO_MAXITEMS;
if( Create() == wxTHREAD_NO_ERROR )
{
SetPriority( WXTHREAD_DEFAULT_PRIORITY - 30 );
Run();
}
}
// -------------------------------------------------------------------------------- //
guFetchSimTracksInfoThread::~guFetchSimTracksInfoThread()
{
if( !TestDestroy() )
{
m_LastFMPanel->m_SimTracksUpdateThreadMutex.Lock();
if( !TestDestroy() )
{
m_LastFMPanel->m_SimTracksUpdateThread = NULL;
}
m_LastFMPanel->m_SimTracksUpdateThreadMutex.Unlock();
}
}
// -------------------------------------------------------------------------------- //
guFetchSimTracksInfoThread::ExitCode guFetchSimTracksInfoThread::Entry()
{
guLastFM * LastFM = new guLastFM();
if( LastFM )
{
if( !TestDestroy() )
{
//guLogMessage( wxT( "==== Getting Similar Tracks ====" ) );
guSimilarTrackInfoArray SimilarTracks = LastFM->TrackGetSimilar( m_ArtistName, m_TrackName );
int count = SimilarTracks.Count();
wxCommandEvent CountEvent( wxEVT_MENU, ID_LASTFM_UPDATE_SIMTRACK_COUNT );
CountEvent.SetInt( count );
wxPostEvent( m_LastFMPanel, CountEvent );
if( count )
{
//guLogMessage( wxT( "Similar Tracks: %u" ), count );
count = wxMin( count, m_Start + GULASTFMINFO_MAXITEMS );
for( int index = m_Start; index < count; index++ )
{
m_DownloadThreadsMutex.Lock();
if( !TestDestroy() )
{
guLastFMTrackInfo * LastFMTrackInfo = new guLastFMTrackInfo( index - m_Start, NULL,
new guSimilarTrackInfo( SimilarTracks[ index ] ) );
if( LastFMTrackInfo )
{
LastFMTrackInfo->m_ImageUrl = SimilarTracks[ index ].m_ImageLink;
guDownloadImageThread * DownloadImageThread = new guDownloadImageThread(
m_LastFMPanel,
this,
m_DbCache,
index - m_Start,
SimilarTracks[ index ].m_ImageLink.c_str(),
ID_LASTFM_UPDATE_SIMTRACK,
LastFMTrackInfo,
&LastFMTrackInfo->m_Image,
guDBCACHE_TYPE_IMAGE_SIZE_TINY );
if( !DownloadImageThread )
{
guLogError( wxT( "Could not create the track image download thread %u" ), index );
}
}
}
m_DownloadThreadsMutex.Unlock();
if( TestDestroy() )
break;
Sleep( GULASTFM_DOWNLOAD_IMAGE_DELAY );
}
}
}
delete LastFM;
//
WaitDownloadThreads();
}
return 0;
}
// -------------------------------------------------------------------------------- //
// guLastFMPanelDropTarget
// -------------------------------------------------------------------------------- //
guLastFMPanelDropTarget::guLastFMPanelDropTarget( guLastFMPanel * lastfmpanel )
{
m_LastFMPanel = lastfmpanel;
wxDataObjectComposite * DataObject = new wxDataObjectComposite();
wxCustomDataObject * TracksDataObject = new wxCustomDataObject( wxDataFormat( wxT( "x-gutracks/guayadeque-copied-tracks" ) ) );
DataObject->Add( TracksDataObject, true );
wxFileDataObject * FileDataObject = new wxFileDataObject();
DataObject->Add( FileDataObject, false );
SetDataObject( DataObject );
}
// -------------------------------------------------------------------------------- //
guLastFMPanelDropTarget::~guLastFMPanelDropTarget()
{
}
// -------------------------------------------------------------------------------- //
wxDragResult guLastFMPanelDropTarget::OnData( wxCoord x, wxCoord y, wxDragResult def )
{
//guLogMessage( wxT( "guListViewDropTarget::OnData" ) );
if( def == wxDragError || def == wxDragNone || def == wxDragCancel )
return def;
if( !GetData() )
{
guLogMessage( wxT( "Error getting drop data" ) );
return wxDragError;
}
guDataObjectComposite * DataObject = ( guDataObjectComposite * ) m_dataObject;
wxDataFormat ReceivedFormat = DataObject->GetReceivedFormat();
//guLogMessage( wxT( "ReceivedFormat: '%s'" ), ReceivedFormat.GetId().c_str() );
if( ReceivedFormat == wxDataFormat( wxT( "x-gutracks/guayadeque-copied-tracks" ) ) )
{
guTrackArray * Tracks;
if( !DataObject->GetDataHere( ReceivedFormat, &Tracks ) )
{
guLogMessage( wxT( "Error getting tracks data..." ) );
}
else
{
m_LastFMPanel->OnDropFiles( Tracks );
}
}
else if( ReceivedFormat == wxDataFormat( wxDF_FILENAME ) )
{
wxFileDataObject * FileDataObject = ( wxFileDataObject * ) DataObject->GetDataObject( wxDataFormat( wxDF_FILENAME ) );
if( FileDataObject )
{
m_LastFMPanel->OnDropFiles( FileDataObject->GetFilenames() );
}
}
return def;
}
}
// -------------------------------------------------------------------------------- //
| 163,056
|
C++
|
.cpp
| 3,653
| 37.095264
| 181
| 0.567105
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
750,657
|
ShowImage.cpp
|
anonbeat_guayadeque/src/ui/lastfmpanel/ShowImage.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "ShowImage.h"
#include "Utils.h"
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
guShowImage::guShowImage( wxWindow * parent, wxImage * image, const wxPoint &pos ) :
wxFrame( parent, wxID_ANY, wxEmptyString, pos, wxSize( image->GetWidth(), image->GetHeight() ), wxNO_BORDER | wxFRAME_NO_TASKBAR | wxTAB_TRAVERSAL )
{
m_CapturedMouse = false;
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* MainSizer;
MainSizer = new wxBoxSizer( wxVERTICAL );
m_Bitmap = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition,
wxSize( image->GetWidth(), image->GetHeight() ), 0 );
MainSizer->Add( m_Bitmap, 1, wxEXPAND, 5 );
this->SetSizer( MainSizer );
this->Layout();
if( image )
{
m_Bitmap->SetBitmap( wxBitmap( image->Copy() ) );
delete image;
}
Bind( wxEVT_ACTIVATE, &guShowImage::FrameActivate, this );
Bind( wxEVT_LEFT_DOWN, &guShowImage::OnClick, this );
Bind( wxEVT_RIGHT_DOWN, &guShowImage::OnClick, this );
Bind( wxEVT_MOUSEWHEEL, &guShowImage::OnClick, this );
m_Bitmap->Bind( wxEVT_MOTION, &guShowImage::OnMouse, this );
Bind( wxEVT_MOTION, &guShowImage::OnMouse, this );
Bind( wxEVT_MOUSE_CAPTURE_LOST, &guShowImage::OnCaptureLost, this );
}
// -------------------------------------------------------------------------------- //
guShowImage::~guShowImage()
{
if( m_CapturedMouse )
ReleaseMouse();
Unbind( wxEVT_ACTIVATE, &guShowImage::FrameActivate, this );
Unbind( wxEVT_LEFT_DOWN, &guShowImage::OnClick, this );
Unbind( wxEVT_RIGHT_DOWN, &guShowImage::OnClick, this );
Unbind( wxEVT_MOUSEWHEEL, &guShowImage::OnClick, this );
m_Bitmap->Unbind( wxEVT_MOTION, &guShowImage::OnMouse, this );
Unbind( wxEVT_MOTION, &guShowImage::OnMouse, this );
Unbind( wxEVT_MOUSE_CAPTURE_LOST, &guShowImage::OnCaptureLost, this );
}
// -------------------------------------------------------------------------------- //
void guShowImage::OnClick( wxMouseEvent &event )
{
Close();
}
// -------------------------------------------------------------------------------- //
void guShowImage::OnCaptureLost( wxMouseCaptureLostEvent &event )
{
m_CapturedMouse = false;
Close();
}
// -------------------------------------------------------------------------------- //
void guShowImage::FrameActivate( wxActivateEvent &event )
{
if( !event.GetActive() )
Close();
}
// -------------------------------------------------------------------------------- //
void guShowImage::OnMouse( wxMouseEvent &event )
{
int MouseX, MouseY;
wxGetMousePosition( &MouseX, &MouseY );
wxRect WinRect = m_Bitmap->GetScreenRect();
//guLogMessage( wxT( "Mouse: %i %i %i %i %i %i" ), MouseX, MouseY, WinRect.x, WinRect.y, WinRect.width, WinRect.height );
if( !WinRect.Contains( MouseX, MouseY ) )
{
Close();
}
else
{
if( !m_CapturedMouse )
{
m_CapturedMouse = true;
CaptureMouse();
}
}
event.Skip();
}
}
// -------------------------------------------------------------------------------- //
| 4,224
|
C++
|
.cpp
| 103
| 37.679612
| 152
| 0.561083
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,658
|
TaskBar.cpp
|
anonbeat_guayadeque/src/ui/taskbar/TaskBar.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "TaskBar.h"
#include "Images.h"
#include "EventCommandIds.h"
#include "Utils.h"
#include <wx/menu.h>
namespace Guayadeque {
// ---------------------------------------------------------------------- //
// guTaskBarIcon
// ---------------------------------------------------------------------- //
guTaskBarIcon::guTaskBarIcon( guMainFrame * NewMainFrame, guPlayerPanel * NewPlayerPanel ) : wxTaskBarIcon()
{
m_MainFrame = NewMainFrame;
m_PlayerPanel = NewPlayerPanel;
//
Bind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYERPANEL_PLAY );
Bind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYERPANEL_STOP );
Bind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYERPANEL_NEXTTRACK );
Bind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYERPANEL_NEXTALBUM );
Bind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYERPANEL_PREVTRACK );
Bind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYERPANEL_PREVALBUM );
Bind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_MENU_QUIT );
Bind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYER_PLAYMODE_SMART );
Bind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYER_PLAYMODE_REPEAT_PLAYLIST );
Bind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYER_PLAYMODE_REPEAT_TRACK );
Bind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYER_PLAYLIST_RANDOMPLAY );
Bind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYERPANEL_SETRATING_0, ID_PLAYERPANEL_SETRATING_5 );
Bind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_MAINFRAME_SETFORCEGAPLESS );
Bind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_MAINFRAME_SETAUDIOSCROBBLE );
Bind( wxEVT_TASKBAR_LEFT_DOWN, &guTaskBarIcon::OnClick, this );
}
// ---------------------------------------------------------------------- //
guTaskBarIcon::~guTaskBarIcon()
{
Unbind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYERPANEL_PLAY );
Unbind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYERPANEL_STOP );
Unbind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYERPANEL_NEXTTRACK );
Unbind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYERPANEL_NEXTALBUM );
Unbind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYERPANEL_PREVTRACK );
Unbind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYERPANEL_PREVALBUM );
Unbind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_MENU_QUIT );
Unbind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYER_PLAYMODE_SMART );
Unbind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYER_PLAYMODE_REPEAT_PLAYLIST );
Unbind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYER_PLAYMODE_REPEAT_TRACK );
Unbind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYER_PLAYLIST_RANDOMPLAY );
Unbind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_PLAYERPANEL_SETRATING_0, ID_PLAYERPANEL_SETRATING_5 );
Unbind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_MAINFRAME_SETFORCEGAPLESS );
Unbind( wxEVT_MENU, &guTaskBarIcon::SendEventToMainFrame, this, ID_MAINFRAME_SETAUDIOSCROBBLE );
Unbind( wxEVT_TASKBAR_LEFT_DOWN, &guTaskBarIcon::OnClick, this );
}
// ---------------------------------------------------------------------- //
void guTaskBarIcon::SendEventToMainFrame( wxCommandEvent &event )
{
wxPostEvent( m_MainFrame, event );
}
// ---------------------------------------------------------------------- //
void guTaskBarIcon::OnClick( wxTaskBarIconEvent &event )
{
if( m_MainFrame )
{
guConfig * Config = ( guConfig * ) guConfig::Get();
if( !m_MainFrame->IsShown() )
{
m_MainFrame->Show( true );
if( m_MainFrame->IsIconized() )
m_MainFrame->Iconize( false );
}
else if( Config->ReadBool( CONFIG_KEY_GENERAL_CLOSE_TO_TASKBAR, false, CONFIG_PATH_GENERAL ) )
{
m_MainFrame->Show( false );
}
else
{
m_MainFrame->Iconize( !m_MainFrame->IsIconized() );
}
}
}
// ---------------------------------------------------------------------- //
wxMenu * guTaskBarIcon::CreatePopupMenu()
{
wxMenu * Menu = new wxMenu;
wxMenuItem * MenuItem;
if( m_PlayerPanel )
{
bool IsPaused = ( m_PlayerPanel->GetState() == guMEDIASTATE_PLAYING );
MenuItem = new wxMenuItem( Menu, ID_PLAYERPANEL_PLAY, IsPaused ? _( "Pause" ) : _( "Play" ), _( "Play current playlist" ) );
//MenuItem->SetBitmap( guImage( IsPaused ? guIMAGE_INDEX_player_normal_pause : guIMAGE_INDEX_player_normal_play ) );
Menu->Append( MenuItem );
MenuItem = new wxMenuItem( Menu, ID_PLAYERPANEL_STOP, _( "Stop" ), _( "Play current playlist" ) );
//MenuItem->SetBitmap( guImage( guIMAGE_INDEX_player_normal_stop ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
MenuItem = new wxMenuItem( Menu, ID_PLAYERPANEL_NEXTTRACK, _( "Next Track" ), _( "Skip to next track in current playlist" ) );
//MenuItem->SetBitmap( guImage( guIMAGE_INDEX_player_normal_next ) );
Menu->Append( MenuItem );
MenuItem = new wxMenuItem( Menu, ID_PLAYERPANEL_NEXTALBUM, _( "Next Album" ), _( "Skip to next album track in current playlist" ) );
//MenuItem->SetBitmap( guImage( guIMAGE_INDEX_player_normal_next ) );
Menu->Append( MenuItem );
MenuItem = new wxMenuItem( Menu, ID_PLAYERPANEL_PREVTRACK, _( "Prev Track" ), _( "Skip to previous track in current playlist" ) );
//MenuItem->SetBitmap( guImage( guIMAGE_INDEX_player_normal_prev ) );
Menu->Append( MenuItem );
MenuItem = new wxMenuItem( Menu, ID_PLAYERPANEL_PREVALBUM, _( "Prev Album" ), _( "Skip to previous album track in current playlist" ) );
//MenuItem->SetBitmap( guImage( guIMAGE_INDEX_player_normal_prev ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
wxMenu * RatingMenu = new wxMenu();
int Rating = m_PlayerPanel->GetRating();
MenuItem = new wxMenuItem( RatingMenu, ID_PLAYERPANEL_SETRATING_0, wxT( "☆☆☆☆☆" ), _( "Set the rating to 0" ), wxITEM_CHECK );
RatingMenu->Append( MenuItem );
MenuItem->Check( Rating <= 0 );
MenuItem = new wxMenuItem( RatingMenu, ID_PLAYERPANEL_SETRATING_1, wxT( "★☆☆☆☆" ), _( "Set the rating to 1" ), wxITEM_CHECK );
RatingMenu->Append( MenuItem );
MenuItem->Check( Rating == 1 );
MenuItem = new wxMenuItem( RatingMenu, ID_PLAYERPANEL_SETRATING_2, wxT( "★★☆☆☆" ), _( "Set the rating to 2" ), wxITEM_CHECK );
RatingMenu->Append( MenuItem );
MenuItem->Check( Rating == 2 );
MenuItem = new wxMenuItem( RatingMenu, ID_PLAYERPANEL_SETRATING_3, wxT( "★★★☆☆" ), _( "Set the rating to 3" ), wxITEM_CHECK );
RatingMenu->Append( MenuItem );
MenuItem->Check( Rating == 3 );
MenuItem = new wxMenuItem( RatingMenu, ID_PLAYERPANEL_SETRATING_4, wxT( "★★★★☆" ), _( "Set the rating to 4" ), wxITEM_CHECK );
RatingMenu->Append( MenuItem );
MenuItem->Check( Rating == 4 );
MenuItem = new wxMenuItem( RatingMenu, ID_PLAYERPANEL_SETRATING_5, wxT( "★★★★★" ), _( "Set the rating to 5" ), wxITEM_CHECK );
RatingMenu->Append( MenuItem );
MenuItem->Check( Rating == 5 );
Menu->AppendSubMenu( RatingMenu, _( "Rating" ), _( "Set the current track rating" ) );
Menu->AppendSeparator();
MenuItem = new wxMenuItem( Menu, ID_PLAYER_PLAYMODE_SMART, _( "&Smart Play" ), _( "Update playlist based on Last.fm statics" ), wxITEM_CHECK );
Menu->Append( MenuItem );
MenuItem->Check( m_PlayerPanel->GetPlaySmart() );
MenuItem = new wxMenuItem( Menu, ID_PLAYER_PLAYMODE_REPEAT_PLAYLIST, _( "&Repeat Playlist" ), _( "Repeat the tracks in the playlist" ), wxITEM_CHECK );
Menu->Append( MenuItem );
MenuItem->Check( m_PlayerPanel->GetPlayMode() == guPLAYER_PLAYMODE_REPEAT_PLAYLIST );
MenuItem = new wxMenuItem( Menu, ID_PLAYER_PLAYMODE_REPEAT_TRACK, _( "&Repeat Track" ), _( "Repeat the current track in the playlist" ), wxITEM_CHECK );
Menu->Append( MenuItem );
MenuItem->Check( m_PlayerPanel->GetPlayMode() == guPLAYER_PLAYMODE_REPEAT_TRACK );
MenuItem = new wxMenuItem( Menu, ID_PLAYER_PLAYLIST_RANDOMPLAY, _( "R&andomize" ), _( "Randomize the playlist" ), wxITEM_NORMAL );
Menu->Append( MenuItem );
Menu->AppendSeparator();
}
MenuItem = new wxMenuItem( Menu, ID_MAINFRAME_SETFORCEGAPLESS, _( "Force Gapless Mode" ), _( "Set playback in gapless mode" ), wxITEM_CHECK );
Menu->Append( MenuItem );
MenuItem->Check( m_PlayerPanel->GetForceGapless() );
MenuItem = new wxMenuItem( Menu, ID_MAINFRAME_SETAUDIOSCROBBLE, _( "Audioscrobbling" ), _( "Send played tracks information" ), wxITEM_CHECK );
Menu->Append( MenuItem );
MenuItem->Check( m_PlayerPanel->GetAudioScrobbleEnabled() );
Menu->AppendSeparator();
MenuItem = new wxMenuItem( Menu, ID_MENU_QUIT, _( "Exit" ), _( "Exit this program" ) );
//MenuItem->SetBitmap( guImage( guIMAGE_INDEX_playback_stop ) );
Menu->Append( MenuItem );
return Menu;
}
}
// ---------------------------------------------------------------------- //
| 10,693
|
C++
|
.cpp
| 174
| 55.350575
| 160
| 0.638151
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,659
|
Preferences.cpp
|
anonbeat_guayadeque/src/ui/preferences/Preferences.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "Preferences.h"
#include "Accelerators.h"
#include "dbus/mpris2.h"
#include "Images.h"
#include "MD5.h"
#include "MediaCtrl.h"
#include "Settings.h"
#include "TagInfo.h"
#include "Transcode.h"
#include "Utils.h"
#include <wx/statline.h>
#include <wx/tokenzr.h>
#include <wx/uri.h>
#include <wx/arrimpl.cpp>
#include <id3v1genres.h>
namespace Guayadeque {
#define guPREFERENCES_LISTBOX_HEIGHT 110
WX_DEFINE_OBJARRAY( guCopyToPatternArray )
// -------------------------------------------------------------------------------- //
// guCopyToPattern
// -------------------------------------------------------------------------------- //
guCopyToPattern::guCopyToPattern()
{
m_Format = guTRANSCODE_FORMAT_KEEP;
m_Quality = guTRANSCODE_QUALITY_KEEP;
m_MoveFiles = false;
}
// -------------------------------------------------------------------------------- //
guCopyToPattern::guCopyToPattern( const wxString &pattern )
{
// Default:{g}/{a}/{b}/{n} - {a} - {t}:0:4:0
m_Format = guTRANSCODE_FORMAT_KEEP;
m_Quality = guTRANSCODE_QUALITY_KEEP;
m_MoveFiles = false;
wxArrayString Fields = wxStringTokenize( pattern, wxT( ":" ) );
int Count = Fields.Count();
if( Count )
{
for( int Index = 0; Index < Count; Index++ )
{
switch( Index )
{
case 0 : m_Name = unescape_configlist_str( Fields[ Index ] ); break;
case 1 : m_Pattern = unescape_configlist_str( Fields[ Index ] ); break;
case 2 : m_Format = wxAtoi( Fields[ Index ] ); break;
case 3 : m_Quality = wxAtoi( Fields[ Index ] ); break;
case 4 : m_MoveFiles = wxAtoi( Fields[ Index ] ); break;
case 5 : m_Path = unescape_configlist_str( Fields[ Index ] ); break;
default :
return;
}
}
}
}
// -------------------------------------------------------------------------------- //
guCopyToPattern::~guCopyToPattern()
{
}
// -------------------------------------------------------------------------------- //
wxString guCopyToPattern::ToString( void )
{
return wxString::Format( wxT( "%s:%s:%i:%i:%i:%s" ),
escape_configlist_str( m_Name ).c_str(), escape_configlist_str( m_Pattern ).c_str(),
m_Format, m_Quality, m_MoveFiles, escape_configlist_str( m_Path ).c_str() );
}
#define PREFERENCES_SCROLL_STEP 20
// -------------------------------------------------------------------------------- //
// guPrefDialog
// -------------------------------------------------------------------------------- //
guPrefDialog::guPrefDialog( wxWindow* parent, guDbLibrary * db, int pagenum )
{
wxBoxSizer * MainSizer;
m_Db = db;
m_LinkSelected = wxNOT_FOUND;
m_CmdSelected = wxNOT_FOUND;
m_CopyToSelected = wxNOT_FOUND;
m_LibPathsChanged = false;
m_VisiblePanels = 0;
m_CopyToOptions = NULL;
m_LyricSearchEngine = NULL;
m_LyricSourceSelected = wxNOT_FOUND;
m_LibOptCopyToChoice = NULL;
m_Config = ( guConfig * ) guConfig::Get();
if( !m_Config )
guLogError( wxT( "Invalid m_Config object in preferences dialog" ) );
wxPoint WindowPos;
WindowPos.x = m_Config->ReadNum( CONFIG_KEY_PREFERENCES_POSX, -1, CONFIG_PATH_PREFERENCES );
WindowPos.y = m_Config->ReadNum( CONFIG_KEY_PREFERENCES_POSY, -1, CONFIG_PATH_PREFERENCES );
wxSize WindowSize;
WindowSize.x = m_Config->ReadNum( CONFIG_KEY_PREFERENCES_WIDTH, 600, CONFIG_PATH_PREFERENCES );
WindowSize.y = m_Config->ReadNum( CONFIG_KEY_PREFERENCES_HEIGHT, 530, CONFIG_PATH_PREFERENCES );
//wxDialog( parent, wxID_ANY, _( "Songs Editor" ), wxDefaultPosition, wxSize( 625, 440 ), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
Create( parent, wxID_ANY, _( "Preferences" ), WindowPos, WindowSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX );
//
m_MainLangChoices.Add( _( "Default" ) );
m_MainLangChoices.Add( _( "Czech" ) );
m_MainLangChoices.Add( _( "Danish" ) );
m_MainLangChoices.Add( _( "Dutch" ) );
m_MainLangChoices.Add( _( "English" ) );
m_MainLangChoices.Add( _( "French" ) );
m_MainLangChoices.Add( _( "German" ) );
m_MainLangChoices.Add( _( "Greek" ) );
m_MainLangChoices.Add( _( "Hungarian" ) );
m_MainLangChoices.Add( _( "Icelandic" ) );
m_MainLangChoices.Add( _( "Italian" ) );
m_MainLangChoices.Add( _( "Japanese" ) );
m_MainLangChoices.Add( _( "Lithuanian" ) );
m_MainLangChoices.Add( _( "Malay (Malaysia)" ) );
m_MainLangChoices.Add( _( "Norwegian Bokmal" ) );
m_MainLangChoices.Add( _( "Polish" ) );
m_MainLangChoices.Add( _( "Portuguese" ) );
m_MainLangChoices.Add( _( "Portuguese-Brazilian" ) );
m_MainLangChoices.Add( _( "Russian" ) );
m_MainLangChoices.Add( _( "Slovak" ) );
m_MainLangChoices.Add( _( "Spanish" ) );
m_MainLangChoices.Add( _( "Swedish" ) );
m_MainLangChoices.Add( _( "Thai" ) );
m_MainLangChoices.Add( _( "Turkish" ) );
m_MainLangChoices.Add( _( "Ukrainian" ) );
m_MainLangChoices.Add( _( "Bulgarian" ) );
m_MainLangChoices.Add( _( "Catalan" ) );
m_MainLangChoices.Add( _( "Serbian" ) );
m_MainLangCodes.Add( wxLANGUAGE_DEFAULT );
m_MainLangCodes.Add( wxLANGUAGE_CZECH );
m_MainLangCodes.Add( wxLANGUAGE_DANISH );
m_MainLangCodes.Add( wxLANGUAGE_DUTCH );
m_MainLangCodes.Add( wxLANGUAGE_ENGLISH );
m_MainLangCodes.Add( wxLANGUAGE_FRENCH );
m_MainLangCodes.Add( wxLANGUAGE_GERMAN );
m_MainLangCodes.Add( wxLANGUAGE_GREEK );
m_MainLangCodes.Add( wxLANGUAGE_HUNGARIAN );
m_MainLangCodes.Add( wxLANGUAGE_ICELANDIC );
m_MainLangCodes.Add( wxLANGUAGE_ITALIAN );
m_MainLangCodes.Add( wxLANGUAGE_JAPANESE );
m_MainLangCodes.Add( wxLANGUAGE_LITHUANIAN );
m_MainLangCodes.Add( wxLANGUAGE_MALAY_MALAYSIA );
m_MainLangCodes.Add( wxLANGUAGE_NORWEGIAN_BOKMAL );
m_MainLangCodes.Add( wxLANGUAGE_POLISH );
m_MainLangCodes.Add( wxLANGUAGE_PORTUGUESE );
m_MainLangCodes.Add( wxLANGUAGE_PORTUGUESE_BRAZILIAN );
m_MainLangCodes.Add( wxLANGUAGE_RUSSIAN );
m_MainLangCodes.Add( wxLANGUAGE_SLOVAK );
m_MainLangCodes.Add( wxLANGUAGE_SPANISH );
m_MainLangCodes.Add( wxLANGUAGE_SWEDISH );
m_MainLangCodes.Add( wxLANGUAGE_THAI );
m_MainLangCodes.Add( wxLANGUAGE_TURKISH );
m_MainLangCodes.Add( wxLANGUAGE_UKRAINIAN );
m_MainLangCodes.Add( wxLANGUAGE_BULGARIAN );
m_MainLangCodes.Add( wxLANGUAGE_CATALAN );
m_MainLangCodes.Add( wxLANGUAGE_SERBIAN );
m_LFMLangNames.Add( _( "Default" ) ); m_LFMLangIds.Add( wxEmptyString );
m_LFMLangNames.Add( _( "English" ) ); m_LFMLangIds.Add( wxT( "en" ) );
m_LFMLangNames.Add( _( "French" ) ); m_LFMLangIds.Add( wxT( "fr" ) );
m_LFMLangNames.Add( _( "German" ) ); m_LFMLangIds.Add( wxT( "de" ) );
m_LFMLangNames.Add( _( "Italian" ) ); m_LFMLangIds.Add( wxT( "it" ) );
m_LFMLangNames.Add( _( "Portuguese" ) ); m_LFMLangIds.Add( wxT( "pt" ) );
m_LFMLangNames.Add( _( "Spanish" ) ); m_LFMLangIds.Add( wxT( "es" ) );
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
MainSizer = new wxBoxSizer( wxVERTICAL );
m_MainNotebook = new wxListbook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT );
m_ImageList = new wxImageList( 32, 32 );
m_ImageList->Add( guImage( guIMAGE_INDEX_pref_general ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_pref_library ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_pref_playback ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_pref_crossfader ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_pref_record ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_pref_last_fm ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_pref_lyrics ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_pref_online_services ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_pref_podcasts ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_pref_jamendo ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_pref_magnatune ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_pref_links ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_pref_commands ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_pref_copy_to ) );
m_ImageList->Add( guImage( guIMAGE_INDEX_pref_accelerators ) );
m_MainNotebook->AssignImageList( m_ImageList );
m_GenPanel = new wxScrolledWindow( m_MainNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL|wxTAB_TRAVERSAL );
m_MainNotebook->AddPage( m_GenPanel, _("General"), true, 0 );
m_GenPanel->SetScrollRate( PREFERENCES_SCROLL_STEP, PREFERENCES_SCROLL_STEP );
m_LibPanel = new wxScrolledWindow( m_MainNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL|wxTAB_TRAVERSAL );
m_MainNotebook->AddPage( m_LibPanel, _("Collections"), false );
m_MainNotebook->SetPageImage( 1, 1 );
m_LibPanel->SetScrollRate( PREFERENCES_SCROLL_STEP, PREFERENCES_SCROLL_STEP );
m_PlayPanel = new wxScrolledWindow( m_MainNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL|wxTAB_TRAVERSAL );
m_MainNotebook->AddPage( m_PlayPanel, _( "Playback" ), false );
m_MainNotebook->SetPageImage( 2, 2 );
m_PlayPanel->SetScrollRate( PREFERENCES_SCROLL_STEP, PREFERENCES_SCROLL_STEP );
m_XFadePanel = new wxScrolledWindow( m_MainNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL|wxTAB_TRAVERSAL );
m_MainNotebook->AddPage( m_XFadePanel, _( "Crossfader" ), false );
m_MainNotebook->SetPageImage( 3, 3 );
m_XFadePanel->SetScrollRate( PREFERENCES_SCROLL_STEP, PREFERENCES_SCROLL_STEP );
m_RecordPanel = new wxScrolledWindow( m_MainNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL|wxTAB_TRAVERSAL );
m_MainNotebook->AddPage( m_RecordPanel, _( "Record" ), false );
m_MainNotebook->SetPageImage( 4, 4 );
m_RecordPanel->SetScrollRate( PREFERENCES_SCROLL_STEP, PREFERENCES_SCROLL_STEP );
m_LastFMPanel = new wxScrolledWindow( m_MainNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL|wxTAB_TRAVERSAL );
m_MainNotebook->AddPage( m_LastFMPanel, _( "Audioscrobble" ), false );
m_MainNotebook->SetPageImage( 5, 5 );
m_LastFMPanel->SetScrollRate( PREFERENCES_SCROLL_STEP, PREFERENCES_SCROLL_STEP );
m_LyricsPanel = new wxScrolledWindow( m_MainNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL|wxTAB_TRAVERSAL );
m_MainNotebook->AddPage( m_LyricsPanel, _( "Lyrics" ), false );
m_MainNotebook->SetPageImage( 6, 6 );
m_LyricsPanel->SetScrollRate( PREFERENCES_SCROLL_STEP, PREFERENCES_SCROLL_STEP );
m_OnlinePanel = new wxScrolledWindow( m_MainNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL|wxTAB_TRAVERSAL );
m_MainNotebook->AddPage( m_OnlinePanel, _( "Online" ), false );
m_MainNotebook->SetPageImage( 7, 7 );
m_OnlinePanel->SetScrollRate( PREFERENCES_SCROLL_STEP, PREFERENCES_SCROLL_STEP );
m_PodcastPanel = new wxScrolledWindow( m_MainNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL|wxTAB_TRAVERSAL );
m_MainNotebook->AddPage( m_PodcastPanel, _("Podcasts"), false );
m_MainNotebook->SetPageImage( 8, 8 );
m_PodcastPanel->SetScrollRate( PREFERENCES_SCROLL_STEP, PREFERENCES_SCROLL_STEP );
m_JamendoPanel = new wxScrolledWindow( m_MainNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL|wxTAB_TRAVERSAL );
m_MainNotebook->AddPage( m_JamendoPanel, wxT("Jamendo"), false );
m_MainNotebook->SetPageImage( 9, 9 );
m_JamendoPanel->SetScrollRate( PREFERENCES_SCROLL_STEP, PREFERENCES_SCROLL_STEP );
m_MagnatunePanel = new wxScrolledWindow( m_MainNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL|wxTAB_TRAVERSAL );
m_MainNotebook->AddPage( m_MagnatunePanel, wxT("Magnatune"), false );
m_MainNotebook->SetPageImage( 10, 10 );
m_MagnatunePanel->SetScrollRate( PREFERENCES_SCROLL_STEP, PREFERENCES_SCROLL_STEP );
m_LinksPanel = new wxScrolledWindow( m_MainNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL|wxTAB_TRAVERSAL );
m_MainNotebook->AddPage( m_LinksPanel, _("Links"), false );
m_MainNotebook->SetPageImage( 11, 11 );
m_LinksPanel->SetScrollRate( PREFERENCES_SCROLL_STEP, PREFERENCES_SCROLL_STEP );
m_CmdPanel = new wxScrolledWindow( m_MainNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL|wxTAB_TRAVERSAL );
m_MainNotebook->AddPage( m_CmdPanel, _( "Commands" ), false );
m_MainNotebook->SetPageImage( 12, 12 );
m_CmdPanel->SetScrollRate( PREFERENCES_SCROLL_STEP, PREFERENCES_SCROLL_STEP );
m_CopyPanel = new wxScrolledWindow( m_MainNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL|wxTAB_TRAVERSAL );
m_MainNotebook->AddPage( m_CopyPanel, _( "Copy to" ), false );
m_MainNotebook->SetPageImage( 13, 13 );
m_CopyPanel->SetScrollRate( PREFERENCES_SCROLL_STEP, PREFERENCES_SCROLL_STEP );
m_AccelPanel = new wxScrolledWindow( m_MainNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL|wxTAB_TRAVERSAL );
m_MainNotebook->AddPage( m_AccelPanel, _( "Shortcuts" ), false );
m_MainNotebook->SetPageImage( 14, 14 );
m_AccelPanel->SetScrollRate( PREFERENCES_SCROLL_STEP, PREFERENCES_SCROLL_STEP );
if( pagenum == guPREFERENCE_PAGE_LASTUSED )
{
pagenum = m_Config->ReadNum( CONFIG_KEY_PREFERENCES_LAST_PAGE, guPREFERENCE_PAGE_GENERAL, CONFIG_PATH_PREFERENCES );
}
switch( pagenum )
{
case guPREFERENCE_PAGE_GENERAL :
BuildGeneralPage();
break;
case guPREFERENCE_PAGE_LIBRARY :
BuildLibraryPage();
break;
case guPREFERENCE_PAGE_PLAYBACK :
BuildPlaybackPage();
break;
case guPREFERENCE_PAGE_CROSSFADER :
BuildCrossfaderPage();
break;
case guPREFERENCE_PAGE_RECORD :
BuildRecordPage();
break;
case guPREFERENCE_PAGE_AUDIOSCROBBLE :
BuildAudioScrobblePage();
break;
case guPREFERENCE_PAGE_LYRICS :
BuildLyricsPage();
break;
case guPREFERENCE_PAGE_ONLINE :
BuildOnlinePage();
break;
case guPREFERENCE_PAGE_PODCASTS :
BuildPodcastsPage();
break;
case guPREFERENCE_PAGE_JAMENDO :
BuildJamendoPage();
break;
case guPREFERENCE_PAGE_MAGNATUNE :
BuildMagnatunePage();
break;
case guPREFERENCE_PAGE_LINKS :
BuildLinksPage();
break;
case guPREFERENCE_PAGE_COMMANDS :
BuildCommandsPage();
break;
case guPREFERENCE_PAGE_COPYTO :
BuildCopyToPage();
break;
case guPREFERENCE_PAGE_ACCELERATORS :
BuildAcceleratorsPage();
break;
}
m_MainNotebook->SetSelection( pagenum );
//
MainSizer->Add( m_MainNotebook, 1, wxEXPAND | wxALL, 5 );
wxStdDialogButtonSizer * ButtonsSizer;
wxButton * ButtonsSizerOK;
wxButton * ButtonsSizerCancel;
ButtonsSizer = new wxStdDialogButtonSizer();
ButtonsSizerOK = new wxButton( this, wxID_OK, _( " Accept " ) );
ButtonsSizer->AddButton( ButtonsSizerOK );
ButtonsSizerCancel = new wxButton( this, wxID_CANCEL, _( " Cancel " ) );
ButtonsSizer->AddButton( ButtonsSizerCancel );
ButtonsSizer->SetAffirmativeButton( ButtonsSizerOK );
ButtonsSizer->SetCancelButton( ButtonsSizerCancel );
ButtonsSizer->Realize();
MainSizer->Add( ButtonsSizer, 0, wxEXPAND|wxBOTTOM|wxLEFT|wxRIGHT, 5 );
this->SetSizer( MainSizer );
this->Layout();
ButtonsSizerOK->SetDefault();
m_MainNotebook->Bind( wxEVT_LISTBOOK_PAGE_CHANGED, &guPrefDialog::OnPageChanged, this );
//
//
//
m_PathSelected = wxNOT_FOUND;
m_FilterSelected = wxNOT_FOUND;
}
// -------------------------------------------------------------------------------- //
guPrefDialog::~guPrefDialog()
{
guConfig * Config = ( guConfig * ) guConfig::Get();
// Save the window position and size
wxPoint WindowPos = GetPosition();
Config->WriteNum( CONFIG_KEY_PREFERENCES_POSX, WindowPos.x, CONFIG_PATH_PREFERENCES );
Config->WriteNum( CONFIG_KEY_PREFERENCES_POSY, WindowPos.y, CONFIG_PATH_PREFERENCES );
wxSize WindowSize = GetSize();
Config->WriteNum( CONFIG_KEY_PREFERENCES_WIDTH, WindowSize.x, CONFIG_PATH_PREFERENCES );
Config->WriteNum( CONFIG_KEY_PREFERENCES_HEIGHT, WindowSize.y, CONFIG_PATH_PREFERENCES );
m_Config->WriteNum( CONFIG_KEY_PREFERENCES_LAST_PAGE, m_MainNotebook->GetSelection(), CONFIG_PATH_PREFERENCES );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::LibSplitterOnIdle( wxIdleEvent &event )
{
m_LibSplitter->SetSashPosition( 170 );
m_LibSplitter->Unbind( wxEVT_IDLE, &guPrefDialog::LibSplitterOnIdle, this );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnPageChanged( wxCommandEvent &event )
{
switch( m_MainNotebook->GetSelection() )
{
case guPREFERENCE_PAGE_GENERAL : BuildGeneralPage(); break;
case guPREFERENCE_PAGE_LIBRARY : BuildLibraryPage(); break;
case guPREFERENCE_PAGE_PLAYBACK : BuildPlaybackPage(); break;
case guPREFERENCE_PAGE_CROSSFADER : BuildCrossfaderPage(); break;
case guPREFERENCE_PAGE_RECORD : BuildRecordPage(); break;
case guPREFERENCE_PAGE_AUDIOSCROBBLE : BuildAudioScrobblePage(); break;
case guPREFERENCE_PAGE_LYRICS : BuildLyricsPage(); break;
case guPREFERENCE_PAGE_ONLINE : BuildOnlinePage(); break;
case guPREFERENCE_PAGE_PODCASTS : BuildPodcastsPage(); break;
case guPREFERENCE_PAGE_JAMENDO : BuildJamendoPage(); break;
case guPREFERENCE_PAGE_MAGNATUNE : BuildMagnatunePage(); break;
case guPREFERENCE_PAGE_LINKS : BuildLinksPage(); break;
case guPREFERENCE_PAGE_COMMANDS : BuildCommandsPage(); break;
case guPREFERENCE_PAGE_COPYTO : BuildCopyToPage(); break;
case guPREFERENCE_PAGE_ACCELERATORS : BuildAcceleratorsPage(); break;
}
event.Skip();
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::BuildGeneralPage( void )
{
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_GENERAL )
return;
m_VisiblePanels |= guPREFERENCE_PAGE_FLAG_GENERAL;
//
// General Preferences Panel
//
wxBoxSizer * GenMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer * StartSizer = new wxStaticBoxSizer( new wxStaticBox( m_GenPanel, wxID_ANY, _(" On Start ") ), wxVERTICAL );
wxBoxSizer * LangSizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticText * LangStaticText = new wxStaticText( m_GenPanel, wxID_ANY, _( "Language:" ), wxDefaultPosition, wxDefaultSize, 0 );
LangStaticText->Wrap( -1 );
LangSizer->Add( LangStaticText, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxBOTTOM, 5 );
m_MainLangChoice = new wxChoice( m_GenPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_MainLangChoices, 0 );
int LangEntry = m_MainLangCodes.Index( m_Config->ReadNum( CONFIG_KEY_GENERAL_LANGUAGE, 0, CONFIG_PATH_GENERAL ) );
if( LangEntry == wxNOT_FOUND )
LangEntry = 0;
m_MainLangChoice->SetSelection( LangEntry );
LangSizer->Add( m_MainLangChoice, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxBOTTOM, 5 );
wxStaticText * LangNoteStaticText = new wxStaticText( m_GenPanel, wxID_ANY, _( "(Needs restart)" ), wxDefaultPosition, wxDefaultSize, 0 );
LangNoteStaticText->Wrap( -1 );
LangSizer->Add( LangNoteStaticText, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxBOTTOM, 5 );
StartSizer->Add( LangSizer, 1, wxEXPAND, 5 );
m_ShowSplashChkBox = new wxCheckBox( m_GenPanel, wxID_ANY, _("Show splash screen"), wxDefaultPosition, wxDefaultSize, 0 );
m_ShowSplashChkBox->SetValue( m_Config->ReadBool( CONFIG_KEY_GENERAL_SHOW_SPLASH_SCREEN, true, CONFIG_PATH_GENERAL ) );
StartSizer->Add( m_ShowSplashChkBox, 0, wxLEFT | wxRIGHT, 5 );
m_MinStartChkBox = new wxCheckBox( m_GenPanel, wxID_ANY, _("Start minimized"), wxDefaultPosition, wxDefaultSize, 0 );
m_MinStartChkBox->SetValue( m_Config->ReadBool( CONFIG_KEY_GENERAL_START_MINIMIZED, false, CONFIG_PATH_GENERAL ) );
StartSizer->Add( m_MinStartChkBox, 0, wxLEFT | wxRIGHT, 5 );
wxBoxSizer * StartPlayingSizer = new wxBoxSizer( wxHORIZONTAL );
m_SavePosCheckBox = new wxCheckBox( m_GenPanel, wxID_ANY, _("Restore position for tracks longer than"), wxDefaultPosition, wxDefaultSize, 0 );
m_SavePosCheckBox->SetValue( m_Config->ReadBool( CONFIG_KEY_GENERAL_SAVE_CURRENT_TRACK_POSITION, false, CONFIG_PATH_GENERAL ) );
StartPlayingSizer->Add( m_SavePosCheckBox, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_MinLenSpinCtrl = new wxSpinCtrl( m_GenPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 9999, 10 );
m_MinLenSpinCtrl->SetValue( m_Config->ReadNum( CONFIG_KEY_GENERAL_MIN_SAVE_PLAYL_POST_LENGTH, 10, CONFIG_PATH_GENERAL ) );
m_MinLenSpinCtrl->SetToolTip( _( "set the minimun length in minutes to save track position" ) );
StartPlayingSizer->Add( m_MinLenSpinCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 );
wxStaticText * MinLenStaticText = new wxStaticText( m_GenPanel, wxID_ANY, _("minutes"), wxDefaultPosition, wxDefaultSize, 0 );
MinLenStaticText->Wrap( -1 );
StartPlayingSizer->Add( MinLenStaticText, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
StartSizer->Add( StartPlayingSizer, 1, wxEXPAND, 5 );
m_IgnoreLayoutsChkBox = new wxCheckBox( m_GenPanel, wxID_ANY, _( "Load default layout" ), wxDefaultPosition, wxDefaultSize, 0 );
m_IgnoreLayoutsChkBox->SetValue( m_Config->ReadBool( CONFIG_KEY_GENERAL_LOAD_DEFAULT_LAYOUTS, false, CONFIG_PATH_GENERAL ) );
StartSizer->Add( m_IgnoreLayoutsChkBox, 0, wxRIGHT|wxLEFT, 5 );
GenMainSizer->Add( StartSizer, 0, wxEXPAND|wxALL, 5 );
wxStaticBoxSizer * BehaviSizer = new wxStaticBoxSizer( new wxStaticBox( m_GenPanel, wxID_ANY, _(" Behaviour ") ), wxVERTICAL );
m_TaskIconChkBox = new wxCheckBox( m_GenPanel, wxID_ANY, _("Activate task bar icon"), wxDefaultPosition, wxDefaultSize, 0 );
m_TaskIconChkBox->SetValue( m_Config->ReadBool( CONFIG_KEY_GENERAL_SHOW_TASK_BAR_ICON, false, CONFIG_PATH_GENERAL ) );
BehaviSizer->Add( m_TaskIconChkBox, 0, wxLEFT | wxRIGHT, 5 );
m_SoundMenuChkBox = NULL;
guMPRIS2 * MPRIS2 = guMPRIS2::Get();
bool IsSoundMenuAvailable = MPRIS2->Indicators_Sound_Available();
if( IsSoundMenuAvailable )
{
m_SoundMenuChkBox = new wxCheckBox( m_GenPanel, wxID_ANY, _( "Integrate into SoundMenu" ), wxDefaultPosition, wxDefaultSize, 0 );
m_SoundMenuChkBox->SetValue( m_Config->ReadBool( CONFIG_KEY_GENERAL_SOUND_MENU_INTEGRATE, false, CONFIG_PATH_GENERAL ) );
m_SoundMenuChkBox->Enable( m_TaskIconChkBox->IsChecked() );
BehaviSizer->Add( m_SoundMenuChkBox, 0, wxLEFT | wxRIGHT, 5 );
}
m_EnqueueChkBox = new wxCheckBox( m_GenPanel, wxID_ANY, _("Enqueue as default action"), wxDefaultPosition, wxDefaultSize, 0 );
m_EnqueueChkBox->SetValue( m_Config->ReadBool( CONFIG_KEY_GENERAL_ACTION_ENQUEUE, false, CONFIG_PATH_GENERAL ) );
BehaviSizer->Add( m_EnqueueChkBox, 0, wxLEFT | wxRIGHT, 5 );
m_DropFilesChkBox = new wxCheckBox( m_GenPanel, wxID_ANY, _("Drop files clear playlist"), wxDefaultPosition, wxDefaultSize, 0 );
m_DropFilesChkBox->SetValue( m_Config->ReadBool( CONFIG_KEY_GENERAL_DROP_FILES_CLEAR_PLAYLIST, false, CONFIG_PATH_GENERAL ) );
BehaviSizer->Add( m_DropFilesChkBox, 0, wxLEFT | wxRIGHT, 5 );
m_InstantSearchChkBox = new wxCheckBox( m_GenPanel, wxID_ANY, _( "Instant text search" ), wxDefaultPosition, wxDefaultSize, 0 );
m_InstantSearchChkBox->SetValue( m_Config->ReadBool( CONFIG_KEY_GENERAL_INSTANT_TEXT_SEARCH, true, CONFIG_PATH_GENERAL ) );
BehaviSizer->Add( m_InstantSearchChkBox, 0, wxLEFT | wxRIGHT, 5 );
m_EnterSearchChkBox = new wxCheckBox( m_GenPanel, wxID_ANY, _( "When searching, pressing enter queues the result" ), wxDefaultPosition, wxDefaultSize, 0 );
m_EnterSearchChkBox->SetValue( m_Config->ReadBool( CONFIG_KEY_GENERAL_TEXT_SEARCH_ENTER, false, CONFIG_PATH_GENERAL ) );
m_EnterSearchChkBox->Enable( m_InstantSearchChkBox->IsChecked() );
BehaviSizer->Add( m_EnterSearchChkBox, 0, wxLEFT | wxRIGHT, 5 );
m_ShowCDFrameChkBox = new wxCheckBox( m_GenPanel, wxID_ANY, _( "Show CD cover frame in player" ), wxDefaultPosition, wxDefaultSize, 0 );
m_ShowCDFrameChkBox->SetValue( m_Config->ReadNum( CONFIG_KEY_GENERAL_COVER_FRAME, 1, CONFIG_PATH_GENERAL ) );
BehaviSizer->Add( m_ShowCDFrameChkBox, 0, wxLEFT | wxRIGHT, 5 );
GenMainSizer->Add( BehaviSizer, 0, wxEXPAND|wxALL, 5 );
wxStaticBoxSizer * OnCloseSizer = new wxStaticBoxSizer( new wxStaticBox( m_GenPanel, wxID_ANY, _(" On Close ") ), wxVERTICAL );
m_SavePlayListChkBox = new wxCheckBox( m_GenPanel, wxID_ANY, _("Save playlist on close"), wxDefaultPosition, wxDefaultSize, 0 );
m_SavePlayListChkBox->SetValue( m_Config->ReadBool( wxT( "SaveOnClose" ), true, wxT( "playlist" ) ) );
OnCloseSizer->Add( m_SavePlayListChkBox, 0, wxLEFT | wxRIGHT, 5 );
m_CloseTaskBarChkBox = new wxCheckBox( m_GenPanel, wxID_ANY, _("Close to task bar icon"), wxDefaultPosition, wxDefaultSize, 0 );
m_CloseTaskBarChkBox->SetValue( m_Config->ReadBool( CONFIG_KEY_GENERAL_CLOSE_TO_TASKBAR, false, CONFIG_PATH_GENERAL ) );
m_CloseTaskBarChkBox->Enable( m_TaskIconChkBox->IsChecked() && ( !m_SoundMenuChkBox || !m_SoundMenuChkBox->IsChecked() ) );
OnCloseSizer->Add( m_CloseTaskBarChkBox, 0, wxLEFT | wxRIGHT, 5 );
m_ExitConfirmChkBox = new wxCheckBox( m_GenPanel, wxID_ANY, _("Ask confirmation on exit"), wxDefaultPosition, wxDefaultSize, 0 );
m_ExitConfirmChkBox->SetValue( m_Config->ReadBool( CONFIG_KEY_GENERAL_SHOW_CLOSE_CONFIRM, true, CONFIG_PATH_GENERAL ) );
m_ExitConfirmChkBox->Enable( !m_SoundMenuChkBox || !m_SoundMenuChkBox->IsChecked() );
OnCloseSizer->Add( m_ExitConfirmChkBox, 0, wxLEFT | wxRIGHT, 5 );
GenMainSizer->Add( OnCloseSizer, 0, wxEXPAND|wxALL, 5 );
m_GenPanel->SetSizer( GenMainSizer );
m_GenPanel->Layout();
GenMainSizer->FitInside( m_GenPanel );
m_TaskIconChkBox->Bind( wxEVT_CHECKBOX, &guPrefDialog::OnActivateTaskBarIcon, this );
if( m_SoundMenuChkBox )
m_SoundMenuChkBox->Bind( wxEVT_CHECKBOX, &guPrefDialog::OnActivateSoundMenuIntegration, this );
m_InstantSearchChkBox->Bind( wxEVT_CHECKBOX, &guPrefDialog::OnActivateInstantSearch, this );
m_ShowSplashChkBox->SetFocus();
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::BuildLibraryPage( void )
{
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_LIBRARY )
return;
m_VisiblePanels |= guPREFERENCE_PAGE_FLAG_LIBRARY;
//
// Library Preferences Panel
//
m_CollectSelected = wxNOT_FOUND;
m_PathSelected = wxNOT_FOUND;
m_CoverSelected = wxNOT_FOUND;
wxBoxSizer * LibMainFrame = new wxBoxSizer( wxVERTICAL );
m_LibSplitter = new wxSplitterWindow( m_LibPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D );
m_LibSplitter->SetMinimumPaneSize( 100 );
//wxPanel * LibCollectPanel = new wxPanel( m_LibSplitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxScrolledWindow * LibCollectPanel = new wxScrolledWindow( m_LibSplitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer * LibCollectMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer * LibCollectSizer = new wxStaticBoxSizer( new wxStaticBox( LibCollectPanel, wxID_ANY, _( " Collections " ) ), wxHORIZONTAL );
m_Config->LoadCollections( &m_Collections, guMEDIA_COLLECTION_TYPE_NORMAL );
m_Config->LoadCollections( &m_Collections, guMEDIA_COLLECTION_TYPE_PORTABLE_DEVICE );
m_Config->LoadCollections( &m_Collections, guMEDIA_COLLECTION_TYPE_IPOD );
m_LibCollectListBox = new wxListBox( LibCollectPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL|wxLB_SINGLE );
int Count = m_Collections.Count();
for( int Index = 0; Index < Count; Index++ )
{
m_LibCollectListBox->Append( m_Collections[ Index ].m_Name );
}
LibCollectSizer->Add( m_LibCollectListBox, 1, wxALL|wxEXPAND, 5 );
wxBoxSizer * LibCollectBtnSizer = new wxBoxSizer( wxVERTICAL );
m_LibCollectAddBtn = new wxBitmapButton( LibCollectPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_add ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
LibCollectBtnSizer->Add( m_LibCollectAddBtn, 0, wxTOP, 5 );
m_LibCollectUpBtn = new wxBitmapButton( LibCollectPanel, wxID_ANY, guImage( guIMAGE_INDEX_up ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LibCollectUpBtn->Enable( false );
LibCollectBtnSizer->Add( m_LibCollectUpBtn, 0, 0, 5 );
m_LibCollectDownBtn = new wxBitmapButton( LibCollectPanel, wxID_ANY, guImage( guIMAGE_INDEX_down ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LibCollectDownBtn->Enable( false );
LibCollectBtnSizer->Add( m_LibCollectDownBtn, 0, 0, 5 );
m_LibCollectDelBtn = new wxBitmapButton( LibCollectPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_del ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LibCollectDelBtn->Enable( false );
LibCollectBtnSizer->Add( m_LibCollectDelBtn, 0, wxBOTTOM, 5 );
LibCollectSizer->Add( LibCollectBtnSizer, 0, wxEXPAND, 5 );
LibCollectMainSizer->Add( LibCollectSizer, 1, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 );
LibCollectPanel->SetSizer( LibCollectMainSizer );
LibCollectPanel->Layout();
LibCollectMainSizer->FitInside( LibCollectPanel );
LibCollectPanel->SetScrollRate( PREFERENCES_SCROLL_STEP, PREFERENCES_SCROLL_STEP );
m_LibOptPanel = new wxScrolledWindow( m_LibSplitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer * LibOptMainSizer = new wxBoxSizer( wxVERTICAL );
m_LibOptSizer = new wxStaticBoxSizer( new wxStaticBox( m_LibOptPanel, wxID_ANY, wxEmptyString ), wxVERTICAL );
m_LibOptPathSizer = new wxStaticBoxSizer( new wxStaticBox( m_LibOptPanel, wxID_ANY, _(" Paths ") ), wxHORIZONTAL );
m_LibPathListBox = new wxListBox( m_LibOptPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_MULTIPLE );
m_LibPathListBox->Enable( false );
m_LibOptPathSizer->Add( m_LibPathListBox, 1, wxEXPAND|wxALL, 5 );
wxBoxSizer * LibOptPathBtnSizer = new wxBoxSizer( wxVERTICAL );
m_LibOptAddPathBtn = new wxBitmapButton( m_LibOptPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_add ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LibOptAddPathBtn->Enable( false );
LibOptPathBtnSizer->Add( m_LibOptAddPathBtn, 0, wxTOP, 5 );
m_LibOptDelPathBtn = new wxBitmapButton( m_LibOptPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_del ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LibOptDelPathBtn->Enable( false );
LibOptPathBtnSizer->Add( m_LibOptDelPathBtn, 0, wxBOTTOM, 5 );
m_LibOptPathSizer->Add( LibOptPathBtnSizer, 0, wxEXPAND, 5 );
m_LibOptSizer->Add( m_LibOptPathSizer, 1, wxEXPAND|wxTOP|wxBOTTOM, 5 );
wxStaticBoxSizer* LibOptCoversSizer = new wxStaticBoxSizer( new wxStaticBox( m_LibOptPanel, wxID_ANY, _(" Words to detect covers ") ), wxHORIZONTAL );
m_LibCoverListBox = new wxListBox( m_LibOptPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE );
m_LibCoverListBox->Enable( false );
LibOptCoversSizer->Add( m_LibCoverListBox, 1, wxEXPAND|wxALL, 5 );
wxBoxSizer * LibOptCoverBtnSizer = new wxBoxSizer( wxVERTICAL );
m_LibOptAddCoverBtn = new wxBitmapButton( m_LibOptPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_add ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LibOptAddCoverBtn->Enable( false );
LibOptCoverBtnSizer->Add( m_LibOptAddCoverBtn, 0, wxTOP, 5 );
m_LibOptUpCoverBtn = new wxBitmapButton( m_LibOptPanel, wxID_ANY, guImage( guIMAGE_INDEX_up ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LibOptUpCoverBtn->Enable( false );
LibOptCoverBtnSizer->Add( m_LibOptUpCoverBtn, 0, wxALIGN_CENTER_HORIZONTAL, 5 );
m_LibOptDownCoverBtn = new wxBitmapButton( m_LibOptPanel, wxID_ANY, guImage( guIMAGE_INDEX_down ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LibOptDownCoverBtn->Enable( false );
LibOptCoverBtnSizer->Add( m_LibOptDownCoverBtn, 0, wxALIGN_CENTER_HORIZONTAL, 5 );
m_LibOptDelCoverBtn = new wxBitmapButton( m_LibOptPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_del ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LibOptDelCoverBtn->Enable( false );
LibOptCoverBtnSizer->Add( m_LibOptDelCoverBtn, 0, wxBOTTOM, 5 );
LibOptCoversSizer->Add( LibOptCoverBtnSizer, 0, wxEXPAND, 5 );
m_LibOptSizer->Add( LibOptCoversSizer, 1, wxEXPAND, 5 );
m_LibOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( m_LibOptPanel, wxID_ANY, _( " Options " ) ), wxVERTICAL );
m_LibOptAutoUpdateChkBox = new wxCheckBox( m_LibOptPanel, wxID_ANY, _( "Update when opened " ), wxDefaultPosition, wxDefaultSize, 0 );
m_LibOptAutoUpdateChkBox->Enable( false );
m_LibOptionsSizer->Add( m_LibOptAutoUpdateChkBox, 0, wxRIGHT|wxLEFT, 5 );
m_LibOptCreatePlayListChkBox = new wxCheckBox( m_LibOptPanel, wxID_ANY, _( "Create playlists on scan" ), wxDefaultPosition, wxDefaultSize, 0 );
m_LibOptCreatePlayListChkBox->Enable( false );
m_LibOptCreatePlayListChkBox->SetValue(true);
m_LibOptionsSizer->Add( m_LibOptCreatePlayListChkBox, 0, wxRIGHT|wxLEFT, 5 );
m_LibOptFollowLinksChkBox = new wxCheckBox( m_LibOptPanel, wxID_ANY, _( "Follow symbolic links on scan" ), wxDefaultPosition, wxDefaultSize, 0 );
m_LibOptFollowLinksChkBox->Enable( false );
m_LibOptionsSizer->Add( m_LibOptFollowLinksChkBox, 0, wxRIGHT|wxLEFT, 5 );
m_LibOptCheckEmbeddedChkBox = new wxCheckBox( m_LibOptPanel, wxID_ANY, _( "Scan embedded covers in audio files" ), wxDefaultPosition, wxDefaultSize, 0 );
m_LibOptCheckEmbeddedChkBox->SetValue(true);
m_LibOptCheckEmbeddedChkBox->Enable( false );
m_LibOptionsSizer->Add( m_LibOptCheckEmbeddedChkBox, 0, wxRIGHT|wxLEFT, 5 );
m_LibOptEmbedTagsChkBox = new wxCheckBox( m_LibOptPanel, wxID_ANY, _( "Embed rating, play count and labels" ), wxDefaultPosition, wxDefaultSize, 0 );
m_LibOptEmbedTagsChkBox->Enable( false );
m_LibOptionsSizer->Add( m_LibOptEmbedTagsChkBox, 0, wxRIGHT|wxLEFT, 5 );
wxBoxSizer * LibOptCopyToSizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticText * LibOptCopyToLabel = new wxStaticText( m_LibOptPanel, wxID_ANY, _( "Default copy action" ), wxDefaultPosition, wxDefaultSize, 0 );
LibOptCopyToLabel->Wrap( -1 );
LibOptCopyToSizer->Add( LibOptCopyToLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
wxArrayString CopyToChoices;
CopyToChoices.Add( _( "None" ) );
wxArrayString CopyToOptions = m_Config->ReadAStr( CONFIG_KEY_COPYTO_OPTION, wxEmptyString, CONFIG_PATH_COPYTO );
Count = CopyToOptions.Count();
for( int Index = 0; Index < Count; Index++ )
{
CopyToChoices.Add( CopyToOptions[ Index ].BeforeFirst( wxT( ':' ) ) );
}
m_LibOptCopyToChoice = new wxChoice( m_LibOptPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, CopyToChoices, 0 );
m_LibOptCopyToChoice->SetSelection( 0 );
m_LibOptCopyToChoice->Enable( false );
LibOptCopyToSizer->Add( m_LibOptCopyToChoice, 1, wxEXPAND, 5 );
m_LibOptionsSizer->Add( LibOptCopyToSizer, 0, wxEXPAND, 5 );
m_LibOptSizer->Add( m_LibOptionsSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
LibOptMainSizer->Add( m_LibOptSizer, 1, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_LibOptPanel->SetSizer( LibOptMainSizer );
m_LibOptPanel->Layout();
LibOptMainSizer->FitInside( m_LibOptPanel );
m_LibOptPanel->SetScrollRate( PREFERENCES_SCROLL_STEP, PREFERENCES_SCROLL_STEP );
m_LibSplitter->SplitVertically( LibCollectPanel, m_LibOptPanel, 170 );
LibMainFrame->Add( m_LibSplitter, 1, wxEXPAND, 5 );
m_LibPanel->SetSizer( LibMainFrame );
m_LibPanel->Layout();
LibMainFrame->FitInside( m_LibPanel );
//
m_LibSplitter->Bind( wxEVT_IDLE, &guPrefDialog::LibSplitterOnIdle, this );
m_LibCollectListBox->Bind( wxEVT_LISTBOX, &guPrefDialog::OnLibCollectSelected, this );
m_LibCollectListBox->Bind( wxEVT_LISTBOX_DCLICK, &guPrefDialog::OnLibCollectDClicked, this );
m_LibCollectAddBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnLibAddCollectClick, this );
m_LibCollectUpBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnLibUpCollectClick, this );
m_LibCollectDownBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnLibDownCollectClick, this );
m_LibCollectDelBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnLibDelCollectClick, this );
m_LibPathListBox->Bind( wxEVT_LISTBOX, &guPrefDialog::OnLibPathSelected, this );
m_LibPathListBox->Bind( wxEVT_LISTBOX_DCLICK, &guPrefDialog::OnLibPathDClicked, this );
m_LibOptAddPathBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnLibAddPathBtnClick, this );
m_LibOptDelPathBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnLibDelPathBtnClick, this );
m_LibCoverListBox->Bind( wxEVT_LISTBOX, &guPrefDialog::OnLibCoverSelected, this );
m_LibCoverListBox->Bind( wxEVT_LISTBOX_DCLICK, &guPrefDialog::OnLibCoverDClicked, this );
m_LibOptAddCoverBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnLibAddCoverBtnClick, this );
m_LibOptUpCoverBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnLibUpCoverBtnClick, this );
m_LibOptDownCoverBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnLibDownCoverBtnClick, this );
m_LibOptDelCoverBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnLibDelCoverBtnClick, this );
m_LibOptAutoUpdateChkBox->Bind( wxEVT_CHECKBOX, &guPrefDialog::OnLibAutoUpdateChanged, this );
m_LibOptCreatePlayListChkBox->Bind( wxEVT_CHECKBOX, &guPrefDialog::OnLibCreatePlayListsChanged, this );
m_LibOptFollowLinksChkBox->Bind( wxEVT_CHECKBOX, &guPrefDialog::OnLibFollowSymLinksChanged, this );
m_LibOptCheckEmbeddedChkBox->Bind( wxEVT_CHECKBOX, &guPrefDialog::OnLibCheckEmbeddedChanged, this );
m_LibOptEmbedTagsChkBox->Bind( wxEVT_CHECKBOX, &guPrefDialog::OnLibEmbeddMetadataChanged, this );
m_LibOptCopyToChoice->Bind( wxEVT_CHOICE, &guPrefDialog::OnLibDefaultCopyToChanged, this );
m_LibCollectListBox->SetFocus();
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::BuildPlaybackPage( void )
{
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_PLAYBACK )
return;
m_VisiblePanels |= guPREFERENCE_PAGE_FLAG_PLAYBACK;
//
// Playback Panel
//
wxBoxSizer * PlayMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer * PlayGenSizer = new wxStaticBoxSizer( new wxStaticBox( m_PlayPanel, wxID_ANY, wxEmptyString ), wxVERTICAL );
wxBoxSizer * RandomPlaySizer = new wxBoxSizer( wxHORIZONTAL );
m_RndPlayChkBox = new wxCheckBox( m_PlayPanel, wxID_ANY, _( "Play random" ), wxDefaultPosition, wxDefaultSize, 0 );
m_RndPlayChkBox->SetValue( m_Config->ReadBool( CONFIG_KEY_GENERAL_RANDOM_PLAY_ON_EMPTY_PLAYLIST, false, CONFIG_PATH_GENERAL ) );
RandomPlaySizer->Add( m_RndPlayChkBox, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxString m_RndModeChoiceChoices[] = { _( "track" ), _( "album" ) };
int m_RndModeChoiceNChoices = sizeof( m_RndModeChoiceChoices ) / sizeof( wxString );
m_RndModeChoice = new wxChoice( m_PlayPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_RndModeChoiceNChoices, m_RndModeChoiceChoices, 0 );
m_RndModeChoice->Enable( m_RndPlayChkBox->IsChecked() );
m_RndModeChoice->SetSelection( m_Config->ReadNum( CONFIG_KEY_GENERAL_RANDOM_MODE_ON_EMPTY_PLAYLIST, 0, CONFIG_PATH_GENERAL ) );
//m_RndModeChoice->SetMinSize( wxSize( 150,-1 ) );
RandomPlaySizer->Add( m_RndModeChoice, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
wxStaticText * RndTextStaticText = new wxStaticText( m_PlayPanel, wxID_ANY, _( "when playlist is empty" ), wxDefaultPosition, wxDefaultSize, 0 );
RndTextStaticText->Wrap( -1 );
RandomPlaySizer->Add( RndTextStaticText, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
PlayGenSizer->Add( RandomPlaySizer, 1, wxEXPAND, 5 );
m_DelPlayChkBox = new wxCheckBox( m_PlayPanel, wxID_ANY, _( "Delete played tracks from playlist" ), wxDefaultPosition, wxDefaultSize, 0 );
m_DelPlayChkBox->SetValue( m_Config->ReadBool( CONFIG_KEY_PLAYBACK_DEL_TRACKS_PLAYED, false, CONFIG_PATH_PLAYBACK ) );
PlayGenSizer->Add( m_DelPlayChkBox, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
m_NotifyChkBox = new wxCheckBox( m_PlayPanel, wxID_ANY, _( "Show notifications" ), wxDefaultPosition, wxDefaultSize, 0 );
m_NotifyChkBox->SetValue( m_Config->ReadBool( CONFIG_KEY_GENERAL_SHOW_NOTIFICATIONS, true, CONFIG_PATH_GENERAL ) );
PlayGenSizer->Add( m_NotifyChkBox, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
m_EqOnChkBox = new wxCheckBox( m_PlayPanel, wxID_ANY, _( "Enable equalizer" ), wxDefaultPosition, wxDefaultSize, 0 );
m_EqOnChkBox->SetValue( m_Config->ReadBool( CONFIG_KEY_GENERAL_EQ_ENABLED, true, CONFIG_PATH_GENERAL ) );
PlayGenSizer->Add( m_EqOnChkBox, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
m_VolOnChkBox = new wxCheckBox( m_PlayPanel, wxID_ANY, _( "Enable volume and fader" ), wxDefaultPosition, wxDefaultSize, 0 );
m_VolOnChkBox->SetValue( m_Config->ReadBool( CONFIG_KEY_GENERAL_VOLUME_ENABLED, true, CONFIG_PATH_GENERAL ) );
PlayGenSizer->Add( m_VolOnChkBox, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
wxBoxSizer * PlayReplaySizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticText * PlayReplayLabel = new wxStaticText( m_PlayPanel, wxID_ANY, _("ReplayGain mode:"), wxDefaultPosition, wxDefaultSize, 0 );
PlayReplayLabel->Wrap( -1 );
PlayReplaySizer->Add( PlayReplayLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxString m_PlayReplayModeChoiceChoices[] = { _( "Disabled" ), _("Track"), _("Album") };
int m_PlayReplayModeChoiceNChoices = sizeof( m_PlayReplayModeChoiceChoices ) / sizeof( wxString );
m_PlayReplayModeChoice = new wxChoice( m_PlayPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_PlayReplayModeChoiceNChoices, m_PlayReplayModeChoiceChoices, 0 );
int ReplayGainModeVal = m_Config->ReadNum( CONFIG_KEY_GENERAL_REPLAY_GAIN_MODE, 0, CONFIG_PATH_GENERAL );
m_PlayReplayModeChoice->SetSelection( ReplayGainModeVal );
PlayReplaySizer->Add( m_PlayReplayModeChoice, 0, wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
wxStaticText * PlayPreAmpLabel = new wxStaticText( m_PlayPanel, wxID_ANY, _( "PreAmp:" ), wxDefaultPosition, wxDefaultSize, 0 );
PlayPreAmpLabel->Wrap( -1 );
PlayReplaySizer->Add( PlayPreAmpLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
int ReplayGainPreAmpVal = m_Config->ReadNum( CONFIG_KEY_GENERAL_REPLAY_GAIN_PREAMP, 6, CONFIG_PATH_GENERAL );
m_PlayPreAmpLevelVal = new wxStaticText( m_PlayPanel, wxID_ANY, wxString::Format( wxT("%idb"), ReplayGainPreAmpVal ), wxDefaultPosition, wxDefaultSize, 0 );
m_PlayPreAmpLevelVal->Wrap( -1 );
m_PlayPreAmpLevelVal->Enable( ReplayGainModeVal );
PlayReplaySizer->Add( m_PlayPreAmpLevelVal, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_PlayPreAmpLevelSlider = new wxSlider( m_PlayPanel, wxID_ANY, ReplayGainPreAmpVal, -20, 20, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL );
m_PlayPreAmpLevelSlider->Enable( ReplayGainModeVal );
PlayReplaySizer->Add( m_PlayPreAmpLevelSlider, 1, wxRIGHT|wxEXPAND, 5 );
PlayGenSizer->Add( PlayReplaySizer, 1, wxEXPAND, 5 );
PlayMainSizer->Add( PlayGenSizer, 0, wxEXPAND|wxALL, 5 );
wxStaticBoxSizer * SmartPlayListSizer = new wxStaticBoxSizer( new wxStaticBox( m_PlayPanel, wxID_ANY, _( " Random / Smart play modes " ) ), wxVERTICAL );
wxFlexGridSizer * SmartPlayListFlexGridSizer = new wxFlexGridSizer( 2, 0, 0 );
SmartPlayListFlexGridSizer->SetFlexibleDirection( wxBOTH );
SmartPlayListFlexGridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_MinTracksSpinCtrl = new wxSpinCtrl( m_PlayPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 10, 4 );
m_MinTracksSpinCtrl->SetValue( m_Config->ReadNum( CONFIG_KEY_PLAYBACK_MIN_TRACKS_PLAY, 4, CONFIG_PATH_PLAYBACK ) );
SmartPlayListFlexGridSizer->Add( m_MinTracksSpinCtrl, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 );
wxStaticText * MinTracksStaticText = new wxStaticText( m_PlayPanel, wxID_ANY, _("Tracks left to start search"), wxDefaultPosition, wxDefaultSize, 0 );
MinTracksStaticText->Wrap( -1 );
SmartPlayListFlexGridSizer->Add( MinTracksStaticText, 0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_NumTracksSpinCtrl = new wxSpinCtrl( m_PlayPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 10, 3 );
m_NumTracksSpinCtrl->SetValue( m_Config->ReadNum( CONFIG_KEY_PLAYBACK_NUM_TRACKS_TO_ADD, 3, CONFIG_PATH_PLAYBACK ) );
SmartPlayListFlexGridSizer->Add( m_NumTracksSpinCtrl, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 );
wxStaticText * AddTracksStaticText = new wxStaticText( m_PlayPanel, wxID_ANY, _("Tracks added each time"), wxDefaultPosition, wxDefaultSize, 0 );
AddTracksStaticText->Wrap( -1 );
SmartPlayListFlexGridSizer->Add( AddTracksStaticText, 0, wxRIGHT|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 );
m_MaxTracksPlayed = new wxSpinCtrl( m_PlayPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 999, 20 );
m_MaxTracksPlayed->SetValue( m_Config->ReadNum( CONFIG_KEY_PLAYBACK_MAX_TRACKS_PLAYED, 20, CONFIG_PATH_PLAYBACK ) );
m_MaxTracksPlayed->Enable( !m_DelPlayChkBox->IsChecked() );
SmartPlayListFlexGridSizer->Add( m_MaxTracksPlayed, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 );
wxStaticText * MaxTracksStaticText = new wxStaticText( m_PlayPanel, wxID_ANY, _("Max played tracks kept in playlist"), wxDefaultPosition, wxDefaultSize, 0 );
MaxTracksStaticText->Wrap( -1 );
SmartPlayListFlexGridSizer->Add( MaxTracksStaticText, 0, wxRIGHT|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 );
SmartPlayListSizer->Add( SmartPlayListFlexGridSizer, 1, wxEXPAND, 5 );
wxBoxSizer * SmartPlayFilterSizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticText * SmartPlayFilterLabel = new wxStaticText( m_PlayPanel, wxID_ANY, _("Don't repeat last"), wxDefaultPosition, wxDefaultSize, 0 );
SmartPlayFilterLabel->Wrap( -1 );
SmartPlayFilterSizer->Add( SmartPlayFilterLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_SmartPlayArtistsSpinCtrl = new wxSpinCtrl( m_PlayPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 50, 20 );
m_SmartPlayArtistsSpinCtrl->SetValue( m_Config->ReadNum( CONFIG_KEY_PLAYBACK_SMART_FILTER_ARTISTS, 20, CONFIG_PATH_PLAYBACK ) );
SmartPlayFilterSizer->Add( m_SmartPlayArtistsSpinCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
wxStaticText * SmartPlayArtistLabel = new wxStaticText( m_PlayPanel, wxID_ANY, _("artists or"), wxDefaultPosition, wxDefaultSize, 0 );
SmartPlayArtistLabel->Wrap( -1 );
SmartPlayFilterSizer->Add( SmartPlayArtistLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
m_SmartPlayTracksSpinCtrl = new wxSpinCtrl( m_PlayPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 200, 100 );
m_SmartPlayTracksSpinCtrl->SetValue( m_Config->ReadNum( CONFIG_KEY_PLAYBACK_SMART_FILTER_TRACKS, 100, CONFIG_PATH_PLAYBACK ) );
SmartPlayFilterSizer->Add( m_SmartPlayTracksSpinCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
wxStaticText * SmartPlayTracksLabel = new wxStaticText( m_PlayPanel, wxID_ANY, _("tracks"), wxDefaultPosition, wxDefaultSize, 0 );
SmartPlayTracksLabel->Wrap( -1 );
SmartPlayFilterSizer->Add( SmartPlayTracksLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
SmartPlayListSizer->Add( SmartPlayFilterSizer, 0, wxEXPAND, 5 );
PlayMainSizer->Add( SmartPlayListSizer, 0, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer * PlaySilenceSizer = new wxStaticBoxSizer( new wxStaticBox( m_PlayPanel, wxID_ANY, _(" Silence detector ") ), wxVERTICAL );
wxBoxSizer * PlayLevelSizer = new wxBoxSizer( wxHORIZONTAL );
bool IsPlayLevelEnabled = m_Config->ReadBool( CONFIG_KEY_PLAYBCK_SILENCE_DETECTOR, false, CONFIG_PATH_PLAYBACK );
m_PlayLevelEnabled = new wxCheckBox( m_PlayPanel, wxID_ANY, _("Skip at"), wxDefaultPosition, wxDefaultSize, 0 );
m_PlayLevelEnabled->SetValue( IsPlayLevelEnabled );
PlayLevelSizer->Add( m_PlayLevelEnabled, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
int PlayLevelValue = m_Config->ReadNum( CONFIG_KEY_PLAYBCK_SILENCE_LEVEL, -500, CONFIG_PATH_PLAYBACK );
m_PlayLevelVal = new wxStaticText( m_PlayPanel, wxID_ANY, wxString::Format( wxT("%02idb"), PlayLevelValue ), wxDefaultPosition, wxDefaultSize, 0 );
m_PlayLevelVal->Wrap( -1 );
m_PlayLevelVal->Enable( IsPlayLevelEnabled );
PlayLevelSizer->Add( m_PlayLevelVal, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
m_PlayLevelSlider = new wxSlider( m_PlayPanel, wxID_ANY, PlayLevelValue, -65, 0, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL );
m_PlayLevelSlider->Enable( IsPlayLevelEnabled );
PlayLevelSizer->Add( m_PlayLevelSlider, 1, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
PlaySilenceSizer->Add( PlayLevelSizer, 0, wxEXPAND, 5 );
wxBoxSizer* PlayEndTimeSizer;
PlayEndTimeSizer = new wxBoxSizer( wxHORIZONTAL );
m_PlayEndTimeCheckBox = new wxCheckBox( m_PlayPanel, wxID_ANY, _("In the last"), wxDefaultPosition, wxDefaultSize, 0 );
m_PlayEndTimeCheckBox->SetValue( m_Config->ReadBool( CONFIG_KEY_PLAYBCK_SILENCE_AT_END, true, CONFIG_PATH_PLAYBACK ) );
m_PlayEndTimeCheckBox->Enable( IsPlayLevelEnabled );
PlayEndTimeSizer->Add( m_PlayEndTimeCheckBox, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_PlayEndTimeSpinCtrl = new wxSpinCtrl( m_PlayPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 5, 360,
m_Config->ReadNum( CONFIG_KEY_PLAYBCK_SILENCE_END_TIME, 45, CONFIG_PATH_PLAYBACK ) );
m_PlayEndTimeSpinCtrl->Enable( IsPlayLevelEnabled && m_PlayEndTimeCheckBox->IsChecked() );
PlayEndTimeSizer->Add( m_PlayEndTimeSpinCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
wxStaticText * PlayEndTimeStaticText = new wxStaticText( m_PlayPanel, wxID_ANY, _( "seconds" ), wxDefaultPosition, wxDefaultSize, 0 );
PlayEndTimeStaticText->Wrap( -1 );
PlayEndTimeSizer->Add( PlayEndTimeStaticText, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
PlaySilenceSizer->Add( PlayEndTimeSizer, 0, wxEXPAND, 5 );
PlayMainSizer->Add( PlaySilenceSizer, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxStaticBoxSizer* PlayOutDeviceSizer = new wxStaticBoxSizer( new wxStaticBox( m_PlayPanel, wxID_ANY, _(" Output device ") ), wxHORIZONTAL );
wxArrayString OutputDeviceOptions;
OutputDeviceOptions.Add( _( "Automatic" ) );
OutputDeviceOptions.Add( _( "GConf Defined" ) );
OutputDeviceOptions.Add( wxT( "Alsa" ) );
OutputDeviceOptions.Add( wxT( "PulseAudio" ) );
OutputDeviceOptions.Add( wxT( "OSS" ) );
OutputDeviceOptions.Add( wxT( "Other" ) );
m_PlayOutDevChoice = new wxChoice( m_PlayPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, OutputDeviceOptions, 0 );
int OutDevice = m_Config->ReadNum( CONFIG_KEY_PLAYBACK_OUTPUT_DEVICE, guOUTPUT_DEVICE_AUTOMATIC, CONFIG_PATH_PLAYBACK );
m_PlayOutDevChoice->SetSelection( OutDevice );
PlayOutDeviceSizer->Add( m_PlayOutDevChoice, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
m_PlayOutDevName = new wxTextCtrl( m_PlayPanel, wxID_ANY, m_Config->ReadStr( CONFIG_KEY_PLAYBACK_OUTPUT_DEVICE_NAME, wxEmptyString, CONFIG_PATH_PLAYBACK ), wxDefaultPosition, wxDefaultSize, 0 );
m_PlayOutDevName->Enable( OutDevice > guOUTPUT_DEVICE_GCONF );
PlayOutDeviceSizer->Add( m_PlayOutDevName, 1, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
PlayMainSizer->Add( PlayOutDeviceSizer, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_PlayPanel->SetSizer( PlayMainSizer );
m_PlayPanel->Layout();
PlayMainSizer->FitInside( m_PlayPanel );
//
//
//
m_RndPlayChkBox->Bind( wxEVT_CHECKBOX, &guPrefDialog::OnRndPlayClicked, this );
m_DelPlayChkBox->Bind( wxEVT_CHECKBOX, &guPrefDialog::OnDelPlayedTracksChecked, this );
m_PlayReplayModeChoice->Bind( wxEVT_CHOICE, &guPrefDialog::OnReplayGainModeChanged, this );
m_PlayPreAmpLevelSlider->Bind( wxEVT_SCROLL_CHANGED, &guPrefDialog::OnPlayPreAmpLevelValueChanged, this );
m_PlayPreAmpLevelSlider->Bind( wxEVT_SCROLL_THUMBTRACK, &guPrefDialog::OnPlayPreAmpLevelValueChanged, this );
m_PlayLevelEnabled->Bind( wxEVT_CHECKBOX, &guPrefDialog::OnPlayLevelEnabled, this );
m_PlayLevelSlider->Bind( wxEVT_SCROLL_CHANGED, &guPrefDialog::OnPlayLevelValueChanged, this );
m_PlayLevelSlider->Bind( wxEVT_SCROLL_THUMBTRACK, &guPrefDialog::OnPlayLevelValueChanged, this );
m_PlayEndTimeCheckBox->Bind( wxEVT_CHECKBOX, &guPrefDialog::OnPlayEndTimeEnabled, this );
m_PlayOutDevChoice->Bind( wxEVT_CHOICE, &guPrefDialog::OnPlayOutDevChanged, this );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::BuildCrossfaderPage( void )
{
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_CROSSFADER )
return;
m_VisiblePanels |= guPREFERENCE_PAGE_FLAG_CROSSFADER;
//
// Crossfader Panel
//
wxBoxSizer * XFadeMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer * XFadesbSizer = new wxStaticBoxSizer( new wxStaticBox( m_XFadePanel, wxID_ANY, _(" Crossfader ") ), wxVERTICAL );
wxFlexGridSizer * XFadeFlexSizer = new wxFlexGridSizer( 3, 0, 0 );
XFadeFlexSizer->AddGrowableCol( 2 );
XFadeFlexSizer->SetFlexibleDirection( wxBOTH );
XFadeFlexSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
wxStaticText * XFadeOutLenLabel = new wxStaticText( m_XFadePanel, wxID_ANY, _("Fade-out length:"), wxDefaultPosition, wxDefaultSize, 0 );
XFadeOutLenLabel->Wrap( -1 );
XFadeFlexSizer->Add( XFadeOutLenLabel, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_XFadeOutLenVal = new wxStaticText( m_XFadePanel, wxID_ANY, wxT( "00.0" ), wxDefaultPosition, wxDefaultSize, 0 );
m_XFadeOutLenVal->Wrap( -1 );
XFadeFlexSizer->Add( m_XFadeOutLenVal, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_XFadeOutLenSlider = new wxSlider( m_XFadePanel, wxID_ANY, m_Config->ReadNum( CONFIG_KEY_CROSSFADER_FADEOUT_TIME, 50, CONFIG_PATH_CROSSFADER ), 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL );
m_XFadeOutLenSlider->SetToolTip( _( "Select the length of the fade out. 0 for gapless playback" ) );
XFadeFlexSizer->Add( m_XFadeOutLenSlider, 1, wxEXPAND|wxRIGHT, 5 );
wxStaticText * XFadeInLenLabel = new wxStaticText( m_XFadePanel, wxID_ANY, _("Fade-in length:"), wxDefaultPosition, wxDefaultSize, 0 );
XFadeInLenLabel->Wrap( -1 );
XFadeFlexSizer->Add( XFadeInLenLabel, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_XFadeInLenVal = new wxStaticText( m_XFadePanel, wxID_ANY, wxT( "00.0" ), wxDefaultPosition, wxDefaultSize, 0 );
m_XFadeInLenVal->Wrap( -1 );
XFadeFlexSizer->Add( m_XFadeInLenVal, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_XFadeInLenSlider = new wxSlider( m_XFadePanel, wxID_ANY, m_Config->ReadNum( CONFIG_KEY_CROSSFADER_FADEIN_TIME, 10, CONFIG_PATH_CROSSFADER ), 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL );
m_XFadeInLenSlider->SetToolTip( _( "Select the length of the fade in" ) );
XFadeFlexSizer->Add( m_XFadeInLenSlider, 0, wxEXPAND|wxRIGHT, 5 );
wxStaticText * XFadeInStartLabel = new wxStaticText( m_XFadePanel, wxID_ANY, _("Fade-in volume:"), wxDefaultPosition, wxDefaultSize, 0 );
XFadeInStartLabel->Wrap( -1 );
XFadeFlexSizer->Add( XFadeInStartLabel, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_XFadeInStartVal = new wxStaticText( m_XFadePanel, wxID_ANY, wxT( "00.0" ), wxDefaultPosition, wxDefaultSize, 0 );
m_XFadeInStartVal->Wrap( -1 );
XFadeFlexSizer->Add( m_XFadeInStartVal, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_XFadeInStartSlider = new wxSlider( m_XFadePanel, wxID_ANY, m_Config->ReadNum( CONFIG_KEY_CROSSFADER_FADEIN_VOL_START, 80, CONFIG_PATH_CROSSFADER ), 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL );
m_XFadeInStartSlider->SetToolTip( _( "Select the initial volume of the fade in" ) );
XFadeFlexSizer->Add( m_XFadeInStartSlider, 0, wxEXPAND|wxRIGHT, 5 );
wxStaticText * XFadeTrigerLabel = new wxStaticText( m_XFadePanel, wxID_ANY, _("Fade-in start:"), wxDefaultPosition, wxDefaultSize, 0 );
XFadeTrigerLabel->Wrap( -1 );
XFadeFlexSizer->Add( XFadeTrigerLabel, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_XFadeTrigerVal = new wxStaticText( m_XFadePanel, wxID_ANY, wxT( "00.0" ), wxDefaultPosition, wxDefaultSize, 0 );
m_XFadeTrigerVal->Wrap( -1 );
XFadeFlexSizer->Add( m_XFadeTrigerVal, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_XFadeInTrigerSlider = new wxSlider( m_XFadePanel, wxID_ANY, m_Config->ReadNum( CONFIG_KEY_CROSSFADER_FADEIN_VOL_TRIGER, 50, CONFIG_PATH_CROSSFADER ), 10, 90, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL );
m_XFadeInTrigerSlider->SetToolTip( _( "Select at which volume of the fade out the fade in starts" ) );
XFadeFlexSizer->Add( m_XFadeInTrigerSlider, 0, wxEXPAND|wxRIGHT, 5 );
XFadesbSizer->Add( XFadeFlexSizer, 1, wxEXPAND, 5 );
XFadeMainSizer->Add( XFadesbSizer, 0, wxEXPAND|wxALL, 5 );
m_FadeBitmap = new wxStaticBitmap( m_XFadePanel, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 400,200 ), 0 );
XFadeMainSizer->Add( m_FadeBitmap, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_XFadePanel->SetSizer( XFadeMainSizer );
m_XFadePanel->Layout();
XFadeMainSizer->FitInside( m_XFadePanel );
//
//
//
m_XFadeOutLenSlider->Bind( wxEVT_SCROLL_CHANGED, &guPrefDialog::OnCrossFadeChanged, this );
m_XFadeOutLenSlider->Bind( wxEVT_SCROLL_THUMBTRACK, &guPrefDialog::OnCrossFadeChanged, this );
m_XFadeInLenSlider->Bind( wxEVT_SCROLL_CHANGED, &guPrefDialog::OnCrossFadeChanged, this );
m_XFadeInLenSlider->Bind( wxEVT_SCROLL_THUMBTRACK, &guPrefDialog::OnCrossFadeChanged, this );
m_XFadeInStartSlider->Bind( wxEVT_SCROLL_CHANGED, &guPrefDialog::OnCrossFadeChanged, this );
m_XFadeInStartSlider->Bind( wxEVT_SCROLL_THUMBTRACK, &guPrefDialog::OnCrossFadeChanged, this );
m_XFadeInTrigerSlider->Bind( wxEVT_SCROLL_CHANGED, &guPrefDialog::OnCrossFadeChanged, this );
m_XFadeInTrigerSlider->Bind( wxEVT_SCROLL_THUMBTRACK, &guPrefDialog::OnCrossFadeChanged, this );
//
wxScrollEvent ScrollEvent;
OnCrossFadeChanged( ScrollEvent );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::BuildRecordPage( void )
{
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_RECORD )
return;
m_VisiblePanels |= guPREFERENCE_PAGE_FLAG_RECORD;
//
// Record Panel
//
wxBoxSizer * RecMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer * RecordSizer = new wxStaticBoxSizer( new wxStaticBox( m_RecordPanel, wxID_ANY, _(" Record ") ), wxVERTICAL );
m_RecordChkBox = new wxCheckBox( m_RecordPanel, wxID_ANY, _("Enable recording"), wxDefaultPosition, wxDefaultSize, 0 );
m_RecordChkBox->SetValue( m_Config->ReadBool( CONFIG_KEY_RECORD_ENABLED, false, CONFIG_PATH_RECORD ) );
RecordSizer->Add( m_RecordChkBox, 0, wxALL|wxEXPAND, 5 );
wxBoxSizer * RecSelDirSizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticText * RecSelDirLabel = new wxStaticText( m_RecordPanel, wxID_ANY, _("Save to:"), wxDefaultPosition, wxDefaultSize, 0 );
RecSelDirLabel->Wrap( -1 );
RecSelDirSizer->Add( RecSelDirLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_RecSelDirPicker = new wxDirPickerCtrl( m_RecordPanel, wxID_ANY, wxEmptyString, _("Select a folder"), wxDefaultPosition, wxDefaultSize, wxDIRP_DEFAULT_STYLE|wxDIRP_DIR_MUST_EXIST );
m_RecSelDirPicker->SetPath( m_Config->ReadStr( CONFIG_KEY_RECORD_PATH, guPATH_DEFAULT_RECORDINGS, CONFIG_PATH_RECORD ) );
m_RecSelDirPicker->Enable( m_RecordChkBox->IsChecked() );
RecSelDirSizer->Add( m_RecSelDirPicker, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
RecordSizer->Add( RecSelDirSizer, 0, wxEXPAND, 5 );
wxStaticBoxSizer * RecPropSizer = new wxStaticBoxSizer( new wxStaticBox( m_RecordPanel, wxID_ANY, _(" Properties ") ), wxVERTICAL );
wxFlexGridSizer * RecPropFlexSizer = new wxFlexGridSizer( 2, 0, 0 );
RecPropFlexSizer->AddGrowableCol( 1 );
RecPropFlexSizer->SetFlexibleDirection( wxBOTH );
RecPropFlexSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
wxStaticText * RecFormatLabel = new wxStaticText( m_RecordPanel, wxID_ANY, _("Format:"), wxDefaultPosition, wxDefaultSize, 0 );
RecFormatLabel->Wrap( -1 );
RecPropFlexSizer->Add( RecFormatLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
wxString m_RecFormatChoiceChoices[] = { wxT("mp3"), wxT("ogg"), wxT("flac") };
int m_RecFormatChoiceNChoices = sizeof( m_RecFormatChoiceChoices ) / sizeof( wxString );
m_RecFormatChoice = new wxChoice( m_RecordPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_RecFormatChoiceNChoices, m_RecFormatChoiceChoices, 0 );
m_RecFormatChoice->SetSelection( m_Config->ReadNum( CONFIG_KEY_RECORD_FORMAT, 0, CONFIG_PATH_RECORD ) );
m_RecFormatChoice->Enable( m_RecordChkBox->IsChecked() );
m_RecFormatChoice->SetMinSize( wxSize( 150,-1 ) );
RecPropFlexSizer->Add( m_RecFormatChoice, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
wxStaticText * RecQualityLabel = new wxStaticText( m_RecordPanel, wxID_ANY, _("Quality:"), wxDefaultPosition, wxDefaultSize, 0 );
RecQualityLabel->Wrap( -1 );
RecPropFlexSizer->Add( RecQualityLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
wxArrayString RecQualityChoiceChoices;
RecQualityChoiceChoices.Add( _( "Very High" ) );
RecQualityChoiceChoices.Add( _( "High" ) );
RecQualityChoiceChoices.Add( _( "Normal" ) );
RecQualityChoiceChoices.Add( _( "Low" ) );
RecQualityChoiceChoices.Add( _( "Very Low" ) );
m_RecQualityChoice = new wxChoice( m_RecordPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, RecQualityChoiceChoices, 0 );
m_RecQualityChoice->SetSelection( m_Config->ReadNum( CONFIG_KEY_RECORD_QUALITY, 2, CONFIG_PATH_RECORD ) );
m_RecQualityChoice->Enable( m_RecordChkBox->IsChecked() );
m_RecQualityChoice->SetMinSize( wxSize( 150,-1 ) );
RecPropFlexSizer->Add( m_RecQualityChoice, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 );
RecPropSizer->Add( RecPropFlexSizer, 1, wxEXPAND, 5 );
RecordSizer->Add( RecPropSizer, 1, wxEXPAND|wxALL, 5 );
m_RecSplitChkBox = new wxCheckBox( m_RecordPanel, wxID_ANY, _( "Split tracks" ), wxDefaultPosition, wxDefaultSize, 0 );
m_RecSplitChkBox->SetValue( m_Config->ReadBool( CONFIG_KEY_RECORD_SPLIT, false, CONFIG_PATH_RECORD ) );
m_RecSplitChkBox->Enable( m_RecordChkBox->IsChecked() );
RecordSizer->Add( m_RecSplitChkBox, 0, wxALL, 5 );
wxBoxSizer * RecDelSizer = new wxBoxSizer( wxHORIZONTAL );
m_RecDelTracks = new wxCheckBox( m_RecordPanel, wxID_ANY, _("Delete tracks shorter than"), wxDefaultPosition, wxDefaultSize, 0 );
m_RecDelTracks->SetValue( m_Config->ReadBool( CONFIG_KEY_RECORD_DELETE, false, CONFIG_PATH_RECORD ) );
RecDelSizer->Add( m_RecDelTracks, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_RecDelTime = new wxSpinCtrl( m_RecordPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 999,
m_Config->ReadNum( CONFIG_KEY_RECORD_DELETE_TIME, 50, CONFIG_PATH_RECORD ) );
m_RecDelTime->Enable( m_RecDelTracks->IsChecked() );
RecDelSizer->Add( m_RecDelTime, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
wxStaticText * RecDelSecLabel = new wxStaticText( m_RecordPanel, wxID_ANY, _("seconds"), wxDefaultPosition, wxDefaultSize, 0 );
RecDelSecLabel->Wrap( -1 );
RecDelSizer->Add( RecDelSecLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
RecordSizer->Add( RecDelSizer, 0, wxEXPAND, 5 );
RecMainSizer->Add( RecordSizer, 0, wxEXPAND|wxALL, 5 );
m_RecordPanel->SetSizer( RecMainSizer );
m_RecordPanel->Layout();
RecMainSizer->FitInside( m_RecordPanel );
//
//
//
m_RecordChkBox->Bind( wxEVT_CHECKBOX, &guPrefDialog::OnRecEnableClicked, this );
m_RecDelTracks->Bind( wxEVT_CHECKBOX, &guPrefDialog::OnRecDelTracksClicked, this );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::BuildAudioScrobblePage( void )
{
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_AUDIOSCROBBLE )
return;
m_VisiblePanels |= guPREFERENCE_PAGE_FLAG_AUDIOSCROBBLE;
//
// LastFM Panel
//
wxBoxSizer * ASMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer * LastFMASSizer = new wxStaticBoxSizer( new wxStaticBox( m_LastFMPanel, wxID_ANY, _(" Last.fm audioscrobble ") ), wxVERTICAL );
m_LastFMASEnableChkBox = new wxCheckBox( m_LastFMPanel, wxID_ANY, _("Enabled"), wxDefaultPosition, wxDefaultSize, 0 );
m_LastFMASEnableChkBox->SetValue( m_Config->ReadBool( CONFIG_KEY_LASTFM_ENABLED, false, CONFIG_PATH_LASTFM ) );
LastFMASSizer->Add( m_LastFMASEnableChkBox, 0, wxALL, 5 );
wxFlexGridSizer * ASLoginSizer = new wxFlexGridSizer( 2, 0, 0 );
ASLoginSizer->SetFlexibleDirection( wxBOTH );
ASLoginSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
wxStaticText * UserNameStaticText = new wxStaticText( m_LastFMPanel, wxID_ANY, _("Username:"), wxDefaultPosition, wxDefaultSize, 0 );
UserNameStaticText->Wrap( -1 );
ASLoginSizer->Add( UserNameStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_LastFMUserNameTextCtrl = new wxTextCtrl( m_LastFMPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 200,-1 ), 0 );
m_LastFMUserNameTextCtrl->SetValue( m_Config->ReadStr( CONFIG_KEY_LASTFM_USERNAME, wxEmptyString, CONFIG_PATH_LASTFM ) );
ASLoginSizer->Add( m_LastFMUserNameTextCtrl, 0, wxALL, 5 );
wxStaticText * PasswdStaticText = new wxStaticText( m_LastFMPanel, wxID_ANY, _("Password:"), wxDefaultPosition, wxDefaultSize, 0 );
PasswdStaticText->Wrap( -1 );
ASLoginSizer->Add( PasswdStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_LastFMPasswdTextCtrl = new wxTextCtrl( m_LastFMPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 200,-1 ), wxTE_PASSWORD );
m_LastFMPasswdTextCtrl->SetValue( m_Config->ReadStr( CONFIG_KEY_LASTFM_PASSWORD, wxEmptyString, CONFIG_PATH_LASTFM ).IsEmpty() ? wxEmptyString : wxT( "******" ) );
// Password is saved in md5 form so we cant load it back
ASLoginSizer->Add( m_LastFMPasswdTextCtrl, 0, wxALL, 5 );
if( m_LastFMPasswdTextCtrl->IsEmpty() || m_LastFMUserNameTextCtrl->IsEmpty() )
{
m_LastFMASEnableChkBox->Disable();
}
LastFMASSizer->Add( ASLoginSizer, 1, wxEXPAND, 5 );
ASMainSizer->Add( LastFMASSizer, 0, wxEXPAND|wxALL, 5 );
wxStaticBoxSizer * LibreFMASSizer = new wxStaticBoxSizer( new wxStaticBox( m_LastFMPanel, wxID_ANY, _(" Libre.fm audioscrobble ") ), wxVERTICAL );
m_LibreFMASEnableChkBox = new wxCheckBox( m_LastFMPanel, wxID_ANY, _( "Enabled" ), wxDefaultPosition, wxDefaultSize, 0 );
m_LibreFMASEnableChkBox->SetValue( m_Config->ReadBool( wxT( "SubmitEnabled" ), false, CONFIG_PATH_LIBREFM ) );
LibreFMASSizer->Add( m_LibreFMASEnableChkBox, 0, wxALL, 5 );
wxFlexGridSizer * LibreFMASLoginSizer = new wxFlexGridSizer( 2, 0, 0 );
LibreFMASLoginSizer->SetFlexibleDirection( wxBOTH );
LibreFMASLoginSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
wxStaticText * LibreFMUserNameStaticText = new wxStaticText( m_LastFMPanel, wxID_ANY, _( "Username:" ), wxDefaultPosition, wxDefaultSize, 0 );
LibreFMUserNameStaticText->Wrap( -1 );
LibreFMASLoginSizer->Add( LibreFMUserNameStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_LibreFMUserNameTextCtrl = new wxTextCtrl( m_LastFMPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 200,-1 ), 0 );
m_LibreFMUserNameTextCtrl->SetValue( m_Config->ReadStr( wxT( "UserName" ), wxEmptyString, CONFIG_PATH_LIBREFM ) );
LibreFMASLoginSizer->Add( m_LibreFMUserNameTextCtrl, 0, wxALL, 5 );
wxStaticText * LibreFMPasswdStaticText = new wxStaticText( m_LastFMPanel, wxID_ANY, _("Password:"), wxDefaultPosition, wxDefaultSize, 0 );
LibreFMPasswdStaticText->Wrap( -1 );
LibreFMASLoginSizer->Add( LibreFMPasswdStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_LibreFMPasswdTextCtrl = new wxTextCtrl( m_LastFMPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 200,-1 ), wxTE_PASSWORD );
m_LibreFMPasswdTextCtrl->SetValue( m_Config->ReadStr( wxT( "Password" ), wxEmptyString, CONFIG_PATH_LIBREFM ).IsEmpty() ? wxEmptyString : wxT( "******" ) );
// Password is saved in md5 form so we cant load it back
LibreFMASLoginSizer->Add( m_LibreFMPasswdTextCtrl, 0, wxALL, 5 );
if( m_LibreFMPasswdTextCtrl->IsEmpty() || m_LibreFMUserNameTextCtrl->IsEmpty() )
{
m_LibreFMASEnableChkBox->Disable();
}
LibreFMASSizer->Add( LibreFMASLoginSizer, 0, wxEXPAND, 5 );
ASMainSizer->Add( LibreFMASSizer, 0, wxEXPAND|wxALL, 5 );
m_LastFMPanel->SetSizer( ASMainSizer );
m_LastFMPanel->Layout();
ASMainSizer->FitInside( m_LastFMPanel );
//
//
//
m_LastFMUserNameTextCtrl->Bind( wxEVT_TEXT, &guPrefDialog::OnLastFMASUserNameChanged, this );
m_LastFMPasswdTextCtrl->Bind( wxEVT_TEXT, &guPrefDialog::OnLastFMASUserNameChanged, this );
m_LibreFMUserNameTextCtrl->Bind( wxEVT_TEXT, &guPrefDialog::OnLibreFMASUserNameChanged, this );
m_LibreFMPasswdTextCtrl->Bind( wxEVT_TEXT, &guPrefDialog::OnLibreFMASUserNameChanged, this );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::BuildLyricsPage( void )
{
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_LYRICS )
return;
m_VisiblePanels |= guPREFERENCE_PAGE_FLAG_LYRICS;
//
// Lyrics
//
wxBoxSizer * LyricsMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer * LyricsSrcSizer = new wxStaticBoxSizer( new wxStaticBox( m_LyricsPanel, wxID_ANY, _(" Sources " ) ), wxHORIZONTAL );
m_LyricSearchEngine = new guLyricSearchEngine();
wxArrayString LyricSourcesNames;
wxArrayInt LyricSourcesEnabled;
int Count = m_LyricSearchEngine->SourcesCount();
for( int Index = 0; Index < Count; Index++ )
{
guLyricSource * LyricSource = m_LyricSearchEngine->GetSource( Index );
LyricSourcesNames.Add( LyricSource->Name() );
LyricSourcesEnabled.Add( LyricSource->Enabled() );
}
m_LyricsSrcListBox = new wxCheckListBox( m_LyricsPanel, wxID_ANY, wxDefaultPosition, wxSize( -1, guPREFERENCES_LISTBOX_HEIGHT ), LyricSourcesNames, 0 );
LyricsSrcSizer->Add( m_LyricsSrcListBox, 1, wxALL|wxEXPAND, 5 );
for( int Index = 0; Index < Count; Index++ )
{
m_LyricsSrcListBox->Check( Index, LyricSourcesEnabled[ Index ] );
}
wxBoxSizer * LyricsSrcBtnSizer = new wxBoxSizer( wxVERTICAL );
m_LyricsAddButton = new wxBitmapButton( m_LyricsPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_add ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
//m_LyricsAddButton->Enable( false );
LyricsSrcBtnSizer->Add( m_LyricsAddButton, 0, wxTOP, 5 );
m_LyricsUpButton = new wxBitmapButton( m_LyricsPanel, wxID_ANY, guImage( guIMAGE_INDEX_up ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LyricsUpButton->Enable( false );
LyricsSrcBtnSizer->Add( m_LyricsUpButton, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP, 5 );
m_LyricsDownButton = new wxBitmapButton( m_LyricsPanel, wxID_ANY, guImage( guIMAGE_INDEX_down ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LyricsDownButton->Enable( false );
LyricsSrcBtnSizer->Add( m_LyricsDownButton, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP, 5 );
m_LyricsDelButton = new wxBitmapButton( m_LyricsPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_del ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LyricsDelButton->Enable( false );
LyricsSrcBtnSizer->Add( m_LyricsDelButton, 0, wxTOP|wxBOTTOM, 5 );
LyricsSrcSizer->Add( LyricsSrcBtnSizer, 0, wxEXPAND|wxALL, 5 );
LyricsMainSizer->Add( LyricsSrcSizer, 1, wxEXPAND|wxALL, 5 );
// Targets
//
wxStaticBoxSizer * LyricsSaveSizer = new wxStaticBoxSizer( new wxStaticBox( m_LyricsPanel, wxID_ANY, _( " Targets " ) ), wxHORIZONTAL );
wxArrayString LyricTargetsNames;
wxArrayInt LyricTargetsEnabled;
Count = m_LyricSearchEngine->TargetsCount();
for( int Index = 0; Index < Count; Index++ )
{
guLyricSource * LyricTarget = m_LyricSearchEngine->GetTarget( Index );
LyricTargetsNames.Add( LyricTarget->Name() );
LyricTargetsEnabled.Add( LyricTarget->Enabled() );
}
m_LyricsSaveListBox = new wxCheckListBox( m_LyricsPanel, wxID_ANY, wxDefaultPosition, wxSize( -1, guPREFERENCES_LISTBOX_HEIGHT ), LyricTargetsNames, 0 );
for( int Index = 0; Index < Count; Index++ )
{
m_LyricsSaveListBox->Check( Index, LyricTargetsEnabled[ Index ] );
}
LyricsSaveSizer->Add( m_LyricsSaveListBox, 1, wxALL|wxEXPAND, 5 );
wxBoxSizer * LyricsSaveBtnSizer = new wxBoxSizer( wxVERTICAL );
m_LyricsSaveAddButton = new wxBitmapButton( m_LyricsPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_add ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
//m_LyricsSaveAddButton->Enable( false );
LyricsSaveBtnSizer->Add( m_LyricsSaveAddButton, 0, wxTOP|wxALIGN_CENTER_HORIZONTAL, 5 );
m_LyricsSaveUpButton = new wxBitmapButton( m_LyricsPanel, wxID_ANY, guImage( guIMAGE_INDEX_up ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LyricsSaveUpButton->Enable( false );
LyricsSaveBtnSizer->Add( m_LyricsSaveUpButton, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP, 5 );
m_LyricsSaveDownButton = new wxBitmapButton( m_LyricsPanel, wxID_ANY, guImage( guIMAGE_INDEX_down ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LyricsSaveDownButton->Enable( false );
LyricsSaveBtnSizer->Add( m_LyricsSaveDownButton, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP, 5 );
m_LyricsSaveDelButton = new wxBitmapButton( m_LyricsPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_del ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LyricsSaveDelButton->Enable( false );
LyricsSaveBtnSizer->Add( m_LyricsSaveDelButton, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_HORIZONTAL, 5 );
LyricsSaveSizer->Add( LyricsSaveBtnSizer, 0, wxEXPAND|wxALL, 5 );
LyricsMainSizer->Add( LyricsSaveSizer, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
// Disabled Genres
//
wxStaticBoxSizer * LyricsDisGenreSizer = new wxStaticBoxSizer( new wxStaticBox( m_LyricsPanel, wxID_ANY, _( " Disabled Genres " ) ), wxHORIZONTAL );
m_LirycsDisGenresListBox = new wxListBox( m_LyricsPanel, wxID_ANY, wxDefaultPosition, wxSize( -1, 100 ), 0, NULL, 0 );
m_LirycsDisGenresListBox->Append( m_Config->ReadAStr( CONFIG_KEY_LYRICS_DISGENRE, wxEmptyString, CONFIG_PATH_LYRICS_DISGENRES ) );
LyricsDisGenreSizer->Add( m_LirycsDisGenresListBox, 1, wxALL|wxEXPAND, 5 );
wxBoxSizer * LyricsDisGenreBtnSizer = new wxBoxSizer( wxVERTICAL );
m_LyricsDisGenreAddButton = new wxBitmapButton( m_LyricsPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_add ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
//m_LyricsDisGenreAddButton->Enable( false );
LyricsDisGenreBtnSizer->Add( m_LyricsDisGenreAddButton, 0, wxTOP|wxALIGN_CENTER_HORIZONTAL, 5 );
m_LyricsDisGenreDelButton = new wxBitmapButton( m_LyricsPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_del ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LyricsDisGenreDelButton->Enable( false );
LyricsDisGenreBtnSizer->Add( m_LyricsDisGenreDelButton, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_HORIZONTAL, 5 );
LyricsDisGenreSizer->Add( LyricsDisGenreBtnSizer, 0, wxEXPAND|wxALL, 5 );
LyricsMainSizer->Add( LyricsDisGenreSizer, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
// Font
//
wxStaticBoxSizer * LyricsFontSizer = new wxStaticBoxSizer( new wxStaticBox( m_LyricsPanel, wxID_ANY, _(" Font ") ), wxHORIZONTAL );
wxStaticText * LyricsFontLabel = new wxStaticText( m_LyricsPanel, wxID_ANY, _( "Font:" ), wxDefaultPosition, wxDefaultSize, 0 );
LyricsFontLabel->Wrap( -1 );
LyricsFontSizer->Add( LyricsFontLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
wxFont LyricFont;
LyricFont.SetNativeFontInfo( m_Config->ReadStr( CONFIG_KEY_LYRICS_FONT, wxEmptyString, CONFIG_PATH_LYRICS ) );
if( !LyricFont.IsOk() )
LyricFont = GetFont();
m_LyricFontPicker = new wxFontPickerCtrl( m_LyricsPanel, wxID_ANY, LyricFont, wxDefaultPosition, wxDefaultSize, wxFNTP_DEFAULT_STYLE );
m_LyricFontPicker->SetMaxPointSize( 100 );
LyricsFontSizer->Add( m_LyricFontPicker, 2, wxEXPAND|wxRIGHT, 5 );
wxStaticText * LyricsAlignLabel = new wxStaticText( m_LyricsPanel, wxID_ANY, _( "Align:" ), wxDefaultPosition, wxDefaultSize, 0 );
LyricsAlignLabel->Wrap( -1 );
LyricsFontSizer->Add( LyricsAlignLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
wxArrayString LyricsAlignChoices;
LyricsAlignChoices.Add( _( "Left" ) );
LyricsAlignChoices.Add( _( "Center" ) );
LyricsAlignChoices.Add( _( "Right" ) );
m_LyricsAlignChoice = new wxChoice( m_LyricsPanel, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), LyricsAlignChoices, 0 );
m_LyricsAlignChoice->SetSelection( m_Config->ReadNum( CONFIG_KEY_LYRICS_TEXT_ALIGN, 1, CONFIG_PATH_LYRICS ) );
LyricsFontSizer->Add( m_LyricsAlignChoice, 1, wxALL, 5 );
LyricsMainSizer->Add( LyricsFontSizer, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_LyricsPanel->SetSizer( LyricsMainSizer );
m_LyricsPanel->Layout();
LyricsMainSizer->FitInside( m_LyricsPanel );
m_LyricsSrcListBox->Bind( wxEVT_LISTBOX, &guPrefDialog::OnLyricSourceSelected, this );
m_LyricsSrcListBox->Bind( wxEVT_LISTBOX_DCLICK, &guPrefDialog::OnLyricSourceDClicked, this );
m_LyricsSrcListBox->Bind( wxEVT_CHECKLISTBOX, &guPrefDialog::OnLyricSourceToggled, this );
m_LyricsAddButton->Bind( wxEVT_BUTTON, &guPrefDialog::OnLyricAddBtnClick, this );
m_LyricsUpButton->Bind( wxEVT_BUTTON, &guPrefDialog::OnLyricUpBtnClick, this );
m_LyricsDownButton->Bind( wxEVT_BUTTON, &guPrefDialog::OnLyricDownBtnClick, this );
m_LyricsDelButton->Bind( wxEVT_BUTTON, &guPrefDialog::OnLyricDelBtnClick, this );
m_LyricsSaveListBox->Bind( wxEVT_LISTBOX, &guPrefDialog::OnLyricSaveSelected, this );
m_LyricsSaveListBox->Bind( wxEVT_LISTBOX_DCLICK, &guPrefDialog::OnLyricSaveDClicked, this );
m_LyricsSaveListBox->Bind( wxEVT_CHECKLISTBOX, &guPrefDialog::OnLyricSaveToggled, this );
m_LyricsSaveAddButton->Bind( wxEVT_BUTTON, &guPrefDialog::OnLyricSaveAddBtnClick, this );
m_LyricsSaveUpButton->Bind( wxEVT_BUTTON, &guPrefDialog::OnLyricSaveUpBtnClick, this );
m_LyricsSaveDownButton->Bind( wxEVT_BUTTON, &guPrefDialog::OnLyricSaveDownBtnClick, this );
m_LyricsSaveDelButton->Bind( wxEVT_BUTTON, &guPrefDialog::OnLyricSaveDelBtnClick, this );
m_LirycsDisGenresListBox->Bind( wxEVT_LISTBOX, &guPrefDialog::OnLyricDisGenreSelected, this );
m_LyricsDisGenreAddButton->Bind( wxEVT_BUTTON, &guPrefDialog::OnLyricDisGenreAddBtnClick, this );
m_LyricsDisGenreDelButton->Bind( wxEVT_BUTTON, &guPrefDialog::OnLyricDisGenreDelBtnClick, this );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::BuildOnlinePage( void )
{
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_ONLINE )
return;
m_VisiblePanels |= guPREFERENCE_PAGE_FLAG_ONLINE;
//
// Online Services Filter
//
wxBoxSizer * OnlineMainSizer = new wxBoxSizer( wxVERTICAL );
// Proxy
wxStaticBoxSizer * OnlineProxyMainSizer = new wxStaticBoxSizer( new wxStaticBox( m_OnlinePanel, wxID_ANY, _(" Proxy ") ), wxVERTICAL );
m_OnlineProxyEnableChkBox = new wxCheckBox( m_OnlinePanel, wxID_ANY, _("Proxy Enabled"), wxDefaultPosition, wxDefaultSize, 0 );
bool ProxyEnabled = m_Config->ReadBool( CONFIG_KEY_PROXY_ENABLED, false, CONFIG_PATH_PROXY );
m_OnlineProxyEnableChkBox->SetValue( ProxyEnabled );
OnlineProxyMainSizer->Add( m_OnlineProxyEnableChkBox, 0, wxALL, 2 );
wxFlexGridSizer * OnlineProxySizer = new wxFlexGridSizer( 2, 0, 0 );
OnlineProxySizer->SetFlexibleDirection( wxBOTH );
OnlineProxySizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
wxStaticText * ProxyHostnameStaticText = new wxStaticText( m_OnlinePanel, wxID_ANY, _( "Hostname:" ), wxDefaultPosition, wxDefaultSize, 0 );
ProxyHostnameStaticText->Wrap( -1 );
OnlineProxySizer->Add( ProxyHostnameStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5 );
wxBoxSizer * ProxyHostPortSizer = new wxBoxSizer( wxHORIZONTAL );
m_OnlineProxyHostTextCtrl = new wxTextCtrl( m_OnlinePanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 250, -1 ), 0 );
m_OnlineProxyHostTextCtrl->SetValue( m_Config->ReadStr( CONFIG_KEY_PROXY_HOSTNAME, wxEmptyString, CONFIG_PATH_PROXY ) );
m_OnlineProxyHostTextCtrl->Enable( ProxyEnabled );
ProxyHostPortSizer->Add( m_OnlineProxyHostTextCtrl, 0, wxALL, 2 );
wxStaticText * ProxyPortStaticText = new wxStaticText( m_OnlinePanel, wxID_ANY, _( "Port:" ), wxDefaultPosition, wxDefaultSize, 0 );
ProxyPortStaticText->Wrap( -1 );
ProxyHostPortSizer->Add( ProxyPortStaticText, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_OnlineProxyPortTextCtrl = new wxTextCtrl( m_OnlinePanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 50, -1 ), 0 );
m_OnlineProxyPortTextCtrl->SetValue( m_Config->ReadStr( CONFIG_KEY_PROXY_PORT, wxEmptyString, CONFIG_PATH_PROXY ) );
m_OnlineProxyPortTextCtrl->Enable( ProxyEnabled );
ProxyHostPortSizer->Add( m_OnlineProxyPortTextCtrl, 0, wxALL, 2 );
OnlineProxySizer->Add( ProxyHostPortSizer );
wxStaticText * ProxyUsernameStaticText = new wxStaticText( m_OnlinePanel, wxID_ANY, _("Username:"), wxDefaultPosition, wxDefaultSize, 0 );
ProxyUsernameStaticText->Wrap( -1 );
OnlineProxySizer->Add( ProxyUsernameStaticText, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_OnlineProxyUserTextCtrl = new wxTextCtrl( m_OnlinePanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 200,-1 ), 0 );
m_OnlineProxyUserTextCtrl->SetValue( m_Config->ReadStr( CONFIG_KEY_PROXY_USERNAME, wxEmptyString, CONFIG_PATH_PROXY ) );
m_OnlineProxyUserTextCtrl->Enable( ProxyEnabled );
OnlineProxySizer->Add( m_OnlineProxyUserTextCtrl, 0, wxALL, 2 );
wxStaticText * PasswdStaticText = new wxStaticText( m_OnlinePanel, wxID_ANY, _("Password:"), wxDefaultPosition, wxDefaultSize, 0 );
PasswdStaticText->Wrap( -1 );
OnlineProxySizer->Add( PasswdStaticText, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_OnlineProxyPasswdTextCtrl = new wxTextCtrl( m_OnlinePanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 200,-1 ), wxTE_PASSWORD );
m_OnlineProxyPasswdTextCtrl->SetValue( m_Config->ReadStr( CONFIG_KEY_PROXY_PASSWORD, wxEmptyString, CONFIG_PATH_PROXY ) );
m_OnlineProxyPasswdTextCtrl->Enable( ProxyEnabled );
OnlineProxySizer->Add( m_OnlineProxyPasswdTextCtrl, 0, wxALL, 2 );
OnlineProxyMainSizer->Add( OnlineProxySizer, 1, wxEXPAND, 2 );
OnlineMainSizer->Add( OnlineProxyMainSizer, 0, wxEXPAND|wxALL, 5 );
wxStaticBoxSizer * OnlineFiltersSizer = new wxStaticBoxSizer( new wxStaticBox( m_OnlinePanel, wxID_ANY, _(" Filters ") ), wxHORIZONTAL );
m_OnlineFiltersListBox = new wxListBox( m_OnlinePanel, wxID_ANY, wxDefaultPosition, wxSize( -1, 100 ), 0, NULL, 0 );
m_OnlineFiltersListBox->Append( m_Config->ReadAStr( CONFIG_KEY_SEARCH_FILTERS_FILTER, wxEmptyString, CONFIG_PATH_SEARCH_FILTERS ) );
OnlineFiltersSizer->Add( m_OnlineFiltersListBox, 1, wxALL|wxEXPAND, 5 );
wxBoxSizer * OnlineBtnSizer = new wxBoxSizer( wxVERTICAL );
m_OnlineAddBtn = new wxBitmapButton( m_OnlinePanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_add ), wxDefaultPosition, wxDefaultSize, 0 );
OnlineBtnSizer->Add( m_OnlineAddBtn, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_OnlineDelBtn = new wxBitmapButton( m_OnlinePanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_del ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_OnlineDelBtn->Disable();
OnlineBtnSizer->Add( m_OnlineDelBtn, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
OnlineFiltersSizer->Add( OnlineBtnSizer, 0, wxEXPAND, 5 );
OnlineMainSizer->Add( OnlineFiltersSizer, 0, wxEXPAND|wxALL, 5 );
wxStaticBoxSizer * OnlineLangSizer = new wxStaticBoxSizer( new wxStaticBox( m_OnlinePanel, wxID_ANY, _( " Language " ) ), wxHORIZONTAL );
m_LangStaticText = new wxStaticText( m_OnlinePanel, wxID_ANY, _("Language:"), wxDefaultPosition, wxDefaultSize, 0 );
m_LangStaticText->Wrap( -1 );
OnlineLangSizer->Add( m_LangStaticText, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_LangChoice = new wxChoice( m_OnlinePanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_LFMLangNames, 0 );
int LangIndex = m_LFMLangIds.Index( m_Config->ReadStr( CONFIG_KEY_LASTFM_LANGUAGE, wxEmptyString, CONFIG_PATH_LASTFM ) );
if( LangIndex == wxNOT_FOUND ) LangIndex = 0;
m_LangChoice->SetSelection( LangIndex );
m_LangChoice->SetMinSize( wxSize( 250,-1 ) );
OnlineLangSizer->Add( m_LangChoice, 0, wxALL, 5 );
OnlineMainSizer->Add( OnlineLangSizer, 0, wxEXPAND|wxALL, 5 );
wxStaticBoxSizer * BrowserCmdSizer = new wxStaticBoxSizer( new wxStaticBox( m_OnlinePanel, wxID_ANY, _(" Browser command ") ), wxHORIZONTAL );
m_BrowserCmdTextCtrl = new wxTextCtrl( m_OnlinePanel, wxID_ANY, m_Config->ReadStr( CONFIG_KEY_GENERAL_BROWSER_COMMAND, wxT( "firefox --new-tab" ), CONFIG_PATH_GENERAL ), wxDefaultPosition, wxDefaultSize, 0 );
BrowserCmdSizer->Add( m_BrowserCmdTextCtrl, 1, wxALL, 5 );
OnlineMainSizer->Add( BrowserCmdSizer, 0, wxEXPAND|wxALL, 5 );
m_LastMinBitRate = m_Config->ReadNum( CONFIG_KEY_RADIOS_MIN_BITRATE, 128, CONFIG_PATH_RADIOS );
wxStaticBoxSizer * RadioBitRateSizer = new wxStaticBoxSizer( new wxStaticBox( m_OnlinePanel, wxID_ANY, _( " Minimum radio allowed bit rate " ) ), wxHORIZONTAL );
m_RadioMinBitRateSlider = new wxSlider( m_OnlinePanel, wxID_ANY, m_LastMinBitRate, 0, 320, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS );
RadioBitRateSizer->Add( m_RadioMinBitRateSlider, 1, wxEXPAND, 5 );
OnlineMainSizer->Add( RadioBitRateSizer, 0, wxEXPAND|wxALL, 5 );
wxStaticBoxSizer * BufferSizeSizer = new wxStaticBoxSizer( new wxStaticBox( m_OnlinePanel, wxID_ANY, _( " Player online buffer size ") ), wxHORIZONTAL );
m_BufferSizeSlider = new wxSlider( m_OnlinePanel, wxID_ANY, m_Config->ReadNum( CONFIG_KEY_GENERAL_BUFFER_SIZE, 64, CONFIG_PATH_GENERAL ), 32, 1024, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS );
BufferSizeSizer->Add( m_BufferSizeSlider, 1, wxEXPAND, 5 );
OnlineMainSizer->Add( BufferSizeSizer, 0, wxEXPAND|wxALL, 5 );
m_OnlinePanel->SetSizer( OnlineMainSizer );
m_OnlinePanel->Layout();
OnlineMainSizer->FitInside( m_OnlinePanel );
//
//
//
m_OnlineProxyEnableChkBox->Bind( wxEVT_CHECKBOX, &guPrefDialog::OnOnlineProxyEnabledChanged, this );
m_OnlineFiltersListBox->Bind( wxEVT_LISTBOX, &guPrefDialog::OnFiltersListBoxSelected, this );
m_OnlineAddBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnOnlineAddBtnClick, this );
m_OnlineDelBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnOnlineDelBtnClick, this );
m_OnlineFiltersListBox->Bind( wxEVT_LISTBOX_DCLICK, &guPrefDialog::OnOnlineListBoxDClicked, this );
m_RadioMinBitRateSlider->Bind( wxEVT_SCROLL_CHANGED, &guPrefDialog::OnOnlineMinBitRateChanged, this );
m_RadioMinBitRateSlider->Bind( wxEVT_SCROLL_THUMBTRACK, &guPrefDialog::OnOnlineMinBitRateChanged, this );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::BuildPodcastsPage( void )
{
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_PODCASTS )
return;
m_VisiblePanels |= guPREFERENCE_PAGE_FLAG_PODCASTS;
//
// Podcasts
//
wxBoxSizer * PodcastsMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer * PodcastsSizer = new wxStaticBoxSizer( new wxStaticBox( m_PodcastPanel, wxID_ANY, _(" Podcasts ") ), wxVERTICAL );
wxBoxSizer * PathSizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticText * PodcastPathStaticText = new wxStaticText( m_PodcastPanel, wxID_ANY, _("Destination directory:"), wxDefaultPosition, wxDefaultSize, 0 );
PodcastPathStaticText->Wrap( -1 );
PathSizer->Add( PodcastPathStaticText, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_PodcastPath = new wxDirPickerCtrl( m_PodcastPanel, wxID_ANY, wxEmptyString, _("Select podcasts folder"), wxDefaultPosition, wxDefaultSize, wxDIRP_DEFAULT_STYLE | wxDIRP_DIR_MUST_EXIST );
m_PodcastPath->SetPath( m_Config->ReadStr( CONFIG_KEY_PODCASTS_PATH, guPATH_PODCASTS, CONFIG_PATH_PODCASTS ) );
PathSizer->Add( m_PodcastPath, 1, wxBOTTOM|wxRIGHT|wxEXPAND, 5 );
PodcastsSizer->Add( PathSizer, 0, wxEXPAND, 5 );
wxBoxSizer * UpdateSizer = new wxBoxSizer( wxHORIZONTAL );
m_PodcastUpdate = new wxCheckBox( m_PodcastPanel, wxID_ANY, _( "Check every" ), wxDefaultPosition, wxDefaultSize, 0 );
m_PodcastUpdate->SetValue( m_Config->ReadBool( CONFIG_KEY_PODCASTS_UPDATE, true, CONFIG_PATH_PODCASTS ) );
UpdateSizer->Add( m_PodcastUpdate, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxString m_PodcastUpdatePeriodChoices[] = { _( "Hour" ), _( "Day" ), _( "Week" ), _( "Month" ) };
int m_PodcastUpdatePeriodNChoices = sizeof( m_PodcastUpdatePeriodChoices ) / sizeof( wxString );
m_PodcastUpdatePeriod = new wxChoice( m_PodcastPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_PodcastUpdatePeriodNChoices, m_PodcastUpdatePeriodChoices, 0 );
m_PodcastUpdatePeriod->SetSelection( m_Config->ReadNum( CONFIG_KEY_PODCASTS_UPDATEPERIOD, 0, CONFIG_PATH_PODCASTS ) );
m_PodcastUpdatePeriod->SetMinSize( wxSize( 150,-1 ) );
UpdateSizer->Add( m_PodcastUpdatePeriod, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
PodcastsSizer->Add( UpdateSizer, 0, wxEXPAND, 5 );
wxBoxSizer * DeleteSizer = new wxBoxSizer( wxHORIZONTAL );
m_PodcastDelete = new wxCheckBox( m_PodcastPanel, wxID_ANY, _("Delete after"), wxDefaultPosition, wxDefaultSize, 0 );
m_PodcastDelete->SetValue( m_Config->ReadBool( CONFIG_KEY_PODCASTS_DELETE, false, CONFIG_PATH_PODCASTS ) );
DeleteSizer->Add( m_PodcastDelete, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_PodcastDeleteTime = new wxSpinCtrl( m_PodcastPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 99,
m_Config->ReadNum( CONFIG_KEY_PODCASTS_DELETETIME, 15, CONFIG_PATH_PODCASTS ) );
DeleteSizer->Add( m_PodcastDeleteTime, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
wxString m_PodcastDeletePeriodChoices[] = { _("Days"), _("Weeks"), _("Months") };
int m_PodcastDeletePeriodNChoices = sizeof( m_PodcastDeletePeriodChoices ) / sizeof( wxString );
m_PodcastDeletePeriod = new wxChoice( m_PodcastPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_PodcastDeletePeriodNChoices, m_PodcastDeletePeriodChoices, 0 );
m_PodcastDeletePeriod->SetSelection( m_Config->ReadNum( CONFIG_KEY_PODCASTS_DELETEPERIOD, 0, CONFIG_PATH_PODCASTS ) );
m_PodcastDeletePeriod->SetMinSize( wxSize( 150,-1 ) );
DeleteSizer->Add( m_PodcastDeletePeriod, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
DeleteSizer->Add( 0, 0, 1, wxEXPAND, 5 );
m_PodcastDeletePlayed = new wxCheckBox( m_PodcastPanel, wxID_ANY, _("Only if played"), wxDefaultPosition, wxDefaultSize, 0 );
m_PodcastDeletePlayed->SetValue( m_Config->ReadBool( CONFIG_KEY_PODCASTS_DELETEPLAYED, false, CONFIG_PATH_PODCASTS ) );
DeleteSizer->Add( m_PodcastDeletePlayed, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
PodcastsSizer->Add( DeleteSizer, 0, wxEXPAND, 5 );
PodcastsMainSizer->Add( PodcastsSizer, 0, wxEXPAND|wxALL, 5 );
m_PodcastPanel->SetSizer( PodcastsMainSizer );
m_PodcastPanel->Layout();
PodcastsMainSizer->FitInside( m_PodcastPanel );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::BuildJamendoPage( void )
{
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_JAMENDO )
return;
m_VisiblePanels |= guPREFERENCE_PAGE_FLAG_JAMENDO;
//
// Jamendo
//
wxBoxSizer * JamMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer * JamGenresSizer = new wxStaticBoxSizer( new wxStaticBox( m_JamendoPanel, wxID_ANY, _( " Genres " ) ), wxHORIZONTAL );
wxArrayString JamendoGenres;
int Index = 0;
do {
wxString GenreName = TStringTowxString( TagLib::ID3v1::genre( Index++ ) );
if( !GenreName.IsEmpty() )
JamendoGenres.Add( GenreName );
else
break;
} while( true );
m_LastJamendoGenres = m_Config->ReadANum( CONFIG_KEY_JAMENDO_GENRES_GENRE, 0, CONFIG_PATH_JAMENDO_GENRES );
guLogMessage( wxT( "Read %li jamendo genres" ), m_LastJamendoGenres.Count() );
m_JamGenresListBox = new wxCheckListBox( m_JamendoPanel, wxID_ANY, wxDefaultPosition, wxSize( -1, guPREFERENCES_LISTBOX_HEIGHT ), JamendoGenres, 0 );
int Count = m_LastJamendoGenres.Count();
for( int Index = 0; Index < Count; Index++ )
{
m_JamGenresListBox->Check( m_LastJamendoGenres[ Index ] );
//guLogMessage( wxT( "Checking %i" ), m_LastJamendoGenres[ Index ] );
}
JamGenresSizer->Add( m_JamGenresListBox, 1, wxALL|wxEXPAND, 5 );
wxBoxSizer * JamGenresBtnSizer = new wxBoxSizer( wxVERTICAL );
m_JamSelAllBtn = new wxButton( m_JamendoPanel, wxID_ANY, _( "All" ), wxDefaultPosition, wxDefaultSize, 0 );
JamGenresBtnSizer->Add( m_JamSelAllBtn, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
m_JamSelNoneBtn = new wxButton( m_JamendoPanel, wxID_ANY, _( "None" ), wxDefaultPosition, wxDefaultSize, 0 );
JamGenresBtnSizer->Add( m_JamSelNoneBtn, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
m_JamInvertBtn = new wxButton( m_JamendoPanel, wxID_ANY, _("Invert"), wxDefaultPosition, wxDefaultSize, 0 );
JamGenresBtnSizer->Add( m_JamInvertBtn, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
JamGenresSizer->Add( JamGenresBtnSizer, 0, wxEXPAND, 5 );
JamMainSizer->Add( JamGenresSizer, 1, wxEXPAND|wxALL, 5 );
wxStaticBoxSizer * JamOtherSizer = new wxStaticBoxSizer( new wxStaticBox( m_JamendoPanel, wxID_ANY, wxEmptyString ), wxVERTICAL );
wxFlexGridSizer * JamFlexSizer = new wxFlexGridSizer( 2, 0, 0 );
JamFlexSizer->AddGrowableCol( 1 );
JamFlexSizer->SetFlexibleDirection( wxBOTH );
JamFlexSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
wxStaticText * JamFormatLabel = new wxStaticText( m_JamendoPanel, wxID_ANY, _( "Audio format:" ), wxDefaultPosition, wxDefaultSize, 0 );
JamFormatLabel->Wrap( -1 );
JamFlexSizer->Add( JamFormatLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxALIGN_RIGHT, 5 );
wxArrayString m_JamFormatChoices;
m_JamFormatChoices.Add( wxT( "mp3" ) );
m_JamFormatChoices.Add( wxT( "ogg" ) );
m_JamFormatChoice = new wxChoice( m_JamendoPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_JamFormatChoices, 0 );
m_JamFormatChoice->SetSelection( m_Config->ReadNum( CONFIG_KEY_JAMENDO_AUDIOFORMAT, 1, CONFIG_PATH_JAMENDO ) );
JamFlexSizer->Add( m_JamFormatChoice, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
wxStaticText * JamBTCmdLabel = new wxStaticText( m_JamendoPanel, wxID_ANY, _( "Torrent command:" ), wxDefaultPosition, wxDefaultSize, 0 );
JamBTCmdLabel->Wrap( -1 );
JamFlexSizer->Add( JamBTCmdLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT|wxALIGN_RIGHT, 5 );
m_JamBTCmd = new wxTextCtrl( m_JamendoPanel, wxID_ANY, m_Config->ReadStr( CONFIG_KEY_JAMENDO_TORRENT_COMMAND, wxT( "transmission" ), CONFIG_PATH_JAMENDO ), wxDefaultPosition, wxDefaultSize, 0 );
JamFlexSizer->Add( m_JamBTCmd, 1, wxEXPAND|wxALL, 5 );
JamOtherSizer->Add( JamFlexSizer, 1, wxEXPAND, 5 );
JamMainSizer->Add( JamOtherSizer, 0, wxEXPAND|wxALL, 5 );
m_JamendoPanel->SetSizer( JamMainSizer );
m_JamendoPanel->Layout();
JamMainSizer->FitInside( m_JamendoPanel );
m_JamSelAllBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnJamendoSelectAll, this );
m_JamSelNoneBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnJamendoSelectNone, this );
m_JamInvertBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnJamendoInvertSelection, this );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::BuildMagnatunePage( void )
{
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_MAGNATUNE )
return;
m_VisiblePanels |= guPREFERENCE_PAGE_FLAG_MAGNATUNE;
//
// Magnatune
//
wxBoxSizer * MagMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer * MagGenresSizer = new wxStaticBoxSizer( new wxStaticBox( m_MagnatunePanel, wxID_ANY, _(" Genres ") ), wxHORIZONTAL );
wxArrayString MagnatuneGenres = m_Config->ReadAStr( CONFIG_KEY_MAGNATUNE_GENRES_GENRE, wxEmptyString, CONFIG_PATH_MAGNATUNE_GENRELIST );
if( !MagnatuneGenres.Count() )
{
int Index = 0;
do {
wxString GenreName = TStringTowxString( TagLib::ID3v1::genre( Index++ ) );
if( !GenreName.IsEmpty() )
MagnatuneGenres.Add( GenreName );
else
break;
} while( true );
}
m_LastMagnatuneGenres = m_Config->ReadAStr( CONFIG_KEY_MAGNATUNE_GENRES_GENRE, wxEmptyString, CONFIG_PATH_MAGNATUNE_GENRES );
m_MagGenresListBox = new wxCheckListBox( m_MagnatunePanel, wxID_ANY, wxDefaultPosition, wxSize( -1, guPREFERENCES_LISTBOX_HEIGHT ), MagnatuneGenres, 0 );
int Count = m_LastMagnatuneGenres.Count();
for( int Index = 0; Index < Count; Index++ )
{
int Pos = MagnatuneGenres.Index( m_LastMagnatuneGenres[ Index ] );
if( Pos != wxNOT_FOUND )
m_MagGenresListBox->Check( Pos );
}
MagGenresSizer->Add( m_MagGenresListBox, 1, wxALL|wxEXPAND, 5 );
wxBoxSizer * MagGenresBtnSizer = new wxBoxSizer( wxVERTICAL );
m_MagSelAllBtn = new wxButton( m_MagnatunePanel, wxID_ANY, _( "All" ), wxDefaultPosition, wxDefaultSize, 0 );
MagGenresBtnSizer->Add( m_MagSelAllBtn, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
m_MagSelNoneBtn = new wxButton( m_MagnatunePanel, wxID_ANY, _("None"), wxDefaultPosition, wxDefaultSize, 0 );
MagGenresBtnSizer->Add( m_MagSelNoneBtn, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
m_MagInvertBtn = new wxButton( m_MagnatunePanel, wxID_ANY, _("Invert"), wxDefaultPosition, wxDefaultSize, 0 );
MagGenresBtnSizer->Add( m_MagInvertBtn, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
MagGenresSizer->Add( MagGenresBtnSizer, 0, wxEXPAND, 5 );
MagMainSizer->Add( MagGenresSizer, 1, wxEXPAND|wxALL, 5 );
wxStaticBoxSizer * MagOtherSizer = new wxStaticBoxSizer( new wxStaticBox( m_MagnatunePanel, wxID_ANY, wxEmptyString ), wxVERTICAL );
wxFlexGridSizer * MagFlexSizer = new wxFlexGridSizer( 2, 0, 0 );
MagFlexSizer->AddGrowableCol( 1 );
MagFlexSizer->SetFlexibleDirection( wxBOTH );
MagFlexSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
wxStaticText * MagMemberLabel = new wxStaticText( m_MagnatunePanel, wxID_ANY, _( "Membership :" ), wxDefaultPosition, wxDefaultSize, 0 );
MagMemberLabel->Wrap( -1 );
MagFlexSizer->Add( MagMemberLabel, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
wxBoxSizer * MagMembSizer = new wxBoxSizer( wxHORIZONTAL );
m_MagNoRadioItem = new wxRadioButton( m_MagnatunePanel, wxID_ANY, _( "None" ), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
m_MagStRadioItem = new wxRadioButton( m_MagnatunePanel, wxID_ANY, _( "Streaming" ), wxDefaultPosition, wxDefaultSize );
m_MagDlRadioItem = new wxRadioButton( m_MagnatunePanel, wxID_ANY, _( "Downloading" ), wxDefaultPosition, wxDefaultSize );
int Membership = m_Config->ReadNum( CONFIG_KEY_MAGNATUNE_MEMBERSHIP, 0, CONFIG_PATH_MAGNATUNE );
if( Membership == 1 ) m_MagStRadioItem->SetValue( true );
else if( Membership == 2 ) m_MagDlRadioItem->SetValue( true );
else m_MagNoRadioItem->SetValue( true );
MagMembSizer->Add( m_MagNoRadioItem, 0, wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
MagMembSizer->Add( m_MagStRadioItem, 0, wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
MagMembSizer->Add( m_MagDlRadioItem, 0, wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
MagFlexSizer->Add( MagMembSizer, 1, wxEXPAND, 5 );
wxStaticText * MagUserLabel = new wxStaticText( m_MagnatunePanel, wxID_ANY, _( "Username :" ), wxDefaultPosition, wxDefaultSize, 0 );
MagUserLabel->Wrap( -1 );
MagFlexSizer->Add( MagUserLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
m_MagUserTextCtrl = new wxTextCtrl( m_MagnatunePanel, wxID_ANY, m_Config->ReadStr( CONFIG_KEY_MAGNATUNE_USERNAME, wxEmptyString, CONFIG_PATH_MAGNATUNE ), wxDefaultPosition, wxDefaultSize, 0 );
m_MagUserTextCtrl->Enable( !m_MagNoRadioItem->GetValue() );
MagFlexSizer->Add( m_MagUserTextCtrl, 0, wxTOP|wxBOTTOM|wxRIGHT|wxEXPAND, 5 );
wxStaticText * MagPassLabel = new wxStaticText( m_MagnatunePanel, wxID_ANY, _( "Password :" ), wxDefaultPosition, wxDefaultSize, 0 );
MagPassLabel->Wrap( -1 );
MagFlexSizer->Add( MagPassLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_RIGHT, 5 );
m_MagPassTextCtrl = new wxTextCtrl( m_MagnatunePanel, wxID_ANY, m_Config->ReadStr( CONFIG_KEY_MAGNATUNE_PASSWORD, wxEmptyString, CONFIG_PATH_MAGNATUNE ), wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD );
m_MagPassTextCtrl->Enable( !m_MagNoRadioItem->GetValue() );
MagFlexSizer->Add( m_MagPassTextCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
// wxStaticText * MagFormatLabel = new wxStaticText( m_MagnatunePanel, wxID_ANY, _( "Format :" ), wxDefaultPosition, wxDefaultSize, 0 );
// MagFormatLabel->Wrap( -1 );
// MagFlexSizer->Add( MagFormatLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
//
// wxArrayString MagFormatChoices;
// MagFormatChoices.Add( wxT( "mp3" ) );
// MagFormatChoices.Add( wxT( "ogg" ) );
// m_MagFormatChoice = new wxChoice( m_MagnatunePanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, MagFormatChoices, 0 );
// m_MagFormatChoice->SetSelection( m_Config->ReadNum( CONFIG_KEY_MAGNATUNE_AUDIO_FORMAT, 1, CONFIG_PATH_MAGNATUNE ) );
// MagFlexSizer->Add( m_MagFormatChoice, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxStaticText * MagFormatLabel = new wxStaticText( m_MagnatunePanel, wxID_ANY, _( "Stream as :" ), wxDefaultPosition, wxDefaultSize, 0 );
MagFormatLabel->Wrap( -1 );
MagFlexSizer->Add( MagFormatLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxBoxSizer * FormatSizer = new wxBoxSizer( wxHORIZONTAL );
wxString m_MagFormatChoiceChoices[] = { wxT("mp3"), wxT("ogg") };
int m_MagFormatChoiceNChoices = sizeof( m_MagFormatChoiceChoices ) / sizeof( wxString );
m_MagFormatChoice = new wxChoice( m_MagnatunePanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_MagFormatChoiceNChoices, m_MagFormatChoiceChoices, 0 );
m_MagFormatChoice->SetSelection( m_Config->ReadNum( CONFIG_KEY_MAGNATUNE_AUDIO_FORMAT, 1, CONFIG_PATH_MAGNATUNE ) );
m_MagFormatChoice->SetMinSize( wxSize( 100,-1 ) );
FormatSizer->Add( m_MagFormatChoice, 1, wxBOTTOM|wxRIGHT|wxEXPAND, 5 );
wxStaticText * MagDownLabel = new wxStaticText( m_MagnatunePanel, wxID_ANY, _("Download as :"), wxDefaultPosition, wxDefaultSize, 0 );
MagDownLabel->Wrap( -1 );
FormatSizer->Add( MagDownLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxString m_MagDownFormatChoiceChoices[] = { _( "Download Page" ), wxT("mp3 (VBR)"), wxT("mp3 (128Kbits)"), wxT("ogg"), wxT("flac"), wxT("wav") };
int m_MagDownFormatChoiceNChoices = sizeof( m_MagDownFormatChoiceChoices ) / sizeof( wxString );
m_MagDownFormatChoice = new wxChoice( m_MagnatunePanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_MagDownFormatChoiceNChoices, m_MagDownFormatChoiceChoices, 0 );
m_MagDownFormatChoice->SetSelection( m_Config->ReadNum( CONFIG_KEY_MAGNATUNE_DOWNLOAD_FORMAT, 0, CONFIG_PATH_MAGNATUNE ) );
m_MagDownFormatChoice->Enable( Membership == 2 );
m_MagDownFormatChoice->SetMinSize( wxSize( 100,-1 ) );
FormatSizer->Add( m_MagDownFormatChoice, 1, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
MagFlexSizer->Add( FormatSizer, 1, wxEXPAND, 5 );
MagOtherSizer->Add( MagFlexSizer, 1, wxEXPAND, 5 );
MagMainSizer->Add( MagOtherSizer, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_MagnatunePanel->SetSizer( MagMainSizer );
m_MagnatunePanel->Layout();
MagMainSizer->FitInside( m_MagnatunePanel );
m_MagSelAllBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnMagnatuneSelectAll, this );
m_MagSelNoneBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnMagnatuneSelectNone, this );
m_MagInvertBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnMagnatuneInvertSelection, this );
m_MagNoRadioItem->Bind( wxEVT_RADIOBUTTON, &guPrefDialog::OnMagNoRadioItemChanged, this );
m_MagStRadioItem->Bind( wxEVT_RADIOBUTTON, &guPrefDialog::OnMagNoRadioItemChanged, this );
m_MagDlRadioItem->Bind( wxEVT_RADIOBUTTON, &guPrefDialog::OnMagNoRadioItemChanged, this );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::BuildLinksPage( void )
{
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_LINKS )
return;
m_VisiblePanels |= guPREFERENCE_PAGE_FLAG_LINKS;
//
// Links
//
wxBoxSizer * LinksMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer * LinksLabelSizer = new wxStaticBoxSizer( new wxStaticBox( m_LinksPanel, wxID_ANY, _(" Links ") ), wxVERTICAL );
wxBoxSizer * LinksListBoxSizer = new wxBoxSizer( wxHORIZONTAL );
m_LinksListBox = new wxListBox( m_LinksPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
wxArrayString SearchLinks = m_Config->ReadAStr( CONFIG_KEY_SEARCHLINKS_LINK, wxEmptyString, CONFIG_PATH_SEARCHLINKS_LINKS );
m_LinksListBox->Append( SearchLinks );
m_LinksNames = m_Config->ReadAStr( CONFIG_KEY_SEARCHLINKS_NAME, wxEmptyString, CONFIG_PATH_SEARCHLINKS_NAMES );
int count = m_LinksListBox->GetCount();
while( ( int ) m_LinksNames.Count() < count )
m_LinksNames.Add( wxEmptyString );
while( ( int ) m_LinksNames.Count() > count )
m_LinksNames.RemoveAt( count );
for( int index = 0; index < count; index++ )
{
if( m_LinksNames[ index ].IsEmpty() )
{
wxURI Uri( SearchLinks[ index ] );
m_LinksNames[ index ] = Uri.GetServer();
}
}
LinksListBoxSizer->Add( m_LinksListBox, 1, wxALL|wxEXPAND, 5 );
wxBoxSizer * LinksBtnSizer = new wxBoxSizer( wxVERTICAL );
m_LinksAddBtn = new wxBitmapButton( m_LinksPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_add ), wxDefaultPosition, wxDefaultSize, 0 );
m_LinksAddBtn->Enable( false );
LinksBtnSizer->Add( m_LinksAddBtn, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_LinksMoveUpBtn = new wxBitmapButton( m_LinksPanel, wxID_ANY, guImage( guIMAGE_INDEX_up ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LinksMoveUpBtn->Enable( false );
LinksBtnSizer->Add( m_LinksMoveUpBtn, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_LinksMoveDownBtn = new wxBitmapButton( m_LinksPanel, wxID_ANY, guImage( guIMAGE_INDEX_down ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LinksMoveDownBtn->Enable( false );
LinksBtnSizer->Add( m_LinksMoveDownBtn, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_LinksDelBtn = new wxBitmapButton( m_LinksPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_del ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LinksDelBtn->Enable( false );
LinksBtnSizer->Add( m_LinksDelBtn, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
LinksListBoxSizer->Add( LinksBtnSizer, 0, wxEXPAND, 5 );
LinksLabelSizer->Add( LinksListBoxSizer, 1, wxEXPAND, 5 );
wxBoxSizer * LinksEditorSizer = new wxBoxSizer( wxHORIZONTAL );
wxFlexGridSizer * LinksFieldsSizer = new wxFlexGridSizer( 2, 0, 0 );
LinksFieldsSizer->AddGrowableCol( 1 );
LinksFieldsSizer->SetFlexibleDirection( wxBOTH );
LinksFieldsSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
wxStaticText * LinkUrlStaticText = new wxStaticText( m_LinksPanel, wxID_ANY, _("URL:"), wxDefaultPosition, wxDefaultSize, 0 );
LinkUrlStaticText->Wrap( -1 );
LinksFieldsSizer->Add( LinkUrlStaticText, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
m_LinksUrlTextCtrl = new wxTextCtrl( m_LinksPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
LinksFieldsSizer->Add( m_LinksUrlTextCtrl, 1, wxALL|wxEXPAND, 5 );
wxStaticText * LinkNameStaticText = new wxStaticText( m_LinksPanel, wxID_ANY, _("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
LinkNameStaticText->Wrap( -1 );
LinksFieldsSizer->Add( LinkNameStaticText, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
m_LinksNameTextCtrl = new wxTextCtrl( m_LinksPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
LinksFieldsSizer->Add( m_LinksNameTextCtrl, 1, wxALL|wxEXPAND, 5 );
LinksEditorSizer->Add( LinksFieldsSizer, 1, wxEXPAND, 5 );
m_LinksAcceptBtn = new wxBitmapButton( m_LinksPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_accept ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_LinksAcceptBtn->Enable( false );
LinksEditorSizer->Add( m_LinksAcceptBtn, 0, wxALL, 5 );
LinksLabelSizer->Add( LinksEditorSizer, 0, wxEXPAND, 5 );
LinksMainSizer->Add( LinksLabelSizer, 1, wxEXPAND|wxALL, 5 );
wxStaticBoxSizer * LinksHelpSizer = new wxStaticBoxSizer( new wxStaticBox( m_LinksPanel, wxID_ANY, _(" Define URLs using ") ), wxHORIZONTAL );
wxStaticText * LinksHelpText = new wxStaticText( m_LinksPanel, wxID_ANY, wxT("{lang}:\n{text}:"), wxDefaultPosition, wxDefaultSize, 0 );
LinksHelpText->Wrap( -1 );
LinksHelpSizer->Add( LinksHelpText, 0, wxALL, 5 );
LinksHelpText = new wxStaticText( m_LinksPanel, wxID_ANY, _( "2 letters language code\nText to search"), wxDefaultPosition, wxDefaultSize, 0 );
LinksHelpText->Wrap( -1 );
LinksHelpSizer->Add( LinksHelpText, 0, wxALL, 5 );
LinksMainSizer->Add( LinksHelpSizer, 0, wxEXPAND|wxALL, 5 );
m_LinksPanel->SetSizer( LinksMainSizer );
m_LinksPanel->Layout();
LinksMainSizer->FitInside( m_LinksPanel );
//
//
//
m_LinksListBox->Bind( wxEVT_LISTBOX, &guPrefDialog::OnLinksListBoxSelected, this );
m_LinksAddBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnLinksAddBtnClick, this );
m_LinksDelBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnLinksDelBtnClick, this );
m_LinksMoveUpBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnLinkMoveUpBtnClick, this );
m_LinksMoveDownBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnLinkMoveDownBtnClick, this );
m_LinksUrlTextCtrl->Bind( wxEVT_TEXT, &guPrefDialog::OnLinksTextChanged, this );
m_LinksNameTextCtrl->Bind( wxEVT_TEXT, &guPrefDialog::OnLinksTextChanged, this );
m_LinksAcceptBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnLinksSaveBtnClick, this );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::BuildCommandsPage( void )
{
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_COMMANDS )
return;
m_VisiblePanels |= guPREFERENCE_PAGE_FLAG_COMMANDS;
//
// Commands Panel
//
wxBoxSizer * CmdMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer * CmdLabelSizer = new wxStaticBoxSizer( new wxStaticBox( m_CmdPanel, wxID_ANY, _(" Commands ") ), wxVERTICAL );
wxBoxSizer * CmdListBoxSizer = new wxBoxSizer( wxHORIZONTAL );
m_CmdListBox = new wxListBox( m_CmdPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
wxArrayString Commands = m_Config->ReadAStr( CONFIG_KEY_COMMANDS_EXEC, wxEmptyString, CONFIG_PATH_COMMANDS_EXECS );
m_CmdListBox->Append( Commands );
m_CmdNames = m_Config->ReadAStr( CONFIG_KEY_COMMANDS_NAME, wxEmptyString, CONFIG_PATH_COMMANDS_NAMES );
int count = m_CmdListBox->GetCount();
while( ( int ) m_CmdNames.Count() < count )
m_CmdNames.Add( wxEmptyString );
if( ( int ) m_CmdNames.Count() > count )
m_CmdNames.RemoveAt( count, m_CmdNames.Count() - count );
for( int index = 0; index < count; index++ )
{
if( m_CmdNames[ index ].IsEmpty() )
{
m_CmdNames[ index ] = Commands[ index ].BeforeFirst( ' ' );
}
}
CmdListBoxSizer->Add( m_CmdListBox, 1, wxALL|wxEXPAND, 5 );
wxBoxSizer * CmdBtnSizer = new wxBoxSizer( wxVERTICAL );
m_CmdAddBtn = new wxBitmapButton( m_CmdPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_add ), wxDefaultPosition, wxDefaultSize, 0 );
m_CmdAddBtn->Enable( false );
CmdBtnSizer->Add( m_CmdAddBtn, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_CmdMoveUpBtn = new wxBitmapButton( m_CmdPanel, wxID_ANY, guImage( guIMAGE_INDEX_up ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_CmdMoveUpBtn->Enable( false );
CmdBtnSizer->Add( m_CmdMoveUpBtn, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_CmdMoveDownBtn = new wxBitmapButton( m_CmdPanel, wxID_ANY, guImage( guIMAGE_INDEX_down ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_CmdMoveDownBtn->Enable( false );
CmdBtnSizer->Add( m_CmdMoveDownBtn, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_CmdDelBtn = new wxBitmapButton( m_CmdPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_del ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_CmdDelBtn->Enable( false );
CmdBtnSizer->Add( m_CmdDelBtn, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
CmdListBoxSizer->Add( CmdBtnSizer, 0, wxEXPAND, 5 );
CmdLabelSizer->Add( CmdListBoxSizer, 1, wxEXPAND, 5 );
wxBoxSizer * CmdEditorSizer = new wxBoxSizer( wxHORIZONTAL );
wxFlexGridSizer * CmdFieldsSizer = new wxFlexGridSizer( 2, 0, 0 );
CmdFieldsSizer->AddGrowableCol( 1 );
CmdFieldsSizer->SetFlexibleDirection( wxBOTH );
CmdFieldsSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
wxStaticText * CmdStaticText = new wxStaticText( m_CmdPanel, wxID_ANY, _( "Command:" ), wxDefaultPosition, wxDefaultSize, 0 );
CmdStaticText->Wrap( -1 );
CmdFieldsSizer->Add( CmdStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
m_CmdTextCtrl = new wxTextCtrl( m_CmdPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
CmdFieldsSizer->Add( m_CmdTextCtrl, 1, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 );
wxStaticText * CmdNameStaticText = new wxStaticText( m_CmdPanel, wxID_ANY, _( "Name:" ), wxDefaultPosition, wxDefaultSize, 0 );
CmdNameStaticText->Wrap( -1 );
CmdFieldsSizer->Add( CmdNameStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
m_CmdNameTextCtrl = new wxTextCtrl( m_CmdPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
CmdFieldsSizer->Add( m_CmdNameTextCtrl, 1, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 );
CmdEditorSizer->Add( CmdFieldsSizer, 1, wxEXPAND, 5 );
m_CmdAcceptBtn = new wxBitmapButton( m_CmdPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_accept ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_CmdAcceptBtn->Enable( false );
CmdEditorSizer->Add( m_CmdAcceptBtn, 0, wxALL, 5 );
CmdLabelSizer->Add( CmdEditorSizer, 0, wxEXPAND, 5 );
CmdMainSizer->Add( CmdLabelSizer, 1, wxEXPAND|wxALL, 5 );
wxStaticBoxSizer * CmdHelpSizer = new wxStaticBoxSizer( new wxStaticBox( m_CmdPanel, wxID_ANY, _(" Define commands using ") ), wxHORIZONTAL );
wxStaticText * CmdHelpText = new wxStaticText( m_CmdPanel, wxID_ANY, wxT( "{bp}:\n{bc}:\n{tp}:"), wxDefaultPosition, wxDefaultSize, 0 );
CmdHelpText->Wrap( -1 );
CmdHelpSizer->Add( CmdHelpText, 0, wxALL, 5 );
CmdHelpText = new wxStaticText( m_CmdPanel, wxID_ANY, _( "Album path\nAlbum cover file path\nTrack path"), wxDefaultPosition, wxDefaultSize, 0 );
CmdHelpText->Wrap( -1 );
CmdHelpSizer->Add( CmdHelpText, 0, wxALL, 5 );
CmdMainSizer->Add( CmdHelpSizer, 0, wxEXPAND|wxALL, 5 );
m_CmdPanel->SetSizer( CmdMainSizer );
m_CmdPanel->Layout();
CmdMainSizer->FitInside( m_CmdPanel );
//
//
//
m_CmdListBox->Bind( wxEVT_LISTBOX, &guPrefDialog::OnCmdListBoxSelected, this );
m_CmdAddBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnCmdAddBtnClick, this );
m_CmdDelBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnCmdDelBtnClick, this );
m_CmdMoveUpBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnCmdMoveUpBtnClick, this );
m_CmdMoveDownBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnCmdMoveDownBtnClick, this );
m_CmdTextCtrl->Bind( wxEVT_TEXT, &guPrefDialog::OnCmdTextChanged, this );
m_CmdNameTextCtrl->Bind( wxEVT_TEXT, &guPrefDialog::OnCmdTextChanged, this );
m_CmdAcceptBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnCmdSaveBtnClick, this );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::BuildCopyToPage( void )
{
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_COPYTO )
return;
m_VisiblePanels |= guPREFERENCE_PAGE_FLAG_COPYTO;
//
// Copy To patterns
//
wxBoxSizer * CopyToMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer * CopyToLabelSizer = new wxStaticBoxSizer( new wxStaticBox( m_CopyPanel, wxID_ANY, _(" Patterns ") ), wxVERTICAL );
wxBoxSizer * CopyToListBoxSizer = new wxBoxSizer( wxHORIZONTAL );
m_CopyToListBox = new wxListBox( m_CopyPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
m_CopyToOptions = new guCopyToPatternArray();
wxArrayString Options = m_Config->ReadAStr( CONFIG_KEY_COPYTO_OPTION, wxEmptyString, CONFIG_PATH_COPYTO );
wxArrayString Names;
int Count = Options.Count();
if( Count )
{
for( int Index = 0; Index < Count; Index++ )
{
guCopyToPattern * CopyToPattern = new guCopyToPattern( Options[ Index ] );
if( CopyToPattern )
{
m_CopyToOptions->Add( CopyToPattern );
Names.Add( CopyToPattern->m_Name );
}
}
}
m_CopyToListBox->Append( Names );
CopyToListBoxSizer->Add( m_CopyToListBox, 1, wxALL|wxEXPAND, 5 );
wxBoxSizer * CopyToBtnSizer = new wxBoxSizer( wxVERTICAL );
m_CopyToAddBtn = new wxBitmapButton( m_CopyPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_add ), wxDefaultPosition, wxDefaultSize, 0 );
m_CopyToAddBtn->Enable( false );
CopyToBtnSizer->Add( m_CopyToAddBtn, 0, wxTOP|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_CopyToUpBtn = new wxBitmapButton( m_CopyPanel, wxID_ANY, guImage( guIMAGE_INDEX_up ), wxDefaultPosition, wxDefaultSize, 0 );
m_CopyToUpBtn->Enable( false );
CopyToBtnSizer->Add( m_CopyToUpBtn, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_CopyToDownBtn = new wxBitmapButton( m_CopyPanel, wxID_ANY, guImage( guIMAGE_INDEX_down ), wxDefaultPosition, wxDefaultSize, 0 );
m_CopyToDownBtn->Enable( false );
CopyToBtnSizer->Add( m_CopyToDownBtn, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_CopyToDelBtn = new wxBitmapButton( m_CopyPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_del ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_CopyToDelBtn->Enable( false );
CopyToBtnSizer->Add( m_CopyToDelBtn, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_CopyToAcceptBtn = new wxBitmapButton( m_CopyPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_accept ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_CopyToAcceptBtn->Enable( false );
CopyToBtnSizer->Add( m_CopyToAcceptBtn, 0, wxBOTTOM|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
CopyToListBoxSizer->Add( CopyToBtnSizer, 0, wxEXPAND, 5 );
CopyToLabelSizer->Add( CopyToListBoxSizer, 1, wxEXPAND, 5 );
wxBoxSizer* CopyToEditorSizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticBoxSizer * CopyToOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( m_CopyPanel, wxID_ANY, _(" Options ") ), wxHORIZONTAL );
wxFlexGridSizer * CopyToFieldsSizer = new wxFlexGridSizer( 2, 0, 0 );
CopyToFieldsSizer->AddGrowableCol( 1 );
CopyToFieldsSizer->SetFlexibleDirection( wxBOTH );
CopyToFieldsSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
wxStaticText * CopyToNameStaticText = new wxStaticText( m_CopyPanel, wxID_ANY, _( "Name:" ), wxDefaultPosition, wxDefaultSize, 0 );
CopyToNameStaticText->Wrap( -1 );
CopyToFieldsSizer->Add( CopyToNameStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxLEFT|wxRIGHT, 5 );
m_CopyToNameTextCtrl = new wxTextCtrl( m_CopyPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
CopyToFieldsSizer->Add( m_CopyToNameTextCtrl, 1, wxEXPAND|wxRIGHT, 5 );
wxStaticText * CopyToPatternStaticText = new wxStaticText( m_CopyPanel, wxID_ANY, _( "Pattern:" ), wxDefaultPosition, wxDefaultSize, 0 );
CopyToPatternStaticText->Wrap( -1 );
CopyToFieldsSizer->Add( CopyToPatternStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxLEFT|wxRIGHT, 5 );
m_CopyToPatternTextCtrl = new wxTextCtrl( m_CopyPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
CopyToFieldsSizer->Add( m_CopyToPatternTextCtrl, 1, wxEXPAND|wxRIGHT, 5 );
wxStaticText * CopyToFormatLabel = new wxStaticText( m_CopyPanel, wxID_ANY, _( "Format:" ), wxDefaultPosition, wxDefaultSize, 0 );
CopyToFormatLabel->Wrap( -1 );
CopyToFieldsSizer->Add( CopyToFormatLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxLEFT|wxRIGHT, 5 );
wxBoxSizer * CopyToFormatSizer;
CopyToFormatSizer = new wxBoxSizer( wxHORIZONTAL );
m_CopyToFormatChoice = new wxChoice( m_CopyPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, guTranscodeFormatStrings(), 0 );
m_CopyToFormatChoice->SetSelection( 0 );
CopyToFormatSizer->Add( m_CopyToFormatChoice, 1, wxEXPAND|wxRIGHT, 5 );
m_CopyToQualityChoice = new wxChoice( m_CopyPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, guTranscodeQualityStrings(), 0 );
m_CopyToQualityChoice->SetSelection( guTRANSCODE_QUALITY_KEEP );
m_CopyToQualityChoice->Enable( false );
CopyToFormatSizer->Add( m_CopyToQualityChoice, 1, wxEXPAND|wxRIGHT, 5 );
CopyToFieldsSizer->Add( CopyToFormatSizer, 1, wxEXPAND, 5 );
wxStaticText * CopyToPathStaticText = new wxStaticText( m_CopyPanel, wxID_ANY, _( "Path:" ), wxDefaultPosition, wxDefaultSize, 0 );
CopyToPathStaticText->Wrap( -1 );
CopyToFieldsSizer->Add( CopyToPathStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxLEFT|wxRIGHT, 5 );
wxBoxSizer * CopyToPathSizer = new wxBoxSizer( wxHORIZONTAL );
m_CopyToPathTextCtrl = new wxTextCtrl( m_CopyPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
CopyToPathSizer->Add( m_CopyToPathTextCtrl, 1, wxEXPAND, 5 );
m_CopyToPathBtn = new wxButton( m_CopyPanel, wxID_ANY, wxT( "..." ), wxDefaultPosition, wxSize( 28,-1 ), 0 );
CopyToPathSizer->Add( m_CopyToPathBtn, 0, wxRIGHT, 5 );
CopyToFieldsSizer->Add( CopyToPathSizer, 1, wxEXPAND, 5 );
CopyToFieldsSizer->Add( 0, 0, 0, wxEXPAND, 5 );
m_CopyToMoveFilesChkBox = new wxCheckBox( m_CopyPanel, wxID_ANY, _("Remove source files"), wxDefaultPosition, wxDefaultSize, 0 );
CopyToFieldsSizer->Add( m_CopyToMoveFilesChkBox, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
CopyToOptionsSizer->Add( CopyToFieldsSizer, 1, wxEXPAND, 5 );
CopyToEditorSizer->Add( CopyToOptionsSizer, 1, wxEXPAND, 5 );
// m_CopyToAcceptBtn = new wxBitmapButton( m_CopyPanel, wxID_ANY, guImage( guIMAGE_INDEX_tiny_accept ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
// m_CopyToAcceptBtn->Enable( false );
//
// CopyToEditorSizer->Add( m_CopyToAcceptBtn, 0, wxALL|wxALIGN_BOTTOM, 5 );
CopyToLabelSizer->Add( CopyToEditorSizer, 0, wxEXPAND, 5 );
CopyToMainSizer->Add( CopyToLabelSizer, 1, wxEXPAND|wxALL, 5 );
wxStaticBoxSizer* CopyToHelpSizer;
CopyToHelpSizer = new wxStaticBoxSizer( new wxStaticBox( m_CopyPanel, wxID_ANY, _(" Define patterns using ") ), wxHORIZONTAL );
wxStaticText * CopyToHelpText = new wxStaticText( m_CopyPanel, wxID_ANY, wxT( "{a}:\n{aa}:\n{A}:\n{b}:" ), wxDefaultPosition, wxDefaultSize, 0 );
CopyToHelpText->Wrap( -1 );
CopyToHelpSizer->Add( CopyToHelpText, 0, wxALL, 5 );
CopyToHelpText = new wxStaticText( m_CopyPanel, wxID_ANY, _( "Artist\nAlbum Artist\n{aa} or {a}\nAlbum" ), wxDefaultPosition, wxDefaultSize, 0 ); CopyToHelpText->Wrap( -1 );
CopyToHelpText->Wrap( -1 );
CopyToHelpSizer->Add( CopyToHelpText, 1, wxALL, 5 );
CopyToHelpText = new wxStaticText( m_CopyPanel, wxID_ANY, wxT( "{c}:\n{d}:\n{f}:\n{g}:" ), wxDefaultPosition, wxDefaultSize, 0 );
CopyToHelpText->Wrap( -1 );
CopyToHelpSizer->Add( CopyToHelpText, 0, wxALL, 5 );
CopyToHelpText = new wxStaticText( m_CopyPanel, wxID_ANY, _( "Composer\nDisk\nFilename\nGenre" ), wxDefaultPosition, wxDefaultSize, 0 );
CopyToHelpText->Wrap( -1 );
CopyToHelpSizer->Add( CopyToHelpText, 1, wxALL, 5 );
CopyToHelpText = new wxStaticText( m_CopyPanel, wxID_ANY, wxT( "{i}:\n{n}:\n{t}:\n{y}:" ), wxDefaultPosition, wxDefaultSize, 0 );
CopyToHelpText->Wrap( -1 );
CopyToHelpSizer->Add( CopyToHelpText, 0, wxALL, 5 );
CopyToHelpText = new wxStaticText( m_CopyPanel, wxID_ANY, _( "Index\nNumber\nTitle\nYear" ), wxDefaultPosition, wxDefaultSize, 0 );
CopyToHelpText->Wrap( -1 );
CopyToHelpSizer->Add( CopyToHelpText, 1, wxALL, 5 );
CopyToMainSizer->Add( CopyToHelpSizer, 0, wxEXPAND|wxALL, 5 );
m_CopyPanel->SetSizer( CopyToMainSizer );
m_CopyPanel->Layout();
CopyToMainSizer->FitInside( m_CopyPanel );
m_CopyToListBox->Bind( wxEVT_LISTBOX, &guPrefDialog::OnCopyToListBoxSelected, this );
m_CopyToAddBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnCopyToAddBtnClick, this );
m_CopyToDelBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnCopyToDelBtnClick, this );
m_CopyToUpBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnCopyToMoveUpBtnClick, this );
m_CopyToDownBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnCopyToMoveDownBtnClick, this );
m_CopyToPatternTextCtrl->Bind( wxEVT_TEXT, &guPrefDialog::OnCopyToTextChanged, this );
m_CopyToPathTextCtrl->Bind( wxEVT_TEXT, &guPrefDialog::OnCopyToTextChanged, this );
m_CopyToPathBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnCopyToPathBtnClick, this );
m_CopyToNameTextCtrl->Bind( wxEVT_TEXT, &guPrefDialog::OnCopyToTextChanged, this );
m_CopyToFormatChoice->Bind( wxEVT_CHOICE, &guPrefDialog::OnCopyToFormatChanged, this );
m_CopyToQualityChoice->Bind( wxEVT_CHOICE, &guPrefDialog::OnCopyToQualityChanged, this );
m_CopyToMoveFilesChkBox->Bind( wxEVT_CHECKBOX, &guPrefDialog::OnCopyToMoveFilesChanged, this );
m_CopyToAcceptBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnCopyToSaveBtnClick, this );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::BuildAcceleratorsPage( void )
{
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_ACCELERATORS )
return;
m_VisiblePanels |= guPREFERENCE_PAGE_FLAG_ACCELERATORS;
guAccelGetActionNames( m_AccelActionNames );
m_AccelKeys = m_Config->ReadANum( CONFIG_KEY_ACCELERATORS_ACCELKEY, 0, CONFIG_PATH_ACCELERATORS );
if( !m_AccelKeys.Count() )
{
guAccelGetDefaultKeys( m_AccelKeys );
}
while( m_AccelKeys.Count() < m_AccelActionNames.Count() )
m_AccelKeys.Add( 0 );
int Count = m_AccelActionNames.Count();
for( int Index = 0; Index < Count; Index++ )
{
m_AccelKeyNames.Add( guAccelGetKeyCodeString( m_AccelKeys[ Index ] ) );
}
//
// Accelerators Panel
//
wxBoxSizer * AccelMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer * AccelActionsSizer = new wxStaticBoxSizer( new wxStaticBox( m_AccelPanel, wxID_ANY, _(" Accelerators ") ), wxVERTICAL );
m_AccelListCtrl = new wxListCtrl( m_AccelPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxLC_SINGLE_SEL | wxLC_REPORT | wxLC_VRULES );
wxListItem AccelColumn;
AccelColumn.SetText( _( "Action" ) );
AccelColumn.SetImage( wxNOT_FOUND );
m_AccelListCtrl->InsertColumn( 0, AccelColumn );
AccelColumn.SetText( _( "Key" ) );
AccelColumn.SetAlign( wxLIST_FORMAT_RIGHT );
m_AccelListCtrl->InsertColumn( 1, AccelColumn );
m_AccelListCtrl->Hide();
wxColour EveBgColor = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX );
wxColour OddBgColor;
if( EveBgColor.Red() > 0x0A && EveBgColor.Green() > 0x0A && EveBgColor.Blue() > 0x0A )
{
OddBgColor.Set( EveBgColor.Red() - 0xA, EveBgColor.Green() - 0x0A, EveBgColor.Blue() - 0x0A );
}
else
{
OddBgColor.Set( EveBgColor.Red() + 0xA, EveBgColor.Green() + 0x0A, EveBgColor.Blue() + 0x0A );
}
for( int Index = 0; Index < Count; Index++ )
{
long NewItem = m_AccelListCtrl->InsertItem( Index, m_AccelActionNames[ Index ], 0 );
m_AccelListCtrl->SetItemData( NewItem, m_AccelKeys[ Index ] );
m_AccelListCtrl->SetItemBackgroundColour( NewItem, Index & 1 ? OddBgColor : EveBgColor );
m_AccelListCtrl->SetItem( NewItem, 1, m_AccelKeyNames[ Index ] );
}
m_AccelListCtrl->Show();
m_AccelListCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE );
m_AccelListCtrl->SetColumnWidth( 1, 200 );
AccelActionsSizer->Add( m_AccelListCtrl, 1, wxEXPAND|wxALL, 5 );
wxBoxSizer * AccelBtnSizer = new wxBoxSizer( wxVERTICAL );
m_AccelDefBtn = new wxButton( m_AccelPanel, wxID_ANY, _( "Default" ), wxDefaultPosition, wxDefaultSize, 0 );
AccelBtnSizer->Add( m_AccelDefBtn, 0, wxALIGN_RIGHT|wxRIGHT, 5 );
AccelActionsSizer->Add( AccelBtnSizer, 0, wxEXPAND, 5 );
AccelMainSizer->Add( AccelActionsSizer, 1, wxEXPAND|wxALL, 5 );
m_AccelPanel->SetSizer( AccelMainSizer );
m_AccelPanel->Layout();
m_AccelCurIndex = wxNOT_FOUND;
m_AccelItemNeedClear = false;
m_AccelListCtrl->Bind( wxEVT_LIST_ITEM_SELECTED, &guPrefDialog::OnAccelSelected, this );
m_AccelListCtrl->Bind( wxEVT_KEY_DOWN, &guPrefDialog::OnAccelKeyDown, this );
m_AccelDefBtn->Bind( wxEVT_BUTTON, &guPrefDialog::OnAccelDefaultClicked, this );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::SaveSettings( void )
{
m_Config = ( guConfig * ) guConfig::Get();
if( !m_Config )
guLogError( wxT( "Invalid m_Config object in preferences dialog" ) );
// Save all configurations
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_GENERAL )
{
m_Config->WriteNum( CONFIG_KEY_GENERAL_LANGUAGE, m_MainLangCodes[ m_MainLangChoice->GetSelection() ], CONFIG_PATH_GENERAL );
m_Config->WriteBool( CONFIG_KEY_GENERAL_SHOW_SPLASH_SCREEN, m_ShowSplashChkBox->GetValue(), CONFIG_PATH_GENERAL );
m_Config->WriteBool( CONFIG_KEY_GENERAL_START_MINIMIZED, m_MinStartChkBox->GetValue(), CONFIG_PATH_GENERAL );
m_Config->WriteBool( CONFIG_KEY_GENERAL_LOAD_DEFAULT_LAYOUTS, m_IgnoreLayoutsChkBox->GetValue(), CONFIG_PATH_GENERAL );
m_Config->WriteBool( CONFIG_KEY_GENERAL_SHOW_TASK_BAR_ICON, m_TaskIconChkBox->GetValue(), CONFIG_PATH_GENERAL );
m_Config->WriteBool( CONFIG_KEY_GENERAL_CLOSE_TO_TASKBAR, m_TaskIconChkBox->IsChecked() && m_CloseTaskBarChkBox->GetValue(), CONFIG_PATH_GENERAL );
if( m_SoundMenuChkBox )
m_Config->WriteBool( CONFIG_KEY_GENERAL_SOUND_MENU_INTEGRATE, m_SoundMenuChkBox->GetValue(), CONFIG_PATH_GENERAL );
m_Config->WriteBool( CONFIG_KEY_GENERAL_ACTION_ENQUEUE, m_EnqueueChkBox->GetValue(), CONFIG_PATH_GENERAL );
m_Config->WriteBool( CONFIG_KEY_GENERAL_DROP_FILES_CLEAR_PLAYLIST, m_DropFilesChkBox->GetValue(), CONFIG_PATH_GENERAL );
m_Config->WriteBool( CONFIG_KEY_GENERAL_INSTANT_TEXT_SEARCH, m_InstantSearchChkBox->GetValue(), CONFIG_PATH_GENERAL );
m_Config->WriteBool( CONFIG_KEY_GENERAL_TEXT_SEARCH_ENTER, m_EnterSearchChkBox->GetValue(), CONFIG_PATH_GENERAL );
m_Config->WriteNum( CONFIG_KEY_GENERAL_COVER_FRAME, m_ShowCDFrameChkBox->GetValue(), CONFIG_PATH_GENERAL );
m_Config->WriteBool( CONFIG_KEY_PLAYLIST_SAVE_ON_CLOSE, m_SavePlayListChkBox->GetValue(), CONFIG_PATH_PLAYLIST );
m_Config->WriteBool( CONFIG_KEY_GENERAL_SAVE_CURRENT_TRACK_POSITION, m_SavePosCheckBox->GetValue(), CONFIG_PATH_GENERAL );
m_Config->WriteNum( CONFIG_KEY_GENERAL_MIN_SAVE_PLAYL_POST_LENGTH, m_MinLenSpinCtrl->GetValue(), CONFIG_PATH_GENERAL );
m_Config->WriteBool( CONFIG_KEY_GENERAL_SHOW_CLOSE_CONFIRM, m_ExitConfirmChkBox->GetValue(), CONFIG_PATH_GENERAL );
}
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_LIBRARY )
{
guMediaCollectionArray OtherCollections;
m_Config->LoadCollections( &OtherCollections, guMEDIA_COLLECTION_TYPE_JAMENDO );
m_Config->LoadCollections( &OtherCollections, guMEDIA_COLLECTION_TYPE_MAGNATUNE );
m_Config->SaveCollections( &m_Collections );
m_Config->SaveCollections( &OtherCollections, false );
}
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_PLAYBACK )
{
m_Config->WriteBool( CONFIG_KEY_GENERAL_RANDOM_PLAY_ON_EMPTY_PLAYLIST, m_RndPlayChkBox->GetValue(), CONFIG_PATH_GENERAL );
m_Config->WriteNum( CONFIG_KEY_GENERAL_RANDOM_MODE_ON_EMPTY_PLAYLIST, m_RndModeChoice->GetSelection(), CONFIG_PATH_GENERAL );
m_Config->WriteBool( CONFIG_KEY_PLAYBACK_DEL_TRACKS_PLAYED, m_DelPlayChkBox->GetValue(), CONFIG_PATH_PLAYBACK );
m_Config->WriteNum( CONFIG_KEY_GENERAL_REPLAY_GAIN_MODE, m_PlayReplayModeChoice->GetSelection(), CONFIG_PATH_GENERAL );
m_Config->WriteNum( CONFIG_KEY_GENERAL_REPLAY_GAIN_PREAMP, m_PlayPreAmpLevelSlider->GetValue(), CONFIG_PATH_GENERAL );
m_Config->WriteBool( CONFIG_KEY_PLAYBCK_SILENCE_DETECTOR, m_PlayLevelEnabled->GetValue(), CONFIG_PATH_PLAYBACK );
m_Config->WriteNum( CONFIG_KEY_PLAYBCK_SILENCE_LEVEL, m_PlayLevelSlider->GetValue(), CONFIG_PATH_PLAYBACK );
m_Config->WriteBool( CONFIG_KEY_PLAYBCK_SILENCE_AT_END, m_PlayEndTimeCheckBox->GetValue(), CONFIG_PATH_PLAYBACK );
m_Config->WriteNum( CONFIG_KEY_PLAYBCK_SILENCE_END_TIME, m_PlayEndTimeSpinCtrl->GetValue(), CONFIG_PATH_PLAYBACK );
m_Config->WriteBool( CONFIG_KEY_GENERAL_SHOW_NOTIFICATIONS, m_NotifyChkBox->GetValue(), CONFIG_PATH_GENERAL );
m_Config->WriteBool( CONFIG_KEY_GENERAL_EQ_ENABLED, m_EqOnChkBox->GetValue(), CONFIG_PATH_GENERAL );
m_Config->WriteBool( CONFIG_KEY_GENERAL_VOLUME_ENABLED, m_VolOnChkBox->GetValue(), CONFIG_PATH_GENERAL );
m_Config->WriteNum( CONFIG_KEY_PLAYBACK_MIN_TRACKS_PLAY, m_MinTracksSpinCtrl->GetValue(), CONFIG_PATH_PLAYBACK );
m_Config->WriteNum( CONFIG_KEY_PLAYBACK_NUM_TRACKS_TO_ADD, m_NumTracksSpinCtrl->GetValue(), CONFIG_PATH_PLAYBACK );
m_Config->WriteNum( CONFIG_KEY_PLAYBACK_MAX_TRACKS_PLAYED, m_MaxTracksPlayed->GetValue(), CONFIG_PATH_PLAYBACK );
m_Config->WriteNum( CONFIG_KEY_PLAYBACK_SMART_FILTER_ARTISTS, m_SmartPlayArtistsSpinCtrl->GetValue(), CONFIG_PATH_PLAYBACK );
m_Config->WriteNum( CONFIG_KEY_PLAYBACK_SMART_FILTER_TRACKS, m_SmartPlayTracksSpinCtrl->GetValue(), CONFIG_PATH_PLAYBACK );
m_Config->WriteNum( CONFIG_KEY_PLAYBACK_OUTPUT_DEVICE, m_PlayOutDevChoice->GetSelection(), CONFIG_PATH_PLAYBACK );
m_Config->WriteStr( CONFIG_KEY_PLAYBACK_OUTPUT_DEVICE_NAME, m_PlayOutDevName->GetValue(), CONFIG_PATH_PLAYBACK );
}
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_CROSSFADER )
{
m_Config->WriteNum( CONFIG_KEY_CROSSFADER_FADEOUT_TIME, m_XFadeOutLenSlider->GetValue(), CONFIG_PATH_CROSSFADER );
m_Config->WriteNum( CONFIG_KEY_CROSSFADER_FADEIN_TIME, m_XFadeInLenSlider->GetValue(), CONFIG_PATH_CROSSFADER );
m_Config->WriteNum( CONFIG_KEY_CROSSFADER_FADEIN_VOL_START, m_XFadeInStartSlider->GetValue(), CONFIG_PATH_CROSSFADER );
m_Config->WriteNum( CONFIG_KEY_CROSSFADER_FADEIN_VOL_TRIGER, m_XFadeInTrigerSlider->GetValue(), CONFIG_PATH_CROSSFADER );
}
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_AUDIOSCROBBLE )
{
m_Config->WriteBool( CONFIG_KEY_LASTFM_ENABLED, m_LastFMASEnableChkBox->IsEnabled() && m_LastFMASEnableChkBox->GetValue(), CONFIG_PATH_LASTFM );
m_Config->WriteStr( CONFIG_KEY_LASTFM_USERNAME, m_LastFMUserNameTextCtrl->GetValue(), CONFIG_PATH_LASTFM );
if( !m_LastFMPasswdTextCtrl->IsEmpty() && m_LastFMPasswdTextCtrl->GetValue() != wxT( "******" ) )
{
guMD5 MD5;
m_Config->WriteStr( CONFIG_KEY_LASTFM_PASSWORD, MD5.MD5( m_LastFMPasswdTextCtrl->GetValue() ), CONFIG_PATH_LASTFM );
//guLogMessage( wxT( "Pass: %s" ), PasswdTextCtrl->GetValue().c_str() );
//guLogMessage( wxT( "MD5 : %s" ), MD5.MD5( PasswdTextCtrl->GetValue() ).c_str() );
}
m_Config->WriteBool( CONFIG_KEY_LIBREFM_ENABLED, m_LibreFMASEnableChkBox->IsEnabled() && m_LibreFMASEnableChkBox->GetValue(), CONFIG_PATH_LIBREFM );
m_Config->WriteStr( CONFIG_KEY_LIBREFM_USERNAME, m_LibreFMUserNameTextCtrl->GetValue(), CONFIG_PATH_LIBREFM );
if( !m_LibreFMPasswdTextCtrl->IsEmpty() && m_LibreFMPasswdTextCtrl->GetValue() != wxT( "******" ) )
{
guMD5 MD5;
m_Config->WriteStr( CONFIG_KEY_LIBREFM_PASSWORD, MD5.MD5( m_LibreFMPasswdTextCtrl->GetValue() ), CONFIG_PATH_LIBREFM );
}
}
// LastFM Panel Info language
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_ONLINE )
{
m_Config->WriteStr( CONFIG_KEY_LASTFM_LANGUAGE, m_LFMLangIds[ m_LangChoice->GetSelection() ], CONFIG_PATH_LASTFM );
m_Config->WriteAStr( CONFIG_KEY_SEARCH_FILTERS_FILTER, m_OnlineFiltersListBox->GetStrings(), CONFIG_PATH_SEARCH_FILTERS );
m_Config->WriteStr( CONFIG_KEY_GENERAL_BROWSER_COMMAND, m_BrowserCmdTextCtrl->GetValue(), CONFIG_PATH_GENERAL );
m_Config->WriteNum( CONFIG_KEY_RADIOS_MIN_BITRATE, m_RadioMinBitRateSlider->GetValue(), CONFIG_PATH_RADIOS );
m_Config->WriteNum( CONFIG_KEY_GENERAL_BUFFER_SIZE, m_BufferSizeSlider->GetValue(), CONFIG_PATH_GENERAL );
m_Config->WriteBool( CONFIG_KEY_PROXY_ENABLED, m_OnlineProxyEnableChkBox->GetValue(), CONFIG_PATH_PROXY );
m_Config->WriteStr( CONFIG_KEY_PROXY_HOSTNAME, m_OnlineProxyHostTextCtrl->GetValue(), CONFIG_PATH_PROXY );
m_Config->WriteStr( CONFIG_KEY_PROXY_PORT, m_OnlineProxyPortTextCtrl->GetValue(), CONFIG_PATH_PROXY );
m_Config->WriteStr( CONFIG_KEY_PROXY_USERNAME, m_OnlineProxyUserTextCtrl->GetValue(), CONFIG_PATH_PROXY );
m_Config->WriteStr( CONFIG_KEY_PROXY_PASSWORD, m_OnlineProxyPasswdTextCtrl->GetValue(), CONFIG_PATH_PROXY );
}
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_RECORD )
{
m_Config->WriteBool( CONFIG_KEY_RECORD_ENABLED, m_RecordChkBox->GetValue(), CONFIG_PATH_RECORD );
m_Config->WriteStr( CONFIG_KEY_RECORD_PATH, m_RecSelDirPicker->GetPath(), CONFIG_PATH_RECORD );
m_Config->WriteNum( CONFIG_KEY_RECORD_FORMAT, m_RecFormatChoice->GetSelection(), CONFIG_PATH_RECORD );
m_Config->WriteNum( CONFIG_KEY_RECORD_QUALITY, m_RecQualityChoice->GetSelection(), CONFIG_PATH_RECORD );
m_Config->WriteBool( CONFIG_KEY_RECORD_SPLIT, m_RecSplitChkBox->GetValue(), CONFIG_PATH_RECORD );
m_Config->WriteBool( CONFIG_KEY_RECORD_DELETE, m_RecDelTracks->GetValue(), CONFIG_PATH_RECORD );
m_Config->WriteNum( CONFIG_KEY_RECORD_DELETE_TIME, m_RecDelTime->GetValue(), CONFIG_PATH_RECORD );
}
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_PODCASTS )
{
m_Config->WriteStr( CONFIG_KEY_PODCASTS_PATH, m_PodcastPath->GetPath(), CONFIG_PATH_PODCASTS );
m_Config->WriteBool( CONFIG_KEY_PODCASTS_UPDATE, m_PodcastUpdate->GetValue(), CONFIG_PATH_PODCASTS );
m_Config->WriteNum( CONFIG_KEY_PODCASTS_UPDATEPERIOD, m_PodcastUpdatePeriod->GetSelection(), CONFIG_PATH_PODCASTS );
m_Config->WriteBool( CONFIG_KEY_PODCASTS_DELETE, m_PodcastDelete->GetValue(), CONFIG_PATH_PODCASTS );
m_Config->WriteNum( CONFIG_KEY_PODCASTS_DELETETIME, m_PodcastDeleteTime->GetValue(), CONFIG_PATH_PODCASTS );
m_Config->WriteNum( CONFIG_KEY_PODCASTS_DELETEPERIOD, m_PodcastDeletePeriod->GetSelection(), CONFIG_PATH_PODCASTS );
m_Config->WriteBool( CONFIG_KEY_PODCASTS_DELETEPLAYED, m_PodcastDeletePlayed->GetValue(), CONFIG_PATH_PODCASTS );
}
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_LYRICS )
{
m_LyricSearchEngine->Save();
m_Config->WriteStr( CONFIG_KEY_LYRICS_FONT, m_LyricFontPicker->GetSelectedFont().GetNativeFontInfoDesc(), CONFIG_PATH_LYRICS );
m_Config->WriteNum( CONFIG_KEY_LYRICS_TEXT_ALIGN, m_LyricsAlignChoice->GetSelection(), CONFIG_PATH_LYRICS );
m_Config->WriteAStr( CONFIG_KEY_LYRICS_DISGENRE, m_LyricDisabledGenres, CONFIG_PATH_LYRICS_DISGENRES );
}
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_JAMENDO )
{
wxArrayInt EnabledGenres;
int Count = m_JamGenresListBox->GetCount();
for( int Index = 0; Index < Count; Index++ )
{
if( m_JamGenresListBox->IsChecked( Index ) )
EnabledGenres.Add( Index );
}
m_Config->WriteANum( CONFIG_KEY_JAMENDO_GENRES_GENRE, EnabledGenres, CONFIG_PATH_JAMENDO_GENRES );
bool DoUpgrade = ( EnabledGenres.Count() != m_LastJamendoGenres.Count() );
if( !DoUpgrade )
{
int Count = EnabledGenres.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( m_LastJamendoGenres.Index( EnabledGenres[ Index ] ) == wxNOT_FOUND )
{
DoUpgrade = true;
break;
}
}
}
m_Config->WriteBool( CONFIG_KEY_JAMENDO_NEED_UPGRADE, DoUpgrade, CONFIG_PATH_JAMENDO );
m_Config->WriteNum( CONFIG_KEY_JAMENDO_AUDIOFORMAT, m_JamFormatChoice->GetSelection(), CONFIG_PATH_JAMENDO );
m_Config->WriteStr( CONFIG_KEY_JAMENDO_TORRENT_COMMAND, m_JamBTCmd->GetValue(), CONFIG_PATH_JAMENDO );
}
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_MAGNATUNE )
{
wxArrayString EnabledGenres;
int Count = m_MagGenresListBox->GetCount();
for( int Index = 0; Index < Count; Index++ )
{
if( m_MagGenresListBox->IsChecked( Index ) )
EnabledGenres.Add( m_MagGenresListBox->GetString( Index ) );
}
m_Config->WriteAStr( CONFIG_KEY_MAGNATUNE_GENRES_GENRE, EnabledGenres, CONFIG_PATH_MAGNATUNE_GENRES );
bool DoUpgrade = ( EnabledGenres.Count() != m_LastMagnatuneGenres.Count() );
if( !DoUpgrade )
{
int Count = EnabledGenres.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( m_LastMagnatuneGenres.Index( EnabledGenres[ Index ] ) == wxNOT_FOUND )
{
DoUpgrade = true;
break;
}
}
}
m_Config->WriteBool( CONFIG_KEY_MAGNATUNE_NEED_UPGRADE, DoUpgrade, CONFIG_PATH_MAGNATUNE );
if( m_MagNoRadioItem->GetValue() )
m_Config->WriteNum( CONFIG_KEY_MAGNATUNE_MEMBERSHIP, 0, CONFIG_PATH_MAGNATUNE );
else if( m_MagStRadioItem->GetValue() )
m_Config->WriteNum( CONFIG_KEY_MAGNATUNE_MEMBERSHIP, 1, CONFIG_PATH_MAGNATUNE );
else
m_Config->WriteNum( CONFIG_KEY_MAGNATUNE_MEMBERSHIP, 2, CONFIG_PATH_MAGNATUNE );
m_Config->WriteStr( CONFIG_KEY_MAGNATUNE_USERNAME, m_MagUserTextCtrl->GetValue(), CONFIG_PATH_MAGNATUNE );
m_Config->WriteStr( CONFIG_KEY_MAGNATUNE_PASSWORD, m_MagPassTextCtrl->GetValue(), CONFIG_PATH_MAGNATUNE );
m_Config->WriteNum( CONFIG_KEY_MAGNATUNE_AUDIO_FORMAT, m_MagFormatChoice->GetSelection(), CONFIG_PATH_MAGNATUNE );
m_Config->WriteNum( CONFIG_KEY_MAGNATUNE_DOWNLOAD_FORMAT, m_MagDownFormatChoice->GetSelection(), CONFIG_PATH_MAGNATUNE );
}
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_LINKS )
{
wxArrayString SearchLinks = m_LinksListBox->GetStrings();
m_Config->WriteAStr( CONFIG_KEY_SEARCHLINKS_LINK, SearchLinks, CONFIG_PATH_SEARCHLINKS_LINKS );
m_Config->WriteAStr( CONFIG_KEY_SEARCHLINKS_NAME, m_LinksNames, CONFIG_PATH_SEARCHLINKS_NAMES, false );
// TODO : Make this process in a thread
int count = SearchLinks.Count();
for( int index = 0; index < count; index++ )
{
wxURI Uri( SearchLinks[ index ] );
if( !wxDirExists( guPATH_LINKICONS ) )
{
wxMkdir( guPATH_LINKICONS, 0770 );
}
wxString IconFile = guPATH_LINKICONS + Uri.GetServer() + wxT( ".ico" );
if( !wxFileExists( IconFile ) )
{
if( DownloadFile( Uri.GetServer() + wxT( "/favicon.ico" ), IconFile ) )
{
wxImage Image( IconFile, wxBITMAP_TYPE_ANY );
if( Image.IsOk() )
{
if( Image.GetWidth() > 25 || Image.GetHeight() > 25 )
{
Image.Rescale( 25, 25, wxIMAGE_QUALITY_HIGH );
}
if( Image.IsOk() )
{
Image.SaveFile( IconFile, wxBITMAP_TYPE_ICO );
}
}
}
else
{
guLogError( wxT( "Coult not get the icon from SearchLink server '%s'" ), Uri.GetServer().c_str() );
}
}
}
}
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_COMMANDS )
{
wxArrayString Commands = m_CmdListBox->GetStrings();
m_Config->WriteAStr( CONFIG_KEY_COMMANDS_EXEC, Commands, CONFIG_PATH_COMMANDS_EXECS );
m_Config->WriteAStr( CONFIG_KEY_COMMANDS_NAME, m_CmdNames, CONFIG_PATH_COMMANDS_NAMES );
}
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_COPYTO )
{
wxArrayString Options;
int Count = m_CopyToOptions->Count();
for( int Index = 0; Index < Count; Index++ )
{
guCopyToPattern &CopyToPattern = m_CopyToOptions->Item( Index );
Options.Add( CopyToPattern.ToString() );
}
m_Config->WriteAStr( CONFIG_KEY_COPYTO_OPTION, Options, CONFIG_PATH_COPYTO );
}
if( m_VisiblePanels & guPREFERENCE_PAGE_FLAG_ACCELERATORS )
{
m_Config->WriteANum( CONFIG_KEY_ACCELERATORS_ACCELKEY, m_AccelKeys, CONFIG_PATH_ACCELERATORS );
}
m_Config->Flush();
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnActivateTaskBarIcon( wxCommandEvent& event )
{
if( m_SoundMenuChkBox )
m_SoundMenuChkBox->Enable( m_TaskIconChkBox->IsChecked() );
m_CloseTaskBarChkBox->Enable( m_TaskIconChkBox->IsChecked() && ( !m_SoundMenuChkBox || !m_SoundMenuChkBox->IsChecked() ) );
m_ExitConfirmChkBox->Enable( !m_SoundMenuChkBox || !m_SoundMenuChkBox->IsEnabled() || !m_SoundMenuChkBox->IsChecked() );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnActivateSoundMenuIntegration( wxCommandEvent& event )
{
m_CloseTaskBarChkBox->Enable( m_TaskIconChkBox->IsChecked() && !m_SoundMenuChkBox->IsChecked() );
m_ExitConfirmChkBox->Enable( !m_SoundMenuChkBox->IsEnabled() || !m_SoundMenuChkBox->IsChecked() );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnActivateInstantSearch( wxCommandEvent& event )
{
m_EnterSearchChkBox->Enable( m_InstantSearchChkBox->IsChecked() );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnRndPlayClicked( wxCommandEvent& event )
{
m_RndModeChoice->Enable( m_RndPlayChkBox->IsChecked() );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnDelPlayedTracksChecked( wxCommandEvent& event )
{
m_MaxTracksPlayed->Enable( !m_DelPlayChkBox->IsChecked() );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibOptionsLoadControls( void )
{
bool CollectSelected = ( m_CollectSelected != wxNOT_FOUND ) &&
( m_Collections[ m_CollectSelected ].m_Type == guMEDIA_COLLECTION_TYPE_NORMAL );
m_PathSelected = wxNOT_FOUND;
m_CoverSelected = wxNOT_FOUND;
m_LibPathListBox->Clear();
m_LibCoverListBox->Clear();
if( CollectSelected )
{
guMediaCollection &CurCollection = m_Collections[ m_CollectSelected ];
int Count = CurCollection.m_Paths.Count();
for( int Index = 0; Index < Count; Index++ )
{
m_LibPathListBox->Append( CurCollection.m_Paths[ Index ] );
}
Count = CurCollection.m_CoverWords.Count();
for( int Index = 0; Index < Count; Index++ )
{
m_LibCoverListBox->Append( CurCollection.m_CoverWords[ Index ] );
}
m_LibOptAutoUpdateChkBox->SetValue( CurCollection.m_UpdateOnStart );
m_LibOptCreatePlayListChkBox->SetValue( CurCollection.m_ScanPlaylists );
m_LibOptFollowLinksChkBox->SetValue( CurCollection.m_ScanFollowSymLinks );
m_LibOptCheckEmbeddedChkBox->SetValue( CurCollection.m_ScanEmbeddedCovers );
m_LibOptEmbedTagsChkBox->SetValue( CurCollection.m_EmbeddMetadata );
if( !m_LibOptCopyToChoice->SetStringSelection( CurCollection.m_DefaultCopyAction ) )
m_LibOptCopyToChoice->SetSelection( 0 );
}
m_LibCollectUpBtn->Enable( m_CollectSelected > 0 );
m_LibCollectDownBtn->Enable( m_CollectSelected != wxNOT_FOUND && ( m_CollectSelected < int( m_Collections.Count() - 1 ) ) );
m_LibCollectDelBtn->Enable( m_CollectSelected != wxNOT_FOUND && ( m_Collections.Count() > 1 ) );
//
m_LibPathListBox->Enable( CollectSelected );
m_LibOptAddPathBtn->Enable( CollectSelected );
m_LibOptDelPathBtn->Enable( CollectSelected && ( m_PathSelected != wxNOT_FOUND ) );
m_LibCoverListBox->Enable( CollectSelected );
m_LibOptAddCoverBtn->Enable( CollectSelected );
m_LibOptUpCoverBtn->Enable( CollectSelected && ( m_CoverSelected != wxNOT_FOUND ) );
m_LibOptDownCoverBtn->Enable( CollectSelected && ( m_CoverSelected != wxNOT_FOUND ) );
m_LibOptDelCoverBtn->Enable( CollectSelected && ( m_CoverSelected != wxNOT_FOUND ) );
m_LibOptAutoUpdateChkBox->Enable( CollectSelected );
m_LibOptCreatePlayListChkBox->Enable( CollectSelected );
m_LibOptFollowLinksChkBox->Enable( CollectSelected );
m_LibOptCheckEmbeddedChkBox->Enable( CollectSelected );
m_LibOptEmbedTagsChkBox->Enable( CollectSelected );
m_LibOptCopyToChoice->Enable( CollectSelected );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibCollectSelected( wxCommandEvent& event )
{
m_CollectSelected = event.GetInt();
guLogMessage( wxT( "guPrefDialog::OnLibCollectSelected( %i )" ), m_CollectSelected );
OnLibOptionsLoadControls();
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibCollectDClicked( wxCommandEvent& event )
{
int CollectIndex = event.GetInt();
if( CollectIndex != wxNOT_FOUND &&
( m_Collections[ CollectIndex ].m_Type == guMEDIA_COLLECTION_TYPE_NORMAL ) )
{
wxTextEntryDialog * EntryDialog = new wxTextEntryDialog( this, _( "Collection: " ), _( "Enter the collection name" ), m_LibCollectListBox->GetString( CollectIndex ) );
if( EntryDialog )
{
if( EntryDialog->ShowModal() == wxID_OK )
{
wxString NewName = EntryDialog->GetValue();
if( m_LibCollectListBox->FindString( NewName ) == wxNOT_FOUND )
{
m_LibCollectListBox->SetString( CollectIndex, NewName );
m_Collections[ m_CollectSelected ].m_Name = NewName;
}
}
EntryDialog->Destroy();
}
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibAddCollectClick( wxCommandEvent& event )
{
wxTextEntryDialog * EntryDialog = new wxTextEntryDialog( this, _( "Collection: " ), _( "Enter the collection name" ), wxEmptyString );
if( EntryDialog )
{
if( EntryDialog->ShowModal() == wxID_OK )
{
wxString NewName = EntryDialog->GetValue();
if( !NewName.IsEmpty() && ( m_LibCollectListBox->FindString( NewName ) == wxNOT_FOUND ) )
{
m_LibCollectListBox->Append( NewName );
guMediaCollection * Collection = new guMediaCollection();
Collection->m_Name = NewName;
if( m_Collections.Count() )
{
Collection->m_CoverWords = m_Collections[ 0 ].m_CoverWords;
}
else
{
Collection->m_CoverWords.Add( wxT( "cover" ) );
Collection->m_CoverWords.Add( wxT( "front" ) );
Collection->m_CoverWords.Add( wxT( "folder" ) );
}
Collection->m_UpdateOnStart = false;
Collection->m_ScanPlaylists = true;
Collection->m_ScanFollowSymLinks = false;
Collection->m_ScanEmbeddedCovers = true;
Collection->m_EmbeddMetadata = false;
Collection->m_LastUpdate = wxNOT_FOUND;
m_Collections.Add( Collection );
m_CollectSelected = m_LibCollectListBox->GetCount() - 1;
m_LibCollectListBox->SetSelection( m_CollectSelected );
OnLibOptionsLoadControls();
}
}
EntryDialog->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibUpCollectClick( wxCommandEvent& event )
{
wxString SavedLabel = m_LibCollectListBox->GetString( m_CollectSelected );
guMediaCollection * SavedCollection = m_Collections.Detach( m_CollectSelected );
m_LibCollectListBox->SetString( m_CollectSelected, m_LibCollectListBox->GetString( m_CollectSelected - 1 ) );
m_CollectSelected--;
m_LibCollectListBox->SetString( m_CollectSelected, SavedLabel );
m_Collections.Insert( SavedCollection, m_CollectSelected );
m_LibCollectListBox->SetSelection( m_CollectSelected );
event.SetInt( m_CollectSelected );
OnLibCollectSelected( event );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibDownCollectClick( wxCommandEvent& event )
{
wxString SavedLabel = m_LibCollectListBox->GetString( m_CollectSelected );
guMediaCollection * SavedCollection = m_Collections.Detach( m_CollectSelected );
m_LibCollectListBox->SetString( m_CollectSelected, m_LibCollectListBox->GetString( m_CollectSelected + 1 ) );
m_CollectSelected++;
m_LibCollectListBox->SetString( m_CollectSelected, SavedLabel );
m_Collections.Insert( SavedCollection, m_CollectSelected );
m_LibCollectListBox->SetSelection( m_CollectSelected );
event.SetInt( m_CollectSelected );
OnLibCollectSelected( event );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibDelCollectClick( wxCommandEvent& event )
{
if( m_CollectSelected != wxNOT_FOUND )
{
if( !guRemoveDir( guPATH_COLLECTIONS + m_Collections[ m_CollectSelected ].m_UniqueId ) )
guLogMessage( wxT( "Could not delete the collection folder '%s'" ), m_Collections[ m_CollectSelected ].m_UniqueId.c_str() );
m_Collections.RemoveAt( m_CollectSelected );
m_LibCollectListBox->Delete( m_CollectSelected );
m_CollectSelected = wxNOT_FOUND;
m_LibCollectListBox->SetSelection( m_CollectSelected );
event.SetInt( m_CollectSelected );
OnLibCollectSelected( event );
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibPathSelected( wxCommandEvent& event )
{
m_PathSelected = event.GetInt();
guLogMessage( wxT( "guPrefDialog::OnLibPathSelected( %i )" ), m_PathSelected );
m_LibOptDelPathBtn->Enable( ( m_CollectSelected != wxNOT_FOUND ) &&
( m_PathSelected != wxNOT_FOUND ) );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibPathDClicked( wxCommandEvent& event )
{
int PathIndex = event.GetInt();
guLogMessage( wxT( "guPrefDialog::OnLibPathDClicked( %i )" ), PathIndex );
if( PathIndex != wxNOT_FOUND )
{
wxDirDialog * DirDialog = new wxDirDialog( this, _( "Change library path" ), m_LibPathListBox->GetString( PathIndex ) );
if( DirDialog )
{
if( DirDialog->ShowModal() == wxID_OK )
{
wxString NewPath = DirDialog->GetPath();
if( m_LibPathListBox->FindString( NewPath, true ) == wxNOT_FOUND )
{
m_LibPathListBox->SetString( PathIndex, NewPath + wxT( "/" ) );
m_Collections[ m_CollectSelected ].m_Paths[ PathIndex ] = NewPath + wxT( "/" );
m_LibPathsChanged = true;
}
}
DirDialog->Destroy();
}
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibAddPathBtnClick( wxCommandEvent& event )
{
guLogMessage( wxT( "guPrefDialog::OnLibAddPathBtnClick( %i )" ), m_PathSelected );
wxDirDialog * DirDialog = new wxDirDialog( this, _( "Select library path" ), wxGetHomeDir() );
if( DirDialog )
{
if( DirDialog->ShowModal() == wxID_OK )
{
wxString NewPath = DirDialog->GetPath();
if( m_LibPathListBox->FindString( NewPath, true ) == wxNOT_FOUND )
{
m_LibPathListBox->Append( NewPath + wxT( "/" ) );
m_Collections[ m_CollectSelected ].m_Paths.Add( NewPath + wxT( "/" ) );
m_LibPathsChanged = true;
}
}
DirDialog->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibDelPathBtnClick( wxCommandEvent& event )
{
guLogMessage( wxT( "guPrefDialog::OnLibDelPathBtnClick( %i )" ), m_CoverSelected );
if( m_PathSelected != wxNOT_FOUND )
{
m_Collections[ m_CollectSelected ].m_Paths.RemoveAt( m_PathSelected );
m_LibPathListBox->Delete( m_PathSelected );
//m_PathSelected = wxNOT_FOUND;
m_LibPathsChanged = true;
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibCoverSelected( wxCommandEvent& event )
{
m_CoverSelected = event.GetInt();
guLogMessage( wxT( "guPrefDialog::OnLibCoverSelected( %i )" ), m_CoverSelected );
if( m_CoverSelected != wxNOT_FOUND )
{
m_LibOptUpCoverBtn->Enable( m_CoverSelected > 0 );
m_LibOptDownCoverBtn->Enable( m_CoverSelected < int( m_LibCoverListBox->GetCount() - 1 ) );
m_LibOptDelCoverBtn->Enable();
}
else
{
m_LibOptUpCoverBtn->Disable();
m_LibOptDownCoverBtn->Disable();
m_LibOptDelCoverBtn->Disable();
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibCoverDClicked( wxCommandEvent& event )
{
int CoverIndex = event.GetInt();
guLogMessage( wxT( "guPrefDialog::OnLibCoverDClicked( %i )" ), CoverIndex );
if( CoverIndex != wxNOT_FOUND )
{
wxTextEntryDialog * EntryDialog = new wxTextEntryDialog( this, _( "Word: " ), _( "Enter the text to find covers" ), m_LibCoverListBox->GetString( CoverIndex ) );
if( EntryDialog )
{
if( EntryDialog->ShowModal() == wxID_OK )
{
wxString NewWord = EntryDialog->GetValue().Lower();
if( m_LibCoverListBox->FindString( NewWord ) == wxNOT_FOUND )
{
m_LibCoverListBox->SetString( CoverIndex, NewWord );
m_Collections[ m_CollectSelected ].m_CoverWords[ CoverIndex ] = NewWord;
}
}
EntryDialog->Destroy();
}
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibAddCoverBtnClick( wxCommandEvent& event )
{
wxTextEntryDialog * EntryDialog = new wxTextEntryDialog( this, _( "Word: " ), _( "Enter the text to find covers" ), wxEmptyString );
if( EntryDialog )
{
if( EntryDialog->ShowModal() == wxID_OK )
{
wxString NewWord = EntryDialog->GetValue().Lower();
if( m_LibCoverListBox->FindString( NewWord ) == wxNOT_FOUND )
{
m_LibCoverListBox->Append( NewWord );
m_Collections[ m_CollectSelected ].m_CoverWords.Add( NewWord );
}
}
EntryDialog->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibUpCoverBtnClick( wxCommandEvent& event )
{
wxString CoverWord = m_LibCoverListBox->GetString( m_CoverSelected );
m_LibCoverListBox->SetString( m_CoverSelected, m_LibCoverListBox->GetString( m_CoverSelected - 1 ) );
guMediaCollection &Collection = m_Collections[ m_CollectSelected ];
Collection.m_CoverWords[ m_CoverSelected ] = Collection.m_CoverWords[ m_CoverSelected - 1 ];
m_CoverSelected--;
m_LibCoverListBox->SetString( m_CoverSelected, CoverWord );
Collection.m_CoverWords[ m_CoverSelected ] = CoverWord;
m_LibCoverListBox->SetSelection( m_CoverSelected );
event.SetInt( m_CoverSelected );
OnLibCoverSelected( event );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibDownCoverBtnClick( wxCommandEvent& event )
{
wxString CoverWord = m_LibCoverListBox->GetString( m_CoverSelected );
m_LibCoverListBox->SetString( m_CoverSelected, m_LibCoverListBox->GetString( m_CoverSelected + 1 ) );
guMediaCollection &Collection = m_Collections[ m_CollectSelected ];
Collection.m_CoverWords[ m_CoverSelected ] = Collection.m_CoverWords[ m_CoverSelected + 1 ];
m_CoverSelected++;
m_LibCoverListBox->SetString( m_CoverSelected, CoverWord );
Collection.m_CoverWords[ m_CoverSelected ] = CoverWord;
m_LibCoverListBox->SetSelection( m_CoverSelected );
event.SetInt( m_CoverSelected );
OnLibCoverSelected( event );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibDelCoverBtnClick( wxCommandEvent& event )
{
if( m_CoverSelected != wxNOT_FOUND )
{
m_Collections[ m_CollectSelected ].m_CoverWords.RemoveAt( m_CoverSelected );
m_LibCoverListBox->Delete( m_CoverSelected );
//m_CoverSelected = wxNOT_FOUND;
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibAutoUpdateChanged( wxCommandEvent& event )
{
m_Collections[ m_CollectSelected ].m_UpdateOnStart = event.IsChecked();
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibCreatePlayListsChanged( wxCommandEvent& event )
{
m_Collections[ m_CollectSelected ].m_ScanPlaylists = event.IsChecked();
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibFollowSymLinksChanged( wxCommandEvent& event )
{
m_Collections[ m_CollectSelected ].m_ScanFollowSymLinks = event.IsChecked();
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibCheckEmbeddedChanged( wxCommandEvent& event )
{
m_Collections[ m_CollectSelected ].m_ScanEmbeddedCovers = event.IsChecked();
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibEmbeddMetadataChanged( wxCommandEvent& event )
{
m_Collections[ m_CollectSelected ].m_EmbeddMetadata = event.IsChecked();
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibDefaultCopyToChanged( wxCommandEvent& event )
{
// guLogMessage( wxT( "Selected: %i" ), event.GetInt() );
m_Collections[ m_CollectSelected ].m_DefaultCopyAction = m_LibOptCopyToChoice->GetString( event.GetInt() );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLyricSourceSelected( wxCommandEvent &event )
{
//guLogMessage( wxT( "Selected %i" ), event.GetInt() );
m_LyricSourceSelected = event.GetInt();
m_LyricsUpButton->Enable( m_LyricSourceSelected > 0 );
m_LyricsDownButton->Enable( m_LyricSourceSelected >= 0 && ( m_LyricSourceSelected < ( ( int ) m_LyricSearchEngine->SourcesCount() - 1 ) ) );
m_LyricsDelButton->Enable( m_LyricSourceSelected != wxNOT_FOUND );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLyricSourceDClicked( wxCommandEvent &event )
{
guLyricSource * CurrentLyricSource = m_LyricSearchEngine->GetSource( m_LyricSourceSelected );
guLyricSourceEditor * LyricSourceEditor = new guLyricSourceEditor( this, CurrentLyricSource );
if( LyricSourceEditor )
{
if( LyricSourceEditor->ShowModal() == wxID_OK )
{
LyricSourceEditor->UpdateLyricSource();
bool WasActive = m_LyricsSrcListBox->IsChecked( m_LyricSourceSelected );
m_LyricsSrcListBox->SetString( m_LyricSourceSelected, CurrentLyricSource->Name() );
m_LyricsSrcListBox->Check( m_LyricSourceSelected, WasActive );
}
LyricSourceEditor->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLyricSourceToggled( wxCommandEvent &event )
{
//guLogMessage( wxT( "Toggled %i %i" ), event.GetInt(), m_LyricsSrcListBox->IsChecked( event.GetInt() ) );
m_LyricSourceSelected = event.GetInt();
guLyricSource * LyricSource = m_LyricSearchEngine->GetSource( m_LyricSourceSelected );
LyricSource->Enabled( m_LyricsSrcListBox->IsChecked( m_LyricSourceSelected ) );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLyricAddBtnClick( wxCommandEvent &event )
{
guLyricSource LyricSource;
LyricSource.Type( guLYRIC_SOURCE_TYPE_DOWNLOAD );
guLyricSourceEditor * LyricSourceEditor = new guLyricSourceEditor( this, &LyricSource );
if( LyricSourceEditor )
{
if( LyricSourceEditor->ShowModal() == wxID_OK )
{
LyricSourceEditor->UpdateLyricSource();
m_LyricsSrcListBox->Append( LyricSource.Name() );
m_LyricSearchEngine->SourceAdd( new guLyricSource( LyricSource ) );
}
LyricSourceEditor->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLyricUpBtnClick( wxCommandEvent &event )
{
wxString LyricSource = m_LyricsSrcListBox->GetString( m_LyricSourceSelected );
bool LyricChecked = m_LyricsSrcListBox->IsChecked( m_LyricSourceSelected );
m_LyricSearchEngine->SourceMoveUp( m_LyricSourceSelected );
m_LyricsSrcListBox->SetString( m_LyricSourceSelected, m_LyricsSrcListBox->GetString( m_LyricSourceSelected - 1 ) );
m_LyricsSrcListBox->Check( m_LyricSourceSelected, m_LyricsSrcListBox->IsChecked( m_LyricSourceSelected - 1 ) );
m_LyricSourceSelected--;
m_LyricsSrcListBox->SetString( m_LyricSourceSelected, LyricSource );
m_LyricsSrcListBox->Check( m_LyricSourceSelected, LyricChecked );
m_LyricsSrcListBox->SetSelection( m_LyricSourceSelected );
event.SetInt( m_LyricSourceSelected );
OnLyricSourceSelected( event );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLyricDownBtnClick( wxCommandEvent &event )
{
wxString LyricSource = m_LyricsSrcListBox->GetString( m_LyricSourceSelected );
bool LyricChecked = m_LyricsSrcListBox->IsChecked( m_LyricSourceSelected );
m_LyricSearchEngine->SourceMoveDown( m_LyricSourceSelected );
m_LyricsSrcListBox->SetString( m_LyricSourceSelected, m_LyricsSrcListBox->GetString( m_LyricSourceSelected + 1 ) );
m_LyricsSrcListBox->Check( m_LyricSourceSelected, m_LyricsSrcListBox->IsChecked( m_LyricSourceSelected + 1 ) );
m_LyricSourceSelected++;
m_LyricsSrcListBox->SetString( m_LyricSourceSelected, LyricSource );
m_LyricsSrcListBox->Check( m_LyricSourceSelected, LyricChecked );
m_LyricsSrcListBox->SetSelection( m_LyricSourceSelected );
event.SetInt( m_LyricSourceSelected );
OnLyricSourceSelected( event );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLyricDelBtnClick( wxCommandEvent &event )
{
if( m_LyricSourceSelected != wxNOT_FOUND )
{
m_LyricSearchEngine->SourceRemoveAt( m_LyricSourceSelected );
m_LyricsSrcListBox->Delete( m_LyricSourceSelected );
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLyricSaveSelected( wxCommandEvent &event )
{
//guLogMessage( wxT( "Selected %i" ), event.GetInt() );
m_LyricTargetSelected = event.GetInt();
m_LyricsSaveUpButton->Enable( m_LyricTargetSelected > 0 );
m_LyricsSaveDownButton->Enable( m_LyricTargetSelected >= 0 && ( m_LyricTargetSelected < ( ( int ) m_LyricSearchEngine->TargetsCount() - 1 ) ) );
m_LyricsSaveDelButton->Enable( m_LyricTargetSelected != wxNOT_FOUND );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLyricSaveDClicked( wxCommandEvent &event )
{
guLyricSource * CurrentLyricTarget = m_LyricSearchEngine->GetTarget( m_LyricTargetSelected );
guLyricSourceEditor * LyricSourceEditor = new guLyricSourceEditor( this, CurrentLyricTarget, true );
if( LyricSourceEditor )
{
if( LyricSourceEditor->ShowModal() == wxID_OK )
{
LyricSourceEditor->UpdateLyricSource();
bool WasActive = m_LyricsSaveListBox->IsChecked( m_LyricTargetSelected );
m_LyricsSaveListBox->SetString( m_LyricTargetSelected, CurrentLyricTarget->Name() );
m_LyricsSaveListBox->Check( m_LyricTargetSelected, WasActive );
}
LyricSourceEditor->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLyricSaveToggled( wxCommandEvent &event )
{
//guLogMessage( wxT( "Toggled %i %i" ), event.GetInt(), m_LyricsSaveListBox->IsChecked( event.GetInt() ) );
m_LyricTargetSelected = event.GetInt();
guLyricSource * LyricTarget = m_LyricSearchEngine->GetTarget( m_LyricTargetSelected );
LyricTarget->Enabled( m_LyricsSaveListBox->IsChecked( m_LyricTargetSelected ) );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLyricSaveAddBtnClick( wxCommandEvent &event )
{
guLyricSource LyricTarget;
guLyricSourceEditor * LyricSourceEditor = new guLyricSourceEditor( this, &LyricTarget, true );
if( LyricSourceEditor )
{
if( LyricSourceEditor->ShowModal() == wxID_OK )
{
LyricSourceEditor->UpdateLyricSource();
m_LyricsSaveListBox->Append( LyricTarget.Name() );
m_LyricSearchEngine->TargetAdd( new guLyricSource( LyricTarget ) );
}
LyricSourceEditor->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLyricSaveUpBtnClick( wxCommandEvent &event )
{
wxString LyricTarget = m_LyricsSaveListBox->GetString( m_LyricTargetSelected );
bool LyricChecked = m_LyricsSaveListBox->IsChecked( m_LyricTargetSelected );
m_LyricSearchEngine->TargetMoveUp( m_LyricTargetSelected );
m_LyricsSaveListBox->SetString( m_LyricTargetSelected, m_LyricsSaveListBox->GetString( m_LyricTargetSelected - 1 ) );
m_LyricsSaveListBox->Check( m_LyricTargetSelected, m_LyricsSaveListBox->IsChecked( m_LyricTargetSelected - 1 ) );
m_LyricTargetSelected--;
m_LyricsSaveListBox->SetString( m_LyricTargetSelected, LyricTarget );
m_LyricsSaveListBox->Check( m_LyricTargetSelected, LyricChecked );
m_LyricsSaveListBox->SetSelection( m_LyricTargetSelected );
event.SetInt( m_LyricTargetSelected );
OnLyricSourceSelected( event );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLyricSaveDownBtnClick( wxCommandEvent &event )
{
wxString LyricTarget = m_LyricsSaveListBox->GetString( m_LyricTargetSelected );
bool LyricChecked = m_LyricsSaveListBox->IsChecked( m_LyricTargetSelected );
m_LyricSearchEngine->TargetMoveDown( m_LyricTargetSelected );
m_LyricsSaveListBox->SetString( m_LyricTargetSelected, m_LyricsSaveListBox->GetString( m_LyricTargetSelected + 1 ) );
m_LyricsSaveListBox->Check( m_LyricTargetSelected, m_LyricsSaveListBox->IsChecked( m_LyricTargetSelected + 1 ) );
m_LyricTargetSelected++;
m_LyricsSaveListBox->SetString( m_LyricTargetSelected, LyricTarget );
m_LyricsSaveListBox->Check( m_LyricTargetSelected, LyricChecked );
m_LyricsSaveListBox->SetSelection( m_LyricTargetSelected );
event.SetInt( m_LyricTargetSelected );
OnLyricSourceSelected( event );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLyricSaveDelBtnClick( wxCommandEvent &event )
{
if( m_LyricTargetSelected != wxNOT_FOUND )
{
m_LyricSearchEngine->TargetRemoveAt( m_LyricTargetSelected );
m_LyricsSaveListBox->Delete( m_LyricTargetSelected );
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLyricDisGenreSelected( wxCommandEvent &event )
{
m_LyricsDisGenreDelButton->Enable( event.GetInt() != wxNOT_FOUND );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLyricDisGenreAddBtnClick( wxCommandEvent &event )
{
wxTextEntryDialog * EntryDialog = new wxTextEntryDialog( this, _( "Genre: " ), _( "Enter the genre to disable" ), wxEmptyString );
if( EntryDialog )
{
if( EntryDialog->ShowModal() == wxID_OK )
{
if( m_LyricDisabledGenres.Index( EntryDialog->GetValue() ) == wxNOT_FOUND )
{
m_LyricDisabledGenres.Add( EntryDialog->GetValue() );
m_LirycsDisGenresListBox->Append( EntryDialog->GetValue() );
}
}
EntryDialog->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLyricDisGenreDelBtnClick( wxCommandEvent &event )
{
int SelectedDisGenre = m_LirycsDisGenresListBox->GetSelection();
if( SelectedDisGenre != wxNOT_FOUND )
{
m_LyricDisabledGenres.RemoveAt( SelectedDisGenre );
m_LirycsDisGenresListBox->Delete( SelectedDisGenre );
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnFiltersListBoxSelected( wxCommandEvent &event )
{
m_FilterSelected = event.GetInt();
if( m_FilterSelected != wxNOT_FOUND )
{
m_OnlineDelBtn->Enable();
}
else
{
m_OnlineDelBtn->Disable();
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnPlayLevelEnabled( wxCommandEvent& event )
{
m_PlayLevelSlider->Enable( event.IsChecked() );
m_PlayLevelVal->Enable( event.IsChecked() );
m_PlayEndTimeCheckBox->Enable( event.IsChecked() );
m_PlayEndTimeSpinCtrl->Enable( event.IsChecked() && m_PlayEndTimeCheckBox->IsChecked() );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnReplayGainModeChanged( wxCommandEvent &event )
{
bool Enabled = m_PlayReplayModeChoice->GetSelection();
m_PlayPreAmpLevelVal->Enable( Enabled );
m_PlayPreAmpLevelSlider->Enable( Enabled );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnPlayPreAmpLevelValueChanged( wxScrollEvent &event )
{
int Value = m_PlayPreAmpLevelSlider->GetValue();
m_PlayPreAmpLevelVal->SetLabel( wxString::Format( wxT( "%idb" ), Value ) );
m_PlayPreAmpLevelVal->GetParent()->GetSizer()->Layout();
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnPlayLevelValueChanged( wxScrollEvent &event )
{
int Value = m_PlayLevelSlider->GetValue();
m_PlayLevelVal->SetLabel( wxString::Format( wxT( "%02idb" ), Value ) );
m_PlayLevelVal->GetParent()->GetSizer()->Layout();
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnPlayEndTimeEnabled( wxCommandEvent& event )
{
m_PlayEndTimeSpinCtrl->Enable( event.IsChecked() );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnPlayOutDevChanged( wxCommandEvent& event )
{
m_PlayOutDevName->Enable( event.GetInt() > guOUTPUT_DEVICE_GCONF );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnCrossFadeChanged( wxScrollEvent& event )
{
bool IsEnabled = m_XFadeOutLenSlider->GetValue();
m_XFadeInLenSlider->Enable( IsEnabled );
m_XFadeInStartSlider->Enable( IsEnabled );
m_XFadeInTrigerSlider->Enable( IsEnabled );
double FadeOutLen = double( m_XFadeOutLenSlider->GetValue() ) / 10.0;
double FadeInLen = double( m_XFadeInLenSlider->GetValue() ) / 10.0;
double FadeInTriger = double( m_XFadeInTrigerSlider->GetValue() ) / 10.0;
double FadeInVolStart = double( m_XFadeInStartSlider->GetValue() ) / 10.0;
m_XFadeOutLenVal->SetLabel( wxString::Format( wxT( "%2.1f" ), FadeOutLen ) );
m_XFadeInLenVal->SetLabel( wxString::Format( wxT( "%2.1f" ), FadeInLen ) );
m_XFadeInStartVal->SetLabel( wxString::Format( wxT( "%2.1f" ), FadeInVolStart ) );
m_XFadeTrigerVal->SetLabel( wxString::Format( wxT( "%2.1f" ), FadeInTriger ) );
m_XFadeInLenVal->Enable( IsEnabled );
m_XFadeInStartVal->Enable( IsEnabled );
m_XFadeTrigerVal->Enable( IsEnabled );
m_XFadeTrigerVal->GetParent()->GetSizer()->Layout();
wxBitmap * FadeBitmap = new wxBitmap( 400, 200 );
if( FadeBitmap )
{
if( FadeBitmap->IsOk() )
{
wxMemoryDC MemDC;
MemDC.SelectObject( * FadeBitmap );
MemDC.Clear();
wxRect Rect( 0, 0, 400, 200 );
wxPoint FadeOutPoints[ 4 ];
FadeOutPoints[ 0 ] = wxPoint( 0, 0 );
FadeOutPoints[ 1 ] = wxPoint( 0, 200 );
FadeOutPoints[ 2 ] = wxPoint( ( FadeOutLen + 1 ) * 20, 200 );
FadeOutPoints[ 3 ] = wxPoint( 20, 0 );
wxRegion OutRegion( WXSIZEOF( FadeOutPoints ), FadeOutPoints );
wxPoint FadeInPoints[ 5 ];
int FadeInStartX = FadeOutPoints[ 2 ].x - ( FadeInTriger * ( ( FadeOutPoints[ 2 ].x - 20 ) / 10 ) );
int FadeInStartY = IsEnabled ? ( 200 - ( FadeInVolStart * 20 ) ) : 0;
FadeInPoints[ 0 ] = wxPoint( FadeInStartX, 200 );
FadeInPoints[ 1 ] = wxPoint( FadeInStartX, FadeInStartY );
FadeInPoints[ 2 ] = wxPoint( FadeInStartX + ( FadeInLen * 20 ), 0 );
FadeInPoints[ 3 ] = wxPoint( 400, 0 );
FadeInPoints[ 4 ] = wxPoint( 400, 200 );
wxRegion InRegion( WXSIZEOF( FadeInPoints ), FadeInPoints );
MemDC.SetDeviceClippingRegion( InRegion );
MemDC.GradientFillLinear( Rect, * wxLIGHT_GREY, * wxGREEN, wxRIGHT );
MemDC.DestroyClippingRegion();
MemDC.SetDeviceClippingRegion( OutRegion );
MemDC.GradientFillLinear( Rect, wxColour( 0, 200, 200 ), wxColour( 0, 128, 128 ), wxRIGHT );
MemDC.DestroyClippingRegion();
OutRegion.Subtract( InRegion );
MemDC.SetDeviceClippingRegion( OutRegion );
MemDC.GradientFillLinear( Rect, * wxBLUE, * wxLIGHT_GREY, wxRIGHT );
MemDC.DestroyClippingRegion();
m_FadeBitmap->SetBitmap( * FadeBitmap );
m_FadeBitmap->Refresh();
}
delete FadeBitmap;
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnRecEnableClicked( wxCommandEvent& event )
{
m_RecSelDirPicker->Enable( event.IsChecked() );
m_RecFormatChoice->Enable( event.IsChecked() );
m_RecQualityChoice->Enable( event.IsChecked() );
m_RecSplitChkBox->Enable( event.IsChecked() );
m_RecDelTracks->Enable( event.IsChecked() );
m_RecDelTime->Enable( event.IsChecked() );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnRecDelTracksClicked( wxCommandEvent& event )
{
m_RecDelTime->Enable( event.IsChecked() );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLastFMASUserNameChanged( wxCommandEvent &event )
{
if( m_LastFMUserNameTextCtrl->GetValue().IsEmpty() ||
m_LastFMPasswdTextCtrl->GetValue().IsEmpty() )
{
m_LastFMASEnableChkBox->Disable();
}
else
{
m_LastFMASEnableChkBox->Enable();
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLibreFMASUserNameChanged( wxCommandEvent &event )
{
if( m_LibreFMUserNameTextCtrl->GetValue().IsEmpty() ||
m_LibreFMPasswdTextCtrl->GetValue().IsEmpty() )
{
m_LibreFMASEnableChkBox->Disable();
}
else
{
m_LibreFMASEnableChkBox->Enable();
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnOnlineAddBtnClick( wxCommandEvent& event )
{
wxTextEntryDialog * EntryDialog = new wxTextEntryDialog( this, _( "Filter: " ), _( "Enter the text to filter" ), wxEmptyString );
if( EntryDialog )
{
if( EntryDialog->ShowModal() == wxID_OK )
{
if( m_OnlineFiltersListBox->FindString( EntryDialog->GetValue(), true ) == wxNOT_FOUND )
{
m_OnlineFiltersListBox->Append( EntryDialog->GetValue() );
}
}
EntryDialog->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnOnlineDelBtnClick( wxCommandEvent& event )
{
if( m_FilterSelected != wxNOT_FOUND )
{
m_OnlineFiltersListBox->Delete( m_FilterSelected );
//m_FilterSelected = wxNOT_FOUND;
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnOnlineListBoxDClicked( wxCommandEvent &event )
{
int index = event.GetInt();
if( index != wxNOT_FOUND )
{
wxTextEntryDialog * EntryDialog = new wxTextEntryDialog( this, _( "Filter: " ), _( "Edit the text to filter" ), m_OnlineFiltersListBox->GetString( index ) );
if( EntryDialog )
{
if( EntryDialog->ShowModal() == wxID_OK )
{
if( m_OnlineFiltersListBox->FindString( EntryDialog->GetValue(), true ) == wxNOT_FOUND )
{
m_OnlineFiltersListBox->SetString( index, EntryDialog->GetValue() );
}
}
EntryDialog->Destroy();
}
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnOnlineMinBitRateChanged( wxScrollEvent &event )
{
int CurPosition = event.GetPosition();
//guLogMessage( wxT( "RadioMinBitrate: %i => %i" ), CurPosition, m_LastMinBitRate );
if( m_LastMinBitRate != CurPosition )
{
if( CurPosition > m_LastMinBitRate )
{
if( CurPosition > 256 )
CurPosition = 320;
else if( CurPosition > 192 )
CurPosition = 256;
else if( CurPosition > 160 )
CurPosition = 192;
else if( CurPosition > 128 )
CurPosition = 160;
else if( CurPosition > 96 )
CurPosition = 128;
else if( CurPosition > 64 )
CurPosition = 96;
else if( CurPosition > 32 )
CurPosition = 64;
else if( CurPosition > 16 )
CurPosition = 32;
else if( CurPosition > 0 )
CurPosition = 16;
else
CurPosition = 0;
}
else
{
if( CurPosition < 16 )
CurPosition = 0;
else if( CurPosition < 32 )
CurPosition = 16;
else if( CurPosition < 64 )
CurPosition = 32;
else if( CurPosition < 96 )
CurPosition = 64;
else if( CurPosition < 128 )
CurPosition = 96;
else if( CurPosition < 192 )
CurPosition = 128;
else if( CurPosition < 256 )
CurPosition = 192;
else if( CurPosition < 320 )
CurPosition = 256;
else
CurPosition = 320;
}
m_LastMinBitRate = CurPosition;
m_RadioMinBitRateSlider->SetValue( CurPosition );
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnOnlineProxyEnabledChanged( wxCommandEvent &event )
{
bool Enabled = event.IsChecked();
m_OnlineProxyHostTextCtrl->Enable( Enabled );
m_OnlineProxyPortTextCtrl->Enable( Enabled );;
m_OnlineProxyUserTextCtrl->Enable( Enabled );;
m_OnlineProxyPasswdTextCtrl->Enable( Enabled );;
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnJamendoSelectAll( wxCommandEvent& event )
{
int Count = m_JamGenresListBox->GetCount();
for( int Index = 0; Index < Count; Index++ )
{
m_JamGenresListBox->Check( Index );
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnJamendoSelectNone( wxCommandEvent& event )
{
int Count = m_JamGenresListBox->GetCount();
for( int Index = 0; Index < Count; Index++ )
{
m_JamGenresListBox->Check( Index, false );
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnJamendoInvertSelection( wxCommandEvent& event )
{
int Count = m_JamGenresListBox->GetCount();
for( int Index = 0; Index < Count; Index++ )
{
m_JamGenresListBox->Check( Index, !m_JamGenresListBox->IsChecked( Index ) );
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnMagnatuneSelectAll( wxCommandEvent& event )
{
int Count = m_MagGenresListBox->GetCount();
for( int Index = 0; Index < Count; Index++ )
{
m_MagGenresListBox->Check( Index );
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnMagnatuneSelectNone( wxCommandEvent& event )
{
int Count = m_MagGenresListBox->GetCount();
for( int Index = 0; Index < Count; Index++ )
{
m_MagGenresListBox->Check( Index, false );
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnMagnatuneInvertSelection( wxCommandEvent& event )
{
int Count = m_MagGenresListBox->GetCount();
for( int Index = 0; Index < Count; Index++ )
{
m_MagGenresListBox->Check( Index, !m_MagGenresListBox->IsChecked( Index ) );
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnMagNoRadioItemChanged( wxCommandEvent& event )
{
bool Enabled = !m_MagNoRadioItem->GetValue();
m_MagUserTextCtrl->Enable( Enabled );
m_MagPassTextCtrl->Enable( Enabled );
m_MagDownFormatChoice->Enable( m_MagDlRadioItem->GetValue() );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLinksListBoxSelected( wxCommandEvent &event )
{
m_LinkSelected = event.GetInt();
if( m_LinkSelected != wxNOT_FOUND )
{
m_LinksDelBtn->Enable();
if( m_LinkSelected > 0 )
m_LinksMoveUpBtn->Enable();
else
m_LinksMoveUpBtn->Disable();
if( m_LinkSelected < ( int ) ( m_LinksListBox->GetCount() - 1 ) )
m_LinksMoveDownBtn->Enable();
else
m_LinksMoveDownBtn->Disable();
m_LinksUrlTextCtrl->SetValue( m_LinksListBox->GetString( m_LinkSelected ) );
m_LinksNameTextCtrl->SetValue( m_LinksNames[ m_LinkSelected ] );
m_LinksAcceptBtn->Disable();
}
else
{
m_LinksDelBtn->Disable();
m_LinksMoveUpBtn->Disable();
m_LinksMoveDownBtn->Disable();
m_LinksAcceptBtn->Disable();
m_LinksUrlTextCtrl->SetValue( wxEmptyString );
m_LinksNameTextCtrl->SetValue( wxEmptyString );
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLinksAddBtnClick( wxCommandEvent& event )
{
wxString Url = m_LinksUrlTextCtrl->GetValue();
if( !Url.IsEmpty() )
{
m_LinksListBox->Append( m_LinksUrlTextCtrl->GetValue() );
m_LinksNames.Add( m_LinksNameTextCtrl->GetValue() );
m_LinkSelected = m_LinksNames.Count() - 1;
m_LinksListBox->SetSelection( m_LinkSelected );
event.SetInt( m_LinkSelected );
OnLinksListBoxSelected( event );
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLinksDelBtnClick( wxCommandEvent& event )
{
if( m_LinkSelected != wxNOT_FOUND )
{
m_LinksNames.RemoveAt( m_LinkSelected );
m_LinksListBox->Delete( m_LinkSelected );
//m_LinkSelected = wxNOT_FOUND;
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLinkMoveUpBtnClick( wxCommandEvent &event )
{
wxString CurUrl = m_LinksListBox->GetString( m_LinkSelected );
wxString CurName = m_LinksNames[ m_LinkSelected ];
m_LinksListBox->SetString( m_LinkSelected, m_LinksListBox->GetString( m_LinkSelected - 1 ) );
m_LinksNames[ m_LinkSelected ] = m_LinksNames[ m_LinkSelected - 1 ];
m_LinkSelected--;
m_LinksListBox->SetString( m_LinkSelected, CurUrl );
m_LinksNames[ m_LinkSelected ] = CurName;
m_LinksListBox->SetSelection( m_LinkSelected );
event.SetInt( m_LinkSelected );
OnLinksListBoxSelected( event );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLinkMoveDownBtnClick( wxCommandEvent &event )
{
wxString CurUrl = m_LinksListBox->GetString( m_LinkSelected );
wxString CurName = m_LinksNames[ m_LinkSelected ];
m_LinksListBox->SetString( m_LinkSelected, m_LinksListBox->GetString( m_LinkSelected + 1 ) );
m_LinksNames[ m_LinkSelected ] = m_LinksNames[ m_LinkSelected + 1 ];
m_LinkSelected++;
m_LinksListBox->SetString( m_LinkSelected, CurUrl );
m_LinksNames[ m_LinkSelected ] = CurName;
m_LinksListBox->SetSelection( m_LinkSelected );
event.SetInt( m_LinkSelected );
OnLinksListBoxSelected( event );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLinksTextChanged( wxCommandEvent &event )
{
if( !m_LinksUrlTextCtrl->GetValue().IsEmpty() )
{
m_LinksAddBtn->Enable();
if( m_LinkSelected != wxNOT_FOUND )
m_LinksAcceptBtn->Enable();
}
else
{
m_LinksAddBtn->Disable();
if( m_LinkSelected != wxNOT_FOUND )
m_LinksAcceptBtn->Disable();
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnLinksSaveBtnClick( wxCommandEvent &event )
{
m_LinksListBox->SetString( m_LinkSelected, m_LinksUrlTextCtrl->GetValue() );
m_LinksNames[ m_LinkSelected ] = m_LinksNameTextCtrl->GetValue();
if( m_LinksNames[ m_LinkSelected ].IsEmpty() )
{
wxURI Uri( m_LinksUrlTextCtrl->GetValue() );
m_LinksNames[ m_LinkSelected ] = Uri.GetServer();
m_LinksNameTextCtrl->SetValue( Uri.GetServer() );
}
m_LinksAcceptBtn->Disable();
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnCmdListBoxSelected( wxCommandEvent &event )
{
m_CmdSelected = event.GetInt();
if( m_CmdSelected != wxNOT_FOUND )
{
m_CmdDelBtn->Enable();
if( m_CmdSelected > 0 )
m_CmdMoveUpBtn->Enable();
else
m_CmdMoveUpBtn->Disable();
if( m_CmdSelected < ( int ) ( m_CmdListBox->GetCount() - 1 ) )
m_CmdMoveDownBtn->Enable();
else
m_CmdMoveDownBtn->Disable();
m_CmdTextCtrl->SetValue( m_CmdListBox->GetString( m_CmdSelected ) );
m_CmdNameTextCtrl->SetValue( m_CmdNames[ m_CmdSelected ] );
m_CmdAcceptBtn->Disable();
}
else
{
m_CmdDelBtn->Disable();
m_CmdMoveUpBtn->Disable();
m_CmdMoveDownBtn->Disable();
m_CmdAcceptBtn->Disable();
m_CmdTextCtrl->SetValue( wxEmptyString );
m_CmdNameTextCtrl->SetValue( wxEmptyString );
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnCmdAddBtnClick( wxCommandEvent& event )
{
wxString Cmd = m_CmdTextCtrl->GetValue();
if( !Cmd.IsEmpty() )
{
m_CmdListBox->Append( m_CmdTextCtrl->GetValue() );
m_CmdNames.Add( m_CmdNameTextCtrl->GetValue() );
m_CmdSelected = m_CmdNames.Count() - 1;
m_CmdListBox->SetSelection( m_CmdSelected );
event.SetInt( m_CmdSelected );
OnCmdListBoxSelected( event );
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnCmdDelBtnClick( wxCommandEvent& event )
{
if( m_CmdSelected != wxNOT_FOUND )
{
m_CmdNames.RemoveAt( m_CmdSelected );
m_CmdListBox->Delete( m_CmdSelected );
//m_CmdSelected = wxNOT_FOUND;
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnCmdMoveUpBtnClick( wxCommandEvent &event )
{
wxString CurUrl = m_CmdListBox->GetString( m_CmdSelected );
wxString CurName = m_CmdNames[ m_CmdSelected ];
m_CmdListBox->SetString( m_CmdSelected, m_CmdListBox->GetString( m_CmdSelected - 1 ) );
m_CmdNames[ m_CmdSelected ] = m_CmdNames[ m_CmdSelected - 1 ];
m_CmdSelected--;
m_CmdListBox->SetString( m_CmdSelected, CurUrl );
m_CmdNames[ m_CmdSelected ] = CurName;
m_CmdListBox->SetSelection( m_CmdSelected );
event.SetInt( m_CmdSelected );
OnCmdListBoxSelected( event );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnCmdMoveDownBtnClick( wxCommandEvent &event )
{
wxString CurUrl = m_CmdListBox->GetString( m_CmdSelected );
wxString CurName = m_CmdNames[ m_CmdSelected ];
m_CmdListBox->SetString( m_CmdSelected, m_CmdListBox->GetString( m_CmdSelected + 1 ) );
m_CmdNames[ m_CmdSelected ] = m_CmdNames[ m_CmdSelected + 1 ];
m_CmdSelected++;
m_CmdListBox->SetString( m_CmdSelected, CurUrl );
m_CmdNames[ m_CmdSelected ] = CurName;
m_CmdListBox->SetSelection( m_CmdSelected );
event.SetInt( m_CmdSelected );
OnCmdListBoxSelected( event );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnCmdTextChanged( wxCommandEvent &event )
{
if( !m_CmdTextCtrl->GetValue().IsEmpty() )
{
m_CmdAddBtn->Enable();
if( m_CmdSelected != wxNOT_FOUND )
m_CmdAcceptBtn->Enable();
}
else
{
m_CmdAddBtn->Disable();
if( m_CmdSelected != wxNOT_FOUND )
m_CmdAcceptBtn->Disable();
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnCmdSaveBtnClick( wxCommandEvent &event )
{
m_CmdListBox->SetString( m_CmdSelected, m_CmdTextCtrl->GetValue() );
m_CmdNames[ m_CmdSelected ] = m_CmdNameTextCtrl->GetValue();
if( m_CmdNames[ m_CmdSelected ].IsEmpty() )
{
m_CmdNames[ m_CmdSelected ] = m_CmdTextCtrl->GetValue().BeforeFirst( ' ' );
m_CmdNameTextCtrl->SetValue( m_CmdNames[ m_CmdSelected ] );
}
m_CmdAcceptBtn->Disable();
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnCopyToListBoxSelected( wxCommandEvent &event )
{
m_CopyToSelected = event.GetInt();
if( m_CopyToSelected != wxNOT_FOUND )
{
m_CopyToDelBtn->Enable();
if( m_CopyToSelected > 0 )
m_CopyToUpBtn->Enable();
else
m_CopyToUpBtn->Disable();
if( m_CopyToSelected < ( int ) ( m_CopyToListBox->GetCount() - 1 ) )
m_CopyToDownBtn->Enable();
else
m_CopyToDownBtn->Disable();
guCopyToPattern &CopyToPattern = m_CopyToOptions->Item( m_CopyToSelected );
m_CopyToNameTextCtrl->SetValue( CopyToPattern.m_Name );
m_CopyToPatternTextCtrl->SetValue( CopyToPattern.m_Pattern );
m_CopyToPathTextCtrl->SetValue( CopyToPattern.m_Path );
m_CopyToFormatChoice->SetSelection( CopyToPattern.m_Format );
m_CopyToQualityChoice->SetSelection( CopyToPattern.m_Quality );
m_CopyToQualityChoice->Enable( CopyToPattern.m_Format );
m_CopyToMoveFilesChkBox->SetValue( CopyToPattern.m_MoveFiles );
m_CopyToAcceptBtn->Disable();
}
else
{
m_CopyToDelBtn->Disable();
m_CopyToUpBtn->Disable();
m_CopyToDownBtn->Disable();
m_CopyToAcceptBtn->Disable();
m_CopyToPatternTextCtrl->SetValue( wxEmptyString );
m_CopyToPathTextCtrl->SetValue( wxEmptyString );
m_CopyToNameTextCtrl->SetValue( wxEmptyString );
m_CopyToFormatChoice->SetSelection( 0 );
m_CopyToQualityChoice->SetSelection( 0 );
m_CopyToQualityChoice->Disable();
m_CopyToMoveFilesChkBox->SetValue( false );
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnCopyToAddBtnClick( wxCommandEvent& event )
{
wxString Cmd = m_CopyToPatternTextCtrl->GetValue();
if( !Cmd.IsEmpty() )
{
m_CopyToListBox->Append( m_CopyToNameTextCtrl->GetValue() );
guCopyToPattern * CopyToPattern = new guCopyToPattern();
CopyToPattern->m_Name = m_CopyToNameTextCtrl->GetValue();
CopyToPattern->m_Pattern = m_CopyToPatternTextCtrl->GetValue();
CopyToPattern->m_Path = m_CopyToPathTextCtrl->GetValue();
CopyToPattern->m_Format = m_CopyToFormatChoice->GetSelection();
CopyToPattern->m_Quality = m_CopyToQualityChoice->GetSelection();
CopyToPattern->m_MoveFiles = m_CopyToMoveFilesChkBox->GetValue();
m_CopyToOptions->Add( CopyToPattern );
UpdateCopyToOptions();
m_CopyToSelected = m_CopyToOptions->Count() - 1;
m_CopyToListBox->SetSelection( m_CopyToSelected );
event.SetInt( m_CopyToSelected );
OnCopyToListBoxSelected( event );
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnCopyToDelBtnClick( wxCommandEvent& event )
{
if( m_CopyToSelected != wxNOT_FOUND )
{
m_CopyToOptions->RemoveAt( m_CopyToSelected );
m_CopyToListBox->Delete( m_CopyToSelected );
//m_CopyToSelected = wxNOT_FOUND;
UpdateCopyToOptions();
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnCopyToMoveUpBtnClick( wxCommandEvent &event )
{
wxString CurName = m_CopyToListBox->GetString( m_CopyToSelected );
guCopyToPattern CopyToPattern = m_CopyToOptions->Item( m_CopyToSelected );
m_CopyToListBox->SetString( m_CopyToSelected, m_CopyToListBox->GetString( m_CopyToSelected - 1 ) );
m_CopyToOptions->Item( m_CopyToSelected ) = m_CopyToOptions->Item( m_CopyToSelected - 1 );
m_CopyToSelected--;
m_CopyToListBox->SetString( m_CopyToSelected, CurName );
m_CopyToOptions->Item( m_CopyToSelected ) = CopyToPattern;
m_CopyToListBox->SetSelection( m_CopyToSelected );
UpdateCopyToOptions();
event.SetInt( m_CopyToSelected );
OnCopyToListBoxSelected( event );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnCopyToMoveDownBtnClick( wxCommandEvent &event )
{
wxString CurName = m_CopyToListBox->GetString( m_CopyToSelected );
guCopyToPattern CopyToPattern = m_CopyToOptions->Item( m_CopyToSelected );
m_CopyToListBox->SetString( m_CopyToSelected, m_CopyToListBox->GetString( m_CopyToSelected + 1 ) );
m_CopyToOptions->Item( m_CopyToSelected ) = m_CopyToOptions->Item( m_CopyToSelected + 1 );
m_CopyToSelected++;
m_CopyToListBox->SetString( m_CopyToSelected, CurName );
m_CopyToOptions->Item( m_CopyToSelected ) = CopyToPattern;
m_CopyToListBox->SetSelection( m_CopyToSelected );
UpdateCopyToOptions();
event.SetInt( m_CopyToSelected );
OnCopyToListBoxSelected( event );
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnCopyToTextChanged( wxCommandEvent &event )
{
if( !m_CopyToPatternTextCtrl->GetValue().IsEmpty() )
{
m_CopyToAddBtn->Enable();
if( m_CopyToSelected != wxNOT_FOUND )
m_CopyToAcceptBtn->Enable();
}
else
{
m_CopyToAddBtn->Disable();
if( m_CopyToSelected != wxNOT_FOUND )
m_CopyToAcceptBtn->Disable();
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnCopyToPathBtnClick( wxCommandEvent &event )
{
wxString CurPath = m_CopyToPathTextCtrl->GetValue();
if( !CurPath.EndsWith( wxT( "/" ) ) )
CurPath.Append( wxT( "/" ) );
wxDirDialog * DirDialog = new wxDirDialog( this,
_( "Select path" ), CurPath, wxDD_DIR_MUST_EXIST );
if( DirDialog )
{
if( DirDialog->ShowModal() == wxID_OK )
{
m_CopyToPathTextCtrl->SetValue( DirDialog->GetPath() + wxT( "/" ) );
}
DirDialog->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnCopyToFormatChanged( wxCommandEvent &event )
{
m_CopyToQualityChoice->Enable( m_CopyToFormatChoice->GetSelection() );
if( m_CopyToSelected != wxNOT_FOUND )
{
if( !m_CopyToPatternTextCtrl->IsEmpty() )
{
m_CopyToAcceptBtn->Enable();
}
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnCopyToQualityChanged( wxCommandEvent &event )
{
m_CopyToQualityChoice->Enable( m_CopyToFormatChoice->GetSelection() );
if( m_CopyToSelected != wxNOT_FOUND )
{
if( !m_CopyToPatternTextCtrl->IsEmpty() )
{
m_CopyToAcceptBtn->Enable();
}
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnCopyToMoveFilesChanged( wxCommandEvent &event )
{
if( m_CopyToSelected != wxNOT_FOUND )
{
if( !m_CopyToPatternTextCtrl->IsEmpty() )
{
m_CopyToAcceptBtn->Enable();
}
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnCopyToSaveBtnClick( wxCommandEvent &event )
{
m_CopyToListBox->SetString( m_CopyToSelected, m_CopyToNameTextCtrl->GetValue() );
guCopyToPattern &CopyToPattern = m_CopyToOptions->Item( m_CopyToSelected );
CopyToPattern.m_Name = m_CopyToNameTextCtrl->GetValue();
CopyToPattern.m_Pattern = m_CopyToPatternTextCtrl->GetValue();
CopyToPattern.m_Path = m_CopyToPathTextCtrl->GetValue();
CopyToPattern.m_Format = m_CopyToFormatChoice->GetSelection();
CopyToPattern.m_Quality = m_CopyToQualityChoice->GetSelection();
CopyToPattern.m_MoveFiles = m_CopyToMoveFilesChkBox->GetValue();
if( CopyToPattern.m_Name.IsEmpty() )
{
CopyToPattern.m_Name = CopyToPattern.m_Pattern;
m_CopyToNameTextCtrl->SetValue( CopyToPattern.m_Pattern );
}
m_CopyToAcceptBtn->Disable();
UpdateCopyToOptions();
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::UpdateCopyToOptions( void )
{
if( m_LibOptCopyToChoice )
{
wxString CurSelected = m_LibOptCopyToChoice->GetStringSelection();
m_LibOptCopyToChoice->Clear();
m_LibOptCopyToChoice->Append( wxEmptyString );
if( m_CopyToOptions )
{
int Count = m_CopyToOptions->Count();
for( int Index = 0; Index < Count; Index++ )
{
m_LibOptCopyToChoice->Append( m_CopyToOptions->Item( Index ).m_Name );
}
}
else
{
wxArrayString CopyToOptions = m_Config->ReadAStr( CONFIG_KEY_COPYTO_OPTION, wxEmptyString, CONFIG_PATH_COPYTO );
int Count = CopyToOptions.Count();
for( int Index = 0; Index < Count; Index++ )
{
m_LibOptCopyToChoice->Append( CopyToOptions[ Index ].BeforeFirst( wxT( ':' ) ) );
}
}
m_LibOptCopyToChoice->SetStringSelection( CurSelected );
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnAccelSelected( wxListEvent &event )
{
if( m_AccelItemNeedClear )
{
m_AccelItemNeedClear = false;
m_AccelListCtrl->SetItem( m_AccelCurIndex, 1, wxEmptyString );
}
m_AccelCurIndex = event.GetIndex();
//guLogMessage( wxT( "Selected Accel %i" ), m_AccelCurIndex );
if( m_AccelCurIndex != wxNOT_FOUND )
{
m_AccelLastKey = m_AccelKeys[ m_AccelCurIndex ];
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnAccelKeyDown( wxKeyEvent &event )
{
if( m_AccelCurIndex != wxNOT_FOUND )
{
//guLogMessage( wxT( "Mod : %08X Key: %08X %i %c" ), event.GetModifiers(), event.GetKeyCode(), event.GetKeyCode(), event.GetKeyCode() );
int Modifiers = event.GetModifiers();
int KeyCode = event.GetKeyCode();
switch( KeyCode )
{
case WXK_SHIFT :
case WXK_ALT :
case WXK_CONTROL :
case WXK_MENU :
case WXK_PAUSE :
case WXK_CAPITAL :
event.Skip();
return;
default :
break;
}
if( Modifiers == 0 )
{
switch( KeyCode )
{
case WXK_HOME :
case WXK_END :
case WXK_PAGEUP :
case WXK_PAGEDOWN :
case WXK_UP :
case WXK_DOWN :
event.Skip();
return;
case WXK_ESCAPE :
if( m_AccelLastKey != m_AccelKeys[ m_AccelCurIndex ] )
{
m_AccelKeys[ m_AccelCurIndex ] = m_AccelLastKey;
m_AccelListCtrl->SetItem( m_AccelCurIndex, 1, guAccelGetKeyCodeString( m_AccelLastKey ) );
}
return;
case WXK_DELETE :
m_AccelListCtrl->SetItem( m_AccelCurIndex, 1, wxEmptyString );
m_AccelKeys[ m_AccelCurIndex ] = 0;
return;
default :
break;
}
/*
if( wxIsalnum( KeyCode ) || wxIsprint( KeyCode ) )
{
return;
}
*/
}
int AccelCurKey = ( Modifiers << 16 ) | KeyCode;
int KeyIndex = m_AccelKeys.Index( AccelCurKey );
if( ( KeyIndex == wxNOT_FOUND ) || ( KeyIndex == m_AccelCurIndex ) )
{
if( m_AccelItemNeedClear )
{
m_AccelItemNeedClear = false;
}
m_AccelKeys[ m_AccelCurIndex ] = AccelCurKey;
m_AccelListCtrl->SetItem( m_AccelCurIndex, 1, guAccelGetKeyCodeString( AccelCurKey ) );
}
else
{
if( !m_AccelItemNeedClear )
{
m_AccelItemNeedClear = true;
m_AccelListCtrl->SetItem( m_AccelCurIndex, 1, wxString( _( "Key used by '" ) ) + m_AccelActionNames[ KeyIndex ] + wxT( "'") );
}
}
}
}
// -------------------------------------------------------------------------------- //
void guPrefDialog::OnAccelDefaultClicked( wxCommandEvent &event )
{
m_AccelKeys.Empty();
guAccelGetDefaultKeys( m_AccelKeys );
int Count = m_AccelKeys.Count();
for( int Index = 0; Index < Count; Index++ )
{
m_AccelListCtrl->SetItem( Index, 1, guAccelGetKeyCodeString( m_AccelKeys[ Index ] ) );
}
}
}
// -------------------------------------------------------------------------------- //
| 211,101
|
C++
|
.cpp
| 3,577
| 53.393626
| 216
| 0.67611
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
750,660
|
LyricsPanel.cpp
|
anonbeat_guayadeque/src/ui/lyrics/LyricsPanel.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "LyricsPanel.h"
#include "EventCommandIds.h"
#include "Config.h"
#include "Preferences.h"
#include "Images.h"
#include "ListView.h"
#include "MainFrame.h"
#include "TagInfo.h"
#include "Utils.h"
#include <wx/arrimpl.cpp>
#include <wx/clipbrd.h>
#include <wx/html/htmprint.h>
#include <wx/html/htmlpars.h>
#include <wx/print.h>
#include <wx/printdlg.h>
#include <wx/settings.h>
#include <wx/txtstrm.h>
#include <wx/xml/xml.h>
#include <wx/regex.h>
#include <wx/sstream.h>
#include <wx/tokenzr.h>
namespace Guayadeque {
int LyricAligns[] = { wxTE_LEFT, wxTE_CENTER, wxTE_RIGHT };
WX_DEFINE_OBJARRAY( guLyricSourceReplaceArray )
WX_DEFINE_OBJARRAY( guLyricSourceExtractArray )
WX_DEFINE_OBJARRAY( guLyricSourceExcludeArray )
WX_DEFINE_OBJARRAY( guLyricSourceArray )
// -------------------------------------------------------------------------------- //
guLyricsPanel::guLyricsPanel( wxWindow * parent, guDbLibrary * db, guLyricSearchEngine * lyricsearchengine ) :
wxPanel( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL )
{
m_Db = db;
m_LyricSearchEngine = lyricsearchengine;
m_LyricSearchContext = NULL;
m_CurrentTrack = NULL;
m_MediaViewer = NULL;
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->RegisterObject( this );
m_UpdateEnabled = Config->ReadBool( CONFIG_KEY_LYRICS_FOLLOW_PLAYER, true, CONFIG_PATH_LYRICS );
m_LyricAlign = LyricAligns[ Config->ReadNum( CONFIG_KEY_LYRICS_TEXT_ALIGN, 1, CONFIG_PATH_LYRICS ) ];
wxFont CurrentFont;
CurrentFont.SetNativeFontInfo( Config->ReadStr( CONFIG_KEY_LYRICS_FONT, wxEmptyString, CONFIG_PATH_LYRICS ) );
if( !CurrentFont.IsOk() )
CurrentFont = GetFont();
wxBoxSizer * MainSizer;
MainSizer = new wxBoxSizer( wxVERTICAL );
m_TitleSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer * EditorSizer;
EditorSizer = new wxBoxSizer( wxHORIZONTAL );
m_UpdateCheckBox = new wxCheckBox( this, wxID_ANY, _( "Follow player" ), wxDefaultPosition, wxDefaultSize, 0 );
m_UpdateCheckBox->SetToolTip( _( "Search the lyrics for the current playing track" ) );
m_UpdateCheckBox->SetValue( m_UpdateEnabled );
EditorSizer->Add( m_UpdateCheckBox, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
m_SetupButton = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_search_engine ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_SetupButton->SetToolTip( _( "Configure lyrics preferences" ) );
EditorSizer->Add( m_SetupButton, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 5 );
m_ReloadButton = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_search_again ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_ReloadButton->SetToolTip( _( "Search for lyrics" ) );
m_ReloadButton->Enable( false );
EditorSizer->Add( m_ReloadButton, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 5 );
m_EditButton = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_edit ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_EditButton->SetToolTip( _( "Edit the lyrics" ) );
m_EditButton->Enable( false );
EditorSizer->Add( m_EditButton, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 5 );
m_SaveButton = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_doc_save ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_SaveButton->Enable( false );
m_SaveButton->SetToolTip( _( "Save the lyrics" ) );
EditorSizer->Add( m_SaveButton, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 5 );
m_WebSearchButton = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_search ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_WebSearchButton->Enable( false );
m_WebSearchButton->SetToolTip( _( "Search the lyrics on the web" ) );
EditorSizer->Add( m_WebSearchButton, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 );
wxStaticText * ArtistStaticText = new wxStaticText( this, wxID_ANY, _( "Artist:" ), wxDefaultPosition, wxDefaultSize, 0 );
ArtistStaticText->Wrap( -1 );
EditorSizer->Add( ArtistStaticText, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT, 5 );
m_ArtistTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_ArtistTextCtrl->Enable( !m_UpdateEnabled );
EditorSizer->Add( m_ArtistTextCtrl, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 );
wxStaticText * TrackStaticText = new wxStaticText( this, wxID_ANY, _( "Track:" ), wxDefaultPosition, wxDefaultSize, 0 );
TrackStaticText->Wrap( -1 );
EditorSizer->Add( TrackStaticText, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT, 5 );
m_TrackTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_TrackTextCtrl->Enable( !m_UpdateEnabled );
EditorSizer->Add( m_TrackTextCtrl, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 );
m_TitleSizer->Add( EditorSizer, 1, wxEXPAND, 5 );
wxStaticLine * TopLine;
TopLine = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
m_TitleSizer->Add( TopLine, 0, wxEXPAND|wxALL, 5 );
m_LyricTitle = new wxStaticText( this, wxID_ANY, wxT( "/" ) );
m_TitleSizer->Add( m_LyricTitle, 0, wxALL|m_LyricAlign, 5 );
MainSizer->Add( m_TitleSizer, 0, wxEXPAND, 5 );
//m_LyricText = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
m_LyricText = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, m_LyricAlign|wxTE_WORDWRAP|wxTE_MULTILINE|wxNO_BORDER );
m_EditModeFGColor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
m_EditModeBGColor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
m_LyricText->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWFRAME ) );
m_LyricText->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ) );
m_LyricText->SetFont( CurrentFont );
CurrentFont.SetPointSize( CurrentFont.GetPointSize() + 2 );
CurrentFont.SetWeight( wxFONTWEIGHT_BOLD );
m_LyricTitle->SetFont( CurrentFont );
MainSizer->Add( m_LyricText, 1, wxALL|wxEXPAND, 5 );
this->SetSizer( MainSizer );
this->Layout();
SetDropTarget( new guLyricsPanelDropTarget( this ) );
m_LyricText->SetDropTarget( new guLyricsPanelDropTarget( this ) );
m_LyricTextTimer.SetOwner( this );
m_UpdateCheckBox->Bind( wxEVT_CHECKBOX, &guLyricsPanel::OnUpdateChkBoxClicked, this );
m_SetupButton->Bind( wxEVT_BUTTON, &guLyricsPanel::OnSetupSelected, this );
m_ReloadButton->Bind( wxEVT_BUTTON, &guLyricsPanel::OnReloadBtnClick, this );
m_EditButton->Bind( wxEVT_BUTTON, &guLyricsPanel::OnEditBtnClick, this );
m_SaveButton->Bind( wxEVT_BUTTON, &guLyricsPanel::OnSaveBtnClick, this );
m_WebSearchButton->Bind( wxEVT_BUTTON, &guLyricsPanel::OnWebSearchBtnClick, this );
m_ArtistTextCtrl->Bind( wxEVT_TEXT, &guLyricsPanel::OnTextUpdated, this );
m_TrackTextCtrl->Bind( wxEVT_TEXT, &guLyricsPanel::OnTextUpdated, this );
Bind( wxEVT_TIMER, &guLyricsPanel::OnTextTimer, this );
m_LyricText->Bind( wxEVT_CONTEXT_MENU, &guLyricsPanel::OnContextMenu, this );
Bind( wxEVT_MENU, &guLyricsPanel::OnLyricsCopy, this, ID_LYRICS_COPY );
Bind( wxEVT_MENU, &guLyricsPanel::OnLyricsPaste, this, ID_LYRICS_PASTE );
Bind( wxEVT_MENU, &guLyricsPanel::OnLyricsPrint, this, ID_LYRICS_PRINT );
Bind( guConfigUpdatedEvent, &guLyricsPanel::OnConfigUpdated, this, ID_CONFIG_UPDATED );
Bind( wxEVT_MENU, &guLyricsPanel::OnLyricFound, this, ID_LYRICS_LYRICFOUND );
}
// -------------------------------------------------------------------------------- //
guLyricsPanel::~guLyricsPanel()
{
// // Save the current selected server
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->WriteBool( CONFIG_KEY_LYRICS_FOLLOW_PLAYER, m_UpdateEnabled, CONFIG_PATH_LYRICS );
Config->UnRegisterObject( this );
m_UpdateCheckBox->Unbind( wxEVT_CHECKBOX, &guLyricsPanel::OnUpdateChkBoxClicked, this );
m_SetupButton->Unbind( wxEVT_BUTTON, &guLyricsPanel::OnSetupSelected, this );
m_ReloadButton->Unbind( wxEVT_BUTTON, &guLyricsPanel::OnReloadBtnClick, this );
m_EditButton->Unbind( wxEVT_BUTTON, &guLyricsPanel::OnEditBtnClick, this );
m_SaveButton->Unbind( wxEVT_BUTTON, &guLyricsPanel::OnSaveBtnClick, this );
m_WebSearchButton->Unbind( wxEVT_BUTTON, &guLyricsPanel::OnWebSearchBtnClick, this );
m_ArtistTextCtrl->Unbind( wxEVT_TEXT, &guLyricsPanel::OnTextUpdated, this );
m_TrackTextCtrl->Unbind( wxEVT_TEXT, &guLyricsPanel::OnTextUpdated, this );
Unbind( wxEVT_TIMER, &guLyricsPanel::OnTextTimer, this );
m_LyricText->Unbind( wxEVT_CONTEXT_MENU, &guLyricsPanel::OnContextMenu, this );
Unbind( wxEVT_MENU, &guLyricsPanel::OnLyricsCopy, this, ID_LYRICS_COPY );
Unbind( wxEVT_MENU, &guLyricsPanel::OnLyricsPaste, this, ID_LYRICS_PASTE );
Unbind( wxEVT_MENU, &guLyricsPanel::OnLyricsPrint, this, ID_LYRICS_PRINT );
Unbind( guConfigUpdatedEvent, &guLyricsPanel::OnConfigUpdated, this, ID_CONFIG_UPDATED );
Unbind( wxEVT_MENU, &guLyricsPanel::OnLyricFound, this, ID_LYRICS_LYRICFOUND );
if( m_LyricSearchContext )
{
delete m_LyricSearchContext;
}
if( m_CurrentTrack )
{
delete m_CurrentTrack;
}
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::OnConfigUpdated( wxCommandEvent &event )
{
int Flags = event.GetInt();
if( Flags & guPREFERENCE_PAGE_FLAG_LYRICS )
{
guConfig * Config = ( guConfig * ) guConfig::Get();
if( Config )
{
wxFont CurrentFont;
CurrentFont.SetNativeFontInfo( Config->ReadStr( CONFIG_KEY_LYRICS_FONT, wxEmptyString, CONFIG_PATH_LYRICS ) );
if( !CurrentFont.IsOk() )
{
wxLogError( wxT( "Font was not correctly loaded from preferences..." ) );
CurrentFont = GetFont();
}
m_LyricText->SetWindowStyle( m_LyricText->GetWindowStyle() ^ m_LyricAlign );
m_LyricAlign = LyricAligns[ Config->ReadNum( CONFIG_KEY_LYRICS_TEXT_ALIGN, 1, CONFIG_PATH_LYRICS ) ];
m_LyricText->SetWindowStyle( m_LyricText->GetWindowStyle() | m_LyricAlign );
m_LyricText->SetDefaultStyle( wxTextAttr( m_LyricTitle->GetForegroundColour(),
m_LyricTitle->GetBackgroundColour(),
CurrentFont ) );
SetText( m_LyricText->GetValue() );
CurrentFont.SetPointSize( CurrentFont.GetPointSize() + 2 );
CurrentFont.SetWeight( wxFONTWEIGHT_BOLD );
m_LyricTitle->SetFont( CurrentFont );
m_TitleSizer->Detach( m_LyricTitle );
m_TitleSizer->Add( m_LyricTitle, 0, wxALL|m_LyricAlign, 5 );
Layout();
}
}
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::OnContextMenu( wxContextMenuEvent &event )
{
wxMenu Menu;
wxPoint Point = event.GetPosition();
// If from keyboard
if( Point.x == -1 && Point.y == -1 )
{
wxSize Size = GetSize();
Point.x = Size.x / 2;
Point.y = Size.y / 2;
}
else
{
Point = ScreenToClient( Point );
}
CreateContextMenu( &Menu );
PopupMenu( &Menu, Point.x, Point.y );
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::CreateContextMenu( wxMenu * menu )
{
wxMenuItem * MenuItem;
MenuItem = new wxMenuItem( menu, ID_LYRICS_COPY, _( "Copy to Clipboard" ), _( "Copy the content of the lyric to clipboard" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_edit_copy ) );
menu->Append( MenuItem );
wxTheClipboard->UsePrimarySelection( false );
if( wxTheClipboard->Open() )
{
if( wxTheClipboard->IsSupported( wxDF_TEXT ) )
{
wxTextDataObject data;
if( wxTheClipboard->GetData( data ) )
{
MenuItem = new wxMenuItem( menu, ID_LYRICS_PASTE, _( "Paste" ), _( "Paste the content of the lyric from clipboard" ) );
menu->Append( MenuItem );
}
}
wxTheClipboard->Close();
}
menu->AppendSeparator();
MenuItem = new wxMenuItem( menu, ID_LYRICS_PRINT, _( "Print" ), _( "Print the content of the lyrics" ) );
//MenuItem->SetBitmap( guImage( guIMAGE_INDEX_ ) );
menu->Append( MenuItem );
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::SetCurrentTrack( const guTrack * track )
{
if( m_UpdateEnabled )
{
if( m_CurrentTrack )
{
delete m_CurrentTrack;
m_CurrentTrack = NULL;
}
guTrackChangeInfo ChangeInfo;
if( track )
{
ChangeInfo.m_ArtistName = track->m_ArtistName;
ChangeInfo.m_TrackName = track->m_SongName;
ChangeInfo.m_MediaViewer = track->m_MediaViewer;
m_CurrentTrack = new guTrack( * track );
}
m_CurrentTrackInfo = ChangeInfo;
m_LastSourceName = m_LastLyricText = m_CurrentLyricText = wxEmptyString;
SetTrack( &ChangeInfo );
m_CurrentLyricText = wxEmptyString;
wxCommandEvent event( wxEVT_MENU, ID_MAINFRAME_UPDATE_SELINFO );
AddPendingEvent( event );
m_WebSearchButton->Enable( m_CurrentTrack );
}
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::OnSetCurrentTrack( wxCommandEvent &event )
{
SetCurrentTrack( ( guTrack * ) event.GetClientData() );
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::OnTextUpdated( wxCommandEvent& event )
{
bool IsEnable = !m_ArtistTextCtrl->GetValue().IsEmpty() &&
!m_TrackTextCtrl->GetValue().IsEmpty();
m_ReloadButton->Enable( IsEnable );
m_WebSearchButton->Enable( IsEnable );
if( m_LyricSearchContext )
{
delete m_LyricSearchContext;
m_LyricSearchContext = NULL;
}
// if( !m_CurrentLyricText.IsEmpty() )
// {
// SetText( ( m_CurrentLyricText = wxEmptyString ) );
// }
SetTitle( m_TrackTextCtrl->GetValue() + wxT( " / " ) + m_ArtistTextCtrl->GetValue() );
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::OnUpdateChkBoxClicked( wxCommandEvent& event )
{
SetAutoUpdate( m_UpdateCheckBox->IsChecked() );
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::SetAutoUpdate( const bool autoupdate )
{
m_UpdateEnabled = autoupdate;
if( m_UpdateEnabled != m_UpdateCheckBox->IsChecked() )
{
m_UpdateCheckBox->SetValue( autoupdate );
}
if( m_UpdateEnabled )
{
wxCommandEvent Event( wxEVT_MENU, ID_MAINFRAME_REQUEST_CURRENTTRACK );
Event.SetClientData( this );
wxPostEvent( guMainFrame::GetMainFrame(), Event );
wxCommandEvent CmdEvent( wxEVT_MENU, ID_MAINFRAME_UPDATE_SELINFO );
AddPendingEvent( CmdEvent );
}
m_ArtistTextCtrl->Enable( !m_UpdateEnabled );
m_TrackTextCtrl->Enable( !m_UpdateEnabled );
m_ReloadButton->Enable( !m_UpdateEnabled &&
!m_ArtistTextCtrl->IsEmpty() &&
!m_TrackTextCtrl->IsEmpty() );
m_WebSearchButton->Enable( m_ReloadButton->IsEnabled() );
m_EditButton->Enable( !m_CurrentLyricText.IsEmpty() );
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::OnSetupSelected( wxCommandEvent &event )
{
wxCommandEvent CmdEvent( wxEVT_MENU, ID_MENU_PREFERENCES );
CmdEvent.SetInt( guPREFERENCE_PAGE_LYRICS );
wxPostEvent( guMainFrame::GetMainFrame(), CmdEvent );
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::OnReloadBtnClick( wxCommandEvent& event )
{
if( m_UpdateEnabled )
{
wxCommandEvent CmdEvent( wxEVT_MENU, ID_MAINFRAME_LYRICSSEARCHNEXT );
wxPostEvent( guMainFrame::GetMainFrame(), CmdEvent );
guTrackChangeInfo TrackChangeInfo( m_ArtistTextCtrl->GetValue(), m_TrackTextCtrl->GetValue(), m_MediaViewer );
SetTrack( &TrackChangeInfo, true );
m_ReloadButton->Enable( false );
}
else
{
if( m_LyricSearchEngine )
{
if( !m_CurrentTrack )
{
m_CurrentTrack = new guTrack();
}
m_CurrentTrack->m_ArtistName = m_ArtistTextCtrl->GetValue();
m_CurrentTrack->m_SongName = m_TrackTextCtrl->GetValue();
SetTitle( m_TrackTextCtrl->GetValue() + wxT( " / " ) + m_ArtistTextCtrl->GetValue() );
SetText( _( "Searching..." ) );
if( !m_LyricSearchContext )
{
m_LyricSearchContext = m_LyricSearchEngine->CreateContext( this, m_CurrentTrack, false );
}
m_LyricSearchEngine->SearchStart( m_LyricSearchContext );
}
}
wxCommandEvent CmdEvent( wxEVT_MENU, ID_MAINFRAME_UPDATE_SELINFO );
AddPendingEvent( CmdEvent );
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::OnLyricFound( wxCommandEvent &event )
{
wxString * LyricText = ( wxString * ) event.GetClientData();
SetLyricText( LyricText, true );
if( LyricText )
{
delete LyricText;
}
SetLastSource( event.GetInt() );
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::OnEditBtnClick( wxCommandEvent& event )
{
m_ReloadButton->Enable( false );
m_EditButton->Enable( false );
m_SaveButton->Enable( true );
m_LyricText->SetEditable( true );
m_LyricText->SetBackgroundColour( m_EditModeBGColor );
m_LyricText->SetForegroundColour( m_EditModeFGColor );
SetText( m_CurrentLyricText );
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::OnSaveBtnClick( wxCommandEvent& event )
{
if( m_LyricText->IsModified() )
{
m_CurrentLyricText = m_LyricText->GetValue();
}
if( m_UpdateEnabled )
{
wxCommandEvent CmdEvent( wxEVT_MENU, ID_MAINFRAME_LYRICSSAVECHANGES );
CmdEvent.SetClientData( new wxString( m_CurrentLyricText ) );
wxPostEvent( guMainFrame::GetMainFrame(), CmdEvent );
}
else
{
// Need to create a context for m_CurrentTrack and send the save message for that context
if( m_LyricSearchEngine && m_CurrentTrack && !m_CurrentLyricText.IsEmpty() )
{
if( !m_LyricSearchContext )
{
m_LyricSearchContext = m_LyricSearchEngine->CreateContext( this, m_CurrentTrack, false );
}
m_LyricSearchEngine->SetLyricText( m_LyricSearchContext, m_CurrentLyricText );
}
}
m_ReloadButton->Enable( true );
m_SaveButton->Enable( false );
m_EditButton->Enable( true );
m_LyricText->SetEditable( false );
m_LyricText->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWFRAME ) );
m_LyricText->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ) );
SetText( m_CurrentLyricText );
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::OnWebSearchBtnClick( wxCommandEvent& event )
{
if( !m_ArtistTextCtrl->IsEmpty() &&
!m_TrackTextCtrl->IsEmpty() )
{
guWebExecute( wxT( "http://www.google.com/search?q=Lyrics+\"" ) +
guURLEncode( m_ArtistTextCtrl->GetValue() ) + wxT( "\"+\"" ) +
guURLEncode( m_TrackTextCtrl->GetValue() ) + wxT( "\"" ) );
}
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::SetTitle( const wxString &title )
{
wxString Label = title;
Label.Replace( wxT( "&" ), wxT( "&&" ) );
m_LyricTitle->SetLabel( Label );
Layout();
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::SetText( const wxString &text )
{
m_LyricText->SetValue( wxEmptyString );
m_LyricText->WriteText( text );
m_LyricText->SetInsertionPoint( 0 );
//guLogMessage( wxT( "SetText: '%s'" ), text.Mid( 0, 16 ).c_str() );
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::SetTrack( const guTrackChangeInfo * trackchangeinfo, const bool onlinesearch )
{
//const wxString &artist, const wxString &tracK
wxString Artist = trackchangeinfo->m_ArtistName;
wxString Track = RemoveSearchFilters( trackchangeinfo->m_TrackName );
m_LyricText->SetEditable( false );
m_LyricText->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWFRAME ) );
m_LyricText->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ) );
SetTitle( Track + wxT( " / " ) + Artist );
SetText( _( "Searching..." ) );
m_ArtistTextCtrl->SetValue( Artist );
m_TrackTextCtrl->SetValue( Track );
m_ReloadButton->Enable( false );
m_EditButton->Enable( false );
m_SaveButton->Enable( false );
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::OnTextTimer( wxTimerEvent &event )
{
if( !m_LastLyricText.IsEmpty() )
{
SetText( m_LastLyricText );
m_CurrentSourceName = m_LastSourceName;
m_ReloadButton->Enable( true );
m_EditButton->Enable( true );
wxCommandEvent event( wxEVT_MENU, ID_MAINFRAME_UPDATE_SELINFO );
AddPendingEvent( event );
}
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::OnLyricsCopy( wxCommandEvent &event )
{
wxTheClipboard->UsePrimarySelection( false );
if( wxTheClipboard->Open() )
{
wxTheClipboard->Clear();
wxString CopyText = m_LyricText->GetStringSelection();
if( CopyText.IsEmpty() )
{
CopyText = m_TrackTextCtrl->GetValue() + wxT( " / " ) +
m_ArtistTextCtrl->GetValue() + wxT( "\n\n" ) +
m_CurrentLyricText;
}
if( !wxTheClipboard->AddData( new wxTextDataObject( CopyText ) ) )
{
guLogError( wxT( "Can't copy data to the clipboard" ) );
}
wxTheClipboard->Close();
}
else
{
guLogError( wxT( "Could not open the clipboard object" ) );
}
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::OnLyricsPaste( wxCommandEvent &event )
{
wxTheClipboard->UsePrimarySelection( false );
if( wxTheClipboard->Open() )
{
if( wxTheClipboard->IsSupported( wxDF_TEXT ) )
{
guLogMessage( wxT( "Pasting:" ) );
wxTextDataObject data;
if( wxTheClipboard->GetData( data ) )
{
wxString PasteLyric = data.GetText();
SetLyricText( &PasteLyric, true );
OnSaveBtnClick( event );
}
}
wxTheClipboard->Close();
}
else
{
guLogError( wxT( "Could not open the clipboard object" ) );
}
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::OnLyricsPrint( wxCommandEvent &event )
{
wxPrintData * PrintData = new wxPrintData;
if( PrintData )
{
PrintData->SetPaperId( wxPAPER_A4 );
wxPrintDialogData * PrintDialogData = new wxPrintDialogData( * PrintData );
if( PrintDialogData )
{
wxString TrackName = m_TrackTextCtrl->GetValue() + wxT( " / " ) + m_ArtistTextCtrl->GetValue();
wxHtmlPrintout Printout( TrackName );
wxString LyricText = wxString::Format( wxT( "<b>%s</b><br><br>" ), TrackName.c_str() ) +
m_CurrentLyricText;
LyricText.Replace( wxT( "\n" ), wxT( "<br>" ) );
// Printout.SetHtmlText( wxString::Format(
// ( ( m_LyricFormat == guLYRIC_FORMAT_NORMAL ) ? guLYRICS_TEMPLATE_DEFAULT : guLYRICS_TEMPLATE_ULTGUITAR ),
// wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWFRAME ).GetAsString( wxC2S_HTML_SYNTAX ).c_str(),
// wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ).GetAsString( wxC2S_HTML_SYNTAX ).c_str(),
// LyricText.c_str() ) );
wxPrinter Printer( PrintDialogData );
Printout.SetFooter( wxT( "<center>Guayadeque Music Player @DATE@ @TIME@ @PAGENUM@ - @PAGESCNT@</center>" ) );
if( Printer.Print( this, &Printout, true ) )
{
if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
guLogMessage( wxT( "There was a problem printing the lyric" ) );
}
delete PrintDialogData;
}
delete PrintData;
}
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::OnDropFiles( const wxArrayString &files )
{
// //guLogMessage( wxT( "guLastFMPanelDropTarget::OnDropFiles" ) );
guTrack Track;
if( !files.Count() )
return;
if( !m_Db->FindTrackFile( files[ 0 ], &Track ) )
{
if( !Track.ReadFromFile( files[ 0 ] ) )
{
return;
}
}
if( m_UpdateEnabled )
{
SetCurrentTrack( &Track );
SetAutoUpdate( false );
}
else
{
m_ArtistTextCtrl->SetValue( Track.m_ArtistName );
m_TrackTextCtrl->SetValue( Track.m_SongName );
if( m_CurrentTrack )
{
delete m_CurrentTrack;
m_CurrentTrack = NULL;
}
}
m_CurrentLyricText = wxEmptyString;
wxCommandEvent DummyEvent;
OnReloadBtnClick( DummyEvent );
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::OnDropFiles( const guTrackArray * tracks )
{
if( tracks && tracks->Count() )
{
const guTrack & Track= tracks->Item( 0 );
if( m_UpdateEnabled )
{
SetCurrentTrack( &Track );
SetAutoUpdate( false );
}
else
{
m_ArtistTextCtrl->SetValue( Track.m_ArtistName );
m_TrackTextCtrl->SetValue( Track.m_SongName );
if( m_CurrentTrack )
{
delete m_CurrentTrack;
m_CurrentTrack = NULL;
}
}
m_CurrentLyricText = wxEmptyString;
wxCommandEvent DummyEvent;
OnReloadBtnClick( DummyEvent );
}
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::SetLyricText( const wxString * lyrictext, const bool forceupdate )
{
if( ( m_UpdateEnabled || forceupdate ) && lyrictext )
{
if( lyrictext->IsEmpty() )
{
SetText( _( "No lyrics found" ) );
//guLogMessage( wxT( "Current empty : %i" ), m_CurrentLyricText.IsEmpty() );
if( !m_LastLyricText.IsEmpty() )
{
if( m_LyricTextTimer.IsRunning() )
m_LyricTextTimer.Stop();
m_LyricTextTimer.Start( 3000, wxTIMER_ONE_SHOT );
}
m_EditButton->Enable( m_CurrentTrack );
}
else
{
SetText( * lyrictext );
m_SaveButton->Enable( m_CurrentTrack && !m_UpdateEnabled );
m_LastLyricText = m_CurrentLyricText = * lyrictext;
}
}
m_ReloadButton->Enable( true );
m_EditButton->Enable( m_CurrentTrack );
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::SetLastSource( const int sourceindex )
{
//guLogMessage( wxT( "Setting the lyrics source index to %i" ), sourceindex );
if( sourceindex == wxNOT_FOUND )
{
m_CurrentSourceName = wxEmptyString;
}
else
{
guLyricSource * LyricSource = m_LyricSearchEngine->GetSource( sourceindex );
if( LyricSource )
{
m_LastSourceName = m_CurrentSourceName = LyricSource->Name();
}
}
wxCommandEvent event( wxEVT_MENU, ID_MAINFRAME_UPDATE_SELINFO );
AddPendingEvent( event );
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::UpdatedTracks( const guTrackArray * tracks )
{
if( !m_CurrentTrack )
return;
int Count = tracks->Count();
for( int Index = 0; Index < Count; Index++ )
{
guTrack * Track = &tracks->Item( Index );
if( Track->m_FileName == m_CurrentTrack->m_FileName )
{
SetCurrentTrack( Track );
wxCommandEvent Event( wxEVT_MENU, ID_MAINFRAME_LYRICSSEARCHFIRST );
wxPostEvent( guMainFrame::GetMainFrame(), Event );
return;
}
}
}
// -------------------------------------------------------------------------------- //
void guLyricsPanel::UpdatedTrack( const guTrack * track )
{
if( track->m_FileName == m_CurrentTrack->m_FileName )
{
SetCurrentTrack( track );
wxCommandEvent Event( wxEVT_MENU, ID_MAINFRAME_LYRICSSEARCHFIRST );
wxPostEvent( guMainFrame::GetMainFrame(), Event );
}
}
// -------------------------------------------------------------------------------- //
wxString guLyricsPanel::GetLyricSource( void )
{
if( !m_CurrentLyricText.IsEmpty() )
{
return _( "Lyrics from " ) + m_CurrentSourceName;
}
else if( m_LyricText->GetValue() == _( "Searching..." ) )
{
return _( "Searching..." );
}
else
{
return _( "No lyrics found" );
}
}
// -------------------------------------------------------------------------------- //
// guLyricsPanelDropTarget
// -------------------------------------------------------------------------------- //
guLyricsPanelDropTarget::guLyricsPanelDropTarget( guLyricsPanel * lyricspanel ) : wxDropTarget()
{
m_LyricsPanel = lyricspanel;
wxDataObjectComposite * DataObject = new wxDataObjectComposite();
wxCustomDataObject * TracksDataObject = new wxCustomDataObject( wxDataFormat( wxT( "x-gutracks/guayadeque-copied-tracks" ) ) );
DataObject->Add( TracksDataObject, true );
wxFileDataObject * FileDataObject = new wxFileDataObject();
DataObject->Add( FileDataObject, false );
SetDataObject( DataObject );
}
// -------------------------------------------------------------------------------- //
guLyricsPanelDropTarget::~guLyricsPanelDropTarget()
{
}
// -------------------------------------------------------------------------------- //
wxDragResult guLyricsPanelDropTarget::OnData( wxCoord x, wxCoord y, wxDragResult def )
{
//guLogMessage( wxT( "guListViewDropTarget::OnData" ) );
if( def == wxDragError || def == wxDragNone || def == wxDragCancel )
return def;
if( !GetData() )
{
guLogMessage( wxT( "Error getting drop data" ) );
return wxDragError;
}
guDataObjectComposite * DataObject = ( guDataObjectComposite * ) m_dataObject;
wxDataFormat ReceivedFormat = DataObject->GetReceivedFormat();
//guLogMessage( wxT( "ReceivedFormat: '%s'" ), ReceivedFormat.GetId().c_str() );
if( ReceivedFormat == wxDataFormat( wxT( "x-gutracks/guayadeque-copied-tracks" ) ) )
{
guTrackArray * Tracks;
if( !DataObject->GetDataHere( ReceivedFormat, &Tracks ) )
{
guLogMessage( wxT( "Error getting tracks data..." ) );
}
else
{
m_LyricsPanel->OnDropFiles( Tracks );
}
}
else if( ReceivedFormat == wxDataFormat( wxDF_FILENAME ) )
{
wxFileDataObject * FileDataObject = ( wxFileDataObject * ) DataObject->GetDataObject( wxDataFormat( wxDF_FILENAME ) );
if( FileDataObject )
{
m_LyricsPanel->OnDropFiles( FileDataObject->GetFilenames() );
}
}
return def;
}
// -------------------------------------------------------------------------------- //
// guLyricSearchContext
// -------------------------------------------------------------------------------- //
guLyricSearchContext::~guLyricSearchContext()
{
m_LyricSearchEngine->RemoveContextThread( this );
}
// -------------------------------------------------------------------------------- //
bool guLyricSearchContext::GetNextSource( guLyricSource * lyricsource, const bool allowloop )
{
return m_LyricSearchEngine->GetNextSource( this, lyricsource, allowloop );
}
// -------------------------------------------------------------------------------- //
// guLyricSourceOption
// -------------------------------------------------------------------------------- //
guLyricSourceOption::guLyricSourceOption( wxXmlNode * xmlnode, const wxString &tag1, const wxString &tag2 )
{
if( xmlnode )
{
xmlnode->GetAttribute( tag1, &m_Text1 );
if( !tag2.IsEmpty() )
{
xmlnode->GetAttribute( tag2, &m_Text2 );
}
}
}
// -------------------------------------------------------------------------------- //
guLyricSourceExtract::guLyricSourceExtract( wxXmlNode * xmlnode )
{
if( xmlnode )
{
if( xmlnode->HasAttribute( wxT( "tag" ) ) )
{
xmlnode->GetAttribute( wxT( "tag" ), &m_Text1 );
}
else
{
xmlnode->GetAttribute( wxT( "begin" ), &m_Text1 );
xmlnode->GetAttribute( wxT( "end" ), &m_Text2 );
}
}
}
// -------------------------------------------------------------------------------- //
// guLyricSource
// -------------------------------------------------------------------------------- //
guLyricSource::guLyricSource( wxXmlNode * xmlnode )
{
if( xmlnode )
{
wxString TypeStr;
xmlnode->GetAttribute( wxT( "type" ), &TypeStr );
if( TypeStr == wxT( "download" ) )
{
m_Type = guLYRIC_SOURCE_TYPE_DOWNLOAD;
}
else if( TypeStr == wxT( "file" ) )
{
m_Type = guLYRIC_SOURCE_TYPE_FILE;
}
else if( TypeStr == wxT( "command" ) )
{
m_Type = guLYRIC_SOURCE_TYPE_COMMAND;
}
else if( TypeStr == wxT( "embedded" ) )
{
m_Type = guLYRIC_SOURCE_TYPE_EMBEDDED;
}
wxString EnabledStr;
xmlnode->GetAttribute( wxT( "enabled" ), &EnabledStr );
m_Enabled = ( EnabledStr == wxT( "true" ) );
xmlnode->GetAttribute( wxT( "name" ), &m_Name );
xmlnode->GetAttribute( wxT( "source" ), &m_Source );
xmlnode = xmlnode->GetChildren();
while( xmlnode )
{
wxString NodeName = xmlnode->GetName();
if( NodeName == wxT( "replace" ) )
{
ReadReplaceItems( xmlnode->GetChildren() );
}
else if( NodeName == wxT( "extract" ) )
{
ReadExtractItems( xmlnode->GetChildren() );
}
else if( NodeName == wxT( "exclude" ) )
{
ReadExcludeItems( xmlnode->GetChildren() );
}
else if( NodeName == wxT( "notfound" ) )
{
ReadNotFoundItems( xmlnode->GetChildren() );
}
xmlnode = xmlnode->GetNext();
}
}
}
// -------------------------------------------------------------------------------- //
void guLyricSource::ReadReplaceItems( wxXmlNode * xmlnode )
{
while( xmlnode )
{
guLyricSourceReplace * LyricSourceReplace = new guLyricSourceReplace( xmlnode );
m_ReplaceItems.Add( LyricSourceReplace );
xmlnode = xmlnode->GetNext();
}
}
// -------------------------------------------------------------------------------- //
void guLyricSource::ReadExtractItems( wxXmlNode * xmlnode )
{
while( xmlnode )
{
guLyricSourceExtract * LyricSourceExtract = new guLyricSourceExtract( xmlnode );
m_ExtractItems.Add( LyricSourceExtract );
xmlnode = xmlnode->GetNext();
}
}
// -------------------------------------------------------------------------------- //
void guLyricSource::ReadExcludeItems( wxXmlNode * xmlnode )
{
while( xmlnode )
{
guLyricSourceExclude * LyricSourceExclude = new guLyricSourceExclude( xmlnode );
m_ExcludeItems.Add( LyricSourceExclude );
xmlnode = xmlnode->GetNext();
}
}
// -------------------------------------------------------------------------------- //
void guLyricSource::ReadNotFoundItems( wxXmlNode * xmlnode )
{
while( xmlnode )
{
wxString NotFoundMsg;
xmlnode->GetAttribute( wxT( "tag" ), &NotFoundMsg );
m_NotFoundItems.Add( NotFoundMsg );
xmlnode = xmlnode->GetNext();
}
}
// -------------------------------------------------------------------------------- //
wxString guCharsReplace( const wxString &text, const wxString &bannedchars, const wxString &replacechar )
{
wxString RetVal;
int Count = text.Length();
for( int Index = 0; Index < Count; Index++ )
{
wxChar C = text[ Index ];
if( wxStrchr( bannedchars, C ) )
C = replacechar[ 0 ];
RetVal.Append( C );
}
return RetVal;
}
// -------------------------------------------------------------------------------- //
wxString guLyricSource::SourceFieldClean( const wxString &field )
{
wxString RetVal = field;
int Count = m_ReplaceItems.Count();
for( int Index = 0; Index < Count; Index++ )
{
guLyricSourceReplace SourceReplace = m_ReplaceItems[ Index ];
RetVal = guCharsReplace( RetVal, SourceReplace.Search(), SourceReplace.Replace() );
}
return RetVal;
}
// -------------------------------------------------------------------------------- //
// guLyricSearchEngine
// -------------------------------------------------------------------------------- //
guLyricSearchEngine::guLyricSearchEngine()
{
LoadDisabledGenres();
// Load the search engines...
Load();
}
// -------------------------------------------------------------------------------- //
guLyricSearchEngine::~guLyricSearchEngine()
{
m_LyricSearchThreadsMutex.Lock();
int Count;
if( ( Count = m_LyricSearchThreads.Count() ) )
{
for( int Index = 0; Index < Count; Index++ )
{
guLyricSearchThread * LyrycSearchThread = m_LyricSearchThreads[ Index ];
LyrycSearchThread->Pause();
LyrycSearchThread->Delete();
}
}
m_LyricSearchThreadsMutex.Unlock();
}
// -------------------------------------------------------------------------------- //
void guLyricSearchEngine::ReadSources( wxXmlNode * xmlnode )
{
while( xmlnode && xmlnode->GetName() == wxT( "lyricsource" ) )
{
guLyricSource * LyricSource = new guLyricSource( xmlnode );
m_LyricSources.Add( LyricSource );
xmlnode = xmlnode->GetNext();
}
}
// -------------------------------------------------------------------------------- //
void guLyricSearchEngine::ReadTargets( wxXmlNode * xmlnode )
{
while( xmlnode && xmlnode->GetName() == wxT( "lyrictarget" ) )
{
guLyricSource * LyricTarget = new guLyricSource( xmlnode );
m_LyricTargets.Add( LyricTarget );
if( !m_TargetsEnabled )
{
if( LyricTarget->Enabled() )
m_TargetsEnabled = true;
}
xmlnode = xmlnode->GetNext();
}
}
// -------------------------------------------------------------------------------- //
void guLyricSearchEngine::LoadDisabledGenres()
{
// Load the lyrics disabled genres
guConfig * Config = guConfig::Get();
m_LyricDisabledGenres = Config->ReadAStr( CONFIG_KEY_LYRICS_DISGENRE, wxEmptyString, CONFIG_PATH_LYRICS_DISGENRES );
}
// -------------------------------------------------------------------------------- //
void guLyricSearchEngine::Load( void )
{
//
m_LyricSources.Empty();
m_LyricTargets.Empty();
m_TargetsEnabled = false;
wxString LyricsConfFile = wxGetHomeDir() + wxT( "/.guayadeque/lyrics_sources.xml" );
if( wxFileExists( LyricsConfFile ) )
{
wxFileInputStream Ins( LyricsConfFile );
if( Ins.IsOk() )
{
wxXmlDocument XmlDoc( Ins );
wxXmlNode * XmlNode = XmlDoc.GetRoot();
//guLogMessage( wxT( "Reading: %s" ), XmlNode->GetName().c_str() );
if( XmlNode && XmlNode->GetName() == wxT( "lyricengine" ) )
{
XmlNode = XmlNode->GetChildren();
while( XmlNode )
{
//guLogMessage( wxT( "Reading: %s" ), XmlNode->GetName().c_str() );
if( XmlNode->GetName() == wxT( "lyricsources" ) )
{
ReadSources( XmlNode->GetChildren() );
}
else if( XmlNode->GetName() == wxT( "lyrictargets" ) )
{
ReadTargets( XmlNode->GetChildren() );
}
XmlNode = XmlNode->GetNext();
}
}
}
}
else
{
guLogError( wxT( "The lyrics source configuration file was not found" ) );
}
}
// -------------------------------------------------------------------------------- //
bool guLyricSearchEngine::GetNextSource( guLyricSearchContext * context, guLyricSource * source, const bool allowloop )
{
bool LoopedOnce = false;
int CurrentIndex = context->m_CurrentIndex;
while( true )
{
CurrentIndex++;
if( CurrentIndex >= ( int ) m_LyricSources.Count() )
{
if( allowloop && !LoopedOnce )
{
LoopedOnce = true;
CurrentIndex = 0;
}
else
{
context->m_CurrentIndex = wxNOT_FOUND;
break;
}
}
if( m_LyricSources[ CurrentIndex ].Enabled() )
{
* source = m_LyricSources[ CurrentIndex ];
context->m_CurrentIndex = CurrentIndex;
return true;
}
}
return false;
}
// -------------------------------------------------------------------------------- //
void guLyricSearchEngine::SourceMoveUp( const int index )
{
m_LyricSearchThreadsMutex.Lock();
guLyricSource * LyricSource = m_LyricSources.Detach( index );
m_LyricSources.Insert( LyricSource, index - 1 );
m_LyricSearchThreadsMutex.Unlock();
}
// -------------------------------------------------------------------------------- //
void guLyricSearchEngine::SourceMoveDown( const int index )
{
m_LyricSearchThreadsMutex.Lock();
guLyricSource * LyricSource = m_LyricSources.Detach( index );
m_LyricSources.Insert( LyricSource, index + 1 );
m_LyricSearchThreadsMutex.Unlock();
}
// -------------------------------------------------------------------------------- //
void guLyricSearchEngine::TargetMoveUp( const int index )
{
m_LyricSearchThreadsMutex.Lock();
guLyricSource * LyricTarget = m_LyricTargets.Detach( index );
m_LyricTargets.Insert( LyricTarget, index - 1 );
m_LyricSearchThreadsMutex.Unlock();
}
// -------------------------------------------------------------------------------- //
void guLyricSearchEngine::TargetMoveDown( const int index )
{
m_LyricSearchThreadsMutex.Lock();
guLyricSource * LyricTarget = m_LyricTargets.Detach( index );
m_LyricTargets.Insert( LyricTarget, index + 1 );
m_LyricSearchThreadsMutex.Unlock();
}
// -------------------------------------------------------------------------------- //
void SaveLyricNotFound( wxXmlNode * xmlnode, guLyricSource * lyricsource )
{
int Count;
if( !( Count = lyricsource->NotFoundCount() ) )
return;
wxXmlNode * NotFoundNode = new wxXmlNode( wxXML_ELEMENT_NODE, wxT( "notfound" ) );
for( int Index = 0; Index < Count; Index++ )
{
wxString NotFoundTag = lyricsource->NotFoundItem( Index );
wxXmlNode * ItemNode = new wxXmlNode( wxXML_ELEMENT_NODE, wxT( "item" ) );
wxXmlAttribute * TagProperty = new wxXmlAttribute( wxT( "tag" ), NotFoundTag, NULL );
ItemNode->SetAttributes( TagProperty );
NotFoundNode->AddChild( ItemNode );
}
xmlnode->AddChild( NotFoundNode );
}
// -------------------------------------------------------------------------------- //
void SaveLyricExclude( wxXmlNode * xmlnode, guLyricSource * lyricsource )
{
int Count;
if( !( Count = lyricsource->ExcludeCount() ) )
return;
wxXmlNode * ExcludeNode = new wxXmlNode( wxXML_ELEMENT_NODE, wxT( "exclude" ) );
for( int Index = 0; Index < Count; Index++ )
{
guLyricSourceExtract * ExcludeItem = lyricsource->ExcludeItem( Index );
wxXmlNode * ItemNode = new wxXmlNode( wxXML_ELEMENT_NODE, wxT( "item" ) );
if( ExcludeItem->IsSingleOption() )
{
wxXmlAttribute * TagProperty = new wxXmlAttribute( wxT( "tag" ), ExcludeItem->Tag(), NULL );
ItemNode->SetAttributes( TagProperty );
}
else
{
wxXmlAttribute * EndProperty = new wxXmlAttribute( wxT( "end" ), ExcludeItem->End(), NULL );
wxXmlAttribute * BeginProperty = new wxXmlAttribute( wxT( "begin" ), ExcludeItem->Begin(), EndProperty );
ItemNode->SetAttributes( BeginProperty );
}
ExcludeNode->AddChild( ItemNode );
}
xmlnode->AddChild( ExcludeNode );
}
// -------------------------------------------------------------------------------- //
void SaveLyricExtract( wxXmlNode * xmlnode, guLyricSource * lyricsource )
{
int Count;
if( !( Count = lyricsource->ExtractCount() ) )
return;
wxXmlNode * ExtractNode = new wxXmlNode( wxXML_ELEMENT_NODE, wxT( "extract" ) );
for( int Index = 0; Index < Count; Index++ )
{
guLyricSourceExtract * ExtractItem = lyricsource->ExtractItem( Index );
wxXmlNode * ItemNode = new wxXmlNode( wxXML_ELEMENT_NODE, wxT( "item" ) );
if( ExtractItem->IsSingleOption() )
{
wxXmlAttribute * TagProperty = new wxXmlAttribute( wxT( "tag" ), ExtractItem->Tag(), NULL );
ItemNode->SetAttributes( TagProperty );
}
else
{
wxXmlAttribute * EndProperty = new wxXmlAttribute( wxT( "end" ), ExtractItem->End(), NULL );
wxXmlAttribute * BeginProperty = new wxXmlAttribute( wxT( "begin" ), ExtractItem->Begin(), EndProperty );
ItemNode->SetAttributes( BeginProperty );
}
ExtractNode->AddChild( ItemNode );
}
xmlnode->AddChild( ExtractNode );
}
// -------------------------------------------------------------------------------- //
void SaveLyricReplace( wxXmlNode * xmlnode, guLyricSource * lyricsource )
{
int Count;
if( !( Count = lyricsource->ReplaceCount() ) )
return;
wxXmlNode * ReplaceNode = new wxXmlNode( wxXML_ELEMENT_NODE, wxT( "replace" ) );
for( int Index = 0; Index < Count; Index++ )
{
guLyricSourceReplace * ReplaceItem = lyricsource->ReplaceItem( Index );
wxXmlNode * ItemNode = new wxXmlNode( wxXML_ELEMENT_NODE, wxT( "item" ) );
wxXmlAttribute * WithProperty = new wxXmlAttribute( wxT( "with" ), ReplaceItem->Replace(), NULL );
wxXmlAttribute * ReplaceProperty = new wxXmlAttribute( wxT( "replace" ), ReplaceItem->Search(), WithProperty );
ItemNode->SetAttributes( ReplaceProperty );
ReplaceNode->AddChild( ItemNode );
}
xmlnode->AddChild( ReplaceNode );
}
// -------------------------------------------------------------------------------- //
void SaveLyricSource( wxXmlNode * xmlnode, guLyricSource * lyricsource, const wxString &tagname )
{
wxXmlNode * LyricSourceNode = new wxXmlNode( wxXML_ELEMENT_NODE, tagname );
wxXmlAttribute * SourceProperty = new wxXmlAttribute( wxT( "source" ), lyricsource->Source(), NULL );
wxXmlAttribute * NameProperty = new wxXmlAttribute( wxT( "name" ), lyricsource->Name(), SourceProperty );
wxXmlAttribute * EnabledProperty = new wxXmlAttribute( wxT( "enabled" ), lyricsource->Enabled() ? wxT( "true" ) : wxT( "false" ), NameProperty );
wxString SourceType;
if( lyricsource->Type() == guLYRIC_SOURCE_TYPE_DOWNLOAD )
SourceType = wxT( "download" );
else if( lyricsource->Type() == guLYRIC_SOURCE_TYPE_EMBEDDED )
SourceType = wxT( "embedded" );
else if( lyricsource->Type() == guLYRIC_SOURCE_TYPE_FILE )
SourceType = wxT( "file" );
else if( lyricsource->Type() == guLYRIC_SOURCE_TYPE_COMMAND )
SourceType = wxT( "command" );
else
SourceType = wxT( "invalid" );
wxXmlAttribute * TypeNode = new wxXmlAttribute( wxT( "type" ), SourceType, EnabledProperty );
LyricSourceNode->SetAttributes( TypeNode );
SaveLyricReplace( LyricSourceNode, lyricsource );
SaveLyricExtract( LyricSourceNode, lyricsource );
SaveLyricExclude( LyricSourceNode, lyricsource );
SaveLyricNotFound( LyricSourceNode, lyricsource );
xmlnode->AddChild( LyricSourceNode );
}
// -------------------------------------------------------------------------------- //
bool guLyricSearchEngine::Save( void )
{
wxXmlDocument OutXml;
wxXmlNode * RootNode = new wxXmlNode( wxXML_ELEMENT_NODE, wxT( "lyricengine" ) );
wxXmlNode * SourcesNode = new wxXmlNode( wxXML_ELEMENT_NODE, wxT( "lyricsources" ) );
int Count = m_LyricSources.Count();
for( int Index = 0; Index < Count; Index++ )
{
SaveLyricSource( SourcesNode, &m_LyricSources[ Index ], wxT( "lyricsource" ) );
}
RootNode->AddChild( SourcesNode );
wxXmlNode * TargetsNode = new wxXmlNode( wxXML_ELEMENT_NODE, wxT( "lyrictargets" ) );
Count = m_LyricTargets.Count();
for( int Index = 0; Index < Count; Index++ )
{
SaveLyricSource( TargetsNode, &m_LyricTargets[ Index ], wxT( "lyrictarget" ) );
}
RootNode->AddChild( TargetsNode );
OutXml.SetRoot( RootNode );
return OutXml.Save( wxGetHomeDir() + wxT( "/.guayadeque/lyrics_sources.xml" ) );
}
// -------------------------------------------------------------------------------- //
guLyricSearchContext * guLyricSearchEngine::CreateContext( wxEvtHandler * owner, guTrack * track, const bool dosaveprocess )
{
return new guLyricSearchContext( this, owner, track, dosaveprocess );
}
// -------------------------------------------------------------------------------- //
void guLyricSearchEngine::SearchStart( guLyricSearchContext * context )
{
RemoveContextThread( context );
m_LyricSearchThreadsMutex.Lock();
guLyricSearchThread * LyricSearchThread = new guLyricSearchThread( context );
if( LyricSearchThread )
{
m_LyricSearchThreads.Add( LyricSearchThread );
}
m_LyricSearchThreadsMutex.Unlock();
}
// -------------------------------------------------------------------------------- //
void guLyricSearchEngine::SetLyricText( guLyricSearchContext * context, const wxString &lyrictext )
{
if( !lyrictext.IsEmpty() )
{
RemoveContextThread( context );
m_LyricSearchThreadsMutex.Lock();
guLyricSearchThread * LyricSearchThread = new guLyricSearchThread( context, lyrictext, true );
if( LyricSearchThread )
{
m_LyricSearchThreads.Add( LyricSearchThread );
}
m_LyricSearchThreadsMutex.Unlock();
}
}
// -------------------------------------------------------------------------------- //
void guLyricSearchEngine::SearchFinished( guLyricSearchThread * searchthread )
{
m_LyricSearchThreadsMutex.Lock();
wxCommandEvent LyricEvent( wxEVT_MENU, ID_LYRICS_LYRICFOUND );
LyricEvent.SetInt( searchthread->LyricSearchContext()->m_CurrentIndex );
LyricEvent.SetClientData( new wxString( searchthread->LyricText() ) );
wxPostEvent( searchthread->LyricSearchContext()->Owner(), LyricEvent );
m_LyricSearchThreads.Remove( searchthread );
m_LyricSearchThreadsMutex.Unlock();
}
// -------------------------------------------------------------------------------- //
void guLyricSearchEngine::RemoveContextThread( guLyricSearchContext * searchcontext )
{
m_LyricSearchThreadsMutex.Lock();
int Count = m_LyricSearchThreads.Count();
for( int Index = 0; Index < Count; Index++ )
{
guLyricSearchThread * LyricSearchThread = m_LyricSearchThreads[ Index ];
if( LyricSearchThread->LyricSearchContext() == searchcontext )
{
LyricSearchThread->Pause();
LyricSearchThread->Delete();
m_LyricSearchThreads.RemoveAt( Index );
break;
}
}
m_LyricSearchThreadsMutex.Unlock();
}
// -------------------------------------------------------------------------------- //
// guLyricSearchThread
// -------------------------------------------------------------------------------- //
guLyricSearchThread::guLyricSearchThread( guLyricSearchContext * context, const wxString &lyrictext, const bool forcesaveprocess ) : wxThread()
{
m_LyricSearchContext = context;
m_LyricText = lyrictext;
m_ForceSaveProcess = forcesaveprocess;
m_CommandIsExecuting = false;
m_NotifyHere = NULL;
if( Create() == wxTHREAD_NO_ERROR )
{
SetPriority( WXTHREAD_DEFAULT_PRIORITY - 30 );
Run();
}
}
// -------------------------------------------------------------------------------- //
guLyricSearchThread::~guLyricSearchThread()
{
guLogDebug( "guLyricSearchThread::~guLyricSearchThread" );
if( !TestDestroy() )
{
m_LyricSearchContext->m_LyricSearchEngine->SearchFinished( this );
}
if( m_NotifyHere != NULL )
*m_NotifyHere = false;
}
// -------------------------------------------------------------------------------- //
bool guLyricSearchThread::CheckNotFound( guLyricSource &lyricsource )
{
int Count = lyricsource.NotFoundCount();
for( int Index = 0; Index < Count; Index++ )
{
wxString NotFoundLabel = lyricsource.NotFoundItem( Index );
if( m_LyricText.Find( NotFoundLabel ) != wxNOT_FOUND )
{
return true;
}
if( TestDestroy() )
break;
}
return false;
}
// -------------------------------------------------------------------------------- //
wxString DoExtractTags( const wxString &content, const wxString &begin, const wxString &end )
{
//guLogMessage( wxT( "CheckExtract: '%s' -> '%s'" ), begin.c_str(), end.c_str() );
int FoundPos = content.Find( begin );
if( FoundPos != wxNOT_FOUND )
{
wxString Content = content.Mid( FoundPos + begin.Length() );
FoundPos = Content.Find( end );
if( FoundPos != wxNOT_FOUND )
{
//guLogMessage( wxT( "Found:\n%s" ), Content.Mid( 0, FoundPos ).c_str() );
return Content.Mid( 0, FoundPos );
}
}
return wxEmptyString;
}
// -------------------------------------------------------------------------------- //
wxString DoExtractTag( const wxString &content, const wxString &tag )
{
if( content.Find( tag ) != wxNOT_FOUND )
{
wxString TagEnd = ( tag.Find( wxT( " " ) ) != wxNOT_FOUND ) ? tag.BeforeFirst( wxT( ' ' ) ) + wxT( ">" ) : tag;
TagEnd.Replace( wxT( "<" ), wxT( "</" ) );
return DoExtractTags( content, tag, TagEnd );
}
return wxEmptyString;
}
// -------------------------------------------------------------------------------- //
wxString guLyricSearchThread::CheckExtract( const wxString &content, guLyricSource &lyricsource )
{
wxString RetVal = wxEmptyString;
int Count = lyricsource.ExtractCount();
if( !Count )
return content;
for( int Index = 0; Index < Count; Index++ )
{
guLyricSourceExtract * LyricSourceExtract = lyricsource.ExtractItem( Index );
if( LyricSourceExtract->IsSingleOption() )
{
RetVal = DoExtractTag( content, LyricSourceExtract->Tag() );
}
else
{
RetVal = DoExtractTags( content, LyricSourceExtract->Begin(), LyricSourceExtract->End() );
}
if( TestDestroy() )
break;
if( !RetVal.IsEmpty() )
break;
}
return RetVal;
}
// -------------------------------------------------------------------------------- //
wxString DoExcludeTags( const wxString &content, const wxString &begin, const wxString &end )
{
int BeginPos = content.Find( begin );
if( BeginPos != wxNOT_FOUND )
{
int EndPos = content.Find( end );
if( EndPos != wxNOT_FOUND )
{
EndPos += end.Length();
return content.Mid( 0, BeginPos ) + content.Mid( EndPos );
}
}
return content;
}
// -------------------------------------------------------------------------------- //
wxString DoExcludeTag( const wxString &content, const wxString &tag )
{
if( content.Find( tag ) != wxNOT_FOUND )
{
wxString TagEnd;
if( tag.Find( wxT( " " ) ) != wxNOT_FOUND )
TagEnd = tag.BeforeFirst( wxT( ' ' ) ) + wxT( ">" );
else
TagEnd = tag;
TagEnd.Replace( wxT( "<" ), wxT( "</" ) );
return DoExcludeTags( content, tag, TagEnd );
}
return content;
}
// -------------------------------------------------------------------------------- //
wxString guLyricSearchThread::CheckExclude( const wxString &content, guLyricSource &lyricsource )
{
wxString RetVal = content;
int Count = lyricsource.ExcludeCount();
for( int Index = 0; Index < Count; Index++ )
{
guLyricSourceExclude * LyricSourceExclude = lyricsource.ExcludeItem( Index );
if( LyricSourceExclude->IsSingleOption() )
{
RetVal = DoExcludeTag( RetVal, LyricSourceExclude->Tag() );
}
else
{
RetVal = DoExcludeTags( RetVal, LyricSourceExclude->Begin(), LyricSourceExclude->End() );
}
if( TestDestroy() || RetVal.IsEmpty() )
break;
}
return RetVal;
}
// -------------------------------------------------------------------------------- //
wxString guLyricSearchThread::DoReplace( const wxString &text, const wxString &search, const wxString &replace )
{
wxString RetVal = text;
wxRegEx RegEx( wxT( "[" ) + search + wxT( "]" ) );
RegEx.Replace( &RetVal, replace );
return RetVal;
}
// -------------------------------------------------------------------------------- //
wxString guLyricSearchThread::DoReplace( const wxString &text, guLyricSource &lyricsource )
{
wxString RetVal = text;
int Count = lyricsource.ReplaceCount();
for( int Index = 0; Index < Count; Index++ )
{
guLyricSourceReplace * LyricSourceReplace = lyricsource.ReplaceItem( Index );
RetVal = DoReplace( RetVal, LyricSourceReplace->Search(), LyricSourceReplace->Replace() );
}
return guURLEncode( RetVal );
}
// -------------------------------------------------------------------------------- //
wxString SpecialCase( const wxString &text )
{
wxString RetVal;
wxArrayString Words = wxStringTokenize( text, wxT( " " ) );
int Count = Words.Count();
for( int Index = 0; Index < Count; Index++ )
{
Words[ Index ][ 0 ] = wxToupper( Words[ Index ][ 0 ] );
RetVal += Words[ Index ] + wxT( " " );
}
RetVal.Trim( 1 );
return RetVal;
}
// -------------------------------------------------------------------------------- //
void guLyricSearchThread::ProcessTags( wxString * text, guLyricSource &lyricsource )
{
guTrack * Track = &m_LyricSearchContext->m_Track;
if( text->Find( guLYRICS_ARTIST ) != wxNOT_FOUND )
text->Replace( guLYRICS_ARTIST, DoReplace( Track->m_ArtistName, lyricsource ) );
if( text->Find( guLYRICS_ARTIST_LOWER ) != wxNOT_FOUND )
text->Replace( guLYRICS_ARTIST_LOWER, DoReplace( Track->m_ArtistName.Lower(), lyricsource ) );
if( text->Find( guLYRICS_ARTIST_UPPER ) != wxNOT_FOUND )
text->Replace( guLYRICS_ARTIST_UPPER, DoReplace( Track->m_ArtistName.Upper(), lyricsource ) );
if( text->Find( guLYRICS_ARTIST_FIRST ) != wxNOT_FOUND )
text->Replace( guLYRICS_ARTIST_FIRST, DoReplace( Track->m_ArtistName.Trim( false )[ 0 ], lyricsource ) );
if( text->Find( guLYRICS_ARTIST_LOWER_FIRST ) != wxNOT_FOUND )
text->Replace( guLYRICS_ARTIST_LOWER_FIRST, DoReplace( Track->m_ArtistName.Lower().Trim( false )[ 0 ], lyricsource ) );
if( text->Find( guLYRICS_ARTIST_UPPER_FIRST ) != wxNOT_FOUND )
text->Replace( guLYRICS_ARTIST_UPPER_FIRST, DoReplace( Track->m_ArtistName.Upper().Trim( false )[ 0 ], lyricsource ) );
if( text->Find( guLYRICS_ARTIST_CAPITALIZE ) )
text->Replace( guLYRICS_ARTIST_CAPITALIZE, DoReplace( SpecialCase( Track->m_ArtistName.Lower() ), lyricsource ) );
if( text->Find( guLYRICS_ALBUM ) != wxNOT_FOUND )
text->Replace( guLYRICS_ALBUM, DoReplace( Track->m_AlbumName, lyricsource ) );
if( text->Find( guLYRICS_ALBUM_LOWER ) != wxNOT_FOUND )
text->Replace( guLYRICS_ALBUM_LOWER, DoReplace( Track->m_AlbumName.Lower(), lyricsource ) );
if( text->Find( guLYRICS_ALBUM_UPPER ) != wxNOT_FOUND )
text->Replace( guLYRICS_ALBUM_UPPER, DoReplace( Track->m_AlbumName.Upper(), lyricsource ) );
if( text->Find( guLYRICS_ALBUM_FIRST ) != wxNOT_FOUND )
text->Replace( guLYRICS_ALBUM_FIRST, DoReplace( Track->m_AlbumName.Trim( false )[ 0 ], lyricsource ) );
if( text->Find( guLYRICS_ALBUM_LOWER_FIRST ) != wxNOT_FOUND )
text->Replace( guLYRICS_ALBUM_LOWER_FIRST, DoReplace( Track->m_AlbumName.Lower().Trim( false )[ 0 ], lyricsource ) );
if( text->Find( guLYRICS_ALBUM_UPPER_FIRST ) != wxNOT_FOUND )
text->Replace( guLYRICS_ALBUM_UPPER_FIRST, DoReplace( Track->m_AlbumName.Upper().Trim( false )[ 0 ], lyricsource ) );
if( text->Find( guLYRICS_ALBUM_CAPITALIZE ) )
text->Replace( guLYRICS_ALBUM_CAPITALIZE, DoReplace( SpecialCase( Track->m_AlbumName.Lower() ), lyricsource ) );
if( text->Find( guLYRICS_ALBUM_PATH ) != wxNOT_FOUND )
text->Replace( guLYRICS_ALBUM_PATH, Track->m_FileName.BeforeLast( wxT( '/' ) ) );
if( text->Find( guLYRICS_TITLE ) != wxNOT_FOUND )
text->Replace( guLYRICS_TITLE, DoReplace( Track->m_SongName, lyricsource ) );
if( text->Find( guLYRICS_TITLE_LOWER ) != wxNOT_FOUND )
text->Replace( guLYRICS_TITLE_LOWER, DoReplace( Track->m_SongName.Lower(), lyricsource ) );
if( text->Find( guLYRICS_TITLE_UPPER ) != wxNOT_FOUND )
text->Replace( guLYRICS_TITLE_UPPER, DoReplace( Track->m_SongName.Upper(), lyricsource ) );
if( text->Find( guLYRICS_TITLE_FIRST ) != wxNOT_FOUND )
text->Replace( guLYRICS_TITLE_FIRST, DoReplace( Track->m_SongName.Trim( false )[ 0 ], lyricsource ) );
if( text->Find( guLYRICS_TITLE_LOWER_FIRST ) != wxNOT_FOUND )
text->Replace( guLYRICS_TITLE_LOWER_FIRST, DoReplace( Track->m_SongName.Lower().Trim( false )[ 0 ], lyricsource ) );
if( text->Find( guLYRICS_TITLE_UPPER_FIRST ) != wxNOT_FOUND )
text->Replace( guLYRICS_TITLE_UPPER_FIRST, DoReplace( Track->m_SongName.Upper().Trim( false )[ 0 ], lyricsource ) );
if( text->Find( guLYRICS_TITLE_CAPITALIZE ) )
text->Replace( guLYRICS_TITLE_CAPITALIZE, DoReplace( SpecialCase( Track->m_SongName.Lower() ), lyricsource ) );
if( text->Find( guLYRICS_FILENAME ) != wxNOT_FOUND )
text->Replace( guLYRICS_FILENAME, Track->m_FileName.BeforeLast( wxT( '.' ) ) );
}
// -------------------------------------------------------------------------------- //
wxString guLyricSearchThread::GetSource( guLyricSource &lyricsource )
{
wxString RetVal = lyricsource.Source();
ProcessTags( &RetVal, lyricsource );
return RetVal;
}
// -------------------------------------------------------------------------------- //
void guLyricSearchThread::LyricDownload( guLyricSource &lyricsource )
{
wxString Url = GetSource( lyricsource );
guLogMessage( wxT( "Trying to get url: %s" ), Url.c_str() );
m_LyricText = GetUrlContent( Url, wxEmptyString, true );
//guLogMessage( wxT( "Content: '%s'" ), m_LyricText.c_str() );
}
// -------------------------------------------------------------------------------- //
void guLyricSearchThread::LyricFile( guLyricSource &lyricsource )
{
wxString FilePath = GetSource( lyricsource );
wxFileName FileName( FilePath );
if( FileName.Normalize( wxPATH_NORM_ALL|wxPATH_NORM_CASE ) )
{
if( wxFileExists( FileName.GetFullPath() ) )
{
wxFileInputStream Ins( FileName.GetFullPath() );
if( Ins.IsOk() )
{
wxStringOutputStream Outs( &m_LyricText );
Ins.Read( Outs );
}
}
// else
// {
// guLogMessage( wxT( "File not found: '%s'" ), FileName.GetFullPath().c_str() );
// }
}
}
// -------------------------------------------------------------------------------- //
void guLyricSearchThread::LyricCommand( guLyricSource &lyricsource )
{
wxString * CommandText = new wxString( GetSource( lyricsource ) );
guLogMessage( wxT( "Trying to execute command: %s" ), CommandText->c_str() );
wxCommandEvent CommandEvent( wxEVT_MENU, ID_MAINFRAME_LYRICSEXECCOMMAND );
CommandEvent.SetClientData( CommandText );
CommandEvent.SetClientObject( ( wxClientData * ) this );
CommandEvent.SetInt( false );
wxPostEvent( guMainFrame::GetMainFrame(), CommandEvent );
m_CommandIsExecuting = true;
long EndLocalTime = wxGetLocalTime() + 90;
while( !TestDestroy() && m_CommandIsExecuting )
{
Sleep( 20 );
if( wxGetLocalTime() > EndLocalTime )
break;
}
m_CommandIsExecuting = false;
}
// -------------------------------------------------------------------------------- //
void guLyricSearchThread::FinishExecCommand( const wxString &lyrictext )
{
if( m_CommandIsExecuting )
{
//guLogMessage( wxT( "Finish Executing the Command..." ) );
m_LyricText = lyrictext;
m_CommandIsExecuting = false;
}
}
// -------------------------------------------------------------------------------- //
void guLyricSearchThread::ProcessSave( guLyricSource &lyricsource )
{
//guLogMessage( wxT( "guLyricSearchThread::ProcessSave" ) );
if( !TestDestroy() && ( m_LyricSearchContext->DoSaveProcess() || m_ForceSaveProcess ) )
{
guLyricSearchEngine * LyricSearchEngine = m_LyricSearchContext->m_LyricSearchEngine;
int Count = LyricSearchEngine->TargetsCount();
for( int Index = 0; Index < Count; Index++ )
{
guLyricSource * LyricTarget = LyricSearchEngine->GetTarget( Index );
if( LyricTarget->Enabled() )
{
if( LyricTarget->Type() == guLYRIC_SOURCE_TYPE_EMBEDDED )
{
if( !m_LyricSearchContext->m_Track.m_Offset && // If its not from a cue file
( lyricsource.Type() != guLYRIC_SOURCE_TYPE_EMBEDDED ) &&
wxFileExists( m_LyricSearchContext->m_Track.m_FileName ) )
{
if( !guTagSetLyrics( m_LyricSearchContext->m_Track.m_FileName, m_LyricText ) )
{
guLogMessage( wxT( "Could not save the lyrics to the file '%s'" ), m_LyricSearchContext->m_Track.m_FileName.c_str() );
}
}
}
else if( LyricTarget->Type() == guLYRIC_SOURCE_TYPE_FILE )
{
wxString TargetFileName = GetSource( * LyricTarget );
//guLogMessage( wxT( "Lyrics Save to File %i : '%s'" ), Index, TargetFileName.c_str() );
if( lyricsource.Type() == guLYRIC_SOURCE_TYPE_FILE )
{
wxString SourceFileName = GetSource( lyricsource );
if( TargetFileName == SourceFileName )
{
continue;
}
}
else if( lyricsource.Type() == guLYRIC_SOURCE_TYPE_EMBEDDED )
{
if( wxFileExists( TargetFileName ) )
{
continue;
}
}
wxFileName FileName( TargetFileName );
if( FileName.Normalize( wxPATH_NORM_ALL|wxPATH_NORM_CASE ) )
{
FileName.Mkdir( 0770, wxPATH_MKDIR_FULL );
if( !m_LyricText.IsEmpty() )
{
wxFile LyricFile( FileName.GetFullPath(), wxFile::write );
if( LyricFile.IsOpened() )
{
if( !LyricFile.Write( m_LyricText ) )
{
guLogError( wxT( "Error writing to lyric file '%s'" ), FileName.GetFullPath().c_str() );
}
LyricFile.Flush();
LyricFile.Close();
}
else
{
guLogError( wxT( "Error saving lyric file '%s'" ), FileName.GetFullPath().c_str() );
}
}
else
{
wxRemoveFile( FileName.GetFullPath() );
}
}
}
else if( LyricTarget->Type() == guLYRIC_SOURCE_TYPE_COMMAND )
{
wxString * CommandText = new wxString( GetSource( * LyricTarget ) );
guLogMessage( wxT( "Trying to execute save command: %s" ), CommandText->c_str() );
wxCommandEvent CommandEvent( wxEVT_MENU, ID_MAINFRAME_LYRICSEXECCOMMAND );
CommandEvent.SetClientObject( ( wxClientData * ) this );
CommandEvent.SetClientData( CommandText );
CommandEvent.SetInt( true );
wxPostEvent( guMainFrame::GetMainFrame(), CommandEvent );
}
}
}
}
}
// -------------------------------------------------------------------------------- //
guLyricSearchThread::ExitCode guLyricSearchThread::Entry()
{
if( TestDestroy() )
return 0;
guLyricSource LyricSource;
// When we are called to only save the lyrics as they have been changed
if( !m_LyricText.IsEmpty() )
{
ProcessSave( LyricSource );
return 0;
}
// Check if genre is disabled...
const wxArrayString DisabledGenres = m_LyricSearchContext->m_LyricSearchEngine->GetDisabledGenres();
if( DisabledGenres.Index( m_LyricSearchContext->m_Track.m_GenreName ) != wxNOT_FOUND )
{
guLogMessage( wxT( "Lyric Search Engine is disabled for the genre '%s'" ), m_LyricSearchContext->m_Track.m_GenreName.c_str() );
return 0;
}
while( m_LyricSearchContext->GetNextSource( &LyricSource, false ) )
{
if( LyricSource.Type() == guLYRIC_SOURCE_TYPE_DOWNLOAD )
{
LyricDownload( LyricSource );
}
else if( LyricSource.Type() == guLYRIC_SOURCE_TYPE_EMBEDDED )
{
if( wxFileExists( m_LyricSearchContext->m_Track.m_FileName ) )
{
m_LyricText = guTagGetLyrics( m_LyricSearchContext->m_Track.m_FileName );
if( !m_LyricText.IsEmpty() )
break;
}
}
else if( LyricSource.Type() == guLYRIC_SOURCE_TYPE_FILE )
{
LyricFile( LyricSource );
}
else if( LyricSource.Type() == guLYRIC_SOURCE_TYPE_COMMAND )
{
LyricCommand( LyricSource );
}
if( !TestDestroy() && !m_LyricText.IsEmpty() )
{
if( !CheckNotFound( LyricSource ) )
{
m_LyricText = CheckExtract( m_LyricText, LyricSource );
//guLogMessage( wxT( "Content:\n%s" ), m_LyricText.c_str() );
if( !m_LyricText.IsEmpty() )
{
wxHtmlEntitiesParser EntitiesParser;
m_LyricText = EntitiesParser.Parse( CheckExclude( m_LyricText, LyricSource ) );
wxRegEx RegExNewLine( wxT( " ?\r? ?\n? ?< ?br ?/? ?> ?\r? ?\n? ?" ), wxRE_EXTENDED );
RegExNewLine.ReplaceAll( &m_LyricText, wxT( "\n" ) );
wxRegEx RegExHtml( wxT( " ?</?[^>]*> ?" ), wxRE_EXTENDED );
RegExHtml.ReplaceAll( &m_LyricText, wxT( "" ) );
if( !CheckNotFound( LyricSource ) )
{
m_LyricText = m_LyricText.Trim( true ).Trim( false );
//guLogMessage( wxT( "LyricText:\n%s" ), m_LyricText.c_str() );
guLogMessage( wxT( "Found the lyrics from source: %s" ), LyricSource.Name().c_str() );
// Do the save of the lyrics
ProcessSave( LyricSource );
}
else
{
m_LyricText = wxEmptyString;
}
}
}
else
{
m_LyricText = wxEmptyString;
}
}
if( TestDestroy() || !m_LyricText.IsEmpty() )
break;
}
return 0;
}
// -------------------------------------------------------------------------------- //
//
// -------------------------------------------------------------------------------- //
guLyricExecCommandTerminate::guLyricExecCommandTerminate( guLyricSearchThread * searchthread, const bool issavecommand ) :
wxProcess( wxPROCESS_REDIRECT )
{
guLogMessage( wxT( "guLyricExecCommandTerminate::guLyricExecCommandTerminate" ) );
m_LyricSearchThread = searchthread;
m_IsSaveCommand = issavecommand;
m_ThreadActive = true;
}
// -------------------------------------------------------------------------------- //
void guLyricExecCommandTerminate::OnTerminate( int pid, int status )
{
guLogMessage( wxT( "Command with pid '%d' finished with status '%d'" ), pid, status );
wxString CommandLyric;
if( !m_IsSaveCommand && IsInputAvailable() )
{
wxInputStream * CmdOutStream = GetInputStream();
if( CmdOutStream )
{
guLogDebug( "guLyricExecCommandTerminate::OnTerminate<%i> while not eof start", pid );
wxTextInputStream TextStream( * CmdOutStream );
while( !CmdOutStream->Eof() )
{
wxString Line = TextStream.ReadLine() + wxT( "\n" );
guLogDebug( "guLyricExecCommandTerminate::OnTerminate<%i> line: %s", pid, Line );
CommandLyric += Line;
}
}
else
{
guLogMessage( wxT( "Error getting the exec command input stream" ) );
}
}
else
guLogDebug( "guLyricExecCommandTerminate::OnTerminate<%i> skip it", pid );
guLogDebug( "guLyricExecCommandTerminate::OnTerminate<%i> thread active = %i", pid, m_ThreadActive );
if( m_ThreadActive )
m_LyricSearchThread->FinishExecCommand( CommandLyric );
delete this;
}
// -------------------------------------------------------------------------------- //
// guLyricSourceEditor
// -------------------------------------------------------------------------------- //
guLyricSourceEditor::guLyricSourceEditor( wxWindow * parent, guLyricSource * lyricsource, const bool istarget ) :
//wxDialog( parent, wxID_ANY, _( "Lyric Source Editor" ), wxDefaultPosition, wxSize( 500, 425 ), wxDEFAULT_DIALOG_STYLE )
wxDialog( parent, wxID_ANY, istarget ? _( "Lyrics Target Editor" ) : _( "Lyrics Source Editor" ), wxDefaultPosition, wxSize( 500, 450 - ( istarget * 235 ) ), wxDEFAULT_DIALOG_STYLE )
{
m_LyricSource = lyricsource;
m_IsTarget = istarget;
m_ReplaceItems = lyricsource->ReplaceItems();
m_ExtractItems = lyricsource->ExtractItems();
m_ExcludeItems = lyricsource->ExcludeItems();
m_NotFoundItems = lyricsource->NotFoundItems();
SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer * MainSizer = new wxBoxSizer( wxVERTICAL );
MainSizer->Add( 0, 10, 0, wxEXPAND, 5 );
wxFlexGridSizer * OptionsSizer = new wxFlexGridSizer( 2, 0, 0 );
OptionsSizer->AddGrowableCol( 1 );
// OptionsSizer->AddGrowableRow( 2 );
// OptionsSizer->AddGrowableRow( 3 );
// OptionsSizer->AddGrowableRow( 4 );
// OptionsSizer->AddGrowableRow( 5 );
OptionsSizer->SetFlexibleDirection( wxBOTH );
OptionsSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
wxStaticText * NameLabel = new wxStaticText( this, wxID_ANY, _( "Name:" ), wxDefaultPosition, wxDefaultSize, 0 );
NameLabel->Wrap( -1 );
OptionsSizer->Add( NameLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
wxBoxSizer * NameSizer = new wxBoxSizer( wxHORIZONTAL );
m_NameTextCtrl = new wxTextCtrl( this, wxID_ANY, lyricsource->Name(), wxDefaultPosition, wxDefaultSize, 0 );
NameSizer->Add( m_NameTextCtrl, 1, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 );
wxStaticText * TypeLabel = new wxStaticText( this, wxID_ANY, _( "Type:" ), wxDefaultPosition, wxDefaultSize, 0 );
TypeLabel->Wrap( -1 );
NameSizer->Add( TypeLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
wxArrayString LyricSourceTypes;
LyricSourceTypes.Add( _( "Embedded" ) );
LyricSourceTypes.Add( _( "File" ) );
LyricSourceTypes.Add( _( "Command" ) );
if( !istarget )
LyricSourceTypes.Add( _( "Download" ) );
m_TypeChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, LyricSourceTypes, 0 );
m_TypeChoice->SetSelection( lyricsource->Type() );
NameSizer->Add( m_TypeChoice, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 );
OptionsSizer->Add( NameSizer, 1, wxEXPAND, 5 );
wxStaticText * SourceLabel = new wxStaticText( this, wxID_ANY, _( "Source:" ), wxDefaultPosition, wxDefaultSize, 0 );
SourceLabel->Wrap( -1 );
OptionsSizer->Add( SourceLabel, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_SourceTextCtrl = new wxTextCtrl( this, wxID_ANY, lyricsource->Source(), wxDefaultPosition, wxDefaultSize, 0 );
m_SourceTextCtrl->Enable( lyricsource->Type() != guLYRIC_SOURCE_TYPE_EMBEDDED );
OptionsSizer->Add( m_SourceTextCtrl, 1, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 );
wxStaticText * ReplaceLabel = new wxStaticText( this, wxID_ANY, _( "Replace:" ), wxDefaultPosition, wxDefaultSize, 0 );
ReplaceLabel->Wrap( -1 );
OptionsSizer->Add( ReplaceLabel, 0, wxALL|wxALIGN_RIGHT, 5 );
wxBoxSizer * ReplaceListBoxSizer = new wxBoxSizer( wxHORIZONTAL );
wxArrayString ListBoxOptions;
int Count = m_ReplaceItems.Count();
for( int Index = 0; Index < Count; Index++ )
{
guLyricSourceReplace * ReplaceItem = &m_ReplaceItems[ Index ];
ListBoxOptions.Add( ReplaceItem->ToStr() );
}
m_ReplaceListBox = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxSize( -1, 70 ), 0, NULL, wxLB_SINGLE );
m_ReplaceListBox->Append( ListBoxOptions );
m_ReplaceListBox->Enable( lyricsource->Type() != guLYRIC_SOURCE_TYPE_EMBEDDED );
ReplaceListBoxSizer->Add( m_ReplaceListBox, 1, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 );
wxBoxSizer * ReplaceBtnSizer = new wxBoxSizer( wxVERTICAL );
m_ReplaceAdd = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_add ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_ReplaceAdd->Enable( lyricsource->Type() != guLYRIC_SOURCE_TYPE_EMBEDDED );
ReplaceBtnSizer->Add( m_ReplaceAdd, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_ReplaceDel = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_del ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_ReplaceDel->Enable( false );
ReplaceBtnSizer->Add( m_ReplaceDel, 0, wxBOTTOM|wxRIGHT, 5 );
ReplaceListBoxSizer->Add( ReplaceBtnSizer, 0, wxEXPAND, 5 );
OptionsSizer->Add( ReplaceListBoxSizer, 1, wxEXPAND, 5 );
if( !istarget )
{
wxStaticText * ExtractLabel = new wxStaticText( this, wxID_ANY, _( "Extract:" ), wxDefaultPosition, wxDefaultSize, 0 );
ExtractLabel->Wrap( -1 );
OptionsSizer->Add( ExtractLabel, 0, wxALL|wxALIGN_RIGHT, 5 );
wxBoxSizer * ExtractListBoxSizer = new wxBoxSizer( wxHORIZONTAL );
ListBoxOptions.Empty();
Count = m_ExtractItems.Count();
for( int Index = 0; Index < Count; Index++ )
{
guLyricSourceExtract * ExtractItem = &m_ExtractItems[ Index ];
ListBoxOptions.Add( ExtractItem->ToStr() );
}
m_ExtractListBox = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxSize( -1, 70 ), 0, NULL, wxLB_SINGLE );
m_ExtractListBox->Append( ListBoxOptions );
ExtractListBoxSizer->Add( m_ExtractListBox, 1, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 );
wxBoxSizer * ExtractBtnSizer = new wxBoxSizer( wxVERTICAL );
m_ExtractAdd = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_add ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
ExtractBtnSizer->Add( m_ExtractAdd, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_ExtractDel = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_del ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_ExtractDel->Enable( false );
ExtractBtnSizer->Add( m_ExtractDel, 0, wxBOTTOM|wxRIGHT, 5 );
ExtractListBoxSizer->Add( ExtractBtnSizer, 0, wxEXPAND, 5 );
OptionsSizer->Add( ExtractListBoxSizer, 1, wxEXPAND, 5 );
wxStaticText * ExcludeLabel = new wxStaticText( this, wxID_ANY, _( "Exclude:" ), wxDefaultPosition, wxDefaultSize, 0 );
ExcludeLabel->Wrap( -1 );
OptionsSizer->Add( ExcludeLabel, 0, wxALL|wxALIGN_RIGHT, 5 );
wxBoxSizer * ExcludeListBoxSizer = new wxBoxSizer( wxHORIZONTAL );
ListBoxOptions.Empty();
Count = m_ExcludeItems.Count();
for( int Index = 0; Index < Count; Index++ )
{
guLyricSourceExclude * ExcludeItem = &m_ExcludeItems[ Index ];
ListBoxOptions.Add( ExcludeItem->ToStr() );
}
m_ExcludeListBox = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxSize( -1, 70 ), 0, NULL, wxLB_SINGLE );
m_ExcludeListBox->Append( ListBoxOptions );
ExcludeListBoxSizer->Add( m_ExcludeListBox, 1, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 );
wxBoxSizer * ExcludeBtnSizer = new wxBoxSizer( wxVERTICAL );
m_ExcludeAdd = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_add ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
ExcludeBtnSizer->Add( m_ExcludeAdd, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_ExcludeDel = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_del ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_ExcludeDel->Enable( false );
ExcludeBtnSizer->Add( m_ExcludeDel, 0, wxBOTTOM|wxRIGHT, 5 );
ExcludeListBoxSizer->Add( ExcludeBtnSizer, 0, wxEXPAND, 5 );
OptionsSizer->Add( ExcludeListBoxSizer, 1, wxEXPAND, 5 );
wxStaticText * NotFoundLabel = new wxStaticText( this, wxID_ANY, _( "Not Found:" ), wxDefaultPosition, wxDefaultSize, 0 );
NotFoundLabel->Wrap( -1 );
OptionsSizer->Add( NotFoundLabel, 0, wxALL|wxALIGN_RIGHT, 5 );
wxBoxSizer * NotFoundListBoxSizer = new wxBoxSizer( wxHORIZONTAL );
m_NotFoundListBox = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxSize( -1, 70 ), 0, NULL, wxLB_SINGLE );
m_NotFoundListBox->Append( m_NotFoundItems );
NotFoundListBoxSizer->Add( m_NotFoundListBox, 1, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 );
wxBoxSizer* NotFoundBtnSizer;
NotFoundBtnSizer = new wxBoxSizer( wxVERTICAL );
m_NotFoundAdd = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_add ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
NotFoundBtnSizer->Add( m_NotFoundAdd, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_NotFoundDel = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_del ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_NotFoundDel->Enable( false );
NotFoundBtnSizer->Add( m_NotFoundDel, 0, wxBOTTOM|wxRIGHT, 5 );
NotFoundListBoxSizer->Add( NotFoundBtnSizer, 0, wxEXPAND, 5 );
OptionsSizer->Add( NotFoundListBoxSizer, 1, wxEXPAND, 5 );
}
MainSizer->Add( OptionsSizer, 1, wxEXPAND, 5 );
wxStdDialogButtonSizer * ButtonsSizer = new wxStdDialogButtonSizer();
wxButton * ButtonsSizerOK = new wxButton( this, wxID_OK );
ButtonsSizer->AddButton( ButtonsSizerOK );
wxButton * ButtonsSizerCancel = new wxButton( this, wxID_CANCEL );
ButtonsSizer->AddButton( ButtonsSizerCancel );
ButtonsSizer->SetAffirmativeButton( ButtonsSizerOK );
ButtonsSizer->SetCancelButton( ButtonsSizerCancel );
ButtonsSizer->Realize();
MainSizer->Add( ButtonsSizer, 0, wxEXPAND|wxALL, 5 );
SetSizer( MainSizer );
Layout();
ButtonsSizerOK->SetDefault();
// Bind Events
m_TypeChoice->Bind( wxEVT_CHOICE, &guLyricSourceEditor::OnTypeChanged, this );
m_ReplaceListBox->Bind( wxEVT_LISTBOX, &guLyricSourceEditor::OnReplaceSelected, this );
m_ReplaceListBox->Bind( wxEVT_LISTBOX_DCLICK, &guLyricSourceEditor::OnReplaceDClicked, this );
m_ReplaceAdd->Bind( wxEVT_BUTTON, &guLyricSourceEditor::OnReplaceAddClicked, this );
m_ReplaceDel->Bind( wxEVT_BUTTON, &guLyricSourceEditor::OnReplaceDelClicked, this );
if( !istarget )
{
m_ExtractListBox->Bind( wxEVT_LISTBOX, &guLyricSourceEditor::OnExtractSelected, this );
m_ExtractListBox->Bind( wxEVT_LISTBOX_DCLICK, &guLyricSourceEditor::OnExtractDClicked, this );
m_ExtractAdd->Bind( wxEVT_BUTTON, &guLyricSourceEditor::OnExtractAddClicked, this );
m_ExtractDel->Bind( wxEVT_BUTTON, &guLyricSourceEditor::OnExtractDelClicked, this );
m_ExcludeListBox->Bind( wxEVT_LISTBOX, &guLyricSourceEditor::OnExcludeSelected, this );
m_ExcludeListBox->Bind( wxEVT_LISTBOX_DCLICK, &guLyricSourceEditor::OnExcludeDClicked, this );
m_ExcludeAdd->Bind( wxEVT_BUTTON, &guLyricSourceEditor::OnExcludeAddClicked, this );
m_ExcludeDel->Bind( wxEVT_BUTTON, &guLyricSourceEditor::OnExcludeDelClicked, this );
m_NotFoundListBox->Bind( wxEVT_LISTBOX, &guLyricSourceEditor::OnNotFoundSelected, this );
m_NotFoundListBox->Bind( wxEVT_LISTBOX_DCLICK, &guLyricSourceEditor::OnNotFoundDClicked, this );
m_NotFoundAdd->Bind( wxEVT_BUTTON, &guLyricSourceEditor::OnNotFoundAddClicked, this );
m_NotFoundDel->Bind( wxEVT_BUTTON, &guLyricSourceEditor::OnNotFoundDelClicked, this );
}
m_NameTextCtrl->SetFocus();
}
// -------------------------------------------------------------------------------- //
guLyricSourceEditor::~guLyricSourceEditor()
{
m_TypeChoice->Unbind( wxEVT_CHOICE, &guLyricSourceEditor::OnTypeChanged, this );
m_ReplaceListBox->Unbind( wxEVT_LISTBOX, &guLyricSourceEditor::OnReplaceSelected, this );
m_ReplaceListBox->Unbind( wxEVT_LISTBOX_DCLICK, &guLyricSourceEditor::OnReplaceDClicked, this );
m_ReplaceAdd->Unbind( wxEVT_BUTTON, &guLyricSourceEditor::OnReplaceAddClicked, this );
m_ReplaceDel->Unbind( wxEVT_BUTTON, &guLyricSourceEditor::OnReplaceDelClicked, this );
if( !m_IsTarget )
{
m_ExtractListBox->Unbind( wxEVT_LISTBOX, &guLyricSourceEditor::OnExtractSelected, this );
m_ExtractListBox->Unbind( wxEVT_LISTBOX_DCLICK, &guLyricSourceEditor::OnExtractDClicked, this );
m_ExtractAdd->Unbind( wxEVT_BUTTON, &guLyricSourceEditor::OnExtractAddClicked, this );
m_ExtractDel->Unbind( wxEVT_BUTTON, &guLyricSourceEditor::OnExtractDelClicked, this );
m_ExcludeListBox->Unbind( wxEVT_LISTBOX, &guLyricSourceEditor::OnExcludeSelected, this );
m_ExcludeListBox->Unbind( wxEVT_LISTBOX_DCLICK, &guLyricSourceEditor::OnExcludeDClicked, this );
m_ExcludeAdd->Unbind( wxEVT_BUTTON, &guLyricSourceEditor::OnExcludeAddClicked, this );
m_ExcludeDel->Unbind( wxEVT_BUTTON, &guLyricSourceEditor::OnExcludeDelClicked, this );
m_NotFoundListBox->Unbind( wxEVT_LISTBOX, &guLyricSourceEditor::OnNotFoundSelected, this );
m_NotFoundListBox->Unbind( wxEVT_LISTBOX_DCLICK, &guLyricSourceEditor::OnNotFoundDClicked, this );
m_NotFoundAdd->Unbind( wxEVT_BUTTON, &guLyricSourceEditor::OnNotFoundAddClicked, this );
m_NotFoundDel->Unbind( wxEVT_BUTTON, &guLyricSourceEditor::OnNotFoundDelClicked, this );
}
}
// -------------------------------------------------------------------------------- //
void guLyricSourceEditor::OnTypeChanged( wxCommandEvent &event )
{
bool Enabled = ( m_TypeChoice->GetSelection() != guLYRIC_SOURCE_TYPE_EMBEDDED );
m_SourceTextCtrl->Enable( Enabled );
m_ReplaceListBox->Enable( Enabled );
m_ReplaceAdd->Enable( Enabled );
}
// -------------------------------------------------------------------------------- //
void guLyricSourceEditor::OnReplaceSelected( wxCommandEvent &event )
{
m_ReplaceDel->Enable( event.GetInt() != wxNOT_FOUND );
}
// -------------------------------------------------------------------------------- //
void guLyricSourceEditor::OnReplaceAddClicked( wxCommandEvent &event )
{
guLyricSourceReplace LyricSourceReplace;
guLyricSourceOptionEditor * SourceOptionEditor = new guLyricSourceOptionEditor( this, &LyricSourceReplace, guLYRIC_SOURCE_OPTION_TYPE_REPLACE );
if( SourceOptionEditor )
{
if( SourceOptionEditor->ShowModal() == wxID_OK )
{
SourceOptionEditor->UpdateSourceOption();
m_ReplaceItems.Add( LyricSourceReplace );
m_ReplaceListBox->Append( LyricSourceReplace.ToStr() );
}
SourceOptionEditor->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guLyricSourceEditor::OnReplaceDelClicked( wxCommandEvent &event )
{
int Selected = m_ReplaceListBox->GetSelection();
m_ReplaceListBox->Delete( Selected );
m_ReplaceItems.RemoveAt( Selected );
}
// -------------------------------------------------------------------------------- //
void guLyricSourceEditor::OnReplaceDClicked( wxCommandEvent &event )
{
int Selected = m_ReplaceListBox->GetSelection();
if( Selected != wxNOT_FOUND )
{
guLyricSourceReplace * LyricSourceReplace = &m_ReplaceItems[ Selected ];
guLyricSourceOptionEditor * SourceOptionEditor = new guLyricSourceOptionEditor( this, LyricSourceReplace, guLYRIC_SOURCE_OPTION_TYPE_REPLACE );
if( SourceOptionEditor )
{
if( SourceOptionEditor->ShowModal() == wxID_OK )
{
SourceOptionEditor->UpdateSourceOption();
m_ReplaceListBox->SetString( Selected, LyricSourceReplace->ToStr() );
}
SourceOptionEditor->Destroy();
}
}
}
// -------------------------------------------------------------------------------- //
void guLyricSourceEditor::OnExtractSelected( wxCommandEvent &event )
{
m_ExtractDel->Enable( event.GetInt() != wxNOT_FOUND );
}
// -------------------------------------------------------------------------------- //
void guLyricSourceEditor::OnExtractAddClicked( wxCommandEvent &event )
{
guLyricSourceExtract LyricSourceExtract;
guLyricSourceOptionEditor * SourceOptionEditor = new guLyricSourceOptionEditor( this, &LyricSourceExtract, guLYRIC_SOURCE_OPTION_TYPE_EXTRACT );
if( SourceOptionEditor )
{
if( SourceOptionEditor->ShowModal() == wxID_OK )
{
SourceOptionEditor->UpdateSourceOption();
m_ExtractItems.Add( LyricSourceExtract );
m_ExtractListBox->Append( LyricSourceExtract.ToStr() );
}
SourceOptionEditor->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guLyricSourceEditor::OnExtractDelClicked( wxCommandEvent &event )
{
int Selected = m_ExtractListBox->GetSelection();
m_ExtractListBox->Delete( Selected );
m_ExtractItems.RemoveAt( Selected );
}
// -------------------------------------------------------------------------------- //
void guLyricSourceEditor::OnExtractDClicked( wxCommandEvent &event )
{
int Selected = m_ExtractListBox->GetSelection();
if( Selected != wxNOT_FOUND )
{
guLyricSourceExtract * LyricSourceExtract = &m_ExtractItems[ Selected ];
guLyricSourceOptionEditor * SourceOptionEditor = new guLyricSourceOptionEditor( this, LyricSourceExtract, guLYRIC_SOURCE_OPTION_TYPE_EXTRACT );
if( SourceOptionEditor )
{
if( SourceOptionEditor->ShowModal() == wxID_OK )
{
SourceOptionEditor->UpdateSourceOption();
m_ExtractListBox->SetString( Selected, LyricSourceExtract->ToStr() );
}
SourceOptionEditor->Destroy();
}
}
}
// -------------------------------------------------------------------------------- //
void guLyricSourceEditor::OnExcludeSelected( wxCommandEvent &event )
{
m_ExcludeDel->Enable( event.GetInt() != wxNOT_FOUND );
}
// -------------------------------------------------------------------------------- //
void guLyricSourceEditor::OnExcludeAddClicked( wxCommandEvent &event )
{
guLyricSourceExclude LyricSourceExclude;
guLyricSourceOptionEditor * SourceOptionEditor = new guLyricSourceOptionEditor( this, &LyricSourceExclude, guLYRIC_SOURCE_OPTION_TYPE_EXCLUDE );
if( SourceOptionEditor )
{
if( SourceOptionEditor->ShowModal() == wxID_OK )
{
SourceOptionEditor->UpdateSourceOption();
m_ExcludeItems.Add( LyricSourceExclude );
m_ExcludeListBox->Append( LyricSourceExclude.ToStr() );
}
SourceOptionEditor->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guLyricSourceEditor::OnExcludeDelClicked( wxCommandEvent &event )
{
int Selected = m_ExcludeListBox->GetSelection();
m_ExcludeListBox->Delete( Selected );
m_ExcludeItems.RemoveAt( Selected );
}
// -------------------------------------------------------------------------------- //
void guLyricSourceEditor::OnExcludeDClicked( wxCommandEvent &event )
{
int Selected = m_ExcludeListBox->GetSelection();
if( Selected != wxNOT_FOUND )
{
guLyricSourceExclude * LyricSourceExclude = &m_ExcludeItems[ Selected ];
guLyricSourceOptionEditor * SourceOptionEditor = new guLyricSourceOptionEditor( this, LyricSourceExclude, guLYRIC_SOURCE_OPTION_TYPE_EXCLUDE );
if( SourceOptionEditor )
{
if( SourceOptionEditor->ShowModal() == wxID_OK )
{
SourceOptionEditor->UpdateSourceOption();
m_ExcludeListBox->SetString( Selected, LyricSourceExclude->ToStr() );
}
SourceOptionEditor->Destroy();
}
}
}
// -------------------------------------------------------------------------------- //
void guLyricSourceEditor::OnNotFoundSelected( wxCommandEvent &event )
{
m_NotFoundDel->Enable( event.GetInt() != wxNOT_FOUND );
}
// -------------------------------------------------------------------------------- //
void guLyricSourceEditor::OnNotFoundAddClicked( wxCommandEvent &event )
{
guLyricSourceOption LyricSourceOption;
guLyricSourceOptionEditor * SourceOptionEditor = new guLyricSourceOptionEditor( this, &LyricSourceOption, guLYRIC_SOURCE_OPTION_TYPE_NOTFOUND );
if( SourceOptionEditor )
{
if( SourceOptionEditor->ShowModal() == wxID_OK )
{
SourceOptionEditor->UpdateSourceOption();
m_NotFoundItems.Add( LyricSourceOption.Text1() );
m_NotFoundListBox->Append( LyricSourceOption.Text1() );
}
SourceOptionEditor->Destroy();
}
}
// -------------------------------------------------------------------------------- //
void guLyricSourceEditor::OnNotFoundDelClicked( wxCommandEvent &event )
{
int Selected = m_NotFoundListBox->GetSelection();
m_NotFoundListBox->Delete( Selected );
m_NotFoundItems.RemoveAt( Selected );
}
// -------------------------------------------------------------------------------- //
void guLyricSourceEditor::OnNotFoundDClicked( wxCommandEvent &event )
{
int Selected = m_NotFoundListBox->GetSelection();
if( Selected != wxNOT_FOUND )
{
guLyricSourceOption * LyricSourceNotFound = new guLyricSourceOption( m_NotFoundItems[ Selected ] );
guLyricSourceOptionEditor * SourceOptionEditor = new guLyricSourceOptionEditor( this, LyricSourceNotFound, guLYRIC_SOURCE_OPTION_TYPE_NOTFOUND );
if( SourceOptionEditor )
{
if( SourceOptionEditor->ShowModal() == wxID_OK )
{
SourceOptionEditor->UpdateSourceOption();
m_NotFoundItems[ Selected ] = LyricSourceNotFound->Text1();
m_NotFoundListBox->SetString( Selected, LyricSourceNotFound->Text1() );
delete LyricSourceNotFound;
}
SourceOptionEditor->Destroy();
}
}
}
// -------------------------------------------------------------------------------- //
void guLyricSourceEditor::UpdateLyricSource( void )
{
m_LyricSource->Name( m_NameTextCtrl->GetValue() );
m_LyricSource->Type( m_TypeChoice->GetSelection() );
m_LyricSource->Source( m_SourceTextCtrl->GetValue() );
m_LyricSource->ReplaceItems( m_ReplaceItems );
m_LyricSource->ExtractItems( m_ExtractItems );
m_LyricSource->ExcludeItems( m_ExcludeItems );
m_LyricSource->NotFoundItems( m_NotFoundItems );
}
// -------------------------------------------------------------------------------- //
guLyricSourceOptionEditor::guLyricSourceOptionEditor( wxWindow * parent, guLyricSourceOption * sourceoption, const int optiontype )
{
m_SourceOption = sourceoption;
wxString Title;
wxString Label1;
wxString Label2;
if( optiontype == guLYRIC_SOURCE_OPTION_TYPE_REPLACE )
{
Title = _( "Replace option editor" );
Label1 = _( "Search:" );
Label2 = _( "Replace:" );
}
else if( optiontype == guLYRIC_SOURCE_OPTION_TYPE_EXTRACT )
{
Title = _( "Extract option editor" );
Label1 = _( "Begin:" );
Label2 = _( "End:" );
}
else if( optiontype == guLYRIC_SOURCE_OPTION_TYPE_EXCLUDE )
{
Title = _( "Exclude option editor" );
Label1 = _( "Begin:" );
Label2 = _( "End:" );
}
else if( optiontype == guLYRIC_SOURCE_OPTION_TYPE_NOTFOUND )
{
Title = _( "Not Found option editor" );
Label1 = _( "Tag:" );
Label2 = _( "Tag:" );
}
Create( parent, wxID_ANY, Title, wxDefaultPosition, wxSize( 400, 150 ), wxDEFAULT_DIALOG_STYLE );
SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer * MainSizer = new wxBoxSizer( wxVERTICAL );
//MainSizer->Add( 0, 10, 1, wxEXPAND, 5 );
wxFlexGridSizer * OptionsSizer;
OptionsSizer = new wxFlexGridSizer( 2, 0, 0 );
OptionsSizer->AddGrowableCol( 1 );
OptionsSizer->SetFlexibleDirection( wxBOTH );
OptionsSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_SearchLabel = new wxStaticText( this, wxID_ANY, Label1, wxDefaultPosition, wxDefaultSize, 0 );
m_SearchLabel->Wrap( -1 );
OptionsSizer->Add( m_SearchLabel, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_SearchTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_SearchTextCtrl->SetValue( sourceoption->Text1() );
OptionsSizer->Add( m_SearchTextCtrl, 1, wxTOP|wxBOTTOM|wxRIGHT|wxEXPAND, 5 );
m_ReplaceLabel = new wxStaticText( this, wxID_ANY, Label2, wxDefaultPosition, wxDefaultSize, 0 );
m_ReplaceLabel->Wrap( -1 );
OptionsSizer->Add( m_ReplaceLabel, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_ReplaceTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_ReplaceTextCtrl->SetValue( sourceoption->Text2() );
m_ReplaceTextCtrl->Enable( optiontype != guLYRIC_SOURCE_OPTION_TYPE_NOTFOUND );
OptionsSizer->Add( m_ReplaceTextCtrl, 0, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 );
MainSizer->Add( OptionsSizer, 1, wxEXPAND, 5 );
wxStdDialogButtonSizer * ButtonsSizer = new wxStdDialogButtonSizer();
wxButton * ButtonsSizerOK = new wxButton( this, wxID_OK );
ButtonsSizer->AddButton( ButtonsSizerOK );
wxButton * ButtonsSizerCancel = new wxButton( this, wxID_CANCEL );
ButtonsSizer->AddButton( ButtonsSizerCancel );
ButtonsSizer->SetAffirmativeButton( ButtonsSizerOK );
ButtonsSizer->SetCancelButton( ButtonsSizerCancel );
ButtonsSizer->Realize();
MainSizer->Add( ButtonsSizer, 1, wxEXPAND|wxALL, 5 );
SetSizer( MainSizer );
Layout();
ButtonsSizerOK->SetDefault();
m_SearchTextCtrl->SetFocus();
}
// -------------------------------------------------------------------------------- //
guLyricSourceOptionEditor::~guLyricSourceOptionEditor()
{
}
// -------------------------------------------------------------------------------- //
void guLyricSourceOptionEditor::UpdateSourceOption( void )
{
m_SourceOption->Text1( m_SearchTextCtrl->GetValue() );
m_SourceOption->Text2( m_ReplaceTextCtrl->GetValue() );
}
}
// -------------------------------------------------------------------------------- //
| 103,384
|
C++
|
.cpp
| 2,275
| 38.345934
| 186
| 0.581091
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
750,661
|
PodcastsPanel.cpp
|
anonbeat_guayadeque/src/ui/podcasts/PodcastsPanel.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "PodcastsPanel.h"
#include "Accelerators.h"
#include "AuiDockArt.h"
#include "ChannelEditor.h"
#include "EventCommandIds.h"
#include "Config.h"
#include "Images.h"
#include "MainFrame.h"
#include "NewChannel.h"
#include "Utils.h"
#include <wx/regex.h>
#include <wx/sstream.h>
#include <wx/uri.h>
#include <wx/xml/xml.h>
#include <wx/zstream.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
// guDbPodcasts
// -------------------------------------------------------------------------------- //
guDbPodcasts::guDbPodcasts( const wxString &dbname ) : guDb( dbname )
{
wxArrayString query;
query.Add( wxT( "CREATE TABLE IF NOT EXISTS podcastchs( podcastch_id INTEGER PRIMARY KEY AUTOINCREMENT, " \
"podcastch_url VARCHAR, podcastch_title VARCHAR COLLATE NOCASE, podcastch_description VARCHAR, " \
"podcastch_language VARCHAR, podcastch_time INTEGER, podcastch_sumary VARCHAR, " \
"podcastch_author VARCHAR, podcastch_ownername VARCHAR, podcastch_owneremail VARCHAR, " \
"podcastch_category VARCHAR, podcastch_image VARCHAR, podcastch_downtype INTEGER, " \
"podcastch_downtext VARCHAR, podcastch_allowdel BOOLEAN );" ) );
//query.Add( wxT( "CREATE UNIQUE INDEX IF NOT EXISTS 'podcastch_id' on podcastchs(podcastch_id ASC);" ) );
query.Add( wxT( "CREATE INDEX IF NOT EXISTS 'podcastch_title' on podcastchs(podcastch_title ASC);" ) );
query.Add( wxT( "CREATE INDEX IF NOT EXISTS 'podcastch_url' on podcastchs(podcastch_url ASC);" ) );
query.Add( wxT( "CREATE TABLE IF NOT EXISTS podcastitems( podcastitem_id INTEGER PRIMARY KEY AUTOINCREMENT, " \
"podcastitem_chid INTEGER, podcastitem_title VARCHAR COLLATE NOCASE, podcastitem_summary VARCHAR, " \
"podcastitem_author VARCHAR COLLATE NOCASE, podcastitem_enclosure VARCHAR, podcastitem_time INTEGER, " \
"podcastitem_file VARCHAR, podcastitem_filesize INTEGER, podcastitem_length INTEGER, " \
"podcastitem_addeddate INTEGER, podcastitem_playcount INTEGER, " \
"podcastitem_lastplay INTEGER, podcastitem_status INTEGER );" ) );
//query.Add( wxT( "CREATE UNIQUE INDEX IF NOT EXISTS 'podcastitem_id' on podcastitems(podcastitem_id ASC);" ) );
query.Add( wxT( "CREATE INDEX IF NOT EXISTS 'podcastitem_title' on podcastitems(podcastitem_title ASC);" ) );
query.Add( wxT( "CREATE INDEX IF NOT EXISTS 'podcastitem_file' on podcastitems(podcastitem_file ASC);" ) );
query.Add( wxT( "CREATE INDEX IF NOT EXISTS 'podcastitem_chid' on podcastitems(podcastitem_chid ASC);" ) );
query.Add( wxT( "CREATE INDEX IF NOT EXISTS 'podcastitem_time' on podcastitems(podcastitem_time ASC);" ) );
query.Add( wxT( "CREATE INDEX IF NOT EXISTS 'podcastitem_enclosure' on podcastitems(podcastitem_enclosure ASC);" ) );
query.Add( wxT( "CREATE INDEX IF NOT EXISTS 'podcastitem_author' on podcastitems(podcastitem_author ASC);" ) );
query.Add( wxT( "CREATE INDEX IF NOT EXISTS 'podcastitem_length' on podcastitems(podcastitem_length ASC);" ) );
int Count = query.Count();
for( int Index = 0; Index < Count; Index++ )
{
ExecuteUpdate( query[ Index ] );
}
}
// -------------------------------------------------------------------------------- //
guDbPodcasts::~guDbPodcasts()
{
}
// -------------------------------------------------------------------------------- //
int guDbPodcasts::GetPodcastChannels( guPodcastChannelArray * channels )
{
wxString query;
wxSQLite3ResultSet dbRes;
query = wxT( "SELECT podcastch_id, podcastch_url, podcastch_title, podcastch_description, " \
"podcastch_language, podcastch_sumary, " \
"podcastch_author, podcastch_ownername, podcastch_owneremail, " \
"podcastch_category, podcastch_image, " \
"podcastch_downtype, podcastch_downtext, podcastch_allowdel " \
"FROM podcastchs " \
"ORDER BY podcastch_title" );
dbRes = ExecuteQuery( query );
while( dbRes.NextRow() )
{
guPodcastChannel * Channel = new guPodcastChannel();
Channel->m_Id = dbRes.GetInt( 0 );
Channel->m_Url = dbRes.GetString( 1 );
Channel->m_Title = dbRes.GetString( 2 );
Channel->m_Description = dbRes.GetString( 3 );
Channel->m_Lang = dbRes.GetString( 4 );
Channel->m_Summary = dbRes.GetString( 5 );
Channel->m_Author = dbRes.GetString( 6 );
Channel->m_OwnerName = dbRes.GetString( 7 );
Channel->m_OwnerEmail = dbRes.GetString( 8 );
Channel->m_Category = dbRes.GetString( 9 );
Channel->m_Image = dbRes.GetString( 10 );
Channel->m_DownloadType = dbRes.GetInt( 11 );
Channel->m_DownloadText = dbRes.GetString( 12 );
Channel->m_AllowDelete = dbRes.GetBool( 13 );
channels->Add( Channel );
}
dbRes.Finalize();
return channels->Count();
}
// -------------------------------------------------------------------------------- //
void guDbPodcasts::SavePodcastChannel( guPodcastChannel * channel, bool onlynew )
{
wxString query;
int ChannelId;
if( ( ChannelId = GetPodcastChannelUrl( channel->m_Url ) ) == wxNOT_FOUND )
{
query = wxString::Format( wxT( "INSERT INTO podcastchs( podcastch_id, podcastch_url, podcastch_title, " \
"podcastch_description, podcastch_language, podcastch_time, podcastch_sumary, " \
"podcastch_author, podcastch_ownername, podcastch_owneremail, " \
"podcastch_category, podcastch_image, " \
"podcastch_downtype, podcastch_downtext, podcastch_allowdel ) " \
"VALUES( NULL, '%s', '%s', " \
"'%s', '%s', 0, '%s', " \
"'%s', '%s', '%s', " \
"'%s', '%s', %u, '%s', %u );" ),
escape_query_str( channel->m_Url ).c_str(),
escape_query_str( channel->m_Title ).c_str(),
escape_query_str( channel->m_Description ).c_str(),
escape_query_str( channel->m_Lang ).c_str(),
escape_query_str( channel->m_Summary ).c_str(),
escape_query_str( channel->m_Author ).c_str(),
escape_query_str( channel->m_OwnerName ).c_str(),
escape_query_str( channel->m_OwnerEmail ).c_str(),
escape_query_str( channel->m_Category ).c_str(),
escape_query_str( channel->m_Image ).c_str(),
channel->m_DownloadType,
escape_query_str( channel->m_DownloadText ).c_str(),
channel->m_AllowDelete );
ExecuteUpdate( query );
ChannelId = GetLastRowId();
channel->m_Id = ChannelId;
}
else if( !onlynew )
{
query = wxString::Format( wxT( "UPDATE podcastchs " \
"SET podcastch_url = '%s', podcastch_title = '%s', " \
"podcastch_description = '%s', podcastch_language = '%s', podcastch_sumary = '%s', " \
"podcastch_author = '%s', podcastch_ownername = '%s', podcastch_owneremail = '%s', " \
"podcastch_category = '%s', podcastch_image = '%s', " \
"podcastch_downtype = %u, podcastch_downtext = '%s', podcastch_allowdel = %u " \
"WHERE podcastch_id = %u" ),
escape_query_str( channel->m_Url ).c_str(),
escape_query_str( channel->m_Title ).c_str(),
escape_query_str( channel->m_Description ).c_str(),
escape_query_str( channel->m_Lang ).c_str(),
escape_query_str( channel->m_Summary ).c_str(),
escape_query_str( channel->m_Author ).c_str(),
escape_query_str( channel->m_OwnerName ).c_str(),
escape_query_str( channel->m_OwnerEmail ).c_str(),
escape_query_str( channel->m_Category ).c_str(),
escape_query_str( channel->m_Image ).c_str(),
channel->m_DownloadType,
escape_query_str( channel->m_DownloadText ).c_str(),
channel->m_AllowDelete,
channel->m_Id );
ExecuteUpdate( query );
ChannelId = channel->m_Id;
}
// Save the Items
SavePodcastItems( ChannelId, &channel->m_Items, onlynew );
}
// -------------------------------------------------------------------------------- //
int guDbPodcasts::SavePodcastChannels( guPodcastChannelArray * channels, bool onlynew )
{
int Count = channels->Count();
for( int Index = 0; Index < Count; Index++ )
{
SavePodcastChannel( &channels->Item( Index ), onlynew );
}
return 1;
}
// -------------------------------------------------------------------------------- //
int guDbPodcasts::GetPodcastChannelUrl( const wxString &url, guPodcastChannel * channel )
{
int RetVal = wxNOT_FOUND;
wxString query;
wxSQLite3ResultSet dbRes;
query = wxString::Format( wxT( "SELECT podcastch_id, podcastch_url, podcastch_title, podcastch_description, " \
"podcastch_language, podcastch_sumary, " \
"podcastch_author, podcastch_ownername, podcastch_owneremail, " \
"podcastch_category, podcastch_image, " \
"podcastch_downtype, podcastch_downtext, podcastch_allowdel " \
"FROM podcastchs " \
"WHERE podcastch_url = '%s' LIMIT 1;" ),
escape_query_str( url ).c_str() );
dbRes = ExecuteQuery( query );
while( dbRes.NextRow() )
{
RetVal = dbRes.GetInt( 0 );
if( channel )
{
channel->m_Id = RetVal;
channel->m_Url = dbRes.GetString( 1 );
channel->m_Title = dbRes.GetString( 2 );
channel->m_Description = dbRes.GetString( 3 );
channel->m_Lang = dbRes.GetString( 4 );
channel->m_Summary = dbRes.GetString( 5 );
channel->m_Author = dbRes.GetString( 6 );
channel->m_OwnerName = dbRes.GetString( 7 );
channel->m_OwnerEmail = dbRes.GetString( 8 );
channel->m_Category = dbRes.GetString( 9 );
channel->m_Image = dbRes.GetString( 10 );
channel->m_DownloadType = dbRes.GetInt( 11 );
channel->m_DownloadText = dbRes.GetString( 12 );
channel->m_AllowDelete = dbRes.GetBool( 13 );
}
}
dbRes.Finalize();
return RetVal;
}
// -------------------------------------------------------------------------------- //
int guDbPodcasts::GetPodcastChannelId( const int id, guPodcastChannel * channel )
{
int RetVal = wxNOT_FOUND;
wxString query;
wxSQLite3ResultSet dbRes;
query = wxString::Format( wxT( "SELECT podcastch_id, podcastch_url, podcastch_title, podcastch_description, " \
"podcastch_language, podcastch_sumary, " \
"podcastch_author, podcastch_ownername, podcastch_owneremail, " \
"podcastch_category, podcastch_image, " \
"podcastch_downtype, podcastch_downtext, podcastch_allowdel " \
"FROM podcastchs " \
"WHERE podcastch_id = %u LIMIT 1;" ),
id );
dbRes = ExecuteQuery( query );
while( dbRes.NextRow() )
{
RetVal = dbRes.GetInt( 0 );
if( channel )
{
channel->m_Id = RetVal;
channel->m_Url = dbRes.GetString( 1 );
channel->m_Title = dbRes.GetString( 2 );
channel->m_Description = dbRes.GetString( 3 );
channel->m_Lang = dbRes.GetString( 4 );
channel->m_Summary = dbRes.GetString( 5 );
channel->m_Author = dbRes.GetString( 6 );
channel->m_OwnerName = dbRes.GetString( 7 );
channel->m_OwnerEmail = dbRes.GetString( 8 );
channel->m_Category = dbRes.GetString( 9 );
channel->m_Image = dbRes.GetString( 10 );
channel->m_DownloadType = dbRes.GetInt( 11 );
channel->m_DownloadText = dbRes.GetString( 12 );
channel->m_AllowDelete = dbRes.GetBool( 13 );
}
}
dbRes.Finalize();
return RetVal;
}
// -------------------------------------------------------------------------------- //
void guDbPodcasts::DelPodcastChannel( const int id )
{
wxString query;
query = wxString::Format( wxT( "DELETE FROM podcastchs WHERE podcastch_id = %u;" ), id );
ExecuteUpdate( query );
DelPodcastItems( id );
}
// -------------------------------------------------------------------------------- //
int guDbPodcasts::GetPodcastItems( guPodcastItemArray * items, const wxArrayInt &filters, const int order, const bool desc )
{
wxString query;
wxSQLite3ResultSet dbRes;
query = wxT( "SELECT podcastitem_id, podcastitem_chid, podcastitem_title, " \
"podcastitem_summary, podcastitem_author, podcastitem_enclosure, podcastitem_time, " \
"podcastitem_file, podcastitem_filesize, podcastitem_length, " \
"podcastitem_playcount, podcastitem_addeddate, podcastitem_lastplay, " \
"podcastitem_status, " \
"podcastch_title, podcastch_category " \
"FROM podcastitems, podcastchs " \
"WHERE podcastitem_chid = podcastch_id AND podcastitem_status != 4" ); // dont get the deleted items
if( filters.Count() )
{
query += wxT( " AND " ) + ArrayToFilter( filters, wxT( "podcastitem_chid" ) );
}
query += wxT( " ORDER BY " );
switch( order )
{
case guPODCASTS_COLUMN_TITLE :
query += wxT( "podcastitem_title COLLATE NOCASE" );
break;
case guPODCASTS_COLUMN_CHANNEL :
query += wxT( "podcastch_title COLLATE NOCASE" );
break;
case guPODCASTS_COLUMN_CATEGORY :
query += wxT( "podcastch_category COLLATE NOCASE" );
break;
case guPODCASTS_COLUMN_DATE :
query += wxT( "podcastitem_time" );
break;
case guPODCASTS_COLUMN_LENGTH :
query += wxT( "podcastitem_length" );
break;
case guPODCASTS_COLUMN_AUTHOR :
query += wxT( "podcastitem_author COLLATE NOCASE" );
break;
case guPODCASTS_COLUMN_PLAYCOUNT :
query += wxT( "podcastitem_playcount" );
break;
case guPODCASTS_COLUMN_LASTPLAY :
query += wxT( "podcastitem_lastplay" );
break;
case guPODCASTS_COLUMN_ADDEDDATE :
query += wxT( "podcastitem_addeddate" );
break;
case guPODCASTS_COLUMN_STATUS :
query += wxT( "podcastitem_status" );
break;
}
if( desc )
query += wxT( " DESC;" );
dbRes = ExecuteQuery( query );
while( dbRes.NextRow() )
{
guPodcastItem * Item = new guPodcastItem();
Item->m_Id = dbRes.GetInt( 0 );
Item->m_ChId = dbRes.GetInt( 1 );
Item->m_Title = dbRes.GetString( 2 );
Item->m_Summary = dbRes.GetString( 3 );
Item->m_Author = dbRes.GetString( 4 );
Item->m_Enclosure = dbRes.GetString( 5 );
Item->m_Time = dbRes.GetInt( 6 );
Item->m_FileName = dbRes.GetString( 7 );
Item->m_FileSize = dbRes.GetInt( 8 );
Item->m_Length = dbRes.GetInt( 9 );
Item->m_PlayCount = dbRes.GetInt( 10 );
Item->m_AddedDate = dbRes.GetInt( 11 );
Item->m_LastPlay = dbRes.GetInt( 12 );
Item->m_Status = dbRes.GetInt( 13 );
Item->m_Channel = dbRes.GetString( 14 );
Item->m_Category = dbRes.GetString( 15 );
items->Add( Item );
}
dbRes.Finalize();
return items->Count();
}
// -------------------------------------------------------------------------------- //
void guDbPodcasts::GetPodcastCounters( const wxArrayInt &filters, wxLongLong * count, wxLongLong * len, wxLongLong * size )
{
wxString query;
wxSQLite3ResultSet dbRes;
query = wxT( "SELECT COUNT(), SUM( podcastitem_length ), SUM( podcastitem_filesize ) "
"FROM podcastitems, podcastchs "
"WHERE podcastitem_chid = podcastch_id AND podcastitem_status != 4" ); // dont get the deleted items
if( filters.Count() )
{
query += wxT( " AND " ) + ArrayToFilter( filters, wxT( "podcastitem_chid" ) );
}
dbRes = ExecuteQuery( query );
if( dbRes.NextRow() )
{
* count = dbRes.GetInt64( 0 );
* len = dbRes.GetInt64( 1 );
* size = dbRes.GetInt64( 2 );
}
dbRes.Finalize();
}
// -------------------------------------------------------------------------------- //
int guDbPodcasts::GetPodcastItems( const wxArrayInt &ids, guPodcastItemArray * items, const int order, const bool desc )
{
wxString query;
wxSQLite3ResultSet dbRes;
query = wxT( "SELECT podcastitem_id, podcastitem_chid, podcastitem_title, " \
"podcastitem_summary, podcastitem_author, podcastitem_enclosure, podcastitem_time, " \
"podcastitem_file, podcastitem_filesize, podcastitem_length, " \
"podcastitem_playcount, podcastitem_addeddate, podcastitem_lastplay, " \
"podcastitem_status, " \
"podcastch_title, podcastch_category " \
"FROM podcastitems, podcastchs " \
"WHERE podcastitem_chid = podcastch_id " \
"AND " ) + ArrayToFilter( ids, wxT( "podcastitem_id" ) );
query += wxT( " ORDER BY " );
switch( order )
{
case guPODCASTS_COLUMN_TITLE :
query += wxT( "podcastitem_title COLLATE NOCASE" );
break;
case guPODCASTS_COLUMN_CHANNEL :
query += wxT( "podcastch_title COLLATE NOCASE" );
break;
case guPODCASTS_COLUMN_CATEGORY :
query += wxT( "podcastch_category COLLATE NOCASE" );
break;
case guPODCASTS_COLUMN_DATE :
query += wxT( "podcastitem_time" );
break;
case guPODCASTS_COLUMN_LENGTH :
query += wxT( "podcastitem_length" );
break;
case guPODCASTS_COLUMN_AUTHOR :
query += wxT( "podcastitem_author COLLATE NOCASE" );
break;
case guPODCASTS_COLUMN_PLAYCOUNT :
query += wxT( "podcastitem_playcount" );
break;
case guPODCASTS_COLUMN_LASTPLAY :
query += wxT( "podcastitem_lastplay" );
break;
case guPODCASTS_COLUMN_ADDEDDATE :
query += wxT( "podcastitem_addeddate" );
break;
case guPODCASTS_COLUMN_STATUS :
query += wxT( "podcastitem_status" );
break;
}
if( desc )
query += wxT( " DESC;" );
dbRes = ExecuteQuery( query );
while( dbRes.NextRow() )
{
guPodcastItem * Item = new guPodcastItem();
Item->m_Id = dbRes.GetInt( 0 );
Item->m_ChId = dbRes.GetInt( 1 );
Item->m_Title = dbRes.GetString( 2 );
Item->m_Summary = dbRes.GetString( 3 );
Item->m_Author = dbRes.GetString( 4 );
Item->m_Enclosure = dbRes.GetString( 5 );
Item->m_Time = dbRes.GetInt( 6 );
Item->m_FileName = dbRes.GetString( 7 );
Item->m_FileSize = dbRes.GetInt( 8 );
Item->m_Length = dbRes.GetInt( 9 );
Item->m_PlayCount = dbRes.GetInt( 10 );
Item->m_AddedDate = dbRes.GetInt( 11 );
Item->m_LastPlay = dbRes.GetInt( 12 );
Item->m_Status = dbRes.GetInt( 13 );
Item->m_Channel = dbRes.GetString( 14 );
Item->m_Category = dbRes.GetString( 15 );
items->Add( Item );
}
dbRes.Finalize();
return items->Count();
}
// -------------------------------------------------------------------------------- //
void guDbPodcasts::SavePodcastItem( const int channelid, guPodcastItem * item, bool onlynew )
{
wxString query;
int ItemId;
if( ( ItemId = GetPodcastItemEnclosure( item->m_Enclosure ) ) == wxNOT_FOUND )
{
//guLogMessage( wxT( "Inserting podcastitem '%s'" ), item->m_Title.c_str() );
query = wxString::Format( wxT( "INSERT INTO podcastitems( " \
"podcastitem_id, podcastitem_chid, podcastitem_title, " \
"podcastitem_summary, podcastitem_author, podcastitem_enclosure, podcastitem_time, " \
"podcastitem_file, podcastitem_filesize, podcastitem_length, " \
"podcastitem_addeddate, podcastitem_playcount, podcastitem_lastplay, " \
"podcastitem_status ) " \
"VALUES( NULL, %u, '%s', '%s', '%s', '%s', %u, " \
"'%s', %u, %u, %lu, %u, %u, %u );" ),
channelid,
escape_query_str( item->m_Title ).c_str(),
escape_query_str( item->m_Summary ).c_str(),
escape_query_str( item->m_Author ).c_str(),
escape_query_str( item->m_Enclosure ).c_str(),
item->m_Time,
escape_query_str( item->m_FileName ).c_str(),
item->m_FileSize,
item->m_Length,
wxDateTime::GetTimeNow(),
0, 0, 0 );
ExecuteUpdate( query );
ItemId = GetLastRowId();
}
else if( !onlynew )
{
query = wxString::Format( wxT( "UPDATE podcastitems SET " \
"podcastitem_chid = %u, podcastitem_title = '%s', " \
"podcastitem_summary = '%s', podcastitem_author = '%s', " \
"podcastitem_enclosure = '%s', podcastitem_time = %u, " \
"podcastitem_file = '%s', podcastitem_filesize = %u, podcastitem_length = %u, " \
"podcastitem_status = %u " \
"WHERE podcastitem_id = %u;" ),
channelid,
escape_query_str( item->m_Title ).c_str(),
escape_query_str( item->m_Summary ).c_str(),
escape_query_str( item->m_Author ).c_str(),
escape_query_str( item->m_Enclosure ).c_str(),
item->m_Time,
escape_query_str( item->m_FileName ).c_str(),
item->m_FileSize,
item->m_Length,
item->m_Status,
ItemId );
ExecuteUpdate( query );
}
}
// -------------------------------------------------------------------------------- //
void guDbPodcasts::SavePodcastItems( const int channelid, guPodcastItemArray * items, bool onlynew )
{
int Count = items->Count();
for( int Index = 0; Index < Count; Index++ )
{
SavePodcastItem( channelid, &items->Item( Index ), onlynew );
}
}
// -------------------------------------------------------------------------------- //
void guDbPodcasts::SetPodcastItemStatus( const int itemid, const int status )
{
wxString query;
query = wxString::Format( wxT( "UPDATE podcastitems SET " \
"podcastitem_status = %u WHERE podcastitem_id = %u;" ),
status, itemid );
ExecuteUpdate( query );
}
// -------------------------------------------------------------------------------- //
void guDbPodcasts::SetPodcastItemPlayCount( const int itemid, const int playcount )
{
wxString query;
query = wxString::Format( wxT( "UPDATE podcastitems SET " \
"podcastitem_playcount = %u, podcastitem_lastplay = %lu WHERE podcastitem_id = %u;" ),
playcount, wxDateTime::GetTimeNow(), itemid );
ExecuteUpdate( query );
}
// -------------------------------------------------------------------------------- //
void guDbPodcasts::UpdatePodcastItemLength( const int itemid, const int length )
{
wxString query;
query = wxString::Format( wxT( "UPDATE podcastitems SET " \
"podcastitem_length = %u WHERE podcastitem_id = %u;" ),
length, itemid );
ExecuteUpdate( query );
}
// -------------------------------------------------------------------------------- //
int guDbPodcasts::GetPodcastItemEnclosure( const wxString &enclosure, guPodcastItem * item )
{
int RetVal = wxNOT_FOUND;
wxString query;
wxSQLite3ResultSet dbRes;
query = wxString::Format( wxT( "SELECT podcastitem_id, podcastitem_chid, podcastitem_title, " \
"podcastitem_summary, podcastitem_author, podcastitem_enclosure, podcastitem_time, " \
"podcastitem_file, podcastitem_filesize, podcastitem_length, " \
"podcastitem_playcount, podcastitem_addeddate, podcastitem_lastplay, " \
"podcastitem_status, " \
"podcastch_title, podcastch_category " \
"FROM podcastitems, podcastchs " \
"WHERE podcastitem_chid = podcastch_id AND " \
"podcastitem_enclosure = '%s';" ),
escape_query_str( enclosure ).c_str() );
dbRes = ExecuteQuery( query );
while( dbRes.NextRow() )
{
RetVal = dbRes.GetInt( 0 );
if( item )
{
item->m_Id = RetVal;
item->m_ChId = dbRes.GetInt( 1 );
item->m_Title = dbRes.GetString( 2 );
item->m_Summary = dbRes.GetString( 3 );
item->m_Author = dbRes.GetString( 4 );
item->m_Enclosure = dbRes.GetString( 5 );
item->m_Time = dbRes.GetInt( 6 );
item->m_FileName = dbRes.GetString( 7 );
item->m_FileSize = dbRes.GetInt( 8 );
item->m_Length = dbRes.GetInt( 9 );
item->m_PlayCount = dbRes.GetInt( 10 );
item->m_AddedDate = dbRes.GetInt( 11 );
item->m_LastPlay = dbRes.GetInt( 12 );
item->m_Status = dbRes.GetInt( 13 );
item->m_Channel = dbRes.GetString( 14 );
item->m_Category = dbRes.GetString( 15 );
}
}
dbRes.Finalize();
return RetVal;
}
// -------------------------------------------------------------------------------- //
int guDbPodcasts::GetPodcastItemId( const int itemid, guPodcastItem * item )
{
int RetVal = wxNOT_FOUND;
wxString query;
wxSQLite3ResultSet dbRes;
query = wxString::Format( wxT( "SELECT podcastitem_id, podcastitem_chid, podcastitem_title, " \
"podcastitem_summary, podcastitem_author, podcastitem_enclosure, podcastitem_time, " \
"podcastitem_file, podcastitem_filesize, podcastitem_length, " \
"podcastitem_playcount, podcastitem_addeddate, podcastitem_lastplay, " \
"podcastitem_status, " \
"podcastch_title, podcastch_category " \
"FROM podcastitems, podcastchs " \
"WHERE podcastitem_chid = podcastch_id AND " \
"podcastitem_id = %u LIMIT 1;" ),
itemid );
dbRes = ExecuteQuery( query );
while( dbRes.NextRow() )
{
RetVal = dbRes.GetInt( 0 );
if( item )
{
item->m_Id = RetVal;
item->m_ChId = dbRes.GetInt( 1 );
item->m_Title = dbRes.GetString( 2 );
item->m_Summary = dbRes.GetString( 3 );
item->m_Author = dbRes.GetString( 4 );
item->m_Enclosure = dbRes.GetString( 5 );
item->m_Time = dbRes.GetInt( 6 );
item->m_FileName = dbRes.GetString( 7 );
item->m_FileSize = dbRes.GetInt( 8 );
item->m_Length = dbRes.GetInt( 9 );
item->m_PlayCount = dbRes.GetInt( 10 );
item->m_AddedDate = dbRes.GetInt( 11 );
item->m_LastPlay = dbRes.GetInt( 12 );
item->m_Status = dbRes.GetInt( 13 );
item->m_Channel = dbRes.GetString( 14 );
item->m_Category = dbRes.GetString( 15 );
}
}
dbRes.Finalize();
return RetVal;
}
// -------------------------------------------------------------------------------- //
int guDbPodcasts::GetPodcastItemFile( const wxString &filename, guPodcastItem * item )
{
int RetVal = 0;
wxString query;
wxSQLite3ResultSet dbRes;
query = wxString::Format( wxT( "SELECT podcastitem_id, podcastitem_chid, podcastitem_title, " \
"podcastitem_summary, podcastitem_author, podcastitem_enclosure, podcastitem_time, " \
"podcastitem_file, podcastitem_filesize, podcastitem_length, " \
"podcastitem_playcount, podcastitem_addeddate, podcastitem_lastplay, " \
"podcastitem_status, " \
"podcastch_title, podcastch_category " \
"FROM podcastitems, podcastchs " \
"WHERE podcastitem_chid = podcastch_id AND " \
"podcastitem_file = '%s' LIMIT 1;" ),
escape_query_str( filename ).c_str() );
dbRes = ExecuteQuery( query );
while( dbRes.NextRow() )
{
RetVal = dbRes.GetInt( 0 );
if( item )
{
item->m_Id = RetVal;
item->m_ChId = dbRes.GetInt( 1 );
item->m_Title = dbRes.GetString( 2 );
item->m_Summary = dbRes.GetString( 3 );
item->m_Author = dbRes.GetString( 4 );
item->m_Enclosure = dbRes.GetString( 5 );
item->m_Time = dbRes.GetInt( 6 );
item->m_FileName = dbRes.GetString( 7 );
item->m_FileSize = dbRes.GetInt( 8 );
item->m_Length = dbRes.GetInt( 9 );
item->m_PlayCount = dbRes.GetInt( 10 );
item->m_AddedDate = dbRes.GetInt( 11 );
item->m_LastPlay = dbRes.GetInt( 12 );
item->m_Status = dbRes.GetInt( 13 );
item->m_Channel = dbRes.GetString( 14 );
item->m_Category = dbRes.GetString( 15 );
}
}
dbRes.Finalize();
return RetVal;
}
// -------------------------------------------------------------------------------- //
void guDbPodcasts::DelPodcastItem( const int itemid )
{
wxString query;
query = wxString::Format( wxT( "UPDATE podcastitems SET " \
"podcastitem_status = %u WHERE podcastitem_id = %u;" ),
guPODCAST_STATUS_DELETED, itemid );
ExecuteUpdate( query );
}
// -------------------------------------------------------------------------------- //
void guDbPodcasts::DelPodcastItems( const int channelid )
{
wxString query;
query = wxString::Format( wxT( "DELETE FROM podcastitems " \
"WHERE podcastitem_chid = %u;" ), channelid );
ExecuteUpdate( query );
}
// -------------------------------------------------------------------------------- //
int guDbPodcasts::GetPendingPodcasts( guPodcastItemArray * items )
{
wxString query;
wxSQLite3ResultSet dbRes;
query = wxT( "SELECT podcastitem_id, podcastitem_chid, podcastitem_title, " \
"podcastitem_summary, podcastitem_author, podcastitem_enclosure, podcastitem_time, " \
"podcastitem_file, podcastitem_filesize, podcastitem_length, " \
"podcastitem_playcount, podcastitem_addeddate, podcastitem_lastplay, " \
"podcastitem_status, " \
"podcastch_title, podcastch_category " \
"FROM podcastitems, podcastchs " \
"WHERE podcastitem_chid = podcastch_id " \
"AND podcastitem_status IN ( 1, 2 ) " \
"ORDER BY podcastitem_status DESC;" );
dbRes = ExecuteQuery( query );
while( dbRes.NextRow() )
{
guPodcastItem * Item = new guPodcastItem();
Item->m_Id = dbRes.GetInt( 0 );
Item->m_ChId = dbRes.GetInt( 1 );
Item->m_Title = dbRes.GetString( 2 );
Item->m_Summary = dbRes.GetString( 3 );
Item->m_Author = dbRes.GetString( 4 );
Item->m_Enclosure = dbRes.GetString( 5 );
Item->m_Time = dbRes.GetInt( 6 );
Item->m_FileName = dbRes.GetString( 7 );
Item->m_FileSize = dbRes.GetInt( 8 );
Item->m_Length = dbRes.GetInt( 9 );
Item->m_PlayCount = dbRes.GetInt( 10 );
Item->m_AddedDate = dbRes.GetInt( 11 );
Item->m_LastPlay = dbRes.GetInt( 12 );
Item->m_Status = dbRes.GetInt( 13 );
Item->m_Channel = dbRes.GetString( 14 );
Item->m_Category = dbRes.GetString( 15 );
items->Add( Item );
}
dbRes.Finalize();
return items->Count();
}
// -------------------------------------------------------------------------------- //
int guDbPodcasts::GetPodcastFiles( const wxArrayInt &channels, guDataObjectComposite * files )
{
int Count = 0;
wxString query;
wxArrayString Filenames;
wxSQLite3ResultSet dbRes;
query = wxT( "SELECT podcastitem_file FROM podcastitems WHERE " ) +
ArrayToFilter( channels, wxT( "podcastitem_chid" ) );
dbRes = ExecuteQuery( query );
while( dbRes.NextRow() )
{
Filenames.Add( guFileDnDEncode( dbRes.GetString( 0 ) ) );
Count++;
}
files->SetFiles( Filenames );
dbRes.Finalize();
return Count;
}
// -------------------------------------------------------------------------------- //
void guDbPodcasts::UpdateItemPaths( const wxString &oldpath, const wxString &newpath )
{
wxString query;
query = wxString::Format( wxT( "UPDATE podcastitems SET podcastitem_file = replace( podcastitem_file, '%s', '%s' )" ),
escape_query_str( oldpath ).c_str(), escape_query_str( newpath ).c_str() );
guLogMessage( wxT( "Updating path: %s" ), query.c_str() );
ExecuteUpdate( query );
}
// -------------------------------------------------------------------------------- //
// guPostcastPanel
// -------------------------------------------------------------------------------- //
guPodcastPanel::guPodcastPanel( wxWindow * parent, guDbPodcasts * db, guMainFrame * mainframe, guPlayerPanel * playerpanel ) :
guAuiManagerPanel( parent )
{
m_Db = db;
m_MainFrame = mainframe;
m_PlayerPanel = playerpanel;
m_LastChannelInfoId = wxNOT_FOUND;
m_LastPodcastInfoId = wxNOT_FOUND;
wxPanel * ChannelsPanel;
wxPanel * PodcastsPanel;
wxStaticText * DetailDescLabel;
wxStaticText * DetailAuthorLabel;
wxStaticText * DetailOwnerLabel;
wxStaticLine * DetailStaticLine1;
wxStaticLine * DetailStaticLine2;
wxStaticText * DetailItemTitleLabel;
wxStaticText * DetailItemSumaryLabel;
wxStaticText * DetailItemDateLabel;
wxStaticText * DetailItemLengthLabel;
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->RegisterObject( this );
InitPanelData();
// Check that the directory to store podcasts are created
m_PodcastsPath = Config->ReadStr( CONFIG_KEY_PODCASTS_PATH,
guPATH_PODCASTS,
CONFIG_PATH_PODCASTS );
if( !wxDirExists( m_PodcastsPath ) )
{
wxMkdir( m_PodcastsPath, 0770 );
}
m_VisiblePanels = Config->ReadNum( CONFIG_KEY_PODCASTS_VISIBLE_PANELS,
guPANEL_PODCASTS_VISIBLE_DEFAULT,
CONFIG_PATH_PODCASTS );
ChannelsPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer * ChannelsMainSizer;
ChannelsMainSizer = new wxBoxSizer( wxVERTICAL );
m_ChannelsListBox = new guChannelsListBox( ChannelsPanel, m_Db, _( "Channels" ) );
ChannelsMainSizer->Add( m_ChannelsListBox, 1, wxEXPAND, 5 );
ChannelsPanel->SetSizer( ChannelsMainSizer );
ChannelsPanel->Layout();
ChannelsMainSizer->Fit( ChannelsPanel );
m_AuiManager.AddPane( ChannelsPanel,
wxAuiPaneInfo().Name( wxT( "PodcastsChannels" ) ).Caption( _( "Channels" ) ).
MinSize( 50, 50 ).
CloseButton( Config->ReadBool( CONFIG_KEY_GENERAL_SHOW_CLOSE_BUTTON, true, CONFIG_PATH_GENERAL ) ).
Dockable( true ).Left() );
PodcastsPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer * MainPodcastsSizer;
MainPodcastsSizer = new wxBoxSizer( wxVERTICAL );
m_PodcastsListBox = new guPodcastListBox( PodcastsPanel, m_Db );
MainPodcastsSizer->Add( m_PodcastsListBox, 1, wxEXPAND, 5 );
PodcastsPanel->SetSizer( MainPodcastsSizer );
PodcastsPanel->Layout();
MainPodcastsSizer->Fit( PodcastsPanel );
m_AuiManager.AddPane( PodcastsPanel, wxAuiPaneInfo().Name( wxT( "PodcastsItems" ) ).Caption( _( "Podcasts" ) ).
MinSize( 50, 50 ).
CenterPane() );
wxPanel * DetailsPanel;
DetailsPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_DetailMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* DetailSizer;
DetailSizer = new wxStaticBoxSizer( new wxStaticBox( DetailsPanel, wxID_ANY, _(" Details ") ), wxVERTICAL );
m_DetailScrolledWindow = new wxScrolledWindow( DetailsPanel, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxHSCROLL );
m_DetailScrolledWindow->SetScrollRate( 5, 5 );
m_DetailScrolledWindow->SetMinSize( wxSize( -1,100 ) );
m_DetailFlexGridSizer = new wxFlexGridSizer( 2, 0, 0 );
m_DetailFlexGridSizer->AddGrowableCol( 1 );
m_DetailFlexGridSizer->SetFlexibleDirection( wxBOTH );
m_DetailFlexGridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_DetailImage = new wxStaticBitmap( m_DetailScrolledWindow, wxID_ANY, guImage( guIMAGE_INDEX_mid_podcast ), wxDefaultPosition, wxSize( 60,60 ), 0 );
m_DetailFlexGridSizer->Add( m_DetailImage, 0, wxALL, 5 );
m_DetailChannelTitle = new wxStaticText( m_DetailScrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_DetailChannelTitle->Wrap( -1 );
m_DetailChannelTitle->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
m_DetailFlexGridSizer->Add( m_DetailChannelTitle, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
DetailDescLabel = new wxStaticText( m_DetailScrolledWindow, wxID_ANY, _("Description:"), wxDefaultPosition, wxDefaultSize, 0 );
DetailDescLabel->Wrap( -1 );
DetailDescLabel->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );
m_DetailFlexGridSizer->Add( DetailDescLabel, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_DetailDescText = new wxStaticText( m_DetailScrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_NO_AUTORESIZE );
//m_DetailDescText->Wrap( 445 );
m_DetailFlexGridSizer->Add( m_DetailDescText, 0, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
DetailAuthorLabel = new wxStaticText( m_DetailScrolledWindow, wxID_ANY, _("Author:"), wxDefaultPosition, wxDefaultSize, 0 );
DetailAuthorLabel->Wrap( -1 );
DetailAuthorLabel->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );
m_DetailFlexGridSizer->Add( DetailAuthorLabel, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_DetailAuthorText = new wxStaticText( m_DetailScrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_DetailAuthorText->Wrap( -1 );
m_DetailFlexGridSizer->Add( m_DetailAuthorText, 0, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
DetailOwnerLabel = new wxStaticText( m_DetailScrolledWindow, wxID_ANY, _("Owner:"), wxDefaultPosition, wxDefaultSize, 0 );
DetailOwnerLabel->Wrap( -1 );
DetailOwnerLabel->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );
m_DetailFlexGridSizer->Add( DetailOwnerLabel, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_DetailOwnerText = new wxStaticText( m_DetailScrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_DetailOwnerText->Wrap( -1 );
m_DetailFlexGridSizer->Add( m_DetailOwnerText, 0, wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
wxStaticText * DetailLinkLabel;
DetailLinkLabel = new wxStaticText( m_DetailScrolledWindow, wxID_ANY, _("Link:"), wxDefaultPosition, wxDefaultSize, 0 );
DetailLinkLabel->Wrap( -1 );
DetailLinkLabel->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );
m_DetailFlexGridSizer->Add( DetailLinkLabel, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_DetailLinkText = new wxHyperlinkCtrl( m_DetailScrolledWindow, wxID_ANY, " ", " ", wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE );
m_DetailFlexGridSizer->Add( m_DetailLinkText, 0, wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
DetailStaticLine1 = new wxStaticLine( m_DetailScrolledWindow, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
m_DetailFlexGridSizer->Add( DetailStaticLine1, 0, wxEXPAND|wxBOTTOM|wxLEFT, 5 );
DetailStaticLine2 = new wxStaticLine( m_DetailScrolledWindow, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
m_DetailFlexGridSizer->Add( DetailStaticLine2, 0, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
DetailItemTitleLabel = new wxStaticText( m_DetailScrolledWindow, wxID_ANY, _("Title:"), wxDefaultPosition, wxDefaultSize, 0 );
DetailItemTitleLabel->Wrap( -1 );
DetailItemTitleLabel->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );
m_DetailFlexGridSizer->Add( DetailItemTitleLabel, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_DetailItemTitleText = new wxStaticText( m_DetailScrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_DetailItemTitleText->Wrap( -1 );
m_DetailFlexGridSizer->Add( m_DetailItemTitleText, 0, wxBOTTOM|wxRIGHT, 5 );
DetailItemSumaryLabel = new wxStaticText( m_DetailScrolledWindow, wxID_ANY, _("Sumary:"), wxDefaultPosition, wxDefaultSize, 0 );
DetailItemSumaryLabel->Wrap( -1 );
DetailItemSumaryLabel->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );
m_DetailFlexGridSizer->Add( DetailItemSumaryLabel, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_DetailItemSumaryText = new wxStaticText( m_DetailScrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_NO_AUTORESIZE );
//m_DetailItemSumaryText->Wrap( 300 );
m_DetailFlexGridSizer->Add( m_DetailItemSumaryText, 0, wxBOTTOM|wxRIGHT|wxEXPAND, 5 );
DetailItemDateLabel = new wxStaticText( m_DetailScrolledWindow, wxID_ANY, _("Date:"), wxDefaultPosition, wxDefaultSize, 0 );
DetailItemDateLabel->Wrap( -1 );
DetailItemDateLabel->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );
m_DetailFlexGridSizer->Add( DetailItemDateLabel, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_DetailItemDateText = new wxStaticText( m_DetailScrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_DetailItemDateText->Wrap( -1 );
m_DetailFlexGridSizer->Add( m_DetailItemDateText, 0, wxBOTTOM|wxRIGHT, 5 );
DetailItemLengthLabel = new wxStaticText( m_DetailScrolledWindow, wxID_ANY, _("Length:"), wxDefaultPosition, wxDefaultSize, 0 );
DetailItemLengthLabel->Wrap( -1 );
DetailItemLengthLabel->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );
m_DetailFlexGridSizer->Add( DetailItemLengthLabel, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_RIGHT, 5 );
m_DetailItemLengthText = new wxStaticText( m_DetailScrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_DetailItemLengthText->Wrap( -1 );
m_DetailFlexGridSizer->Add( m_DetailItemLengthText, 0, wxBOTTOM|wxRIGHT, 5 );
m_DetailScrolledWindow->SetSizer( m_DetailFlexGridSizer );
m_DetailScrolledWindow->Layout();
m_DetailFlexGridSizer->Fit( m_DetailScrolledWindow );
DetailSizer->Add( m_DetailScrolledWindow, 1, wxEXPAND|wxALL, 5 );
m_DetailMainSizer->Add( DetailSizer, 1, wxEXPAND|wxALL, 5 );
DetailsPanel->SetSizer( m_DetailMainSizer );
DetailsPanel->Layout();
DetailSizer->Fit( DetailsPanel );
m_AuiManager.AddPane( DetailsPanel, wxAuiPaneInfo().Name( wxT( "PodcastsDetails" ) ).Caption( _( "Podcast Details" ) ).
MinSize( 100, 100 ).
CloseButton( Config->ReadBool( CONFIG_KEY_GENERAL_SHOW_CLOSE_BUTTON, true, CONFIG_PATH_GENERAL ) ).
Dockable( true ).Bottom() );
wxString PodcastLayout = Config->ReadStr( CONFIG_KEY_PODCASTS_LASTLAYOUT,
wxEmptyString,
CONFIG_PATH_PODCASTS );
if( Config->GetIgnoreLayouts() || PodcastLayout.IsEmpty() )
{
m_VisiblePanels = guPANEL_PODCASTS_VISIBLE_DEFAULT;
PodcastLayout = wxT( "layout2|name=PodcastsChannels;caption=" ) + wxString( _( "Channels" ) );
PodcastLayout += wxT( ";state=2099196;dir=4;layer=0;row=0;pos=0;prop=100000;bestw=50;besth=50;minw=50;minh=50;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|" );
PodcastLayout += wxT( "name=PodcastsItems;caption=Podcasts;state=768;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=50;besth=50;minw=50;minh=50;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|" );
PodcastLayout += wxT( "name=PodcastsDetails;caption=" ) + wxString( _( "Details" ) );
PodcastLayout += wxT( ";state=2099196;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=100;besth=132;minw=100;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(4,0,0)=181|" );
PodcastLayout += wxT( "dock_size(5,0,0)=52|dock_size(3,0,0)=479|" );
//m_AuiManager.Update();
}
m_AuiManager.LoadPerspective( PodcastLayout, true );
// Bind events
Bind( wxEVT_MENU, &guPodcastPanel::AddChannel, this, ID_PODCASTS_CHANNEL_ADD );
Bind( wxEVT_MENU, &guPodcastPanel::DeleteChannels, this, ID_PODCASTS_CHANNEL_DEL );
Bind( wxEVT_MENU, &guPodcastPanel::ChannelProperties, this, ID_PODCASTS_CHANNEL_PROPERTIES );
Bind( wxEVT_MENU, &guPodcastPanel::UpdateChannels, this, ID_PODCASTS_CHANNEL_UPDATE );
m_ChannelsListBox->Bind( wxEVT_MENU, &guPodcastPanel::ChannelsCopyTo, this, ID_COPYTO_BASE, ID_COPYTO_BASE + guCOPYTO_MAXCOUNT );
Bind( guPodcastEvent, &guPodcastPanel::OnPodcastItemUpdated, this, ID_PODCASTS_ITEM_UPDATED );
m_ChannelsListBox->Bind( wxEVT_LISTBOX, &guPodcastPanel::OnChannelsSelected, this );
m_ChannelsListBox->Bind( wxEVT_LISTBOX_DCLICK, &guPodcastPanel::OnChannelsActivated, this );
m_PodcastsListBox->Bind( wxEVT_LIST_COL_CLICK, &guPodcastPanel::OnPodcastsColClick, this );
m_PodcastsListBox->Bind( wxEVT_LISTBOX, &guPodcastPanel::OnPodcastItemSelected, this );
m_PodcastsListBox->Bind( wxEVT_LISTBOX_DCLICK, &guPodcastPanel::OnPodcastItemActivated, this );
Bind( wxEVT_MENU, &guPodcastPanel::OnPodcastItemPlay, this, ID_PODCASTS_ITEM_PLAY );
Bind( wxEVT_MENU, &guPodcastPanel::OnPodcastItemEnqueue, this, ID_PODCASTS_ITEM_ENQUEUE_AFTER_ALL, ID_PODCASTS_ITEM_ENQUEUE_AFTER_ARTIST );
Bind( wxEVT_MENU, &guPodcastPanel::OnPodcastItemDelete, this, ID_PODCASTS_ITEM_DEL );
Bind( wxEVT_MENU, &guPodcastPanel::OnPodcastItemDownload, this, ID_PODCASTS_ITEM_DOWNLOAD );
m_PodcastsListBox->Bind( wxEVT_MENU, &guPodcastPanel::OnPodcastItemCopyTo, this, ID_COPYTO_BASE, ID_COPYTO_BASE + guCOPYTO_MAXCOUNT );
Bind( guConfigUpdatedEvent, &guPodcastPanel::OnConfigUpdated, this, ID_CONFIG_UPDATED );
}
// -------------------------------------------------------------------------------- //
guPodcastPanel::~guPodcastPanel()
{
// Save the Splitter positions into the main config
guConfig * Config = ( guConfig * ) guConfig::Get();
if( Config )
{
Config->UnRegisterObject( this );
Config->WriteNum( CONFIG_KEY_PODCASTS_VISIBLE_PANELS,
m_VisiblePanels,
CONFIG_PATH_PODCASTS );
Config->WriteStr( CONFIG_KEY_PODCASTS_LASTLAYOUT,
m_AuiManager.SavePerspective(),
CONFIG_PATH_PODCASTS );
}
// Unbind events
Unbind( wxEVT_MENU, &guPodcastPanel::AddChannel, this, ID_PODCASTS_CHANNEL_ADD );
Unbind( wxEVT_MENU, &guPodcastPanel::DeleteChannels, this, ID_PODCASTS_CHANNEL_DEL );
Unbind( wxEVT_MENU, &guPodcastPanel::ChannelProperties, this, ID_PODCASTS_CHANNEL_PROPERTIES );
Unbind( wxEVT_MENU, &guPodcastPanel::UpdateChannels, this, ID_PODCASTS_CHANNEL_UPDATE );
m_ChannelsListBox->Unbind( wxEVT_MENU, &guPodcastPanel::ChannelsCopyTo, this, ID_COPYTO_BASE, ID_COPYTO_BASE + guCOPYTO_MAXCOUNT );
Unbind( guPodcastEvent, &guPodcastPanel::OnPodcastItemUpdated, this, ID_PODCASTS_ITEM_UPDATED );
m_ChannelsListBox->Unbind( wxEVT_LISTBOX, &guPodcastPanel::OnChannelsSelected, this );
m_ChannelsListBox->Unbind( wxEVT_LISTBOX_DCLICK, &guPodcastPanel::OnChannelsActivated, this );
m_PodcastsListBox->Unbind( wxEVT_LIST_COL_CLICK, &guPodcastPanel::OnPodcastsColClick, this );
m_PodcastsListBox->Unbind( wxEVT_LISTBOX, &guPodcastPanel::OnPodcastItemSelected, this );
m_PodcastsListBox->Unbind( wxEVT_LISTBOX_DCLICK, &guPodcastPanel::OnPodcastItemActivated, this );
Unbind( wxEVT_MENU, &guPodcastPanel::OnPodcastItemPlay, this, ID_PODCASTS_ITEM_PLAY );
Unbind( wxEVT_MENU, &guPodcastPanel::OnPodcastItemEnqueue, this, ID_PODCASTS_ITEM_ENQUEUE_AFTER_ALL, ID_PODCASTS_ITEM_ENQUEUE_AFTER_ARTIST );
Unbind( wxEVT_MENU, &guPodcastPanel::OnPodcastItemDelete, this, ID_PODCASTS_ITEM_DEL );
Unbind( wxEVT_MENU, &guPodcastPanel::OnPodcastItemDownload, this, ID_PODCASTS_ITEM_DOWNLOAD );
m_PodcastsListBox->Unbind( wxEVT_MENU, &guPodcastPanel::OnPodcastItemCopyTo, this, ID_COPYTO_BASE, ID_COPYTO_BASE + guCOPYTO_MAXCOUNT );
Unbind( guConfigUpdatedEvent, &guPodcastPanel::OnConfigUpdated, this, ID_CONFIG_UPDATED );
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::InitPanelData( void )
{
m_PanelNames.Add( wxT( "PodcastsChannels" ) );
m_PanelNames.Add( wxT( "PodcastsDetails" ) );
m_PanelIds.Add( guPANEL_PODCASTS_CHANNELS );
m_PanelIds.Add( guPANEL_PODCASTS_DETAILS );
m_PanelCmdIds.Add( ID_MENU_VIEW_POD_CHANNELS );
m_PanelCmdIds.Add( ID_MENU_VIEW_POD_DETAILS );
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::OnConfigUpdated( wxCommandEvent &event )
{
int Flags = event.GetInt();
if( Flags & guPREFERENCE_PAGE_FLAG_PODCASTS )
{
guConfig * Config = ( guConfig * ) guConfig::Get();
// Check that the directory to store podcasts are created
m_PodcastsPath = Config->ReadStr( CONFIG_KEY_PODCASTS_PATH,
guPATH_PODCASTS,
CONFIG_PATH_PODCASTS );
if( !wxDirExists( m_PodcastsPath ) )
{
wxMkdir( m_PodcastsPath, 0770 );
}
}
}
// -------------------------------------------------------------------------------- //
void NormalizePodcastChannel( guPodcastChannel * PodcastChannel )
{
int ChId = PodcastChannel->m_Id;
wxString ChName = PodcastChannel->m_Title;
wxString Category = PodcastChannel->m_Category;
int Count = PodcastChannel->m_Items.Count();
for( int Index = 0; Index < Count; Index++ )
{
guPodcastItem * PodcastItem = &PodcastChannel->m_Items[ Index ];
PodcastItem->m_ChId = ChId;
PodcastItem->m_Channel = ChName;
PodcastItem->m_Category = Category;
}
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::AddChannel( wxCommandEvent &event )
{
guNewPodcastChannelSelector * NewPodcastChannel = new guNewPodcastChannelSelector( this );
if( NewPodcastChannel->ShowModal() == wxID_OK )
{
wxSetCursor( * wxHOURGLASS_CURSOR );
wxTheApp->Yield();
wxString PodcastUrl = NewPodcastChannel->GetValue().Trim( false ).Trim( true );
if( !PodcastUrl.IsEmpty() )
{
// If we find an itunes link we replace the itpc to the standard http
if( PodcastUrl.StartsWith( wxT( "itpc://" ) ) )
{
PodcastUrl.Replace( wxT( "itpc://" ), wxT( "http://" ) );
}
guPodcastChannel PodcastChannel( PodcastUrl );
wxSetCursor( * wxSTANDARD_CURSOR );
//
guChannelEditor * ChannelEditor = new guChannelEditor( this, &PodcastChannel );
if( ChannelEditor->ShowModal() == wxID_OK )
{
wxSetCursor( * wxHOURGLASS_CURSOR );
ChannelEditor->GetEditData();
// Create the channel dir
wxFileName ChannelDir = wxFileName( m_PodcastsPath + wxT( "/" ) +
PodcastChannel.m_Title );
if( ChannelDir.Normalize( wxPATH_NORM_ALL | wxPATH_NORM_CASE ) )
{
if( !wxDirExists( ChannelDir.GetFullPath() ) )
{
wxMkdir( ChannelDir.GetFullPath(), 0770 );
}
}
PodcastChannel.CheckLogo();
//
//guLogMessage( wxT( "The Channel have DownloadType : %u" ), PodcastChannel.m_DownloadType );
m_Db->SavePodcastChannel( &PodcastChannel );
PodcastChannel.CheckDeleteItems( m_Db );
PodcastChannel.CheckDownloadItems( m_Db, m_MainFrame );
m_ChannelsListBox->ReloadItems();
}
ChannelEditor->Destroy();
}
wxSetCursor( * wxSTANDARD_CURSOR );
}
NewPodcastChannel->Destroy();
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::DeleteChannels( wxCommandEvent &event )
{
if( wxMessageBox( _( "Are you sure to delete the selected podcast channel?" ),
_( "Confirm" ),
wxICON_QUESTION|wxYES_NO|wxNO_DEFAULT, this ) == wxYES )
{
wxArrayInt SelectedItems = m_ChannelsListBox->GetSelectedItems();
int Count = SelectedItems.Count();
if( Count )
{
wxSetCursor( * wxHOURGLASS_CURSOR );
for( int Index = 0; Index < Count; Index++ )
{
m_Db->DelPodcastChannel( SelectedItems[ Index ] );
}
m_ChannelsListBox->ReloadItems();
wxSetCursor( * wxSTANDARD_CURSOR );
}
}
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::ChannelProperties( wxCommandEvent &event )
{
guPodcastChannel PodcastChannel;
wxArrayInt SelectedItems = m_ChannelsListBox->GetSelectedItems();
m_Db->GetPodcastChannelId( SelectedItems[ 0 ], &PodcastChannel );
guChannelEditor * ChannelEditor = new guChannelEditor( this, &PodcastChannel );
if( ChannelEditor->ShowModal() == wxID_OK )
{
wxSetCursor( * wxHOURGLASS_CURSOR );
ChannelEditor->GetEditData();
// Create the channel dir
wxFileName ChannelDir = wxFileName( m_PodcastsPath + wxT( "/" ) +
PodcastChannel.m_Title );
if( ChannelDir.Normalize( wxPATH_NORM_ALL | wxPATH_NORM_CASE ) )
{
if( !wxDirExists( ChannelDir.GetFullPath() ) )
{
wxMkdir( ChannelDir.GetFullPath(), 0770 );
}
}
PodcastChannel.CheckLogo();
//
//guLogMessage( wxT( "The Channel have DownloadType : %u" ), PodcastChannel.m_DownloadType );
m_Db->SavePodcastChannel( &PodcastChannel );
PodcastChannel.CheckDeleteItems( m_Db );
PodcastChannel.CheckDownloadItems( m_Db, m_MainFrame );
m_ChannelsListBox->ReloadItems();
wxSetCursor( * wxSTANDARD_CURSOR );
}
ChannelEditor->Destroy();
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::ChannelsCopyTo( wxCommandEvent &event )
{
guPodcastItemArray PodcastItems;
guTrackArray * Tracks = new guTrackArray();
m_Db->GetPodcastItems( &PodcastItems, m_PodcastsListBox->GetFilters(), m_PodcastsListBox->GetOrder(), m_PodcastsListBox->GetOrderDesc() );
int Count = PodcastItems.Count();
for( int Index = 0; Index < Count; Index++ )
{
guTrack * Track = new guTrack();
if( Track )
{
Track->m_Type = guTRACK_TYPE_PODCAST;
Track->m_SongId = PodcastItems[ Index ].m_Id;
Track->m_FileName = PodcastItems[ Index ].m_FileName;
Track->m_SongName = PodcastItems[ Index ].m_Title;
Track->m_ArtistName = PodcastItems[ Index ].m_Author;
Track->m_AlbumId = PodcastItems[ Index ].m_ChId;
Track->m_AlbumName = PodcastItems[ Index ].m_Channel;
Track->m_Length = PodcastItems[ Index ].m_Length;
Track->m_PlayCount = PodcastItems[ Index ].m_PlayCount;
Track->m_GenreName = wxT( "Podcasts" );
Track->m_Number = Index;
Track->m_Rating = -1;
Track->m_CoverId = 0;
Track->m_Year = 0; // Get year from item date
Tracks->Add( Track );
}
}
int CommandIndex = event.GetId() - ID_COPYTO_BASE;
if( CommandIndex >= guCOPYTO_DEVICE_BASE )
{
CommandIndex -= guCOPYTO_DEVICE_BASE;
event.SetId( ID_MAINFRAME_COPYTODEVICE_TRACKS );
}
else
{
event.SetId( ID_MAINFRAME_COPYTO );
}
event.SetInt( CommandIndex );
event.SetClientData( ( void * ) Tracks );
wxPostEvent( m_MainFrame, event );
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::UpdateChannels( wxCommandEvent &event )
{
wxArrayInt Selected = m_ChannelsListBox->GetSelectedItems();
int Count = Selected.Count();
if( Count )
{
wxSetCursor( * wxHOURGLASS_CURSOR );
guPodcastChannel PodcastChannel;
for( int Index = 0; Index < Count; Index++ )
{
if( m_Db->GetPodcastChannelId( Selected[ Index ], &PodcastChannel ) != wxNOT_FOUND )
{
ProcessChannel( &PodcastChannel );
}
}
wxSetCursor( * wxSTANDARD_CURSOR );
}
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::OnChannelsSelected( wxCommandEvent &event )
{
wxArrayInt SelectedItems = m_ChannelsListBox->GetSelectedItems();
m_PodcastsListBox->SetFilters( SelectedItems );
m_PodcastsListBox->ReloadItems();
if( SelectedItems.Count() == 1 && SelectedItems[ 0 ] != 0 )
UpdateChannelInfo( SelectedItems[ 0 ] );
else
UpdateChannelInfo( -1 );
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::ProcessChannel( guPodcastChannel * channel )
{
wxSetCursor( * wxHOURGLASS_CURSOR );
wxTheApp->Yield();
channel->Update( m_Db, m_MainFrame );
m_ChannelsListBox->ReloadItems( false );
m_PodcastsListBox->ReloadItems( false );
wxSetCursor( * wxSTANDARD_CURSOR );
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::OnChannelsActivated( wxCommandEvent &event )
{
wxArrayInt Selected = m_ChannelsListBox->GetSelectedItems();
if( Selected.Count() )
{
guPodcastChannel PodcastChannel;
if( m_Db->GetPodcastChannelId( Selected[ 0 ], &PodcastChannel ) != wxNOT_FOUND )
{
ProcessChannel( &PodcastChannel );
}
}
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::OnPodcastsColClick( wxListEvent &event )
{
int ColId = m_PodcastsListBox->GetColumnId( event.m_col );
m_PodcastsListBox->SetOrder( ColId );
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::OnPodcastItemSelected( wxCommandEvent &event )
{
wxArrayInt Selection = m_PodcastsListBox->GetSelectedItems();
UpdatePodcastInfo( Selection.Count() ? Selection[ 0 ] : -1 );
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::UpdatePodcastInfo( int itemid )
{
if( m_LastPodcastInfoId == itemid )
return;
m_LastPodcastInfoId = itemid;
guPodcastItem PodcastItem;
//
//guLogMessage( wxT( "Updating the podcast info of the item %u" ), itemid );
if( itemid > 0 )
{
m_Db->GetPodcastItemId( itemid, &PodcastItem );
UpdateChannelInfo( PodcastItem.m_ChId );
m_DetailItemTitleText->SetLabel( PodcastItem.m_Title );
m_DetailItemSumaryText->SetLabel( PodcastItem.m_Summary );
wxDateTime AddedDate;
AddedDate.Set( ( time_t ) PodcastItem.m_Time );
m_DetailItemDateText->SetLabel( AddedDate.Format( wxT( "%a, %d %b %Y %T %z" ) ) );
m_DetailItemLengthText->SetLabel( LenToString( PodcastItem.m_Length ) );
}
else
{
m_DetailItemTitleText->SetLabel( wxEmptyString );
m_DetailItemSumaryText->SetLabel( wxEmptyString );
m_DetailItemDateText->SetLabel( wxEmptyString );
m_DetailItemLengthText->SetLabel( wxEmptyString );
}
m_DetailMainSizer->Layout();
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::UpdateChannelInfo( int itemid )
{
if( m_LastChannelInfoId == itemid )
return;
m_LastChannelInfoId = itemid;
guPodcastChannel PodcastChannel;
//
//guLogMessage( wxT( "Updating the channel info of the item %u" ), itemid );
if( itemid > 0 )
{
m_Db->GetPodcastChannelId( itemid, &PodcastChannel );
// Set Image...
wxFileName ImageFile = wxFileName( m_PodcastsPath + wxT( "/" ) +
PodcastChannel.m_Title + wxT( "/" ) +
PodcastChannel.m_Title + wxT( ".jpg" ) );
if( ImageFile.Normalize( wxPATH_NORM_ALL|wxPATH_NORM_CASE ) )
{
wxImage PodcastImage;
if( wxFileExists( ImageFile.GetFullPath() ) &&
PodcastImage.LoadFile( ImageFile.GetFullPath() ) &&
PodcastImage.IsOk() )
{
m_DetailImage->SetBitmap( PodcastImage );
}
else
m_DetailImage->SetBitmap( guBitmap( guIMAGE_INDEX_mid_podcast ) );
}
m_DetailChannelTitle->SetLabel( PodcastChannel.m_Title );
m_DetailDescText->SetLabel( PodcastChannel.m_Description );
m_DetailAuthorText->SetLabel( PodcastChannel.m_Author );
m_DetailOwnerText->SetLabel( PodcastChannel.m_OwnerName +
wxT( " (" ) + PodcastChannel.m_OwnerEmail + wxT( ")" ) );
m_DetailLinkText->SetLabel( PodcastChannel.m_Url );
m_DetailLinkText->SetURL( PodcastChannel.m_Url );
}
else
{
m_DetailImage->SetBitmap( guBitmap( guIMAGE_INDEX_mid_podcast ) );
m_DetailChannelTitle->SetLabel( wxEmptyString );
m_DetailDescText->SetLabel( wxEmptyString );
m_DetailAuthorText->SetLabel( wxEmptyString );
m_DetailOwnerText->SetLabel( wxEmptyString );
m_DetailLinkText->SetURL( wxEmptyString );
m_DetailLinkText->SetLabel( wxEmptyString );
}
m_DetailMainSizer->FitInside( m_DetailScrolledWindow );
m_DetailScrolledWindow->SetVirtualSize( m_DetailMainSizer->GetSize() );
//m_DetailFlexGridSizer->FitInside( m_DetailScrolledWindow );
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::OnPodcastItemUpdated( wxCommandEvent &event )
{
guPodcastItem * PodcastItem = ( guPodcastItem * ) event.GetClientData();
//guLogMessage( wxT( "PodcastItem Updated... Item: %s Status: %u" ), PodcastItem->m_Title.c_str(), PodcastItem->m_Status );
m_Db->SavePodcastItem( PodcastItem->m_ChId, PodcastItem );
m_PodcastsListBox->ReloadItems( false );
delete PodcastItem;
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::OnSelectPodcasts( bool enqueue, const int aftercurrent )
{
wxArrayInt Selected = m_PodcastsListBox->GetSelectedItems();
int Count = Selected.Count();
if( Count )
{
guTrackArray Tracks;
for( int Index = 0; Index < Count; Index++ )
{
guPodcastItem PodcastItem;
if( m_Db->GetPodcastItemId( Selected[ Index ], &PodcastItem ) != wxNOT_FOUND )
{
if( PodcastItem.m_Status == guPODCAST_STATUS_READY )
{
if( wxFileExists( PodcastItem.m_FileName ) )
{
guTrack * Track = new guTrack();
if( Track )
{
Track->m_Type = guTRACK_TYPE_PODCAST;
Track->m_SongId = PodcastItem.m_Id;
Track->m_FileName = PodcastItem.m_FileName;
Track->m_SongName = PodcastItem.m_Title;
Track->m_ArtistName = PodcastItem.m_Author;
Track->m_AlbumId = PodcastItem.m_ChId;
Track->m_AlbumName = PodcastItem.m_Channel;
Track->m_Length = PodcastItem.m_Length;
Track->m_PlayCount = PodcastItem.m_PlayCount;
Track->m_Rating = -1;
Track->m_CoverId = 0;
Track->m_Year = 0; // Get year from item date
Tracks.Add( Track );
}
}
else
{
PodcastItem.m_Status = guPODCAST_STATUS_ERROR;
wxCommandEvent event( guPodcastEvent, ID_PODCASTS_ITEM_UPDATED );
event.SetClientData( new guPodcastItem( PodcastItem ) );
wxPostEvent( this, event );
}
}
else if( ( PodcastItem.m_Status == guPODCAST_STATUS_NORMAL ) ||
( PodcastItem.m_Status == guPODCAST_STATUS_ERROR ) )
{
// Download the item
guPodcastItemArray AddList;
AddList.Add( PodcastItem );
m_MainFrame->AddPodcastsDownloadItems( &AddList );
PodcastItem.m_Status = guPODCAST_STATUS_PENDING;
wxCommandEvent event( guPodcastEvent, ID_PODCASTS_ITEM_UPDATED );
event.SetClientData( new guPodcastItem( PodcastItem ) );
wxPostEvent( this, event );
}
}
}
if( Tracks.Count() )
{
if( enqueue )
{
m_PlayerPanel->AddToPlayList( Tracks, true, aftercurrent );
}
else
{
m_PlayerPanel->SetPlayList( Tracks );
}
}
}
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::OnPodcastItemActivated( wxCommandEvent &event )
{
guConfig * Config = ( guConfig * ) guConfig::Get();
OnSelectPodcasts( Config->ReadBool( CONFIG_KEY_GENERAL_ACTION_ENQUEUE, false, CONFIG_PATH_GENERAL ) );
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::OnPodcastItemPlay( wxCommandEvent &event )
{
OnSelectPodcasts( false );
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::OnPodcastItemEnqueue( wxCommandEvent &event )
{
OnSelectPodcasts( true, event.GetId() - ID_PODCASTS_ITEM_ENQUEUE_AFTER_ALL );
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::OnPodcastItemDelete( wxCommandEvent &event )
{
if( wxMessageBox( _( "Are you sure to delete the selected podcast item?" ),
_( "Confirm" ),
wxICON_QUESTION|wxYES_NO|wxNO_DEFAULT, this ) == wxYES )
{
wxArrayInt Selection = m_PodcastsListBox->GetSelectedItems();
// Check if in the download thread this items are included and delete them
guPodcastItemArray Podcasts;
m_Db->GetPodcastItems( Selection, &Podcasts, m_PodcastsListBox->GetOrder(), m_PodcastsListBox->GetOrderDesc() );
m_MainFrame->RemovePodcastDownloadItems( &Podcasts );
int Count = Selection.Count();
for( int Index = 0; Index < Count; Index++ )
{
m_Db->SetPodcastItemStatus( Selection[ Index ], guPODCAST_STATUS_DELETED );
}
m_PodcastsListBox->ReloadItems();
}
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::OnPodcastItemDownload( wxCommandEvent &event )
{
wxArrayInt Selection = m_PodcastsListBox->GetSelectedItems();
guPodcastItemArray DownloadList;
int Count = Selection.Count();
for( int Index = 0; Index < Count; Index++ )
{
guPodcastItem PodcastItem;
m_Db->GetPodcastItemId( Selection[ Index ], &PodcastItem );
DownloadList.Add( new guPodcastItem( PodcastItem ) );
}
m_MainFrame->AddPodcastsDownloadItems( &DownloadList );
m_PodcastsListBox->ReloadItems( false );
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::OnPodcastItemCopyTo( wxCommandEvent &event )
{
guTrackArray * Tracks = new guTrackArray();
m_PodcastsListBox->GetSelectedSongs( Tracks );
int Index = event.GetId() - ID_COPYTO_BASE;
if( Index >= guCOPYTO_DEVICE_BASE )
{
Index -= guCOPYTO_DEVICE_BASE;
event.SetId( ID_MAINFRAME_COPYTODEVICE_TRACKS );
}
else
{
event.SetId( ID_MAINFRAME_COPYTO );
}
event.SetInt( Index );
event.SetClientData( ( void * ) Tracks );
wxPostEvent( guMainFrame::GetMainFrame(), event );
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::SetSelection( const int type, const int id )
{
if( type == guMEDIAVIEWER_SELECT_TRACK )
{
m_ChannelsListBox->SetSelection( wxNOT_FOUND );
m_PodcastsListBox->SetSelection( m_PodcastsListBox->FindItem( id ) );
}
else if( type == guMEDIAVIEWER_SELECT_ALBUM )
{
m_ChannelsListBox->SetSelection( wxNOT_FOUND );
m_ChannelsListBox->SetSelection( m_ChannelsListBox->FindItem( id ) );
}
}
// -------------------------------------------------------------------------------- //
void guPodcastPanel::UpdateTrack( const guTrack * )
{
if( m_PodcastsListBox )
m_PodcastsListBox->ReloadItems( false );
}
// -------------------------------------------------------------------------------- //
// guChannelsListBox
// -------------------------------------------------------------------------------- //
void guChannelsListBox::GetItemsList( void )
{
m_PodChannels.Empty();
int Count = ( ( guDbPodcasts * ) m_Db )->GetPodcastChannels( &m_PodChannels );
for( int Index = 0; Index < Count; Index++ )
{
m_Items->Add( new guListItem( m_PodChannels[ Index ].m_Id, m_PodChannels[ Index ].m_Title ) );
}
}
// -------------------------------------------------------------------------------- //
void guChannelsListBox::OnKeyDown( wxKeyEvent &event )
{
if( event.GetKeyCode() == WXK_DELETE )
{
wxCommandEvent CmdEvent( wxEVT_MENU, ID_PODCASTS_CHANNEL_DEL );
wxPostEvent( this, CmdEvent );
return;
}
event.Skip();
}
// -------------------------------------------------------------------------------- //
int guChannelsListBox::GetSelectedSongs( guTrackArray * Songs, const bool isdrag ) const
{
return 0;
}
// -------------------------------------------------------------------------------- //
int guChannelsListBox::GetDragFiles( guDataObjectComposite * files )
{
return ( ( guDbPodcasts * ) m_Db )->GetPodcastFiles( GetSelectedItems(), files );
}
// -------------------------------------------------------------------------------- //
void guChannelsListBox::CreateContextMenu( wxMenu * Menu ) const
{
wxMenuItem * MenuItem;
int SelCount = GetSelectedCount();
MenuItem = new wxMenuItem( Menu, ID_PODCASTS_CHANNEL_ADD, _( "New Channel" ), _( "Add a new podcast channel" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
Menu->Append( MenuItem );
if( SelCount )
{
MenuItem = new wxMenuItem( Menu, ID_PODCASTS_CHANNEL_DEL, _( "Delete" ), _( "delete this podcast channels and all its items" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_edit_clear ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
MenuItem = new wxMenuItem( Menu, ID_PODCASTS_CHANNEL_UPDATE, _( "Update" ), _( "Update the podcast items of the selected channels" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_doc_save ) );
Menu->Append( MenuItem );
if( SelCount == 1 )
{
MenuItem = new wxMenuItem( Menu, ID_PODCASTS_CHANNEL_PROPERTIES, _( "Properties" ), _( "Edit the podcast channel" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_edit ) );
Menu->Append( MenuItem );
}
Menu->AppendSeparator();
guMainFrame * MainFrame = ( guMainFrame * ) guMainFrame::GetMainFrame();
MainFrame->CreateCopyToMenu( Menu );
}
}
// -------------------------------------------------------------------------------- //
int guChannelsListBox::FindItem( const int channelid )
{
int Count = m_Items->Count();
for( int Index = 0; Index < Count; Index++ )
{
if( m_Items->Item( Index ).m_Id == channelid )
{
return Index;
}
}
return wxNOT_FOUND;
}
// -------------------------------------------------------------------------------- //
// guPodcastListBox
// -------------------------------------------------------------------------------- //
guPodcastListBox::guPodcastListBox( wxWindow * parent, guDbPodcasts * db ) :
guListView( parent, wxLB_MULTIPLE | guLISTVIEW_COLUMN_SELECT | guLISTVIEW_COLUMN_SORTING | guLISTVIEW_ALLOWDRAG )
{
m_Db = db;
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->RegisterObject( this );
m_ColumnNames.Add( _( "Status" ) );
m_ColumnNames.Add( _( "Title" ) );
m_ColumnNames.Add( _( "Channel" ) );
m_ColumnNames.Add( _( "Category" ) );
m_ColumnNames.Add( _( "Date" ) );
m_ColumnNames.Add( _( "Length" ) );
m_ColumnNames.Add( _( "Author" ) );
m_ColumnNames.Add( _( "Plays" ) );
m_ColumnNames.Add( _( "Last Played" ) );
m_ColumnNames.Add( _( "Added" ) );
m_Order = Config->ReadNum( CONFIG_KEY_PODCASTS_ORDER, 0, CONFIG_PATH_PODCASTS );
m_OrderDesc = Config->ReadNum( CONFIG_KEY_PODCASTS_ORDERDESC, false, CONFIG_PATH_PODCASTS );
// Construct the images for the status
m_Images[ guPODCAST_STATUS_NORMAL ] = NULL;
m_Images[ guPODCAST_STATUS_PENDING ] = new wxImage( guImage( guIMAGE_INDEX_tiny_status_pending ) );
m_Images[ guPODCAST_STATUS_DOWNLOADING ] = new wxImage( guImage( guIMAGE_INDEX_tiny_doc_save ) );
m_Images[ guPODCAST_STATUS_READY ] = new wxImage( guImage( guIMAGE_INDEX_tiny_accept ) );
m_Images[ guPODCAST_STATUS_DELETED ] = new wxImage( guImage( guIMAGE_INDEX_tiny_status_error ) );
m_Images[ guPODCAST_STATUS_ERROR ] = new wxImage( guImage( guIMAGE_INDEX_tiny_status_error ) );
int count = m_ColumnNames.Count();
for( int index = 0; index < count; index++ )
{
int ColId = Config->ReadNum( wxString::Format( wxT( "id%u" ), index ), index, wxT( "podcasts/columns/ids" ) );
wxString ColName = m_ColumnNames[ ColId ];
ColName += ( ( ColId == m_Order ) ? ( m_OrderDesc ? wxT( " ▼" ) : wxT( " ▲" ) ) : wxEmptyString );
guListViewColumn * Column = new guListViewColumn(
ColName,
ColId,
Config->ReadNum( wxString::Format( wxT( "width%u" ), index ), 80, wxT( "podcasts/columns/widths" ) ),
Config->ReadBool( wxString::Format( wxT( "show%u" ), index ), true, wxT( "podcasts/columns/shows" ) )
);
InsertColumn( Column );
}
Bind( guConfigUpdatedEvent, &guPodcastListBox::OnConfigUpdated, this, ID_CONFIG_UPDATED );
CreateAcceleratorTable();
ReloadItems();
}
// -------------------------------------------------------------------------------- //
guPodcastListBox::~guPodcastListBox()
{
guConfig * Config = ( guConfig * ) guConfig::Get();
Config->UnRegisterObject( this );
int count = m_ColumnNames.Count();
for( int index = 0; index < count; index++ )
{
Config->WriteNum( wxString::Format( wxT( "id%u" ), index ),
( * m_Columns )[ index ].m_Id, wxT( "podcasts/columns/ids" ) );
Config->WriteNum( wxString::Format( wxT( "width%u" ), index ),
( * m_Columns )[ index ].m_Width, wxT( "podcasts/columns/widths" ) );
Config->WriteBool( wxString::Format( wxT( "show%u" ), index ),
( * m_Columns )[ index ].m_Enabled, wxT( "podcasts/columns/shows" ) );
}
Config->WriteNum( CONFIG_KEY_PODCASTS_ORDER, m_Order, CONFIG_PATH_PODCASTS );
Config->WriteBool( CONFIG_KEY_PODCASTS_ORDERDESC, m_OrderDesc, CONFIG_PATH_PODCASTS );
for( int index = 0; index < guPODCAST_STATUS_ERROR + 1; index++ )
{
delete m_Images[ index ];
}
Unbind( guConfigUpdatedEvent, &guPodcastListBox::OnConfigUpdated, this, ID_CONFIG_UPDATED );
}
// -------------------------------------------------------------------------------- //
void guPodcastListBox::OnConfigUpdated( wxCommandEvent &event )
{
int Flags = event.GetInt();
if( Flags & guPREFERENCE_PAGE_FLAG_ACCELERATORS )
{
CreateAcceleratorTable();
}
}
// -------------------------------------------------------------------------------- //
void guPodcastListBox::CreateAcceleratorTable( void )
{
wxAcceleratorTable AccelTable;
wxArrayInt AliasAccelCmds;
wxArrayInt RealAccelCmds;
AliasAccelCmds.Add( ID_TRACKS_PLAY );
AliasAccelCmds.Add( ID_TRACKS_ENQUEUE_AFTER_ALL );
AliasAccelCmds.Add( ID_TRACKS_ENQUEUE_AFTER_TRACK );
AliasAccelCmds.Add( ID_TRACKS_ENQUEUE_AFTER_ALBUM );
AliasAccelCmds.Add( ID_TRACKS_ENQUEUE_AFTER_ARTIST );
RealAccelCmds.Add( ID_PODCASTS_ITEM_PLAY );
RealAccelCmds.Add( ID_PODCASTS_ITEM_ENQUEUE_AFTER_ALL );
RealAccelCmds.Add( ID_PODCASTS_ITEM_ENQUEUE_AFTER_TRACK );
RealAccelCmds.Add( ID_PODCASTS_ITEM_ENQUEUE_AFTER_ALBUM );
RealAccelCmds.Add( ID_PODCASTS_ITEM_ENQUEUE_AFTER_ARTIST );
if( guAccelDoAcceleratorTable( AliasAccelCmds, RealAccelCmds, AccelTable ) )
{
SetAcceleratorTable( AccelTable );
}
}
// -------------------------------------------------------------------------------- //
void guPodcastListBox::DrawItem( wxDC &dc, const wxRect &rect, const int row, const int col ) const
{
if( ( * m_Columns )[ col ].m_Id == guPODCASTS_COLUMN_STATUS )
{
guPodcastItem * Podcast;
Podcast = &m_PodItems[ row ];
if( Podcast->m_Status )
{
dc.SetBackgroundMode( wxTRANSPARENT );
dc.DrawBitmap( * m_Images[ Podcast->m_Status ], rect.x + 3, rect.y + 3, true );
}
}
else
{
guListView::DrawItem( dc, rect, row, col );
}
}
// -------------------------------------------------------------------------------- //
wxString guPodcastListBox::OnGetItemText( const int row, const int col ) const
{
guPodcastItem * Podcast;
Podcast = &m_PodItems[ row ];
switch( ( * m_Columns )[ col ].m_Id )
{
case guPODCASTS_COLUMN_TITLE :
return Podcast->m_Title;
case guPODCASTS_COLUMN_CHANNEL :
return Podcast->m_Channel;
case guPODCASTS_COLUMN_CATEGORY :
return Podcast->m_Category;
case guPODCASTS_COLUMN_DATE :
{
wxDateTime AddedDate;
AddedDate.Set( ( time_t ) Podcast->m_Time );
return AddedDate.FormatDate();
break;
}
case guPODCASTS_COLUMN_LENGTH :
return LenToString( Podcast->m_Length );
case guPODCASTS_COLUMN_AUTHOR :
return Podcast->m_Author;
case guPODCASTS_COLUMN_PLAYCOUNT :
return wxString::Format( wxT( "%u" ), Podcast->m_PlayCount );
case guPODCASTS_COLUMN_LASTPLAY :
if( Podcast->m_LastPlay )
{
wxDateTime LastPlay;
LastPlay.Set( ( time_t ) Podcast->m_LastPlay );
return LastPlay.FormatDate();
}
else
return _( "Never" );
case guPODCASTS_COLUMN_ADDEDDATE :
wxDateTime AddedDate;
AddedDate.Set( ( time_t ) Podcast->m_AddedDate );
return AddedDate.FormatDate();
}
return wxEmptyString;
}
// -------------------------------------------------------------------------------- //
void guPodcastListBox::GetItemsList( void )
{
m_Db->GetPodcastItems( &m_PodItems, m_PodChFilters, m_Order, m_OrderDesc );
wxCommandEvent event( wxEVT_MENU, ID_MAINFRAME_UPDATE_SELINFO );
AddPendingEvent( event );
}
// -------------------------------------------------------------------------------- //
void guPodcastListBox::ReloadItems( bool reset )
{
//
wxArrayInt Selection;
int FirstVisible = 0;
if( reset )
{
SetSelection( -1 );
}
else
{
Selection = GetSelectedItems( false );
FirstVisible = GetVisibleRowsBegin();
}
m_PodItems.Empty();
GetItemsList();
SetItemCount( m_PodItems.Count() );
if( !reset )
{
SetSelectedItems( Selection );
ScrollToRow( FirstVisible );
}
RefreshAll();
}
// -------------------------------------------------------------------------------- //
void guPodcastListBox::OnKeyDown( wxKeyEvent &event )
{
if( event.GetKeyCode() == WXK_DELETE )
{
wxCommandEvent CmdEvent( wxEVT_MENU, ID_PODCASTS_ITEM_DEL );
wxPostEvent( this, CmdEvent );
return;
}
event.Skip();
}
// -------------------------------------------------------------------------------- //
void guPodcastListBox::CreateContextMenu( wxMenu * Menu ) const
{
int SelCount = GetSelectedCount();
if( SelCount )
{
wxMenuItem * MenuItem;
MenuItem = new wxMenuItem( Menu, ID_PODCASTS_ITEM_PLAY,
wxString( _( "Play" ) ) + guAccelGetCommandKeyCodeString( ID_TRACKS_PLAY ),
_( "Play current selected songs" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_player_tiny_light_play ) );
Menu->Append( MenuItem );
MenuItem = new wxMenuItem( Menu, ID_PODCASTS_ITEM_ENQUEUE_AFTER_ALL,
wxString( _( "Enqueue" ) ) + guAccelGetCommandKeyCodeString( ID_TRACKS_ENQUEUE_AFTER_ALL ),
_( "Add current selected songs to playlist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
Menu->Append( MenuItem );
wxMenu * EnqueueMenu = new wxMenu();
MenuItem = new wxMenuItem( EnqueueMenu, ID_PODCASTS_ITEM_ENQUEUE_AFTER_TRACK,
wxString( _( "Current Track" ) ) + guAccelGetCommandKeyCodeString( ID_TRACKS_ENQUEUE_AFTER_TRACK ),
_( "Add current selected tracks to playlist after the current track" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem = new wxMenuItem( EnqueueMenu, ID_PODCASTS_ITEM_ENQUEUE_AFTER_ALBUM,
wxString( _( "Current Album" ) ) + guAccelGetCommandKeyCodeString( ID_TRACKS_ENQUEUE_AFTER_ALBUM ),
_( "Add current selected tracks to playlist after the current album" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
MenuItem = new wxMenuItem( EnqueueMenu, ID_PODCASTS_ITEM_ENQUEUE_AFTER_ARTIST,
wxString( _( "Current Artist" ) ) + guAccelGetCommandKeyCodeString( ID_TRACKS_ENQUEUE_AFTER_ARTIST ),
_( "Add current selected tracks to playlist after the current artist" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
EnqueueMenu->Append( MenuItem );
Menu->Append( wxID_ANY, _( "Enqueue After" ), EnqueueMenu );
Menu->AppendSeparator();
MenuItem = new wxMenuItem( Menu, ID_PODCASTS_ITEM_DEL, _( "Delete" ), _( "Delete the current selected podcasts" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_edit_clear ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
MenuItem = new wxMenuItem( Menu, ID_PODCASTS_ITEM_DOWNLOAD, _( "Download" ), _( "Download the current selected podcasts" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_doc_save ) );
Menu->Append( MenuItem );
Menu->AppendSeparator();
guMainFrame * MainFrame = ( guMainFrame * ) guMainFrame::GetMainFrame();
MainFrame->CreateCopyToMenu( Menu );
}
else
{
wxMenuItem * MenuItem;
MenuItem = new wxMenuItem( Menu, wxID_ANY, _( "No selected items..." ), _( "Copy the current selected podcasts to a directory or device" ) );
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_status_error ) );
Menu->Append( MenuItem );
}
}
// -------------------------------------------------------------------------------- //
int inline guPodcastListBox::GetItemId( const int row ) const
{
return m_PodItems[ row ].m_Id;
}
// -------------------------------------------------------------------------------- //
wxString inline guPodcastListBox::GetItemName( const int row ) const
{
return m_PodItems[ row ].m_Title;
}
// -------------------------------------------------------------------------------- //
void guPodcastListBox::SetOrder( int columnid )
{
if( m_Order != columnid )
{
m_Order = columnid;
m_OrderDesc = ( columnid != 0 );
}
else
m_OrderDesc = !m_OrderDesc;
//m_Db->SetPodcastOrder( m_Order );
int count = m_ColumnNames.Count();
for( int index = 0; index < count; index++ )
{
int CurColId = GetColumnId( index );
SetColumnLabel( index,
m_ColumnNames[ CurColId ] + ( ( CurColId == m_Order ) ?
( m_OrderDesc ? wxT( " ▼" ) : wxT( " ▲" ) ) : wxEmptyString ) );
}
ReloadItems();
}
// -------------------------------------------------------------------------------- //
void guPodcastListBox::SetFilters( const wxArrayInt &filters )
{
if( filters.Index( 0 ) != wxNOT_FOUND )
{
m_PodChFilters.Empty();
}
else
{
m_PodChFilters = filters;
}
}
// -------------------------------------------------------------------------------- //
int guPodcastListBox::GetSelectedSongs( guTrackArray * tracks, const bool isdrag ) const
{
wxArrayInt Selection = GetSelectedItems();
int Count = Selection.Count();
for( int Index = 0; Index < Count; Index++ )
{
guPodcastItem PodcastItem;
if( ( m_Db->GetPodcastItemId( Selection[ Index ], &PodcastItem ) != wxNOT_FOUND ) &&
( PodcastItem.m_Status == guPODCAST_STATUS_READY ) &&
( wxFileExists( PodcastItem.m_FileName ) ) )
{
guTrack * Track = new guTrack();
if( Track )
{
Track->m_Type = guTRACK_TYPE_PODCAST;
Track->m_SongId = PodcastItem.m_Id;
Track->m_FileName = PodcastItem.m_FileName;
Track->m_SongName = PodcastItem.m_Title;
Track->m_ArtistName = PodcastItem.m_Author;
Track->m_AlbumId = PodcastItem.m_ChId;
Track->m_AlbumName = PodcastItem.m_Channel;
Track->m_Length = PodcastItem.m_Length;
Track->m_PlayCount = PodcastItem.m_PlayCount;
Track->m_GenreName = wxT( "Podcasts" );
Track->m_Number = Index;
Track->m_Rating = -1;
Track->m_CoverId = 0;
Track->m_Year = 0; // Get year from item date
tracks->Add( Track );
}
}
}
return tracks->Count();
}
// -------------------------------------------------------------------------------- //
int guPodcastListBox::FindItem( const int podcastid )
{
int Count = m_PodItems.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( m_PodItems[ Index ].m_Id == podcastid )
{
return Index;
}
}
return wxNOT_FOUND;
}
}
// -------------------------------------------------------------------------------- //
| 87,965
|
C++
|
.cpp
| 1,886
| 39.378579
| 209
| 0.59186
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
750,662
|
Podcasts.cpp
|
anonbeat_guayadeque/src/ui/podcasts/Podcasts.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "Podcasts.h"
#include "Config.h"
#include "DbLibrary.h"
#include "MainFrame.h"
#include "PodcastsPanel.h"
#include "TagInfo.h"
#include "Utils.h"
#include <wx/arrimpl.cpp>
#include <wx/uri.h>
namespace Guayadeque {
WX_DEFINE_OBJARRAY( guPodcastChannelArray )
WX_DEFINE_OBJARRAY( guPodcastItemArray )
wxDEFINE_EVENT( guPodcastEvent, wxCommandEvent );
// -------------------------------------------------------------------------------- //
unsigned int StrLengthToInt( const wxString &length )
{
if( !length.IsEmpty() )
{
// 1:02:03:04
wxString Rest = length.Strip( wxString::both );
long element;
int FactorIndex = 0;
unsigned int RetVal = 0;
int Factor[] = { 1, 60, 3600, 86400 };
do {
Rest.AfterLast( wxT( ':' ) ).ToLong( &element );
if( !element )
break;
RetVal += ( Factor[ FactorIndex ] * element );
if( ( ++FactorIndex > 3 ) )
break;
Rest = Rest.BeforeLast( wxT( ':' ) );
} while( !Rest.IsEmpty() );
//guLogMessage( wxT( "StrLengthToInt : '%s' -> %u" ), length.c_str(), RetVal );
return RetVal * 1000;
}
return 0;
}
// -------------------------------------------------------------------------------- //
guPodcastChannel::guPodcastChannel( const wxString &url )
{
m_Url = url;
ReadContent();
}
// -------------------------------------------------------------------------------- //
bool guPodcastChannel::ReadContent( void )
{
bool RetVal = false;
wxString Content = GetUrlContent( m_Url );
if( !Content.IsEmpty() )
{
wxStringInputStream ins( Content );
wxXmlDocument XmlDoc( ins );
wxXmlNode * XmlNode = XmlDoc.GetRoot();
if( XmlNode && XmlNode->GetName() == wxT( "rss" ) )
{
RetVal = ReadXml( XmlNode->GetChildren() );
}
else
{
guLogMessage( wxT( "This url is not a valid podcast" ) );
}
}
else
{
guLogError( wxT( "Could not get podcast content for %s" ), m_Url.c_str() );
}
return RetVal;
}
// -------------------------------------------------------------------------------- //
bool guPodcastChannel::ReadXmlImage( wxXmlNode * XmlNode )
{
while( XmlNode )
{
if( XmlNode->GetName() == wxT( "url" ) )
{
m_Image = XmlNode->GetNodeContent();
return true;
}
XmlNode = XmlNode->GetNext();
}
return false;
}
// -------------------------------------------------------------------------------- //
bool guPodcastChannel::ReadXml( wxXmlNode * XmlNode )
{
while( XmlNode )
{
if( XmlNode->GetName() == wxT( "channel" ) )
{
XmlNode = XmlNode->GetChildren();
while( XmlNode )
{
if( XmlNode->GetName() == wxT( "title" ) )
{
m_Title = XmlNode->GetNodeContent();
}
else if( XmlNode->GetName() == wxT( "link" ) )
{
m_Link = XmlNode->GetNodeContent();
}
else if( XmlNode->GetName() == wxT( "language" ) )
{
m_Lang = XmlNode->GetNodeContent();
}
else if( XmlNode->GetName() == wxT( "description" ) )
{
m_Description = XmlNode->GetNodeContent();
}
else if( XmlNode->GetName() == wxT( "itunes:author" ) )
{
m_Author = XmlNode->GetNodeContent();
}
else if( XmlNode->GetName() == wxT( "itunes:owner" ) )
{
ReadXmlOwner( XmlNode->GetChildren() );
}
else if( XmlNode->GetName() == wxT( "itunes:image" ) )
{
XmlNode->GetAttribute( wxT( "href" ), &m_Image );
}
else if( XmlNode->GetName() == wxT( "image" ) )
{
ReadXmlImage( XmlNode->GetChildren() );
}
else if( XmlNode->GetName() == wxT( "itunes:category" ) )
{
XmlNode->GetAttribute( wxT( "text" ), &m_Category );
}
else if( XmlNode->GetName() == wxT( "itunes:summary" ) )
{
m_Summary = XmlNode->GetNodeContent();
}
else if( XmlNode->GetName() == wxT( "item" ) )
{
guPodcastItem * PodcastItem = new guPodcastItem( XmlNode->GetChildren() );
//PodcastItem->ReadXml( XmlNode->GetChildren() );
if( PodcastItem->m_Author.IsEmpty() )
PodcastItem->m_Author = m_Author;
//guLogMessage( wxT( "Item Length: %i" ), PodcastItem->m_Length );
m_Items.Add( PodcastItem );
}
XmlNode = XmlNode->GetNext();
}
return true;
}
XmlNode = XmlNode->GetNext();
}
return false;
}
// -------------------------------------------------------------------------------- //
void guPodcastChannel::ReadXmlOwner( wxXmlNode * XmlNode )
{
while( XmlNode )
{
if( XmlNode->GetName() == wxT( "itunes:name" ) )
{
m_OwnerName = XmlNode->GetNodeContent();
}
else if( XmlNode->GetName() == wxT( "itunes:email" ) )
{
m_OwnerEmail = XmlNode->GetNodeContent();
}
XmlNode = XmlNode->GetNext();
}
}
// -------------------------------------------------------------------------------- //
void guPodcastChannel::CheckLogo( void )
{
if( !m_Image.IsEmpty() )
{
guConfig * Config = ( guConfig * ) guConfig::Get();
wxString PodcastsPath = Config->ReadStr( CONFIG_KEY_PODCASTS_PATH,
guPATH_PODCASTS,
CONFIG_PATH_PODCASTS );
//guLogMessage( wxT( "Downloading the Image..." ) );
wxFileName ImageFile = wxFileName( PodcastsPath + wxT( "/" ) +
m_Title + wxT( "/" ) +
m_Title + wxT( ".jpg" ) );
if( ImageFile.Normalize( wxPATH_NORM_ALL|wxPATH_NORM_CASE ) )
{
if( !wxFileExists( ImageFile.GetFullPath() ) )
{
if( !DownloadImage( m_Image, ImageFile.GetFullPath(), 60, 60 ) )
guLogWarning( wxT( "Download image failed..." ) );
}
// else
// {
// guLogMessage( wxT( "Image File already exists" ) );
// }
}
else
{
guLogError( wxT( "Error in normalize downloading the podcast image" ) );
}
}
}
// -------------------------------------------------------------------------------- //
int guPodcastChannel::GetUpdateItems( guDbPodcasts * db, guPodcastItemArray * items )
{
wxString query;
wxSQLite3ResultSet dbRes;
// If the download type is set to manual there is nothign to download
if( m_DownloadType == guPODCAST_DOWNLOAD_MANUALLY )
return 0;
query = wxString::Format( wxT( "SELECT podcastitem_id, podcastitem_chid, podcastitem_title, " \
"podcastitem_summary, podcastitem_author, podcastitem_enclosure, podcastitem_time, " \
"podcastitem_file, podcastitem_filesize, podcastitem_length, " \
"podcastitem_playcount, podcastitem_addeddate, podcastitem_lastplay, " \
"podcastitem_status, " \
"podcastch_title, podcastch_category " \
"FROM podcastitems, podcastchs " \
"WHERE podcastitem_chid = podcastch_id " \
"AND podcastitem_chid = %u " ), m_Id );
query += wxT( "AND podcastitem_status IN ( 0, 5 ) " );
if( m_DownloadType == guPODCAST_DOWNLOAD_FILTER )
{
wxArrayString Words;
if( !m_DownloadText.IsEmpty() )
{
Words = guSplitWords( m_DownloadText );
}
int Count = Words.Count();
if( Count )
{
query += wxT( "AND ( " );
for( int Index = 0; Index < Count; Index++ )
{
query += wxString::Format( wxT( "podcastitem_title LIKE '%%%s%%' OR " \
"podcastitem_summary LIKE '%%%s%%'" ),
Words[ Index ].c_str(),
Words[ Index ].c_str() );
}
query += wxT( " );" );
}
}
//guLogMessage( wxT( "GetUpdateItems : %s" ), query.c_str() );
dbRes = db->ExecuteQuery( query );
while( dbRes.NextRow() )
{
guPodcastItem * Item = new guPodcastItem();
Item->m_Id = dbRes.GetInt( 0 );
Item->m_ChId = dbRes.GetInt( 1 );
Item->m_Title = dbRes.GetString( 2 );
Item->m_Summary = dbRes.GetString( 3 );
Item->m_Author = dbRes.GetString( 4 );
Item->m_Enclosure = dbRes.GetString( 5 );
Item->m_Time = dbRes.GetInt( 6 );
Item->m_FileName = dbRes.GetString( 7 );
Item->m_FileSize = dbRes.GetInt( 8 );
Item->m_Length = dbRes.GetInt( 9 );
Item->m_PlayCount = dbRes.GetInt( 10 );
Item->m_AddedDate = dbRes.GetInt( 11 );
Item->m_LastPlay = dbRes.GetInt( 12 );
Item->m_Status = dbRes.GetInt( 13 );
Item->m_Channel = dbRes.GetString( 14 );
Item->m_Category = dbRes.GetString( 15 );
items->Add( Item );
}
dbRes.Finalize();
return items->Count();
}
// -------------------------------------------------------------------------------- //
int guPodcastChannel::GetPendingChannelItems( guDbPodcasts * db, int channelid, guPodcastItemArray * items )
{
wxString query;
wxSQLite3ResultSet dbRes;
query = wxString::Format( wxT( "SELECT podcastitem_id, podcastitem_chid, podcastitem_title, " \
"podcastitem_summary, podcastitem_author, podcastitem_enclosure, podcastitem_time, " \
"podcastitem_file, podcastitem_filesize, podcastitem_length, " \
"podcastitem_playcount, podcastitem_addeddate, podcastitem_lastplay, " \
"podcastitem_status, " \
"podcastch_title, podcastch_category " \
"FROM podcastitems, podcastchs " \
"WHERE podcastitem_chid = podcastch_id " \
"AND podcastitem_chid = %u " ), channelid );
query += wxT( "AND podcastitem_status IN ( 1 ) " );
dbRes = db->ExecuteQuery( query );
while( dbRes.NextRow() )
{
guPodcastItem * Item = new guPodcastItem();
Item->m_Id = dbRes.GetInt( 0 );
Item->m_ChId = dbRes.GetInt( 1 );
Item->m_Title = dbRes.GetString( 2 );
Item->m_Summary = dbRes.GetString( 3 );
Item->m_Author = dbRes.GetString( 4 );
Item->m_Enclosure = dbRes.GetString( 5 );
Item->m_Time = dbRes.GetInt( 6 );
Item->m_FileName = dbRes.GetString( 7 );
Item->m_FileSize = dbRes.GetInt( 8 );
Item->m_Length = dbRes.GetInt( 9 );
Item->m_PlayCount = dbRes.GetInt( 10 );
Item->m_AddedDate = dbRes.GetInt( 11 );
Item->m_LastPlay = dbRes.GetInt( 12 );
Item->m_Status = dbRes.GetInt( 13 );
Item->m_Channel = dbRes.GetString( 14 );
Item->m_Category = dbRes.GetString( 15 );
items->Add( Item );
}
dbRes.Finalize();
return items->Count();
}
// -------------------------------------------------------------------------------- //
int guPodcastChannel::CheckDownloadItems( guDbPodcasts * db, guMainFrame * mainframe )
{
if( m_DownloadType != guPODCAST_DOWNLOAD_MANUALLY )
{
guPodcastItemArray UpdatePodcasts;
// If there was items to be downloaded
int Count;
if( ( Count = GetUpdateItems( db, &UpdatePodcasts ) ) )
{
mainframe->AddPodcastsDownloadItems( &UpdatePodcasts );
return Count;
}
}
else if( m_DownloadType == guPODCAST_DOWNLOAD_MANUALLY )
{
// Check if in the download thread this items are included and delete them
guPodcastItemArray Podcasts;
GetPendingChannelItems( db, m_Id, &Podcasts );
int Count = Podcasts.Count();
if( Count )
{
mainframe->RemovePodcastDownloadItems( &Podcasts );
for( int Index = 0; Index < Count; Index++ )
{
db->SetPodcastItemStatus( Podcasts[ Index ].m_Id, guPODCAST_STATUS_NORMAL );
}
}
}
return 0;
}
// -------------------------------------------------------------------------------- //
void guPodcastChannel::CheckDeleteItems( guDbPodcasts * db )
{
// Get the config object
guConfig * Config = ( guConfig * ) guConfig::Get();
if( Config->ReadBool( CONFIG_KEY_PODCASTS_DELETE, false, CONFIG_PATH_PODCASTS ) )
{
wxString query = wxT( "SELECT podcastitem_file FROM podcastitems, podcastchs " );
wxString Condition = wxT( "WHERE podcastitem_chid = podcastch_id AND podcastch_allowdel = 1 " );
int TimeOption = Config->ReadNum( CONFIG_KEY_PODCASTS_DELETETIME, 15, CONFIG_PATH_PODCASTS );
wxDateTime DeleteTime = wxDateTime::Now();
//
switch( Config->ReadNum( CONFIG_KEY_PODCASTS_DELETEPERIOD, guPODCAST_DELETE_DAY, CONFIG_PATH_PODCASTS ) )
{
case guPODCAST_DELETE_DAY :
DeleteTime.Subtract( wxDateSpan::Days( TimeOption ) );
break;
case guPODCAST_DELETE_WEEK :
DeleteTime.Subtract( wxDateSpan::Weeks( TimeOption ) );
break;
case guPODCAST_DELETE_MONTH :
DeleteTime.Subtract( wxDateSpan::Months( TimeOption ) );
break;
default :
guLogError( wxT( "Invalid delete period entry in configuration file" ) );
return;
}
Condition += wxString::Format( wxT( "AND podcastitem_time < %lu " ), DeleteTime.GetTicks() );
//
if( Config->ReadBool( CONFIG_KEY_PODCASTS_DELETEPLAYED, false, CONFIG_PATH_PODCASTS ) )
{
Condition += wxT( "AND podcastitem_playcount > 0" );
}
query += Condition;
wxSQLite3ResultSet dbRes = db->ExecuteQuery( query );
while( dbRes.NextRow() )
{
wxString FileToDelete = dbRes.GetString( 0 );
if( wxFileExists( FileToDelete ) )
{
if( !wxRemoveFile( FileToDelete ) )
{
guLogError( wxT( "Could not delete the file '%s'" ), FileToDelete.c_str() );
}
}
}
dbRes.Finalize();
query = wxT( "DELETE FROM podcastitems WHERE podcastitem_id IN ( " \
"SELECT podcastitem_id FROM podcastitems, podcastchs " );
query += Condition;
query += wxT( ");" );
//guLogMessage( wxT( "Delete : %s" ), query.c_str() );
db->ExecuteUpdate( query );
}
}
// -------------------------------------------------------------------------------- //
void guPodcastChannel::Update( guDbPodcasts * db, guMainFrame * mainframe )
{
//guLogMessage( wxT( "The address is %s" ), m_Url.c_str() );
CheckDir();
if( ReadContent() )
{
CheckLogo();
// Save only the new items in the channel
db->SavePodcastChannel( this, true );
CheckDeleteItems( db );
CheckDownloadItems( db, mainframe );
}
}
// -------------------------------------------------------------------------------- //
void guPodcastChannel::CheckDir( void )
{
// Save the Splitter positions into the main config
guConfig * Config = ( guConfig * ) guConfig::Get();
// Check that the directory to store podcasts are created
wxString PodcastsPath = Config->ReadStr( CONFIG_KEY_PODCASTS_PATH, guPATH_PODCASTS, CONFIG_PATH_PODCASTS );
// Create the channel dir
wxFileName ChannelDir = wxFileName( PodcastsPath + wxT( "/" ) + m_Title );
if( ChannelDir.Normalize( wxPATH_NORM_ALL | wxPATH_NORM_CASE ) )
{
if( !wxDirExists( ChannelDir.GetFullPath() ) )
{
wxMkdir( ChannelDir.GetFullPath(), 0770 );
}
}
}
// -------------------------------------------------------------------------------- //
// guPodcastItem
// -------------------------------------------------------------------------------- //
guPodcastItem::guPodcastItem( wxXmlNode * XmlNode )
{
m_Id = 0;
m_ChId = 0;
m_Time = 0;
m_Length = 0;
m_PlayCount = 0;
m_LastPlay = 0;
m_Status = 0;
ReadXml( XmlNode );
}
// -------------------------------------------------------------------------------- //
void guPodcastItem::ReadXml( wxXmlNode * XmlNode )
{
while( XmlNode )
{
//guLogMessage( wxT( "Reading now : '%s'" ), XmlNode->GetName().c_str() );
if( XmlNode->GetName() == wxT( "title" ) )
{
m_Title = XmlNode->GetNodeContent();
//guLogMessage( wxT( "Item: '%s'" ), m_Title.c_str() );
}
else if( XmlNode->GetName() == wxT( "enclosure" ) )
{
XmlNode->GetAttribute( wxT( "url" ), &m_Enclosure );
wxString LenStr;
XmlNode->GetAttribute( wxT( "length" ), &LenStr );
unsigned long ULongVal;
LenStr.ToULong( &ULongVal );
m_FileSize = ULongVal;
}
else if( m_Summary.IsEmpty() && ( ( XmlNode->GetName() == wxT( "itunes:summary" ) ) ||
( XmlNode->GetName() == wxT( "description" ) ) ) )
{
m_Summary= XmlNode->GetNodeContent();
}
else if( XmlNode->GetName() == wxT( "pubDate" ) )
{
wxDateTime DateTime;
DateTime.ParseRfc822Date( XmlNode->GetNodeContent() );
m_Time = DateTime.GetTicks();
}
else if( XmlNode->GetName() == wxT( "itunes:duration" ) )
{
m_Length = StrLengthToInt( XmlNode->GetNodeContent() );
}
else if( XmlNode->GetName() == wxT( "itunes:author" ) )
{
m_Author = XmlNode->GetNodeContent();
}
XmlNode = XmlNode->GetNext();
}
}
// -------------------------------------------------------------------------------- //
// guPodcastDownloadQueueThread
// -------------------------------------------------------------------------------- //
guPodcastDownloadQueueThread::guPodcastDownloadQueueThread( guMainFrame * mainframe )
{
m_MainFrame = mainframe;
m_CurPos = 0;
guConfig * Config = ( guConfig * ) guConfig::Get();
m_GaugeId = wxNOT_FOUND;
// Check that the directory to store podcasts are created
m_PodcastsPath = Config->ReadStr( CONFIG_KEY_PODCASTS_PATH, guPATH_PODCASTS, CONFIG_PATH_PODCASTS );
if( Create() == wxTHREAD_NO_ERROR )
{
SetPriority( WXTHREAD_DEFAULT_PRIORITY - 30 );
}
}
// -------------------------------------------------------------------------------- //
guPodcastDownloadQueueThread::~guPodcastDownloadQueueThread()
{
// m_MainFrame->ClearPodcastsDownloadThread();
}
// -------------------------------------------------------------------------------- //
void guPodcastDownloadQueueThread::SendUpdateEvent( guPodcastItem * podcastitem )
{
//guLogMessage( wxT( "Sending the update event..." ) );
wxCommandEvent event( guPodcastEvent, ID_PODCASTS_ITEM_UPDATED );
event.SetClientData( new guPodcastItem( * podcastitem ) );
wxPostEvent( m_MainFrame, event );
}
// -------------------------------------------------------------------------------- //
void guPodcastDownloadQueueThread::AddPodcastItems( guPodcastItemArray * items, bool priority )
{
int Count = items->Count();
if( Count )
{
Lock();
for( int Index = 0; Index < Count; Index++ )
{
if( priority )
m_Items.Insert( new guPodcastItem( items->Item( Index ) ), m_CurPos );
else
m_Items.Add( new guPodcastItem( items->Item( Index ) ) );
}
Unlock();
}
if( !IsRunning() )
{
//guLogMessage( wxT( "Launching download thread..." ) );
Run();
}
}
// -------------------------------------------------------------------------------- //
int guPodcastDownloadQueueThread::FindPodcastItem( guPodcastItem * podcastitem )
{
int Count = m_Items.Count();
for( int Index = 0; Index < Count; Index++ )
{
if( m_Items[ Index ].m_Enclosure == podcastitem->m_Enclosure )
return Index;
}
return wxNOT_FOUND;
}
// -------------------------------------------------------------------------------- //
void guPodcastDownloadQueueThread::RemovePodcastItems( guPodcastItemArray * items )
{
int ItemPos;
int Count = items->Count();
if( Count && m_Items.Count() )
{
Lock();
for( int Index = 0; Index < Count; Index++ )
{
if( ( ItemPos = FindPodcastItem( &items->Item( Index ) ) ) != wxNOT_FOUND )
{
m_Items.RemoveAt( ItemPos );
if( ItemPos < m_CurPos )
m_CurPos--;
}
}
Unlock();
}
}
// -------------------------------------------------------------------------------- //
int guPodcastDownloadQueueThread::GetCount( void )
{
Lock();
int Count = m_Items.Count();
Unlock();
return Count;
}
// -------------------------------------------------------------------------------- //
guPodcastDownloadQueueThread::ExitCode guPodcastDownloadQueueThread::Entry()
{
int Count;
int IdleCount = 0;
while( !TestDestroy() )
{
Count = GetCount();
// guLogMessage( wxT( "DownloadThread %u of %u" ), m_CurPos, Count );
if( m_CurPos < Count )
{
IdleCount = 0;
//
guPodcastItem * PodcastItem = &m_Items[ m_CurPos ];
guLogMessage( wxT( "Ok so we have one item to download... %u %s" ),
m_CurPos, PodcastItem->m_Enclosure.c_str() );
if( PodcastItem->m_Enclosure.IsEmpty() )
{
PodcastItem->m_Status = guPODCAST_STATUS_ERROR;
PodcastItem->m_FileName = wxEmptyString;
SendUpdateEvent( PodcastItem );
}
else
{
wxURI Uri( PodcastItem->m_Enclosure );
wxDateTime PodcastTime;
PodcastTime.Set( ( time_t ) PodcastItem->m_Time );
wxFileName PodcastFile( m_PodcastsPath + wxT( "/" ) +
PodcastItem->m_Channel + wxT( "/" ) +
//PodcastTime.Format( wxT( "%Y%m%d%H%M%S-" ) ) +
Uri.GetPath().AfterLast( wxT( '/' ) ) );
if( PodcastFile.Normalize( wxPATH_NORM_ALL|wxPATH_NORM_CASE ) )
{
PodcastItem->m_FileName = PodcastFile.GetFullPath();
wxFileName::Mkdir( m_PodcastsPath + wxT( "/" ) +
PodcastItem->m_Channel, 0770, wxPATH_MKDIR_FULL );
if( !wxFileExists( PodcastFile.GetFullPath() ) ||
( abs( guGetFileSize( PodcastFile.GetFullPath() ) - PodcastItem->m_FileSize ) > 100*1024 ) )
{
PodcastItem->m_Status = guPODCAST_STATUS_DOWNLOADING;
SendUpdateEvent( PodcastItem );
if( guIsValidAudioFile( Uri.GetPath() ) &&
DownloadFile( PodcastItem->m_Enclosure, PodcastFile.GetFullPath() ) )
{
PodcastItem->m_Status = guPODCAST_STATUS_READY;
PodcastItem->m_FileSize = guGetFileSize( PodcastFile.GetFullPath() );
guTagInfo * TagInfo;
TagInfo = guGetTagInfoHandler( PodcastFile.GetFullPath() );
if( TagInfo )
{
TagInfo->Read();
PodcastItem->m_Length = TagInfo->m_Length;
delete TagInfo;
}
}
else
{
PodcastItem->m_Status = guPODCAST_STATUS_ERROR;
guLogError( wxT( "Podcast download failed..." ) );
}
SendUpdateEvent( PodcastItem );
}
else if( PodcastItem->m_Status != guPODCAST_STATUS_READY )
{
PodcastItem->m_Status = guPODCAST_STATUS_READY;
//guLogMessage( wxT( "Podcast File already exists" ) );
SendUpdateEvent( PodcastItem );
}
}
else
{
guLogError( wxT( "Error in normalizing the podcast filename..." ) );
}
}
//
m_CurPos++;
}
else
{
Lock();
if( m_CurPos == ( int ) m_Items.Count() )
{
if( m_CurPos )
{
m_CurPos = 0;
m_Items.Clear();
}
else
{
if( ++IdleCount > 4 )
{
//ID_MAINFRAME_REMOVEPODCASTTHREAD
wxCommandEvent event( ID_MAINFRAME_REMOVEPODCASTTHREAD );
wxPostEvent( m_MainFrame, event );
IdleCount = 0;
}
else
{
Sleep( 500 );
}
}
}
Unlock();
}
Sleep( 200 );
}
return 0;
}
}
// -------------------------------------------------------------------------------- //
| 27,110
|
C++
|
.cpp
| 696
| 29.132184
| 116
| 0.488016
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
750,663
|
NewChannel.cpp
|
anonbeat_guayadeque/src/ui/podcasts/NewChannel.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "NewChannel.h"
#include "Config.h"
#include "Images.h"
#include "MainFrame.h"
#include "Settings.h"
#include "Utils.h"
#include <wx/wfstream.h>
#include <wx/tokenzr.h>
#include <wx/arrimpl.cpp>
namespace Guayadeque {
#define guDIGITALPODCAST_OPML wxT( "http://www.digitalpodcast.com/opml/digitalpodcast.opml" )
WX_DEFINE_OBJARRAY( guNewPodcastItemArray )
WX_DEFINE_OBJARRAY( guNewPodcastChannelArray )
// -------------------------------------------------------------------------------- //
// guPodcastTreeCtrl
// -------------------------------------------------------------------------------- //
guPodcastTreeCtrl::guPodcastTreeCtrl( wxWindow * parent, guNewPodcastChannelArray * newpodcasts ) :
wxTreeCtrl( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
wxTR_DEFAULT_STYLE|wxTR_HIDE_ROOT|wxTR_FULL_ROW_HIGHLIGHT|wxTR_SINGLE|wxSUNKEN_BORDER )
{
m_NewPodcasts = newpodcasts;
m_NewItemsCount = 0;
m_RootId = AddRoot( wxT( "Channels" ), -1, -1, NULL );
SetIndent( 5 );
ReloadItems();
}
// -------------------------------------------------------------------------------- //
guPodcastTreeCtrl::~guPodcastTreeCtrl()
{
}
// -------------------------------------------------------------------------------- //
void guPodcastTreeCtrl::ReloadItems( void )
{
DeleteChildren( m_RootId );
int CountCh = m_NewPodcasts->Count();
for( int IndexCh = 0; IndexCh < CountCh; IndexCh++ )
{
guNewPodcastCategory * NewPodcastChannel = &m_NewPodcasts->Item( IndexCh );
wxTreeItemId LastItemId = AppendItem( m_RootId, NewPodcastChannel->m_Name, -1, -1, NULL );
int CountIt = NewPodcastChannel->m_Items.Count();
for( int IndexIt = 0; IndexIt < CountIt; IndexIt++ )
{
AppendItem( LastItemId, NewPodcastChannel->m_Items[ IndexIt ].m_Name, -1, -1,
new guNewPodcastItem( NewPodcastChannel->m_Items[ IndexIt ] ) );
}
m_NewItemsCount += CountIt;
}
}
// -------------------------------------------------------------------------------- //
// guNewPodcastChannelSelector
// -------------------------------------------------------------------------------- //
guNewPodcastChannelSelector::guNewPodcastChannelSelector( wxWindow * parent ) :
wxDialog( parent, wxID_ANY, _( "New Podcast Channel" ), wxDefaultPosition, wxSize( 550,410 ), wxDEFAULT_DIALOG_STYLE )
{
wxStaticText * UrlLabel;
wxStdDialogButtonSizer * m_StandardButtons;
wxButton * m_StandardButtonsOK;
wxButton * m_StandardButtonsCancel;
SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer * DirectoryMainSizer;
DirectoryMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* DirectoryStaticSizer;
DirectoryStaticSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _( " Digital Podcast Directory " ) ), wxVERTICAL );
wxBoxSizer* DirectoryTopSizer;
DirectoryTopSizer = new wxBoxSizer( wxHORIZONTAL );
//("Directory: 14 categories, 175 channels")
m_DirectoryInfoStaticText = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_DirectoryInfoStaticText->Wrap( -1 );
DirectoryTopSizer->Add( m_DirectoryInfoStaticText, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_FilterDirectory = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_search ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_FilterDirectory->SetToolTip( _( "Search in the podcast directory" ) );
DirectoryTopSizer->Add( m_FilterDirectory, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
m_DirectoryReload = new wxBitmapButton( this, wxID_ANY, guImage( guIMAGE_INDEX_tiny_reload ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_DirectoryReload->SetToolTip( _( "Refresh the podcast directory list" ) );
DirectoryTopSizer->Add( m_DirectoryReload, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
DirectoryStaticSizer->Add( DirectoryTopSizer, 0, wxEXPAND, 5 );
m_DirectoryTreeCtrl = new guPodcastTreeCtrl( this, &m_NewPodcasts );
DirectoryStaticSizer->Add( m_DirectoryTreeCtrl, 1, wxEXPAND|wxALL, 5 );
wxBoxSizer* UrlSizer;
UrlSizer = new wxBoxSizer( wxHORIZONTAL );
UrlLabel = new wxStaticText( this, wxID_ANY, wxT("Url:"), wxDefaultPosition, wxDefaultSize, 0 );
UrlLabel->Wrap( -1 );
UrlSizer->Add( UrlLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_UrlTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
UrlSizer->Add( m_UrlTextCtrl, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
DirectoryStaticSizer->Add( UrlSizer, 0, wxEXPAND, 5 );
DirectoryMainSizer->Add( DirectoryStaticSizer, 1, wxEXPAND|wxALL, 5 );
m_StandardButtons = new wxStdDialogButtonSizer();
m_StandardButtonsOK = new wxButton( this, wxID_OK );
m_StandardButtons->AddButton( m_StandardButtonsOK );
m_StandardButtonsCancel = new wxButton( this, wxID_CANCEL );
m_StandardButtons->AddButton( m_StandardButtonsCancel );
m_StandardButtons->SetAffirmativeButton( m_StandardButtonsOK );
m_StandardButtons->SetCancelButton( m_StandardButtonsCancel );
m_StandardButtons->Realize();
DirectoryMainSizer->Add( m_StandardButtons, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
this->SetSizer( DirectoryMainSizer );
this->Layout();
m_StandardButtonsOK->SetDefault();
// Bind Events
m_FilterDirectory->Bind( wxEVT_BUTTON, &guNewPodcastChannelSelector::OnFilterDirectoryClicked, this );
m_DirectoryReload->Bind( wxEVT_BUTTON, &guNewPodcastChannelSelector::OnReloadDirectoryClicked, this );
m_DirectoryTreeCtrl->Bind( wxEVT_TREE_ITEM_ACTIVATED, &guNewPodcastChannelSelector::OnDirectoryItemSelected, this );
m_DirectoryTreeCtrl->Bind( wxEVT_TREE_SEL_CHANGED, &guNewPodcastChannelSelector::OnDirectoryItemChanged, this );
//
LoadPodcastDirectory();
m_UrlTextCtrl->SetFocus();
}
// -------------------------------------------------------------------------------- //
guNewPodcastChannelSelector::~guNewPodcastChannelSelector()
{
// Unbind events
m_FilterDirectory->Unbind( wxEVT_BUTTON, &guNewPodcastChannelSelector::OnFilterDirectoryClicked, this );
m_DirectoryReload->Unbind( wxEVT_BUTTON, &guNewPodcastChannelSelector::OnReloadDirectoryClicked, this );
m_DirectoryTreeCtrl->Unbind( wxEVT_TREE_ITEM_ACTIVATED, &guNewPodcastChannelSelector::OnDirectoryItemSelected, this );
m_DirectoryTreeCtrl->Unbind( wxEVT_TREE_SEL_CHANGED, &guNewPodcastChannelSelector::OnDirectoryItemChanged, this );
}
// -------------------------------------------------------------------------------- //
wxString guNewPodcastChannelSelector::GetValue( void )
{
return m_UrlTextCtrl->GetValue();
}
// -------------------------------------------------------------------------------- //
int guNewPodcastChannelSelector::ReadNewPodcastChannel( wxXmlNode * XmlNode, guNewPodcastCategory * podcastchannel )
{
while( XmlNode && XmlNode->GetName() == wxT( "outline" ) )
{
guNewPodcastItem * NewPodcastItem = new guNewPodcastItem();
if( !NewPodcastItem )
return 0;
XmlNode->GetAttribute( wxT( "text" ), &NewPodcastItem->m_Name );
XmlNode->GetAttribute( wxT( "url" ), &NewPodcastItem->m_Url );
int Count = m_Filters.Count();
if( Count )
{
bool ItemFound = false;
for( int Index = 0; Index < Count; Index++ )
{
if( NewPodcastItem->m_Name.Lower().Find( m_Filters[ Index ].Lower() ) != wxNOT_FOUND )
{
//guLogMessage( wxT( "Found item %s" ), NewPodcastItem->m_Name.c_str() );
podcastchannel->m_Items.Add( NewPodcastItem );
ItemFound = true;
break;
}
}
if( !ItemFound )
delete NewPodcastItem;
}
else
{
podcastchannel->m_Items.Add( NewPodcastItem );
}
XmlNode = XmlNode->GetNext();
}
return podcastchannel->m_Items.Count();
}
// -------------------------------------------------------------------------------- //
int guNewPodcastChannelSelector::ReadNewPodcastChannels( wxXmlNode * XmlNode )
{
guNewPodcastCategory * NewPodcastChannel = NULL;
while( XmlNode && XmlNode->GetName() == wxT( "outline" ) )
{
// if( !NewPodcastChannel )
// return 0;
if( m_Filters.Count() )
{
if( !m_NewPodcasts.Count() )
{
NewPodcastChannel = new guNewPodcastCategory();
NewPodcastChannel->m_Name = _( "Filtered channels" );
m_NewPodcasts.Add( NewPodcastChannel );
}
}
else
{
NewPodcastChannel = new guNewPodcastCategory();
XmlNode->GetAttribute( wxT( "text" ), &NewPodcastChannel->m_Name );
}
if( !NewPodcastChannel )
return 0;
if( ReadNewPodcastChannel( XmlNode->GetChildren(), NewPodcastChannel ) )
{
if( !m_Filters.Count() )
m_NewPodcasts.Add( NewPodcastChannel );
}
else
{
if( !m_Filters.Count() )
delete NewPodcastChannel;
}
XmlNode = XmlNode->GetNext();
}
return m_NewPodcasts.Count();
}
// -------------------------------------------------------------------------------- //
int guNewPodcastChannelSelector::LoadNewPodcastsFromXml( const wxString &filename )
{
wxFFileInputStream ins( filename );
wxXmlDocument XmlDoc( ins );
wxXmlNode * XmlNode = XmlDoc.GetRoot();
if( XmlNode )
{
if( XmlNode->GetName() == wxT( "opml" ) )
{
XmlNode = XmlNode->GetChildren();
while( XmlNode )
{
if( XmlNode->GetName() == wxT( "body" ) )
{
ReadNewPodcastChannels( XmlNode->GetChildren() );
}
XmlNode = XmlNode->GetNext();
}
}
}
return m_NewPodcasts.Count();
}
// -------------------------------------------------------------------------------- //
void guNewPodcastChannelSelector::LoadPodcastDirectory( void )
{
guConfig * Config = ( guConfig * ) guConfig::Get();
wxString PodcastsPath = Config->ReadStr( CONFIG_KEY_PODCASTS_PATH,
guPATH_PODCASTS,
CONFIG_PATH_PODCASTS );
wxSetCursor( * wxHOURGLASS_CURSOR );
wxTheApp->Yield();
if( wxFileExists( PodcastsPath + wxT( "/Podcast.Directory.xml" ) ) ||
DownloadFile( guDIGITALPODCAST_OPML, PodcastsPath + wxT( "/Podcast.Directory.xml" ) ) )
{
m_NewPodcasts.Empty();
if( LoadNewPodcastsFromXml( PodcastsPath + wxT( "/Podcast.Directory.xml" ) ) )
{
m_DirectoryTreeCtrl->ReloadItems();
if( m_Filters.Count() )
{
m_DirectoryInfoStaticText->SetLabel( wxString::Format( _( "%u Channels" ),
m_DirectoryTreeCtrl->GetItemsCount() ) );
}
else
{
m_DirectoryInfoStaticText->SetLabel( wxString::Format( _( "%u Categories, %u Channels" ),
m_DirectoryTreeCtrl->GetCategoryCount(),
m_DirectoryTreeCtrl->GetItemsCount() ) );
}
//guLogMessage( wxT( "%s" ), m_DirectoryInfoStaticText->GetLabel().c_str() );
}
}
else
{
guLogWarning( wxT( "Could not download the Podcast Directory xml file" ) );
}
if( m_Filters.Count() )
{
m_DirectoryTreeCtrl->ExpandAll();
}
else
{
m_DirectoryTreeCtrl->ExpandRoot();
}
wxSetCursor( * wxSTANDARD_CURSOR );
}
// -------------------------------------------------------------------------------- //
void guNewPodcastChannelSelector::OnDirectoryItemChanged( wxTreeEvent &event )
{
guNewPodcastItem * ItemData = ( guNewPodcastItem * ) m_DirectoryTreeCtrl->GetItemData( event.GetItem() );
if( ItemData )
{
m_UrlTextCtrl->SetValue( ItemData->m_Url );
}
else
{
m_UrlTextCtrl->SetValue( wxEmptyString );
}
}
// -------------------------------------------------------------------------------- //
void guNewPodcastChannelSelector::OnDirectoryItemSelected( wxTreeEvent &event )
{
guNewPodcastItem * ItemData = ( guNewPodcastItem * ) m_DirectoryTreeCtrl->GetItemData( event.GetItem() );
if( ItemData )
{
m_UrlTextCtrl->SetValue( ItemData->m_Url );
EndModal( wxID_OK );
}
else
{
event.Skip();
}
}
// -------------------------------------------------------------------------------- //
void guNewPodcastChannelSelector::OnFilterDirectoryClicked( wxCommandEvent &event )
{
wxString FilterText = wxEmptyString;
int Count = m_Filters.Count();
if( Count )
{
for( int Index = 0; Index < Count; Index++ )
{
FilterText += m_Filters[ Index ] + wxT( " " );
}
FilterText.RemoveLast();
}
wxTextEntryDialog * EntryDialog = new wxTextEntryDialog( guMainFrame::GetMainFrame(), _( "Filter Text: " ), _( "Enter the text to filter podcasts channels" ), FilterText );
if( EntryDialog->ShowModal() == wxID_OK )
{
m_Filters = wxStringTokenize( EntryDialog->GetValue(), wxT( "\t\r\n " ) );
//guLogMessage( wxT( "Filter Text : '%s' %u items" ), EntryDialog->GetValue().c_str(), m_Filters.Count() );
LoadPodcastDirectory();
}
EntryDialog->Destroy();
}
// -------------------------------------------------------------------------------- //
void guNewPodcastChannelSelector::OnReloadDirectoryClicked( wxCommandEvent &event )
{
guConfig * Config = ( guConfig * ) guConfig::Get();
wxString PodcastsPath = Config->ReadStr( CONFIG_KEY_PODCASTS_PATH,
guPATH_PODCASTS,
CONFIG_PATH_PODCASTS );
wxRemoveFile( PodcastsPath + wxT( "/Podcast.Directory.xml" ) );
LoadPodcastDirectory();
}
}
// -------------------------------------------------------------------------------- //
| 15,217
|
C++
|
.cpp
| 344
| 37.802326
| 176
| 0.590427
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
750,664
|
ChannelEditor.cpp
|
anonbeat_guayadeque/src/ui/podcasts/ChannelEditor.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "ChannelEditor.h"
#include "Config.h"
#include "EventCommandIds.h"
#include "Images.h"
#include "Utils.h"
#include <wx/filename.h>
namespace Guayadeque {
wxDECLARE_EVENT( guChannelEditorEvent, wxCommandEvent );
#define guPODCASTS_IMAGE_SIZE 60
// -------------------------------------------------------------------------------- //
guChannelEditor::guChannelEditor( wxWindow * parent, guPodcastChannel * channel ) :
wxDialog( parent, wxID_ANY, _( "Podcast Channel Editor" ), wxDefaultPosition, wxSize( 564,329 ), wxDEFAULT_DIALOG_STYLE )
{
wxStaticText* DescLabel;
wxStaticText* AuthorLabel;
wxStaticText* OwnerLabel;
wxStaticText* DownloadLabel;
wxStaticText* DeleteLabel;
wxStdDialogButtonSizer* ButtonsSizer;
wxButton* ButtonsSizerOK;
wxButton* ButtonsSizerCancel;
m_PodcastChannel = channel;
guConfig * Config = ( guConfig * ) guConfig::Get();
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* MainSizer;
MainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* ChannelSizer;
ChannelSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _( " Podcast Channel " ) ), wxVERTICAL );
wxFlexGridSizer* FlexGridSizer;
FlexGridSizer = new wxFlexGridSizer( 2, 0, 0 );
FlexGridSizer->AddGrowableCol( 1 );
FlexGridSizer->SetFlexibleDirection( wxBOTH );
FlexGridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_Image = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( guPODCASTS_IMAGE_SIZE,guPODCASTS_IMAGE_SIZE ), 0 );
FlexGridSizer->Add( m_Image, 0, wxALL, 5 );
// Check that the directory to store podcasts are created
wxString PodcastsPath = Config->ReadStr( CONFIG_KEY_PODCASTS_PATH, guPATH_PODCASTS, CONFIG_PATH_PODCASTS );
wxFileName ImageFile = wxFileName( PodcastsPath + wxT( "/" ) +
channel->m_Title + wxT( "/" ) +
channel->m_Title + wxT( ".jpg" ) );
if( ImageFile.Normalize( wxPATH_NORM_ALL | wxPATH_NORM_CASE ) )
{
wxImage PodcastImage;
if( wxFileExists( ImageFile.GetFullPath() ) &&
PodcastImage.LoadFile( ImageFile.GetFullPath() ) &&
PodcastImage.IsOk() )
{
m_Image->SetBitmap( PodcastImage );
}
else
{
m_Image->SetBitmap( guBitmap( guIMAGE_INDEX_mid_podcast ) );
if( !channel->m_Image.IsEmpty() )
{
guChannelUpdateImageThread * UpdateImageThread = new guChannelUpdateImageThread( this, channel->m_Image.c_str() );
if( !UpdateImageThread )
{
guLogError( wxT( "Could not create the Channel Image Thread" ) );
}
}
}
}
m_Title = new wxStaticText( this, wxID_ANY, channel->m_Title, wxDefaultPosition, wxDefaultSize, 0 );
FlexGridSizer->Add( m_Title, 1, wxEXPAND, 5 );
DescLabel = new wxStaticText( this, wxID_ANY, _( "Description:" ), wxDefaultPosition, wxDefaultSize, 0 );
DescLabel->Wrap( -1 );
DescLabel->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );
FlexGridSizer->Add( DescLabel, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_DescText = new wxStaticText( this, wxID_ANY, ( channel->m_Description.Length() > 200 ?
channel->m_Description.Mid( 0, 200 ) + wxT( " ..." ) :
channel->m_Description ), wxDefaultPosition, wxDefaultSize, 0 );
m_DescText->Wrap( 450 );
FlexGridSizer->Add( m_DescText, 0, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
AuthorLabel = new wxStaticText( this, wxID_ANY, _("Author:"), wxDefaultPosition, wxDefaultSize, 0 );
AuthorLabel->Wrap( -1 );
AuthorLabel->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );
FlexGridSizer->Add( AuthorLabel, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_AuthorText = new wxStaticText( this, wxID_ANY, channel->m_Author, wxDefaultPosition, wxDefaultSize, 0 );
m_AuthorText->Wrap( -1 );
FlexGridSizer->Add( m_AuthorText, 0, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
OwnerLabel = new wxStaticText( this, wxID_ANY, _("Owner:"), wxDefaultPosition, wxDefaultSize, 0 );
OwnerLabel->Wrap( -1 );
OwnerLabel->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );
FlexGridSizer->Add( OwnerLabel, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_OwnerText = new wxStaticText( this, wxID_ANY, channel->m_OwnerName +
wxT( " ( " ) + channel->m_OwnerEmail + wxT( " )" ) , wxDefaultPosition, wxDefaultSize, 0 );
m_OwnerText->Wrap( -1 );
FlexGridSizer->Add( m_OwnerText, 0, wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
DownloadLabel = new wxStaticText( this, wxID_ANY, _("Download:"), wxDefaultPosition, wxDefaultSize, 0 );
DownloadLabel->Wrap( -1 );
FlexGridSizer->Add( DownloadLabel, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxBoxSizer* DownloadSizer;
DownloadSizer = new wxBoxSizer( wxHORIZONTAL );
wxString m_DownloadChoiceChoices[] = { _( "Manually" ), _( "Only if contains" ), _( "Everything" ) };
int m_DownloadChoiceNChoices = sizeof( m_DownloadChoiceChoices ) / sizeof( wxString );
m_DownloadChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_DownloadChoiceNChoices, m_DownloadChoiceChoices, 0 );
m_DownloadChoice->SetSelection( channel->m_DownloadType );
DownloadSizer->Add( m_DownloadChoice, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_DownloadText = new wxTextCtrl( this, wxID_ANY, channel->m_DownloadText, wxDefaultPosition, wxDefaultSize, 0 );
m_DownloadText->Enable( ( channel->m_DownloadType == guPODCAST_DOWNLOAD_FILTER ) );
DownloadSizer->Add( m_DownloadText, 1, wxEXPAND|wxALL, 5 );
FlexGridSizer->Add( DownloadSizer, 1, wxEXPAND, 5 );
DeleteLabel = new wxStaticText( this, wxID_ANY, _("Delete:"), wxDefaultPosition, wxDefaultSize, 0 );
DeleteLabel->Wrap( -1 );
FlexGridSizer->Add( DeleteLabel, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_DeleteCheckBox = new wxCheckBox( this, wxID_ANY, _( "Allow delete old items" ), wxDefaultPosition, wxDefaultSize, 0 );
m_DeleteCheckBox->SetValue( channel->m_AllowDelete );
FlexGridSizer->Add( m_DeleteCheckBox, 0, wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
ChannelSizer->Add( FlexGridSizer, 1, wxEXPAND, 5 );
MainSizer->Add( ChannelSizer, 1, wxEXPAND|wxALL, 5 );
ButtonsSizer = new wxStdDialogButtonSizer();
ButtonsSizerOK = new wxButton( this, wxID_OK );
ButtonsSizer->AddButton( ButtonsSizerOK );
ButtonsSizerCancel = new wxButton( this, wxID_CANCEL );
ButtonsSizer->AddButton( ButtonsSizerCancel );
ButtonsSizer->SetAffirmativeButton( ButtonsSizerOK );
ButtonsSizer->SetCancelButton( ButtonsSizerCancel );
ButtonsSizer->Realize();
MainSizer->Add( ButtonsSizer, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
this->SetSizer( MainSizer );
this->Layout();
ButtonsSizerOK->SetDefault();
// Bind Events
m_DownloadChoice->Bind( wxEVT_CHOICE, &guChannelEditor::OnDownloadChoice, this );
Bind( guChannelEditorEvent, &guChannelEditor::OnChannelImageUpdated, this, guCHANNELEDITOR_EVENT_UPDATE_IMAGE );
m_DescText->SetFocus();
}
// -------------------------------------------------------------------------------- //
guChannelEditor::~guChannelEditor()
{
// Unbind Events
m_DownloadChoice->Unbind( wxEVT_CHOICE, &guChannelEditor::OnDownloadChoice, this );
Unbind( guChannelEditorEvent, &guChannelEditor::OnChannelImageUpdated, this, guCHANNELEDITOR_EVENT_UPDATE_IMAGE );
}
// -------------------------------------------------------------------------------- //
void guChannelEditor::OnDownloadChoice( wxCommandEvent &event )
{
m_DownloadText->Enable( m_DownloadChoice->GetSelection() == 1 );
}
// -------------------------------------------------------------------------------- //
void guChannelEditor::GetEditData( void )
{
//m_PodcastChannel->m_Title = m_Title->GetValue();
m_PodcastChannel->m_DownloadType = m_DownloadChoice->GetSelection();
m_PodcastChannel->m_DownloadText = ( m_PodcastChannel->m_DownloadType == 1 ) ?
m_DownloadText->GetValue() : wxT( "" );
m_PodcastChannel->m_AllowDelete = m_DeleteCheckBox->IsChecked();
}
// -------------------------------------------------------------------------------- //
void guChannelEditor::OnChannelImageUpdated( wxCommandEvent &event )
{
wxImage * Image = ( wxImage * ) event.GetClientData();
if( Image )
{
m_Image->SetBitmap( * Image );
delete Image;
}
}
// -------------------------------------------------------------------------------- //
// guChannelUpdateImageThread
// -------------------------------------------------------------------------------- //
guChannelUpdateImageThread::guChannelUpdateImageThread( guChannelEditor * channeleditor, const wxChar * imageurl ) :
wxThread( wxTHREAD_DETACHED )
{
m_ChannelEditor = channeleditor;
m_ImageUrl = wxString( imageurl );
if( Create() == wxTHREAD_NO_ERROR )
{
SetPriority( WXTHREAD_DEFAULT_PRIORITY - 30 );
Run();
}
}
// -------------------------------------------------------------------------------- //
guChannelUpdateImageThread::~guChannelUpdateImageThread()
{
}
// -------------------------------------------------------------------------------- //
guChannelUpdateImageThread::ExitCode guChannelUpdateImageThread::Entry()
{
wxImage * Image = NULL;
if( !m_ImageUrl.IsEmpty() )
{
if( !TestDestroy() )
{
wxBitmapType ImageType;
Image = guGetRemoteImage( m_ImageUrl, ImageType );
if( Image )
{
//guLogMessage( wxT( "Image loaded ok %u" ), Index );
if( Image->IsOk() && !TestDestroy() )
{
Image->Rescale( guPODCASTS_IMAGE_SIZE, guPODCASTS_IMAGE_SIZE, wxIMAGE_QUALITY_HIGH );
}
else
{
delete Image;
Image = NULL;
}
}
}
}
//
if( !TestDestroy() )
{
wxCommandEvent event( guChannelEditorEvent, guCHANNELEDITOR_EVENT_UPDATE_IMAGE );
event.SetClientData( Image );
wxPostEvent( m_ChannelEditor, event );
}
else if( Image )
{
delete Image;
}
return 0;
}
}
// -------------------------------------------------------------------------------- //
| 11,565
|
C++
|
.cpp
| 237
| 43.362869
| 139
| 0.624191
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,665
|
RatingCtrl.cpp
|
anonbeat_guayadeque/src/ui/ratingctrl/RatingCtrl.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "RatingCtrl.h"
#include "Images.h"
#include "Utils.h"
#include <wx/dcclient.h>
namespace Guayadeque {
wxIMPLEMENT_DYNAMIC_CLASS( guRatingEvent, wxEvent );
wxDEFINE_EVENT( guEVT_RATING_CHANGED, guRatingEvent );
BEGIN_EVENT_TABLE( guRating, wxControl )
EVT_PAINT( guRating::OnPaint)
EVT_MOUSE_EVENTS( guRating::OnMouseEvents )
END_EVENT_TABLE()
// -------------------------------------------------------------------------------- //
guRating::guRating( wxWindow * parent, const int style ) :
wxControl( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE )
{
m_Rating = wxNOT_FOUND;
m_Style = style;
m_NormalStar = new wxBitmap( guImage( ( guIMAGE_INDEX ) ( guIMAGE_INDEX_star_normal_tiny + style ) ) );
m_SelectStar = new wxBitmap( guImage( ( guIMAGE_INDEX ) ( guIMAGE_INDEX_star_highlight_tiny + style ) ) );
}
// -------------------------------------------------------------------------------- //
guRating::~guRating()
{
if( m_NormalStar )
delete m_NormalStar;
if( m_SelectStar )
delete m_SelectStar;
}
// -------------------------------------------------------------------------------- //
void guRating::SetRating( const int rating )
{
m_Rating = rating;
Refresh();
}
// -------------------------------------------------------------------------------- //
int guRating::GetRating( void )
{
return m_Rating;
}
// -------------------------------------------------------------------------------- //
wxSize guRating::DoGetBestSize( void ) const
{
wxSize RetVal;
RetVal.x = 4 + ( 5 * ( ( m_Style * 2 ) + GURATING_IMAGE_SIZE ) );
RetVal.y = ( m_Style * 2 ) + GURATING_IMAGE_SIZE + 4;
return RetVal;
}
// -------------------------------------------------------------------------------- //
void guRating::OnPaint( wxPaintEvent &event )
{
wxPaintDC dc( this );
PrepareDC( dc );
dc.SetBackgroundMode( wxTRANSPARENT );
int x;
int w = ( ( m_Style * 2 ) + GURATING_IMAGE_SIZE );
for( x = 0; x < 5; x++ )
{
dc.DrawBitmap( ( x >= m_Rating ) ? * m_NormalStar : * m_SelectStar,
3 + ( w * x ), 2, true );
}
}
// -------------------------------------------------------------------------------- //
void guRating::OnMouseEvents( wxMouseEvent &event )
{
if( event.RightDown() || event.LeftDown() )
{
int SavedRating = m_Rating;
if( event.RightDown() )
{
m_Rating = 0;
}
else if( event.LeftDown() )
{
int w = ( ( m_Style * 2 ) + GURATING_IMAGE_SIZE );
if( event.m_x < 3 )
m_Rating = 0;
else
m_Rating = wxMin( 5, ( wxMax( 0, event.m_x - 3 ) / w ) + 1 );
//guLogMessage( wxT( "Clicked %i %i" ), event.m_x, m_Rating );
}
if( SavedRating == m_Rating )
{
m_Rating = 0;
}
if( SavedRating != m_Rating )
{
Refresh();
guRatingEvent evt( guEVT_RATING_CHANGED );
//evt.SetClientObject( this );
evt.SetInt( m_Rating );
wxPostEvent( this, evt );
}
}
}
}
// -------------------------------------------------------------------------------- //
| 4,314
|
C++
|
.cpp
| 117
| 32.119658
| 110
| 0.488873
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,666
|
GstPipelineBuilder.cpp
|
anonbeat_guayadeque/src/audio/GstPipelineBuilder.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "GstPipelineBuilder.h"
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
// guGstPipelineBuilder
// -------------------------------------------------------------------------------- //
bool guGstPipelineBuilder::IsValidElement( GstElement * element )
{
if( !GST_IS_ELEMENT( element ) )
{
if( G_IS_OBJECT( element ) )
g_object_unref( element );
return false;
}
return true;
}
// -------------------------------------------------------------------------------- //
guGstPipelineBuilder::guGstPipelineBuilder( GstElement * the_bin )
{
guLogDebug( "guGstPipelineBuilder::guGstPipelineBuilder existing bin: %s", GST_ELEMENT_NAME(the_bin) );
m_CanPlay = false;
m_Last = NULL;
m_Cleanup = true;
m_Bin = the_bin;
}
// -------------------------------------------------------------------------------- //
guGstPipelineBuilder::guGstPipelineBuilder( const char * bin_name, GstElement ** element_ref )
{
guLogDebug( "guGstPipelineBuilder::guGstPipelineBuilder %s (%p)", bin_name, element_ref );
m_CanPlay = false;
m_Last = NULL;
m_Cleanup = true;
m_Bin = gst_bin_new( bin_name );
if( IsValidElement( m_Bin ) )
{
PushElement( m_Bin, element_ref );
m_CanPlay = true;
if( element_ref != NULL )
*element_ref = m_Bin;
}
else
guLogError( "Unable to create gstreamer bin" );
}
// -------------------------------------------------------------------------------- //
guGstPipelineBuilder::~guGstPipelineBuilder()
{
guLogDebug( "guGstPipelineBuilder::~guGstPipelineBuilder" );
if( !m_Cleanup )
return;
while( !m_UnrefElementStack.empty() )
{
guGstPipelineElementPack pe = m_UnrefElementStack.top();
if( IsValidElement( pe.element ) )
{
guLogDebug( "guGstPipelineBuilder::~guGstPipelineBuilder unref: %p", pe.element );
gst_object_unref( pe.element );
}
if( pe.element_ref != NULL )
{
guLogDebug( "guGstPipelineBuilder::~guGstPipelineBuilder nullptr: %p", pe.element_ref );
*pe.element_ref = NULL;
}
m_UnrefElementStack.pop();
}
}
// -------------------------------------------------------------------------------- //
void guGstPipelineBuilder::PushElement( GstElement * element, GstElement ** element_ref )
{
guLogDebug( "guGstPipelineBuilder::PushElement %p (%p)", element, element_ref );
guGstPipelineElementPack e;
e.element = element;
e.element_ref = element_ref;
m_UnrefElementStack.push( e );
m_ElementChain.push_back( element );
}
bool guGstPipelineBuilder::Link( GstElement * element )
{
guLogDebug( "guGstPipelineBuilder::Link %p", element );
if( gst_bin_add( GST_BIN(m_Bin), element ) )
{
if( m_Last == NULL || gst_element_link( m_Last, element ) )
{
m_Last = element;
return true;
}
else
{
char * this_name = gst_element_get_name( element );
char * last_name = gst_element_get_name( m_Last );
guLogError( "Unable to link elements: %s -> %s", last_name, this_name );
g_free( this_name );
g_free( last_name );
}
}
else
{
char * this_name = gst_element_get_name( element );
guLogError( "Gstreamer bin did not accept the element: %s", this_name );
g_free( this_name );
}
m_CanPlay = false;
return false;
}
} // namespace Guayadeque
| 4,663
|
C++
|
.cpp
| 124
| 32.282258
| 107
| 0.543002
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,667
|
FaderTimeLine.cpp
|
anonbeat_guayadeque/src/audio/FaderTimeLine.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "FaderTimeLine.h"
#include "MediaCtrl.h"
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
guFaderTimeLine::guFaderTimeLine( const int timeout, wxEvtHandler * parent, guFaderPlaybin * faderplaybin,
double volstart, double volend ) :
guTimeLine( timeout, parent )
{
m_FaderPlayBin = faderplaybin;
m_VolStart = volstart;
m_VolEnd = volend;
if( volstart > volend )
m_VolStep = volstart - volend;
else
m_VolStep = volend - volstart;
//guLogDebug( wxT( "Created the fader timeline for %i msecs %0.2f -> %0.2f (%0.2f)" ), timeout, volstart, volend, m_VolStep );
}
// -------------------------------------------------------------------------------- //
guFaderTimeLine::~guFaderTimeLine()
{
//guLogDebug( wxT( "Destroyed the fader timeline" ) );
}
// -------------------------------------------------------------------------------- //
void guFaderTimeLine::ValueChanged( float value )
{
if( m_Duration )
{
if( m_Direction == guTimeLine::Backward )
{
m_FaderPlayBin->SetFaderVolume( m_VolEnd + ( value * m_VolStep ) );
}
else
{
m_FaderPlayBin->SetFaderVolume( m_VolStart + ( value * m_VolStep ) );
}
}
}
// -------------------------------------------------------------------------------- //
void guFaderTimeLine::Finished( void )
{
m_FaderPlayBin->SetFaderVolume( m_VolEnd );
m_FaderPlayBin->EndFade();
}
// -------------------------------------------------------------------------------- //
static bool TimerUpdated( guFaderTimeLine * timeline )
{
timeline->TimerEvent();
return true;
}
// -------------------------------------------------------------------------------- //
int guFaderTimeLine::TimerCreate( void )
{
return g_timeout_add( m_UpdateInterval, GSourceFunc( TimerUpdated ), this );
}
}
// -------------------------------------------------------------------------------- //
| 3,059
|
C++
|
.cpp
| 77
| 36.545455
| 130
| 0.509091
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,668
|
MediaCtrl.cpp
|
anonbeat_guayadeque/src/audio/MediaCtrl.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "MediaCtrl.h"
#include "Config.h"
#include "FileRenamer.h" // NormalizeField
#include "LevelInfo.h"
#include "PlayerPanel.h"
#include "RadioTagInfo.h"
#include "Settings.h"
#include "TagInfo.h"
#include "Utils.h"
#include <wx/uri.h>
namespace Guayadeque {
#define guFADERPLAYBIN_FAST_FADER_TIME (1000)
#define guFADERPLAYBIN_SHORT_FADER_TIME (200)
#define GST_TO_WXSTRING( str ) ( wxString( str, wxConvUTF8 ) )
#ifdef GU_DEBUG
#define guSHOW_DUMPFADERPLAYBINS 1
#endif
#ifdef guSHOW_DUMPFADERPLAYBINS
// -------------------------------------------------------------------------------- //
static void DumpFaderPlayBins( const guFaderPlayBinArray &playbins, guFaderPlaybin * current )
{
guLogDebug( wxT( "CurrentPlayBin: %li" ), current ? current->GetId() : 0l );
if( !playbins.Count() )
{
guLogMessage( wxT( "The faderplaybins list is empty" ) );
return;
}
guLogDebug( wxT( " * * * * * * * * * * current stream list * * * * * * * * * *" ) );
int Count = playbins.Count();
for( int Index = 0; Index < Count; Index++ )
{
guFaderPlaybin * FaderPlayBin = playbins[ Index ];
wxString StateName;
switch( FaderPlayBin->GetState() )
{
case guFADERPLAYBIN_STATE_WAITING : StateName = wxT( "waiting" ); break;
case guFADERPLAYBIN_STATE_PLAYING : StateName = wxT( "playing" ); break;
case guFADERPLAYBIN_STATE_PAUSED : StateName = wxT( "paused" ); break;
case guFADERPLAYBIN_STATE_STOPPED : StateName = wxT( "stopped" ); break;
case guFADERPLAYBIN_STATE_FADEIN : StateName = wxT( "fading in" ); break;
case guFADERPLAYBIN_STATE_WAITING_EOS : StateName = wxT( "waiting for EOS" ); break;
case guFADERPLAYBIN_STATE_FADEOUT : StateName = wxT( "fading out" ); break;
case guFADERPLAYBIN_STATE_FADEOUT_PAUSE : StateName = wxT( "fading->paused" ); break;
case guFADERPLAYBIN_STATE_FADEOUT_STOP : StateName = wxT( "fading->stopped" ); break;
case guFADERPLAYBIN_STATE_PENDING_REMOVE: StateName = wxT( "pending remove" ); break;
case guFADERPLAYBIN_STATE_ERROR : StateName = wxT( "error" ); break;
default : StateName = wxT( "other" ); break;
}
//if( !FaderPlayBin->Uri().IsEmpty() )
{
guLogDebug( wxT( "[%li] '%s'" ), FaderPlayBin->GetId(), StateName.c_str() );
}
}
guLogDebug( wxT( " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * " ) );
}
#endif
// -------------------------------------------------------------------------------- //
extern "C" {
// -------------------------------------------------------------------------------- //
// idle handler used to clean up finished streams
static gboolean cleanup_mediactrl( guMediaCtrl * player )
{
player->DoCleanUp();
return false;
}
// -------------------------------------------------------------------------------- //
static bool tick_timeout( guMediaCtrl * mediactrl )
{
mediactrl->UpdatePosition();
return true;
}
}
// -------------------------------------------------------------------------------- //
guMediaCtrl::guMediaCtrl( guPlayerPanel * playerpanel )
{
m_PlayerPanel = playerpanel;
m_CurrentPlayBin = NULL;
m_CleanUpId = 0;
m_IsRecording = false;
m_LastPosition = 0;
// now that the sink is running, start polling for playing position.
// might want to replace this with a complicated set of pad probes
// to avoid polling, but duration queries on the sink are better
// as they account for internal buffering etc. maybe there's a way
// to account for that in a pad probe callback on the sink's sink pad?
gint ms_period = 1000 / 4;
m_TickTimeoutId = g_timeout_add( ms_period, GSourceFunc( tick_timeout ), this );
if( Init() )
{
guConfig * Config = guConfig::Get();
m_ForceGapless = Config->ReadBool( CONFIG_KEY_CROSSFADER_FORCE_GAPLESS, false, CONFIG_PATH_CROSSFADER );
UpdatedConfig();
}
}
// -------------------------------------------------------------------------------- //
guMediaCtrl::~guMediaCtrl()
{
if( m_TickTimeoutId )
{
g_source_remove( m_TickTimeoutId );
m_TickTimeoutId = 0;
}
if( m_CleanUpId )
{
g_source_remove( m_CleanUpId );
m_CleanUpId = 0;
}
CleanUp();
gst_deinit();
}
// -------------------------------------------------------------------------------- //
void guMediaCtrl::CleanUp( void )
{
Lock();
int Count = m_FaderPlayBins.Count();
for( int Index = 0; Index < Count; Index++ )
{
delete m_FaderPlayBins[ Index ];
}
Unlock();
}
// -------------------------------------------------------------------------------- //
void guMediaCtrl::SendEvent( guMediaEvent &event )
{
wxPostEvent( m_PlayerPanel, event );
}
// -------------------------------------------------------------------------------- //
void guMediaCtrl::UpdatePosition( void )
{
gint64 Pos = -1;
gint64 Duration = -1;
Lock();
if( m_CurrentPlayBin )
{
m_CurrentPlayBin->Lock();
Pos = m_CurrentPlayBin->Position();
Pos /= GST_MSECOND;
Duration = -1;
gst_element_query_duration( m_CurrentPlayBin->m_OutputSink, GST_FORMAT_TIME, &Duration );
if( Pos != m_LastPosition )
{
if( !m_CurrentPlayBin->AboutToFinishPending() || Pos < m_LastPosition )
{
//guLogMessage( wxT( "Sent UpdatePositon event for %i" ), m_CurrentPlayBin->GetId() );
guMediaEvent event( guEVT_MEDIA_CHANGED_POSITION );
event.SetInt( Pos );
event.SetExtraLong( Duration / GST_MSECOND );
event.SetClientData( ( void * ) m_CurrentPlayBin->GetId() );
SendEvent( event );
if( m_CurrentPlayBin->AboutToFinishPending() )
m_CurrentPlayBin->ResetAboutToFinishPending();
}
m_LastPosition = Pos;
}
//guLogDebug( wxT( "Current fade volume: %0.2f" ), m_CurrentPlayBin->GetFaderVolume() );
m_CurrentPlayBin->Unlock();
}
Unlock();
}
// -------------------------------------------------------------------------------- //
bool guMediaCtrl::RemovePlayBin( guFaderPlaybin * playbin )
{
guLogDebug( wxT( "guMediaCtrl::RemovePlayBin (%li)" ), playbin->m_Id );
bool RetVal = false;
Lock();
if( m_CurrentPlayBin == playbin )
m_CurrentPlayBin = NULL;
if( m_FaderPlayBins.Index( playbin ) != wxNOT_FOUND )
{
m_FaderPlayBins.Remove( playbin );
RetVal = true;
}
Unlock();
return RetVal;
}
// -------------------------------------------------------------------------------- //
wxFileOffset guMediaCtrl::Position( void )
{
wxFileOffset Pos = 0;
Lock();
if( m_CurrentPlayBin )
{
Pos = m_CurrentPlayBin->Position();
}
Unlock();
return Pos;
}
// -------------------------------------------------------------------------------- //
wxFileOffset guMediaCtrl::Length( void )
{
Lock();
wxFileOffset Len = 0;
if( m_CurrentPlayBin )
{
Len = m_CurrentPlayBin->Length();
}
Unlock();
return Len;
}
// -------------------------------------------------------------------------------- //
bool guMediaCtrl::SetVolume( double volume )
{
guLogDebug( wxT( "MediaCtrl::SetVolume( %0.5f )" ), volume );
m_Volume = volume;
Lock();
int Count = m_FaderPlayBins.Count();
for( int Index = 0; Index < Count; Index++ )
{
m_FaderPlayBins[ Index ]->SetVolume( volume );
}
Unlock();
return true;
}
// -------------------------------------------------------------------------------- //
void guMediaCtrl::SetEqualizerBand( const int band, const int value )
{
m_EqBands[ band ] = value;
Lock();
int Count = m_FaderPlayBins.Count();
for( int Index = 0; Index < Count; Index++ )
{
m_FaderPlayBins[ Index ]->SetEqualizerBand( band, value );
}
Unlock();
}
// -------------------------------------------------------------------------------- //
bool guMediaCtrl::SetEqualizer( const wxArrayInt &eqbands )
{
m_EqBands = eqbands;
Lock();
int Count = m_FaderPlayBins.Count();
for( int Index = 0; Index < Count; Index++ )
{
m_FaderPlayBins[ Index ]->SetEqualizer( eqbands );
}
Unlock();
return true;
}
// -------------------------------------------------------------------------------- //
void guMediaCtrl::ResetEqualizer( void )
{
int Count = m_EqBands.Count();
for( int Index = 0; Index < Count; Index++ )
{
m_EqBands[ Index ] = 0;
}
Lock();
Count = m_FaderPlayBins.Count();
for( int Index = 0; Index < Count; Index++ )
{
m_FaderPlayBins[ Index ]->SetEqualizer( m_EqBands );
}
Unlock();
}
// -------------------------------------------------------------------------------- //
guMediaState guMediaCtrl::GetState( void )
{
guMediaState State = guMEDIASTATE_STOPPED;
Lock();
if( m_CurrentPlayBin )
{
guLogDebug( wxT( "guMediaCtrl::GetState %i" ), m_CurrentPlayBin->GetState() );
switch( m_CurrentPlayBin->GetState() )
{
case guFADERPLAYBIN_STATE_FADEOUT_PAUSE :
case guFADERPLAYBIN_STATE_PAUSED :
State = guMEDIASTATE_PAUSED;
break;
case guFADERPLAYBIN_STATE_FADEOUT :
case guFADERPLAYBIN_STATE_FADEOUT_STOP :
case guFADERPLAYBIN_STATE_FADEIN :
case guFADERPLAYBIN_STATE_PLAYING :
State = guMEDIASTATE_PLAYING;
break;
case guFADERPLAYBIN_STATE_ERROR :
State = guMEDIASTATE_ERROR;
default :
break;
}
}
Unlock();
return State;
}
// -------------------------------------------------------------------------------- //
long guMediaCtrl::Load( const wxString &uri, guFADERPLAYBIN_PLAYTYPE playtype, const int startpos )
{
guLogDebug( wxT( "guMediaCtrl::Load %i" ), playtype );
guFaderPlaybin * FaderPlaybin;
long Result = 0;
#ifdef guSHOW_DUMPFADERPLAYBINS
Lock();
DumpFaderPlayBins( m_FaderPlayBins, m_CurrentPlayBin );
Unlock();
#endif
if( IsBuffering() )
{
playtype = guFADERPLAYBIN_PLAYTYPE_REPLACE;
}
switch( playtype )
{
case guFADERPLAYBIN_PLAYTYPE_AFTER_EOS :
{
guLogDebug( wxT( "guMediaCtrl::Load guFADERPLAYBIN_PLAYTYPE_AFTER_EOS..." ) );
Lock();
if( m_CurrentPlayBin )
{
m_CurrentPlayBin->SetNextUri( uri );
m_CurrentPlayBin->SetNextId( wxGetLocalTime() );
Result = m_CurrentPlayBin->NextId();
Unlock();
return Result;
}
Unlock();
break;
}
case guFADERPLAYBIN_PLAYTYPE_REPLACE :
{
guLogDebug( wxT( "guMediaCtrl::Load Replacing the current track in the current playbin..." ) );
Lock();
if( m_CurrentPlayBin )
{
guLogDebug( wxT( "guMediaCtrl::Load Id: %li State: %i Error: %i" ), m_CurrentPlayBin->GetId(), m_CurrentPlayBin->GetState(), m_CurrentPlayBin->ErrorCode() );
//if( m_CurrentPlayBin->m_State == guFADERPLAYBIN_STATE_ERROR )
if( !m_CurrentPlayBin->IsOk() || m_IsRecording )
{
guLogDebug( wxT( "guMediaCtrl::Load The current playbin has error or recording...Removing it" ) );
m_CurrentPlayBin->m_State = guFADERPLAYBIN_STATE_PENDING_REMOVE;
m_CurrentPlayBin->DisableRecordAndStop();
ScheduleCleanUp();
}
else
{
guLogDebug( wxT( "guMediaCtrl::Load The current playbin has no error...Replacing it" ) );
m_CurrentPlayBin->m_PlayType = guFADERPLAYBIN_PLAYTYPE_REPLACE;
m_CurrentPlayBin->m_State = guFADERPLAYBIN_STATE_WAITING;
m_CurrentPlayBin->Load( uri, true, startpos );
m_CurrentPlayBin->SetBuffering( false );
m_CurrentPlayBin->SetFaderVolume( 1.0 );
Result = m_CurrentPlayBin->GetId();
Unlock();
return Result;
}
}
Unlock();
break;
}
default :
break;
}
FaderPlaybin = new guFaderPlaybin( this, uri, playtype, startpos );
if( FaderPlaybin )
{
if( FaderPlaybin->IsOk() )
{
if( gst_element_set_state( FaderPlaybin->Playbin(), GST_STATE_PAUSED ) != GST_STATE_CHANGE_FAILURE )
{
Lock();
m_FaderPlayBins.Insert( FaderPlaybin, 0 );
Unlock();
guMediaEvent event( guEVT_MEDIA_LOADED );
event.SetInt( true );
SendEvent( event );
return FaderPlaybin->GetId();
}
// else
// {
// RemovePlayBin( FaderPlaybin );
// }
}
delete FaderPlaybin;
}
return Result;
}
// -------------------------------------------------------------------------------- //
bool guMediaCtrl::Play( void )
{
guLogDebug( wxT( "wxMediaCtrl::Play" ) );
Lock();
if( !m_FaderPlayBins.Count() )
{
Unlock();
return false;
}
#ifdef guSHOW_DUMPFADERPLAYBINS
DumpFaderPlayBins( m_FaderPlayBins, m_CurrentPlayBin );
#endif
guFaderPlaybin * FaderPlaybin = m_FaderPlayBins[ 0 ];
guLogDebug( wxT( "CurrentFaderPlayBin State %i" ), FaderPlaybin->GetState() );
Unlock();
switch( FaderPlaybin->GetState() )
{
case guFADERPLAYBIN_STATE_FADEIN :
case guFADERPLAYBIN_STATE_PLAYING :
case guFADERPLAYBIN_STATE_FADEOUT :
case guFADERPLAYBIN_STATE_FADEOUT_PAUSE :
case guFADERPLAYBIN_STATE_FADEOUT_STOP :
{
FaderPlaybin->m_State = guFADERPLAYBIN_STATE_PLAYING;
// Send event of change state to Playing
guMediaEvent event( guEVT_MEDIA_CHANGED_STATE );
event.SetInt( GST_STATE_PLAYING );
SendEvent( event );
break;
}
case guFADERPLAYBIN_STATE_PAUSED :
{
Lock();
if( m_CurrentPlayBin != FaderPlaybin )
{
m_CurrentPlayBin = FaderPlaybin;
}
Unlock();
FaderPlaybin->StartFade( 0.0, 1.0, ( !m_ForceGapless && m_FadeOutTime ) ? guFADERPLAYBIN_FAST_FADER_TIME : guFADERPLAYBIN_SHORT_FADER_TIME );
FaderPlaybin->m_State = guFADERPLAYBIN_STATE_FADEIN;
FaderPlaybin->Play();
guMediaEvent event( guEVT_MEDIA_CHANGED_STATE );
event.SetInt( GST_STATE_PLAYING );
SendEvent( event );
break;
}
case guFADERPLAYBIN_STATE_WAITING :
case guFADERPLAYBIN_STATE_WAITING_EOS :
return FaderPlaybin->StartPlay();
default :
break;
}
return false;
}
// -------------------------------------------------------------------------------- //
bool guMediaCtrl::Pause( void )
{
guLogDebug( wxT( "***************************************************************************** guMediaCtrl::Pause" ) );
guFaderPlaybin * FaderPlayBin = NULL;
wxArrayPtrVoid ToFade;
bool Done = FALSE;
double FadeOutStart = 1.0f;
gint64 FadeOutTime;
Lock();
int Count = m_FaderPlayBins.Count();
if( !Count )
{
Unlock();
return true;
}
#ifdef guSHOW_DUMPFADERPLAYBINS
DumpFaderPlayBins( m_FaderPlayBins, m_CurrentPlayBin );
#endif
for( int Index = 0; Index < Count; Index++ )
{
FaderPlayBin = m_FaderPlayBins[ Index ];
switch( FaderPlayBin->m_State )
{
case guFADERPLAYBIN_STATE_WAITING :
case guFADERPLAYBIN_STATE_WAITING_EOS :
FaderPlayBin->m_State = guFADERPLAYBIN_STATE_PAUSED;
//guLogDebug( wxT( "stream %s is not yet playing, can't pause" ), FaderPlayBin->m_Uri.c_str() );
break;
case guFADERPLAYBIN_STATE_PAUSED :
case guFADERPLAYBIN_STATE_FADEOUT_PAUSE :
case guFADERPLAYBIN_STATE_FADEOUT_STOP :
//guLogDebug( wxT( "stream %s is already paused" ), FaderPlayBin->m_Uri.c_str() );
Done = true;
break;
case guFADERPLAYBIN_STATE_FADEIN :
case guFADERPLAYBIN_STATE_FADEOUT :
case guFADERPLAYBIN_STATE_PLAYING :
//guLogDebug( wxT( "pausing stream %s -> FADING_OUT_PAUSED" ), FaderPlayBin->m_Uri.c_str() );
ToFade.Insert( FaderPlayBin, 0 );
Done = true;
break;
case guFADERPLAYBIN_STATE_PENDING_REMOVE:
//guLogDebug( wxT( "stream %s is done, can't pause" ), FaderPlayBin->m_Uri.c_str() );
break;
}
// if( Done )
// break;
}
Unlock();
Count = ToFade.Count();
for( int Index = 0; Index < Count; Index++ )
{
FaderPlayBin = ( guFaderPlaybin * ) ToFade[ Index ];
FadeOutTime = ( !m_ForceGapless && m_FadeOutTime ) ? guFADERPLAYBIN_FAST_FADER_TIME : guFADERPLAYBIN_SHORT_FADER_TIME;
switch( FaderPlayBin->m_State )
{
case guFADERPLAYBIN_STATE_FADEOUT :
case guFADERPLAYBIN_STATE_FADEIN :
FadeOutStart = FaderPlayBin->GetFaderVolume();
FadeOutTime = ( gint64 ) ( ( ( double ) guFADERPLAYBIN_FAST_FADER_TIME ) * FadeOutStart );
//guLogDebug( wxT( "============== Fading Out a Fading In playbin =================" ) );
case guFADERPLAYBIN_STATE_PLAYING:
{
FaderPlayBin->m_State = guFADERPLAYBIN_STATE_FADEOUT_PAUSE;
FaderPlayBin->StartFade( FadeOutStart, 0.0f, FadeOutTime );
}
default:
// shouldn't happen, but ignore it if it does
break;
}
}
if( !Done )
guLogMessage( wxT( "couldn't find a stream to pause" ) );
#ifdef guSHOW_DUMPFADERPLAYBINS
Lock();
DumpFaderPlayBins( m_FaderPlayBins, m_CurrentPlayBin );
Unlock();
#endif
return Done;
}
// -------------------------------------------------------------------------------- //
bool guMediaCtrl::Stop( void )
{
guLogDebug( wxT( "***************************************************************************** guMediaCtrl::Stop" ) );
guFaderPlaybin * FaderPlayBin = NULL;
wxArrayPtrVoid ToFade;
bool Done = FALSE;
double FadeOutStart = 1.0f;
gint64 FadeOutTime;
Lock();
int Count = m_FaderPlayBins.Count();
if( !Count )
{
Unlock();
return true;
}
#ifdef guSHOW_DUMPFADERPLAYBINS
DumpFaderPlayBins( m_FaderPlayBins, m_CurrentPlayBin );
#endif
for( int Index = 0; Index < Count; Index++ )
{
FaderPlayBin = m_FaderPlayBins[ Index ];
switch( FaderPlayBin->m_State )
{
case guFADERPLAYBIN_STATE_WAITING :
case guFADERPLAYBIN_STATE_WAITING_EOS :
FaderPlayBin->m_State = guFADERPLAYBIN_STATE_PENDING_REMOVE;
Unlock();
ScheduleCleanUp();
Lock();
//guLogDebug( wxT( "stream %s is not yet playing, can't pause" ), FaderPlayBin->m_Uri.c_str() );
break;
case guFADERPLAYBIN_STATE_PAUSED :
case guFADERPLAYBIN_STATE_FADEOUT_PAUSE :
case guFADERPLAYBIN_STATE_FADEOUT_STOP :
//guLogDebug( wxT( "stream %s is already paused" ), FaderPlayBin->m_Uri.c_str() );
FaderPlayBin->m_State = guFADERPLAYBIN_STATE_PENDING_REMOVE;
Unlock();
ScheduleCleanUp();
Lock();
break;
case guFADERPLAYBIN_STATE_FADEIN :
case guFADERPLAYBIN_STATE_FADEOUT :
case guFADERPLAYBIN_STATE_PLAYING :
//guLogDebug( wxT( "pausing stream %s -> FADING_OUT_PAUSED" ), FaderPlayBin->m_Uri.c_str() );
ToFade.Insert( FaderPlayBin, 0 );
Done = true;
break;
case guFADERPLAYBIN_STATE_PENDING_REMOVE:
//guLogDebug( wxT( "stream %s is done, can't pause" ), FaderPlayBin->m_Uri.c_str() );
break;
}
// if( Done )
// break;
}
Unlock();
Count = ToFade.Count();
for( int Index = 0; Index < Count; Index++ )
{
FaderPlayBin = ( guFaderPlaybin * ) ToFade[ Index ];
FadeOutTime = ( !m_ForceGapless && m_FadeOutTime ) ? guFADERPLAYBIN_FAST_FADER_TIME : guFADERPLAYBIN_SHORT_FADER_TIME;
switch( FaderPlayBin->m_State )
{
case guFADERPLAYBIN_STATE_FADEOUT :
case guFADERPLAYBIN_STATE_FADEIN :
FadeOutStart = FaderPlayBin->GetFaderVolume();
FadeOutTime = ( gint64 ) ( ( ( double ) guFADERPLAYBIN_FAST_FADER_TIME ) * FadeOutStart );
//guLogDebug( wxT( "============== Fading Out a Fading In playbin =================" ) );
case guFADERPLAYBIN_STATE_PLAYING:
{
if( IsBuffering() )
{
FaderPlayBin->m_State = guFADERPLAYBIN_STATE_PENDING_REMOVE;
ScheduleCleanUp();
guMediaEvent BufEvent( guEVT_MEDIA_BUFFERING );
BufEvent.SetInt( 100 );
SendEvent( BufEvent );
guMediaEvent event( guEVT_MEDIA_FADEOUT_FINISHED );
SendEvent( event );
FaderPlayBin->SetBuffering( false );
}
else
{
FaderPlayBin->m_State = guFADERPLAYBIN_STATE_FADEOUT_STOP;
FaderPlayBin->StartFade( FadeOutStart, 0.0f, FadeOutTime );
}
}
default:
// shouldn't happen, but ignore it if it does
break;
}
}
if( !Done )
{
guMediaEvent event( guEVT_MEDIA_CHANGED_STATE );
event.SetInt( GST_STATE_READY );
SendEvent( event );
guLogMessage( wxT( "couldn't find a stream to pause" ) );
}
#ifdef guSHOW_DUMPFADERPLAYBINS
Lock();
DumpFaderPlayBins( m_FaderPlayBins, m_CurrentPlayBin );
Unlock();
#endif
return Done;
}
// -------------------------------------------------------------------------------- //
bool guMediaCtrl::Seek( wxFileOffset where, const bool accurate )
{
guLogDebug( wxT( "guMediaCtrl::Seek( %lli )" ), where );
bool Result = false;
Lock();
if( m_CurrentPlayBin )
{
Result = m_CurrentPlayBin->Seek( where, accurate );
}
Unlock();
return Result;
}
// -------------------------------------------------------------------------------- //
void guMediaCtrl::UpdatedConfig( void )
{
guConfig * Config = ( guConfig * ) guConfig::Get();
//m_ForceGapless = Config->ReadBool( CONFIG_KEY_CROSSFADER_FORCE_GAPLESS, false, CONFIG_PATH_CROSSFADER );
m_FadeOutTime = Config->ReadNum( CONFIG_KEY_CROSSFADER_FADEOUT_TIME, 50, CONFIG_PATH_CROSSFADER ) * 100;
m_FadeInTime = Config->ReadNum( CONFIG_KEY_CROSSFADER_FADEIN_TIME, 10, CONFIG_PATH_CROSSFADER ) * 100;
m_FadeInVolStart = double( Config->ReadNum( CONFIG_KEY_CROSSFADER_FADEIN_VOL_START, 80, CONFIG_PATH_CROSSFADER ) ) / 100.0;
m_FadeInVolTriger = double( Config->ReadNum( CONFIG_KEY_CROSSFADER_FADEIN_VOL_TRIGER, 50, CONFIG_PATH_CROSSFADER ) ) / 100.0;
m_BufferSize = Config->ReadNum( CONFIG_KEY_GENERAL_BUFFER_SIZE, 64, CONFIG_PATH_GENERAL );
m_EnableEq = Config->ReadBool( CONFIG_KEY_GENERAL_EQ_ENABLED, true, CONFIG_PATH_GENERAL );
m_EnableVolCtls = Config->ReadBool( CONFIG_KEY_GENERAL_VOLUME_ENABLED, true, CONFIG_PATH_GENERAL );
m_ReplayGainMode = Config->ReadNum( CONFIG_KEY_GENERAL_REPLAY_GAIN_MODE, 0, CONFIG_PATH_GENERAL );
m_ReplayGainPreAmp = double( Config->ReadNum( CONFIG_KEY_GENERAL_REPLAY_GAIN_PREAMP, 6, CONFIG_PATH_GENERAL ) );
m_OutputDevice = Config->ReadNum( CONFIG_KEY_PLAYBACK_OUTPUT_DEVICE, guOUTPUT_DEVICE_AUTOMATIC, CONFIG_PATH_PLAYBACK );
m_OutputDeviceName = Config->ReadStr( CONFIG_KEY_PLAYBACK_OUTPUT_DEVICE_NAME, wxEmptyString, CONFIG_PATH_PLAYBACK );
m_ProxyEnabled = Config->ReadBool( CONFIG_KEY_PROXY_ENABLED, false, CONFIG_PATH_PROXY );
m_ProxyHost = Config->ReadStr( CONFIG_KEY_PROXY_HOSTNAME, wxEmptyString, CONFIG_PATH_PROXY );
m_ProxyPort = Config->ReadNum( CONFIG_KEY_PROXY_PORT, 8080, CONFIG_PATH_PROXY );
m_ProxyUser = Config->ReadStr( CONFIG_KEY_PROXY_USERNAME, wxEmptyString, CONFIG_PATH_PROXY );
m_ProxyPass = Config->ReadStr( CONFIG_KEY_PROXY_PASSWORD, wxEmptyString, CONFIG_PATH_PROXY );
m_ProxyServer = wxString::Format( wxT( "%s:%d" ), m_ProxyHost, m_ProxyPort );
ReconfigureRG();
guMediaEvent e( guEVT_PIPELINE_CHANGED );
e.SetClientData( NULL );
SendEvent( e ); // returns in ::RefreshPlaybackItems
}
// -------------------------------------------------------------------------------- //
void guMediaCtrl::ScheduleCleanUp( void )
{
//Lock();
if( !m_CleanUpId )
{
m_CleanUpId = g_timeout_add( 4000, GSourceFunc( cleanup_mediactrl ), this );
}
//Unlock();
}
// -------------------------------------------------------------------------------- //
void guMediaCtrl::FadeInStart( void )
{
guLogDebug( wxT( "guMediaCtrl::FadeInStart" ) );
Lock();
#ifdef guSHOW_DUMPFADERPLAYBINS
DumpFaderPlayBins( m_FaderPlayBins, m_CurrentPlayBin );
#endif
int Count = m_FaderPlayBins.Count();
for( int Index = 0; Index < Count; Index++ )
{
guFaderPlaybin * NextPlayBin = m_FaderPlayBins[ Index ];
if( NextPlayBin->m_State == guFADERPLAYBIN_STATE_WAITING )
{
guLogDebug( wxT( "got fade-in-start for stream %s -> FADE_IN" ), NextPlayBin->m_Uri.c_str() );
NextPlayBin->StartFade( m_FadeInVolStart, 1.0, m_FadeInTime );
NextPlayBin->m_State = guFADERPLAYBIN_STATE_FADEIN;
NextPlayBin->Play();
guMediaEvent event( guEVT_MEDIA_CHANGED_STATE );
event.SetInt( GST_STATE_PLAYING );
SendEvent( event );
guMediaEvent event2( guEVT_MEDIA_FADEIN_STARTED );
event2.SetExtraLong( NextPlayBin->GetId() );
SendEvent( event2 );
m_CurrentPlayBin = NextPlayBin;
break;
}
}
Unlock();
}
// -------------------------------------------------------------------------------- //
void guMediaCtrl::FadeOutDone( guFaderPlaybin * faderplaybin )
{
guLogDebug( wxT( "guMediaCtrl:FadeOutDone" ) );
switch( faderplaybin->m_State )
{
case guFADERPLAYBIN_STATE_FADEOUT :
{
faderplaybin->m_State = guFADERPLAYBIN_STATE_PENDING_REMOVE;
ScheduleCleanUp();
guMediaEvent event( guEVT_MEDIA_FADEOUT_FINISHED );
event.SetExtraLong( faderplaybin->GetId() );
SendEvent( event );
break;
}
case guFADERPLAYBIN_STATE_FADEOUT_PAUSE:
{
// try to seek back a bit to account for the fade
gint64 Pos = Position();
if( Pos != -1 )
{
faderplaybin->m_PausePosition = Pos > guFADERPLAYBIN_FAST_FADER_TIME ? Pos - guFADERPLAYBIN_FAST_FADER_TIME : guFADERPLAYBIN_SHORT_FADER_TIME;
guLogDebug( wxT( "got fade-out-done for stream %s -> SEEKING_PAUSED [%" G_GINT64_FORMAT "]" ), faderplaybin->m_Uri.c_str(), faderplaybin->m_Id );
}
else
{
faderplaybin->m_PausePosition = wxNOT_FOUND;
guLogDebug( wxT( "got fade-out-done for stream %s -> PAUSED (position query failed)" ), faderplaybin->m_Uri.c_str() );
}
faderplaybin->m_State = guFADERPLAYBIN_STATE_PAUSED;
faderplaybin->Pause();
guMediaEvent event( guEVT_MEDIA_CHANGED_STATE );
event.SetInt( GST_STATE_PAUSED );
SendEvent( event );
break;
}
case guFADERPLAYBIN_STATE_FADEOUT_STOP :
{
faderplaybin->m_PausePosition = 0;
faderplaybin->m_State = guFADERPLAYBIN_STATE_STOPPED;
faderplaybin->Stop();
guMediaEvent event( guEVT_MEDIA_CHANGED_STATE );
event.SetInt( GST_STATE_READY );
SendEvent( event );
break;
}
}
}
// -------------------------------------------------------------------------------- //
bool guMediaCtrl::EnableRecord( const wxString &recfile, const int format, const int quality )
{
guLogDebug( wxT( "guMediaCtrl::EnableRecord" ) );
Lock();
m_IsRecording = ( m_CurrentPlayBin && m_CurrentPlayBin->EnableRecord( recfile, format, quality ) );
Unlock();
return m_IsRecording;
}
// -------------------------------------------------------------------------------- //
void guMediaCtrl::DisableRecord( void )
{
guLogDebug( wxT( "guMediaCtrl::DisableRecord" ) );
m_IsRecording = false;
Lock();
if( m_CurrentPlayBin )
{
m_CurrentPlayBin->DisableRecord();
}
Unlock();
}
// -------------------------------------------------------------------------------- //
bool guMediaCtrl::SetRecordFileName( const wxString &filename )
{
guLogDebug( "guMediaCtrl::SetRecordFileName '%s'", filename );
Lock();
bool Result = m_CurrentPlayBin && m_CurrentPlayBin->SetRecordFileName( filename );
Unlock();
return Result;
}
// -------------------------------------------------------------------------------- //
void guMediaCtrl::DoCleanUp( void )
{
guLogDebug( wxT( "guMediaCtrl::DoCleanUp" ) );
wxArrayPtrVoid ToDelete;
Lock();
#ifdef guSHOW_DUMPFADERPLAYBINS
DumpFaderPlayBins( m_FaderPlayBins, m_CurrentPlayBin );
#endif
m_CleanUpId = 0;
int Count = m_FaderPlayBins.Count();
for( int Index = Count - 1; Index >= 0; Index-- )
{
guFaderPlaybin * FaderPlaybin = m_FaderPlayBins[ Index ];
if( ( FaderPlaybin->m_State == guFADERPLAYBIN_STATE_PENDING_REMOVE ) ||
( FaderPlaybin->m_State == guFADERPLAYBIN_STATE_ERROR ) )
{
ToDelete.Add( FaderPlaybin );
m_FaderPlayBins.RemoveAt( Index );
if( FaderPlaybin == m_CurrentPlayBin )
{
m_CurrentPlayBin = NULL;
}
}
}
if( !m_FaderPlayBins.Count() )
{
guMediaEvent event( guEVT_MEDIA_CHANGED_STATE );
event.SetInt( GST_STATE_READY );
SendEvent( event );
}
#ifdef guSHOW_DUMPFADERPLAYBINS
DumpFaderPlayBins( m_FaderPlayBins, m_CurrentPlayBin );
#endif
Unlock();
Count = ToDelete.Count();
for( int Index = 0; Index < Count; Index++ )
{
guLogDebug( wxT( "Free stream %li" ), ( ( guFaderPlaybin * ) ToDelete[ Index ] )->GetId() );
delete ( ( guFaderPlaybin * ) ToDelete[ Index ] );
}
}
// -------------------------------------------------------------------------------- //
bool guMediaCtrl::Init()
{
// Code taken from wxMediaCtrl class
//Convert arguments to unicode if enabled
#if wxUSE_UNICODE
int i;
char * * argvGST = new char * [ wxTheApp->argc + 1 ];
for( i = 0; i < wxTheApp->argc; i++ )
{
argvGST[ i ] = wxStrdup( wxTheApp->argv[ i ].char_str() );
}
argvGST[ wxTheApp->argc ] = NULL;
int argcGST = wxTheApp->argc;
#else
#define argcGST wxTheApp->argc
#define argvGST wxTheApp->argv
#endif
//Really init gstreamer
gboolean bInited;
GError * error = NULL;
bInited = gst_init_check( &argcGST, &argvGST, &error );
// Cleanup arguments for unicode case
#if wxUSE_UNICODE
for( i = 0; i < argcGST; i++ )
{
free( argvGST[ i ] );
}
delete [] argvGST;
#endif
return bInited;
}
// -------------------------------------------------------------------------------- //
bool guMediaCtrl::ProxyEnabled() const
{
return m_ProxyEnabled;
}
// -------------------------------------------------------------------------------- //
wxString guMediaCtrl::ProxyHost() const
{
return m_ProxyHost;
}
// -------------------------------------------------------------------------------- //
int guMediaCtrl::ProxyPort() const
{
return m_ProxyPort;
}
// -------------------------------------------------------------------------------- //
wxString guMediaCtrl::ProxyUser() const
{
return m_ProxyUser;
}
// -------------------------------------------------------------------------------- //
wxString guMediaCtrl::ProxyPass() const
{
return m_ProxyPass;
}
// -------------------------------------------------------------------------------- //
wxString guMediaCtrl::ProxyServer() const
{
return m_ProxyServer;
}
// -------------------------------------------------------------------------------- //
void guMediaCtrl::ToggleEqualizer()
{
guLogDebug("guMediaCtrl::ToggleEqualizer <<" );
Lock();
int Count = m_FaderPlayBins.Count();
for( int Index = 0; Index < Count; Index++ )
{
guFaderPlaybin * FaderPlaybin = m_FaderPlayBins[ Index ];
if( FaderPlaybin->IsOk() )
FaderPlaybin->ToggleEqualizer();
}
m_EnableEq = !m_EnableEq;
Unlock();
}
// -------------------------------------------------------------------------------- //
void guMediaCtrl::ToggleVolCtl()
{
guLogDebug("guMediaCtrl::ToggleVolCtl <<" );
Lock();
int Count = m_FaderPlayBins.Count();
for( int Index = 0; Index < Count; Index++ )
{
guFaderPlaybin * FaderPlaybin = m_FaderPlayBins[ Index ];
if( FaderPlaybin->IsOk() )
FaderPlaybin->ToggleVolCtl();
}
m_EnableVolCtls = !m_EnableVolCtls;
guConfig * Config = ( guConfig * ) guConfig::Get();
m_ForceGapless = m_EnableVolCtls ? Config->ReadBool( CONFIG_KEY_CROSSFADER_FORCE_GAPLESS, false, CONFIG_PATH_CROSSFADER ) : true;
Unlock();
}
// -------------------------------------------------------------------------------- //
void guMediaCtrl::ReconfigureRG()
{
guLogDebug("guMediaCtrl::ReconfigureRG <<" );
Lock();
int Count = m_FaderPlayBins.Count();
for( int Index = 0; Index < Count; Index++ )
{
guFaderPlaybin * FaderPlaybin = m_FaderPlayBins[ Index ];
if( FaderPlaybin->IsOk() )
FaderPlaybin->ReconfigureRG();
}
Unlock();
}
// -------------------------------------------------------------------------------- //
bool guMediaCtrl::IsRecording( void )
{
if( m_CurrentPlayBin )
m_IsRecording = m_CurrentPlayBin->IsRecording();
return m_IsRecording;
}
}
// -------------------------------------------------------------------------------- //
| 36,311
|
C++
|
.cpp
| 953
| 31.097587
| 175
| 0.536493
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
750,669
|
GstTypeFinder.cpp
|
anonbeat_guayadeque/src/audio/GstTypeFinder.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "GstTypeFinder.h"
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
// guMediaFileExtensions
// -------------------------------------------------------------------------------- //
guMediaFileExtensions::guMediaFileExtensions() : guMediaFileExtensionsHashMap()
{
// do nothing
}
// -------------------------------------------------------------------------------- //
void guMediaFileExtensions::join(guMediaFileExtensions what)
{
guMediaFileExtensions::iterator it;
for( it = what.begin(); it != what.end(); ++it )
{
wxString key = it->first;
wxArrayString arr = it->second;
wxArrayString * myptr = &( this->operator[]( key ) );
for( size_t i=0; i<arr.Count(); i++ )
{
wxString larri = arr[i].Lower();
if( myptr->Index( larri ) == wxNOT_FOUND )
myptr->Add( larri );
}
}
}
// -------------------------------------------------------------------------------- //
// guGstTypeFinder
// -------------------------------------------------------------------------------- //
guGstTypeFinder::guGstTypeFinder()
{
FetchMedia();
}
// -------------------------------------------------------------------------------- //
bool guGstTypeFinder::FetchMedia( void )
{
if( READY )
return true;
if( !gst_is_initialized() )
return false;
m_MediaMutex.Lock();
GList *iter, *plugin_features = gst_registry_get_feature_list(
gst_registry_get(),
GST_TYPE_TYPE_FIND_FACTORY );
for( iter=plugin_features; iter != NULL; iter=iter->next )
{
if( iter->data != NULL )
{
GstPluginFeature *p_feature = GST_PLUGIN_FEATURE( iter->data );
GstTypeFindFactory *factory;
const gchar *const *extensions;
factory = GST_TYPE_FIND_FACTORY( p_feature );
wxArrayString t_value;
extensions = gst_type_find_factory_get_extensions( factory );
if( extensions != NULL )
for( guint i = 0; extensions[i]; i++ )
{
wxString ext = extensions[i];
t_value.Add( ext.Lower() );
}
wxString t_name = gst_plugin_feature_get_name( p_feature );
m_Media[ t_name.Lower() ] = t_value;
}
}
gst_plugin_feature_list_free(plugin_features);
READY = !m_Media.empty();
if( READY )
InitMediaTypes();
m_MediaMutex.Unlock();
return READY;
}
// -------------------------------------------------------------------------------- //
guMediaFileExtensions guGstTypeFinder::GetMediaByPrefix( const wxString& media_type_prefix )
{
FetchMedia();
guMediaFileExtensions res;
guMediaFileExtensions::iterator it;
for( it = m_Media.begin(); it != m_Media.end(); ++it )
{
wxString key = it->first;
if( media_type_prefix.IsNull() || key.StartsWith( media_type_prefix ) )
res[key] = it->second;
}
return res;
}
// -------------------------------------------------------------------------------- //
guMediaFileExtensions guGstTypeFinder::GetMedia( void )
{
guMediaFileExtensions res;
for( size_t i = 0; i<m_MediaTypePrefixes.Count(); ++i )
res.join( GetMediaByPrefix( m_MediaTypePrefixes[i] ) );
return res;
}
// -------------------------------------------------------------------------------- //
wxArrayString guGstTypeFinder::GetMediaTypes( void )
{
wxArrayString res;
for( size_t i = 0; i<m_MediaTypePrefixes.Count(); ++i )
{
wxArrayString sub = GetMediaTypesByPrefix(m_MediaTypePrefixes[i]);
for( size_t j = 0; j<sub.Count(); ++j )
res.Add(sub[j]);
}
return res;
}
// -------------------------------------------------------------------------------- //
wxArrayString guGstTypeFinder::GetMediaTypesByPrefix( const wxString &media_type_prefix )
{
wxArrayString res;
guMediaFileExtensions med = GetMediaByPrefix(media_type_prefix);
guMediaFileExtensions::iterator it;
for( it = med.begin(); it != med.end(); ++it )
res.Add(it->first);
return res;
}
// -------------------------------------------------------------------------------- //
wxArrayString guGstTypeFinder::GetExtensions( void )
{
wxArrayString res;
for( size_t i = 0; i<m_MediaTypePrefixes.Count(); ++i )
{
wxArrayString sub = GetExtensionsByPrefix(m_MediaTypePrefixes[i]);
for( size_t j = 0; j<sub.Count(); ++j )
res.Add(sub[j]);
}
return res;
}
// -------------------------------------------------------------------------------- //
wxArrayString guGstTypeFinder::GetExtensionsByPrefix( const wxString &media_type_prefix )
{
FetchMedia();
wxArrayString res;
guMediaFileExtensions med = GetMediaByPrefix(media_type_prefix);
guMediaFileExtensions::iterator it;
for( it = med.begin(); it != med.end(); ++it )
{
wxArrayString arr = it->second;
for( size_t i = 0; i<arr.Count(); i++)
res.Add(arr[i]);
}
return res;
}
// -------------------------------------------------------------------------------- //
void guGstTypeFinder::AddMediaTypePrefix( const wxString &media_type_prefix )
{
if( m_MediaTypePrefixes.Index( media_type_prefix ) == wxNOT_FOUND )
m_MediaTypePrefixes.Add(media_type_prefix);
}
// -------------------------------------------------------------------------------- //
bool guGstTypeFinder::HasPrefixes( void )
{
return m_MediaTypePrefixes.Count() > 0;
}
void guGstTypeFinder::AddMediaExtension( const wxString &media_type, const wxString &extension )
{
AddMediaTypePrefix(media_type);
if( m_Media.count( media_type ) )
m_Media[ media_type ].Add( extension );
else
{
wxArrayString addme;
addme.Add(extension);
m_Media[ media_type ] = addme;
}
}
void guGstTypeFinder::InitMediaTypes( void )
{
// supported media types
//
AddMediaTypePrefix( "audio/" ); // all gstreamer audio
AddMediaTypePrefix( "video/" ); // all gstreamer video
AddMediaTypePrefix( "avtype_" ); // additional gstreamer formats from libav
AddMediaTypePrefix( "application/mxf" ); // Material Exchange Format
AddMediaTypePrefix( "application/ogg" ); // OGG formats
AddMediaTypePrefix( "application/sdp" ); // SDP mediastream file
AddMediaTypePrefix( "application/smil" ); // Synchronized Multimedia Integration Language
AddMediaTypePrefix( "application/vnd.rn-realmedia" ); // RealMedia
AddMediaTypePrefix( "application/x-pn-realaudio" ); // RealAudio
AddMediaTypePrefix( "application/x-3gp" ); // 3GP video
AddMediaTypePrefix( "application/x-ape" ); // APE
AddMediaTypePrefix( "application/x-hls" ); // UTF8 M3U
AddMediaTypePrefix( "application/x-ogm-audio" ); // sounds like something with sound :)
AddMediaTypePrefix( "application/x-yuv4mpeg" ); // sounds like something with sound :)
// some gstreamer supported formats (DSD & exotic tracker audio)
// are not listed as GST_TYPE_FIND_FACTORY for some reason
// but those are tested to work with gstreamer-libav 1.16.2
//
AddMediaExtension( "application/x-gst-av-dsf", "dsf" ); // DSD
AddMediaExtension( "application/x-gst-av-iff", "maud" ); // Amiga MAUD audio format
AddMediaExtension( "audio/x-ay", "emul" ); // AY Emul
AddMediaExtension( "audio/x-mod", "mmd1" ); // OctaMED MMD1
AddMediaExtension( "audio/x-mod", "mptm" ); // OpenMPT
AddMediaExtension( "audio/x-mod", "okta" ); // Oktalyzer
AddMediaExtension( "audio/x-sid", "psid" ); // PlaySID
AddMediaExtension( "audio/x-svx", "8svx" ); // 8-Bit Sampled Voice
AddMediaExtension( "audio/x-vgm", "vgz" ); // Video Game Music - Sega Megadrive (somtimes only after gunzip)
}
}
// the end :)
| 8,960
|
C++
|
.cpp
| 220
| 35.618182
| 113
| 0.553399
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,670
|
GstUtils.cpp
|
anonbeat_guayadeque/src/audio/GstUtils.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "GstUtils.h"
namespace Guayadeque {
//
// debugging routines
//
#ifdef GU_DEBUG
// log pad info
void guLogGstPadData(const char * msg, GstPad *pad)
{
if( pad != NULL )
guLogDebug( "%s name=%s parent=%s",
msg,
GST_OBJECT_NAME(pad),
GST_ELEMENT_NAME(GST_OBJECT_PARENT(pad))
);
else
guLogDebug( "%s pad is null", msg );
}
#endif
// GU_DEBUG
//
// get actual peer of the pad avoiding proxy pads
//
GstPad * guGetPeerPad( GstPad * pad )
{
guLogGstPadData( "guGetPeerPad <<", pad );
if ( !pad )
return NULL;
GstPad *peer = gst_pad_get_peer( pad );
guLogGstPadData( "guGetPeerPad peer", peer );
while( peer !=NULL && GST_IS_PROXY_PAD( peer ) )
{
GstPad *next_pad;
if( GST_IS_GHOST_PAD( peer ) )
{
next_pad = gst_ghost_pad_get_target( GST_GHOST_PAD( peer ) );
guLogGstPadData( "guGetPeerPad ghost pad target", next_pad );
}
else
{
GstPad * opp = GST_PAD( gst_proxy_pad_get_internal( GST_PROXY_PAD( peer ) ) );
guLogGstPadData( "guGetPeerPad proxy pad peer", opp );
next_pad = gst_pad_get_peer( opp );
gst_object_unref( opp );
}
gst_object_unref( peer );
peer = next_pad;
}
guLogGstPadData( "guGetPeerPad >>", peer );
return peer;
}
//
// check if any of element pads is linked to another element
//
bool guIsGstElementLinked( GstElement *element )
{
if( element == NULL || !GST_IS_ELEMENT(element) )
{
guLogDebug( "guIsGstElementLinked << bad element %p", element );
return false;
}
else
guLogDebug( "guIsGstElementLinked << %s", GST_ELEMENT_NAME(element) );
bool pads_connected = false;
gst_element_foreach_pad( element,
[](GstElement *e, GstPad *p, gpointer d)
{
bool *pads_connected = (bool *)d;
GstPad *peer = guGetPeerPad(p);
guLogGstPadData( "guIsGstElementLinked peer", peer );
if( peer != NULL )
{
if( GST_OBJECT_PARENT(peer) != NULL )
*pads_connected = true;
gst_object_unref( peer );
}
return 1;
}, &pads_connected);
guLogDebug( "guIsGstElementLinked >> %i", pads_connected );
return pads_connected;
}
//
// set element state to NULL if unlinked
//
bool guGstStateToNullIfUnlinked( GstElement *element )
{
if( element == NULL )
return false;
if( guIsGstElementLinked( element ) )
{
guLogDebug( "guGstStateToNullIfUnlinked: element is linked" );
return false;
}
else
{
guLogDebug( "guGstStateToNullIfUnlinked: setting state" );
if( GST_IS_ELEMENT( GST_OBJECT_PARENT( element ) ) )
{
gst_object_ref( element );
if( !gst_bin_remove( GST_BIN( GST_OBJECT_PARENT( element ) ), element ) )
{
guLogDebug( "guGstStateToNullIfUnlinked gst_bin_remove fail" );
gst_object_unref( element );
return false;
}
}
return gst_element_set_state( element, GST_STATE_NULL ) == GST_STATE_CHANGE_SUCCESS;
}
}
//
// set element state to NULL and unref
//
bool guGstStateToNullAndUnref( GstElement *element )
{
if( element == NULL || !GST_IS_ELEMENT( element ) )
return true;
if( GST_IS_ELEMENT( GST_OBJECT_PARENT( element ) ) )
{
gst_object_ref( element );
if( !gst_bin_remove( GST_BIN( GST_OBJECT_PARENT( element ) ), element ) )
{
guLogTrace( "Failed to remove element <%s> from the bin", GST_ELEMENT_NAME( element ) );
gst_object_unref( element );
}
}
bool res = gst_element_set_state( element, GST_STATE_NULL ) == GST_STATE_CHANGE_SUCCESS;
gst_object_unref( element );
return res;
}
} // namespace Guayadeque
| 5,021
|
C++
|
.cpp
| 151
| 27.10596
| 100
| 0.587544
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,671
|
MediaEvent.cpp
|
anonbeat_guayadeque/src/audio/MediaEvent.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "MediaEvent.h"
namespace Guayadeque {
wxIMPLEMENT_DYNAMIC_CLASS( guMediaEvent, wxEvent );
wxDEFINE_EVENT( guEVT_MEDIA_LOADED, guMediaEvent );
wxDEFINE_EVENT( guEVT_MEDIA_FINISHED, guMediaEvent );
wxDEFINE_EVENT( guEVT_MEDIA_CHANGED_STATE, guMediaEvent );
wxDEFINE_EVENT( guEVT_MEDIA_BUFFERING, guMediaEvent );
wxDEFINE_EVENT( guEVT_MEDIA_LEVELINFO, guMediaEvent );
wxDEFINE_EVENT( guEVT_MEDIA_TAGINFO, guMediaEvent );
wxDEFINE_EVENT( guEVT_MEDIA_CHANGED_BITRATE, guMediaEvent );
wxDEFINE_EVENT( guEVT_MEDIA_CHANGED_CODEC, guMediaEvent );
wxDEFINE_EVENT( guEVT_MEDIA_CHANGED_POSITION, guMediaEvent );
wxDEFINE_EVENT( guEVT_MEDIA_CHANGED_LENGTH, guMediaEvent );
wxDEFINE_EVENT( guEVT_MEDIA_FADEOUT_FINISHED, guMediaEvent );
wxDEFINE_EVENT( guEVT_MEDIA_FADEIN_STARTED, guMediaEvent );
wxDEFINE_EVENT( guEVT_PIPELINE_CHANGED, guMediaEvent );
wxDEFINE_EVENT( guEVT_MEDIA_ERROR, guMediaEvent );
}
// -------------------------------------------------------------------------------- //
| 2,107
|
C++
|
.cpp
| 40
| 51.5
| 86
| 0.646602
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,672
|
FaderPlaybin.cpp
|
anonbeat_guayadeque/src/audio/FaderPlaybin.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "FaderPlaybin.h"
#include "LevelInfo.h"
#include "MediaCtrl.h"
#include "RadioTagInfo.h"
#include "GstPipelineBuilder.h"
#include "GstPipelineActuator.h"
#include <wx/wx.h>
#include <wx/url.h>
namespace Guayadeque {
// GstPlayFlags flags from playbin2. It is the policy of GStreamer to
// not publicly expose element-specific enums. That's why this
// GstPlayFlags enum has been copied here.
typedef enum {
GST_PLAY_FLAG_VIDEO = 0x00000001,
GST_PLAY_FLAG_AUDIO = 0x00000002,
GST_PLAY_FLAG_TEXT = 0x00000004,
GST_PLAY_FLAG_VIS = 0x00000008,
GST_PLAY_FLAG_SOFT_VOLUME = 0x00000010,
GST_PLAY_FLAG_NATIVE_AUDIO = 0x00000020,
GST_PLAY_FLAG_NATIVE_VIDEO = 0x00000040,
GST_PLAY_FLAG_DOWNLOAD = 0x00000080,
GST_PLAY_FLAG_BUFFERING = 0x000000100
} GstPlayFlags;
// -------------------------------------------------------------------------------- //
extern "C" {
static char ProxyServer[ 200 ] = "";
static char ProxyUser[ 200 ] = "";
static char ProxyPass[ 200 ] = "";
// -------------------------------------------------------------------------------- //
static gboolean gst_bus_async_callback( GstBus * bus, GstMessage * message, guFaderPlaybin::WeakPtr * wpp )
{
if( wpp == NULL)
{
guLogTrace( "Gst async fail: parent fader playbin is null" );
return FALSE;
}
auto sp = wpp->lock();
if( !sp )
{
guLogTrace( "Gst async fail: parent fader playbin is gone" );
delete wpp;
return FALSE;
}
guFaderPlaybin * ctrl = (*sp);
switch( GST_MESSAGE_TYPE( message ) )
{
case GST_MESSAGE_ERROR :
{
GError * err;
//gchar * debug;
gst_message_parse_error( message, &err, NULL );
ctrl->SetState( guFADERPLAYBIN_STATE_ERROR );
guMediaCtrl * MediaCtrl = ctrl->GetPlayer();
if( MediaCtrl && ctrl->IsOk() )
{
MediaCtrl->SetLastError( err->code );
ctrl->SetErrorCode( err->code );
ctrl->SetState( guFADERPLAYBIN_STATE_ERROR );
wxString * ErrorStr = new wxString( err->message, wxConvUTF8 );
guLogError( wxT( "Gstreamer error '%s'" ), ErrorStr->c_str() );
guMediaEvent event( guEVT_MEDIA_ERROR );
event.SetClientData( ( void * ) ErrorStr );
MediaCtrl->SendEvent( event );
}
g_error_free( err );
//g_free( debug );
break;
}
case GST_MESSAGE_STATE_CHANGED:
{
GstState oldstate, newstate, pendingstate;
gst_message_parse_state_changed( message, &oldstate, &newstate, &pendingstate );
//
guLogDebug( wxT( "State changed %u -> %u (%u)" ), oldstate, newstate, pendingstate );
//// if( pendingstate == GST_STATE_VOID_PENDING )
//// {
//// wxMediaEvent event( wxEVT_MEDIA_STATECHANGED );
//// ctrl->AddPendingEvent( event );
//// }
break;
}
case GST_MESSAGE_BUFFERING :
{
gint Percent;
gst_message_parse_buffering( message, &Percent );
guLogDebug( wxT( "Buffering (%li): %i%%" ), ctrl->GetId(), Percent );
if( Percent != 100 )
{
if( !ctrl->IsBuffering() )
ctrl->Pause();
}
else
{
ctrl->Play();
}
ctrl->SetBuffering( Percent != 100 );
guMediaEvent event( guEVT_MEDIA_BUFFERING );
event.SetInt( Percent );
ctrl->SendEvent( event );
break;
}
case GST_MESSAGE_EOS :
{
#ifdef GU_DEBUG
GstElement * pb = ctrl->Playbin();
GstState st, ps;
int gsr = gst_element_get_state( pb, &st, &ps, 5*GST_SECOND);
guLogDebug("GST_MESSAGE_EOS gst_element_get_state=%i state=%i pending=%i", gsr, st, ps);
#endif
guMediaEvent event( guEVT_MEDIA_FINISHED );
event.SetExtraLong( ctrl->GetId() );
ctrl->SendEvent( event );
ctrl->SetState( guFADERPLAYBIN_STATE_PENDING_REMOVE );
ctrl->GetPlayer()->ScheduleCleanUp();
guLogDebug( wxT( "***** EOS received..." ) );
break;
}
case GST_MESSAGE_TAG :
{
// The stream discovered new tags.
GstTagList * tags;
//gchar * title = NULL;
gchar * audio_codec = NULL;
unsigned int bitrate = 0;
// Extract from the message the GstTagList.
//This generates a copy, so we must remember to free it.
gst_message_parse_tag( message, &tags );
guRadioTagInfo * RadioTagInfo = new guRadioTagInfo();
gst_tag_list_get_string( tags, GST_TAG_ORGANIZATION, &RadioTagInfo->m_Organization );
gst_tag_list_get_string( tags, GST_TAG_LOCATION, &RadioTagInfo->m_Location );
gst_tag_list_get_string( tags, GST_TAG_TITLE, &RadioTagInfo->m_Title );
gst_tag_list_get_string( tags, GST_TAG_GENRE, &RadioTagInfo->m_Genre );
//guLogMessage( wxT( "New Tag Found:\n'%s'\n'%s'\n'%s'\n'%s'" ),
// wxString( RadioTagInfo->m_Organization, wxConvUTF8 ).c_str(),
// wxString( RadioTagInfo->m_Location, wxConvUTF8 ).c_str(),
// wxString( RadioTagInfo->m_Title, wxConvUTF8 ).c_str(),
// wxString( RadioTagInfo->m_Genre, wxConvUTF8 ).c_str() );
if( RadioTagInfo->m_Organization || RadioTagInfo->m_Location ||
RadioTagInfo->m_Title || RadioTagInfo->m_Genre )
{
guMediaEvent event( guEVT_MEDIA_TAGINFO );
event.SetClientData( RadioTagInfo );
ctrl->SendEvent( event );
}
else
{
delete RadioTagInfo;
}
if( gst_tag_list_get_string( tags, GST_TAG_AUDIO_CODEC, &audio_codec ) )
{
if( audio_codec )
{
guMediaEvent event( guEVT_MEDIA_CHANGED_CODEC );
event.SetString( wxString::FromUTF8( audio_codec ) );
event.SetExtraLong( ctrl->GetId() );
ctrl->SendEvent( event );
g_free( audio_codec );
}
}
gst_tag_list_get_uint( tags, GST_TAG_BITRATE, &bitrate );
if( bitrate )
{
guMediaEvent event( guEVT_MEDIA_CHANGED_BITRATE );
event.SetInt( bitrate );
event.SetExtraLong( ctrl->GetId() );
ctrl->SendEvent( event );
}
// Free the tag list
gst_tag_list_free( tags );
break;
}
case GST_MESSAGE_ELEMENT :
{
if( ctrl == ctrl->GetPlayer()->CurrentPlayBin() )
{
const GstStructure * s = gst_message_get_structure( message );
const gchar * name = gst_structure_get_name( s );
// guLogDebug( wxT( "MESSAGE_ELEMENT %s" ), wxString( name ).c_str() );
if( !strcmp( name, "level" ) )
{
guLevelInfo * LevelInfo = new guLevelInfo();
guMediaEvent event( guEVT_MEDIA_LEVELINFO );
gint channels;
const GValue * list;
const GValue * value;
GValueArray * avalue;
// if( !gst_structure_get_clock_time( s, "endtime", &LevelInfo->m_EndTime ) )
// guLogWarning( wxT( "Could not parse endtime" ) );
//
// LevelInfo->m_EndTime /= GST_MSECOND;
// GstFormat format = GST_FORMAT_TIME;
// if( gst_element_query_position( ctrl->OutputSink(), &format, ( gint64 * ) &LevelInfo->m_OutTime ) )
// {
// LevelInfo->m_OutTime /= GST_MSECOND;
// }
////guLogDebug( wxT( "endtime: %" GST_TIME_FORMAT ", channels: %d" ), GST_TIME_ARGS( endtime ), channels );
// we can get the number of channels as the length of any of the value lists
list = gst_structure_get_value( s, "rms" );
avalue = ( GValueArray * ) g_value_get_boxed( list );
channels = avalue->n_values;
LevelInfo->m_Channels = channels;
//value = g_value_array_get_nth( avalue, 0 );
value = avalue->values;
LevelInfo->m_RMS_L = g_value_get_double( value );
if( channels > 1 )
{
//value = g_value_array_get_nth( avalue, 1 );
value = avalue->values + 1;
LevelInfo->m_RMS_R = g_value_get_double( value );
}
list = gst_structure_get_value( s, "peak" );
avalue = ( GValueArray * ) g_value_get_boxed( list );
//channels = avalue->n_values;
//value = g_value_array_get_nth( avalue, 0 );
value = avalue->values;
LevelInfo->m_Peak_L = g_value_get_double( value );
if( channels > 1 )
{
//value = g_value_array_get_nth( avalue, 1 );
value = avalue->values + 1;
LevelInfo->m_Peak_R = g_value_get_double( value );
}
list = gst_structure_get_value( s, "decay" );
avalue = ( GValueArray * ) g_value_get_boxed( list );
//value = g_value_array_get_nth( avalue, 0 );
value = avalue->values;
LevelInfo->m_Decay_L = g_value_get_double( value );
if( channels > 1 )
{
//value = g_value_array_get_nth( avalue, 1 );
value = avalue->values + 1;
LevelInfo->m_Decay_R = g_value_get_double( value );
}
// current timestamp - can be used further in the event
GstClockTime timestamp;
if( gst_structure_get_clock_time( s, "timestamp", ×tamp) )
{
// guLogDebug( "GST_MESSAGE_ELEMENT timestamp: %" GST_TIME_FORMAT, GST_TIME_ARGS(timestamp) );
LevelInfo->m_OutTime = timestamp / GST_MSECOND;
}
// //guLogDebug( wxT( " RMS: %f dB, peak: %f dB, decay: %f dB" ),
// event.m_LevelInfo.m_RMS_L,
// event.m_LevelInfo.m_Peak_L,
// event.m_LevelInfo.m_Decay_L );
// // converting from dB to normal gives us a value between 0.0 and 1.0 */
// rms = pow( 10, rms_dB / 20 );
// //guLogDebug( wxT( " normalized rms value: %f" ), rms );
event.SetClientObject( ( wxClientData * ) LevelInfo );
event.SetExtraLong( ctrl->GetId() );
ctrl->SendEvent( event );
}
}
break;
}
//
case GST_MESSAGE_APPLICATION :
{
const GstStructure * Struct;
const char * Name;
Struct = gst_message_get_structure( message );
Name = gst_structure_get_name( Struct );
// guLogDebug( wxT( "Got Application Message %s" ), GST_TO_WXSTRING( Name ).c_str() );
if( !strcmp( Name, guFADERPLAYBIN_MESSAGE_FADEIN_START ) )
{
if( !ctrl->EmittedStartFadeIn() )
{
ctrl->FadeInStart();
}
}
else if( !strcmp( Name, guFADERPLAYBIN_MESSAGE_FADEOUT_DONE ) )
{
if( !ctrl->EmittedStartFadeIn() )
{
ctrl->FadeInStart();
}
ctrl->FadeOutDone();
}
break;
}
default:
break;
}
return TRUE;
}
// -------------------------------------------------------------------------------- //
static void gst_about_to_finish( GstElement * playbin, guFaderPlaybin::WeakPtr * wpp )
{
guLogDebug( "gst_about_to_finish << %p", wpp );
if( wpp == NULL)
{
guLogTrace( "Gst about to finish: parent fader playbin is null" );
return;
}
auto sp = wpp->lock();
if( !sp )
{
guLogTrace( "Gst about to finish: parent fader playbin is gone" );
delete wpp;
return;
}
guFaderPlaybin * ctrl = (*sp);
if( !ctrl->NextUri().IsEmpty() )
{
ctrl->AboutToFinish();
}
else if( !ctrl->EmittedStartFadeIn() )
{
ctrl->FadeInStart();
}
}
// -------------------------------------------------------------------------------- //
static void gst_audio_changed( GstElement * playbin, guFaderPlaybin::WeakPtr * wpp )
{
guLogDebug( "gst_audio_changed << %p", wpp );
if( wpp == NULL)
{
guLogTrace( "gst_audio_changed: parent fader playbin is null" );
return;
}
if( auto sp = wpp->lock() )
{
(*sp)->AudioChanged();
}
else
{
guLogTrace( "gst_audio_changed: parent fader playbin is gone" );
delete wpp;
}
}
// -------------------------------------------------------------------------------- //
void gst_source_setup( GstElement * playbin, GstElement * source, guMediaCtrl * ctrl )
{
guLogDebug( "gst_source_setup" );
if( ctrl && ctrl->ProxyEnabled() )
{
if( g_object_class_find_property( G_OBJECT_GET_CLASS( source ), "proxy" ) )
{
//guLogMessage( wxT( "Found proxy property... '%s'" ), ctrl->ProxyServer().c_str() );
strncpy( ProxyServer, ctrl->ProxyServer().char_str(), sizeof( ProxyServer ) - 1 );
g_object_set( source,
"proxy", ProxyServer,
NULL );
if( !ctrl->ProxyUser().IsEmpty() )
{
strncpy( ProxyUser, ctrl->ProxyUser().char_str(), sizeof( ProxyUser ) - 1 );
strncpy( ProxyPass, ctrl->ProxyPass().char_str(), sizeof( ProxyPass ) - 1 );
g_object_set( source,
"proxy-id", ProxyUser,
"proxy-pw", ProxyPass,
NULL );
}
}
}
}
// -------------------------------------------------------------------------------- //
static bool seek_timeout( guFaderPlaybin::WeakPtr * wpp )
{
if( auto sp = wpp->lock() )
(*sp)->DoStartSeek();
else
guLogTrace( "Seek timeout fail: parent bin is gone" );
delete wpp;
return false;
}
// -------------------------------------------------------------------------------- //
static bool pause_timeout( GstElement * playbin )
{
guLogDebug("pause_timeout: GST_STATE_PAUSED");
gst_element_set_state( playbin, GST_STATE_PAUSED );
return false;
}
// -------------------------------------------------------------------------------- //
bool IsValidElement( GstElement * element )
{
if( !GST_IS_ELEMENT( element ) )
{
if( G_IS_OBJECT( element ) )
g_object_unref( element );
return false;
}
return true;
}
}
// -------------------------------------------------------------------------------- //
// guFaderPlaybin
// -------------------------------------------------------------------------------- //
guFaderPlaybin::guFaderPlaybin( guMediaCtrl * mediactrl, const wxString &uri, const int playtype, const int startpos )
{
//guLogDebug( wxT( "creating new stream for %s" ), uri.c_str() );
m_Player = mediactrl;
m_Uri = uri;
m_Id = wxGetLocalTimeMillis().GetLo();
m_State = guFADERPLAYBIN_STATE_WAITING;
m_ErrorCode = 0;
m_IsFading = false;
m_IsBuffering = false;
m_EmittedStartFadeIn = false;
m_PlayType = playtype;
m_FaderTimeLine = NULL;
m_AboutToFinishPending = false;
m_LastFadeVolume = -1;
m_StartOffset = startpos;
m_SeekTimerId = 0;
m_SettingRecordFileName = false;
m_PositionDelta = 0;
m_ReplayGain = NULL;
m_ReplayGainLimiter = NULL;
m_SharedPointer = std::make_shared<guFaderPlaybin*>( this );
m_RecordBin = NULL;
m_Valve = NULL;
guLogDebug( wxT( "guFaderPlaybin::guFaderPlaybin (%li) %i" ), m_Id, playtype );
if( BuildOutputBin() && BuildPlaybackBin() )
{
//Load( uri, false );
if( startpos )
{
m_SeekTimerId = g_timeout_add( 100, GSourceFunc( seek_timeout ), GetWeakPtr() );
}
SetVolume( m_Player->GetVolume() );
SetEqualizer( m_Player->GetEqualizer() );
}
}
// -------------------------------------------------------------------------------- //
guFaderPlaybin::~guFaderPlaybin()
{
guLogDebug( wxT( "guFaderPlaybin::~guFaderPlaybin (%li) e: %i" ), m_Id, m_ErrorCode );
if( m_RecordBin != NULL )
guGstPipelineActuator( m_RecordBin ).Disable();
//m_Player->RemovePlayBin( this );
if( m_SeekTimerId )
{
g_source_remove( m_SeekTimerId );
}
if( m_Playbin )
{
GstStateChangeReturn ChangeState = gst_element_set_state( m_Playbin, GST_STATE_NULL );
// typedef enum {
// GST_STATE_CHANGE_FAILURE = 0,
// GST_STATE_CHANGE_SUCCESS = 1,
// GST_STATE_CHANGE_ASYNC = 2,
// GST_STATE_CHANGE_NO_PREROLL = 3
// } GstSt
//guLogMessage( wxT( "Set To NULL: %i" ), ChangeState );
if( ChangeState == GST_STATE_CHANGE_ASYNC )
{
guLogDebug( "guFaderPlaybin::~guFaderPlaybin wait on GST_STATE_CHANGE_ASYNC" );
gst_element_get_state( m_Playbin, NULL, NULL, GST_SECOND );
}
// guLogDebug( "mPlaybin refcount: %i", GST_OBJECT_REFCOUNT( m_Playbin ) );
GstBus * bus = gst_pipeline_get_bus( GST_PIPELINE( m_Playbin ) );
gst_bus_remove_watch( bus );
// guLogDebug( "mPlaybin bus refcount: %i", GST_OBJECT_REFCOUNT( bus ) - 1 );
gst_object_unref( bus );
gst_object_unref( GST_OBJECT( m_Playbin ) );
guGstStateToNullAndUnref( m_FaderVolume );
guGstStateToNullAndUnref( m_Volume );
guGstStateToNullAndUnref( m_Equalizer ) ;
guGstStateToNullAndUnref( m_ReplayGain );
guGstStateToNullAndUnref( m_ReplayGainLimiter );
}
if( m_FaderTimeLine )
{
EndFade();
}
guGstStateToNullAndUnref( m_RecordBin );
guLogDebug( wxT( "Finished destroying the playbin %li" ), m_Id );
}
// -------------------------------------------------------------------------------- //
bool guFaderPlaybin::BuildOutputBin( void )
{
GstElement * outputsink;
const char * ElementNames[] = {
"autoaudiosink",
"gconfaudiosink",
"alsasink",
"pulsesink",
"osssink",
NULL
};
int OutputDevice = m_Player->OutputDevice();
if( ( OutputDevice >= guOUTPUT_DEVICE_AUTOMATIC ) && ( OutputDevice < guOUTPUT_DEVICE_OTHER ) )
{
outputsink = gst_element_factory_make( ElementNames[ OutputDevice ], "OutputSink" );
if( IsValidElement( outputsink ) )
{
if( OutputDevice > guOUTPUT_DEVICE_GCONF )
{
wxString OutputDeviceName = m_Player->OutputDeviceName();
if( !OutputDeviceName.IsEmpty() )
{
g_object_set( outputsink, "device", ( const char * ) OutputDeviceName.mb_str( wxConvFile ), NULL );
}
}
m_OutputSink = outputsink;
return true;
}
}
else if( OutputDevice == guOUTPUT_DEVICE_OTHER )
{
wxString OutputDeviceName = m_Player->OutputDeviceName();
if( !OutputDeviceName.IsEmpty() )
{
GError * err = NULL;
outputsink = gst_parse_launch( ( const char * ) OutputDeviceName.mb_str( wxConvFile ), &err );
if( outputsink )
{
if( err )
{
guLogMessage( wxT( "Error building output pipeline: '%s'" ), wxString( err->message, wxConvUTF8 ).c_str() );
g_error_free( err );
}
m_OutputSink = outputsink;
return true;
}
}
}
guLogError( wxT( "The configured audio output sink is not valid. Autoconfiguring..." ) );
int Index = 0;
while( ElementNames[ Index ] )
{
outputsink = gst_element_factory_make( ElementNames[ Index ], "OutputSink" );
if( IsValidElement( outputsink ) )
{
m_OutputSink = outputsink;
return true;
}
Index++;
}
m_OutputSink = NULL;
return false;
}
// -------------------------------------------------------------------------------- //
bool guFaderPlaybin::BuildPlaybackBin( void )
{
//
// full playback pipeline including [removable] elements:
// playbin > valve > tee > queue > audioconvert >
// [ equalizer-10bands ] > [ rgvolume > rglimiter ] >
// [ volume > fader volume ] > level > audioresample > sink
//
guGstPipelineBuilder gpb( "playbackbin", &m_Playbackbin );
gpb.Add( "playbin", "play", &m_Playbin, false,
"uri", ( const char * ) m_Uri.mb_str( wxConvFile ),
"buffer-size", gint( m_Player->BufferSize() * 1024 )
);
gpb.Add( "valve", "pb_valve", &m_Valve );
gpb.Add( "tee", "pb_tee", &m_Tee );
gpb.Add( "queue", "pb_queue", NULL, true,
"max-size-time", guint64( 250000000 ),
"max-size-buffers", 0,
"max-size-bytes", 0
);
gpb.Add( "audioconvert", "pb_audioconvert" );
// add with valve's since we want to mass-plug those & don't want be racing on pads
gpb.AddV( "equalizer-10bands", "pb_equalizer", &m_Equalizer, m_Player->m_EnableEq );
gpb.AddV( "rgvolume", "pb_rgvolume", &m_ReplayGain, m_Player->m_ReplayGainMode );
SetRGProperties();
gpb.AddV( "rglimiter", "pb_rglimiter", &m_ReplayGainLimiter, m_Player->m_ReplayGainMode );
gpb.AddV( "volume", "pb_volume", &m_Volume, m_Player->m_EnableVolCtls );
if( m_PlayType == guFADERPLAYBIN_PLAYTYPE_CROSSFADE )
gpb.Add( "volume", "fader_volume", &m_FaderVolume, m_Player->m_EnableVolCtls,
"volume", gdouble( 0.0 )
);
else
gpb.Add( "volume", "fader_volume", &m_FaderVolume, m_Player->m_EnableVolCtls );
gpb.Add( "level", "pb_level", NULL, true,
"message", gboolean( true ),
"interval", guint64( 100000000 ),
"peak-falloff", gdouble( 6.0 ),
"peak-ttl", guint64( 3 * 300000000 )
);
// gpb.Add( "audioconvert", "sink_audioconvert" );
gpb.Add( "audioresample", "sink_audioresample", NULL, true,
"quality", gint( 10 )
);
gpb.Link( m_OutputSink );
if( !gpb.CanPlay() )
return false;
guLogDebug("guFaderPlaybin::BuildPlaybackBin pipeline is built");
GstPad * pad = gst_element_get_static_pad( m_Valve, "sink" );
if( GST_IS_PAD( pad ) )
{
GstPad * ghostpad = gst_ghost_pad_new( "sink", pad );
gst_element_add_pad( m_Playbackbin, ghostpad );
gst_object_unref( pad );
g_object_set( G_OBJECT( m_Playbin ), "audio-sink", m_Playbackbin, NULL );
g_object_set( G_OBJECT( m_Playbin ), "flags", GST_PLAY_FLAG_AUDIO | GST_PLAY_FLAG_SOFT_VOLUME, NULL );
g_signal_connect( G_OBJECT( m_Playbin ), "about-to-finish",
G_CALLBACK( gst_about_to_finish ), ( void * ) GetWeakPtr() );
//
g_signal_connect( G_OBJECT( m_Playbin ), "audio-changed",
G_CALLBACK( gst_audio_changed ), ( void * ) GetWeakPtr() );
g_signal_connect( G_OBJECT( m_Playbin ), "source-setup",
G_CALLBACK( gst_source_setup ), ( void * ) m_Player );
GstBus * bus = gst_pipeline_get_bus( GST_PIPELINE( m_Playbin ) );
gst_bus_add_watch( bus, GstBusFunc( gst_bus_async_callback ), GetWeakPtr() );
gst_object_unref( bus );
gpb.SetCleanup( false );
m_PlayChain = gpb.GetChain();
return true;
}
else
{
if( G_IS_OBJECT( pad ) )
gst_object_unref( pad );
guLogError( wxT( "Could not create the pad element" ) );
}
return false;
}
// -------------------------------------------------------------------------------- //
bool guFaderPlaybin::BuildRecordBin( const wxString &path )
{
guLogDebug( wxT( "BuildRecordBin( '%s' )" ), path.c_str() );
guGstPipelineBuilder gpb( "gurb_recordbin", &m_RecordBin );
g_object_set( m_RecordBin, "async-handling", gboolean( true ), NULL );
GstElement * queue = gpb.Add( "queue", "gurb_queue", NULL, true,
"max-size-buffers", guint( 3 ),
"max-size-time", 0,
"max-size-bytes", 0
);
gpb.Add( "audioconvert", "gurb_audioconvert" );
gpb.Add( "audioresample", "gurb_audioresample" , NULL, true,
"quality", gint( 10 )
);
gpb.Link( m_Encoder );
if( m_Muxer != NULL )
gpb.Link( m_Muxer );
gpb.Add( "filesink", "gurb_filesink", &m_FileSink, true,
"location", ( const char * ) path.mb_str( wxConvFile )
);
if( !gpb.CanPlay() )
return false;
GstPad * pad = gst_element_get_static_pad( queue, "sink" );
if( GST_IS_PAD( pad ) )
{
m_RecordSinkPad = gst_ghost_pad_new( "sink", pad );
gst_element_add_pad( m_RecordBin, m_RecordSinkPad );
gst_object_unref( pad );
gpb.SetCleanup( false );
return true;
}
else
{
if( G_IS_OBJECT( pad ) )
gst_object_unref( pad );
guLogError( wxT( "Could not create the pad element" ) );
}
return false;
}
// -------------------------------------------------------------------------------- //
bool guFaderPlaybin::DoStartSeek( void )
{
guLogDebug( wxT( "DoStartSeek( %i )" ), m_StartOffset );
m_SeekTimerId = 0;
if( GST_IS_ELEMENT( m_Playbin ) )
{
return Seek( m_StartOffset, true );
}
return false;
}
// -------------------------------------------------------------------------------- //
void guFaderPlaybin::SendEvent( guMediaEvent &event )
{
m_Player->SendEvent( event );
}
// -------------------------------------------------------------------------------- //
void guFaderPlaybin::SetBuffering( const bool isbuffering )
{
if( m_IsBuffering != isbuffering )
{
m_IsBuffering = isbuffering;
if( !isbuffering )
{
if( !m_PendingNewRecordName.IsEmpty() )
{
SetRecordFileName( m_PendingNewRecordName );
}
}
}
}
// -------------------------------------------------------------------------------- //
bool guFaderPlaybin::SetVolume( double volume )
{
guLogDebug( wxT( "guFaderPlaybin::SetVolume (%li) %0.2f" ), m_Id, volume );
g_object_set( m_Volume, "volume", gdouble( wxMax( 0.0001, volume ) ), NULL );
return true;
}
// -------------------------------------------------------------------------------- //
double guFaderPlaybin::GetFaderVolume( void )
{
double RetVal;
g_object_get( m_FaderVolume, "volume", &RetVal, NULL );
return RetVal;
}
// -------------------------------------------------------------------------------- //
void guFaderPlaybin::FadeInStart( void )
{
m_EmittedStartFadeIn = true;
m_Player->FadeInStart();
}
// -------------------------------------------------------------------------------- //
void guFaderPlaybin::FadeOutDone( void )
{
m_Player->FadeOutDone( this );
}
// -------------------------------------------------------------------------------- //
bool guFaderPlaybin::SetFaderVolume( double volume )
{
const char * Message = NULL;
//guLogMessage( wxT( "Set the VolEnd: %0.2f" ), volume );
if( volume != m_LastFadeVolume )
{
//guLogDebug( wxT( "guFaderPlaybin::SetFaderVolume (%li) %0.2f %i" ), m_Id, volume, m_State == guFADERPLAYBIN_STATE_FADEIN );
Lock();
m_LastFadeVolume = volume;
g_object_set( m_FaderVolume, "volume", gdouble( volume ), NULL );
switch( m_State )
{
case guFADERPLAYBIN_STATE_FADEIN :
{
if( ( volume > 0.99 ) && m_IsFading )
{
guLogDebug( wxT( "stream fully faded in (at %f) -> PLAYING state" ), volume );
m_IsFading = false;
m_State = guFADERPLAYBIN_STATE_PLAYING;
}
break;
}
case guFADERPLAYBIN_STATE_FADEOUT :
case guFADERPLAYBIN_STATE_FADEOUT_PAUSE :
case guFADERPLAYBIN_STATE_FADEOUT_STOP :
{
if( volume < 0.001 )
{
//guLogDebug( wxT( "stream %s fully faded out (at %f)" ), faderplaybin->m_Uri.c_str(), Vol );
if( m_IsFading )
{
//Message = guFADERPLAYBIN_MESSAGE_FADEOUT_DONE;
// m_State = guFADERPLAYBIN_STATE_PENDING_REMOVE;
// guMediaEvent event( guEVT_MEDIA_FADEOUT_FINISHED );
// event.SetExtraLong( GetId() );
// SendEvent( event );
//
// m_Player->ScheduleCleanUp();
//m_Player->FadeOutDone( this );
Message = guFADERPLAYBIN_MESSAGE_FADEOUT_DONE;
//m_IsFading = false;
}
}
else if( !m_EmittedStartFadeIn && volume < ( m_Player->m_FadeInVolTriger + 0.001 ) )
{
if( m_IsFading && m_State == guFADERPLAYBIN_STATE_FADEOUT )
{
//m_EmittedStartFadeIn = true;
//m_Player->FadeInStart();
Message = guFADERPLAYBIN_MESSAGE_FADEIN_START;
}
}
break;
}
}
Unlock();
}
if( Message )
{
GstMessage * Msg;
GstStructure * Struct;
//guLogDebug( wxT( "posting %s message for stream %s" ), GST_TO_WXSTRING( Message ).c_str(), faderplaybin->m_Uri.c_str() );
Struct = gst_structure_new( Message, NULL, NULL );
Msg = gst_message_new_application( GST_OBJECT( m_Playbin ), Struct );
gst_element_post_message( GST_ELEMENT( m_Playbin ), Msg );
}
return true;
}
// -------------------------------------------------------------------------------- //
bool guFaderPlaybin::SetEqualizer( const wxArrayInt &eqbands )
{
if( m_Equalizer && ( eqbands.Count() == guEQUALIZER_BAND_COUNT ) )
{
for( int index = 0; index < guEQUALIZER_BAND_COUNT; index++ )
{
SetEqualizerBand( index, eqbands[ index ] );
}
return true;
}
return false;
}
// -------------------------------------------------------------------------------- //
void guFaderPlaybin::SetEqualizerBand( const int band, const int value )
{
if( m_Equalizer != NULL )
g_object_set( G_OBJECT( m_Equalizer ), wxString::Format( wxT( "band%u" ),
band ).char_str(), gdouble( value / 10.0 ), NULL );
}
// -------------------------------------------------------------------------------- //
bool guFaderPlaybin::Load( const wxString &uri, const bool restart, const int startpos )
{
guLogDebug( wxT( "guFaderPlaybin::Load (%li) %i" ), m_Id, restart );
DisableRecord();
if( GST_IS_ELEMENT( m_Playbin ) )
if( restart )
{
// recording data loss here => do not reuse recording bins
if( gst_element_set_state( m_Playbin, GST_STATE_READY ) == GST_STATE_CHANGE_FAILURE )
{
guLogDebug( wxT( "guFaderPlaybin::Load => Could not set state to ready..." ) );
return false;
}
gst_element_set_state( m_Playbin, GST_STATE_NULL );
}
if( !gst_uri_is_valid( ( const char * ) uri.mb_str( wxConvFile ) ) )
{
guLogDebug( wxT( "guFaderPlaybin::Load => Invalid uri: '%s'" ), uri.c_str() );
return false;
}
g_object_set( G_OBJECT( m_Playbin ), "uri", ( const char * ) uri.mb_str( wxConvFile ), NULL );
if( restart )
{
if( gst_element_set_state( m_Playbin, GST_STATE_PAUSED ) == GST_STATE_CHANGE_FAILURE )
{
guLogDebug( wxT( "guFaderPlaybin::Load => Could not restore state to paused..." ) );
return false;
}
}
m_PositionDelta = startpos - gst_clock_get_time( gst_element_get_clock( m_Playbin ) );
if( startpos )
{
m_StartOffset = startpos;
m_SeekTimerId = g_timeout_add( 100, GSourceFunc( seek_timeout ), GetWeakPtr() );
}
guMediaEvent event( guEVT_MEDIA_LOADED );
event.SetInt( restart );
SendEvent( event );
guLogDebug( wxT( "guFaderPlaybin::Load => Sent the loaded event..." ) );
return true;
}
// -------------------------------------------------------------------------------- //
bool guFaderPlaybin::Play( void )
{
guLogDebug( wxT( "guFaderPlaybin::Play (%li)" ), m_Id );
if( m_State != guFADERPLAYBIN_STATE_PENDING_REMOVE )
{
SetValveDrop( false );
return ( gst_element_set_state( m_Playbin, GST_STATE_PLAYING ) != GST_STATE_CHANGE_FAILURE );
}
else
{
return false;
}
}
// -------------------------------------------------------------------------------- //
bool guFaderPlaybin::StartPlay( void )
{
guLogMessage( wxT( "guFaderPlaybin::StartPlay (%li)" ), m_Id );
bool Ret = true;
bool NeedReap = false;
bool Playing = false;
guFaderPlayBinArray ToFade;
#ifdef guSHOW_DUMPFADERPLAYBINS
m_Player->Lock();
DumpFaderPlayBins( m_Player->m_FaderPlayBins, m_Player->m_CurrentPlayBin );
m_Player->Unlock();
#endif
switch( m_PlayType )
{
case guFADERPLAYBIN_PLAYTYPE_CROSSFADE :
{
guLogDebug( wxT( "About to start the faderplaybin in crossfade type" ) );
m_Player->Lock();
int Count = m_Player->m_FaderPlayBins.Count();
for( int Index = 0; Index < Count; Index++ )
{
guFaderPlaybin * FaderPlaybin = m_Player->m_FaderPlayBins[ Index ];
if( FaderPlaybin == this )
continue;
switch( FaderPlaybin->m_State )
{
case guFADERPLAYBIN_STATE_FADEIN :
case guFADERPLAYBIN_STATE_PLAYING :
ToFade.Add( FaderPlaybin );
break;
case guFADERPLAYBIN_STATE_ERROR :
case guFADERPLAYBIN_STATE_PAUSED :
case guFADERPLAYBIN_STATE_STOPPED :
case guFADERPLAYBIN_STATE_WAITING :
case guFADERPLAYBIN_STATE_WAITING_EOS :
FaderPlaybin->m_State = guFADERPLAYBIN_STATE_PENDING_REMOVE;
case guFADERPLAYBIN_STATE_PENDING_REMOVE :
NeedReap = true;
default :
break;
}
}
m_Player->Unlock();
Count = ToFade.Count();
for( int Index = 0; Index < Count; Index++ )
{
double FadeOutStart = 1.0;
int FadeOutTime = m_Player->m_ForceGapless ? 0 : m_Player->m_FadeOutTime;
guFaderPlaybin * FaderPlaybin = ToFade[ Index ];
switch( FaderPlaybin->m_State )
{
case guFADERPLAYBIN_STATE_FADEIN :
//g_object_get( FaderPlaybin->m_Playbin, "volume", &FadeOutStart, NULL );
FadeOutStart = FaderPlaybin->GetFaderVolume();
FadeOutTime = ( int ) ( ( ( double ) FadeOutTime ) * FadeOutStart );
case guFADERPLAYBIN_STATE_PLAYING :
FaderPlaybin->StartFade( FadeOutStart, 0.0, FadeOutTime );
FaderPlaybin->m_State = guFADERPLAYBIN_STATE_FADEOUT;
m_IsFading = true;
break;
default :
break;
}
}
if( !m_IsFading )
{
guLogDebug( wxT( "There was not previous playing track in crossfade mode so play this playbin..." ) );
SetFaderVolume( 1.0 ); //g_object_set( m_Playbin, "volume", 1.0, NULL );
if( Play() )
{
m_State = guFADERPLAYBIN_STATE_PLAYING;
m_Player->Lock();
m_Player->m_CurrentPlayBin = this;
m_Player->Unlock();
guMediaEvent event( guEVT_MEDIA_CHANGED_STATE );
event.SetInt( GST_STATE_PLAYING );
SendEvent( event );
}
}
break;
}
case guFADERPLAYBIN_PLAYTYPE_AFTER_EOS :
{
Playing = false;
m_Player->Lock();
int Count = m_Player->m_FaderPlayBins.Count();
for( int Index = 0; Index < Count; Index++ )
{
guFaderPlaybin * FaderPlaybin = m_Player->m_FaderPlayBins[ Index ];
if( FaderPlaybin == this )
continue;
switch( FaderPlaybin->m_State )
{
case guFADERPLAYBIN_STATE_PLAYING :
case guFADERPLAYBIN_STATE_FADEIN :
case guFADERPLAYBIN_STATE_FADEOUT_PAUSE :
guLogDebug( wxT( "Stream %s already playing" ), FaderPlaybin->m_Uri.c_str() );
Playing = true;
break;
case guFADERPLAYBIN_STATE_PAUSED :
guLogDebug( wxT( "stream %s is paused; replacing it" ), FaderPlaybin->m_Uri.c_str() );
FaderPlaybin->m_State = guFADERPLAYBIN_STATE_PENDING_REMOVE;
case guFADERPLAYBIN_STATE_PENDING_REMOVE :
NeedReap = true;
break;
default:
break;
}
}
m_Player->Unlock();
if( Playing )
{
m_State = guFADERPLAYBIN_STATE_WAITING_EOS;
}
else
{
if( Play() )
{
m_State = guFADERPLAYBIN_STATE_PLAYING;
m_Player->Lock();
m_Player->m_CurrentPlayBin = this;
m_Player->Unlock();
guMediaEvent event( guEVT_MEDIA_CHANGED_STATE );
event.SetInt( GST_STATE_PLAYING );
SendEvent( event );
}
}
break;
}
case guFADERPLAYBIN_PLAYTYPE_REPLACE :
{
m_Player->Lock();
int Count = m_Player->m_FaderPlayBins.Count();
for( int Index = 0; Index < Count; Index++ )
{
guFaderPlaybin * FaderPlaybin = m_Player->m_FaderPlayBins[ Index ];
if( FaderPlaybin == this )
continue;
switch( FaderPlaybin->m_State )
{
case guFADERPLAYBIN_STATE_PLAYING :
case guFADERPLAYBIN_STATE_PAUSED :
case guFADERPLAYBIN_STATE_FADEIN :
case guFADERPLAYBIN_STATE_PENDING_REMOVE :
// kill this one
guLogDebug( wxT( "stopping stream %s (replaced by new stream)" ), FaderPlaybin->m_Uri.c_str() );
FaderPlaybin->m_State = guFADERPLAYBIN_STATE_PENDING_REMOVE;
NeedReap = true;
break;
default:
break;
}
}
m_Player->Unlock();
if( Play() )
{
m_State = guFADERPLAYBIN_STATE_PLAYING;
m_Player->Lock();
m_Player->m_CurrentPlayBin = this;
m_Player->Unlock();
guMediaEvent event( guEVT_MEDIA_CHANGED_STATE );
event.SetInt( GST_STATE_PLAYING );
SendEvent( event );
}
break;
}
}
if( NeedReap )
{
m_Player->ScheduleCleanUp();
}
return Ret;
}
// -------------------------------------------------------------------------------- //
void guFaderPlaybin::AboutToFinish( void )
{
guLogDebug( wxT( "guFaderPlaybin::AboutToFinish (%li)" ), m_Id );
Load( m_NextUri, false );
m_NextUri = wxEmptyString;
m_AboutToFinishPending = true;
}
// -------------------------------------------------------------------------------- //
static bool guFaderPlaybin__AudioChanged_timeout( guFaderPlaybin::WeakPtr * wpp )
{
guLogDebug( "guFaderPlaybin__AudioChanged_timeout << %p", wpp );
if( auto sp = wpp->lock() )
{
(*sp)->ResetAboutToFinishPending();
}
else
{
guLogTrace( "Audio changed event: parent fader playbin is gone" );
}
delete wpp;
return false;
}
// -------------------------------------------------------------------------------- //
void guFaderPlaybin::AudioChanged( void )
{
guLogDebug( wxT( "guFaderPlaybin::AudioChanged (%li)" ), m_Id );
if( m_AboutToFinishPending )
{
if( m_NextId )
{
m_Id = m_NextId;
m_NextId = 0;
}
guMediaEvent event( guEVT_MEDIA_CHANGED_STATE );
event.SetInt( GST_STATE_PLAYING );
SendEvent( event );
//m_AboutToFinishPending = false;
m_AboutToFinishPendingId = g_timeout_add( 3000, GSourceFunc( guFaderPlaybin__AudioChanged_timeout ), GetWeakPtr() );
}
}
// -------------------------------------------------------------------------------- //
bool guFaderPlaybin::StartFade( double volstart, double volend, int timeout )
{
guLogDebug( wxT( "guFaderPlaybin::StartFade (%li) %0.2f, %0.2f, %i" ), m_Id, volstart, volend, timeout );
// SetFaderVolume( volstart );
m_EmittedStartFadeIn = false;
m_IsFading = true;
if( m_FaderTimeLine )
{
// guLogDebug( wxT( "Reversed the fader for %li" ), m_Id );
// m_FaderTimeLine->ToggleDirection();
EndFade();
}
m_FaderTimeLine = new guFaderTimeLine( timeout, NULL, this, volstart, volend );
m_FaderTimeLine->SetDirection( volstart > volend ? guFaderTimeLine::Backward : guFaderTimeLine::Forward );
m_FaderTimeLine->SetCurveShape( guTimeLine::EaseInOutCurve );
m_FaderTimeLine->Start();
return true;
}
// -------------------------------------------------------------------------------- //
bool guFaderPlaybin::Pause( void )
{
guLogDebug( wxT( "guFaderPlaybin::Pause (%li)" ), m_Id );
// we do not pause while recording, filesinks don't like it
if( IsRecording() )
{
guLogTrace( "Pause: can not pause while recording" );
return false;
}
else
{
guLogDebug( "guFaderPlaybin::Pause ok" );
g_timeout_add( 200, GSourceFunc( pause_timeout ), m_Playbin );
return true;
}
}
// -------------------------------------------------------------------------------- //
bool guFaderPlaybin::Stop( void )
{
guLogDebug( wxT( "guFaderPlaybin::Stop (%li)" ), m_Id );
SetValveDrop( true );
SetBuffering( false );
SetVolume( 0 );
if( m_RecordBin == NULL )
return ( gst_element_set_state( m_Playbin, GST_STATE_READY ) != GST_STATE_CHANGE_FAILURE );
else
return DisableRecordAndStop(); // async soft-stop
}
// -------------------------------------------------------------------------------- //
bool guFaderPlaybin::Seek( wxFileOffset where, bool accurate )
{
guLogDebug( wxT( "guFaderPlaybin::Seek (%li) %li )" ), m_Id, where );
GstSeekFlags SeekFlags = GstSeekFlags( GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT );
if( accurate )
SeekFlags = GstSeekFlags( SeekFlags | GST_SEEK_FLAG_ACCURATE );
gboolean seek_ok = gst_element_seek_simple( m_Playbin, GST_FORMAT_TIME, SeekFlags, where * GST_MSECOND );
if( seek_ok )
m_PositionDelta = where * GST_MSECOND - gst_clock_get_time( gst_element_get_clock( m_Playbin ) );
return seek_ok;
}
// -------------------------------------------------------------------------------- //
wxFileOffset guFaderPlaybin::Position( void )
{
wxFileOffset Position = 0;
// actual position detection
gst_element_query_position( m_Playbin, GST_FORMAT_TIME, &Position );
// feature R&D {
#ifdef GU_DEBUG
wxFileOffset play_pos_estimation = 0;
if( GST_IS_ELEMENT( m_Playbin ) )
{
// calculate the position from the sink total playback time
// to support getting position if gst_element_query_position() is tripping
GstClock * playbin_clock = gst_element_get_clock( m_Playbin );
if( playbin_clock )
{
// delta is adjusted in Seek() and reset in Load()
play_pos_estimation = gst_clock_get_time( playbin_clock ) + m_PositionDelta;
// only as stats for now
}
gst_object_unref( playbin_clock );
}
guLogStats( "track position: estimated=%lu real=%lu", play_pos_estimation, Position );
#endif
// } feature R&D
return Position < 0 ? 0 : Position;
}
// -------------------------------------------------------------------------------- //
wxFileOffset guFaderPlaybin::Length( void )
{
wxFileOffset Length;
gst_element_query_duration( m_OutputSink, GST_FORMAT_TIME, ( gint64 * ) &Length );
return Length;
}
// -------------------------------------------------------------------------------- //
bool guFaderPlaybin::AddRecordElement( GstPad * pad )
{
guLogGstPadData( "guFaderPlaybin::AddRecordElement << ", pad );
if( !gst_bin_add( GST_BIN( m_Playbackbin ), m_RecordBin ) )
{
guLogError( "Record error: failed to add recorder into the pipeline" );
return false;
}
if( !gst_element_sync_state_with_parent( m_RecordBin ) )
{
guLogError( "Record error: unable to set recorder state" );
return false;
}
m_TeeSrcPad = gst_element_get_request_pad( m_Tee, "src_%u" );
guLogGstPadData( "guFaderPlaybin::AddRecordElement src request pad", m_TeeSrcPad );
if( m_TeeSrcPad == NULL )
{
guLogError( "Record error: request pad is null" );
return false;
}
int lres = gst_pad_link( m_TeeSrcPad, m_RecordSinkPad );
if( lres == GST_PAD_LINK_OK )
{
guLogDebug( "guFaderPlaybin::AddRecordElement link ok" );
return true;
}
guLogError( "Record error: pads do not link (code %i)", lres );
return false;
// gst_object_ref( m_RecordSinkPad );
}
// -------------------------------------------------------------------------------- //
static GstPadProbeReturn guFaderPlaybin__EnableRecord( GstPad * pad, GstPadProbeInfo * info, guFaderPlaybin::WeakPtr * wpp )
{
guLogDebug( "guFaderPlaybin__EnableRecord << %p", wpp );
if( auto sp = wpp->lock() )
{
if( (*sp)->AddRecordElement( pad ) )
guLogDebug( "guFaderPlaybin__EnableRecord recorder added" );
else
guLogTrace( "Recorder fail" );
guMediaEvent e( guEVT_PIPELINE_CHANGED );
e.SetClientData( wpp );
(*sp)->SendEvent( e ); // returns in ::RefreshPlaybackItems
}
else
{
guLogTrace( "Enable recording: parent fader playbin is gone" );
delete wpp;
}
guLogDebug( "guFaderPlaybin__EnableRecord >>" );
return GST_PAD_PROBE_REMOVE;
}
// -------------------------------------------------------------------------------- //
bool guFaderPlaybin::EnableRecord( const wxString &recfile, const int format, const int quality )
{
guLogDebug( wxT( "guFaderPlaybin::EnableRecord %i %i '%s'" ), format, quality, recfile.c_str() );
m_Encoder = NULL;
m_Muxer = NULL;
gint Mp3Quality[] = { 320, 192, 128, 96, 64 };
gfloat OggQuality[] = { 0.9f, 0.7f, 0.5f, 0.3f, 0.1f };
gint FlacQuality[] = { 8, 7, 5, 3, 1 };
//
switch( format )
{
case guRECORD_FORMAT_MP3 :
{
m_Encoder = gst_element_factory_make( "lamemp3enc", "rb_lame" );
if( IsValidElement( m_Encoder ) )
{
g_object_set( m_Encoder, "bitrate", Mp3Quality[ quality ], NULL );
m_Muxer = gst_element_factory_make( "xingmux", "rb_xingmux" );
if( !IsValidElement( m_Muxer ) )
{
guLogError( wxT( "Could not create the record xingmux object" ) );
m_Muxer = NULL;
}
}
else
{
m_Encoder = NULL;
}
break;
}
case guRECORD_FORMAT_OGG :
{
m_Encoder = gst_element_factory_make( "vorbisenc", "rb_vorbis" );
if( IsValidElement( m_Encoder ) )
{
g_object_set( m_Encoder, "quality", OggQuality[ quality ], NULL );
m_Muxer = gst_element_factory_make( "oggmux", "rb_oggmux" );
if( !IsValidElement( m_Muxer ) )
{
guLogError( wxT( "Could not create the record oggmux object" ) );
m_Muxer = NULL;
}
}
else
{
m_Encoder = NULL;
}
break;
}
case guRECORD_FORMAT_FLAC :
{
m_Encoder = gst_element_factory_make( "flacenc", "rb_flac" );
if( IsValidElement( m_Encoder ) )
{
g_object_set( m_Encoder, "quality", FlacQuality[ quality ], NULL );
}
else
{
m_Encoder = NULL;
}
break;
}
}
if( m_Encoder )
{
if( BuildRecordBin( recfile ) )
{
guGstPtr<GstPad> AddPad( gst_element_get_static_pad( m_Tee, "sink" ) );
guGstPtr<GstPad> IdlePad( gst_pad_get_peer( AddPad.ptr ) );
WeakPtr * p = GetWeakPtr();
if( gst_pad_add_probe( IdlePad.ptr, GST_PAD_PROBE_TYPE_IDLE,
GstPadProbeCallback( guFaderPlaybin__EnableRecord ), p, NULL ) )
{
guLogDebug( "guFaderPlaybin::EnableRecord probe added" );
return true;
}
else
{
if( guIsGstElementLinked( m_RecordBin ) )
{
guLogDebug( "guFaderPlaybin::EnableRecord enabled in the current thread" );
return true;
}
else
{
guLogError( "Record error: unable to add element probe" );
}
delete p;
}
}
else
{
guLogMessage( "Record error: could not build the recordbin object." );
}
}
else
{
guLogError( "Record error: could not create the encoder object" );
}
return false;
}
// -------------------------------------------------------------------------------- //
static void guFaderPlaybin__RefreshPlaybackItems( guFaderPlaybin::WeakPtr * wpp )
{
guLogDebug( "guFaderPlaybin__RefreshPlaybackItems << %p", wpp );
if( auto sp = wpp->lock() )
{
// this function runs inside pad probe thread, so
// elements state changes should happen in another
guLogDebug( "guFaderPlaybin__RefreshPlaybackItems found the bin" );
guMediaEvent e( guEVT_PIPELINE_CHANGED );
e.SetClientData( wpp );
(*sp)->SendEvent( e ); // returns in ::RefreshPlaybackItems
}
else
{
guLogTrace( "Refresh pipeline elements: parent fader playbin is gone" );
delete wpp;
}
guLogDebug( "guFaderPlaybin__RefreshPlaybackItems >>" );
}
// -------------------------------------------------------------------------------- //
static bool guFaderPlaybin__ElementCleanup_finish( GstElement * element )
{
guGstStateToNullAndUnref( element );
return false;
}
// -------------------------------------------------------------------------------- //
static void guFaderPlaybin__ElementCleanup( GstElement * element )
{
guLogDebug( "guFaderPlaybin__ElementCleanup << %p", element );
g_timeout_add( 10, GSourceFunc( guFaderPlaybin__ElementCleanup_finish ), element );
}
// this should be used only to stop the recording while playing
// use ::DisableRecordAndStop if you need to stop playback ensuring recording data safety
// -------------------------------------------------------------------------------- //
bool guFaderPlaybin::DisableRecord( void )
{
guLogDebug( "guFaderPlaybin::DisableRecord" );
if( m_RecordBin == NULL || !guIsGstElementLinked( m_RecordBin ) )
return true;
guGstPipelineActuator gpa( m_RecordBin );
guGstResultHandler rh(
guGstResultHandler::Func( guFaderPlaybin__ElementCleanup ),
m_RecordBin
);
gpa.SetHandler( &rh );
m_RecordBin = NULL;
return gpa.Disable();
}
// guFaderPlaybin::DisableRecordAndStop callout {
// -------------------------------------------------------------------------------- //
void guFaderPlaybin::DisableRecordAndStop_finish( void )
{
guGstStateToNullAndUnref( m_RecordBin );
m_RecordBin = NULL;
gst_element_set_state( m_Playbin, GST_STATE_READY );
guMediaEvent e( guEVT_PIPELINE_CHANGED );
e.SetClientData( NULL );
SendEvent( e ); // will not return
}
// -------------------------------------------------------------------------------- //
static bool guFaderPlaybin__DisableRecordAndStop_finish( guFaderPlaybin::WeakPtr * wpp )
{
if( auto sp = wpp->lock() )
{
guLogDebug( "guFaderPlaybin__DisableRecordAndStop_finish found the bin" );
(*sp)->DisableRecordAndStop_finish();
}
else
{
guLogTrace( "Disable record: parent fader playbin is gone" );
}
delete wpp;
return false;
}
// -------------------------------------------------------------------------------- //
static void guFaderPlaybin__DisableRecordAndStop( guFaderPlaybin::WeakPtr * wpp )
{
// may run in gstreamer thread
guLogDebug( "guFaderPlaybin__DisableRecordAndStop << %p", wpp );
g_timeout_add( 10, GSourceFunc( guFaderPlaybin__DisableRecordAndStop_finish ), wpp );
}
// clean way to stop playback while recording without loosing data
// -------------------------------------------------------------------------------- //
bool guFaderPlaybin::DisableRecordAndStop( void )
{
guLogDebug( "guFaderPlaybin::DisableRecordAndStop" );
if( m_RecordBin == NULL )
return true;
if( !guIsGstElementLinked( m_RecordBin ) )
{
guGstStateToNullAndUnref( m_RecordBin );
m_RecordBin = NULL;
return true;
}
guGstPipelineActuator gpa( m_RecordBin );
guGstResultHandler rh(
guGstResultHandler::Func( guFaderPlaybin__DisableRecordAndStop ),
GetWeakPtr()
);
gpa.SetHandler( &rh );
return gpa.Disable();
}
// } guFaderPlaybin::DisableRecordAndStop callout
// -------------------------------------------------------------------------------- //
bool guFaderPlaybin::SetRecordFileName( const wxString &filename )
{
if( filename.IsNull() )
return false;
if( filename == m_LastRecordFileName )
return true;
if( !m_RecordBin || m_SettingRecordFileName )
return false;
if( m_IsBuffering )
{
m_PendingNewRecordName = filename;
return true;
}
guLogDebug( "guFaderPlaybin::SetRecordFileName << %s (%i)", filename, m_IsBuffering );
m_SettingRecordFileName = true;
m_LastRecordFileName = filename;
m_PendingNewRecordName.Clear();
if( !wxDirExists( wxPathOnly( m_LastRecordFileName ) ) )
wxFileName::Mkdir( wxPathOnly( m_LastRecordFileName ), 0770, wxPATH_MKDIR_FULL );
static int sink_count = 0;
std::string sink_name = "gurb_filesink_" + std::to_string( ++sink_count );
GstElement * new_sink = gst_element_factory_make( "filesink", sink_name.c_str() );
if( !IsValidElement( new_sink ) )
{
guLogError( "GStreamer error: unable to create a new filesink" );
m_SettingRecordFileName = false;
return false;
}
g_object_set( G_OBJECT( new_sink ),
"location", gchararray( (const char *)filename.mb_str() ), NULL );
guGstElementsChain chain = {
m_Muxer != NULL ? m_Muxer : m_Encoder,
new_sink,
m_FileSink
};
guGstPipelineActuator gpa( &chain );
guGstResultHandler rh(
guGstResultHandler::Func( guFaderPlaybin__ElementCleanup ),
m_FileSink
);
gpa.SetHandler( &rh );
bool res = false;
// ::Enable will replace m_FileSink since new_sink doesn't have src pad
if( gpa.Enable( new_sink ) )
{
guLogDebug( "guFaderPlaybin::SetRecordFileName new_sink plugged" );
m_FileSink = new_sink;
res = true;
}
else
{
guLogError( "Failed to set recording filename to <%s>", filename );
}
m_SettingRecordFileName = false;
return res;
}
// -------------------------------------------------------------------------------- //
void guFaderPlaybin::RefreshPlaybackItems( void )
{
// just a stub for now
guLogDebug( "guFaderPlaybin::RefreshPlaybackItems" );
}
// -------------------------------------------------------------------------------- //
void guFaderPlaybin::ToggleEqualizer( void )
{
guLogDebug( "guFaderPlaybin::ToggleEqualizer" );
guGstPipelineActuator gpa( &m_PlayChain );
guGstResultHandler rh(
guGstResultHandler::Func( guFaderPlaybin__RefreshPlaybackItems ),
GetWeakPtr()
);
gpa.SetHandler( &rh );
gpa.Toggle( m_Equalizer );
}
// -------------------------------------------------------------------------------- //
void guFaderPlaybin::ToggleVolCtl( void )
{
guLogDebug( "guFaderPlaybin::ToggleVolCtl" );
guGstPipelineActuator gpa( &m_PlayChain );
guGstResultHandler rh(
guGstResultHandler::Func( guFaderPlaybin__RefreshPlaybackItems ),
GetWeakPtr()
);
gpa.SetHandler( &rh );
gpa.Toggle( m_FaderVolume );
// renew weak_ptr for every next call
gpa.Toggle( m_Volume, GetWeakPtr() );
}
// -------------------------------------------------------------------------------- //
void guFaderPlaybin::SetRGProperties( void )
{
guLogDebug( "guFaderPlaybin::SetRGProperties" );
g_object_set( m_ReplayGain,
"pre-amp", gdouble( m_Player->m_ReplayGainPreAmp ),
"album-mode", gboolean( m_Player->m_ReplayGainMode == 2 ),
NULL );
//g_object_set( G_OBJECT( m_ReplayGain ), "fallback-gain", gdouble( -6 ), NULL );
}
// -------------------------------------------------------------------------------- //
void guFaderPlaybin::ReconfigureRG( void )
{
guLogDebug( "guFaderPlaybin::ReconfigureRG" );
SetRGProperties();
guGstPipelineActuator gpa( &m_PlayChain );
guGstResultHandler rh(
guGstResultHandler::Func( guFaderPlaybin__RefreshPlaybackItems ),
GetWeakPtr()
);
gpa.SetHandler( &rh );
if( m_Player->m_ReplayGainMode )
{
gpa.Enable( m_ReplayGainLimiter );
gpa.Enable( m_ReplayGain, GetWeakPtr() );
}
else
{
gpa.Disable( m_ReplayGain );
gpa.Disable( m_ReplayGainLimiter, GetWeakPtr() );
}
}
// -------------------------------------------------------------------------------- //
void guFaderPlaybin::SetValveDrop( bool drop )
{
guLogDebug( "guFaderPlaybin::SetValveDrop << %i", drop );
if( m_Valve != NULL )
{
g_object_set( m_Valve, "drop", gboolean( drop ), NULL );
}
}
}
// -------------------------------------------------------------------------------- //
| 62,013
|
C++
|
.cpp
| 1,571
| 30.372374
| 136
| 0.5128
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
750,673
|
MediaRecordCtrl.cpp
|
anonbeat_guayadeque/src/audio/MediaRecordCtrl.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "MediaRecordCtrl.h"
#include "Config.h"
#include "FileRenamer.h"
#include "MediaCtrl.h"
#include "PlayerPanel.h"
#include "TagInfo.h"
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
guMediaRecordCtrl::guMediaRecordCtrl( guPlayerPanel * playerpanel, guMediaCtrl * mediactrl )
{
m_PlayerPanel = playerpanel;
m_MediaCtrl = mediactrl;
m_Recording = false;
m_FirstChange = false;
UpdatedConfig();
}
// -------------------------------------------------------------------------------- //
guMediaRecordCtrl::~guMediaRecordCtrl()
{
guLogDebug( "guMediaRecordCtrl::~guMediaRecordCtrl" );
}
// -------------------------------------------------------------------------------- //
void guMediaRecordCtrl::UpdatedConfig( void )
{
guConfig * Config = ( guConfig * ) guConfig::Get();
m_MainPath = Config->ReadStr( CONFIG_KEY_RECORD_PATH, guPATH_DEFAULT_RECORDINGS, CONFIG_PATH_RECORD );
m_Format = Config->ReadNum( CONFIG_KEY_RECORD_FORMAT, guRECORD_FORMAT_MP3, CONFIG_PATH_RECORD );
m_Quality = Config->ReadNum( CONFIG_KEY_RECORD_QUALITY, guRECORD_QUALITY_NORMAL, CONFIG_PATH_RECORD );
m_SplitTracks = Config->ReadBool( CONFIG_KEY_RECORD_SPLIT, false, CONFIG_PATH_RECORD );
m_DeleteTracks = Config->ReadBool( CONFIG_KEY_RECORD_DELETE, false, CONFIG_PATH_RECORD );
m_DeleteTime = Config->ReadNum( CONFIG_KEY_RECORD_DELETE_TIME, 55, CONFIG_PATH_RECORD ) * 1000;
if( !m_MainPath.EndsWith( wxT( "/" ) ) )
m_MainPath += wxT( "/" );
switch( m_Format )
{
case guRECORD_FORMAT_MP3 :
m_Ext = wxT( ".mp3" );
break;
case guRECORD_FORMAT_OGG :
m_Ext = wxT( ".ogg" );
break;
case guRECORD_FORMAT_FLAC :
m_Ext = wxT( ".flac" );
break;
}
//guLogDebug( wxT( "Record to '%s' %i, %i '%s'" ), m_MainPath.c_str(), m_Format, m_Quality, m_Ext.c_str() );
}
// -------------------------------------------------------------------------------- //
bool guMediaRecordCtrl::Start( const guTrack * track )
{
//guLogDebug( wxT( "guMediaRecordCtrl::Start" ) );
m_TrackInfo = * track;
if( m_TrackInfo.m_SongName.IsEmpty() )
m_TrackInfo.m_SongName = wxT( "Record" );
m_FileName = GenerateRecordFileName();
wxFileName::Mkdir( wxPathOnly( m_FileName ), 0770, wxPATH_MKDIR_FULL );
m_Recording = m_MediaCtrl->EnableRecord( m_FileName, m_Format, m_Quality );
return m_Recording;
}
// -------------------------------------------------------------------------------- //
bool guMediaRecordCtrl::Stop( void )
{
//guLogDebug( wxT( "guMediaRecordCtrl::Stop" ) );
if( m_Recording )
{
m_MediaCtrl->DisableRecord();
m_Recording = false;
SaveTagInfo( m_PrevFileName, &m_PrevTrack );
m_PrevFileName = wxEmptyString;
}
return true;
}
// -------------------------------------------------------------------------------- //
wxString guMediaRecordCtrl::GenerateRecordFileName( void )
{
wxString FileName = m_MainPath;
if( !m_TrackInfo.m_AlbumName.IsEmpty() )
{
FileName += NormalizeField( m_TrackInfo.m_AlbumName );
}
else
{
wxURI Uri( m_TrackInfo.m_FileName );
FileName += NormalizeField( Uri.GetServer() + wxT( "-" ) + Uri.GetPath() );
}
FileName += wxT( "/" );
if( !m_TrackInfo.m_ArtistName.IsEmpty() )
{
FileName += NormalizeField( m_TrackInfo.m_ArtistName ) + wxT( " - " );
}
FileName += NormalizeField( m_TrackInfo.m_SongName ) + m_Ext;
//guLogDebug( wxT( "The New Record Location is : '%s'" ), FileName.c_str() );
return FileName;
}
// -------------------------------------------------------------------------------- //
void guMediaRecordCtrl::SplitTrack( void )
{
guLogMessage( wxT( "guMediaRecordCtrl::SplitTrack" ) );
m_FileName = GenerateRecordFileName();
m_MediaCtrl->SetRecordFileName( m_FileName );
SaveTagInfo( m_PrevFileName, &m_PrevTrack );
m_PrevFileName = m_FileName;
m_PrevTrack = m_TrackInfo;
}
// -------------------------------------------------------------------------------- //
bool guMediaRecordCtrl::SaveTagInfo( const wxString &filename, const guTrack * Track )
{
bool RetVal = true;
guTagInfo * TagInfo;
if( !filename.IsEmpty() && wxFileExists( filename ) )
{
TagInfo = guGetTagInfoHandler( filename );
if( TagInfo )
{
if( m_DeleteTracks )
{
TagInfo->Read();
if( TagInfo->m_Length < m_DeleteTime )
{
wxRemoveFile( filename );
delete TagInfo;
return true;
}
}
TagInfo->m_AlbumName = Track->m_AlbumName;
TagInfo->m_ArtistName = Track->m_ArtistName;
TagInfo->m_GenreName = Track->m_GenreName;
TagInfo->m_TrackName = Track->m_SongName;
if( !( RetVal = TagInfo->Write( guTRACK_CHANGED_DATA_TAGS ) ) )
{
guLogError( wxT( "Could not set tags to the record track" ) );
}
delete TagInfo;
}
}
return RetVal;
}
// -------------------------------------------------------------------------------- //
void guMediaRecordCtrl::SetTrack( const guTrack &track )
{
guLogMessage( wxT( "guMediaRecordCtrl::SetTrack" ) );
m_TrackInfo = track;
SplitTrack();
}
// -------------------------------------------------------------------------------- //
void guMediaRecordCtrl::SetTrackName( const wxString &artistname, const wxString &trackname )
{
bool NeedSplit = false;
// If its the first file Set it so the tags are saved
if( m_PrevFileName.IsEmpty() )
{
m_PrevFileName = m_FileName;
m_PrevTrack = m_TrackInfo;
}
if( m_TrackInfo.m_ArtistName != artistname )
{
m_TrackInfo.m_ArtistName = artistname;
NeedSplit = true;
}
if( m_TrackInfo.m_SongName != trackname )
{
m_TrackInfo.m_SongName = trackname;
NeedSplit = true;
}
if( NeedSplit )
{
SplitTrack();
}
}
// -------------------------------------------------------------------------------- //
void guMediaRecordCtrl::SetStation( const wxString &station )
{
guLogMessage( wxT( "guMediaRecordCtrl::SetStation" ) );
if( m_TrackInfo.m_AlbumName != station )
{
m_TrackInfo.m_AlbumName = station;
SplitTrack();
}
}
}
// -------------------------------------------------------------------------------- //
| 7,695
|
C++
|
.cpp
| 202
| 32.648515
| 112
| 0.535882
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,674
|
GstPipelineActuator.cpp
|
anonbeat_guayadeque/src/audio/GstPipelineActuator.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "GstPipelineActuator.h"
namespace Guayadeque {
struct guGstElementProbeData
{
guGstResultHandler * rhandler;
void * probe_data;
guGstElementProbeData( void * e, guGstResultHandler * rh )
{
rhandler = rh;
probe_data = e;
}
};
// -------------------------------------------------------------------------------- //
// guGstPipelineActuator
// -------------------------------------------------------------------------------- //
// -------------------------------------------------------------------------------- //
guGstPipelineActuator::guGstPipelineActuator( GstElement *element ) : guGstPipelineActuator()
{
guLogDebug( "guGstPipelineActuator <%s>", GST_ELEMENT_NAME(element) );
m_PrivateChain = true;
m_Chain = new guGstElementsChain();
m_Chain->push_back( element );
}
// -------------------------------------------------------------------------------- //
guGstPipelineActuator::guGstPipelineActuator( guGstElementsChain *chain ) : guGstPipelineActuator()
{
guLogDebug( "guGstPipelineActuator [%lu]", chain->size() );
m_Chain = chain;
m_PrivateChain = false;
}
// -------------------------------------------------------------------------------- //
guGstPipelineActuator::~guGstPipelineActuator()
{
guLogDebug( "~guGstPipelineActuator" );
if( m_PrivateChain && m_Chain != NULL )
delete m_Chain;
}
// -------------------------------------------------------------------------------- //
static GstPadProbeReturn guUnplugGstElementEOS( GstPad * my_pad, GstPadProbeInfo * info, guGstElementProbeData * pd )
{
guLogGstPadData( "guUnplugGstElementEOS << ", my_pad );
GstEvent *event = GST_PAD_PROBE_INFO_EVENT (info);
if( GST_EVENT_TYPE( event ) != GST_EVENT_EOS )
return GST_PAD_PROBE_OK;
guGstResultExec rexec( pd->rhandler );
GstElement *what = (GstElement *)pd->probe_data;
delete pd;
gst_object_ref( what );
gst_bin_remove( GST_BIN( GST_OBJECT_PARENT( what ) ), what );
guLogDebug( "guUnplugGstElementEOS >> " );
return GST_PAD_PROBE_REMOVE;
}
// -------------------------------------------------------------------------------- //
static bool guScheduleEOSProbe( GstPad * pad, GstElement * unplug_me, guGstResultExec * rexec )
{
GstPad * wait_eos_here = pad;
guGstPtr<GstPad> wait_eos_here_unref( NULL );
if( GST_IS_BIN( unplug_me ) ) // need to wait on the last sink
{
guLogDebug( "guScheduleEOSProbe unplug_me is bin");
GstIterator * gi = gst_bin_iterate_sinks( GST_BIN( unplug_me ) );
GValue v = G_VALUE_INIT;
if( gi != NULL && gst_iterator_next( gi, &v ) == GST_ITERATOR_OK )
{
GstElement * e = GST_ELEMENT( g_value_get_object( &v ) );
guLogDebug( "guScheduleEOSProbe bin sink: <%s>", GST_ELEMENT_NAME(e) );
wait_eos_here = gst_element_get_static_pad( e, "sink" );
wait_eos_here_unref.ptr = wait_eos_here;
g_value_reset( &v );
gst_iterator_free( gi );
}
else
guLogTrace( "EOS scheduler: failed to list bin sinks, trying pad probe" );
}
guLogGstPadData( "guScheduleEOSProbe wait_eos_here", wait_eos_here );
guGstElementProbeData * pd = new guGstElementProbeData( unplug_me, rexec->Pass() );
if( gst_pad_add_probe( wait_eos_here, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
GstPadProbeCallback( guUnplugGstElementEOS ), pd, NULL) )
{
gst_pad_send_event( pad, gst_event_new_eos() );
return true;
}
guLogTrace( "EOS scheduler: add event probe failure" );
rexec->Retake( pd->rhandler );
delete pd;
return false;
}
// -------------------------------------------------------------------------------- //
static GstPadProbeReturn
guPlugGstElementProbe( GstPad *pad, GstPadProbeInfo *info, gpointer data )
{
guGstElementProbeData * pd = (guGstElementProbeData *)data;
GstElement *what = (GstElement *)pd->probe_data;
guGstResultExec rexec( pd->rhandler );
delete pd;
guLogDebug( "guPlugGstElementProbe << %s", GST_ELEMENT_NAME(what) );
guLogGstPadData( "guPlugGstElementProbe my pad", pad );
guGstPtr<GstPad> peer_gp( gst_pad_get_peer( pad ) );
GstPad *peer = peer_gp.ptr;
guLogGstPadData( "guPlugGstElementProbe plug to", peer );
if( peer == NULL )
{
guLogError( "Plug failed: unable to get pad peer" );
return GST_PAD_PROBE_REMOVE;
}
if( !gst_pad_unlink( pad, peer ) )
{
guLogError( "Plug failed: unable to unlink pads" );
return GST_PAD_PROBE_REMOVE;
}
if( !gst_element_sync_state_with_parent( what ) )
{
guLogError( "Plug failed: unable to sync element <%s> state", GST_ELEMENT_NAME(what) );
gst_pad_link( pad, peer );
return GST_PAD_PROBE_REMOVE;
}
if( gst_element_link_pads( GST_ELEMENT( GST_OBJECT_PARENT( pad ) ), GST_OBJECT_NAME( pad ), what, NULL ) )
{
guGstPtr<GstPad> what_src_pad( gst_element_get_static_pad( what, "src" ) );
if( what_src_pad.ptr == NULL || gst_element_link_pads( what, NULL, GST_ELEMENT( GST_OBJECT_PARENT( peer ) ), GST_OBJECT_NAME( peer ) ) )
{
guLogDebug( "guPlugGstElementProbe plugged ok" );
if( what_src_pad.ptr == NULL )
{
guLogTrace( "Plug: element <%s> has no 'src' pad (replacing sink or bin?)", GST_ELEMENT_NAME( what ) );
if( guScheduleEOSProbe( peer, GST_ELEMENT( GST_OBJECT_PARENT( peer ) ), &rexec ) )
guLogDebug( "guPlugGstElementProbe guScheduleEOSProbe ok" );
else
guLogDebug( "guPlugGstElementProbe guScheduleEOSProbe fail" );
}
rexec.SetErrorMode( false );
return GST_PAD_PROBE_REMOVE;
}
else
{
guLogError( "Plug failed: unable to link element <%s> sink pads", GST_ELEMENT_NAME( GST_OBJECT_PARENT( pad ) ) );
}
}
else
guLogError( "Plug failed: unable to link element <%s> src pads", GST_ELEMENT_NAME( GST_OBJECT_PARENT( pad ) ) );
if( peer != NULL )
gst_pad_link( pad, peer );
return GST_PAD_PROBE_REMOVE;
}
// -------------------------------------------------------------------------------- //
static gulong guPlugGstElement( GstElement *plug_element, GstElement *previous_element, const guGstResultHandler &rhandler )
{
guLogDebug( "guPlugGstElement << <%s> after <%s>", GST_ELEMENT_NAME(plug_element), GST_ELEMENT_NAME(previous_element) );
if( !guIsGstElementLinked(previous_element) )
{
guLogError( "Plug error: previous element is unplugged" );
return false;
}
GstBin *previous_element_parent = GST_BIN(GST_OBJECT_PARENT(previous_element));
if( GST_BIN(GST_OBJECT_PARENT(plug_element)) != previous_element_parent )
{
guLogDebug( "guPlugGstElement add <%s> to bin <%s>", GST_ELEMENT_NAME(plug_element), GST_ELEMENT_NAME(previous_element_parent) );
if( !gst_bin_add( previous_element_parent, plug_element) )
guLogTrace( "Plug problem: failed to add element <%s> to bin <%s>", GST_ELEMENT_NAME(plug_element), GST_ELEMENT_NAME(previous_element_parent) );
}
GstPad *src_pad = gst_element_get_static_pad( previous_element, "src" );
if( src_pad == NULL )
{
guLogError( "Plug error: unable to get source pad of the element <%s>", GST_ELEMENT_NAME(previous_element) );
return false;
}
guGstResultHandler * rh = new guGstResultHandler( rhandler );
guGstElementProbeData * pd = new guGstElementProbeData( plug_element, rh );
gulong res = gst_pad_add_probe( src_pad, GST_PAD_PROBE_TYPE_IDLE, guPlugGstElementProbe, pd, NULL );
if( res == 0 )
{
if( guIsGstElementLinked( plug_element ) )
{
guLogDebug( "guPlugGstElement probe was executed ok in the current thread" );
res = ULONG_MAX;
}
else
{
guLogError( "Plug error: failed to add the probe on source pad <%s> of the element <%s>", GST_ELEMENT_NAME(src_pad), GST_ELEMENT_NAME(previous_element) );
delete rh;
delete pd;
}
}
gst_object_unref( src_pad );
return res;
}
// -------------------------------------------------------------------------------- //
bool guGstPipelineActuator::Enable( GstElement *element, void * new_data )
{
guLogDebug( "guGstPipelineActuator::Enable << %s", GST_ELEMENT_NAME(element) );
if( new_data != NULL && m_ResultHandler != NULL )
m_ResultHandler->m_ExecData = new_data;
if( guIsGstElementLinked( element ) )
{
guLogDebug( "guGstPipelineActuator::Enable >> already enabled" );
return true;
}
GstElement *found_here = NULL, *plug_here = NULL;
for( GstElement *pf : *m_Chain )
{
if( pf == element )
{
found_here = pf;
break;
}
if( guIsGstElementLinked( pf ) )
plug_here = pf;
}
if( found_here != element || plug_here == NULL )
{
guLogError( "Plug error: unable to locate previous element in the chain, <%s> can not be plugged", GST_ELEMENT_NAME(element) );
return false;
}
guLogDebug( "guGstPipelineActuator::Enable previous_element_name <%s>", GST_ELEMENT_NAME(plug_here) );
bool res = guPlugGstElement( element, plug_here, m_ResultHandler != NULL ? *m_ResultHandler : guGstResultHandler( "Actuator Enable default handler" ) );
guLogDebug( "guGstPipelineActuator::Enable >> %i", res );
return res;
}
// -------------------------------------------------------------------------------- //
static GstPadProbeReturn guUnplugGstElementProbe( GstPad * previous_src_pad, GstPadProbeInfo * info, gpointer data )
{
guLogDebug( "guUnplugGstElementProbe on pad <%s> of <%s>", GST_OBJECT_NAME(previous_src_pad), GST_ELEMENT_NAME(GST_OBJECT_PARENT(previous_src_pad)) );
guGstElementProbeData * pd = (guGstElementProbeData *)data;
guGstResultExec rexec( pd->rhandler );
GstElement *what = (GstElement *)pd->probe_data;
delete pd;
guGstPtr<GstPad> previous_src_pad_peer_gp( gst_pad_get_peer( previous_src_pad ) );
GstPad *previous_src_pad_peer = previous_src_pad_peer_gp.ptr;
guLogGstPadData( "guUnplugGstElementProbe previous_src_pad_peer", previous_src_pad_peer );
if( previous_src_pad_peer == NULL )
{
guLogError( "Unplug failed: pad <%s> of element <%s> has null peer", GST_OBJECT_NAME(previous_src_pad), GST_ELEMENT_NAME(GST_OBJECT_PARENT(previous_src_pad)) );
return GST_PAD_PROBE_REMOVE;
}
GstElement *unplug_me = what;
guLogDebug( "guUnplugGstElementProbe unplug_me is <%s>", GST_OBJECT_NAME(unplug_me) );
if( unplug_me == NULL )
{
guLogError( "Unplug failed: target element of pad <%s> (<%s>) is null", GST_OBJECT_NAME(previous_src_pad), GST_ELEMENT_NAME(GST_OBJECT_PARENT(previous_src_pad)) );
return GST_PAD_PROBE_REMOVE;
}
guGstPtr<GstPad> unplug_me_src_pad_gp( gst_element_get_static_pad( unplug_me, "src" ) );
GstPad *unplug_me_src_pad = unplug_me_src_pad_gp.ptr;
guLogGstPadData( "guUnplugGstElementProbe unplug_me_src_pad", unplug_me_src_pad );
bool unplug_me_is_sink = unplug_me_src_pad == NULL;
if( unplug_me_is_sink )
{
guLogTrace( "Unplug: target element <%s> has no 'src' pad (last element?)", GST_ELEMENT_NAME(unplug_me) );
}
guGstPtr<GstPad> next_sink_pad_gp( unplug_me_is_sink ? NULL : gst_pad_get_peer( unplug_me_src_pad ) );
GstPad *next_sink_pad = next_sink_pad_gp.ptr;
guLogGstPadData( "guUnplugGstElementProbe next_sink_pad", next_sink_pad );
if( !unplug_me_is_sink && next_sink_pad == NULL )
{
guLogError( "Unplug failed: sink pad of <%s> pad is null", GST_OBJECT_NAME(unplug_me_src_pad) );
return GST_PAD_PROBE_REMOVE;
}
guGstPtr<GstPad> next_sink_pad_peer_gp( unplug_me_is_sink ? NULL : gst_pad_get_peer( next_sink_pad ) );
GstPad *next_sink_pad_peer = next_sink_pad_peer_gp.ptr;
guLogGstPadData( "guUnplugGstElementProbe next_sink_pad_peer", next_sink_pad_peer );
if( !unplug_me_is_sink && next_sink_pad_peer == NULL )
{
guLogError( "Unplug failed: peer pad of <%s> pad is null", GST_OBJECT_NAME(next_sink_pad) );
return GST_PAD_PROBE_REMOVE;
}
if( gst_pad_unlink( previous_src_pad, previous_src_pad_peer ) )
{
if( unplug_me_is_sink || gst_pad_unlink( next_sink_pad_peer, next_sink_pad ) )
{
int lres = GST_PAD_LINK_OK;
if( !unplug_me_is_sink )
{
lres = gst_pad_link( previous_src_pad, next_sink_pad );
guLogDebug( "guUnplugGstElementProbe link result=%i", lres );
}
if( lres == GST_PAD_LINK_OK )
{
// happy finish
//
if( unplug_me_is_sink && GST_STATE(unplug_me) == GST_STATE_PLAYING ) // need EOS
{
if( guScheduleEOSProbe( previous_src_pad_peer, unplug_me, &rexec ) )
{
guLogDebug( "guUnplugGstElementProbe guScheduleEOSProbe ok" );
return GST_PAD_PROBE_REMOVE;
}
else
guLogDebug( "guUnplugGstElementProbe guScheduleEOSProbe fail" );
}
guLogDebug( "guUnplugGstElementProbe no eos unplug" );
gst_object_ref( unplug_me );
if( !gst_bin_remove( GST_BIN( GST_OBJECT_PARENT( unplug_me ) ), unplug_me ) )
{
guLogDebug( "guUnplugGstElementProbe gst_bin_remove fail" );
gst_object_unref( unplug_me );
}
rexec.SetErrorMode( false );
return GST_PAD_PROBE_REMOVE;
}
else
{
guLogError( "Unplug failed: unable to link pads" );
gst_pad_link( next_sink_pad_peer, next_sink_pad );
}
}
gst_pad_link( previous_src_pad, previous_src_pad_peer );
}
else
guLogError( "Unplug failed: unable to unlink source pads" );
return GST_PAD_PROBE_REMOVE;
}
// -------------------------------------------------------------------------------- //
static bool guUnplugGstElement( GstElement *unplug_me, const guGstResultHandler &rhandler )
{
guLogDebug( "guUnplugGstElement << <%s>", GST_ELEMENT_NAME(unplug_me) );
bool unplug_result = false;
guGstElementProbeData pd( &unplug_result, (guGstResultHandler*)&rhandler );
gst_element_foreach_sink_pad( unplug_me,
[ ] ( GstElement * element, GstPad * sink_pad, void * user_data )
{
guGstElementProbeData * pd = (guGstElementProbeData *)user_data;
bool *res_ptr = (bool *)pd->probe_data;
guLogGstPadData( "guUnplugGstElement unplug sink pad", sink_pad );
GstPad *sink_peer = gst_pad_get_peer( sink_pad );
guLogGstPadData( "guUnplugGstElement sink_peer is", sink_peer );
if ( sink_peer != NULL )
{
guGstResultHandler * rh = new guGstResultHandler( *pd->rhandler );
guGstElementProbeData * for_probe = new guGstElementProbeData( element, rh );
if( gst_pad_add_probe( sink_peer, GST_PAD_PROBE_TYPE_IDLE, guUnplugGstElementProbe, for_probe, NULL ) )
*res_ptr = true;
else
{
if( guIsGstElementLinked( element ) )
{
guLogTrace( "Unplug: failed to add element probe for element <%s> pad <%s>", GST_ELEMENT_NAME(GST_OBJECT_PARENT(sink_peer)), GST_OBJECT_NAME(sink_peer) );
delete rh;
delete for_probe;
}
else
{
guLogDebug( "guUnplugGstElement unplugged in current thread" );
*res_ptr = true;
}
}
gst_object_unref( sink_peer );
}
else
guLogTrace( "Unplug: target is null for element <%s> pad <%s>", GST_ELEMENT_NAME(GST_OBJECT_PARENT(sink_pad)), GST_OBJECT_NAME(sink_pad) );
return 1;
}, &pd );
guLogDebug( "guUnplugGstElement >> %i", unplug_result);
return unplug_result;
}
// -------------------------------------------------------------------------------- //
bool guGstPipelineActuator::Disable( GstElement *element, void * new_data )
{
/*
safe gstreamer element unplug sequence (kinda fiddly):
wait for GST_PAD_PROBE_TYPE_IDLE on src pad of the previous element
unlink there the element, send EOS to the element for a happy finish
wait for EOS during GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM on the element src/sink pad
(or on the sink pad of the the last sink if the unplugged element is the GstBin)
do gst_bin_remove during EOS and give control to handler function
further element handling (like state change & unref) should be done by caller (in another thread)
*/
guLogDebug( "guGstPipelineActuator::Disable << %s", GST_ELEMENT_NAME(element) );
if( new_data != NULL && m_ResultHandler != NULL )
m_ResultHandler->m_ExecData = new_data;
if( !guIsGstElementLinked( element ) )
{
guLogDebug( "guGstPipelineActuator::Disable >> already disabled" );
return true;
}
return guUnplugGstElement( element, m_ResultHandler != NULL ? *m_ResultHandler : guGstResultHandler( "Actuator Disable handler" ) );
}
// -------------------------------------------------------------------------------- //
bool guGstPipelineActuator::Toggle( GstElement *element, void * new_data )
{
guLogDebug( "guGstPipelineActuator::Toggle <%s>", GST_ELEMENT_NAME(element) );
return guIsGstElementLinked( element ) ? Disable( element, new_data ) : Enable( element, new_data );
}
}
// -------------------------------------------------------------------------------- //
| 19,218
|
C++
|
.cpp
| 405
| 39.832099
| 178
| 0.582125
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,675
|
Images.cpp
|
anonbeat_guayadeque/src/images/Images.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.h"tml
//
// -------------------------------------------------------------------------------- //
#include "Images.h"
#include <wx/mstream.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
#include "./images/add.h"
#include "./images/blank_cd_cover.h"
#include "./images/bookmark.h"
#include "./images/default_lastfm_image.h"
#include "./images/del.h"
#include "./images/doc_new.h"
#include "./images/doc_save.h"
#include "./images/download_covers.h"
#include "./images/down.h"
#include "./images/edit_clear.h"
#include "./images/edit_copy.h"
#include "./images/edit_delete.h"
#include "./images/edit.h"
#include "./images/exit.h"
#include "./images/filter.h"
#include "./images/guayadeque.h"
#include "./images/guayadeque_taskbar.h"
#include "./images/lastfm_as_off.h"
#include "./images/lastfm_as_on.h"
#include "./images/lastfm_on.h"
#include "./images/left.h"
#include "./images/musicbrainz.h"
#include "./images/net_radio.h"
#include "./images/no_cover.h"
#include "./images/no_photo.h"
#include "./images/numerate.h"
#include "./images/podcast.h"
#include "./images/right.h"
#include "./images/search_engine.h"
#include "./images/search.h"
#include "./images/splash.h"
#include "./images/system_run.h"
#include "./images/tags.h"
#include "./images/tiny_accept.h"
#include "./images/tiny_add.h"
#include "./images/tiny_del.h"
#include "./images/tiny_doc_save.h"
#include "./images/tiny_edit_clear.h"
#include "./images/tiny_edit.h"
#include "./images/tiny_edit_copy.h"
#include "./images/tiny_filter.h"
#include "./images/tiny_left.h"
#include "./images/tiny_net_radio.h"
#include "./images/tiny_numerate.h"
#include "./images/mid_podcast.h"
#include "./images/tiny_podcast.h"
#include "./images/tiny_reload.h"
#include "./images/tiny_right.h"
#include "./images/tiny_search.h"
#include "./images/tiny_search_again.h"
#include "./images/tiny_search_engine.h"
#include "./images/tiny_shoutcast.h"
#include "./images/tiny_tunein.h"
#include "./images/tiny_status_error.h"
#include "./images/tiny_status_pending.h"
#include "./images/track.h"
#include "./images/up.h"
#include "./images/tiny_library.h"
#include "./images/tiny_record.h"
#include "./images/pref_commands.h"
#include "./images/pref_copy_to.h"
#include "./images/pref_general.h"
#include "./images/pref_last_fm.h"
#include "./images/pref_library.h"
#include "./images/pref_links.h"
#include "./images/pref_lyrics.h"
#include "./images/pref_online_services.h"
#include "./images/pref_playback.h"
#include "./images/pref_podcasts.h"
#include "./images/pref_record.h"
#include "./images/pref_crossfader.h"
#include "./images/pref_jamendo.h"
#include "./images/pref_magnatune.h"
#include "./images/pref_accelerators.h"
//
#include "./images/loc_library.h"
#include "./images/loc_portable_device.h"
#include "./images/loc_net_radio.h"
#include "./images/loc_podcast.h"
#include "./images/loc_magnatune.h"
#include "./images/loc_jamendo.h"
#include "./images/loc_lastfm.h"
#include "./images/loc_lyrics.h"
//
#include "./images/tiny_close_normal.h"
#include "./images/tiny_close_highlight.h"
//
#include "./images/player_highlight_equalizer.h"
#include "./images/player_highlight_muted.h"
#include "./images/player_highlight_next.h"
#include "./images/player_highlight_pause.h"
#include "./images/player_highlight_play.h"
#include "./images/player_highlight_prev.h"
#include "./images/player_highlight_random.h"
#include "./images/player_highlight_record.h"
#include "./images/player_highlight_repeat.h"
#include "./images/player_highlight_repeat_single.h"
#include "./images/player_highlight_search.h"
#include "./images/player_highlight_setup.h"
#include "./images/player_highlight_smart.h"
#include "./images/player_highlight_stop.h"
#include "./images/player_highlight_vol_hi.h"
#include "./images/player_highlight_vol_low.h"
#include "./images/player_highlight_vol_mid.h"
#include "./images/player_highlight_love.h"
#include "./images/player_highlight_ban.h"
#include "./images/player_highlight_crossfading.h"
#include "./images/player_highlight_gapless.h"
#include "./images/player_light_equalizer.h"
#include "./images/player_light_muted.h"
#include "./images/player_light_next.h"
#include "./images/player_light_pause.h"
#include "./images/player_light_play.h"
#include "./images/player_light_prev.h"
#include "./images/player_light_random.h"
#include "./images/player_light_record.h"
#include "./images/player_light_repeat.h"
#include "./images/player_light_repeat_single.h"
#include "./images/player_light_search.h"
#include "./images/player_light_setup.h"
#include "./images/player_light_smart.h"
#include "./images/player_light_stop.h"
#include "./images/player_light_vol_hi.h"
#include "./images/player_light_vol_low.h"
#include "./images/player_light_vol_mid.h"
#include "./images/player_light_love.h"
#include "./images/player_light_ban.h"
#include "./images/player_light_crossfading.h"
#include "./images/player_light_gapless.h"
#include "./images/player_normal_equalizer.h"
#include "./images/player_normal_muted.h"
#include "./images/player_normal_next.h"
#include "./images/player_normal_pause.h"
#include "./images/player_normal_play.h"
#include "./images/player_normal_prev.h"
#include "./images/player_normal_random.h"
#include "./images/player_normal_record.h"
#include "./images/player_normal_repeat.h"
#include "./images/player_normal_repeat_single.h"
#include "./images/player_normal_search.h"
#include "./images/player_normal_setup.h"
#include "./images/player_normal_smart.h"
#include "./images/player_normal_stop.h"
#include "./images/player_normal_vol_hi.h"
#include "./images/player_normal_vol_low.h"
#include "./images/player_normal_vol_mid.h"
#include "./images/player_normal_love.h"
#include "./images/player_normal_ban.h"
#include "./images/player_normal_crossfading.h"
#include "./images/player_normal_gapless.h"
#include "./images/player_tiny_light_play.h"
#include "./images/player_tiny_light_stop.h"
#include "./images/player_tiny_red_stop.h"
//
#include "./images/star_normal_tiny.h"
#include "./images/star_normal_mid.h"
#include "./images/star_normal_big.h"
#include "./images/star_highlight_tiny.h"
#include "./images/star_highlight_mid.h"
#include "./images/star_highlight_big.h"
//
#include "./images/tiny_mv_library.h"
#include "./images/tiny_mv_albumbrowser.h"
#include "./images/tiny_mv_treeview.h"
#include "./images/tiny_mv_playlists.h"
// -------------------------------------------------------------------------------- //
typedef struct {
const unsigned char * imgdata;
unsigned int imgsize;
wxBitmapType imgtype;
} guImage_Item;
#define GUIMAGE( IMAGENAME, IMAGETYPE ) { IMAGENAME, sizeof( IMAGENAME ), IMAGETYPE }
// -------------------------------------------------------------------------------- //
guImage_Item guImage_Items[] = {
GUIMAGE( guImage_add, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_blank_cd_cover, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_bookmark, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_default_lastfm_image, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_del, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_doc_new, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_doc_save, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_download_covers, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_down, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_edit_clear, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_edit_copy, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_edit_delete, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_edit, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_exit, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_filter, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_guayadeque, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_guayadeque_taskbar, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_lastfm_as_off, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_lastfm_as_on, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_lastfm_on, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_left, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_net_radio, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_no_cover, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_no_photo, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_numerate, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_right, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_search, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_splash, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_system_run, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tags, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_accept, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_add, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_del, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_up, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_track, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_search, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_search_engine, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_musicbrainz, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_edit, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_edit_copy, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_filter, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_search_again, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_numerate, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_edit_clear, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_podcast, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_mid_podcast, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_podcast, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_status_pending, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_status_error, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_doc_save, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_reload, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_shoutcast, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_tunein, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_net_radio, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_left, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_right, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_search_engine, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_library, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_record, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_pref_commands, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_pref_copy_to, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_pref_general, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_pref_last_fm, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_pref_library, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_pref_links, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_pref_lyrics, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_pref_online_services, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_pref_playback, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_pref_podcasts, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_pref_record, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_pref_crossfader, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_pref_jamendo, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_pref_magnatune, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_pref_accelerators, wxBITMAP_TYPE_PNG ),
//
GUIMAGE( guImage_loc_library, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_loc_portable_device, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_loc_net_radio, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_loc_podcast, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_loc_magnatune, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_loc_jamendo, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_loc_lastfm, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_loc_lyrics, wxBITMAP_TYPE_PNG ),
//
GUIMAGE( guImage_tiny_close_normal, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_close_highlight, wxBITMAP_TYPE_PNG ),
//
GUIMAGE( guImage_player_highlight_equalizer, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_highlight_muted, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_highlight_next, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_highlight_pause, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_highlight_play, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_highlight_prev, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_highlight_random, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_highlight_record, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_highlight_repeat, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_highlight_repeat_single, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_highlight_search, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_highlight_setup, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_highlight_smart, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_highlight_stop, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_highlight_vol_hi, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_highlight_vol_low, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_highlight_vol_mid, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_highlight_love, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_highlight_ban, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_highlight_crossfading, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_highlight_gapless, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_equalizer, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_muted, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_next, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_pause, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_play, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_prev, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_random, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_record, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_repeat, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_repeat_single, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_search, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_setup, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_smart, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_stop, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_vol_hi, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_vol_low, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_vol_mid, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_love, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_ban, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_crossfading, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_light_gapless, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_equalizer, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_muted, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_next, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_pause, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_play, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_prev, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_random, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_record, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_repeat, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_repeat_single, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_search, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_setup, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_smart, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_stop, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_vol_hi, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_vol_low, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_vol_mid, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_love, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_ban, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_crossfading, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_normal_gapless, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_tiny_light_play, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_tiny_light_stop, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_player_tiny_red_stop, wxBITMAP_TYPE_PNG ),
//
GUIMAGE( guImage_star_normal_tiny, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_star_normal_mid, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_star_normal_big, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_star_highlight_tiny, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_star_highlight_mid, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_star_highlight_big, wxBITMAP_TYPE_PNG ),
//
GUIMAGE( guImage_tiny_mv_library, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_mv_albumbrowser, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_mv_treeview, wxBITMAP_TYPE_PNG ),
GUIMAGE( guImage_tiny_mv_playlists, wxBITMAP_TYPE_PNG )
};
// -------------------------------------------------------------------------------- //
wxBitmap guBitmap( guIMAGE_INDEX imageindex )
{
return wxBitmap( guImage( imageindex ) );
}
// -------------------------------------------------------------------------------- //
wxImage guImage( guIMAGE_INDEX imageindex )
{
wxMemoryInputStream image_stream( guImage_Items[ imageindex ].imgdata,
guImage_Items[ imageindex ].imgsize );
return wxImage( image_stream, guImage_Items[ imageindex ].imgtype );
}
}
// -------------------------------------------------------------------------------- //
| 20,101
|
C++
|
.cpp
| 379
| 50.102902
| 88
| 0.628329
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,676
|
Config.cpp
|
anonbeat_guayadeque/src/config/Config.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "Config.h"
#include "EventCommandIds.h"
#include "Utils.h"
#include "Preferences.h"
#include "DbLibrary.h"
#include "DbRadios.h"
#include "PodcastsPanel.h"
#include "MediaViewer.h"
#include <wx/wfstream.h>
namespace Guayadeque {
static guConfig * m_Config = NULL;
wxDEFINE_EVENT( guConfigUpdatedEvent, wxCommandEvent );
#define guCONFIG_DEFAULT_VERSION 1
// -------------------------------------------------------------------------------- //
guConfig::guConfig( const wxString &conffile )
{
m_IgnoreLayouts = false;
m_Version = guCONFIG_DEFAULT_VERSION;
m_FileName = conffile;
m_XmlDocument = NULL;
m_RootNode = NULL;
if( LoadWithBackup( m_FileName ) )
return;
// The file could not be read so create it
guLogMessage( wxT( "Could not read the conf file '%s'" ), conffile.c_str() );
}
// -------------------------------------------------------------------------------- //
guConfig::~guConfig()
{
Flush();
if( m_XmlDocument )
{
delete m_XmlDocument;
}
}
// -------------------------------------------------------------------------------- //
bool guConfig::LoadFile( const wxString &filename )
{
wxFileInputStream Ins( filename );
if( Ins.IsOk() )
{
m_XmlDocument = new wxXmlDocument( Ins );
if( m_XmlDocument )
{
if( m_XmlDocument->IsOk() )
{
m_RootNode = m_XmlDocument->GetRoot();
if( m_RootNode && m_RootNode->GetName() == wxT( "config" ) )
{
wxString VersionStr;
m_RootNode->GetAttribute( wxT( "version" ), &VersionStr );
long Version;
if( VersionStr.ToLong( &Version ) )
{
m_Version = Version;
}
return true;
}
}
delete m_XmlDocument;
m_XmlDocument = NULL;
}
}
return false;
}
// -------------------------------------------------------------------------------- //
bool guConfig::AddBackupFile( const wxString &filename )
{
if( wxFileExists( filename + wxT( ".00" ) ) )
{
if( !wxCopyFile( filename + wxT( ".00" ), filename + wxT( ".01" ), true ) )
{
guLogMessage( wxT( "Could not create the 01 backup conf file" ) );
return false;
}
}
if( !wxCopyFile( filename, filename + wxT( ".00" ), true ) )
{
guLogMessage( wxT( "Could not create the 00 backup conf file" ) );
return false;
}
return true;
}
// -------------------------------------------------------------------------------- //
bool guConfig::LoadWithBackup( const wxString &conffile )
{
if( LoadFile( m_FileName ) )
{
AddBackupFile( m_FileName );
return true;
}
else
{
if( LoadFile( conffile + wxT( ".00" ) ) )
{
m_FileName = conffile;
Flush();
AddBackupFile( m_FileName );
return true;
}
else
{
if( LoadFile( conffile + wxT( ".01" ) ) )
{
m_FileName = conffile;
Flush();
AddBackupFile( m_FileName );
return true;
}
}
}
return false;
}
// -------------------------------------------------------------------------------- //
void guConfig::Set( guConfig * config )
{
m_Config = config;
}
// -------------------------------------------------------------------------------- //
guConfig * guConfig::Get( void )
{
return m_Config;
}
// -------------------------------------------------------------------------------- //
void guConfig::Flush( void )
{
if( m_XmlDocument )
{
if( !m_XmlDocument->Save( m_FileName ) )
{
guLogMessage( wxT( "Error saving the configuration file '%s'" ), m_FileName.c_str() );
return;
}
}
}
// -------------------------------------------------------------------------------- //
long guConfig::ReadNum( const wxString &keyname, const long defval, const wxString &category )
{
wxString KeyValue = ReadStr( keyname, wxEmptyString, category );
if( !KeyValue.IsEmpty() )
{
long RetVal;
if( KeyValue.ToLong( &RetVal ) )
{
return RetVal;
}
}
return defval;
}
// -------------------------------------------------------------------------------- //
bool guConfig::WriteNum( const wxString &keyname, long value, const wxString &category )
{
return WriteStr( keyname, wxString::Format( wxT( "%ld" ), value ), category );
}
// -------------------------------------------------------------------------------- //
bool guConfig::ReadBool( const wxString &keyname, bool defval, const wxString &category )
{
return ReadNum( keyname, defval, category );
}
// -------------------------------------------------------------------------------- //
bool guConfig::WriteBool( const wxString &keyname, bool value, const wxString &category )
{
return WriteStr( keyname, wxString::Format( wxT( "%i" ), value ), category );
}
// -------------------------------------------------------------------------------- //
inline wxXmlNode * FindNodeByName( wxXmlNode * xmlnode, const wxString &category )
{
wxXmlNode * XmlNode = xmlnode;
while( XmlNode )
{
if( XmlNode->GetName() == category )
{
return XmlNode;
}
XmlNode = XmlNode->GetNext();
}
return NULL;
}
// -------------------------------------------------------------------------------- //
inline wxXmlNode * guConfig::FindNode( const wxString &category )
{
wxArrayString Keys;
Keys = wxStringTokenize( category, wxT( "/" ) );
int Index;
int Count = Keys.Count();
if( Count && m_RootNode )
{
Index = 0;
wxXmlNode * XmlNode = FindNodeByName( m_RootNode->GetChildren(), Keys[ Index ] );
while( XmlNode )
{
Index++;
if( Index >= Count )
return XmlNode;
XmlNode = FindNodeByName( XmlNode->GetChildren(), Keys[ Index ] );
}
}
return NULL;
}
// -------------------------------------------------------------------------------- //
inline wxXmlAttribute * FindPropertyByName( wxXmlAttribute * property, const wxString &category )
{
wxXmlAttribute * Property = property;
while( Property )
{
if( Property->GetName() == category )
{
return Property;
}
Property = Property->GetNext();
}
return NULL;
}
// -------------------------------------------------------------------------------- //
wxString guConfig::ReadStr( const wxString &keyname, const wxString &defval, const wxString &category )
{
//guLogMessage( wxT( "ReadStr( '%s', '%s', '%s' ) " ), keyname.c_str(), defval.c_str(), category.c_str() );
wxMutexLocker Locker( m_ConfigMutex );
wxXmlNode * XmlNode = category.IsEmpty() ? m_RootNode : FindNode( category );
if( XmlNode )
{
XmlNode = FindNodeByName( XmlNode->GetChildren(), keyname );
if( XmlNode )
{
wxString RetVal;
XmlNode->GetAttribute( wxT( "value" ), &RetVal );
//guLogMessage( wxT( "ReadStr( '%s/%s' (%s) => '%s'" ), category.c_str(), keyname.c_str(), defval.c_str(), RetVal.c_str() );
return RetVal;
}
}
//guLogMessage( wxT( "******************** FAILED!!!!!!!!!!!!" ) );
return defval;
}
// -------------------------------------------------------------------------------- //
inline wxXmlNode * CreateCategoryNode( wxXmlNode * xmlnode, const wxString &category )
{
//guLogMessage( wxT( "CreateCategoryNode( '%s' )" ), category.c_str() );
wxArrayString Keys;
Keys = wxStringTokenize( category, wxT( "/" ) );
int Index;
int Count = Keys.Count();
if( Count && xmlnode )
{
Index = 0;
wxXmlNode * ParentNode = xmlnode;
wxXmlNode * XmlNode;
do {
XmlNode = FindNodeByName( ParentNode->GetChildren(), Keys[ Index ] );
if( !XmlNode )
{
XmlNode = new wxXmlNode( wxXML_ELEMENT_NODE, Keys[ Index ] );
ParentNode->AddChild( XmlNode );
}
Index++;
if( Index >= Count )
return XmlNode;
ParentNode = XmlNode;
} while( true );
}
return xmlnode;
}
// -------------------------------------------------------------------------------- //
bool guConfig::WriteStr( const wxString &keyname, const wxString &value, const wxString &category )
{
wxMutexLocker Locker( m_ConfigMutex );
wxXmlNode * CatNode = category.IsEmpty() ? m_RootNode : CreateCategoryNode( m_RootNode, category );
wxXmlNode * XmlNode = FindNodeByName( CatNode->GetChildren(), keyname );
if( !XmlNode )
{
XmlNode = new wxXmlNode( wxXML_ELEMENT_NODE, keyname );
wxXmlAttribute * Properties = new wxXmlAttribute( wxT( "value" ), value, NULL );
XmlNode->SetAttributes( Properties );
CatNode->AddChild( XmlNode );
}
else
{
wxXmlAttribute * Property = FindPropertyByName( XmlNode->GetAttributes(), wxT( "value" ) );
if( !Property )
{
Property = new wxXmlAttribute( wxT( "value" ), value, NULL );
XmlNode->SetAttributes( Property );
}
else
{
Property->SetValue( value );
}
}
return true;
}
// -------------------------------------------------------------------------------- //
wxArrayString guConfig::ReadAStr( const wxString &keyname, const wxString &defval, const wxString &category )
{
wxMutexLocker Locker( m_ConfigMutex );
wxArrayString RetVal;
wxXmlNode * XmlNode = FindNode( category );
if( XmlNode )
{
int Index = 0;
do {
wxXmlNode * EntryNode = FindNodeByName( XmlNode->GetChildren(), keyname + wxString::Format( wxT( "%i" ), Index++ ) );
if( !EntryNode )
break;
wxString Entry;
EntryNode->GetAttribute( wxT( "value" ), &Entry );
RetVal.Add( Entry );
} while( true );
}
return RetVal;
}
// -------------------------------------------------------------------------------- //
void guConfig::DeleteCategory( const wxString &category )
{
wxXmlNode * CatNode = FindNode( category );
if( CatNode )
{
wxXmlNode * XmlNode;
do {
XmlNode = CatNode->GetChildren();
if( !XmlNode )
break;
CatNode->RemoveChild( XmlNode );
delete XmlNode;
} while( XmlNode );
}
}
// -------------------------------------------------------------------------------- //
void LoadCollectionWordList( wxXmlNode * xmlnode, wxArrayString * wordlist )
{
while( xmlnode )
{
wxString Value;
xmlnode->GetAttribute( wxT( "value" ), &Value );
if( !Value.IsEmpty() )
wordlist->Add( Value );
xmlnode = xmlnode->GetNext();
}
}
// -------------------------------------------------------------------------------- //
int LoadCollectionInt( wxXmlNode * xmlnode )
{
wxString ValueStr;
long ValueNum;
xmlnode->GetAttribute( wxT( "value" ), &ValueStr );
if( !ValueStr.IsEmpty() && ValueStr.ToLong( &ValueNum ) )
return ValueNum;
return 0;
}
// -------------------------------------------------------------------------------- //
void LoadCollection( wxXmlNode * xmlnode, guMediaCollection * collection )
{
while( xmlnode )
{
wxString Name = xmlnode->GetName();
if( Name == wxT( "paths" ) )
{
LoadCollectionWordList( xmlnode->GetChildren(), &collection->m_Paths );
}
else if( Name == wxT( "covers" ) )
{
LoadCollectionWordList( xmlnode->GetChildren(), &collection->m_CoverWords );
}
else if( Name == wxT( "UniqueId" ) )
{
xmlnode->GetAttribute( wxT( "value" ), &collection->m_UniqueId );
}
else if( Name == wxT( "Type" ) )
{
collection->m_Type = LoadCollectionInt( xmlnode );
}
else if( Name == wxT( "Name" ) )
{
xmlnode->GetAttribute( wxT( "value" ), &collection->m_Name );
}
else if( Name == wxT( "LastUpdate" ) )
{
collection->m_LastUpdate = LoadCollectionInt( xmlnode );
}
else if( Name == wxT( "UpdateOnStart" ) )
{
collection->m_UpdateOnStart = LoadCollectionInt( xmlnode );
}
else if( Name == wxT( "ScanPlaylists" ) )
{
collection->m_ScanPlaylists = LoadCollectionInt( xmlnode );
}
else if( Name == wxT( "ScanFollowSymLinks" ) )
{
collection->m_ScanFollowSymLinks = LoadCollectionInt( xmlnode );
}
else if( Name == wxT( "ScanEmbeddedCovers" ) )
{
collection->m_ScanEmbeddedCovers = LoadCollectionInt( xmlnode );
}
else if( Name == wxT( "EmbeddMetadata" ) )
{
collection->m_EmbeddMetadata = LoadCollectionInt( xmlnode );
}
else if( Name == wxT( "DefaultCopyAction" ) )
{
xmlnode->GetAttribute( wxT( "value" ), &collection->m_DefaultCopyAction );
}
xmlnode = xmlnode->GetNext();
}
}
// -------------------------------------------------------------------------------- //
int guConfig::LoadCollections( guMediaCollectionArray * collections, const int type )
{
int LoadCount = 0;
wxXmlNode * XmlNode = FindNode( wxT( "collections" ) );
if( XmlNode )
{
XmlNode = XmlNode->GetChildren();
while( XmlNode )
{
guMediaCollection * Collection = new guMediaCollection();
LoadCollection( XmlNode->GetChildren(), Collection );
if( ( type == wxNOT_FOUND ) || ( Collection->m_Type == type ) )
{
collections->Add( Collection );
LoadCount++;
}
else
{
delete Collection;
}
XmlNode = XmlNode->GetNext();
}
}
return LoadCount;
}
// -------------------------------------------------------------------------------- //
void WriteStr( wxXmlNode * xmlnode, const wxString &name, const wxString &value )
{
wxXmlNode * XmlNode = new wxXmlNode( wxXML_ELEMENT_NODE, name );
wxXmlAttribute * Properties = new wxXmlAttribute( wxT( "value" ), value, NULL );
XmlNode->SetAttributes( Properties );
xmlnode->AddChild( XmlNode );
}
// -------------------------------------------------------------------------------- //
void SaveCollection( wxXmlNode * xmlnode, guMediaCollection * collection )
{
wxXmlNode * XmlNode = new wxXmlNode( wxXML_ELEMENT_NODE, wxT( "collection" ) );
WriteStr( XmlNode, wxT( "UniqueId" ), collection->m_UniqueId );
WriteStr( XmlNode, wxT( "Type" ), wxString::Format( wxT( "%i" ), collection->m_Type ) );
WriteStr( XmlNode, wxT( "Name" ), collection->m_Name );
WriteStr( XmlNode, wxT( "UpdateOnStart" ), wxString::Format( wxT( "%i" ), collection->m_UpdateOnStart ) );
WriteStr( XmlNode, wxT( "ScanPlaylists" ), wxString::Format( wxT( "%i" ), collection->m_ScanPlaylists ) );
WriteStr( XmlNode, wxT( "ScanFollowSymLinks" ), wxString::Format( wxT( "%i" ), collection->m_ScanFollowSymLinks ) );
WriteStr( XmlNode, wxT( "ScanEmbeddedCovers" ), wxString::Format( wxT( "%i" ), collection->m_ScanEmbeddedCovers ) );
WriteStr( XmlNode, wxT( "EmbeddMetadata" ), wxString::Format( wxT( "%i" ), collection->m_EmbeddMetadata ) );
WriteStr( XmlNode, wxT( "DefaultCopyAction" ), collection->m_DefaultCopyAction );
WriteStr( XmlNode, wxT( "LastUpdate" ), wxString::Format( wxT( "%i" ), collection->m_LastUpdate ) );
wxXmlNode * ParentNode = new wxXmlNode( wxXML_ELEMENT_NODE, wxT( "paths" ) );
int Count = collection->m_Paths.Count();
for( int Index = 0; Index < Count; Index++ )
{
WriteStr( ParentNode, wxString::Format( wxT( "Path%i" ), Index ), collection->m_Paths[ Index ] );
}
XmlNode->AddChild( ParentNode );
ParentNode = new wxXmlNode( wxXML_ELEMENT_NODE, wxT( "covers" ) );
Count = collection->m_CoverWords.Count();
for( int Index = 0; Index < Count; Index++ )
{
WriteStr( ParentNode, wxString::Format( wxT( "Cover%i" ), Index ), collection->m_CoverWords[ Index ] );
}
XmlNode->AddChild( ParentNode );
xmlnode->AddChild( XmlNode );
}
// -------------------------------------------------------------------------------- //
void guConfig::SaveCollections( guMediaCollectionArray * collections, const bool resetgroup )
{
if( resetgroup )
DeleteCategory( wxT( "collections" ) );
wxXmlNode * XmlNode = FindNode( wxT( "collections" ) );
if( !XmlNode )
{
XmlNode = CreateCategoryNode( m_RootNode, wxT( "collections" ) );
}
int Count = collections->Count();
for( int Index = 0; Index < Count; Index++ )
{
SaveCollection( XmlNode, &collections->Item( Index ) );
}
}
// -------------------------------------------------------------------------------- //
bool guConfig::WriteAStr( const wxString &keyname, const wxArrayString &value, const wxString &category, bool resetgroup )
{
int Count = value.Count();
if( resetgroup )
DeleteCategory( category );
for( int Index = 0; Index < Count; Index++ )
{
if( !WriteStr( keyname + wxString::Format( wxT( "%i" ), Index ), value[ Index ], category ) )
return false;
}
return true;
}
#if wxUSE_STL
// -------------------------------------------------------------------------------- //
bool guConfig::WriteAStr( const wxString &Key, const wxSortedArrayString &Value, const wxString &Category, bool ResetGroup )
{
wxArrayString AStrings;
int Count = Value.Count();
for( int Index = 0; Index < Count; Index++ )
{
AStrings.Add( Value[ Index ] );
}
return WriteAStr( Key, AStrings, Category, ResetGroup );
}
#endif
// -------------------------------------------------------------------------------- //
wxArrayInt guConfig::ReadANum( const wxString &keyname, const int defval, const wxString &category )
{
//guLogMessage( wxT( "ReadANum( '%s', %i, '%s'" ), keyname.c_str(), defval, category.c_str() );
wxMutexLocker Locker( m_ConfigMutex );
wxArrayInt RetVal;
wxXmlNode * XmlNode = FindNode( category );
if( XmlNode )
{
int Index = 0;
do {
wxXmlNode * EntryNode = FindNodeByName( XmlNode->GetChildren(), keyname + wxString::Format( wxT( "%i" ), Index++ ) );
if( !EntryNode )
break;
wxString EntryStr;
long Entry;
EntryNode->GetAttribute( wxT( "value" ), &EntryStr );
EntryStr.ToLong( &Entry );
RetVal.Add( Entry );
} while( true );
}
return RetVal;
}
// -------------------------------------------------------------------------------- //
bool guConfig::WriteANum( const wxString &keyname, const wxArrayInt &value, const wxString &category, bool resetgroup )
{
int Count = value.Count();
if( resetgroup )
DeleteCategory( category );
for( int Index = 0; Index < Count; Index++ )
{
if( !WriteNum( keyname + wxString::Format( wxT( "%i" ), Index ), value[ Index ], category ) )
return false;
}
return true;
}
// -------------------------------------------------------------------------------- //
void guConfig::RegisterObject( wxEvtHandler * object )
{
wxMutexLocker Lock( m_ObjectsMutex );
if( m_Objects.Index( object ) == wxNOT_FOUND )
{
m_Objects.Add( object );
}
}
// -------------------------------------------------------------------------------- //
void guConfig::UnRegisterObject( wxEvtHandler * object )
{
wxMutexLocker Lock( m_ObjectsMutex );
int Index = m_Objects.Index( object );
if( Index != wxNOT_FOUND )
{
m_Objects.RemoveAt( Index );
}
}
// -------------------------------------------------------------------------------- //
void guConfig::SendConfigChangedEvent( const int flags )
{
wxMutexLocker Lock( m_ObjectsMutex );
wxCommandEvent event( guConfigUpdatedEvent, ID_CONFIG_UPDATED );
event.SetInt( flags );
int Count = m_Objects.Count();
for( int Index = 0; Index < Count; Index++ )
{
m_Objects[ Index ]->AddPendingEvent( event );
}
}
// -------------------------------------------------------------------------------- //
void WriteTrack( wxXmlNode * xmlnode, const guTrack &track )
{
wxXmlNode * XmlNode = new wxXmlNode( wxXML_ELEMENT_NODE, wxT( "track" ) );
WriteStr( XmlNode, wxT( "Type" ), wxString::Format( wxT( "%i" ), track.m_Type ) );
if( track.m_MediaViewer )
{
//WriteStr( XmlNode, wxT( "MediaViewer" ), track.m_MediaViewer->GetUniqueId() );
}
WriteStr( XmlNode, wxT( "Name" ), track.m_SongName );
WriteStr( XmlNode, wxT( "Artist" ), track.m_ArtistName );
WriteStr( XmlNode, wxT( "AlbumArtist" ), track.m_AlbumArtist );
WriteStr( XmlNode, wxT( "Composer" ), track.m_Composer );
WriteStr( XmlNode, wxT( "Album" ), track.m_AlbumName );
WriteStr( XmlNode, wxT( "Path" ), track.m_Path );
WriteStr( XmlNode, wxT( "FileName" ), track.m_FileName );
WriteStr( XmlNode, wxT( "Number" ), wxString::Format( wxT( "%i" ), track.m_Number ) );
WriteStr( XmlNode, wxT( "Rating" ), wxString::Format( wxT( "%i" ), track.m_Rating ) );
WriteStr( XmlNode, wxT( "Offset" ), wxString::Format( wxT( "%u" ), track.m_Offset ) );
WriteStr( XmlNode, wxT( "Length" ), wxString::Format( wxT( "%u" ), track.m_Length ) );
xmlnode->AddChild( XmlNode );
}
// -------------------------------------------------------------------------------- //
int inline StrToInt( const wxString &value )
{
long RetVal = 0;
value.ToLong( &RetVal );
return RetVal;
}
// -------------------------------------------------------------------------------- //
void ReadTrack( wxXmlNode * xmlnode, guTrack &track )
{
while( xmlnode )
{
wxString Name = xmlnode->GetName();
wxString Value;
if( Name == wxT( "Type" ) )
{
xmlnode->GetAttribute( wxT( "value" ), &Value );
track.m_Type = ( guTrackType ) StrToInt( Value );
}
else if( Name == wxT( "MediaViewer" ) )
{
}
else if( Name == wxT( "Name" ) )
{
xmlnode->GetAttribute( wxT( "value" ), &track.m_SongName );
}
else if( Name == wxT( "Artist" ) )
{
xmlnode->GetAttribute( wxT( "value" ), &track.m_ArtistName );
}
else if( Name == wxT( "AlbumArtist" ) )
{
xmlnode->GetAttribute( wxT( "value" ), &track.m_AlbumArtist );
}
else if( Name == wxT( "Composer" ) )
{
xmlnode->GetAttribute( wxT( "value" ), &track.m_Composer );
}
else if( Name == wxT( "Album" ) )
{
xmlnode->GetAttribute( wxT( "value" ), &track.m_AlbumName );
}
else if( Name == wxT( "Path" ) )
{
xmlnode->GetAttribute( wxT( "value" ), &track.m_Path );
}
else if( Name == wxT( "FileName" ) )
{
xmlnode->GetAttribute( wxT( "value" ), &track.m_FileName );
}
else if( Name == wxT( "Number" ) )
{
xmlnode->GetAttribute( wxT( "value" ), &Value );
track.m_Number = StrToInt( Value );
}
else if( Name == wxT( "Rating" ) )
{
xmlnode->GetAttribute( wxT( "value" ), &Value );
track.m_Rating = StrToInt( Value );
}
else if( Name == wxT( "Offset" ) )
{
xmlnode->GetAttribute( wxT( "value" ), &Value );
track.m_Offset = StrToInt( Value );
}
else if( Name == wxT( "Length" ) )
{
xmlnode->GetAttribute( wxT( "value" ), &Value );
track.m_Length = StrToInt( Value );
}
xmlnode = xmlnode->GetNext();
}
}
// -------------------------------------------------------------------------------- //
bool guConfig::SavePlaylistTracks( const guTrackArray &tracks, const int currenttrack )
{
DeleteCategory( wxT( "playlist/nowplaying") );
WriteNum( wxT( "Count" ), tracks.Count(), wxT( "playlist/nowplaying" ) );
WriteNum( wxT( "CurItem" ), currenttrack, wxT( "playlist/nowplaying" ) );
wxXmlNode * XmlNode = CreateCategoryNode( m_RootNode, wxT( "playlist/nowplaying/tracks" ) );
int Count = tracks.Count();
for( int Index = 0; Index < Count; Index++ )
{
WriteTrack( XmlNode, tracks[ Index ] );
}
Flush();
return true;
}
// -------------------------------------------------------------------------------- //
int guConfig::LoadPlaylistTracks( guTrackArray &tracks )
{
int CurItem = ReadNum( wxT( "CurItem" ), wxNOT_FOUND, wxT( "playlist/nowplaying" ) );
wxXmlNode * XmlNode = FindNode( wxT( "playlist/nowplaying/tracks" ) );
if( XmlNode )
{
XmlNode = XmlNode->GetChildren();
while( XmlNode )
{
if( XmlNode->GetName() == wxT( "track" ) )
{
guTrack Track;
ReadTrack( XmlNode->GetChildren(), Track );
tracks.Add( new guTrack( Track ) );
}
XmlNode = XmlNode->GetNext();
}
}
return CurItem;
}
}
// -------------------------------------------------------------------------------- //
| 26,874
|
C++
|
.cpp
| 731
| 30.157319
| 136
| 0.505661
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
750,677
|
Http.cpp
|
anonbeat_guayadeque/src/network/Http.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "Http.h"
#include "wx/wx.h"
#include <wx/wfstream.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
guHttp::guHttp( const wxString &url ) : guCurl( url )
{
}
// -------------------------------------------------------------------------------- //
guHttp::~guHttp()
{
}
// -------------------------------------------------------------------------------- //
void guHttp::AddHeader( const wxString &key, const wxString &value )
{
m_ReqHeaders.Add( key + ": " + value );
}
// -------------------------------------------------------------------------------- //
bool guHttp::Post( const char * buffer, size_t size, const wxString &url )
{
wxMemoryInputStream InStream( buffer, size );
return Post( InStream, url );
}
// -------------------------------------------------------------------------------- //
bool guHttp::Post( wxInputStream &instream, const wxString &url )
{
if( instream.IsOk() )
{
SetDefaultOptions( url );
SetHeaders();
curl_off_t Size = instream.GetSize();
if( !Size )
return false;
SetOption( CURLOPT_POST, 1L );
SetOption( CURLOPT_POSTFIELDSIZE_LARGE, Size );
SetStreamReadOption( instream );
SetStringWriteOption( m_ResData );
if( Perform() )
{
CleanHeaders();
CleanupHandle();
return ( m_ResCode >= 200 && m_ResCode < 300 );
}
CleanHeaders();
CleanupHandle();
}
return false;
}
// -------------------------------------------------------------------------------- //
bool guHttp::Get( const wxString &filename, const wxString &url )
{
wxFFileOutputStream outStream( filename );
return Get( outStream, url );
}
// -------------------------------------------------------------------------------- //
size_t guHttp::Get( char * &buffer, const wxString &url )
{
buffer = NULL;
wxMemoryOutputStream outStream;
if( Get( outStream, url ) )
{
size_t Retval = outStream.GetSize();
buffer = ( char * ) malloc( Retval + 1 );
if( buffer )
{
if( outStream.CopyTo( buffer, Retval ) == Retval )
{
buffer[ Retval ] = 0;
return Retval;
}
else
{
free( buffer );
buffer = NULL;
}
}
}
return 0;
}
// -------------------------------------------------------------------------------- //
bool guHttp::Get( wxOutputStream &buffer, const wxString &url )
{
if( buffer.IsOk() )
{
SetDefaultOptions( url );
SetHeaders();
SetOption( CURLOPT_HTTPGET, 1L );
SetStreamWriteOption( buffer );
if( Perform() )
{
CleanHeaders();
CleanupHandle();
return ( m_ResCode >= 200 && m_ResCode < 300 );
}
CleanHeaders();
CleanupHandle();
}
return false;
}
}
// -------------------------------------------------------------------------------- //
| 4,162
|
C++
|
.cpp
| 122
| 28.721311
| 86
| 0.462151
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,678
|
Curl.cpp
|
anonbeat_guayadeque/src/network/Curl.cpp
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or ( at your option )
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#include "Curl.h"
#include "Config.h"
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
extern "C"
{
size_t string_write_callback( void * buffer, size_t size, size_t nitems, wxCharBuffer * outstring )
{
size_t Size = size * nitems;
if( outstring )
{
wxString str = wxString( * outstring, wxConvLibc ) + wxString( ( const char * ) buffer, wxConvLibc );
* outstring = str.ToAscii();
}
return Size;
}
size_t string_read_callback( void * buffer, size_t size, size_t nitems, wxCharBuffer * instring )
{
size_t Retval = 0;
if( instring )
{
size_t BufLen = size * nitems;
size_t InLen = instring->length();
Retval = InLen > BufLen ? BufLen : InLen;
memcpy( ( char * ) buffer, instring->data(), Retval );
wxString remaining = wxString( instring->data(), wxConvLibc ).Right( InLen - Retval );
* instring = remaining.ToAscii();
}
return Retval;
}
size_t stream_write_callback( void * buffer, size_t size, size_t nitems, wxOutputStream * outstream )
{
if( outstream )
{
size_t Size = size * nitems;
outstream->Write( buffer, Size );
return outstream->LastWrite();
}
return 0;
}
size_t stream_read_callback( void * buffer, size_t size, size_t nitems, wxInputStream * instream )
{
if( instream )
{
size_t Size = size * nitems;
instream->Read( buffer, Size );
return instream->LastRead();
}
return 0;
}
}
// -------------------------------------------------------------------------------- //
guCurl::guCurl( const wxString &url )
{
m_CurlHandle = NULL;
m_Url = url.ToAscii();
m_User = "";
m_Password = "";
m_Port = 0;
m_ResCode = -1;
m_CurlHeaders = NULL;
guConfig * Config = guConfig::Get();
m_UseProxy = Config->ReadBool( CONFIG_KEY_PROXY_ENABLED, false, CONFIG_PATH_PROXY );
m_ProxyHost = Config->ReadStr( CONFIG_KEY_PROXY_HOSTNAME, wxEmptyString, CONFIG_PATH_PROXY ).ToAscii();
m_ProxyPort = Config->ReadNum( CONFIG_KEY_PROXY_PORT, 8080, CONFIG_PATH_PROXY );
m_ProxyUser = Config->ReadStr( CONFIG_KEY_PROXY_USERNAME, wxEmptyString, CONFIG_PATH_PROXY ).ToAscii();
m_ProxyPassword = Config->ReadStr( CONFIG_KEY_PROXY_PASSWORD, wxEmptyString, CONFIG_PATH_PROXY ).ToAscii();
m_ErrorBuffer[ 0 ] = 0;
}
// -------------------------------------------------------------------------------- //
guCurl::~guCurl()
{
CleanHeaders();
CleanupHandle();
}
// -------------------------------------------------------------------------------- //
bool guCurl::InitHandle()
{
if( m_CurlHandle )
return false;
m_CurlHandle = curl_easy_init();
return ( m_CurlHandle != NULL );
}
// -------------------------------------------------------------------------------- //
bool guCurl::CleanupHandle()
{
if( m_CurlHandle )
{
curl_easy_cleanup( m_CurlHandle );
m_CurlHandle = NULL;
}
return true;
}
// -------------------------------------------------------------------------------- //
bool guCurl::ReInitHandle()
{
CleanupHandle();
return InitHandle();
}
// -------------------------------------------------------------------------------- //
void guCurl::ResetHandle()
{
curl_easy_reset( m_CurlHandle );
}
// -------------------------------------------------------------------------------- //
bool guCurl::Perform()
{
CURLcode res = curl_easy_perform( m_CurlHandle );
GetInfo( CURLINFO_RESPONSE_CODE, &m_ResCode );
return ( res == CURLE_OK );
}
// -------------------------------------------------------------------------------- //
void guCurl::SetUrl( const wxString &url )
{
m_Url = url.ToAscii();
}
// -------------------------------------------------------------------------------- //
wxString guCurl::GetUrl() const
{
return wxString( m_Url, wxConvLibc );
}
// -------------------------------------------------------------------------------- //
void guCurl::SetPort( const long &port )
{
m_Port = port;
}
// -------------------------------------------------------------------------------- //
long guCurl::GetPort() const
{
return m_Port;
}
// -------------------------------------------------------------------------------- //
void guCurl::SetUsername( const wxString &username )
{
m_User = username.ToAscii();
}
// -------------------------------------------------------------------------------- //
wxString guCurl::GetUsername() const
{
return wxString( m_User, wxConvLibc );
}
// -------------------------------------------------------------------------------- //
void guCurl::SetPassword( const wxString &password )
{
m_Password = password.ToAscii();
}
// -------------------------------------------------------------------------------- //
wxString guCurl::GetPassword() const
{
return wxString( m_Password, wxConvLibc );
}
// -------------------------------------------------------------------------------- //
wxString guCurl::GetResHeader() const
{
return wxString( m_ResHeader, wxConvLibc );
}
// -------------------------------------------------------------------------------- //
wxString guCurl::GetResData() const
{
return wxString( m_ResData, wxConvLibc );
}
// -------------------------------------------------------------------------------- //
long guCurl::GetResCode() const
{
return m_ResCode;
}
// -------------------------------------------------------------------------------- //
void guCurl::SetUseProxy( const bool useproxy )
{
m_UseProxy = useproxy;
}
// -------------------------------------------------------------------------------- //
bool guCurl::GetUseProxy() const
{
return m_UseProxy;
}
// -------------------------------------------------------------------------------- //
void guCurl::SetProxyHost( const wxString &proxyhost )
{
m_ProxyHost = proxyhost.ToAscii();
}
// -------------------------------------------------------------------------------- //
wxString guCurl::GetProxyHost() const
{
return wxString( m_ProxyHost, wxConvLibc );
}
// -------------------------------------------------------------------------------- //
void guCurl::SetProxyUser( const wxString &proxyusername )
{
m_ProxyUser = proxyusername.ToAscii();
}
// -------------------------------------------------------------------------------- //
wxString guCurl::GetProxyUser() const
{
return wxString( m_ProxyUser, wxConvLibc );
}
// -------------------------------------------------------------------------------- //
void guCurl::SetProxyPassword( const wxString &proxypassword )
{
m_ProxyPassword = proxypassword.ToAscii();
}
// -------------------------------------------------------------------------------- //
wxString guCurl::GetProxyPassword() const
{
return wxString( m_ProxyPassword, wxConvLibc );
}
// -------------------------------------------------------------------------------- //
void guCurl::SetProxyPort( const long &proxyport )
{
m_ProxyPort = proxyport;
}
// -------------------------------------------------------------------------------- //
long guCurl::GetProxyPort() const
{
return m_ProxyPort;
}
// -------------------------------------------------------------------------------- //
bool guCurl::SetOption( CURLoption option, long value )
{
return curl_easy_setopt( m_CurlHandle, option, value ) == CURLE_OK;
}
// -------------------------------------------------------------------------------- //
bool guCurl::SetOption( CURLoption option, wxCharBuffer &value )
{
return curl_easy_setopt( m_CurlHandle, option, ( const char * ) value ) == CURLE_OK;
}
// -------------------------------------------------------------------------------- //
bool guCurl::SetOption( CURLoption option, void * value )
{
return curl_easy_setopt( m_CurlHandle, option, value ) == CURLE_OK;
}
// -------------------------------------------------------------------------------- //
bool guCurl::SetStringReadOption( const wxCharBuffer &str )
{
return SetOption( CURLOPT_READFUNCTION, ( void * ) string_read_callback ) &&
SetOption( CURLOPT_READDATA, ( void * ) &str );
}
// -------------------------------------------------------------------------------- //
bool guCurl::SetStringWriteOption( const wxCharBuffer &str )
{
return SetOption( CURLOPT_WRITEFUNCTION, ( void * ) string_write_callback ) &&
SetOption( CURLOPT_WRITEDATA, ( void * ) &str );
}
// -------------------------------------------------------------------------------- //
bool guCurl::SetStreamReadOption( const wxInputStream &stream )
{
return SetOption( CURLOPT_READFUNCTION, ( void * ) stream_read_callback ) &&
SetOption( CURLOPT_READDATA, ( void * ) &stream );
}
// -------------------------------------------------------------------------------- //
bool guCurl::SetStreamWriteOption( const wxOutputStream &stream )
{
return SetOption( CURLOPT_WRITEFUNCTION, ( void * ) stream_write_callback ) &&
SetOption( CURLOPT_WRITEDATA, ( void * ) &stream );
}
// -------------------------------------------------------------------------------- //
bool guCurl::GetInfo( CURLINFO info, long * value )
{
return curl_easy_getinfo( m_CurlHandle, info, value ) == CURLE_OK;
}
// -------------------------------------------------------------------------------- //
void guCurl::SetDefaultOptions( const wxString &url )
{
if( !url.empty() )
SetUrl( url );
if( m_CurlHandle )
{
ResetHandle();
}
else
{
InitHandle();
}
ResetResVars();
SetOption( CURLOPT_URL, m_Url );
SetOption( CURLOPT_HEADERFUNCTION, ( void * ) string_write_callback );
SetOption( CURLOPT_HEADERDATA, ( void * ) &m_ResHeader );
SetOption( CURLOPT_ERRORBUFFER, ( void * ) m_ErrorBuffer );
if( !wxCHARBUFFER_ISEMPTY( m_User ) &&
!wxCHARBUFFER_ISEMPTY( m_Password ) )
{
wxString str = wxString( m_User, wxConvLibc ) +
wxT( ":" ) +
wxString( m_Password, wxConvLibc );
m_CurlUserPass = str.ToAscii();
SetOption( CURLOPT_USERPWD, m_CurlUserPass );
SetOption( CURLOPT_HTTPAUTH, CURLAUTH_ANY );
}
if( m_Port )
{
SetOption( CURLOPT_PORT, m_Port );
}
if( m_UseProxy )
{
if( !wxCHARBUFFER_ISEMPTY( m_ProxyHost ) )
{
SetOption( CURLOPT_PROXY, m_ProxyHost );
}
if( m_ProxyPort )
{
SetOption( CURLOPT_PROXYPORT, m_ProxyPort );
}
if( !wxCHARBUFFER_ISEMPTY( m_ProxyUser ) &&
!wxCHARBUFFER_ISEMPTY( m_ProxyPassword ) )
{
wxString str = wxString( m_ProxyUser, wxConvLibc ) +
wxT( ":" ) +
wxString( m_ProxyPassword, wxConvLibc );
m_CurlProxyUserPass = str.ToAscii();
SetOption( CURLOPT_PROXYUSERPWD, m_CurlProxyUserPass );
}
}
SetOption( CURLOPT_VERBOSE, CURL_VERBOSE_MODE );
SetOption( CURLOPT_NOSIGNAL, CURL_NO_SIGNALS );
SetOption( CURLOPT_FOLLOWLOCATION, CURL_FOLLOW_LOCATIONS );
SetOption( CURLOPT_MAXREDIRS, CURL_MAX_REDIRS );
}
// -------------------------------------------------------------------------------- //
void guCurl::SetHeaders()
{
if( !m_ReqHeaders.IsEmpty() )
{
if( m_CurlHeaders )
{
curl_slist_free_all( m_CurlHeaders );
m_CurlHeaders = NULL;
SetOption( CURLOPT_HTTPHEADER, ( void * ) m_CurlHeaders );
}
int Count = m_ReqHeaders.Count();
for( int Index = 0; Index < Count; Index++ )
{
m_CurlHeaders = curl_slist_append( m_CurlHeaders, m_ReqHeaders[ Index ].ToAscii() );
}
SetOption( CURLOPT_HTTPHEADER, ( void * ) m_CurlHeaders );
}
}
// -------------------------------------------------------------------------------- //
void guCurl::CleanHeaders()
{
m_ReqHeaders.Clear();
if( m_CurlHeaders )
{
curl_slist_free_all( m_CurlHeaders );
m_CurlHeaders = NULL;
SetOption( CURLOPT_HTTPHEADER, ( void * ) m_CurlHeaders );
}
}
// -------------------------------------------------------------------------------- //
void guCurl::ResetResVars()
{
m_ResHeader = "";
m_ResData = "";
m_ResCode = -1;
}
// -------------------------------------------------------------------------------- //
void guCurl::CurlInit()
{
curl_global_init( CURL_GLOBAL_ALL );
}
// -------------------------------------------------------------------------------- //
void guCurl::CurlDone()
{
curl_global_cleanup();
}
}
// -------------------------------------------------------------------------------- //
| 13,832
|
C++
|
.cpp
| 387
| 31.713178
| 111
| 0.460582
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,679
|
MainApp.h
|
anonbeat_guayadeque/src/MainApp.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __MAINAPP_H__
#define __MAINAPP_H__
#include "Config.h"
#include "DbLibrary.h"
#include "DbCache.h"
#include <wx/app.h>
#include <wx/snglinst.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
class guMainApp : public wxApp
{
protected :
guDbCache * m_DbCache;
guConfig * m_Config;
wxSingleInstanceChecker * m_SingleInstanceChecker;
wxLocale m_Locale;
public:
guMainApp();
~guMainApp();
virtual bool OnInit();
virtual int OnExit();
void OnFatalException();
wxLocale * GetLocale() { return &m_Locale; }
};
}
#endif
// -------------------------------------------------------------------------------- //
| 1,823
|
C++
|
.h
| 48
| 35.895833
| 86
| 0.552915
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,680
|
Settings.h
|
anonbeat_guayadeque/src/Settings.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __SETTINGS_H__
#define __SETTINGS_H__
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
#define guPATH_CONFIG wxGetHomeDir() + wxT( "/.guayadeque/" )
#define guPATH_CONFIG_FILENAME guPATH_CONFIG wxT( "guayadeque.conf" )
#define guPATH_OLD_DBNAME guPATH_CONFIG wxT( "guayadeque.db" )
#define guPATH_DBNAME wxT( "guayadeque.db" )
#define guPATH_DBCACHE guPATH_CONFIG wxT( "cache.db" )
#define guPATH_COLLECTIONS guPATH_CONFIG wxT( "Collections/" )
#define guPATH_LYRICS guPATH_CONFIG wxT( "Lyrics/" )
#define guPATH_LYRICS_SOURCES_FILENAME guPATH_CONFIG wxT( "lyrics_sources.xml" )
#define guPATH_LAYOUTS guPATH_CONFIG wxT( "Layouts/" )
#define guPATH_RADIOS guPATH_CONFIG wxT( "Radios/" )
#define guPATH_RADIOS_DBNAME guPATH_RADIOS wxT( "radios.db" )
#define guPATH_PODCASTS guPATH_CONFIG wxT( "Podcasts/" )
#define guPATH_PODCASTS_DBNAME guPATH_PODCASTS wxT( "podcasts.db" )
#define guPATH_JAMENDO guPATH_COLLECTIONS wxT( "Jamendo/" )
#define guPATH_JAMENDO_COVERS guPATH_JAMENDO wxT( "Covers/" )
#define guPATH_MAGNATUNE guPATH_COLLECTIONS wxT( "Magnatune/" )
#define guPATH_MAGNATUNE_COVERS guPATH_MAGNATUNE wxT( "Covers/" )
#define guPATH_LINKICONS guPATH_CONFIG wxT( "LinkIcons/" )
#define guPATH_PLAYLISTS guPATH_CONFIG wxT( "PlayLists/" )
#define guPATH_DEVICES guPATH_COLLECTIONS
#define guPATH_EQUALIZERS guPATH_CONFIG
#define guPATH_EQUALIZERS_FILENAME guPATH_CONFIG wxT( "equalizers.conf" )
#define guPATH_DEFAULT_RECORDINGS wxGetHomeDir() + wxT( "/Recordings" )
#define guCOPYTO_MAXCOUNT 199
#define guCOPYTO_DEVICE_BASE 100
#define guCOMMANDS_MAXCOUNT 99
#define guLINKS_MAXCOUNT 99
#define guCOLLECTIONS_ID_FILENAME wxT( ".guayadeque" )
#define guCOLLECTIONS_MAXCOUNT 40
// -------------------------------------------------------------------------------- //
// Patterns
// -------------------------------------------------------------------------------- //
#define guLINKS_LANGUAGE wxT( "{lang}" )
#define guLINKS_TEXT wxT( "{text}" )
#define guCOMMAND_ALBUMPATH wxT( "{bp}" )
#define guCOMMAND_COVERPATH wxT( "{bc}" )
#define guCOMMAND_TRACKPATH wxT( "{tp}" )
#define guCOPYTO_ARTIST wxT( "{a}" )
#define guCOPYTO_ARTIST_LOWER wxT( "{al}" )
#define guCOPYTO_ARTIST_UPPER wxT( "{au}" )
#define guCOPYTO_ARTIST_FIRST wxT( "{a1}" )
#define guCOPYTO_ALBUMARTIST wxT( "{aa}" )
#define guCOPYTO_ALBUMARTIST_LOWER wxT( "{aal}" )
#define guCOPYTO_ALBUMARTIST_UPPER wxT( "{aau}" )
#define guCOPYTO_ALBUMARTIST_FIRST wxT( "{aa1}" )
#define guCOPYTO_ANYARTIST wxT( "{A}" )
#define guCOPYTO_ANYARTIST_LOWER wxT( "{Al}" )
#define guCOPYTO_ANYARTIST_UPPER wxT( "{Au}" )
#define guCOPYTO_ANYARTIST_FIRST wxT( "{A1}" )
#define guCOPYTO_ALBUM wxT( "{b}" )
#define guCOPYTO_ALBUM_LOWER wxT( "{bl}" )
#define guCOPYTO_ALBUM_UPPER wxT( "{bu}" )
#define guCOPYTO_ALBUM_FIRST wxT( "{b1}" )
#define guCOPYTO_ALBUM_PATH wxT( "{bp}" )
#define guCOPYTO_COMPOSER wxT( "{c}" )
#define guCOPYTO_COMPOSER_LOWER wxT( "{cl}" )
#define guCOPYTO_COMPOSER_UPPER wxT( "{cu}" )
#define guCOPYTO_COMPOSER_FIRST wxT( "{c1}" )
#define guCOPYTO_FILENAME wxT( "{f}" )
#define guCOPYTO_GENRE wxT( "{g}" )
#define guCOPYTO_GENRE_LOWER wxT( "{gl}" )
#define guCOPYTO_GENRE_UPPER wxT( "{gu}" )
#define guCOPYTO_GENRE_FIRST wxT( "{g1}" )
#define guCOPYTO_NUMBER wxT( "{n}" )
#define guCOPYTO_TITLE wxT( "{t}" )
#define guCOPYTO_TITLE_LOWER wxT( "{tl}" )
#define guCOPYTO_TITLE_UPPER wxT( "{tu}" )
#define guCOPYTO_TITLE_FIRST wxT( "{t1}" )
#define guCOPYTO_YEAR wxT( "{y}" )
#define guCOPYTO_DISC wxT( "{d}" )
#define guCOPYTO_INDEX wxT( "{i}" )
#define guLYRICS_ARTIST wxT( "{a}" )
#define guLYRICS_ARTIST_LOWER wxT( "{al}" )
#define guLYRICS_ARTIST_UPPER wxT( "{au}" )
#define guLYRICS_ARTIST_FIRST wxT( "{a1}" )
#define guLYRICS_ARTIST_LOWER_FIRST wxT( "{al}" )
#define guLYRICS_ARTIST_UPPER_FIRST wxT( "{au}" )
#define guLYRICS_ARTIST_CAPITALIZE wxT( "{as}" )
#define guLYRICS_ALBUM wxT( "{b}" )
#define guLYRICS_ALBUM_LOWER wxT( "{bl}" )
#define guLYRICS_ALBUM_UPPER wxT( "{bu}" )
#define guLYRICS_ALBUM_FIRST wxT( "{b1}" )
#define guLYRICS_ALBUM_LOWER_FIRST wxT( "{bl}" )
#define guLYRICS_ALBUM_UPPER_FIRST wxT( "{bu}" )
#define guLYRICS_ALBUM_CAPITALIZE wxT( "{bs}" )
#define guLYRICS_TITLE wxT( "{t}" )
#define guLYRICS_TITLE_LOWER wxT( "{tl}" )
#define guLYRICS_TITLE_UPPER wxT( "{tu}" )
#define guLYRICS_TITLE_FIRST wxT( "{t1}" )
#define guLYRICS_TITLE_LOWER_FIRST wxT( "{tl}" )
#define guLYRICS_TITLE_UPPER_FIRST wxT( "{tu}" )
#define guLYRICS_TITLE_CAPITALIZE wxT( "{ts}" )
#define guLYRICS_ALBUM_PATH wxT( "{bp}" )
#define guLYRICS_FILENAME wxT( "{f}" )
// -------------------------------------------------------------------------------- //
// Splash
// -------------------------------------------------------------------------------- //
#define guSPLASH_NAME wxT( "J.Rios" )
#define guSPLASH_EMAIL wxT( "anonbeat@gmail.com" )
#define guSPLASH_HOMEPAGE wxT( "http://guayadeque.org" )
#define guSPLASH_DONATION_LINK wxT( "https://goo.gl/GHDEEO" )
// -------------------------------------------------------------------------------- //
// Colors
// -------------------------------------------------------------------------------- //
#define guCOLOR_BASE wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW )
#define guCOLOR_CAPTION_INACTIVE wxSystemSettings::GetColour( wxSYS_COLOUR_INACTIVECAPTION )
#define guCOLOR_CAPTION_ACTIVE wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVECAPTION )
#define guCOLOR_CAPTION_GRADIENT_INACTIVE wxSystemSettings::GetColour( wxSYS_COLOUR_GRADIENTINACTIVECAPTION )
#define guCOLOR_CAPTION_GRADIENT_ACTIVE wxSystemSettings::GetColour( wxSYS_COLOUR_GRADIENTACTIVECAPTION )
#define guCOLOR_CAPTION_TEXT_INACTIVE wxSystemSettings::GetColour( wxSYS_COLOUR_INACTIVECAPTIONTEXT )
#define guCOLOR_CAPTION_TEXT_ACTIVE wxSystemSettings::GetColour( wxSYS_COLOUR_CAPTIONTEXT )
#define guCOLOR_SASH wxAuiStepColour( guCOLOR_BASE, 85 )
#define guSIZE_CAPTION 22
#define guSIZE_BORDER 0
#define guSIZE_SASH 5
#define guGRADIENT_TYPE wxAUI_GRADIENT_VERTICAL
}
#endif
// -------------------------------------------------------------------------------- //
| 8,847
|
C++
|
.h
| 144
| 60.243056
| 111
| 0.529222
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,681
|
DbLibrary.h
|
anonbeat_guayadeque/src/db/DbLibrary.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __DBLIBRARY_H__
#define __DBLIBRARY_H__
#include "Db.h"
#include "Podcasts.h"
// wxWidgets
#include <wx/wx.h>
#include <wx/string.h>
#include <wx/arrstr.h>
#include <wx/utils.h>
#include <wx/filefn.h>
#include <wx/dir.h>
#include <wx/dynarray.h>
namespace Guayadeque {
#define GU_TRACKS_QUERYSTR wxT( "SELECT song_id, song_name, song_genreid, song_genre, song_artistid, song_artist, " \
"song_albumartistid, song_albumartist, song_composerid, song_composer, song_albumid, song_album, " \
"song_pathid, song_path, song_filename, song_format, song_disk, song_number, song_year, song_comment, " \
"song_coverid, song_offset, song_length, song_bitrate, song_rating, song_playcount, " \
"song_addedtime, song_lastplay, song_filesize " \
"FROM songs " )
#define GUCOVER_THUMB_SIZE 38
#define GUCOVER_IMAGE_SIZE 100
// PLAYLISTS
#define guPLAYLIST_TYPE_STATIC 0
#define guPLAYLIST_TYPE_DYNAMIC 1
extern unsigned long DynPLDateOption2[];
#define guTRACK_TYPE_STOP_HERE 0x80000000
enum guTrackType {
guTRACK_TYPE_DB = 0,
guTRACK_TYPE_NOTDB,
guTRACK_TYPE_RADIOSTATION,
guTRACK_TYPE_PODCAST,
guTRACK_TYPE_JAMENDO,
guTRACK_TYPE_MAGNATUNE,
guTRACK_TYPE_IPOD,
guTRACK_TYPE_AUDIOCD
};
enum guTrackMode {
guTRACK_MODE_USER,
guTRACK_MODE_SMART,
guTRACK_MODE_RANDOM,
guTRACK_MODE_RADIO
};
enum guRandomMode {
guRANDOM_MODE_TRACK,
guRANDOM_MODE_ALBUM
};
class guMediaViewer;
class guLibPanel;
class guDbLibrary;
// -------------------------------------------------------------------------------- //
class guTrack
{
public:
guTrackType m_Type;
int m_SongId;
wxString m_SongName;
int m_AlbumId;
wxString m_AlbumName;
int m_ArtistId;
wxString m_ArtistName;
int m_AlbumArtistId;
wxString m_AlbumArtist;
int m_GenreId;
wxString m_GenreName;
int m_PathId;
wxString m_Path;
wxString m_FileName; // mp3 path + filename
unsigned int m_FileSize;
int m_Number; // the track num of the song into the album
int m_Year; // the year of the song
unsigned int m_Length; // the length of the song in seconds
unsigned int m_Offset;
int m_Bitrate;
int m_Rating;
int m_PlayCount;
int m_LastPlay;
int m_AddedTime;
int m_CoverId;
//
wxString m_Disk;
wxString m_Comments;
wxString m_Composer;
int m_ComposerId;
wxString m_Format;
//
guTrackMode m_TrackMode; // Indicate how the track was created
guMediaViewer * m_MediaViewer;
guTrack() {
m_MediaViewer = NULL;
m_Type = guTRACK_TYPE_DB;
m_TrackMode = guTRACK_MODE_USER;
m_Bitrate = 0;
m_Number = 0;
m_Year = 0;
m_Length = 0;
m_Offset = 0;
m_Bitrate = 0;
m_Rating = wxNOT_FOUND;
m_PlayCount = 0;
m_LastPlay = 0;
m_AddedTime = 0;
m_CoverId = 0;
};
virtual ~guTrack() {}
bool ReadFromFile( const wxString &file );
};
WX_DECLARE_OBJARRAY(guTrack, guTrackArray);
// -------------------------------------------------------------------------------- //
class guListItem //: public wxObject
{
public:
int m_Id;
wxString m_Name;
guListItem() {}
guListItem( int NewId, const wxString &NewName = wxEmptyString ) { m_Id = NewId; m_Name = NewName; }
};
WX_DECLARE_OBJARRAY(guListItem,guListItems);
// -------------------------------------------------------------------------------- //
class guArrayListItem //: public wxObject
{
private :
int m_Id;
// wxString m_Name;
wxArrayInt m_Data;
public :
guArrayListItem() { m_Id = -1; }
guArrayListItem( int NewId ) { m_Id = NewId; }
// guArrayListItem( int NewId, const wxString &NewName ) { m_Id = NewId; m_Name = NewName; }
~guArrayListItem() {}
void SetId( int NewId ) { m_Id = NewId; }
void AddData( int m_Id ) { m_Data.Add( m_Id ); }
void DelData( int m_Id ) { m_Data.Remove( m_Id ); }
wxArrayInt GetData( void ) { return m_Data; }
int GetId() { return m_Id; }
int Index( int id ) { return m_Data.Index( id ); }
// const wxString GetName( void ) { return m_Name; }
// void SetName( const wxString &NewName ) { m_Name = NewName; }
};
WX_DECLARE_OBJARRAY(guArrayListItem, guArrayListItems);
// -------------------------------------------------------------------------------- //
class guCoverInfo
{
public:
int m_AlbumId;
wxString m_AlbumName;
wxString m_ArtistName;
wxString m_AlbumPath;
guCoverInfo( const int m_Id, const wxString &Album, const wxString &Artist, const wxString &Path )
{
m_AlbumId = m_Id;
m_AlbumName = Album;
m_ArtistName = Artist;
m_AlbumPath = Path;
}
};
WX_DECLARE_OBJARRAY(guCoverInfo, guCoverInfos);
// -------------------------------------------------------------------------------- //
class guAlbumItem : public guListItem
{
public:
int m_ArtistId;
int m_CoverId;
wxString m_CoverPath;
wxBitmap * m_Thumb;
int m_Year;
wxString m_ArtistName;
guAlbumItem() : guListItem()
{
m_Thumb = NULL;
m_Year = 0;
}
guAlbumItem( int id, const wxString &label ) : guListItem( id, label )
{
m_Thumb = NULL;
m_Year = 0;
};
~guAlbumItem()
{
if( m_Thumb )
delete m_Thumb;
};
};
WX_DECLARE_OBJARRAY(guAlbumItem,guAlbumItems);
enum guTRACKS_ORDER {
guTRACKS_ORDER_NUMBER,
guTRACKS_ORDER_TITLE,
guTRACKS_ORDER_ARTIST,
guTRACKS_ORDER_ALBUMARTIST,
guTRACKS_ORDER_ALBUM,
guTRACKS_ORDER_GENRE,
guTRACKS_ORDER_COMPOSER,
guTRACKS_ORDER_DISK,
guTRACKS_ORDER_LENGTH,
guTRACKS_ORDER_YEAR,
guTRACKS_ORDER_BITRATE,
guTRACKS_ORDER_RATING,
guTRACKS_ORDER_PLAYCOUNT,
guTRACKS_ORDER_LASTPLAY,
guTRACKS_ORDER_ADDEDDATE,
guTRACKS_ORDER_FORMAT,
guTRACKS_ORDER_FILEPATH
};
enum guALBUMS_ORDER {
guALBUMS_ORDER_NAME = 0,
guALBUMS_ORDER_YEAR,
guALBUMS_ORDER_YEAR_REVERSE,
guALBUMS_ORDER_ARTIST_NAME,
guALBUMS_ORDER_ARTIST_YEAR,
guALBUMS_ORDER_ARTIST_YEAR_REVERSE,
guALBUMS_ORDER_ADDEDTIME
};
// -------------------------------------------------------------------------------- //
class guAS_SubmitInfo //guAudioScrobbler_SubmitInfo
{
public:
int m_Id;
wxString m_ArtistName;
wxString m_AlbumName;
wxString m_TrackName;
int m_PlayedTime; // UTC Time since 1/1/1970
wxChar m_Source;
wxChar m_Rating;
int m_TrackLen;
int m_TrackNum;
int m_MBTrackId;
};
WX_DECLARE_OBJARRAY(guAS_SubmitInfo, guAS_SubmitInfoArray);
enum guLIBRARY_FILTER {
guLIBRARY_FILTER_LABELS = 0,
guLIBRARY_FILTER_GENRES,
guLIBRARY_FILTER_COMPOSERS,
guLIBRARY_FILTER_ALBUMARTISTS,
guLIBRARY_FILTER_ARTISTS,
guLIBRARY_FILTER_YEARS,
guLIBRARY_FILTER_ALBUMS,
guLIBRARY_FILTER_RATINGS,
guLIBRARY_FILTER_PLAYCOUNTS,
guLIBRARY_FILTER_SONGS
};
class guDynPlayList;
class guAlbumBrowserItemArray;
class guTreeViewFilterArray;
class guCurrentTrack;
// -------------------------------------------------------------------------------- //
class guDbLibrary : public guDb
{
private :
wxString m_LastAlbum;
int m_LastAlbumId;
wxString m_LastGenre;
int m_LastGenreId;
int m_LastCoverId;
wxString m_LastCoverPath;
guListItems m_LastItems;
wxString m_LastPath;
int m_LastPathId;
wxString m_LastArtist;
int m_LastArtistId;
wxString m_LastAlbumArtist;
int m_LastAlbumArtistId;
wxString m_LastComposer;
int m_LastComposerId;
protected :
guMediaViewer * m_MediaViewer;
// wxString m_ConfigPath;
bool m_NeedUpdate;
// Library Filter Options
wxArrayInt m_GeFilters;
wxArrayInt m_LaFilters; // Label
wxArrayInt m_CoFilters; // Composers
wxArrayInt m_AAFilters; // AlbumArtist
wxArrayInt m_ArFilters; // Artist
wxArrayInt m_AlFilters; // Album
wxArrayString m_TeFilters; // Text string filters
wxArrayInt m_YeFilters; // Year
wxArrayInt m_RaFilters; // Ratting
wxArrayInt m_PcFilters; // PlayCount
int m_TracksOrder;
bool m_TracksOrderDesc;
int m_AlbumsOrder; // 0 ->
wxArrayString m_CoverSearchWords;
wxString FiltersSQL( int Level );
void inline FillTrackFromDb( guTrack * Song, wxSQLite3ResultSet * dbRes );
public :
guDbLibrary();
guDbLibrary( const wxString &DbName );
guDbLibrary( guDb * db );
~guDbLibrary();
virtual int GetDbVersion( void );
// void ConfigChanged( void );
bool NeedUpdate( void ) { return m_NeedUpdate; }
guMediaViewer * GetMediaViewer( void ) { return m_MediaViewer; }
void SetMediaViewer( guMediaViewer * mediaviewer );
//void DoCleanUp( void );
void CleanItems( const wxArrayInt &tracks, const wxArrayInt &covers );
void CleanFiles( const wxArrayString &files );
virtual bool CheckDbVersion( void );
//void LoadCache( void );
int GetGenreId( wxString &GenreName );
int GetComposerId( wxString &composername, bool create = true );
const wxString GetArtistName( const int ArtistId );
int GetArtistId( wxString &ArtistName, bool Create = true );
int GetAlbumArtistId( wxString &albumartist, bool create = true );
int AddCoverImage( const wxImage &image );
int AddCoverFile( const wxString &coverfile, const wxString &coverhash = wxEmptyString );
void UpdateCoverFile( int coverid, const wxString &coverfile, const wxString &coverhash );
// int FindCoverFile( const wxString &DirName );
int SetAlbumCover( const int AlbumId, const wxString & CoverPath, const wxString &coverhash = wxEmptyString );
int SetAlbumCover( const int AlbumId, const wxImage &image );
bool GetAlbumInfo( const int AlbumId, wxString * AlbumName, wxString * ArtistName, wxString * AlbumPath );
int GetAlbumCoverId( const int AlbumId );
wxString GetCoverPath( const int CoverId );
int GetAlbumId( wxString &AlbumName, const int ArtistId, const int PathId, const wxString &Path, const int coverid = 0 );
int GetSongId( wxString &filename, const int pathid, const time_t filedate, const int start = 0, bool * created = NULL );
int GetSongId( wxString &FileName, wxString &FilePath, const time_t filedate, const int start = 0, bool * created = NULL );
wxArrayInt GetLabelIds( const wxArrayString &Labels );
wxArrayString GetLabelNames( const wxArrayInt &LabelIds );
int GetLabelId( int * LabelId, wxString &LabelName );
int PathExists( const wxString &path );
int GetPathId( wxString &PathValue );
virtual int UpdateSong( const guTrack &track, const bool allowrating = false );
int AddFiles( const wxArrayString &files );
void GetGenres( guListItems * Genres, const bool FullList = false );
void GetLabels( guListItems * Labels, const bool FullList = false );
void GetArtists( guListItems * Artists, const bool FullList = false );
void GetYears( guListItems * items, const bool FullList = false );
void GetRatings( guListItems * items, const bool FullList = false );
void GetPlayCounts( guListItems * items, const bool FullList = false );
void GetAlbumArtists( guListItems * items, const bool FullList = false );
void GetComposers( guListItems * items, const bool FullList = false );
void SetAlbumsOrder( const int order );
int GetAlbumsOrder( void ) { return m_AlbumsOrder; }
void GetAlbums( guListItems * Albums, bool FullList = false );
void GetAlbums( guAlbumItems * Albums, bool FullList = false );
wxArrayString GetAlbumsPaths( const wxArrayInt &AlbumIds );
int GetAlbums( guAlbumBrowserItemArray * items, guDynPlayList * filter,
const wxArrayString &textfilters, const int start, const int count, const int order );
int GetAlbumsCount( guDynPlayList * filter, const wxArrayString &textfilters );
bool GetAlbumDetails( const int albumid, int * year, int * trackcount );
int GetAlbumYear( const int albumid );
int GetAlbumTrackCount( const int albumid );
void GetPaths( guListItems * Paths, bool FullList = false );
bool GetSong( const int songid, guTrack * song );
void GetSongsCounters( const guTreeViewFilterArray &filters, const wxArrayString &textfilters, wxLongLong * count, wxLongLong * len, wxLongLong * size );
int GetSongs( const guTreeViewFilterArray &filters, guTrackArray * Songs, const wxArrayString &textfilters, const int order, const bool orderdesc );
int GetSongs( const wxArrayInt &SongIds, guTrackArray * Songs );
int GetSongsCount( void );
int GetSongs( guTrackArray * Songs, const int start, const int end );
int GetSongsId( const int start );
wxString GetSongsName( const int start );
void GetTracksCounters( wxLongLong * count, wxLongLong * len, wxLongLong * size );
void DeleteLibraryTracks( const guTrackArray * tracks, const bool savedeleted );
bool FindDeletedFile( const wxString &file, const bool create );
int GetTracksOrder( void ) const { return m_TracksOrder; }
void SetTracksOrder( const int order ) { m_TracksOrder = order; }
bool GetTracksOrderDesc( void ) const { return m_TracksOrderDesc; }
void SetTracksOrderDesc( const bool orderdesc ) { m_TracksOrderDesc = orderdesc; }
void UpdateSongs( const guTrackArray * Songs, const wxArrayInt &changedflags );
void UpdateTracksWithValue( guTrackArray * tracks, const int fieldid, void * value );
void UpdateTrackLength( const int trackid, const int length );
void UpdateTrackBitRate( const int trackid, const int bitrate );
int GetAlbumsSongs( const wxArrayInt &Albums, guTrackArray * Songs, bool ordertoedit = false );
int GetArtistsSongs( const wxArrayInt &Artists, guTrackArray * Songs,
guTrackMode trackmode = guTRACK_MODE_USER );
int GetArtistsSongs( const wxArrayInt &Artists, guTrackArray * Songs,
const int count, const int filterallow, const int filterdeny );
int GetArtistsAlbums( const wxArrayInt &Artists, wxArrayInt * Albums );
int GetAlbumArtistsAlbums( const wxArrayInt &albumartists, wxArrayInt * Albums );
int GetGenresSongs( const wxArrayInt &Genres, guTrackArray * Songs );
int GetRandomTracks( guTrackArray * Tracks, const int count, const int rndmode,
const int allowplaylist, const int denyplaylist );
int GetLabelsSongs( const wxArrayInt &Labels, guTrackArray * Songs );
int AddLabel( wxString LabelName );
int SetLabelName( const int labelid, const wxString &oldlabel, const wxString &newlabel );
int DelLabel( const int LabelId );
wxArrayInt GetLabels( void );
int GetStaticPlayList( const wxString &name );
virtual int CreateStaticPlayList( const wxString &name, const wxArrayInt &tracks );
virtual int UpdateStaticPlayList( const int plid, const wxArrayInt &tracks );
virtual int AppendStaticPlayList( const int plid, const wxArrayInt &tracks );
virtual void UpdateStaticPlayListFile( const int plid );
virtual int DelPlaylistSetIds( const int plid, const wxArrayInt &setids );
int GetPlayListFiles( const int plid, wxFileDataObject * Files );
int GetPlayListsCount( void );
void GetPlayLists( guListItems &playlists );
void GetPlayLists( wxArrayString &playlistnames );
void GetPlayLists( wxArrayInt &playlistids );
void GetPlayLists( guListItems * PlayLists, const int type, const wxArrayString * textfilters = NULL );
int GetPlayListSongIds( const int plid, wxArrayInt * tracks );
int GetPlayListSongs( const int plid, guTrackArray * tracks );
int GetPlayListSongs( const int plid, const int pltype, guTrackArray * tracks,
wxArrayInt * setids = NULL, wxLongLong * len = NULL, wxLongLong * size = NULL,
const int order = wxNOT_FOUND, const bool orderdesc = false );
int GetPlayListSongs( const wxArrayInt &ids, const wxArrayInt &types, guTrackArray * tracks,
wxArrayInt * setids = NULL, wxLongLong * len = NULL, wxLongLong * size = NULL,
const int order = wxNOT_FOUND, const bool orderdesc = false );
int GetPlayListSetIds( const int plid, wxArrayInt * setids );
int GetPlayListSetIds( const wxArrayInt &plid, wxArrayInt * setids );
virtual void DeletePlayList( const int plid );
virtual void SetPlayListName( const int plid, const wxString &plname );
wxString GetPlayListName( const int plid );
wxString GetPlayListPath( const int plid );
void SetPlayListPath( const int plid, const wxString &path );
void GetDynamicPlayList( const int plid, guDynPlayList * playlist );
virtual int CreateDynamicPlayList( const wxString &name, const guDynPlayList * playlist );
virtual void UpdateDynamicPlayList( const int plid, const guDynPlayList * playlist );
wxString GetPlayListQuery( const int plid );
int GetPlayListType( const int plid );
// void SetLibPath( const wxArrayString &NewPaths );
int ReadFileTags( const wxString &filename, const bool allowrating = false );
void UpdateImageFile( const char * filename, const char * saveto,
const wxBitmapType type = wxBITMAP_TYPE_JPEG, const int maxsize = wxNOT_FOUND );
int GetFiltersCount() const;
void SetTeFilters( const wxArrayString &tefilters, const bool locked );
void SetGeFilters( const wxArrayInt &filters, const bool locked );
void SetLaFilters( const wxArrayInt &filters, const bool locked );
void SetArFilters( const wxArrayInt &filters, const bool locked );
void SetAlFilters( const wxArrayInt &filters, const bool locked );
void SetYeFilters( const wxArrayInt &filter, const bool locked );
void SetRaFilters( const wxArrayInt &filter );
void SetPcFilters( const wxArrayInt &filter );
void SetCoFilters( const wxArrayInt &filter, const bool locked );
void SetAAFilters( const wxArrayInt &filter, const bool locked );
//
guArrayListItems GetArtistsLabels( const wxArrayInt &Artists );
guArrayListItems GetAlbumsLabels( const wxArrayInt &Albums );
guArrayListItems GetSongsLabels( const wxArrayInt &Songs );
void SetArtistsLabels( const wxArrayInt &Artists, const wxArrayInt &Labels );
void SetAlbumsLabels( const wxArrayInt &Albums, const wxArrayInt &Labels );
void SetSongsLabels( const wxArrayInt &Songs, const wxArrayInt &Labels );
virtual void UpdateArtistsLabels( const guArrayListItems &labelsets );
virtual void UpdateAlbumsLabels( const guArrayListItems &labelsets );
virtual void UpdateSongsLabels( const guArrayListItems &labelsets );
virtual void UpdateSongLabel( const guTrack &tracks, const wxString &label, const wxString &newlabel );
virtual void UpdateSongsLabel( const guTrackArray &tracks, const wxString &label, const wxString &newlabel );
void SetTrackRating( const int songid, const int rating, const bool writetags = false );
void SetTracksRating( const wxArrayInt &songids, const int rating, const bool writetags = false );
void SetTracksRating( const guTrackArray * tracks, const int rating, const bool writetags = false );
void SetTrackPlayCount( const int songid, const int playcount, const bool writetags = false );
int GetYearsSongs( const wxArrayInt &Years, guTrackArray * Songs );
int GetRatingsSongs( const wxArrayInt &Ratings, guTrackArray * Songs );
int GetPlayCountsSongs( const wxArrayInt &PlayCounts, guTrackArray * Songs );
int GetComposersSongs( const wxArrayInt &Composers, guTrackArray * Songs );
int GetAlbumArtistsSongs( const wxArrayInt &albumartists, guTrackArray * tracks );
wxBitmap * GetCoverBitmap( const int coverid, const bool thumb = true );
int GetEmptyCovers( guCoverInfos &coverinfos );
// Smart Playlist and LastFM Panel support functions
int FindArtist( const wxString &Artist );
int FindAlbum( const wxString &Artist, const wxString &Album );
int FindTrack( const wxString &Artist, const wxString &m_Name );
int GetTrackIndex( const int trackid );
guTrack * FindSong( const wxString &artist, const wxString &track,
const int filterallow, const int filterdeny );
int FindTrackFile( const wxString &filename, guTrack * track );
int FindTrackId( const int trackid, guTrack * track );
//
// AudioScrobbler functions
//
bool AddCachedPlayedSong( const guCurrentTrack &Song );
guAS_SubmitInfoArray GetCachedPlayedSongs( int MaxCount = 10 );
bool DeleteCachedPlayedSongs( const guAS_SubmitInfoArray &SubmitInfo );
// File Browser related functions
void UpdateTrackFileName( const wxString &oldname, const wxString &newname );
void UpdatePaths( const wxString &oldpath, const wxString &newpath );
};
// -------------------------------------------------------------------------------- //
// Array Functions
// -------------------------------------------------------------------------------- //
int guAlbumItemSearch( const guAlbumItems &Items, int StartPos, int EndPos, int m_Id );
wxString guAlbumItemsGetName( const guAlbumItems &Items, int m_Id );
int guAlbumItemsGetCoverId( const guAlbumItems &Items, int m_Id );
int guListItemSearch( const guListItems &Items, int StartPos, int EndPos, int m_Id );
wxString guListItemsGetName( const guListItems &Items, int m_Id );
wxArrayInt GetArraySameItems( const wxArrayInt &Source, const wxArrayInt &Oper );
wxArrayInt GetArrayDiffItems( const wxArrayInt &Source, const wxArrayInt &Oper );
wxString TextFilterToSQL( const wxArrayString &TeFilters );
wxString LabelFilterToSQL( const wxArrayInt &LaFilters );
// -------------------------------------------------------------------------------- //
wxString inline ArrayIntToStrList( const wxArrayInt &Data )
{
wxString RetVal = wxT( "(" );
int count = Data.Count();
for( int index = 0; index < count; index++ )
{
RetVal += wxString::Format( wxT( "%u," ), Data[ index ] );
}
if( RetVal.Length() > 1 )
RetVal = RetVal.RemoveLast() + wxT( ")" );
else
RetVal += wxT( ")" );
return RetVal;
}
// -------------------------------------------------------------------------------- //
wxString inline ArrayToFilter( const wxArrayInt &Filters, const wxString &VarName )
{
return VarName + wxT( " IN " ) + ArrayIntToStrList( Filters );
}
// -------------------------------------------------------------------------------- //
void inline guDbLibrary::FillTrackFromDb( guTrack * Song, wxSQLite3ResultSet * dbRes )
{
/*
#define GU_TRACKS_QUERYSTR wxT( "SELECT song_id, song_name, song_genreid, song_genre, song_artistid, song_artist, " \
"song_albumartistid, song_albumartist, song_composerid, song_composer, song_albumid, song_album, " \
"song_pathid, song_path, song_filename, song_format, song_disk, song_number, song_year, song_comment, " \
"song_coverid, song_offset, song_length, song_bitrate, song_rating, song_playcount, " \
"song_addedtime, song_lastplay, song_filesize " \
"FROM songs " )
*/
Song->m_SongId = dbRes->GetInt( 0 );
Song->m_SongName = dbRes->GetString( 1 );
Song->m_GenreId = dbRes->GetInt( 2 );
Song->m_GenreName = dbRes->GetString( 3 );
Song->m_ArtistId = dbRes->GetInt( 4 );
Song->m_ArtistName = dbRes->GetString( 5 );
Song->m_AlbumArtistId = dbRes->GetInt( 6 );
Song->m_AlbumArtist = dbRes->GetString( 7 );
Song->m_ComposerId = dbRes->GetInt( 8 );
Song->m_Composer = dbRes->GetString( 9 );
Song->m_AlbumId = dbRes->GetInt( 10 );
Song->m_AlbumName = dbRes->GetString( 11 );
Song->m_PathId = dbRes->GetInt( 12 );
Song->m_Path = dbRes->GetString( 13 );
Song->m_FileName = Song->m_Path + dbRes->GetString( 14 );
Song->m_Format = dbRes->GetString( 15 );
Song->m_Disk = dbRes->GetString( 16 );
Song->m_Number = dbRes->GetInt( 17 );
Song->m_Year = dbRes->GetInt( 18 );
Song->m_Comments = dbRes->GetString( 19 );
Song->m_CoverId = dbRes->GetInt( 20 );
Song->m_Offset = dbRes->GetInt( 21 );
Song->m_Length = dbRes->GetInt( 22 );
Song->m_Bitrate = dbRes->GetInt( 23 );
Song->m_Rating = dbRes->GetInt( 24 );
Song->m_PlayCount = dbRes->GetInt( 25 );
Song->m_AddedTime = dbRes->GetInt( 26 );
Song->m_LastPlay = dbRes->GetInt( 27 );
Song->m_FileSize = dbRes->GetInt( 28 );
Song->m_MediaViewer = m_MediaViewer;
}
}
#endif
// -------------------------------------------------------------------------------- //
| 28,801
|
C++
|
.h
| 563
| 46.138544
| 172
| 0.596719
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,682
|
DbListBox.h
|
anonbeat_guayadeque/src/db/DbListBox.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __DBLISTBOX_H__
#define __DBLISTBOX_H__
// -------------------------------------------------------------------------------- //
guDbListBoxCache : public wxObject
{
private :
DbLibrary * Db;
public :
guDbListBoxCache( DbLibrary * db );
};
// -------------------------------------------------------------------------------- //
// This is the shown title bar
guDbListBoxHeader : public wxWindow
{
private :
wxString LabelFormat;
wxString LabelStr;
public :
};
// -------------------------------------------------------------------------------- //
// This is really the listbox conainted into the virtual control
guDbListBoxItems : public wxVListBox
{
private :
wxPoint DragStart;
int DragCount;
wxColor SelBgColor;
wxColor SelFgColor;
wxColor OddBgColor;
wxColor EveBgColor;
wxColor TextFgColor;
wxColor SepColor;
void OnDragOver( const wxCoord x, const wxCoord y );
void OnDrawItem( wxDC &dc, const wxRect &rect, size_t n ) const;
wxCoord OnMeasureItem( size_t n ) const;
void OnDrawBackground( wxDC &dc, const wxRect &rect, size_t n ) const;
void OnKeyDown( wxKeyEvent &event );
void OnBeginDrag( wxMouseEvent &event );
void OnMouse( wxMouseEvent &event );
void OnContextMenu( wxContextMenuEvent& event );
DECLARE_EVENT_TABLE()
friend class guAlbumListBoxTimer;
public :
};
// -------------------------------------------------------------------------------- //
// this is a container class for the header, cache and listbox
guDbListBox : public wxScrolledWindow
{
private :
DbLibrary * Db;
guDbListBoxHeader * ListBoxHeader;
guDbListBoxCache * ListBoxCache;
guDbListBoxItems * ListBoxItems;
public :
guDbListBox( wxWindow * parent, DbLibrary * db, const wxString &label );
~guDbListBox();
void ReloadItems( void );
wxArrayInt GetSelection( void ) const;
// Return the Tracks from the library selected by the current selection of this control
int GetSelectedTracks( guTrackArray * Tracks ) const;
};
#endif
// -------------------------------------------------------------------------------- //
| 3,545
|
C++
|
.h
| 84
| 38.142857
| 91
| 0.529617
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,683
|
DbRadios.h
|
anonbeat_guayadeque/src/db/DbRadios.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __DBRADIOS_H__
#define __DBRADIOS_H__
#include "DbLibrary.h"
#include <wx/dynarray.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
class guRadioStation
{
public :
int m_Id;
int m_SCId;
wxString m_Name;
wxString m_Link;
int m_GenreId;
wxString m_GenreName;
int m_Source;
wxString m_Type;
int m_BitRate;
int m_Listeners;
wxString m_NowPlaying;
};
WX_DECLARE_OBJARRAY(guRadioStation,guRadioStations);
enum guRadioSource {
guRADIO_SOURCE_SHOUTCAST_GENRE = 0,
guRADIO_SOURCE_USER,
guRADIO_SOURCE_SHOUTCAST_SEARCH,
guRADIO_SOURCE_TUNEIN
};
enum guRADIOSTATION_ORDER {
guRADIOSTATIONS_ORDER_NAME = 0,
guRADIOSTATIONS_ORDER_BITRATE,
guRADIOSTATIONS_ORDER_LISTENERS,
guRADIOSTATIONS_ORDER_TYPE,
guRADIOSTATIONS_ORDER_NOWPLAYING
};
// -------------------------------------------------------------------------------- //
class guDbRadios : public guDb
{
protected :
// guDb * m_Db;
int m_StationsOrder; // 0 -> Name, 1 -> BitRate, 2 -> Listeners
bool m_StationsOrderDesc;
// Radio Filters Options
wxArrayInt m_RaGeFilters;
int m_RadioSource;
wxArrayInt m_RaLaFilters;
wxArrayString m_RaTeFilters;
int GetRadioFiltersCount( void ) const;
wxString RadioFiltersSQL( void );
public :
guDbRadios( const wxString &dbname );
~guDbRadios();
int GetRadioLabelsSongs( const wxArrayInt &Labels, guTrackArray * Songs );
int AddRadioLabel( wxString LabelName );
int SetRadioLabelName( const int LabelId, wxString NewName );
int DelRadioLabel( const int LabelId );
wxArrayInt GetRadioLabels( void );
void GetRadioLabels( guListItems * Labels, const bool FullList = false );
//
// Radio support functions
//
void SetRaTeFilters( const wxArrayString &filters );
void SetRadioLabelsFilters( const wxArrayInt &filters );
void SetRadioGenresFilters( const wxArrayInt &filters );
void SetRadioSourceFilter( int source );
void GetRadioGenresList( const int source, const wxArrayInt &ids, guListItems * listitems, wxArrayInt * radioflags = NULL );
void GetRadioGenres( const int source, guListItems * radiogenres, bool allowfilter = true, wxArrayInt * radioflags = NULL );
void SetRadioGenres( const wxArrayString &Genres );
int GetRadioStations( guRadioStations * stations );
// void GetRadioCounter( wxLongLong * count );
int GetUserRadioStations( guRadioStations * stations );
void SetRadioStation( const guRadioStation * RadioStation );
bool GetRadioStation( const int id, guRadioStation * radiostation );
bool RadioStationExists( const int shoutcastid );
void SetRadioStations( const guRadioStations * RadioStations );
wxArrayInt GetStationsSCIds( const wxArrayInt &stations );
guArrayListItems GetStationsLabels( const wxArrayInt &Stations );
void SetRadioStationsLabels( const guArrayListItems &labelsets );
int DelRadioStations( const int source, const wxArrayInt &radioids );
int DelRadioStation( const int radioid );
void SetRadioStationsOrder( int OrderValue );
int AddRadioGenre( const wxString &name, const int source, const int flags );
int SetRadioGenre( const int id, const wxString &name, const int source = guRADIO_SOURCE_SHOUTCAST_GENRE,
const int flags = 0 );
int DelRadioGenre( const int GenreId );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 5,312
|
C++
|
.h
| 110
| 44.427273
| 147
| 0.573192
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,684
|
Db.h
|
anonbeat_guayadeque/src/db/Db.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __DB_H__
#define __DB_H__
#include "Utils.h"
// wxWidgets
#include <wx/string.h>
#include <wx/utils.h>
// wxSqlite3
#include <wx/wxsqlite3.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
void inline escape_query_str( wxString * Str )
{
Str->Replace( wxT( "'" ), wxT( "''" ) );
//Str->Replace( _T( "\"" ), _T( "\"\"" ) );
//Str->Replace( _T( "\\" ), _T( "\\\\" ) );
}
// -------------------------------------------------------------------------------- //
wxString inline escape_query_str( const wxString &str )
{
wxString QueryStr = str;
escape_query_str( &QueryStr );
//guLogMessage( wxT( "'%s' --> '%s'" ), str.c_str(), QueryStr.c_str() );
return QueryStr;
}
// -------------------------------------------------------------------------------- //
class guDb
{
protected :
wxString m_DbName;
wxSQLite3Database * m_Db;
public :
guDb( void );
guDb( const wxString &dbname );
virtual ~guDb();
int Open( const wxString &dbname );
int Close( void );
wxSQLite3Database * GetDb( void ) { return m_Db; }
wxSQLite3ResultSet ExecuteQuery( const wxString &query );
int ExecuteUpdate( const wxString &query );
wxSQLite3ResultSet ExecuteQuery( const wxSQLite3StatementBuffer &query );
int ExecuteUpdate( const wxSQLite3StatementBuffer &query );
int GetLastRowId( void ) { return m_Db->GetLastRowId().GetLo(); }
virtual void SetInitParams( void );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 2,754
|
C++
|
.h
| 68
| 38.088235
| 86
| 0.520584
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,685
|
DbCache.h
|
anonbeat_guayadeque/src/db/DbCache.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __DBCACHE_H__
#define __DBCACHE_H__
#include "Db.h"
#include <wx/image.h>
namespace Guayadeque {
enum guDBCacheTypes {
guDBCACHE_TYPE_TEXT = 0x45545458,
guDBCACHE_TYPE_IMAGE_SIZE_TINY = 0,
guDBCACHE_TYPE_IMAGE_SIZE_MID,
guDBCACHE_TYPE_IMAGE_SIZE_BIG,
guDBCACHE_TYPE_LASTFM,
guDBCACHE_TYPE_SHOUTCAST,
guDBCACHE_TYPE_TUNEIN
};
// -------------------------------------------------------------------------------- //
class guDbCache : public guDb
{
private :
static guDbCache * m_DbCache;
protected :
bool DoSetImage( const wxString &url, wxImage * img, const wxBitmapType imgtype, int imagesize );
public :
guDbCache( const wxString &dbname );
~guDbCache();
wxImage * GetImage( const wxString &url, wxBitmapType &imagetype, const int imagesize );
bool SetImage( const wxString &url, wxImage * img, const wxBitmapType imgtype );
wxString GetContent( const wxString &url );
bool SetContent( const wxString &url, const char * str, const int len );
bool SetContent( const wxString &url, const wxString &content, const int type = guDBCACHE_TYPE_TEXT );
static guDbCache * GetDbCache( void ) { return m_DbCache; }
void SetDbCache( void ) { m_DbCache = this; }
void ClearExpired( void );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 2,532
|
C++
|
.h
| 57
| 41.77193
| 121
| 0.587089
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,686
|
mmkeys.h
|
anonbeat_guayadeque/src/dbus/mmkeys.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __MMKEYS_H__
#define __MMKEYS_H__
#include "gudbus.h"
#include "PlayerPanel.h"
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
class guMMKeys : public guDBusClient
{
protected :
guPlayerPanel * m_PlayerPanel;
public :
guMMKeys( guDBusServer * server, guPlayerPanel * playerpanel );
~guMMKeys();
virtual DBusHandlerResult HandleMessages( guDBusMessage * msg, guDBusMessage * reply = NULL );
void GrabMediaPlayerKeys( const unsigned int time );
void ReleaseMediaPlayerKeys( void );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 1,807
|
C++
|
.h
| 41
| 42.170732
| 104
| 0.555492
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,687
|
gsession.h
|
anonbeat_guayadeque/src/dbus/gsession.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __GSESSION_H__
#define __GSESSION_H__
#include "gudbus.h"
#include <wx/wx.h>
namespace Guayadeque {
typedef enum {
guGSESSION_STATUS_ERROR = -1,
guGSESSION_STATUS_REGISTER_CLIENT = 0,
guGSESSION_STATUS_INITIALIZED,
guGSESSION_STATUS_QUERY_END_SESSION,
guGSESSION_STATUS_END_SESSION,
guGSESSION_STATUS_ENDED_SESSION,
guGSESSION_STATUS_UNREGISTER
} guGSessionStatus;
// -------------------------------------------------------------------------------- //
class guGSession : public guDBusClient
{
protected :
int m_Status;
wxString m_ObjectPath;
public :
guGSession( guDBusServer * server );
~guGSession();
virtual DBusHandlerResult HandleMessages( guDBusMessage * msg, guDBusMessage * reply = NULL );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 1,925
|
C++
|
.h
| 49
| 37.020408
| 100
| 0.59164
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,688
|
mpris.h
|
anonbeat_guayadeque/src/dbus/mpris.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __MPRIS_H__
#define __MPRIS_H__
#include "gudbus.h"
#include "PlayerPanel.h"
namespace Guayadeque {
#define GUAYADEQUE_MPRIS_SERVICENAME "org.mpris.guayadeque"
#define GUAYADEQUE_MPRIS_INTERFACE "org.freedesktop.MediaPlayer"
#define GUAYADEQUE_MPRIS_ROOT_PATH "/"
#define GUAYADEQUE_MPRIS_PLAYER_PATH "/Player"
#define GUAYADEQUE_MPRIS_TRACKLIST_PATH "/TrackList"
#define GUAYADEQUE_MPRIS_VERSION_MAJOR 1
#define GUAYADEQUE_MPRIS_VERSION_MINOR 0
#define MPRIS_CAPS_NONE 0
#define MPRIS_CAPS_CAN_GO_NEXT ( 1 << 0 )
#define MPRIS_CAPS_CAN_GO_PREV ( 1 << 1 )
#define MPRIS_CAPS_CAN_PAUSE ( 1 << 2 )
#define MPRIS_CAPS_CAN_PLAY ( 1 << 3 )
#define MPRIS_CAPS_CAN_SEEK ( 1 << 4 )
#define MPRIS_CAPS_CAN_PROVIDE_METADATA ( 1 << 5 )
#define MPRIS_CAPS_CAN_HAS_TRACKLIST ( 1 << 6 )
// -------------------------------------------------------------------------------- //
class guMPRIS : public guDBusClient
{
protected :
guPlayerPanel * m_PlayerPanel;
public :
guMPRIS( guDBusServer * server, guPlayerPanel * playerpanel );
virtual ~guMPRIS();
virtual DBusHandlerResult HandleMessages( guDBusMessage * msg, guDBusMessage * reply = NULL );
virtual void OnPlayerTrackChange();
virtual void OnPlayerStatusChange();
virtual void OnPlayerCapsChange();
virtual void OnTrackListChange();
};
}
#endif
// -------------------------------------------------------------------------------- //
| 2,658
|
C++
|
.h
| 58
| 44
| 100
| 0.586167
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,689
|
notify.h
|
anonbeat_guayadeque/src/dbus/notify.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __NOTIFY_H__
#define __NOTIFY_H__
#include "gudbus.h"
#include <wx/wx.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
class guDBusNotify : public guDBusClient
{
protected:
int m_MsgId;
public :
guDBusNotify( guDBusServer * server );
~guDBusNotify();
virtual DBusHandlerResult HandleMessages( guDBusMessage * msg, guDBusMessage * reply = NULL );
void Notify( const wxString &icon, const wxString &summary,
const wxString &body, wxImage * image, bool newnotify = false );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 1,746
|
C++
|
.h
| 41
| 40.268293
| 100
| 0.567552
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,690
|
mpris2.h
|
anonbeat_guayadeque/src/dbus/mpris2.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __MPRIS2_H__
#define __MPRIS2_H__
#include "gudbus.h"
#include "PlayerPanel.h"
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
class guMPRIS2 : public guDBusClient
{
protected :
static guMPRIS2 * m_MPRIS2;
guPlayerPanel * m_PlayerPanel;
guDbLibrary * m_Db;
private :
bool GetPlaylists( DBusMessage * msg, const dbus_int32_t start, const dbus_int32_t maxcount,
const char * order, const dbus_bool_t reverseorder );
public :
guMPRIS2( guDBusServer * server, guPlayerPanel * playerpanel, guDbLibrary * db );
~guMPRIS2();
virtual DBusHandlerResult HandleMessages( guDBusMessage * msg, guDBusMessage * reply = NULL );
void OnPlayerTrackChange( void );
void OnPlayerStatusChange( void );
void OnPlayerCapsChange( void );
void OnPlayerVolumeChange( void );
void OnTrackListChange( void );
void OnFullscreenChanged( void );
void OnPlayerSeeked( const unsigned int newpos );
bool Indicators_Sound_Available( void );
int Indicators_Sound_BlacklistMediaPlayer( const dbus_bool_t blacklist = true );
int Indicators_Sound_IsBlackListed( void );
static void Set( guMPRIS2 * object ) { m_MPRIS2 = object; }
static guMPRIS2 * Get( void ) { return m_MPRIS2; }
const char ** GetSupportedMimeTypes( void );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 2,836
|
C++
|
.h
| 57
| 46.578947
| 108
| 0.546638
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,691
|
gudbus.h
|
anonbeat_guayadeque/src/dbus/gudbus.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __DBUS_H__
#define __DBUS_H__
#include <dbus/dbus.h>
#include <wx/dynarray.h>
#include <wx/thread.h>
namespace Guayadeque {
#define guDBUS_THREAD_IDLE_TIMEOUT 50
#define guDBUS_DEFAULT_SEND_TIMEOUT 1000
class guDBusThread;
// -------------------------------------------------------------------------------- //
class guDBusMessage
{
protected :
DBusMessage * m_DBusMsg;
public :
guDBusMessage( void ) { m_DBusMsg = NULL; }
guDBusMessage( int type );
guDBusMessage( DBusMessage * msg );
guDBusMessage( guDBusMessage * msg );
virtual ~guDBusMessage();
DBusMessage * GetMessage();
int GetType();
const char * GetErrorName();
const char * GetInterface();
const char * GetMember();
bool NeedReply();
void SetNoReply( const bool needreply );
const char * GetPath();
unsigned int GetReplySerial();
const char * GetSender();
const char * GetDestination();
unsigned int GetSerial();
bool HasDestination( const char * dest );
bool HasInterface( const char * iface );
bool HasMember( const char * member );
bool HasPath( const char * member );
bool HasSender( const char * member );
bool IsError( const char * errname );
bool IsMethodCall( const char * iface, const char * method );
bool IsSignal( const char * iface, const char * signal_name );
const char * GetObjectPath();
};
// -------------------------------------------------------------------------------- //
class guDBusMethodCall : public guDBusMessage
{
public :
guDBusMethodCall( const char * dest, const char * path, const char *iface, const char * method );
};
// -------------------------------------------------------------------------------- //
class guDBusMethodReturn : public guDBusMessage
{
public :
guDBusMethodReturn( guDBusMessage * msg );
guDBusMethodReturn( DBusMessage * msg );
};
// -------------------------------------------------------------------------------- //
class guDBusSignal : public guDBusMessage
{
public:
guDBusSignal( const char * path, const char * iface, const char * name );
//~guDBusSignal();
};
class guDBusServer;
// -------------------------------------------------------------------------------- //
class guDBusClient
{
protected :
guDBusServer * m_DBusServer;
bool RegisterClient( void );
bool UnRegisterClient( void );
public :
guDBusClient( guDBusServer * server );
virtual ~guDBusClient();
bool HasOwner( const char * name );
bool RequestName( const char * name );
virtual DBusHandlerResult HandleMessages( guDBusMessage * msg, guDBusMessage * reply = NULL );
DBusConnection * GetConnection();
bool RegisterObjectPath( const char * objname );
bool UnRegisterObjectPath( const char * objname );
bool AddMatch( const char * rule );
bool Send( guDBusMessage * msg );
bool SendWithReply( guDBusMessage * msg, int timeout = guDBUS_DEFAULT_SEND_TIMEOUT );
guDBusMessage * SendWithReplyAndBlock( guDBusMessage * msg, int timeout = guDBUS_DEFAULT_SEND_TIMEOUT );
void Flush();
};
WX_DEFINE_ARRAY_PTR( guDBusClient *, guDBusClientArray );
static guDBusServer * MainDBusServer = NULL;
// -------------------------------------------------------------------------------- //
class guDBusServer
{
protected :
DBusConnection * m_DBusConn;
DBusError m_DBusErr;
guDBusClientArray m_Clients;
wxMutex m_ClientsMutex;
guDBusThread * m_DBusThread;
public :
guDBusServer( const char * name, bool System = false );
virtual ~guDBusServer();
bool HasOwner( const char * name );
bool RequestName( const char * name );
virtual DBusHandlerResult HandleMessages( guDBusMessage * msg, guDBusMessage * reply = NULL );
DBusConnection * GetConnection();
bool RegisterObjectPath( const char * objname );
bool UnRegisterObjectPath( const char * objname );
bool AddMatch( const char * rule );
bool Send( guDBusMessage * msg );
bool SendWithReply( guDBusMessage * msg, guDBusClient * client, int timeout = guDBUS_DEFAULT_SEND_TIMEOUT );
guDBusMessage * SendWithReplyAndBlock( guDBusMessage * msg, int timeout = guDBUS_DEFAULT_SEND_TIMEOUT );
void Flush();
void MethodCall( const char * dest, const char * path,
const char * iface, const char * method );
bool RegisterClient( guDBusClient * client );
bool UnRegisterClient( guDBusClient * client );
void Run();
static void Set( guDBusServer * server )
{
wxASSERT( !MainDBusServer );
wxASSERT( server );
MainDBusServer = server;
}
static guDBusServer * Get( void )
{
return MainDBusServer;
}
friend class guDBusClient;
};
// -------------------------------------------------------------------------------- //
class guDBusThread : public wxThread
{
protected :
guDBusServer * m_DBusOwner;
public :
guDBusThread( guDBusServer * dbusowner );
virtual ~guDBusThread();
virtual ExitCode Entry();
friend class guDBusServer;
};
}
#endif
// -------------------------------------------------------------------------------- //
| 6,956
|
C++
|
.h
| 162
| 38.962963
| 135
| 0.539429
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,692
|
TagInfo.h
|
anonbeat_guayadeque/src/taginfo/TagInfo.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __TAGINFO_H__
#define __TAGINFO_H__
#include "DbLibrary.h"
#include <tag.h>
#include <attachedpictureframe.h>
#include <fileref.h>
#include <id3v2framefactory.h>
#include <textidentificationframe.h>
#include <unsynchronizedlyricsframe.h>
#include <asffile.h>
#include <mpegfile.h>
#include <flacfile.h>
#include <mp4file.h>
#include <mpcfile.h>
#include <oggfile.h>
#include <vorbisfile.h>
#include <wavpackfile.h>
#include <trueaudiofile.h>
#include <xiphcomment.h>
#ifdef TAGLIB_WITH_APE_SUPPORT
#include <apefile.h>
#endif
#include <mp4tag.h>
#include <apetag.h>
#include <id3v2tag.h>
#include <asftag.h>
#include <wx/string.h>
#include <wx/arrstr.h>
#include <wx/image.h>
#include <gst/gst.h>
namespace Guayadeque {
using namespace TagLib;
#define wxStringToTString(s) TagLib::String(s.ToUTF8(), TagLib::String::UTF8)
#define TStringTowxString(s) wxString::FromUTF8( s.toCString(true) )
#define guTRACK_CHANGED_DATA_NONE 0
#define guTRACK_CHANGED_DATA_TAGS ( 1 << 0 )
#define guTRACK_CHANGED_DATA_IMAGES ( 1 << 1 )
#define guTRACK_CHANGED_DATA_LYRICS ( 1 << 2 )
#define guTRACK_CHANGED_DATA_LABELS ( 1 << 3 )
#define guTRACK_CHANGED_DATA_RATING ( 1 << 4 )
// -------------------------------------------------------------------------------- //
class guTagInfo
{
protected :
FileRef * m_TagFile;
Tag * m_Tag;
protected :
bool ReadExtendedTags( ID3v2::Tag * tag );
bool WriteExtendedTags( ID3v2::Tag * tag, const int changedflag );
bool ReadExtendedTags( Ogg::XiphComment * tag );
bool WriteExtendedTags( Ogg::XiphComment * tag, const int changedflag );
bool ReadExtendedTags( MP4::Tag * tag );
bool WriteExtendedTags( MP4::Tag * tag, const int changedflag );
bool ReadExtendedTags( APE::Tag * tag );
bool WriteExtendedTags( APE::Tag * tag, const int changedflag );
bool ReadExtendedTags( ASF::Tag * tag );
bool WriteExtendedTags( ASF::Tag * tag, const int changedflag );
public:
wxString m_FileName;
wxString m_TrackName;
wxString m_GenreName;
wxString m_ArtistName;
wxString m_AlbumArtist;
wxString m_AlbumName;
wxString m_Composer;
wxString m_Comments;
int m_Track;
int m_Year;
int m_Length;
int m_Bitrate;
int m_PlayCount;
int m_Rating;
wxString m_Disk;
wxArrayString m_TrackLabels;
wxString m_TrackLabelsStr;
wxArrayString m_ArtistLabels;
wxString m_ArtistLabelsStr;
wxArrayString m_AlbumLabels;
wxString m_AlbumLabelsStr;
bool m_Compilation;
guTagInfo( const wxString &filename = wxEmptyString );
virtual ~guTagInfo();
void SetFileName( const wxString &filename );
virtual bool Read( void );
virtual bool Write( const int changedflag );
virtual bool CanHandleImages( void );
virtual wxImage * GetImage( void );
virtual bool SetImage( const wxImage * image );
virtual bool CanHandleLyrics( void );
virtual wxString GetLyrics( void );
virtual bool SetLyrics( const wxString &lyrics );
};
bool guIsValidAudioFile( const wxString &filename );
guTagInfo * guGetTagInfoHandler( const wxString &filename );
// -------------------------------------------------------------------------------- //
class guMp3TagInfo : public guTagInfo
{
protected :
ID3v2::Tag * m_TagId3v2;
public :
guMp3TagInfo( const wxString &filename = wxEmptyString );
~guMp3TagInfo();
virtual bool Read( void );
virtual bool Write( const int changedflag );
virtual bool CanHandleImages( void );
virtual wxImage * GetImage( void );
virtual bool SetImage( const wxImage * image );
virtual bool CanHandleLyrics( void );
virtual wxString GetLyrics( void );
virtual bool SetLyrics( const wxString &lyrics );
};
// -------------------------------------------------------------------------------- //
class guFlacTagInfo : public guTagInfo
{
protected :
Ogg::XiphComment * m_XiphComment;
public :
guFlacTagInfo( const wxString &filename = wxEmptyString );
~guFlacTagInfo();
virtual bool Read( void );
virtual bool Write( const int changedflag );
virtual bool CanHandleImages( void );
virtual wxImage * GetImage();
virtual bool SetImage( const wxImage * image );
virtual bool CanHandleLyrics( void );
virtual wxString GetLyrics( void );
virtual bool SetLyrics( const wxString &lyrics );
};
// -------------------------------------------------------------------------------- //
class guOggTagInfo : public guTagInfo
{
protected :
Ogg::XiphComment * m_XiphComment;
public :
guOggTagInfo( const wxString &filename = wxEmptyString );
~guOggTagInfo();
virtual bool Read( void );
virtual bool Write( const int changedflag );
virtual bool CanHandleImages( void );
virtual wxImage * GetImage( void );
virtual bool SetImage( const wxImage * image );
virtual bool CanHandleLyrics( void );
virtual wxString GetLyrics( void );
virtual bool SetLyrics( const wxString &lyrics );
};
// -------------------------------------------------------------------------------- //
class guMp4TagInfo : public guTagInfo
{
protected :
TagLib::MP4::Tag * m_Mp4Tag;
public :
guMp4TagInfo( const wxString &filename = wxEmptyString );
~guMp4TagInfo();
virtual bool Read( void );
virtual bool Write( const int changedflag );
#ifdef TAGLIB_WITH_MP4_COVERS
virtual bool CanHandleImages( void );
virtual wxImage * GetImage( void );
virtual bool SetImage( const wxImage * image );
#endif
virtual bool CanHandleLyrics( void );
virtual wxString GetLyrics( void );
virtual bool SetLyrics( const wxString &lyrics );
};
#ifdef TAGLIB_WITH_APE_SUPPORT
// -------------------------------------------------------------------------------- //
class guApeTagInfo : public guTagInfo
{
protected :
ID3v1::Tag * m_TagId3v1;
APE::Tag * m_ApeTag;
public :
guApeTagInfo( const wxString &filename = wxEmptyString );
~guApeTagInfo();
virtual bool Read( void );
virtual bool Write( const int changedflag );
virtual bool CanHandleLyrics( void );
virtual wxString GetLyrics( void );
virtual bool SetLyrics( const wxString &lyrics );
};
#endif
// -------------------------------------------------------------------------------- //
class guMpcTagInfo : public guTagInfo
{
protected :
TagLib::APE::Tag * m_ApeTag;
public :
guMpcTagInfo( const wxString &filename = wxEmptyString );
~guMpcTagInfo();
virtual bool Read( void );
virtual bool Write( const int changedflag );
virtual bool CanHandleImages( void );
virtual wxImage * GetImage( void );
virtual bool SetImage( const wxImage * image );
};
// -------------------------------------------------------------------------------- //
class guWavPackTagInfo : public guTagInfo
{
protected :
TagLib::APE::Tag * m_ApeTag;
public :
guWavPackTagInfo( const wxString &filename = wxEmptyString );
~guWavPackTagInfo();
virtual bool Read( void );
virtual bool Write( const int changedflag );
virtual bool CanHandleImages( void );
virtual wxImage * GetImage( void );
virtual bool SetImage( const wxImage * image );
virtual bool CanHandleLyrics( void );
virtual wxString GetLyrics( void );
virtual bool SetLyrics( const wxString &lyrics );
};
// -------------------------------------------------------------------------------- //
class guTrueAudioTagInfo : public guTagInfo
{
protected :
ID3v2::Tag * m_TagId3v2;
public :
guTrueAudioTagInfo( const wxString &filename = wxEmptyString );
~guTrueAudioTagInfo();
virtual bool Read( void );
virtual bool Write( const int changedflag );
virtual bool CanHandleImages( void );
virtual wxImage * GetImage( void );
virtual bool SetImage( const wxImage * image );
virtual bool CanHandleLyrics( void );
virtual wxString GetLyrics( void );
virtual bool SetLyrics( const wxString &lyrics );
};
// -------------------------------------------------------------------------------- //
class guASFTagInfo : public guTagInfo
{
protected :
ASF::Tag * m_ASFTag;
public :
guASFTagInfo( const wxString &filename = wxEmptyString );
~guASFTagInfo();
virtual bool Read( void );
virtual bool Write( const int changedflag );
virtual bool CanHandleImages( void );
virtual wxImage * GetImage( void );
virtual bool SetImage( const wxImage * image );
virtual bool CanHandleLyrics( void );
virtual wxString GetLyrics( void );
virtual bool SetLyrics( const wxString &lyrics );
};
// -------------------------------------------------------------------------------- //
class guGStreamerTagInfo : public guTagInfo
{
protected :
const GstTagList * m_GstTagList = NULL;
wxImage * m_GStreamerImage = NULL;
public :
guGStreamerTagInfo( const wxString &filename = wxEmptyString );
~guGStreamerTagInfo();
virtual bool Read( void );
virtual wxString GetLyrics( void );
virtual bool SetLyrics( const wxString &lyrics ) { return false; };
virtual bool CanHandleLyrics( void ) { return true; };
virtual wxImage * GetImage( void );
virtual bool SetImage( const wxImage * image ) { return false; };
virtual bool CanHandleImages( void );
virtual bool ReadGStreamerTags( const wxString &filename = wxEmptyString );
virtual wxString GetGstStrTag( const gchar * tag );
virtual int GetGstIntTag( const gchar * tag );
virtual bool GetGstBoolTag( const gchar * tag );
virtual GDateTime * GetGstTimeTag( const gchar * tag );
};
class guImagePtrArray;
// -------------------------------------------------------------------------------- //
wxImage * guTagGetPicture( const wxString &filename );
bool guTagSetPicture( const wxString &filename, wxImage * picture, const bool forcesave = false );
bool guTagSetPicture( const wxString &filename, const wxString &imagefile, const bool forcesave = false );
wxString guTagGetLyrics( const wxString &filename );
bool guTagSetLyrics( const wxString &filename, const wxString &lyrics, const bool forcesave = false );
//void guUpdateTrack( const guTrack &track, const wxImage * image, const wxString &lyrics, const int &changedflags );
void guUpdateTracks( const guTrackArray &tracks, const guImagePtrArray &images,
const wxArrayString &lyrics, const wxArrayInt &changedflags, const bool forcesave = false );
void guUpdateImages( const guTrackArray &songs, const guImagePtrArray &images, const wxArrayInt &changedflags );
void guUpdateLyrics( const guTrackArray &songs, const wxArrayString &lyrics, const wxArrayInt &changedflags );
bool guStrDiskToDiskNum( const wxString &diskstr, int &disknum, int &disktotal );
}
#endif
// -------------------------------------------------------------------------------- //
| 12,921
|
C++
|
.h
| 305
| 38.891803
| 124
| 0.594437
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,693
|
Collections.h
|
anonbeat_guayadeque/src/collections/Collections.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __COLLECTIONS_H__
#define __COLLECTIONS_H__
#include <wx/string.h>
#include <wx/arrstr.h>
#include <wx/dynarray.h>
#include <wx/menu.h>
namespace Guayadeque {
enum guMediaCollectionType {
guMEDIA_COLLECTION_TYPE_NORMAL,
guMEDIA_COLLECTION_TYPE_JAMENDO,
guMEDIA_COLLECTION_TYPE_MAGNATUNE,
guMEDIA_COLLECTION_TYPE_PORTABLE_DEVICE,
guMEDIA_COLLECTION_TYPE_IPOD
};
// -------------------------------------------------------------------------------- //
class guMediaCollection
{
public :
wxString m_UniqueId;
int m_Type;
wxString m_Name;
wxArrayString m_Paths;
wxArrayString m_CoverWords;
bool m_UpdateOnStart;
bool m_ScanPlaylists;
bool m_ScanFollowSymLinks;
bool m_ScanEmbeddedCovers;
bool m_EmbeddMetadata;
wxString m_DefaultCopyAction;
int m_LastUpdate;
guMediaCollection( const int type = guMEDIA_COLLECTION_TYPE_NORMAL );
~guMediaCollection();
bool CheckPaths( void );
};
WX_DECLARE_OBJARRAY( guMediaCollection, guMediaCollectionArray );
// -------------------------------------------------------------------------------- //
class guManagedCollection : public guMediaCollection
{
protected :
bool m_Enabled;
wxMenu * m_MenuItem;
public :
guManagedCollection( void );
~guManagedCollection();
};
WX_DECLARE_OBJARRAY( guManagedCollection, guManagedCollectionArray );
}
#endif
// -------------------------------------------------------------------------------- //
| 2,660
|
C++
|
.h
| 70
| 35.385714
| 86
| 0.580458
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,694
|
LibUpdate.h
|
anonbeat_guayadeque/src/collections/LibUpdate.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __LIBUPDATE_H__
#define __LIBUPDATE_H__
#include "DbLibrary.h"
#include "MainFrame.h"
#include "LibPanel.h"
namespace Guayadeque {
class guMediaViewer;
// -------------------------------------------------------------------------------- //
class guLibUpdateThread : public wxThread
{
private :
guMediaViewer * m_MediaViewer;
guDbLibrary * m_Db;
//guLibPanel * m_LibPanel;
guMainFrame * m_MainFrame;
wxArrayString m_TrackFiles;
wxArrayString m_ImageFiles;
wxArrayString m_PlayListFiles;
wxArrayString m_CueFiles;
int m_GaugeId;
wxArrayString m_LibPaths;
int m_LastUpdate;
wxArrayString m_CoverSearchWords;
wxString m_ScanPath;
bool m_ScanAddPlayLists;
bool m_ScanEmbeddedCovers;
bool m_ScanSymlinks;
int ScanDirectory( wxString dirname, bool includedir = false );
// bool ReadFileTags( const wxString &filename );
void ProcessCovers( void );
public :
guLibUpdateThread( guMediaViewer * mediaviewer, int gaugeid, const wxString &scanpath = wxEmptyString );
~guLibUpdateThread();
ExitCode Entry();
};
// -------------------------------------------------------------------------------- //
class guLibCleanThread : public wxThread
{
private :
guMediaViewer * m_MediaViewer;
guDbLibrary * m_Db;
guLibPanel * m_LibPanel;
guMainFrame * m_MainFrame;
wxTimer m_ProgressTimer;
void OnTimer( wxTimerEvent &event );
public :
guLibCleanThread( guMediaViewer * mediaviewer );
~guLibCleanThread();
ExitCode Entry();
};
}
#endif
// -------------------------------------------------------------------------------- //
| 2,950
|
C++
|
.h
| 74
| 36.945946
| 108
| 0.554507
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,695
|
CopyTo.h
|
anonbeat_guayadeque/src/copyto/CopyTo.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __COPYTO_H__
#define __COPYTO_H__
#include "DbLibrary.h"
#include "MainFrame.h"
#include "PlayListFile.h"
#include "PortableMedia.h"
#include <wx/string.h>
#include <wx/dynarray.h>
namespace Guayadeque {
enum guCopyToActionType {
guCOPYTO_ACTION_NONE,
guCOPYTO_ACTION_COPYTO,
guCOPYTO_ACTION_COPYTODEVICE,
guCOPYTO_ACTION_COPYTOIPOD
};
// -------------------------------------------------------------------------------- //
class guCopyToAction
{
private :
int m_Type;
guTrackArray * m_Tracks;
wxString m_DestDir;
wxString m_Pattern;
guPlaylistFile * m_PlayListFile;
int m_Format;
int m_Quality;
bool m_MoveFiles;
int m_CoverFormats;
int m_CoverSize;
wxString m_CoverName;
guMediaViewer * m_MediaViewer;
guDbLibrary * m_Db;
public :
guCopyToAction();
guCopyToAction( guTrackArray * tracks, guMediaViewer * mediaviewer, const wxString &destdir, const wxString &pattern, int format, int quality, bool movefiles );
guCopyToAction( guTrackArray * tracks, guMediaViewer * mediaviewer );
guCopyToAction( wxString * playlistpath, guMediaViewer * mediaviewer );
~guCopyToAction();
int Type( void ) { return m_Type; }
guTrackArray * Tracks( void ) { return m_Tracks; }
wxString DestDir( void ) { return m_DestDir; }
wxString Pattern( void ) { return m_Pattern; }
int Format( void ) { return m_Format; }
void Format( const int format ) { m_Format = format; }
int Quality( void ) { return m_Quality; }
void Quality( const int quality ) { m_Quality = quality; }
bool MoveFiles( void ) { return m_MoveFiles; }
int CoverFormats( void ) { return m_CoverFormats; }
int CoverSize( void ) { return m_CoverSize; }
wxString CoverName( void ) { return m_CoverName; }
guPlaylistFile * PlayListFile( void ) { return m_PlayListFile; }
size_t Count( void ) { return m_Tracks->Count(); }
guTrack * Track( const int index ) { return &m_Tracks->Item( index ); }
//guPortableMediaViewCtrl * PortableMediaViewCtrl( void ) { return m_PortableMediaViewCtrl; }
guPortableMediaDevice * GetPortableMediaDevice( void ) { return ( ( guMediaViewerPortableDevice * ) m_MediaViewer )->GetPortableMediaDevice(); }
guDbLibrary * GetDb( void ) { return m_Db; }
guMediaViewer * GetMediaViewer( void ) { return m_MediaViewer; }
};
WX_DECLARE_OBJARRAY( guCopyToAction, guCopyToActionArray );
// -------------------------------------------------------------------------------- //
class guCopyToThread : public wxThread
{
private:
guMainFrame * m_MainFrame;
int m_GaugeId;
wxFileOffset m_SizeCounter;
int m_CurrentFile;
int m_FileCount;
wxArrayString m_FilesToAdd;
wxArrayString m_CoversToAdd;
guTrackArray m_DeleteTracks;
guCopyToActionArray * m_CopyToActions;
wxMutex m_CopyToActionsMutex;
bool CopyFile( const wxString &from, const wxString &to );
bool TranscodeFile( const guTrack * track, const wxString &to, int format, int quality );
void DoCopyToAction( guCopyToAction ©toaction );
public:
guCopyToThread( guMainFrame * mainframe, int gaugeid );
~guCopyToThread();
void AddAction( guTrackArray * tracks, guMediaViewer * mediaviewer, const wxString &destdir,
const wxString &pattern, int format, int quality, bool movefiles );
// void AddAction( guTrackArray * tracks, guDbLibrary * db, guPortableMediaViewCtrl * portablemediaviewctrl );
void AddAction( guTrackArray * tracks, guMediaViewer * mediaviewer );
// void AddAction( wxString * playlistpath, guDbLibrary * db, guPortableMediaViewCtrl * portablemediaviewctrl );
void AddAction( wxString * playlistpath, guMediaViewer * mediaviewer );
virtual ExitCode Entry();
};
}
#endif
// -------------------------------------------------------------------------------- //
| 5,776
|
C++
|
.h
| 111
| 48.414414
| 164
| 0.557958
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,696
|
Transcode.h
|
anonbeat_guayadeque/src/copyto/Transcode.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __TRANSCODE_H__
#define __TRANSCODE_H__
#include "DbLibrary.h"
#include <wx/event.h>
#include <wx/wx.h>
#include <gst/gst.h>
namespace Guayadeque {
enum guTranscodeFormat {
guTRANSCODE_FORMAT_KEEP,
guTRANSCODE_FORMAT_MP3,
guTRANSCODE_FORMAT_OGG,
guTRANSCODE_FORMAT_FLAC,
guTRANSCODE_FORMAT_AAC,
guTRANSCODE_FORMAT_WMA
};
enum guPortableMediaTranscodeQuality { // mp3 ogg flac aac wma
guTRANSCODE_QUALITY_KEEP,
guTRANSCODE_QUALITY_VERY_HIGH, // 320 240
guTRANSCODE_QUALITY_HIGH, // 256 160
guTRANSCODE_QUALITY_VERY_GOOD, // 192 140
guTRANSCODE_QUALITY_GOOD, // 160 120
guTRANSCODE_QUALITY_NORMAL, // 128 110
guTRANSCODE_QUALITY_LOW, // 96 96
guTRANSCODE_QUALITY_VERY_LOW // 64 70
};
wxArrayString guTranscodeFormatStrings( const bool isipod = false );
wxString guTranscodeFormatString( const int format );
wxArrayString guTranscodeQualityStrings( void );
wxString guTranscodeQualityString( const int quality );
int guGetTranscodeFileFormat( const wxString &filetype );
// -------------------------------------------------------------------------------- //
class guTranscodeThread : public wxThread
{
protected :
const guTrack * m_Track;
wxString m_Target;
wxString m_TempName;
int m_Format;
int m_Quality;
int m_StartPos;
int m_Length;
bool m_Running;
GstElement * m_Pipeline;
bool m_HasError;
int m_SeekTimerId;
void BuildPipeline( void );
bool BuildEncoder( GstElement ** enc, GstElement ** mux );
void WriteTags();
public :
guTranscodeThread( const guTrack * track, const wxChar * target, const int format, const int quality );
~guTranscodeThread();
virtual ExitCode Entry();
void Stop();
bool IsTranscoding( void ) { return m_Running; }
bool IsOk() { return !m_HasError; }
void SetError( bool error ) { m_HasError = error; }
bool CheckTrackEnd();
GstElement * GetPipeline() { return m_Pipeline; }
bool DoStartSeek();
};
}
#endif
// -------------------------------------------------------------------------------- //
| 3,579
|
C++
|
.h
| 84
| 39.583333
| 107
| 0.561046
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,697
|
hmac_sha2.h
|
anonbeat_guayadeque/src/hmac/hmac_sha2.h
|
/*-
* HMAC-SHA-224/256/384/512 implementation
* Last update: 06/15/2005
* Issue date: 06/15/2005
*
* Copyright (C) 2005 Olivier Gay <olivier.gay@a3.epfl.ch>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _HMAC_SHA2_H
#define _HMAC_SHA2_H
#include "sha2.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
sha224_ctx ctx_inside;
sha224_ctx ctx_outside;
/* for hmac_reinit */
sha224_ctx ctx_inside_reinit;
sha224_ctx ctx_outside_reinit;
unsigned char block_ipad[SHA224_BLOCK_SIZE];
unsigned char block_opad[SHA224_BLOCK_SIZE];
} hmac_sha224_ctx;
typedef struct {
sha256_ctx ctx_inside;
sha256_ctx ctx_outside;
/* for hmac_reinit */
sha256_ctx ctx_inside_reinit;
sha256_ctx ctx_outside_reinit;
unsigned char block_ipad[SHA256_BLOCK_SIZE];
unsigned char block_opad[SHA256_BLOCK_SIZE];
} hmac_sha256_ctx;
typedef struct {
sha384_ctx ctx_inside;
sha384_ctx ctx_outside;
/* for hmac_reinit */
sha384_ctx ctx_inside_reinit;
sha384_ctx ctx_outside_reinit;
unsigned char block_ipad[SHA384_BLOCK_SIZE];
unsigned char block_opad[SHA384_BLOCK_SIZE];
} hmac_sha384_ctx;
typedef struct {
sha512_ctx ctx_inside;
sha512_ctx ctx_outside;
/* for hmac_reinit */
sha512_ctx ctx_inside_reinit;
sha512_ctx ctx_outside_reinit;
unsigned char block_ipad[SHA512_BLOCK_SIZE];
unsigned char block_opad[SHA512_BLOCK_SIZE];
} hmac_sha512_ctx;
void hmac_sha224_init(hmac_sha224_ctx *ctx, unsigned char *key,
unsigned int key_size);
void hmac_sha224_reinit(hmac_sha224_ctx *ctx);
void hmac_sha224_update(hmac_sha224_ctx *ctx, unsigned char *message,
unsigned int message_len);
void hmac_sha224_final(hmac_sha224_ctx *ctx, unsigned char *mac,
unsigned int mac_size);
void hmac_sha224(unsigned char *key, unsigned int key_size,
unsigned char *message, unsigned int message_len,
unsigned char *mac, unsigned mac_size);
void hmac_sha256_init(hmac_sha256_ctx *ctx, unsigned char *key,
unsigned int key_size);
void hmac_sha256_reinit(hmac_sha256_ctx *ctx);
void hmac_sha256_update(hmac_sha256_ctx *ctx, unsigned char *message,
unsigned int message_len);
void hmac_sha256_final(hmac_sha256_ctx *ctx, unsigned char *mac,
unsigned int mac_size);
void hmac_sha256(unsigned char *key, unsigned int key_size,
unsigned char *message, unsigned int message_len,
unsigned char *mac, unsigned mac_size);
void hmac_sha384_init(hmac_sha384_ctx *ctx, unsigned char *key,
unsigned int key_size);
void hmac_sha384_reinit(hmac_sha384_ctx *ctx);
void hmac_sha384_update(hmac_sha384_ctx *ctx, unsigned char *message,
unsigned int message_len);
void hmac_sha384_final(hmac_sha384_ctx *ctx, unsigned char *mac,
unsigned int mac_size);
void hmac_sha384(unsigned char *key, unsigned int key_size,
unsigned char *message, unsigned int message_len,
unsigned char *mac, unsigned mac_size);
void hmac_sha512_init(hmac_sha512_ctx *ctx, unsigned char *key,
unsigned int key_size);
void hmac_sha512_reinit(hmac_sha512_ctx *ctx);
void hmac_sha512_update(hmac_sha512_ctx *ctx, unsigned char *message,
unsigned int message_len);
void hmac_sha512_final(hmac_sha512_ctx *ctx, unsigned char *mac,
unsigned int mac_size);
void hmac_sha512(unsigned char *key, unsigned int key_size,
unsigned char *message, unsigned int message_len,
unsigned char *mac, unsigned mac_size);
#ifdef __cplusplus
}
#endif
#endif /* ! _HMAC_SHA2_H */
| 5,426
|
C++
|
.h
| 118
| 38.90678
| 78
| 0.68712
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
750,699
|
LastFM.h
|
anonbeat_guayadeque/src/info/lastfm/LastFM.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __LASTFM_H__
#define __LASTFM_H__
#include "DbLibrary.h"
#include "MD5.h"
namespace Guayadeque {
#define LASTFM_API_KEY wxT( "96a881180c49ba8ec586675172c3ef36" )
#define LASTFM_SHARED_SECRET wxT( "cecb145e943f307c7e7488e0ff6ebbbe" )
#define LASTFM_API_ROOT wxT( "http://ws.audioscrobbler.com/2.0/" )
#define LASTFM_POST_PATH wxT( "/2.0/" )
#define LASTFM_AUTH_ROOT wxT( "http://www.last.fm/api/auth/" )
//#define LASTFM_HOST wxT( "ws.audioscrobbler.com" )
// -------------------------------------------------------------------------------- //
class guLastFMRequest
{
private:
wxSortedArrayString m_Args;
//wxString Method;
wxString GetSign();
public:
guLastFMRequest();
~guLastFMRequest();
wxString DoRequest( const bool AddSign = true, const bool IsGetAction = true );
void AddArgument( const wxString &ArgName, const wxString &ArgValue, bool Filter );
void AddArgument( const wxString &ArgName, const wxString &ArgValue );
void SetMethod( const wxString &MethodName );
};
// -------------------------------------------------------------------------------- //
class guArtistInfo {
public:
wxString m_Name;
wxString m_Url;
wxString m_ImageLink;
wxArrayString m_Tags;
wxString m_BioSummary;
wxString m_BioContent;
};
// -------------------------------------------------------------------------------- //
class guAlbumInfo {
public:
wxString m_Name;
wxString m_Artist;
wxString m_Url;
wxString m_ReleaseDate;
wxString m_ImageLink;
wxString m_Tags;
wxString m_Rank;
};
WX_DECLARE_OBJARRAY(guAlbumInfo, guAlbumInfoArray);
// -------------------------------------------------------------------------------- //
class guTrackInfo {
public:
wxString m_TrackName;
wxString m_ArtistName;
wxString m_AlbumName;
wxString m_Url;
wxArrayString m_TopTags;
wxString m_Summary;
wxString m_Content;
};
// -------------------------------------------------------------------------------- //
class guTopTrackInfo {
public:
wxString m_TrackName;
int m_PlayCount;
int m_Listeners;
wxString m_ArtistName;
wxString m_Url;
wxString m_ImageLink;
};
WX_DECLARE_OBJARRAY(guTopTrackInfo, guTopTrackInfoArray);
// -------------------------------------------------------------------------------- //
class guSimilarArtistInfo {
public:
wxString m_Name;
wxString m_Match;
wxString m_Url;
wxString m_ImageLink;
guSimilarArtistInfo() {}
guSimilarArtistInfo( guSimilarArtistInfo * info )
{
wxASSERT( info );
m_Name = wxString( info->m_Name.c_str() );
m_Match = wxString( info->m_Match.c_str() );
m_Url = wxString( info->m_Url.c_str() );
m_ImageLink = wxString( info->m_ImageLink.c_str() );
}
};
WX_DECLARE_OBJARRAY(guSimilarArtistInfo, guSimilarArtistInfoArray);
// -------------------------------------------------------------------------------- //
class guSimilarTrackInfo {
public:
wxString m_TrackName;
wxString m_ArtistName;
wxString m_Match;
wxString m_Url;
wxString m_ImageLink;
guSimilarTrackInfo() {}
guSimilarTrackInfo( guSimilarTrackInfo * info )
{
wxASSERT( info );
m_TrackName = wxString( info->m_TrackName.c_str() );
m_ArtistName = wxString( info->m_ArtistName.c_str() );
m_Match = wxString( info->m_Match.c_str() );
m_Url = wxString( info->m_Url.c_str() );
m_ImageLink = wxString( info->m_ImageLink.c_str() );
}
};
WX_DECLARE_OBJARRAY(guSimilarTrackInfo,guSimilarTrackInfoArray);
// -------------------------------------------------------------------------------- //
class guEventInfo {
public :
int m_Id;
wxString m_Title;
wxArrayString m_Artists;
wxString m_LocationName;
wxString m_LocationCity;
wxString m_LocationCountry;
wxString m_LocationStreet;
wxString m_LocationZipCode;
wxString m_LocationGeoLat;
wxString m_LocationGeoLong;
wxString m_LocationTimeZone;
wxString m_LocationLink;
wxString m_Date;
wxString m_Time;
wxString m_Description;
wxString m_ImageLink;
wxString m_Url;
};
WX_DECLARE_OBJARRAY(guEventInfo,guEventInfoArray);
// -------------------------------------------------------------------------------- //
class guLastFM
{
private:
guTrackArray m_Songs;
wxString m_UserName;
wxString m_Password;
wxString m_AuthToken;
wxString m_AuthSession;
wxString m_AuthKey;
wxString m_Language;
long m_ErrorCode;
public:
guLastFM();
~guLastFM();
void SetUserName( const wxString &NewUser ) { m_UserName = NewUser; }
void SetPassword( const wxString &NewPass ) { m_Password = NewPass; }
void SetLanguage( const wxString &lang ) { m_Language = lang; }
wxString GetAuthSession();
wxString GetAuthURL();
bool DoAuthentication();
int GetLastError() { return m_ErrorCode; }
bool IsOk();
wxString AuthGetSession();
wxString AuthGetToken();
// Album Methods
bool AlbumAddTags( const wxString &Artist, const wxString &Album, const wxString &Tags );
guAlbumInfo AlbumGetInfo( const wxString &Artist, const wxString &Album );
wxArrayString AlbumGetTags( const wxString &Artist, const wxString &Album );
bool AlbumRemoveTag( const wxString &Artist, const wxString &Album, const wxString &Tag );
// Artist Methods
bool ArtistAddTags( const wxString &Artist, const wxString &Tags );
guArtistInfo ArtistGetInfo( const wxString &Artist );
guSimilarArtistInfoArray ArtistGetSimilar( const wxString &Artist );
wxArrayString ArtistGetTags( const wxString &Artist );
guAlbumInfoArray ArtistGetTopAlbums( const wxString &Artist );
wxArrayString ArtistGetTopTags( const wxString &Artist );
guTopTrackInfoArray ArtistGetTopTracks( const wxString &Artist );
guEventInfoArray ArtistGetEvents( const wxString &Artist );
// Track Methods
guTrackInfo TrackGetInfo( const wxString &Artist, const wxString &Track );
guSimilarTrackInfoArray TrackGetSimilar( const wxString &Artist, const wxString &Track );
wxArrayString TrackGetTags( const wxString &Artist, const wxString &Track );
wxArrayString TrackGetTopTags( const wxString &Artist, const wxString &Track );
bool TrackRemoveTag( const wxString &Artist, const wxString &Track, const wxString &Tag );
bool TrackLove( const wxString &artist, const wxString &title );
bool TrackBan( const wxString &artist, const wxString &title );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 8,535
|
C++
|
.h
| 202
| 38.376238
| 117
| 0.556826
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,700
|
SmartMode.h
|
anonbeat_guayadeque/src/info/smartmode/SmartMode.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __SMARTMODE_H__
#define __SMARTMODE_H__
#include "DbLibrary.h"
#include "LastFM.h"
#include <wx/wx.h>
#include <wx/thread.h>
namespace Guayadeque {
enum guSmartModeTrackLimitType {
guSMARTMODE_TRACK_LIMIT_TRACKS,
guSMARTMODE_TRACK_LIMIT_TIME_MINUTES,
guSMARTMODE_TRACK_LIMIT_TIME_HOURS,
guSMARTMODE_TRACK_LIMIT_SIZE_MB,
guSMARTMODE_TRACK_LIMIT_SIZE_GB
};
#define guSMARTMODE_FILTER_ALLOW_ALL 0
#define guSMARTMODE_FILTER_DENY_NONE 0
// -------------------------------------------------------------------------------- //
class guSmartModeThread : public wxThread
{
protected :
guDbLibrary * m_Db;
wxEvtHandler * m_Owner;
guLastFM * m_LastFM;
wxString m_ArtistName;
wxString m_TrackName;
int m_FilterAllowPlayList;
int m_FilterDenyPlayList;
wxArrayInt * m_SmartAddedTracks;
wxArrayString * m_SmartAddedArtists;
int m_MaxSmartTracksList;
int m_MaxSmartArtistsList;
u_int64_t m_TrackLimit;
int m_LimitType;
u_int64_t m_LimitCounter;
bool m_LimitReached;
int m_GaugeId;
bool CheckAddTrack( const wxString &artist, const wxString &track, guTrackArray * tracks );
int AddSimilarTracks( const wxString &artist, const wxString &track, guTrackArray * tracks );
bool CheckLimit( const guTrack * track = NULL );
void SendTracks( guTrackArray * tracks );
public:
guSmartModeThread( guDbLibrary * db, wxEvtHandler * owner,
const wxString &artistname, const wxString &trackname,
wxArrayInt * smartaddedtracks, wxArrayString * smartaddedartists,
const int maxtracks, const int maxartists,
const uint tracklimit, const int limittype = guSMARTMODE_TRACK_LIMIT_TRACKS,
const int filterallow = guSMARTMODE_FILTER_ALLOW_ALL, const int filterdeny = guSMARTMODE_FILTER_DENY_NONE,
const int gaugeid = wxNOT_FOUND );
~guSmartModeThread();
virtual ExitCode Entry();
};
class guMediaViewer;
// -------------------------------------------------------------------------------- //
class guGenSmartPlaylist : public wxDialog
{
protected:
wxComboBox * m_SaveToComboBox;
wxChoice * m_FilterAlowChoice;
wxChoice * m_FilterDenyChoice;
wxTextCtrl * m_LimitTextCtrl;
wxChoice * m_LimitChoice;
guMediaViewer * m_MediaViewer;
guDbLibrary * m_Db;
guListItems m_Playlists;
public:
guGenSmartPlaylist( wxWindow * parent, guMediaViewer * mediaviewer, const wxString &playlistname );
~guGenSmartPlaylist();
int GetPlayListId( void );
wxString GetPlaylistName( void ) { return m_SaveToComboBox->GetValue(); }
int GetAllowFilter( void ) { return m_Playlists[ m_FilterAlowChoice->GetSelection() ].m_Id; }
int GetDenyFilter( void ) { return m_Playlists[ m_FilterDenyChoice->GetSelection() ].m_Id; }
double GetLimitValue( void ) { double RetVal = 0; m_LimitTextCtrl->GetValue().ToDouble( &RetVal ); return RetVal; }
int GetLimitType( void ) { return m_LimitChoice->GetSelection(); }
};
}
#endif
// -------------------------------------------------------------------------------- //
| 4,442
|
C++
|
.h
| 98
| 41.408163
| 128
| 0.608937
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,701
|
AcousticId.h
|
anonbeat_guayadeque/src/info/musicbrainz/AcousticId.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __ACOUSTICID_H__
#define __ACOUSTICID_H__
#include "DbLibrary.h"
#include <wx/event.h>
#include <wx/wx.h>
#include <wx/xml/xml.h>
#include <gst/gst.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
// Any class that want to use the guAcousticId must be of this class
class guAcousticIdClient
{
public :
virtual ~guAcousticIdClient() {}
virtual void OnAcousticIdFingerprintFound( const wxString &fingerprint ) {}
virtual void OnAcousticIdMBIdFound( const wxString &mbid ) {}
virtual void OnAcousticIdError( const int errorcode ) {}
};
class guAcousticIdThread;
// -------------------------------------------------------------------------------- //
class guAcousticId
{
public :
enum guAcousticIdStatus {
guAID_STATUS_OK,
guAID_STATUS_ERROR_THREAD,
guAID_STATUS_ERROR_GSTREAMER,
guAID_STATUS_ERROR_NO_FINGERPRINT,
guAID_STATUS_ERROR_HTTP,
guAID_STATUS_ERROR_BAD_STATUS,
guAID_STATUS_ERROR_XMLERROR,
guAID_STATUS_ERROR_XMLPARSE
};
private :
guAcousticIdThread * m_AcousticIdThread;
protected :
guAcousticIdClient * m_AcousticIdClient;
const guTrack * m_Track;
wxString m_Fingerprint;
wxString m_MBId;
wxString m_XmlDoc;
int m_Status;
bool DoGetFingerprint( void );
bool DoGetMetadata( void );
bool DoParseXmlDoc( void );
void SetStatus( const int status );
wxString GetXmlDoc( void );
void SetXmlDoc( const wxString &xmldoc );
void SetFingerprint( const wxString &fingerprint );
void SetFingerprint( const gchar * fingerprint );
void SetMBId( const wxString &puid );
void ClearAcousticIdThread( void );
public :
guAcousticId( guAcousticIdClient * acidclient );
~guAcousticId();
void SearchTrack( const guTrack * track );
void CancelSearch( void );
wxString GetMBId( void );
int GetStatus( void );
bool IsRunning( void );
bool IsOk( void );
friend class guAcousticIdThread;
};
}
#endif
// -------------------------------------------------------------------------------- //
| 3,587
|
C++
|
.h
| 87
| 37.632184
| 86
| 0.549482
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,702
|
MusicBrainz.h
|
anonbeat_guayadeque/src/info/musicbrainz/MusicBrainz.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __MUSICBRAINZ_H__
#define __MUSICBRAINZ_H__
#include "DbLibrary.h"
#include "AcousticId.h"
#include <wx/wx.h>
#include <wx/dynarray.h>
#include <wx/thread.h>
#include <wx/xml/xml.h>
namespace Guayadeque {
#define GetTrackLengthDiff( time1, time2 ) abs( ( int ) time1 - time2 )
#define guMBRAINZ_MAX_TIME_DIFF 3000
// -------------------------------------------------------------------------------- //
class guMBRecording
{
public :
wxString m_Id;
wxString m_Title;
int m_Length;
wxString m_ArtistId;
wxString m_ArtistName;
wxString m_ReleaseId;
wxString m_ReleaseName;
int m_Number;
guMBRecording() { m_Length = 0; m_Number = 0; }
};
WX_DECLARE_OBJARRAY( guMBRecording, guMBRecordingArray );
// -------------------------------------------------------------------------------- //
class guMBRelease
{
public :
wxString m_Id;
wxString m_Title;
wxString m_ArtistId;
wxString m_ArtistName;
int m_Year;
guMBRecordingArray m_Recordings;
};
WX_DECLARE_OBJARRAY( guMBRelease, guMBReleaseArray );
int FindMBReleaseId( guMBReleaseArray * releases, const wxString &releaseid );
// -------------------------------------------------------------------------------- //
class guMusicBrainz
{
protected :
wxString m_ErrorMsg;
public :
guMusicBrainz();
virtual ~guMusicBrainz();
int GetRecordReleases( const wxString &artist, const wxString &title, guMBReleaseArray * releases );
int GetRecordReleases( const wxString &recordid, guMBReleaseArray * releases );
int GetDiscIdReleases( const wxString &discid, guMBReleaseArray * releases );
int GetRecordings( const wxString &releaseid, guMBRecordingArray * recordings );
int GetRecordings( guMBRelease &mbrelease );
void GetRecordingInfo( const wxString &recordingid, guMBRecording * mbrecording );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 3,207
|
C++
|
.h
| 78
| 38.564103
| 116
| 0.566195
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,703
|
AudioScrobble.h
|
anonbeat_guayadeque/src/info/audioscrobble/AudioScrobble.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __AUDIOSCROBBLE_H__
#define __AUDIOSCROBBLE_H__
#include <wx/wx.h>
#include "EventCommandIds.h"
#include "DbLibrary.h"
#include "Version.h"
#define guAS_PROTOCOL_VERSION wxT( "1.2.1" )
//#ifdef _DEBUG
// #define guAS_DEVELOPMENT
//#endif
#ifndef guAS_DEVELOPMENT
#define guAS_CLIENT_ID wxT( "gua" ) // Assigned by Adrian Woodhead <adrian@last.fm>
#define guAS_CLIENT_VERSION ID_GUAYADEQUE_VERSION
#else
#define guAS_CLIENT_ID wxT( "tst" )
#define guAS_CLIENT_VERSION wxT( "1.0" )
#endif
#define guLASTFM_POST_SERVER wxT( "http://post.audioscrobbler.com/" )
#define guLIBREFM_POST_SERVER wxT( "http://turtle.libre.fm/" )
#define guAS_MIN_PLAYTIME 240
#define guAS_MIN_TRACKLEN 30
#define guAS_SUBMITTRACKS 10
#define guAS_MAX_SUBMITTRACKS 50
#define guAS_SUBMIT_RETRY_TIMEOUT 30000
#define guAS_SUBMIT_TIMEOUT 1000
#define guAS_ERROR_NOERROR 0
#define guAS_ERROR_BANNED 1
#define guAS_ERROR_BADAUTH 2
#define guAS_ERROR_BADTIME 3
#define guAS_ERROR_FAILED 4
#define guAS_ERROR_UNKNOWN 5
#define guAS_ERROR_NOSESSION 6
namespace Guayadeque {
enum guAS_RATING {
guAS_RATING_NONE = 0,
guAS_RATING_LOVE,
guAS_RATING_BAN,
guAS_RATING_SKIP
};
class guASPlayedThread;
class guCurrentTrack;
// -------------------------------------------------------------------------------- //
class guAudioScrobbleSender
{
protected :
guDbLibrary * m_Db;
wxString m_UserName;
wxString m_Password;
wxString m_ServerUrl;
wxString m_SessionId;
wxString m_NowPlayUrl;
wxString m_SubmitUrl;
int m_ErrorCode;
wxString GetAuthToken( int TimeStamp );
int DoRequest( const wxString &Url, int Timeout = 60, const wxString &PostData = wxEmptyString );
int ProcessError( const wxString &ErrorStr );
virtual void ReadUserConfig( void ) {}
public:
guAudioScrobbleSender( guDbLibrary * db, const wxString &serverurl );
virtual ~guAudioScrobbleSender();
void SetUserName( const wxString &username ) { m_UserName = username; }
void SetPassword( const wxString &password ) { m_Password = password; }
bool GetSessionId( void );
bool IsOk() { return ( m_ErrorCode == guAS_ERROR_NOERROR ) ||
( m_ErrorCode == guAS_ERROR_NOSESSION ); }
int GetErrorCode() { return m_ErrorCode; }
void OnConfigUpdated( void );
bool SubmitNowPlaying( const guAS_SubmitInfo * curtrack );
bool SubmitPlayedSongs( const guAS_SubmitInfoArray &playedtracks );
};
// -------------------------------------------------------------------------------- //
class guLastFMAudioScrobble : public guAudioScrobbleSender
{
protected :
virtual void ReadUserConfig( void );
public :
guLastFMAudioScrobble( guDbLibrary * db );
~guLastFMAudioScrobble();
};
// -------------------------------------------------------------------------------- //
class guLibreFMAudioScrobble : public guAudioScrobbleSender
{
protected :
virtual void ReadUserConfig( void );
public :
guLibreFMAudioScrobble( guDbLibrary * db );
~guLibreFMAudioScrobble();
};
class guMainFrame;
class guASNowPlayingThread;
// -------------------------------------------------------------------------------- //
class guAudioScrobble : public wxEvtHandler
{
protected :
guDbLibrary * m_Db;
guMainFrame * m_MainFrame;
guLastFMAudioScrobble * m_LastFMAudioScrobble;
guLibreFMAudioScrobble * m_LibreFMAudioScrobble;
guASPlayedThread * m_PlayedThread;
bool m_PendingNowPlaying;
guAS_SubmitInfo * m_NowPlayingInfo;
guASNowPlayingThread * m_NowPlayingThread;
wxMutex m_NowPlayingInfoMutex;
public :
guAudioScrobble( guDbLibrary * db );
~guAudioScrobble();
bool SubmitNowPlaying( const guAS_SubmitInfo * curtrack );
bool SubmitPlayedSongs( const guAS_SubmitInfoArray &playedtracks );
void SendNowPlayingTrack( const guCurrentTrack &track );
void SendPlayedTrack( const guCurrentTrack &track );
void EndPlayedThread( void );
void EndNowPlayingThread( void );
void OnConfigUpdated( void );
bool IsOk( void );
};
// -------------------------------------------------------------------------------- //
class guASNowPlayingThread : public wxThread
{
private:
guAudioScrobble * m_AudioScrobble;
const guAS_SubmitInfo * m_CurrentSong;
public:
guASNowPlayingThread( guAudioScrobble * audioscrobble, const guAS_SubmitInfo * playingsong );
~guASNowPlayingThread();
virtual ExitCode Entry();
};
// -------------------------------------------------------------------------------- //
class guASPlayedThread : public wxThread
{
private:
guAudioScrobble * m_AudioScrobble;
guDbLibrary * m_Db;
public:
guASPlayedThread( guAudioScrobble * audioscrobble, guDbLibrary * db );
~guASPlayedThread();
virtual ExitCode Entry();
};
}
#endif
// -------------------------------------------------------------------------------- //
| 7,026
|
C++
|
.h
| 161
| 39.658385
| 125
| 0.543175
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,704
|
OnlineLinks.h
|
anonbeat_guayadeque/src/onlinelinks/OnlineLinks.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __ONLINELINKS_H__
#define __ONLINELINKS_H__
#include <wx/menu.h>
namespace Guayadeque {
void AddOnlineLinksMenu( wxMenu * Menu );
void ExecuteOnlineLink( const int linkid, const wxString &text );
}
#endif
// -------------------------------------------------------------------------------- //
| 1,350
|
C++
|
.h
| 30
| 43.833333
| 86
| 0.587833
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,705
|
ArrayStringArray.h
|
anonbeat_guayadeque/src/misc/ArrayStringArray.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __ARRAYSTRINGARRAY_H__
#define __ARRAYSTRINGARRAY_H__
#include <wx/arrstr.h>
#include <wx/dynarray.h>
namespace Guayadeque {
WX_DECLARE_OBJARRAY(wxArrayString, guArrayStringArray);
}
#endif
// -------------------------------------------------------------------------------- //
| 1,335
|
C++
|
.h
| 30
| 43.333333
| 86
| 0.59
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,706
|
TimeLine.h
|
anonbeat_guayadeque/src/misc/TimeLine.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// Bassed on the QTimeLine class from QT
// -------------------------------------------------------------------------------- //
#ifndef __TIMELINE_H__
#define __TIMELINE_H__
#include <wx/event.h>
#include <gst/gst.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
class guTimeLine
{
public :
enum guState {
NotRunning,
Paused,
Running
};
enum guDirection {
Forward,
Backward
};
enum guCurveShape {
EaseInCurve,
EaseOutCurve,
EaseInOutCurve,
LinearCurve,
SineCurve
};
private :
int m_StartTime;
int m_StartFrame;
int m_EndFrame;
int m_TotalLoopCount;
int m_CurrentLoopCount;
int m_TimerId;
guState m_State;
void ChangeCurrentTime( const int msec );
protected :
int m_Duration;
int m_UpdateInterval;
int m_CurrentTime;
guDirection m_Direction;
int m_LoopCount;
guCurveShape m_CurveShape;
wxEvtHandler * m_Parent;
public :
guTimeLine( int duration = 1000, wxEvtHandler * parent = NULL );
virtual ~guTimeLine();
int Duration( void ) const { return m_Duration; }
void SetDuration( const int duration ) { m_Duration = duration; }
int UpdateInterval( void ) const { return m_UpdateInterval; }
void SetUpdateInterval( const int interval ) { m_UpdateInterval = interval; }
int CurrentTime( void ) const { return m_CurrentTime; }
void SetCurrentTime( const int time );
guDirection Direction( void ) const { return m_Direction; }
void SetDirection( const guDirection direction );
int LoopCount( void ) const { return m_LoopCount; }
void SetLoopCount( const int count ) { m_LoopCount = count; }
guCurveShape CurveShape( void ) const { return m_CurveShape; }
void SetCurveShape( const guCurveShape shape ) { m_CurveShape = shape; }
guState State( void ) const { return m_State; }
void SetState( guState state ) { if( m_State != state ) StateChanged( state ); }
int StartFrame( void ) const { return m_StartFrame; }
void SetStartFrame( const int frame ) { m_StartFrame = frame; }
int EndFrame( void ) const { return m_EndFrame; }
void SetEndFrame( const int frame ) { m_EndFrame = frame; }
void SetFrameRange( const int start, const int end ) { m_StartFrame = start; m_EndFrame = end; }
int CurrentFrame( void ) { return FrameForTime( m_CurrentTime ); }
float CurrentValue( void ) { return ValueForTime( m_CurrentTime ); }
int FrameForTime( int msec ) { return m_StartFrame + int( ( m_EndFrame - m_StartFrame ) * ValueForTime( msec ) ); }
virtual float ValueForTime( int msec );
void Start( void );
void Stop( void );
void SetPaused( const bool paused );
void ToggleDirection( void ) { SetDirection( m_Direction == guTimeLine::Forward ? guTimeLine::Backward : guTimeLine::Forward ); }
virtual void ValueChanged( float value );
virtual void FrameChanged( int frame );
virtual void StateChanged( guState state );
virtual void Finished( void );
virtual void TimerEvent( void );
virtual int TimerCreate( void );
virtual void TimerDestroy( void ) { g_source_remove( m_TimerId ); }
};
}
#endif
// -------------------------------------------------------------------------------- //
| 4,829
|
C++
|
.h
| 105
| 41.752381
| 144
| 0.565106
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,707
|
GIO_Volume.h
|
anonbeat_guayadeque/src/misc/GIO_Volume.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __GIO_VOLUME_H__
#define __GIO_VOLUME_H__
#include <gio/gio.h>
#include "Utils.h"
#include <wx/arrstr.h>
#include <wx/string.h>
#include <wx/dynarray.h>
namespace Guayadeque {
class guGIO_Mount;
class guMainFrame;
// -------------------------------------------------------------------------------- //
class guGIO_Volume
{
private :
GVolume * m_Volume;
protected :
public :
guGIO_Volume( GVolume * volume ) { m_Volume = volume; }
~guGIO_Volume( void ) { if( m_Volume ) g_object_unref( m_Volume ); }
wxString GetName( void );
wxString GetUUID( void );
wxString GetIcon( void );
guGIO_Mount GetMount( void );
bool CanMount( void );
bool ShouldAutoMount( void );
bool CanEject( void );
};
// -------------------------------------------------------------------------------- //
class guGIO_Mount
{
private :
GMount * m_Mount;
protected :
wxString m_Id;
bool m_IsReadOnly;
wxString m_Name;
wxString m_MountPath;
wxString m_IconString;
wxString FindWriteableFolder( const wxString &mountpath );
public :
guGIO_Mount( GMount * mount );
guGIO_Mount( GMount * mount, wxString &mountpath );
~guGIO_Mount();
bool IsMount( GMount * mount ) { return m_Mount == mount; }
bool IsReadOnly( void ) { return m_IsReadOnly; }
void SetId( const wxString &id ) { m_Id = id; }
wxString GetId( void ) { return m_Id; }
wxString GetName( void ) { return m_Name; }
wxString GetMountPath( void ) { return m_MountPath; }
wxString IconString( void ) { return m_IconString; }
GVolume GetVolume( void );
bool CanUnmount( void );
void Unmount( void );
};
WX_DEFINE_ARRAY_PTR( guGIO_Mount *, guGIO_MountArray );
// -------------------------------------------------------------------------------- //
class guGIO_VolumeMonitor
{
private :
int m_VolumeAddedId;
int m_VolumeRemovedId;
int m_MountAddedId;
int m_MountPreUnmountId;
int m_MountRemovedId;
protected :
guMainFrame * m_MainFrame;
GVolumeMonitor * m_VolumeMonitor;
guGIO_MountArray * m_MountedVolumes;
int FindMount( GMount * mount );
void GetCurrentMounts( void );
void CheckAudioCDVolume( GVolume * volume, const bool adding );
public :
guGIO_VolumeMonitor( guMainFrame * mainframe );
~guGIO_VolumeMonitor();
void OnMountAdded( GMount * mount );
void OnMountRemoved( GMount * mount );
void OnVolumeAdded( GVolume * volume );
void OnVolumeRemoved( GVolume * volume );
wxArrayString GetMountNames( void );
int GetMountCount( void ) { return m_MountedVolumes->Count(); }
guGIO_Mount * GetMount( const int index ) { return m_MountedVolumes->Item( index ); }
guGIO_Mount * GetMountById( const wxString &id );
guGIO_Mount * GetMountByPath( const wxString &path );
guGIO_Mount * GetMountByName( const wxString &name );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 4,483
|
C++
|
.h
| 109
| 37.743119
| 95
| 0.543738
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,708
|
MD5.h
|
anonbeat_guayadeque/src/misc/MD5.h
|
// -------------------------------------------------------------------------------- //
//
// Name: md5.h
// Author: Kai Krahn
// Created: 11.11.07 12:35
// Description: wxWidgets md5 header
//
// This code implements the MD5 message-digest algorithm.
// The algorithm is due to Ron Rivest. This code is based on the code
// written by Colin Plumb in 1993, no copyright is claimed.
// This code is in the public domain; do with it what you wish.
//
// This version implements the MD5 algorithm for the free GUI toolkit wxWidgets.
// Basic functionality, like MD5 hash creation out of strings and files, or
// to verify strings and files against a given MD5 hash, was added
// by Kai Krahn.
//
// This code is provided "as is" and comes without any warranty!
// -------------------------------------------------------------------------------- //
#ifndef __MD5_H__
#define __MD5_H__
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#else
#include <wx/wxprec.h>
#endif
typedef unsigned int uint32;
// -------------------------------------------------------------------------------- //
class guMD5CTX
{
private:
uint32 m_State[ 4 ];
uint32 m_Count[ 2 ];
unsigned char m_Buffer[ 64 ];
void Transform( uint32 * in );
public:
guMD5CTX();
void Init();
void Update( const unsigned char * InBuffer, unsigned Len );
void Final( unsigned char Digest[ 16 ] );
};
// -------------------------------------------------------------------------------- //
class guMD5
{
private :
guMD5CTX m_Context;
public :
guMD5(){}
wxString inline MD5( const wxString &Input )
{
return MD5( Input.char_str(), Input.Length() );
};
wxString inline MD5( const wxChar * Data, unsigned int Len )
{
return MD5( ( unsigned char * ) Data, Len );
};
wxString MD5( const unsigned char * Data, unsigned int Len );
wxString inline MD5( const void * Data, unsigned int Len )
{
return MD5( ( unsigned char * ) Data, Len );
};
wxString MD5File( const wxString &FileName );
};
#endif
// -------------------------------------------------------------------------------- //
| 2,230
|
C++
|
.h
| 68
| 29.441176
| 86
| 0.535014
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,709
|
Utils.h
|
anonbeat_guayadeque/src/misc/Utils.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef _UTILS_H
#define _UTILS_H
#include <wx/wx.h>
#include <wx/file.h>
#include <wx/wfstream.h>
#include <wx/mstream.h>
#include <wx/xml/xml.h>
namespace Guayadeque {
#ifdef NDEBUG
#define guLogDebug(...)
#define guLogTrace(...) guLogMsgIfDebug( __VA_ARGS__ )
#define guLogMessage wxLogMessage
#define guLogWarning wxLogWarning
#define guLogError wxLogError
#else
#define GU_DEBUG
#define guLogDebug(...) guLogMsgIfDebug( __VA_ARGS__ )
#define guLogTrace wxLogMessage
#define guLogMessage wxLogMessage
#define guLogWarning wxLogWarning
#define guLogError wxLogError
#endif
#define guRandomInit() (srand( time( NULL ) ))
#define guRandom(x) (rand() % x)
#define guDEFAULT_BROWSER_USER_AGENT wxT( "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/55.0.2883.87 Chrome/55.0.2883.87 Safari/537.36" )
class guTrackArray;
class guMediaViewer;
static bool guDebugMode = std::getenv( "GU_DEBUG" ) != NULL;
static bool guGatherStats = std::getenv( "GU_STATS" ) != NULL;
template<typename... Args>
static void guLogMsgIfDebug( Args... what )
{
if( guDebugMode )
guLogMessage( what... );
}
template<typename... Args>
static void guLogStats( Args... what )
{
if( guGatherStats )
guLogMessage( what... );
}
// -------------------------------------------------------------------------------- //
void inline guImageResize( wxImage * image, int maxsize, bool forceresize = false )
{
int w = image->GetWidth();
int h = image->GetHeight();
double ratio = wxMin( static_cast<double>( maxsize ) / h,
static_cast<double>( maxsize ) / w );
if( forceresize || ( ratio < 1 ) )
{
image->Rescale( ( w * ratio ) + .5, ( h * ratio ) + .5, wxIMAGE_QUALITY_HIGH );
}
}
// -------------------------------------------------------------------------------- //
time_t inline GetFileLastChangeTime( const wxString &filename )
{
wxStructStat St;
if( wxStat( filename, &St ) )
return -1;
return St.st_ctime;
}
// -------------------------------------------------------------------------------- //
bool inline IsFileSymbolicLink( const wxString &filename )
{
wxStructStat St;
wxLstat( filename, &St );
return S_ISLNK( St.st_mode );
}
class guTrack;
// -------------------------------------------------------------------------------- //
bool IsColorDark( const wxColour &color );
wxString LenToString( wxUint64 len );
wxString SizeToString( wxFileOffset size );
wxArrayString guSplitWords( const wxString &InputStr );
wxImage * guGetRemoteImage( const wxString &url, wxBitmapType &imgtype );
bool DownloadImage( const wxString &source, const wxString &target, const wxBitmapType imagetype, int maxwidth, int maxheight );
bool DownloadImage( const wxString &source, const wxString &taget, int maxwidth = -1, int maxheight = -1 );
int DownloadFile( const wxString &Source, const wxString &Target );
wxString RemoveSearchFilters( const wxString &Album );
bool SearchCoverWords( const wxString &filename, const wxArrayString &Strings );
wxString guURLEncode( const wxString &url, bool encodespace = true );
wxString guFileDnDEncode( const wxString &file );
int guWebExecute( const wxString &Url );
int guExecute( const wxString &Command );
wxFileOffset guGetFileSize( const wxString &filename );
wxString GetUrlContent( const wxString &url, const wxString &referer = wxEmptyString, bool encoding = false );
void CheckSymLinks( wxArrayString &libpaths );
bool CheckFileLibPath( const wxArrayString &LibPaths, const wxString &filename );
int guGetFileMode( const wxString &filepath );
bool guSetFileMode( const wxString &filepath, int mode, bool adding = false );
bool guRenameFile( const wxString &oldname, const wxString &newname, bool overwrite = true );
wxString guGetNextXMLChunk( wxFile &xmlfile, wxFileOffset &CurPos, const char * startstr, const char * endstr, const wxMBConv &conv = wxConvUTF8 );
wxString guExpandTrackMacros( const wxString &pattern, guTrack * track, const int indexpos = 0 );
bool guIsValidImageFile( const wxString &filename );
bool guRemoveDir( const wxString &path );
void GetMediaViewerTracks( const guTrackArray &sourcetracks, const wxArrayInt &sourceflags,
const guMediaViewer * mediaviewer, guTrackArray &tracks, wxArrayInt &changedflags );
void GetMediaViewerTracks( const guTrackArray &sourcetracks, const int flags,
const guMediaViewer * mediaviewer, guTrackArray &tracks, wxArrayInt &changedflags );
void GetMediaViewerTracks( const guTrackArray &sourcetracks, const guMediaViewer * mediaviewer, guTrackArray &tracks );
void GetMediaViewersList( const guTrackArray &tracks, wxArrayPtrVoid &MediaViewerPtrs );
wxString ExtractString( const wxString &source, const wxString &start, const wxString &end );
}
// -------------------------------------------------------------------------------- //
#endif
| 6,476
|
C++
|
.h
| 126
| 48.468254
| 182
| 0.614121
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,710
|
ThreadArray.h
|
anonbeat_guayadeque/src/misc/ThreadArray.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __THREADARRAY_H__
#define __THREADARRAY_H__
#include <wx/dynarray.h>
#include <wx/thread.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
WX_DEFINE_ARRAY_PTR(wxThread *, guThreadArray);
}
#endif
// -------------------------------------------------------------------------------- //
| 1,404
|
C++
|
.h
| 31
| 44.129032
| 86
| 0.545322
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,711
|
Accelerators.h
|
anonbeat_guayadeque/src/misc/Accelerators.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __ACCELERATORS_H__
#define __ACCELERATORS_H__
#include <wx/wx.h>
namespace Guayadeque {
void guAccelInit( void );
void guAccelOnConfigUpdated( void );
int guAccelGetActionNames( wxArrayString &actionnames );
int guAccelGetDefaultKeys( wxArrayInt &accelkeys );
wxString guAccelGetKeyCodeString( const int keycode );
wxString guAccelGetKeyCodeMenuString( const int keycode );
wxString guAccelGetCommandKeyCodeString( const int cmd );
int guAccelGetCommandKeyCode( const int cmd );
int guAccelDoAcceleratorTable( const wxArrayInt &aliascmds, const wxArrayInt &realcmds, wxAcceleratorTable &acceltable );
}
#endif
// -------------------------------------------------------------------------------- //
| 1,810
|
C++
|
.h
| 37
| 47.783784
| 129
| 0.630656
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,712
|
EventCommandIds.h
|
anonbeat_guayadeque/src/misc/EventCommandIds.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __EVENTCOMMANDIDS_H__
#define __EVENTCOMMANDIDS_H__
namespace Guayadeque {
#define guEVT_USER_FIRST 10000
// -------------------------------------------------------------------------------- //
//
enum guCommandIds {
ID_MENU_UPDATE_LIBRARY = guEVT_USER_FIRST,
ID_MENU_UPDATE_LIBRARYFORCED,
ID_MENU_LIBRARY_ADD_PATH,
ID_MENU_PLAY_STREAM,
ID_MENU_UPDATE_PODCASTS,
ID_MENU_UPDATE_COVERS,
ID_MENU_QUIT,
ID_MENU_PREFERENCES,
ID_MENU_PREFERENCES_COMMANDS,
ID_MENU_PREFERENCES_LINKS,
ID_MENU_PREFERENCES_COPYTO,
ID_MENU_VIEW_STATUSBAR,
ID_MENU_VIEW_FULLSCREEN,
ID_MENU_VIEW_PLAYER_PLAYLIST,
ID_MENU_VIEW_PLAYER_FILTERS,
ID_MENU_VIEW_PLAYER_VUMETERS,
ID_MENU_VIEW_PLAYER_NOTEBOOK,
ID_MENU_VIEW_MAIN_LOCATIONS,
ID_MENU_VIEW_MAIN_SHOWCOVER,
ID_MENU_VIEW_CLOSEWINDOW,
ID_MENU_VIEW_AUDIOCD,
ID_MENU_VOLUME_DOWN,
ID_MENU_VOLUME_UP,
ID_MENU_HIDE_CAPTIONS,
//
ID_MENU_VIEW_LIBRARY,
ID_MENU_VIEW_LIB_LABELS,
ID_MENU_VIEW_LIB_GENRES,
ID_MENU_VIEW_LIB_ARTISTS,
ID_MENU_VIEW_LIB_COMPOSERS,
ID_MENU_VIEW_LIB_ALBUMARTISTS,
ID_MENU_VIEW_LIB_ALBUMS,
ID_MENU_VIEW_LIB_YEARS,
ID_MENU_VIEW_LIB_RATINGS,
ID_MENU_VIEW_LIB_PLAYCOUNT,
ID_MENU_VIEW_LASTFM,
ID_MENU_VIEW_RADIO,
ID_MENU_VIEW_RAD_TEXTSEARCH,
ID_MENU_VIEW_RAD_LABELS,
ID_MENU_VIEW_RAD_GENRES,
ID_MENU_VIEW_RAD_PROPERTIES,
ID_MENU_VIEW_LYRICS,
ID_MENU_VIEW_PLAYLISTS,
ID_MENU_VIEW_PODCASTS,
ID_MENU_VIEW_POD_CHANNELS,
ID_MENU_VIEW_POD_DETAILS,
ID_MENU_VIEW_POD_PROPERTIES,
ID_MENU_VIEW_ALBUMBROWSER,
ID_MENU_VIEW_FILEBROWSER,
ID_MENU_VIEW_TREEVIEW,
//
ID_MENU_COLLECTION_NEW,
// ID_MENU_VIEW_IPOD,
// ID_MENU_VIEW_FBR_DETAILS,
ID_MENU_LAYOUT_CREATE,
ID_MENU_LAYOUT_DUMMY,
ID_MENU_ABOUT,
ID_MENU_HELP,
ID_MENU_COMMUNITY,
//
ID_MAINFRAME_COPYTO,
ID_MAINFRAME_COPYTODEVICE_TRACKS,
ID_MAINFRAME_COPYTODEVICE_PLAYLIST,
ID_MAINFRAME_REMOVEPODCASTTHREAD,
ID_MAINFRAME_UPDATE_SELINFO,
ID_MAINFRAME_SELECT_ALBUM,
ID_MAINFRAME_SELECT_ALBUMNAME,
ID_MAINFRAME_SELECT_ARTIST,
ID_MAINFRAME_SELECT_ARTISTNAME,
ID_MAINFRAME_SELECT_ALBUMARTIST,
ID_MAINFRAME_SELECT_ALBUMARTISTNAME,
ID_MAINFRAME_SELECT_COMPOSER,
ID_MAINFRAME_SELECT_COMPOSERNAME,
ID_MAINFRAME_SELECT_TRACK,
ID_MAINFRAME_SELECT_YEAR,
ID_MAINFRAME_SELECT_GENRE,
ID_MAINFRAME_SELECT_PODCAST,
ID_MAINFRAME_REQUEST_CURRENTTRACK,
ID_MAINFRAME_SELECT_LOCATION,
ID_MAINFRAME_SETFORCEGAPLESS,
ID_MAINFRAME_SETAUDIOSCROBBLE,
ID_MAINFRAME_LYRICSSEARCHFIRST,
ID_MAINFRAME_LYRICSSEARCHNEXT,
ID_MAINFRAME_LYRICSSAVECHANGES,
ID_MAINFRAME_LYRICSEXECCOMMAND,
ID_MAINFRAME_SET_ALLOW_PLAYLIST,
ID_MAINFRAME_SET_DENY_PLAYLIST,
ID_MAINFRAME_WINDOW_RAISE,
ID_MAINFRAME_LOAD_PLAYLIST,
ID_MAINFRAME_MEDIAVIEWER_CLOSED,
//
ID_LIBRARY_UPDATED,
ID_LIBRARY_DOCLEANDB,
ID_LIBRARY_CLEANFINISHED,
ID_LIBRARY_RELOADCONTROLS,
ID_LIBRARY_SEARCH,
//
ID_GENRE_PLAY,
ID_GENRE_ENQUEUE_AFTER_ALL,
ID_GENRE_ENQUEUE_AFTER_TRACK,
ID_GENRE_ENQUEUE_AFTER_ALBUM,
ID_GENRE_ENQUEUE_AFTER_ARTIST,
ID_GENRE_SELECTNAME,
ID_GENRE_SETSELECTION,
ID_GENRE_SAVETOPLAYLIST,
//
ID_LABEL_ADD,
ID_LABEL_DELETE,
ID_LABEL_EDIT,
ID_LABEL_PLAY,
ID_LABEL_ENQUEUE_AFTER_ALL,
ID_LABEL_ENQUEUE_AFTER_TRACK,
ID_LABEL_ENQUEUE_AFTER_ALBUM,
ID_LABEL_ENQUEUE_AFTER_ARTIST,
ID_LABEL_UPDATELABELS,
ID_LABEL_SAVETOPLAYLIST,
//
ID_ARTIST_PLAY,
ID_ARTIST_ENQUEUE_AFTER_ALL,
ID_ARTIST_ENQUEUE_AFTER_TRACK,
ID_ARTIST_ENQUEUE_AFTER_ALBUM,
ID_ARTIST_ENQUEUE_AFTER_ARTIST,
ID_ARTIST_EDITLABELS,
ID_ARTIST_EDITTRACKS,
ID_ARTIST_SETSELECTION,
ID_ARTIST_SELECTNAME,
ID_ARTIST_SAVETOPLAYLIST,
ID_ARTIST_CREATE_BESTOF_PLAYLIST,
//
ID_ALBUM_PLAY,
ID_ALBUM_ENQUEUE_AFTER_ALL,
ID_ALBUM_ENQUEUE_AFTER_TRACK,
ID_ALBUM_ENQUEUE_AFTER_ALBUM,
ID_ALBUM_ENQUEUE_AFTER_ARTIST,
ID_ALBUM_EDITLABELS,
ID_ALBUM_EDITTRACKS,
ID_ALBUM_MANUALCOVER,
ID_ALBUM_COVER_CHANGED,
ID_ALBUM_COVER_DELETE,
ID_ALBUM_COVER_EMBED,
ID_ALBUM_SETSELECTION,
ID_ALBUM_SELECTNAME,
ID_ALBUM_SELECT_COVER,
ID_ALBUM_SAVETOPLAYLIST,
ID_ALBUM_CREATE_BESTOF_PLAYLIST,
//
ID_ALBUM_ORDER_NAME,
ID_ALBUM_ORDER_YEAR,
ID_ALBUM_ORDER_YEAR_REVERSE,
ID_ALBUM_ORDER_ARTIST_NAME,
ID_ALBUM_ORDER_ARTIST_YEAR,
ID_ALBUM_ORDER_ARTIST_YEAR_REVERSE,
//
ID_YEAR_PLAY,
ID_YEAR_ENQUEUE_AFTER_ALL,
ID_YEAR_ENQUEUE_AFTER_TRACK,
ID_YEAR_ENQUEUE_AFTER_ALBUM,
ID_YEAR_ENQUEUE_AFTER_ARTIST,
ID_YEAR_EDITTRACKS,
ID_YEAR_SAVETOPLAYLIST,
//
ID_RATING_PLAY,
ID_RATING_ENQUEUE_AFTER_ALL,
ID_RATING_ENQUEUE_AFTER_TRACK,
ID_RATING_ENQUEUE_AFTER_ALBUM,
ID_RATING_ENQUEUE_AFTER_ARTIST,
ID_RATING_EDITTRACKS,
ID_RATING_SAVETOPLAYLIST,
//
ID_PLAYCOUNT_PLAY,
ID_PLAYCOUNT_ENQUEUE_AFTER_ALL,
ID_PLAYCOUNT_ENQUEUE_AFTER_TRACK,
ID_PLAYCOUNT_ENQUEUE_AFTER_ALBUM,
ID_PLAYCOUNT_ENQUEUE_AFTER_ARTIST,
ID_PLAYCOUNT_EDITTRACKS,
ID_PLAYCOUNT_SAVETOPLAYLIST,
//
ID_COMPOSER_PLAY,
ID_COMPOSER_ENQUEUE_AFTER_ALL,
ID_COMPOSER_ENQUEUE_AFTER_TRACK,
ID_COMPOSER_ENQUEUE_AFTER_ALBUM,
ID_COMPOSER_ENQUEUE_AFTER_ARTIST,
ID_COMPOSER_EDITTRACKS,
ID_COMPOSER_SETSELECTION,
ID_COMPOSER_SAVETOPLAYLIST,
//
ID_ALBUMARTIST_PLAY,
ID_ALBUMARTIST_ENQUEUE_AFTER_ALL,
ID_ALBUMARTIST_ENQUEUE_AFTER_TRACK,
ID_ALBUMARTIST_ENQUEUE_AFTER_ALBUM,
ID_ALBUMARTIST_ENQUEUE_AFTER_ARTIST,
ID_ALBUMARTIST_EDITTRACKS,
ID_ALBUMARTIST_SETSELECTION,
ID_ALBUMARTIST_SAVETOPLAYLIST,
ID_ALBUMARTIST_CREATE_BESTOF_PLAYLIST,
//
ID_TRACKS_PLAY,
ID_TRACKS_PLAYALL,
ID_TRACKS_ENQUEUE_AFTER_ALL,
ID_TRACKS_ENQUEUE_AFTER_TRACK,
ID_TRACKS_ENQUEUE_AFTER_ALBUM,
ID_TRACKS_ENQUEUE_AFTER_ARTIST,
ID_TRACKS_EDITLABELS,
ID_TRACKS_EDITTRACKS,
ID_TRACKS_SAVETOPLAYLIST,
ID_TRACKS_DELETE_LIBRARY,
ID_TRACKS_DELETE,
ID_TRACKS_DELETE_DRIVE,
ID_TRACKS_BROWSE_GENRE,
ID_TRACKS_BROWSE_ARTIST,
ID_TRACKS_BROWSE_ALBUMARTIST,
ID_TRACKS_BROWSE_COMPOSER,
ID_TRACKS_BROWSE_ALBUM,
ID_TRACKS_SELECTNAME,
ID_TRACKS_EDIT_COLUMN,
ID_TRACKS_SET_COLUMN,
ID_TRACKS_SET_RATING_0,
ID_TRACKS_SET_RATING_1,
ID_TRACKS_SET_RATING_2,
ID_TRACKS_SET_RATING_3,
ID_TRACKS_SET_RATING_4,
ID_TRACKS_SET_RATING_5,
ID_TRACKS_RANDOMIZE,
//
ID_PLAYER_PLAYLIST_UPDATETITLE,
ID_PLAYER_PLAYLIST_UPDATELIST,
ID_PLAYER_PLAYLIST_CLEAR,
ID_PLAYER_PLAYLIST_REMOVE,
ID_PLAYER_PLAYLIST_SAVE,
ID_PLAYER_PLAYLIST_CREATE_BESTOF,
ID_PLAYER_PLAYMODE_SMART,
ID_PLAYER_PLAYLIST_RANDOMPLAY,
ID_PLAYER_PLAYMODE_REPEAT_PLAYLIST,
ID_PLAYER_PLAYMODE_REPEAT_TRACK,
ID_PLAYER_PLAYLIST_SMART_ADDTRACK,
ID_PLAYER_PLAYLIST_EDITLABELS,
ID_PLAYER_PLAYLIST_EDITTRACKS,
ID_PLAYER_PLAYLIST_SEARCH,
ID_PLAYER_PLAYLIST_SELECT_TITLE,
ID_PLAYER_PLAYLIST_SELECT_ARTIST,
ID_PLAYER_PLAYLIST_SELECT_ALBUM,
ID_PLAYER_PLAYLIST_SELECT_ALBUMARTIST,
ID_PLAYER_PLAYLIST_SELECT_COMPOSER,
ID_PLAYER_PLAYLIST_SELECT_GENRE,
ID_PLAYER_PLAYLIST_SELECT_YEAR,
ID_PLAYER_PLAYLIST_DELETE_LIBRARY,
ID_PLAYER_PLAYLIST_DELETE_DRIVE,
ID_PLAYER_PLAYLIST_STOP_ATEND,
ID_PLAYER_PLAYLIST_SET_NEXT_TRACK,
ID_PLAYER_PLAYLIST_START_SAVETIMER,
//
ID_RADIO_PLAY,
ID_RADIO_ENQUEUE_AFTER_ALL,
ID_RADIO_ENQUEUE_AFTER_TRACK,
ID_RADIO_ENQUEUE_AFTER_ALBUM,
ID_RADIO_ENQUEUE_AFTER_ARTIST,
ID_RADIO_DOUPDATE,
ID_RADIO_UPDATED,
ID_RADIO_ADD_TO_USER,
ID_RADIO_CREATE_TREE_ITEM,
ID_RADIO_UPDATE_END,
ID_RADIO_GENRE_ADD,
ID_RADIO_GENRE_EDIT,
ID_RADIO_GENRE_DELETE,
ID_RADIO_SEARCH_ADD,
ID_RADIO_SEARCH_EDIT,
ID_RADIO_SEARCH_DELETE,
ID_RADIO_EDIT_LABELS,
ID_RADIO_USER_ADD,
ID_RADIO_USER_EDIT,
ID_RADIO_USER_DEL,
ID_RADIO_USER_EXPORT,
ID_RADIO_USER_IMPORT,
ID_RADIO_PLAYLIST_LOADED,
ID_RADIO_SEARCH,
ID_RADIO_LOADING_STATIONS_FINISHED,
//
ID_PLAYERPANEL_PLAY,
ID_PLAYERPANEL_STOP,
ID_PLAYERPANEL_NEXTTRACK,
ID_PLAYERPANEL_PREVTRACK,
ID_PLAYERPANEL_NEXTALBUM,
ID_PLAYERPANEL_PREVALBUM,
ID_PLAYERPANEL_UPDATERADIOTRACK,
ID_PLAYERPANEL_TRACKCHANGED,
ID_PLAYERPANEL_COVERUPDATED,
ID_PLAYERPANEL_CAPSCHANGED,
ID_PLAYERPANEL_STATUSCHANGED,
ID_PLAYERPANEL_TRACKLISTCHANGED,
ID_PLAYERPANEL_PLAYMODECHANGED,
ID_PLAYERPANEL_VOLUMECHANGED,
ID_PLAYERPANEL_SEEKED,
ID_PLAYERPANEL_SETRATING_0,
ID_PLAYERPANEL_SETRATING_1,
ID_PLAYERPANEL_SETRATING_2,
ID_PLAYERPANEL_SETRATING_3,
ID_PLAYERPANEL_SETRATING_4,
ID_PLAYERPANEL_SETRATING_5,
ID_PLAYERPANEL_ADDTRACKS,
ID_PLAYERPANEL_REMOVETRACK,
ID_PLAYERPANEL_SETREPEAT,
ID_PLAYERPANEL_SETLOOP,
ID_PLAYERPANEL_SETRANDOM,
ID_PLAYERPANEL_SETVOLUME,
//
ID_AUDIOSCROBBLE_UPDATED,
// Commands for the CoverEditor
ID_COVEREDITOR_ADDCOVERIMAGE,
ID_COVEREDITOR_DOWNLOADEDLINKS,
ID_SELCOVERDIALOG_FINISH,
// Commands for LastFM Panel
ID_LASTFM_UPDATE_ARTISTINFO, // The thread update the Artist Info
ID_LASTFM_UPDATE_ALBUMINFO, // The thread update the top albums
ID_LASTFM_UPDATE_ALBUM_COUNT,
ID_LASTFM_UPDATE_TOPTRACKS, // The thread update the top tracks
ID_LASTFM_UPDATE_TOPTRACKS_COUNT,
ID_LASTFM_UPDATE_SIMARTIST, // The thread update the Similar artists
ID_LASTFM_UPDATE_SIMARTIST_COUNT,
ID_LASTFM_UPDATE_SIMTRACK, // The thread update the Similar tracks
ID_LASTFM_UPDATE_SIMTRACK_COUNT, // The thread update the Similar tracks
ID_LASTFM_UPDATE_EVENTINFO,
ID_LASTFM_UPDATE_EVENTS_COUNT,
ID_LASTFM_PLAY,
ID_LASTFM_ENQUEUE_AFTER_ALL,
ID_LASTFM_ENQUEUE_AFTER_TRACK,
ID_LASTFM_ENQUEUE_AFTER_ALBUM,
ID_LASTFM_ENQUEUE_AFTER_ARTIST,
ID_LASTFM_SELECT_ARTIST,
ID_LASTFM_VISIT_URL,
ID_LASTFM_COPYTOCLIPBOARD,
ID_LASTFM_SAVETOPLAYLIST,
//
ID_STATUSBAR_GAUGE_CREATE,
ID_STATUSBAR_GAUGE_CREATED,
ID_STATUSBAR_GAUGE_PULSE,
ID_STATUSBAR_GAUGE_SETMAX,
ID_STATUSBAR_GAUGE_UPDATE,
ID_STATUSBAR_GAUGE_REMOVE,
//
ID_LYRICS_UPDATE_LYRICINFO,
ID_LYRICS_COPY,
ID_LYRICS_PASTE,
ID_LYRICS_PRINT,
ID_LYRICS_LYRICFOUND,
//
ID_MULTIMEDIAKEYS_DBUS,
//
ID_PLAYLIST_PLAY,
ID_PLAYLIST_ENQUEUE_AFTER_ALL,
ID_PLAYLIST_ENQUEUE_AFTER_TRACK,
ID_PLAYLIST_ENQUEUE_AFTER_ALBUM,
ID_PLAYLIST_ENQUEUE_AFTER_ARTIST,
ID_PLAYLIST_NEWPLAYLIST,
ID_PLAYLIST_EDIT,
ID_PLAYLIST_RENAME,
ID_PLAYLIST_DELETE,
ID_PLAYLIST_UPDATED,
ID_PLAYLIST_IMPORT,
ID_PLAYLIST_EXPORT,
ID_PLAYLIST_SEARCH,
ID_PLAYLIST_SMART_PLAYLIST,
//
ID_PODCASTS_CHANNEL_ADD,
ID_PODCASTS_CHANNEL_DEL,
ID_PODCASTS_CHANNEL_PROPERTIES,
ID_PODCASTS_CHANNEL_UPDATE,
ID_PODCASTS_CHANNEL_UNDELETE,
//
ID_PODCASTS_ITEM_DEL,
ID_PODCASTS_ITEM_PLAY,
ID_PODCASTS_ITEM_ENQUEUE_AFTER_ALL,
ID_PODCASTS_ITEM_ENQUEUE_AFTER_TRACK,
ID_PODCASTS_ITEM_ENQUEUE_AFTER_ALBUM,
ID_PODCASTS_ITEM_ENQUEUE_AFTER_ARTIST,
ID_PODCASTS_ITEM_DOWNLOAD,
ID_PODCASTS_ITEM_UPDATED,
//
ID_ALBUMBROWSER_PLAY,
ID_ALBUMBROWSER_ENQUEUE_AFTER_ALL,
ID_ALBUMBROWSER_ENQUEUE_AFTER_TRACK,
ID_ALBUMBROWSER_ENQUEUE_AFTER_ALBUM,
ID_ALBUMBROWSER_ENQUEUE_AFTER_ARTIST,
ID_ALBUMBROWSER_EDITLABELS,
ID_ALBUMBROWSER_EDITTRACKS,
ID_ALBUMBROWSER_SEARCHCOVER,
ID_ALBUMBROWSER_SELECTCOVER,
ID_ALBUMBROWSER_DELETECOVER,
ID_ALBUMBROWSER_EMBEDCOVER,
ID_ALBUMBROWSER_COPYTOCLIPBOARD,
ID_ALBUMBROWSER_UPDATEDETAILS,
ID_ALBUMBROWSER_BEGINDRAG,
ID_ALBUMBROWSER_COVER_BEGINDRAG,
ID_ALBUMBROWSER_SEARCH,
ID_ALBUMBROWSER_ORDER_NAME,
ID_ALBUMBROWSER_ORDER_YEAR,
ID_ALBUMBROWSER_ORDER_YEAR_REVERSE,
ID_ALBUMBROWSER_ORDER_ARTIST,
ID_ALBUMBROWSER_ORDER_ARTIST_YEAR,
ID_ALBUMBROWSER_ORDER_ARTIST_YEAR_REVERSE,
ID_ALBUMBROWSER_ORDER_ADDEDTIME,
ID_ALBUMBROWSER_TRACKS_PLAY,
ID_ALBUMBROWSER_TRACKS_ENQUEUE_AFTER_ALL,
ID_ALBUMBROWSER_TRACKS_ENQUEUE_AFTER_TRACK,
ID_ALBUMBROWSER_TRACKS_ENQUEUE_AFTER_ALBUM,
ID_ALBUMBROWSER_TRACKS_ENQUEUE_AFTER_ARTIST,
ID_ALBUMBROWSER_TRACKS_EDITLABELS,
ID_ALBUMBROWSER_TRACKS_EDITTRACKS,
ID_ALBUMBROWSER_TRACKS_BEGINDRAG,
ID_ALBUMBROWSER_TRACKS_PLAYLIST_SAVE,
ID_ALBUMBROWSER_TRACKS_SMART_PLAYLIST,
//
ID_FILESYSTEM_FOLDER_PLAY,
ID_FILESYSTEM_FOLDER_ENQUEUE_AFTER_ALL,
ID_FILESYSTEM_FOLDER_ENQUEUE_AFTER_TRACK,
ID_FILESYSTEM_FOLDER_ENQUEUE_AFTER_ALBUM,
ID_FILESYSTEM_FOLDER_ENQUEUE_AFTER_ARTIST,
ID_FILESYSTEM_FOLDER_NEW,
ID_FILESYSTEM_FOLDER_RENAME,
ID_FILESYSTEM_FOLDER_DELETE,
ID_FILESYSTEM_FOLDER_COPY,
ID_FILESYSTEM_FOLDER_PASTE,
ID_FILESYSTEM_FOLDER_EDITTRACKS,
ID_FILESYSTEM_FOLDER_SAVEPLAYLIST,
ID_FILESYSTEM_FOLDER_UPDATE,
ID_FILESYSTEM_ITEMS_PLAY,
ID_FILESYSTEM_ITEMS_ENQUEUE_AFTER_ALL,
ID_FILESYSTEM_ITEMS_ENQUEUE_AFTER_TRACK,
ID_FILESYSTEM_ITEMS_ENQUEUE_AFTER_ALBUM,
ID_FILESYSTEM_ITEMS_ENQUEUE_AFTER_ARTIST,
ID_FILESYSTEM_ITEMS_EDITTRACKS,
ID_FILESYSTEM_ITEMS_RENAME,
ID_FILESYSTEM_ITEMS_DELETE,
ID_FILESYSTEM_ITEMS_COPY,
ID_FILESYSTEM_ITEMS_PASTE,
ID_FILESYSTEM_ITEMS_SAVEPLAYLIST,
//
ID_JAMENDO_UPDATE, // Redownload the latest database
ID_JAMENDO_UPGRADE, // Actualiza las canciones
ID_JAMENDO_EDIT_GENRES,
ID_JAMENDO_SETUP,
ID_JAMENDO_UPDATE_FINISHED,
ID_JAMENDO_COVER_DOWNLAODED,
ID_JAMENDO_DOWNLOAD_TORRENT_ALBUM,
ID_JAMENDO_DOWNLOAD_TORRENT_TRACK_ALBUM,
ID_JAMENDO_DOWNLOAD_DIRECT_ALBUM,
ID_JAMENDO_DOWNLOAD_DIRECT_TRACK_ALBUM,
ID_JAMENDO_DOWNLOAD_DIRECTLY,
//
ID_MAGNATUNE_UPDATE, // Redownload the latest database
ID_MAGNATUNE_UPGRADE, // Actualiza las canciones
ID_MAGNATUNE_EDIT_GENRES,
ID_MAGNATUNE_SETUP,
ID_MAGNATUNE_UPDATE_FINISHED,
ID_MAGNATUNE_COVER_DOWNLAODED,
ID_MAGNATUNE_DOWNLOAD_DIRECT_ALBUM,
ID_MAGNATUNE_DOWNLOAD_DIRECT_TRACK_ALBUM,
ID_MAGNATUNE_DOWNLOAD_DIRECTLY,
//
ID_TREEVIEW_FILTER_NEW,
ID_TREEVIEW_FILTER_EDIT,
ID_TREEVIEW_FILTER_DELETE,
ID_TREEVIEW_EDITLABELS,
ID_TREEVIEW_EDITTRACKS,
ID_TREEVIEW_SAVETOPLAYLIST,
ID_TREEVIEW_PLAY,
ID_TREEVIEW_ENQUEUE_AFTER_ALL,
ID_TREEVIEW_ENQUEUE_AFTER_TRACK,
ID_TREEVIEW_ENQUEUE_AFTER_ALBUM,
ID_TREEVIEW_ENQUEUE_AFTER_ARTIST,
ID_TREEVIEW_SEARCH,
//
ID_AUDIOCD_ITEM_PLAY,
ID_AUDIOCD_ITEM_ENQUEUE_AFTER_ALL,
ID_AUDIOCD_ITEM_ENQUEUE_AFTER_TRACK,
ID_AUDIOCD_ITEM_ENQUEUE_AFTER_ALBUM,
ID_AUDIOCD_ITEM_ENQUEUE_AFTER_ARTIST,
ID_AUDIOCD_REFRESH_METADATA,
ID_AUDIOCD_EDIT_COLUMN,
ID_AUDIOCD_SET_COLUMN,
//
ID_VOLUMEMANAGER_MOUNT_CHANGED,
ID_VOLUMEMANAGER_AUDIOCD_CHANGED,
//
ID_PORTABLEDEVICE_UPDATE,
ID_PORTABLEDEVICE_PROPERTIES,
ID_PORTABLEDEVICE_UNMOUNT,
//
ID_CONFIG_UPDATED,
//
ID_SMARTMODE_ADD_TRACKS,
ID_SMARTMODE_THREAD_END,
//
ID_MENU_LAYOUT_LOAD = guEVT_USER_FIRST + 2000,
ID_MENU_LAYOUT_DELETE = guEVT_USER_FIRST + 2100,
//
ID_LINKS_BASE = guEVT_USER_FIRST + 2200, // to 2299
//
// We reserve 200 Ids for the CopyTo patterns. The 2nd 100 are for copy to portable devices
ID_COPYTO_BASE = guEVT_USER_FIRST + 2300, // to 2499
//
// Reserve 100 ids for commands
ID_COMMANDS_BASE = guEVT_USER_FIRST + 2500, // to 3099
//
// Reserve 40 ids for each collection
ID_MENU_VIEW_PORTABLE_DEVICE = guEVT_USER_FIRST + 3000,
ID_COLLECTIONS_BASE = guEVT_USER_FIRST + 3100
};
enum guCollectionActionId {
guCOLLECTION_ACTION_VIEW_COLLECTION = 0,
guCOLLECTION_ACTION_VIEW_LIBRARY,
guCOLLECTION_ACTION_VIEW_LIB_LABELS,
guCOLLECTION_ACTION_VIEW_LIB_GENRES,
guCOLLECTION_ACTION_VIEW_LIB_ARTISTS,
guCOLLECTION_ACTION_VIEW_LIB_COMPOSERS,
guCOLLECTION_ACTION_VIEW_LIB_ALBUMARTISTS,
guCOLLECTION_ACTION_VIEW_LIB_ALBUMS,
guCOLLECTION_ACTION_VIEW_LIB_YEARS,
guCOLLECTION_ACTION_VIEW_LIB_RATINGS,
guCOLLECTION_ACTION_VIEW_LIB_PLAYCOUNT,
guCOLLECTION_ACTION_VIEW_ALBUMBROWSER,
guCOLLECTION_ACTION_VIEW_TREEVIEW,
guCOLLECTION_ACTION_VIEW_PLAYLISTS,
guCOLLECTION_ACTION_UPDATE_LIBRARY,
guCOLLECTION_ACTION_RESCAN_LIBRARY,
guCOLLECTION_ACTION_SEARCH_COVERS,
guCOLLECTION_ACTION_ADD_PATH,
guCOLLECTION_ACTION_VIEW_PROPERTIES,
guCOLLECTION_ACTION_IMPORT,
guCOLLECTION_ACTION_UNMOUNT,
guCOLLECTION_ACTION_COUNT // Leave this always the end
};
}
#endif
// -------------------------------------------------------------------------------- //
| 18,068
|
C++
|
.h
| 562
| 27.391459
| 95
| 0.708824
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,713
|
MainFrame.h
|
anonbeat_guayadeque/src/ui/MainFrame.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __MAINFRAME_H__
#define __MAINFRAME_H__
#include "AlbumBrowser.h"
#include "AudioCdPanel.h"
#include "AuiNotebook.h"
#include "Config.h"
#include "CoverPanel.h"
#include "Collections.h"
#include "Http.h"
#include "dbus/gudbus.h"
#include "dbus/mpris.h"
#include "dbus/mpris2.h"
#include "dbus/mmkeys.h"
#include "dbus/gsession.h"
#include "dbus/notify.h"
#include "DbLibrary.h"
#include "DbCache.h"
#include "FileBrowser.h"
#include "Jamendo.h"
#include "LastFM.h"
#include "LastFMPanel.h"
#include "LibPanel.h"
#include "GIO_Volume.h"
#include "LyricsPanel.h"
#include "Magnatune.h"
#include "MediaViewer.h"
#include "PlayerFilters.h"
#include "PlayerPanel.h"
#include "PlayListPanel.h"
#include "PodcastsPanel.h"
#include "PortableMedia.h"
#include "RadioPanel.h"
#include "StatusBar.h"
#include "SplashWin.h"
#include "TrackEdit.h"
#include "TreePanel.h"
#include "Vumeters.h"
#include <wx/aui/aui.h>
#include <wx/wx.h>
#include <wx/splitter.h>
#include <wx/regex.h>
#include <wx/sstream.h>
#include <wx/uri.h>
#include <wx/xml/xml.h>
#include <wx/zstream.h>
namespace Guayadeque {
#define guPANEL_MAIN_PLAYERPLAYLIST ( 1 << 0 )
#define guPANEL_MAIN_PLAYERFILTERS ( 1 << 1 )
#define guPANEL_MAIN_PLAYERVUMETERS ( 1 << 2 )
#define guPANEL_MAIN_LIBRARY ( 1 << 3 )
#define guPANEL_MAIN_RADIOS ( 1 << 4 )
#define guPANEL_MAIN_LASTFM ( 1 << 5 )
#define guPANEL_MAIN_LYRICS ( 1 << 6 )
#define guPANEL_MAIN_PLAYLISTS ( 1 << 7 )
#define guPANEL_MAIN_PODCASTS ( 1 << 8 )
#define guPANEL_MAIN_ALBUMBROWSER ( 1 << 9 )
#define guPANEL_MAIN_FILEBROWSER ( 1 << 10 )
#define guPANEL_MAIN_JAMENDO ( 1 << 11 )
#define guPANEL_MAIN_MAGNATUNE ( 1 << 12 )
#define guPANEL_MAIN_LOCATIONS ( 1 << 13 )
#define guPANEL_MAIN_SHOWCOVER ( 1 << 14 )
#define guPANEL_MAIN_TREEVIEW ( 1 << 15 )
#define guPANEL_MAIN_AUDIOCD ( 1 << 16 )
#define guPANEL_MAIN_SELECTOR ( guPANEL_MAIN_RADIOS | guPANEL_MAIN_LASTFM | guPANEL_MAIN_LYRICS | guPANEL_MAIN_PODCASTS )
#define guPANEL_MAIN_VISIBLE_DEFAULT ( guPANEL_MAIN_PLAYERPLAYLIST | guPANEL_MAIN_PLAYERFILTERS | \
guPANEL_MAIN_SELECTOR )
#define guPORTABLEDEVICE_COMMANDS_COUNT 20 // 0 .. 9 Main Window Commands
// 10 .. 19 -> Library Pane Windows
#define guWINDOW_STATE_NORMAL 0
#define guWINDOW_STATE_FULLSCREEN ( 1 << 0 )
#define guWINDOW_STATE_MAXIMIZED ( 1 << 1 )
#define guWINDOW_STATE_NOSTATUSBAR ( 1 << 3 )
enum guUPDATED_TRACKS {
guUPDATED_TRACKS_NONE = 0,
guUPDATED_TRACKS_PLAYER,
guUPDATED_TRACKS_PLAYER_PLAYLIST,
// guUPDATED_TRACKS_PLAYLISTS,
// guUPDATED_TRACKS_TREEVIEW,
// guUPDATED_TRACKS_LIBRARY,
guUPDATED_TRACKS_MEDIAVIEWER
};
class guTaskBarIcon;
class guLibUpdateThread;
class guLibCleanThread;
class guUpdatePodcastsTimer;
class guCopyToThread;
class guLocationPanel;
// -------------------------------------------------------------------------------- //
class guMainFrame : public wxFrame
{
private :
static guMainFrame * m_MainFrame;
private:
wxAuiManager m_AuiManager;
unsigned int m_VisiblePanels;
guAuiNotebook * m_MainNotebook;
bool m_DestroyLastWindow;
wxString m_NBPerspective;
wxSplitterWindow * m_PlayerSplitter;
guPlayerFilters * m_PlayerFilters;
guPlayerPlayList * m_PlayerPlayList;
guPlayerVumeters * m_PlayerVumeters;
guPlayerPanel * m_PlayerPanel;
guRadioPanel * m_RadioPanel;
guLastFMPanel * m_LastFMPanel;
guLyricsPanel * m_LyricsPanel;
guPodcastPanel * m_PodcastsPanel;
guFileBrowser * m_FileBrowserPanel;
guLocationPanel * m_LocationPanel;
guCoverPanel * m_CoverPanel;
guAudioCdPanel * m_AudioCdPanel;
guTaskBarIcon * m_TaskBarIcon;
guStatusBar * m_MainStatusBar;
wxMenuItem * m_MenuPlaySmart;
wxMenuItem * m_MenuLoopPlayList;
wxMenuItem * m_MenuLoopTrack;
wxMenu * m_MenuLayoutLoad;
wxMenu * m_MenuLayoutDelete;
wxMenuItem * m_MenuPlayerPlayList;
wxMenuItem * m_MenuPlayerFilters;
wxMenuItem * m_MenuPlayerVumeters;
wxMenuItem * m_MenuMainLocations;
wxMenuItem * m_MenuMainShowCover;
wxMenuItem * m_MenuRadios;
wxMenuItem * m_MenuRadTextSearch;
// wxMenuItem * m_MenuRadLabels;
wxMenuItem * m_MenuRadGenres;
wxMenuItem * m_MenuRadUpdate;
wxMenuItem * m_MenuPodcasts;
wxMenuItem * m_MenuPodChannels;
wxMenuItem * m_MenuPodDetails;
wxMenuItem * m_MenuPodUpdate;
wxMenuItem * m_MenuLastFM;
wxMenuItem * m_MenuLyrics;
wxMenuItem * m_MenuAudioCD;
wxMenuItem * m_MenuFileBrowser;
wxMenuItem * m_MenuFullScreen;
wxMenuItem * m_MenuStatusBar;
wxMenuItem * m_MenuForceGapless;
wxMenuItem * m_MenuAudioScrobble;
wxMenu * m_MenuCollections;
guDbLibrary * m_Db;
guDbCache * m_DbCache;
guDbPodcasts * m_DbPodcasts;
wxIcon m_AppIcon;
guUpdatePodcastsTimer * m_UpdatePodcastsTimer;
guPodcastDownloadQueueThread * m_DownloadThread;
wxMutex m_DownloadThreadMutex;
guDBusServer * m_DBusServer;
guMPRIS * m_MPRIS;
guMPRIS2 * m_MPRIS2;
guMMKeys * m_MMKeys;
guGSession * m_GSession;
guDBusNotify * m_NotifySrv;
guGIO_VolumeMonitor * m_VolumeMonitor;
wxWindow * m_CurrentPage;
wxLongLong m_SelCount;
wxLongLong m_SelLength;
wxLongLong m_SelSize;
// Layouts
wxArrayString m_LayoutNames;
guCopyToThread * m_CopyToThread;
wxMutex m_CopyToThreadMutex;
guLyricSearchEngine * m_LyricSearchEngine;
guLyricSearchContext * m_LyricSearchContext;
guMediaCollectionArray m_Collections;
wxMutex m_CollectionsMutex;
guMediaViewerArray m_MediaViewers;
int m_LoadLayoutPending;
// Store the Pending Update Tracks
guTrackArray m_PendingUpdateTracks;
wxArrayString m_PendingUpdateFiles;
guImagePtrArray m_PendingUpdateImages;
wxArrayString m_PendingUpdateLyrics;
wxArrayInt m_PendingUpdateFlags;
wxMutex m_PendingUpdateMutex;
void OnUpdatePodcasts( wxCommandEvent &event );
void OnUpdateTrack( wxCommandEvent &event );
void OnPlayerStatusChanged( wxCommandEvent &event );
void OnPlayerTrackListChanged( wxCommandEvent &event );
void OnPlayerCapsChanged( wxCommandEvent &event );
void OnPlayerVolumeChanged( wxCommandEvent &event );
void OnAudioScrobbleUpdate( wxCommandEvent &event );
void OnPlayerSeeked( wxCommandEvent &event );
guMediaViewer * FindCollectionMediaViewer( void * windowptr );
void CreateCollectionsMenu( wxMenu * menu );
void CreateCollectionMenu( wxMenu * menu, const guMediaCollection &collection,
const int basecommand, const int collectiontype = guMEDIA_COLLECTION_TYPE_NORMAL );
void CollectionsUpdated( void );
void CreateViewMenu( wxMenu * menu );
void CreateLayoutMenus( wxMenu * menu );
void CreateControlsMenu( wxMenu * menu );
void CreateHelpMenu( wxMenu * menu );
void CreateMenu();
void DoCreateStatusBar( int kind );
void OnCloseWindow( wxCloseEvent &event );
//void OnIconizeWindow( wxIconizeEvent &event );
void OnPreferences( wxCommandEvent &event );
void OnPlay( wxCommandEvent &event );
void OnStop( wxCommandEvent &event );
void OnStopAtEnd( wxCommandEvent &event );
void OnClearPlaylist( wxCommandEvent &event );
void OnNextTrack( wxCommandEvent &event );
void OnPrevTrack( wxCommandEvent &event );
void OnNextAlbum( wxCommandEvent &event );
void OnPrevAlbum( wxCommandEvent &event );
void OnRandomize( wxCommandEvent &event );
void OnAbout( wxCommandEvent &event );
void OnHelp( wxCommandEvent &event );
void OnCommunity( wxCommandEvent &event );
void OnPlayMode( wxCommandEvent &event );
void OnCopyTracksTo( wxCommandEvent &event );
void OnCopyTracksToDevice( wxCommandEvent &event );
void OnCopyPlayListToDevice( wxCommandEvent &event );
void OnPlayerPlayListUpdateTitle( wxCommandEvent &event );
void CheckShowNotebook( void );
void CheckHideNotebook( void );
void OnGaugeCreate( wxCommandEvent &event );
void OnSetSelection( wxCommandEvent &event );
void OnSelectLocation( wxCommandEvent &event );
void OnPlayListUpdated( wxCommandEvent &event );
void CreateTaskBarIcon( void );
void OnPodcastItemUpdated( wxCommandEvent &event );
void OnRemovePodcastThread( wxCommandEvent &event );
void OnIdle( wxIdleEvent &event );
void OnSize( wxSizeEvent &event );
void OnIconize( wxIconizeEvent &event );
void OnPageChanged( wxAuiNotebookEvent& event );
void OnPageClosed( wxAuiNotebookEvent& event );
void DoPageClose( wxPanel * panel );
void OnUpdateSelInfo( wxCommandEvent &event );
void OnRequestCurrentTrack( wxCommandEvent &event );
void OnUpdateRadio( wxCommandEvent &event ) { if( m_RadioPanel ) wxPostEvent( m_RadioPanel, event ); }
//void OnSysColorChanged( wxSysColourChangedEvent &event );
void OnCreateNewLayout( wxCommandEvent &event );
void OnLoadLayout( wxCommandEvent &event );
void OnDeleteLayout( wxCommandEvent &event );
bool SaveCurrentLayout( const wxString &layoutname );
void LoadLayoutNames( void );
void ReloadLayoutMenus( void );
void OnPlayerShowPanel( wxCommandEvent &event );
void ShowMainPanel( const int panelid, const bool enable );
void OnCollectionCommand( wxCommandEvent &event );
void OnViewRadio( wxCommandEvent &event );
void OnRadioShowPanel( wxCommandEvent &event );
void OnRadioProperties( wxCommandEvent &event );
void OnViewLastFM( wxCommandEvent &event );
void OnViewLyrics( wxCommandEvent &event );
void OnViewPlayLists( wxCommandEvent &event );
void OnPlayListShowPanel( wxCommandEvent &event );
void OnViewPodcasts( wxCommandEvent &event );
void OnPodcastsShowPanel( wxCommandEvent &event );
void OnPodcastsProperties( wxCommandEvent &event );
void OnViewAudioCD( wxCommandEvent &event );
void OnViewFileBrowser( wxCommandEvent &event );
void OnViewPortableDevice( wxCommandEvent &event );
void OnMainPaneClose( wxAuiManagerEvent &event );
void LoadPerspective( const wxString &layout );
void LoadTabsPerspective( const wxString &layout );
void OnPlayStream( wxCommandEvent &event );
void OnViewFullScreen( wxCommandEvent &event );
void OnViewStatusBar( wxCommandEvent &event );
// There is a bug that dont removes correctly the last window from the AuiNotebook
// When a new one is inserted if it was already in the Notebook then
// Its shown the last removed tab instead of the new we created.
// As a workaround we control if we are going to remove the last window and if so
// Instead of remove it we hide the Notebook
// When inserting we need to control if it was hiden and if so add the new one and remove the first
// We create two functions RemoveTabPanel and InsertTabPanel that controls this
void RemoveTabPanel( wxPanel * panel );
void InsertTabPanel( wxPanel * panel, const int index, const wxString &label, const wxString &panelid );
void OnLibraryCoverChanged( wxCommandEvent &event );
void OnPlayerPanelCoverChanged( wxCommandEvent &event );
void OnMountMonitorUpdated( wxCommandEvent &event );
void OnAudioCdVolumeUpdated( wxCommandEvent &event );
void OnSetAudioScrobble( wxCommandEvent &event );
void OnLyricFound( wxCommandEvent &event );
void OnLyricSearchFirst( wxCommandEvent &event );
void OnLyricSearchNext( wxCommandEvent &event );
void OnLyricSaveChanges( wxCommandEvent &event );
void OnLyricExecCommand( wxCommandEvent &event );
void OnConfigUpdated( wxCommandEvent &event );
void OnChangeVolume( wxCommandEvent &event );
void OnSongSetRating( wxCommandEvent &event );
void OnSetAllowDenyFilter( wxCommandEvent &event );
void OnRaiseWindow( wxCommandEvent &event );
void OnLoadPlayList( wxCommandEvent &event );
void OnMediaViewerClosed( wxCommandEvent &event ) { MediaViewerClosed( ( guMediaViewer * ) event.GetClientData() ); }
public:
guMainFrame( wxWindow * parent, guDbCache * dbcache );
~guMainFrame();
void OnSetForceGapless( wxCommandEvent &event );
static guMainFrame * GetMainFrame( void ) { return m_MainFrame; }
void SetMainFrame( void ) { m_MainFrame = this; }
guRadioPanel * GetRadioPanel( void ) { return m_RadioPanel; }
guPodcastPanel * GetPodcastsPanel( void ) { return m_PodcastsPanel; }
guMediaViewer * GetDefaultMediaViewer( void );
const guMediaCollectionArray & GetMediaCollections( void ) { wxMutexLocker Locker( m_CollectionsMutex ); return m_Collections; }
bool IsCollectionActive( const wxString &uniqueid );
bool IsCollectionPresent( const wxString &uniqueid );
wxString GetCollectionIconString( const wxString &uniqueid );
void OnQuit( wxCommandEvent &event );
void OnCloseTab( wxCommandEvent &event );
void DoShowCaptions( const bool visible );
void OnShowCaptions( wxCommandEvent &event );
void UpdatePodcasts( void );
void RemovePodcastsDownloadThread( void );
void AddPodcastsDownloadItems( guPodcastItemArray * items );
void RemovePodcastDownloadItems( guPodcastItemArray * items );
void UpdatedTracks( int updatedby, const guTrackArray * tracks );
void UpdatedTrack( int updatedby, const guTrack * track );
guDBusNotify * GetNotifyObject( void ) { return m_NotifySrv; }
guDbPodcasts * GetPodcastsDb( void )
{
if( !m_DbPodcasts )
m_DbPodcasts = new guDbPodcasts( guPATH_PODCASTS_DBNAME );
return m_DbPodcasts;
}
void CreateCopyToMenu( wxMenu * menu );
void CopyToThreadFinished( void );
int VisiblePanels( void ) { return m_VisiblePanels; }
wxArrayString PortableDeviceVolumeNames( void ) { return m_VolumeMonitor->GetMountNames(); }
guLyricSearchEngine * LyricSearchEngine( void ) { return m_LyricSearchEngine; }
int AddGauge( const wxString &label, const bool showpercent = true );
void RemoveGauge( const int gaugeid );
void OnGaugePulse( wxCommandEvent &event ) { m_MainStatusBar->Pulse( event.GetInt() ); }
void OnGaugeSetMax( wxCommandEvent &event ) { m_MainStatusBar->SetTotal( event.GetInt(), event.GetExtraLong() ); }
void OnGaugeUpdate( wxCommandEvent &event ) { m_MainStatusBar->SetValue( event.GetInt(), event.GetExtraLong() ); }
void OnGaugeRemove( wxCommandEvent &event ) { m_MainStatusBar->RemoveGauge( event.GetInt() ); }
void SaveCollections( void );
void GetCollectionsCoverNames( wxArrayString &covernames );
guMediaViewer * FindCollectionMediaViewer( const wxString &uniqueid );
int GetMediaViewerIndex( guMediaViewer * mediaviewer );
guMediaCollection * FindCollection( const wxString &uniqueid );
void MediaViewerCreated( const wxString &uniqueid, guMediaViewer * mediaviewer );
void MediaViewerClosed( guMediaViewer * mediaviewer );
void ImportFiles( guMediaViewer * mediaviewer, guTrackArray * tracks, const wxString ©tooption, const wxString &destdir );
const guCurrentTrack * GetCurrentTrack( void ) const { return m_PlayerPanel->GetCurrentTrack(); }
void AddPendingUpdateTrack( const guTrack &track, const wxImage * image, const wxString &lyric, const int changedflags );
void AddPendingUpdateTrack( const wxString &filename, const wxImage * image, const wxString &lyric, const int changedflags );
void CheckPendingUpdates( const guTrack * track, const bool forcesave = false );
};
// -------------------------------------------------------------------------------- //
class guUpdatePodcastsTimer : public wxTimer
{
protected :
guDbLibrary * m_Db;
guMainFrame * m_MainFrame;
public:
guUpdatePodcastsTimer( guMainFrame * mainframe, guDbLibrary * db );
//Called each time the timer's timeout expires
void Notify();
};
// -------------------------------------------------------------------------------- //
class guUpdatePodcastsThread : public wxThread
{
protected :
int m_GaugeId;
guDbPodcasts * m_Db;
guMainFrame * m_MainFrame;
public :
guUpdatePodcastsThread( guMainFrame * mainframe, int gaugeid );
~guUpdatePodcastsThread();
virtual ExitCode Entry();
};
}
#endif
// -------------------------------------------------------------------------------- //
| 23,153
|
C++
|
.h
| 389
| 54.886889
| 157
| 0.537276
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,714
|
Jamendo.h
|
anonbeat_guayadeque/src/ui/jamendo/Jamendo.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __JAMENDO_H__
#define __JAMENDO_H__
#include "Config.h"
#include "LibPanel.h"
#include "DbLibrary.h"
#include "MediaViewer.h"
#include "Preferences.h"
#include "Settings.h"
#include <wx/string.h>
#include <wx/window.h>
namespace Guayadeque {
#define guJAMENDO_DATABASE_DUMP_URL wxT( "http://img.jamendo.com/data/dbdump_artistalbumtrack.xml.gz" )
#define guJAMENDO_STREAM_FORMAT_MP3 wxT( "mp31" )
#define guJAMENDO_STREAM_FORMAT_OGG wxT( "ogg2" )
#define guJAMENDO_FILE_STREAM_URL wxT( "http://api.jamendo.com/get2/stream/track/redirect/?id=%u&streamencoding=" )
#define guJAMENDO_FILE_STREAM_MP3_URL wxT( "http://api.jamendo.com/get2/stream/track/redirect/?id=%u&streamencoding=mp31" )
#define guJAMENDO_FILE_STREAM_OGG_URL wxT( "http://api.jamendo.com/get2/stream/track/redirect/?id=%u&streamencoding=ogg2" )
#define guJAMENDO_COVER_DOWNLOAD_URL wxT( "http://api.jamendo.com/get2/image/album/redirect/?id=%u&imagesize=%u" )
#define guJAMENDO_TORRENT_DOWNLOAD_URL wxT( "http://api.jamendo.com/get2/bittorrent/file/plain/?album_id=%u&type=archive&class=" )
#define guJAMENDO_DOWNLOAD_FORMAT_MP3 wxT( "mp32" )
#define guJAMENDO_DOWNLOAD_FORMAT_OGG wxT( "ogg3" )
#define guJAMENDO_DOWNLOAD_DIRECT wxT( "http://www.jamendo.com/en/download/album/%u/do" )
#define guJAMENDO_ACTION_UPDATE 0 // Download the database and then upgrade
#define guJAMENDO_ACTION_UPGRADE 1 // Just refresh the tracks not updating the database
// -------------------------------------------------------------------------------- //
class guJamendoLibrary : public guDbLibrary
{
public :
guJamendoLibrary( const wxString &libpath );
~guJamendoLibrary();
virtual void UpdateArtistsLabels( const guArrayListItems &labelsets );
virtual void UpdateAlbumsLabels( const guArrayListItems &labelsets );
virtual void UpdateSongsLabels( const guArrayListItems &labelsets );
void CreateNewSong( guTrack * track );
};
class guMediaViewerJamendo;
// -------------------------------------------------------------------------------- //
class guJamendoUpdateThread : public wxThread
{
private :
guJamendoLibrary * m_Db;
guMediaViewerJamendo * m_MediaViewer;
guMainFrame * m_MainFrame;
int m_GaugeId;
int m_Action;
wxArrayInt m_AllowedGenres;
guTrack m_CurrentTrack;
bool UpgradeDatabase( void );
protected :
public :
guJamendoUpdateThread( guMediaViewerJamendo * mediaviewer, const int action, int gaugeid );
~guJamendoUpdateThread();
ExitCode Entry();
};
class guJamendoDownloadThread;
// -------------------------------------------------------------------------------- //
class guJamendoPanel : public guLibPanel
{
protected :
void OnDownloadAlbum( wxCommandEvent &event );
void OnDownloadTrackAlbum( wxCommandEvent &event );
public :
guJamendoPanel( wxWindow * parent, guMediaViewer * mediaviewer );
~guJamendoPanel();
guJamendoLibrary * GetJamendoDb( void ) { return ( guJamendoLibrary * ) m_Db; }
};
// -------------------------------------------------------------------------------- //
class guJamendoAlbumBrowser : public guAlbumBrowser
{
protected :
void OnDownloadAlbum( wxCommandEvent &event );
public :
guJamendoAlbumBrowser( wxWindow * parent, guMediaViewer * mediaviewer );
~guJamendoAlbumBrowser();
};
// -------------------------------------------------------------------------------- //
class guJamendoTreePanel : public guTreeViewPanel
{
protected :
void OnDownloadAlbum( wxCommandEvent &event );
void OnDownloadTrackAlbum( wxCommandEvent &event );
public :
guJamendoTreePanel( wxWindow * parent, guMediaViewer * mediaviewer );
~guJamendoTreePanel();
};
// -------------------------------------------------------------------------------- //
class guJamendoPlayListPanel : public guPlayListPanel
{
protected :
void OnDownloadTrackAlbum( wxCommandEvent &event );
public :
guJamendoPlayListPanel( wxWindow * parent, guMediaViewer * mediaviewer );
~guJamendoPlayListPanel();
};
// -------------------------------------------------------------------------------- //
class guJamendoDownloadThread : public wxThread
{
private :
guJamendoLibrary * m_Db;
guMediaViewerJamendo * m_MediaViewer;
wxArrayInt m_Covers;
wxMutex m_CoversMutex;
wxArrayInt m_Albums;
wxMutex m_AlbumsMutex;
protected :
public :
guJamendoDownloadThread( guMediaViewerJamendo * jamendopanel );
~guJamendoDownloadThread();
void AddAlbum( const int albumid, const bool iscover = true );
void AddAlbums( const wxArrayInt &albums, const bool iscover = true );
ExitCode Entry();
};
// -------------------------------------------------------------------------------- //
class guMediaViewerJamendo : public guMediaViewer
{
protected :
guJamendoDownloadThread * m_DownloadThread;
wxMutex m_DownloadThreadMutex;
virtual void LoadMediaDb( void );
virtual void OnConfigUpdated( wxCommandEvent &event );
void OnCoverDownloaded( wxCommandEvent &event );
void OnUpdateFinished( wxCommandEvent &event );
void EndUpdateThread( void );
void EndDownloadThread( void );
public :
guMediaViewerJamendo( wxWindow * parent, guMediaCollection &mediacollection,
const int basecmd, guMainFrame * mainframe, const int mode,
guPlayerPanel * playerpanel );
~guMediaViewerJamendo();
virtual wxImage * GetAlbumCover( const int albumid, int &coverid, wxString &coverpath,
const wxString &artistname = wxEmptyString, const wxString &albumname = wxEmptyString );
virtual void UpdateLibrary( void );
virtual void UpgradeLibrary( void );
virtual void NormalizeTracks( guTrackArray * tracks, const bool isdrag = false );
void AddDownload( const int albumid, const bool iscover = true );
void AddDownloads( const wxArrayInt &albumids, const bool iscover = true );
virtual void DownloadAlbumCover( const int albumid );
virtual void DownloadAlbums( const wxArrayInt &albums, const bool istorrent );
virtual void CreateContextMenu( wxMenu * menu, const int windowid = wxNOT_FOUND );
virtual bool CreateLibraryView( void );
virtual bool CreateAlbumBrowserView( void );
virtual bool CreateTreeView( void );
virtual bool CreatePlayListView( void );
virtual wxString GetCoverName( const int albumid );
virtual void SelectAlbumCover( const int albumid );
virtual bool FindMissingCover( const int albumid, const wxString &artistname,
const wxString &albumname, const wxString &albumpath );
virtual void EditProperties( void );
friend class guJamendoDownloadThread;
friend class guJamendoUpdateThread;
};
}
#endif
// -------------------------------------------------------------------------------- //
| 8,767
|
C++
|
.h
| 175
| 46.211429
| 135
| 0.589882
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,715
|
Google.h
|
anonbeat_guayadeque/src/ui/cover/Google.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __GOOGLE_H__
#define __GOOGLE_H__
#include "ArrayStringArray.h"
#include "CoverFetcher.h"
namespace Guayadeque {
class guFetchCoverLinksThread;
// -------------------------------------------------------------------------------- //
class guGoogleCoverFetcher : public guCoverFetcher
{
private :
void ExtractImageInfo( const wxString &content );
int ExtractImagesInfo( wxString &content, int count );
public :
guGoogleCoverFetcher( guFetchCoverLinksThread * mainthread, guArrayStringArray * coverlinks,
const wxChar * artist, const wxChar * album );
virtual int AddCoverLinks( int pagenum );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 1,832
|
C++
|
.h
| 41
| 42.146341
| 96
| 0.574552
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,716
|
Apple.h
|
anonbeat_guayadeque/src/ui/cover/Apple.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __APPLE_H__
#define __APPLE_H__
#include "ArrayStringArray.h"
#include "CoverFetcher.h"
#include <wx/xml/xml.h>
namespace Guayadeque {
class guFetchCoverLinksThread;
// -------------------------------------------------------------------------------- //
class guAppleCoverFetcher : public guCoverFetcher
{
private :
int ExtractImagesInfo( wxString &content );
public :
guAppleCoverFetcher( guFetchCoverLinksThread * mainthread, guArrayStringArray * coverlinks,
const wxChar * artist, const wxChar * album );
virtual int AddCoverLinks( int pagenum );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 1,775
|
C++
|
.h
| 41
| 40.829268
| 95
| 0.573001
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,717
|
CoverFrame.h
|
anonbeat_guayadeque/src/ui/cover/CoverFrame.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __COVERFRAME_H__
#define __COVERFRAME_H__
#include "PlayerPanel.h"
#include <wx/wx.h>
#define guCOVERFRAME_NONE 0
#define guCOVERFRAME_DEFAULT 1
#define guCOVERFRAME_CUSTOM 2
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
class guCoverFrame : public wxFrame
{
protected:
wxStaticBitmap * m_CoverBitmap;
bool m_CapturedMouse;
wxTimer * m_AutoCloseTimer;
void CoverFrameActivate( wxActivateEvent &event );
void OnClick( wxMouseEvent &event );
void OnCaptureLost( wxMouseCaptureLostEvent &event );
void OnMouse( wxMouseEvent &event );
void OnTimer( wxTimerEvent &event );
public:
guCoverFrame( wxWindow * parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 293, 258 ), long style = 0|wxTAB_TRAVERSAL );
~guCoverFrame();
void SetBitmap( const guSongCoverType CoverType, const wxString &CoverPath = wxEmptyString );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 2,208
|
C++
|
.h
| 49
| 42.836735
| 216
| 0.609222
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,718
|
CoverFetcher.h
|
anonbeat_guayadeque/src/ui/cover/CoverFetcher.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __COVERFETCHER_H__
#define __COVERFETCHER_H__
#include "CoverEdit.h"
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
wxString ExtractString( const wxString &source, const wxString &start, const wxString &end );
// -------------------------------------------------------------------------------- //
class guCoverFetcher
{
protected :
guFetchCoverLinksThread * m_MainThread;
guArrayStringArray * m_CoverLinks;
wxString m_Artist;
wxString m_Album;
bool CoverLinkExist( const wxString &coverlink );
public :
guCoverFetcher( guFetchCoverLinksThread * mainthread, guArrayStringArray * coverlinks,
const wxChar * artist, const wxChar * album );
~guCoverFetcher();
virtual int AddCoverLinks( int pagenum ) = 0;
};
}
#endif
| 1,983
|
C++
|
.h
| 44
| 42.227273
| 93
| 0.564767
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,719
|
LastFMCovers.h
|
anonbeat_guayadeque/src/ui/cover/LastFMCovers.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __LASTFMCOVERS_H__
#define __LASTFMCOVERS_H__
#include "ArrayStringArray.h"
#include "CoverFetcher.h"
namespace Guayadeque {
class guFetchCoverLinksThread;
// -------------------------------------------------------------------------------- //
class guLastFMCoverFetcher : public guCoverFetcher
{
private :
public :
guLastFMCoverFetcher( guFetchCoverLinksThread * mainthread, guArrayStringArray * coverlinks,
const wxChar * artist, const wxChar * album );
virtual int AddCoverLinks( int pagenum );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 1,707
|
C++
|
.h
| 39
| 41.333333
| 96
| 0.574699
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,720
|
SelCoverFile.h
|
anonbeat_guayadeque/src/ui/cover/SelCoverFile.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __SELCOVERFILE_H__
#define __SELCOVERFILE_H__
#include "DbLibrary.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/dialog.h>
namespace Guayadeque {
class guMediaViewer;
// -------------------------------------------------------------------------------- //
// Class guSelCoverFile
// -------------------------------------------------------------------------------- //
class guSelCoverFile : public wxDialog
{
protected:
guDbLibrary * m_Db;
wxString m_AlbumPath;
guMediaViewer * m_MediaViewer;
// GUI
wxTextCtrl * m_FileLink;
wxButton * m_SelFileBtn;
wxCheckBox * m_EmbedToFilesChkBox;
wxButton * m_StdBtnOk;
void OnSelFileClicked( wxCommandEvent& event );
void OnPathChanged( wxCommandEvent &event );
void OnCoverFinish( wxCommandEvent &event );
public:
guSelCoverFile( wxWindow * parent, guMediaViewer * mediaviewer, const int albumid = wxNOT_FOUND ); //, wxWindowID id = wxID_ANY, const wxString& title = wxT("Select Cover File"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 400,125 ), long style = wxDEFAULT_DIALOG_STYLE );
~guSelCoverFile();
wxString GetSelFile( void );
wxString GetAlbumPath( void ) { return m_AlbumPath; }
bool EmbedToFiles( void ) { return m_EmbedToFilesChkBox->IsChecked(); }
};
}
#endif
// -------------------------------------------------------------------------------- //
| 2,695
|
C++
|
.h
| 63
| 40.52381
| 301
| 0.590909
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,721
|
Discogs.h
|
anonbeat_guayadeque/src/ui/cover/Discogs.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __DISCOGS_H__
#define __DISCOGS_H__
#include "CoverFetcher.h"
#include <wx/dynarray.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
class guDiscogsImage
{
public :
wxString m_Url;
int m_Width;
int m_Height;
guDiscogsImage() {}
~guDiscogsImage() {}
guDiscogsImage( const wxString &url, int width = -1, int height = -1 )
{
m_Url = url;
m_Width = width;
m_Height = height;
}
};
WX_DECLARE_OBJARRAY( guDiscogsImage, guDiscogsImageArray );
// -------------------------------------------------------------------------------- //
class guDiscogsTrack
{
public :
wxString m_Title;
int m_Length;
int m_Position;
guDiscogsTrack() {}
~guDiscogsTrack() {}
};
WX_DECLARE_OBJARRAY( guDiscogsTrack, guDiscogsTrackArray );
// -------------------------------------------------------------------------------- //
class guDiscogsRelease
{
public:
int m_Id;
wxString m_Type;
wxString m_Format;
wxString m_Title;
//wxString m_Label;
int m_Year;
guDiscogsImageArray m_Images;
guDiscogsTrackArray m_Tracks;
guDiscogsRelease() {}
~guDiscogsRelease() {}
};
WX_DECLARE_OBJARRAY( guDiscogsRelease, guDiscogsReleaseArray );
// -------------------------------------------------------------------------------- //
class guDiscogsArtist
{
public :
wxString m_Name;
wxString m_RealName;
guDiscogsImageArray m_Images;
wxArrayString m_Urls;
//wxArrayString m_Aliases;
guDiscogsReleaseArray m_Releases;
guDiscogsArtist() {}
~guDiscogsArtist() {}
};
// -------------------------------------------------------------------------------- //
class guDiscogs
{
protected :
public :
guDiscogs();
~guDiscogs();
bool GetArtist( const wxString &name, guDiscogsArtist * artist );
bool GetReleaseImages( const int id, guDiscogsRelease * release );
bool GetRelease( const int id, guDiscogsRelease * release );
guDiscogsReleaseArray GetArtistReleases( const wxString &artist, const wxString &type = wxEmptyString, const wxString &format = wxEmptyString );
//Search( const wxString &query, const int pagenum = 1 );
};
// -------------------------------------------------------------------------------- //
class guDiscogsCoverFetcher : public guCoverFetcher
{
public :
guDiscogsCoverFetcher( guFetchCoverLinksThread * mainthread, guArrayStringArray * coverlinks,
const wxChar * artist, const wxChar * album );
~guDiscogsCoverFetcher();
virtual int AddCoverLinks( int pagenum );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 3,995
|
C++
|
.h
| 108
| 33.601852
| 150
| 0.530644
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,722
|
Yahoo.h
|
anonbeat_guayadeque/src/ui/cover/Yahoo.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __YAHOO_H__
#define __YAHOO_H__
#include "ArrayStringArray.h"
#include "CoverFetcher.h"
namespace Guayadeque {
class guFetchCoverLinksThread;
// -------------------------------------------------------------------------------- //
class guYahooCoverFetcher : public guCoverFetcher
{
private :
void ExtractImageInfo( const wxString &content );
int ExtractImagesInfo( wxString &content, int count );
public :
guYahooCoverFetcher( guFetchCoverLinksThread * mainthread, guArrayStringArray * coverlinks,
const wxChar * artist, const wxChar * album );
virtual int AddCoverLinks( int pagenum );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 1,828
|
C++
|
.h
| 41
| 42.04878
| 95
| 0.573596
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,723
|
CoverPanel.h
|
anonbeat_guayadeque/src/ui/cover/CoverPanel.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __COVERPANEL_H__
#define __COVERPANEL_H__
#include "PlayerPanel.h"
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/statbmp.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/sizer.h>
#include <wx/panel.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
class guCoverPanel : public wxPanel
{
protected :
guPlayerPanel * m_PlayerPanel;
int m_LastSize;
wxBitmap m_CoverImage;
int m_CoverType;
wxString m_CoverPath;
wxMutex m_CoverImageMutex;
wxTimer m_ResizeTimer;
virtual void OnSize( wxSizeEvent &event );
virtual void OnPaint( wxPaintEvent &event );
virtual void OnResizeTimer( wxTimerEvent &event );
void UpdateImage( void );
public :
guCoverPanel( wxWindow * parent, guPlayerPanel * playerpanel );
~guCoverPanel();
void OnUpdatedTrack( wxCommandEvent &event );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 2,292
|
C++
|
.h
| 59
| 36.644068
| 86
| 0.569307
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,724
|
Amazon.h
|
anonbeat_guayadeque/src/ui/cover/Amazon.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __AMAZON_H__
#define __AMAZON_H__
#include "ArrayStringArray.h"
#include "CoverFetcher.h"
#include <wx/xml/xml.h>
namespace Guayadeque {
class guFetchCoverLinksThread;
// -------------------------------------------------------------------------------- //
class guAmazonCoverFetcher : public guCoverFetcher
{
private :
wxArrayString GetImageInfo( wxXmlNode * XmlNode );
int ExtractImagesInfo( wxString &content );
public :
guAmazonCoverFetcher( guFetchCoverLinksThread * mainthread, guArrayStringArray * coverlinks,
const wxChar * artist, const wxChar * album );
virtual int AddCoverLinks( int pagenum );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 1,836
|
C++
|
.h
| 42
| 41.190476
| 96
| 0.578947
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,725
|
CoverEdit.h
|
anonbeat_guayadeque/src/ui/cover/CoverEdit.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __COVEREDIT_H__
#define __COVEREDIT_H__
#include "ArrayStringArray.h"
#include "AutoPulseGauge.h"
#include "ThreadArray.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/image.h>
#include <wx/statbmp.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/bmpbuttn.h>
#include <wx/dialog.h>
#include <wx/gauge.h>
#include <wx/choice.h>
#include <wx/checkbox.h>
#define GUCOVERINFO_LINK 0
#define GUCOVERINFO_SIZE 1
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
class guCoverImage
{
public:
wxString m_Link;
wxString m_SizeStr;
wxImage * m_Image;
guCoverImage()
{
m_Link = wxEmptyString;
m_Image = NULL;
};
guCoverImage( const wxString &link, const wxString size, wxImage * image )
{
m_Link = link;
m_SizeStr = size;
m_Image = image;
};
~guCoverImage()
{
if( m_Image )
delete m_Image;
};
};
WX_DECLARE_OBJARRAY(guCoverImage, guCoverImageArray);
class guCoverEditor;
class guCoverFetcher;
// -------------------------------------------------------------------------------- //
class guFetchCoverLinksThread : public wxThread
{
private:
guCoverEditor * m_CoverEditor;
guCoverFetcher * m_CoverFetcher;
guArrayStringArray m_CoverLinks;
int m_CurrentPage;
int m_LastDownload;
wxString m_Artist;
wxString m_Album;
int m_EngineIndex;
public:
guFetchCoverLinksThread( guCoverEditor * owner, const wxChar * artist, const wxChar * album, int engineindex );
~guFetchCoverLinksThread();
virtual ExitCode Entry();
};
// -------------------------------------------------------------------------------- //
class guDownloadCoverThread : public wxThread
{
private:
guCoverEditor * m_CoverEditor;
wxString m_UrlStr;
wxString m_SizeStr;
public:
guDownloadCoverThread( guCoverEditor * Owner, const wxArrayString * CoverInfo );
~guDownloadCoverThread();
virtual ExitCode Entry();
};
class guCoverFetcher;
// -------------------------------------------------------------------------------- //
// Class guCoverEditor
// -------------------------------------------------------------------------------- //
class guCoverEditor : public wxDialog
{
private:
wxString m_AlbumPath;
wxTextCtrl * m_ArtistTextCtrl;
wxTextCtrl * m_AlbumTextCtrl;
wxChoice * m_EngineChoice;
wxCheckBox * m_EmbedToFilesChkBox;
wxBitmapButton * m_CoverSelectButton;
wxBitmapButton * m_CoverDownloadButton;
wxStaticBitmap * m_CoverBitmap;
wxBitmapButton * m_PrevButton;
wxBitmapButton * m_NextButton;
wxButton * m_ButtonsSizerOK;
wxButton * m_ButtonsSizerCancel;
wxBoxSizer * m_SizeSizer;
wxStaticText * m_SizeStaticText;
wxMutex m_DownloadThreadMutex;
wxMutex m_DownloadEventsMutex;
guAutoPulseGauge * m_Gauge;
wxStaticText * m_InfoTextCtrl;
guCoverImageArray m_AlbumCovers;
guFetchCoverLinksThread * m_DownloadCoversThread;
guThreadArray m_DownloadThreads;
int m_CurrentImage;
int m_EngineIndex;
void OnInitDialog( wxInitDialogEvent& event );
void OnTextCtrlEnter( wxCommandEvent& event );
void OnEngineChanged( wxCommandEvent& event );
void OnCoverLeftDClick( wxMouseEvent& event );
void OnCoverLeftClick( wxMouseEvent& event );
void OnPrevButtonClick( wxCommandEvent& event );
void OnNextButtonClick( wxCommandEvent& event );
void OnAddCoverImage( wxCommandEvent &event );
void UpdateCoverBitmap();
void EndDownloadLinksThread();
void EndDownloadCoverThread( guDownloadCoverThread * DownloadCoverThread );
void OnDownloadedLinks( wxCommandEvent &event );
void OnCoverSelectClick( wxCommandEvent &event );
void OnCoverDownloadClick( wxCommandEvent &event );
void OnMouseWheel( wxMouseEvent &event );
public:
guCoverEditor( wxWindow * parent, const wxString &Artist, const wxString &Album, const wxString &albumpath = wxEmptyString );// wxWindowID id = wxID_ANY, const wxString& title = wxT("Cover Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE );
~guCoverEditor();
wxString GetSelectedCoverUrl( void );
wxImage * GetSelectedCoverImage( void );
bool EmbedToFiles( void ) { return m_EmbedToFilesChkBox->IsChecked(); }
friend class guFetchCoverLinksThread;
friend class guDownloadCoverThread;
};
}
#endif
// -------------------------------------------------------------------------------- //
| 6,100
|
C++
|
.h
| 153
| 36.27451
| 319
| 0.593137
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,726
|
TrackChangeInfo.h
|
anonbeat_guayadeque/src/ui/player/TrackChangeInfo.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __TRACKCHANGEINFO_H__
#define __TRACKCHANGEINFO_H__
#include <wx/dynarray.h>
#include <wx/string.h>
namespace Guayadeque {
#define guTRACKCHANGEINFO_MAXCOUNT 15
class guMediaViewer;
// -------------------------------------------------------------------------------- //
class guTrackChangeInfo
{
public :
wxString m_ArtistName;
wxString m_TrackName;
guMediaViewer * m_MediaViewer;
guTrackChangeInfo() {}
guTrackChangeInfo( const wxString &artist, const wxString &track, guMediaViewer * mediaviewer )
{
m_ArtistName = artist;
m_TrackName = track;
m_MediaViewer = mediaviewer;
};
~guTrackChangeInfo() {}
};
WX_DECLARE_OBJARRAY(guTrackChangeInfo, guTrackChangeInfoArray);
}
#endif
// -------------------------------------------------------------------------------- //
| 1,912
|
C++
|
.h
| 48
| 37.416667
| 99
| 0.583064
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,727
|
PlayList.h
|
anonbeat_guayadeque/src/ui/player/PlayList.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __PLAYLIST_H__
#define __PLAYLIST_H__
#include "AuiManagedPanel.h"
#include "DbLibrary.h"
#include "ListView.h"
#include <wx/wx.h>
#include <wx/vlbox.h>
#include <wx/dnd.h>
#include <wx/dir.h>
#include <wx/arrimpl.cpp>
#include <wx/thread.h>
#include <wx/timer.h>
#include <wx/string.h>
namespace Guayadeque {
class guPlayerPanel;
class guPlayList;
class guMainFrame;
// -------------------------------------------------------------------------------- //
class guPlayList : public guListView
{
private :
guDbLibrary * m_Db;
guMainFrame * m_MainFrame;
guPlayerPanel * m_PlayerPanel;
guTrackArray m_Items;
wxMutex m_ItemsMutex;
bool m_StartPlaying;
long m_CurItem;
unsigned int m_TotalLen;
long m_MaxPlayedTracks;
int m_MinPlayListTracks;
bool m_DelTracksPLayed;
int m_ItemHeight;
wxString m_LastSearch;
wxBitmap * m_PlayBitmap;
wxBitmap * m_StopBitmap;
wxBitmap * m_NormalStar;
wxBitmap * m_SelectStar;
wxCoord m_SecondLineOffset;
wxTimer * m_SavePlaylistTimer;
wxArrayString m_PendingLoadIds;
int m_SysFontPointSize;
virtual wxCoord OnMeasureItem( size_t row ) const;
virtual int GetSelectedSongs( guTrackArray * Songs, const bool isdrag = false ) const;
virtual void OnDropFile( const wxString &filename );
virtual void OnDropTracks( const guTrackArray * tracks );
virtual void OnDropBegin( void );
virtual void OnDropEnd( void );
virtual wxString GetItemSearchText( const int row );
void RemoveSelected();
virtual void MoveSelection( void );
void OnClearClicked( wxCommandEvent &event );
void OnRemoveClicked( wxCommandEvent &event );
void OnSaveClicked( wxCommandEvent &event );
void OnCreateBestOfClicked( wxCommandEvent &event );
void OnCopyToClicked( wxCommandEvent &event );
void OnEditLabelsClicked( wxCommandEvent &event );
void OnEditTracksClicked( wxCommandEvent &event );
void OnSearchClicked( wxCommandEvent &event );
void OnStopAtEnd( wxCommandEvent &event ) { StopAtEnd(); }
void SetNextTracks( wxCommandEvent &event );
void OnSearchLinkClicked( wxCommandEvent &event );
void OnCommandClicked( wxCommandEvent &event );
wxString GetSearchText( int item ) const;
void OnSelectTrack( wxCommandEvent &event );
void OnSelectArtist( wxCommandEvent &event );
void OnSelectAlbum( wxCommandEvent &event );
void OnSelectAlbumArtist( wxCommandEvent &event );
void OnSelectComposer( wxCommandEvent &event );
void OnSelectYear( wxCommandEvent &event );
void OnSelectGenre( wxCommandEvent &event );
void CreateAcceleratorTable( void );
void SavePlaylistTracks( void );
void LoadPlaylistTracks( void );
protected:
virtual void OnKeyDown( wxKeyEvent &event );
virtual void DrawItem( wxDC &dc, const wxRect &rect, const int row, const int col ) const;
virtual void DrawBackground( wxDC &dc, const wxRect &rect, const int row, const int col ) const;
virtual void CreateContextMenu( wxMenu * Menu ) const;
virtual wxString OnGetItemText( const int row, const int column ) const;
virtual void GetItemsList( void );
virtual void OnMouse( wxMouseEvent &event );
void OnConfigUpdated( wxCommandEvent &event );
void OnDeleteFromLibrary( wxCommandEvent &event );
void OnDeleteFromDrive( wxCommandEvent &event );
void OnSetRating( wxCommandEvent &event );
void SetTrackRating( const guTrack &track, const int rating );
void SetTracksRating( const guTrackArray &tracks, const int rating );
void CheckPendingLoadItems( const wxString &uniqueid, guMediaViewer * mediaviewer );
void OnCreateSmartPlaylist( wxCommandEvent &event );
void StartSavePlaylistTimer( wxCommandEvent &event );
void OnSavePlaylistTimer( wxTimerEvent & );
public :
guPlayList( wxWindow * parent, guDbLibrary * db, guPlayerPanel * playerpanel = NULL, guMainFrame * mainframe = NULL );
~guPlayList();
void SetPlayerPanel( guPlayerPanel * playerpanel ) { m_PlayerPanel = playerpanel; }
void AddItem( const guTrack &NewItem, const int pos = wxNOT_FOUND );
//void AddItem( const guTrack * NewItem );
void AddPlayListItem( const wxString &FileName, const int aftercurrent, const int pos );
virtual void ReloadItems( bool reset = true );
virtual wxString GetItemName( const int row ) const { return m_Items[ row ].m_SongName; }
virtual int GetItemId( const int row ) const { return row; }
guTrack * GetItem( size_t item );
long GetCount() { return m_Items.GetCount(); }
guTrack * GetCurrent();
int GetCurItem();
void SetCurrent( int curitem, bool delold = false );
guTrack * GetNext( const int playloop, const bool forceskip = false );
guTrack * GetPrev( const int playloop, const bool forceskip = false );
guTrack * GetNextAlbum( const int playloop, const bool forceskip = false );
guTrack * GetPrevAlbum( const int playloop, const bool forceskip = false );
void ClearItems();
long GetLength( void ) const;
wxString GetLengthStr( void ) const;
void AddToPlayList( const guTrackArray &newitems, const bool deleteold = false, const int aftercurrent = 0 ); //guINSERT_AFTER_CURRENT_NONE
void SetPlayList( const guTrackArray &NewItems );
wxString FindCoverFile( const wxString &DirName );
void Randomize( const bool isplaying );
int GetCaps();
void RemoveItem( int itemnum );
void UpdatedTracks( const guTrackArray * tracks );
void UpdatedTrack( const guTrack * track );
bool StartPlaying( void ) { return m_StartPlaying; }
void StopAtEnd( void );
void ClearStopAtEnd( void );
void MediaViewerCreated( const wxString &uniqueid, guMediaViewer * mediaviewer );
void MediaViewerClosed( guMediaViewer * mediaviewer );
friend class guAddDropFilesThread;
friend class guPlayListDropTarget;
friend class guPlayerPlayList;
};
// -------------------------------------------------------------------------------- //
class guPlayerPlayList : public guAuiManagedPanel
{
protected :
guPlayList * m_PlayListCtrl;
public :
guPlayerPlayList( wxWindow * parent, guDbLibrary * db, wxAuiManager * manager );
~guPlayerPlayList() {}
guPlayList * GetPlayListCtrl( void ) { return m_PlayListCtrl; }
void SetPlayerPanel( guPlayerPanel * player );
void inline UpdatedTracks( const guTrackArray * tracks ) { m_PlayListCtrl->UpdatedTracks( tracks ); }
void inline UpdatedTrack( const guTrack * track ) { m_PlayListCtrl->UpdatedTrack( track ); }
void inline MediaViewerCreated( const wxString &uniqueid, guMediaViewer * mediaviewer ) { m_PlayListCtrl->MediaViewerCreated( uniqueid, mediaviewer ); }
void inline MediaViewerClosed( guMediaViewer * mediaviewer ) { m_PlayListCtrl->MediaViewerClosed( mediaviewer ); }
void LoadPlaylistTracks( void ) { m_PlayListCtrl->LoadPlaylistTracks(); }
};
}
#endif
// -------------------------------------------------------------------------------- //
| 9,925
|
C++
|
.h
| 171
| 54.011696
| 166
| 0.56438
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,728
|
PlayerPanel.h
|
anonbeat_guayadeque/src/ui/player/PlayerPanel.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __PLAYERPANEL_H__
#define __PLAYERPANEL_H__
#include "AudioScrobble.h"
#include "AutoScrollText.h"
#include "dbus/notify.h"
#include "LastFM.h"
#include "MediaCtrl.h"
#include "MediaEvent.h"
#include "MediaRecordCtrl.h"
#include "PlayerFilters.h"
#include "PlayList.h"
#include "RatingCtrl.h"
#include "RoundButton.h"
#include "SmartMode.h"
#include "StaticBitmap.h"
#include "ToggleRoundButton.h"
#include "Vumeters.h"
#include <wx/aui/aui.h>
#include <wx/wx.h>
#include <wx/dnd.h>
//#include <wx/mediactrl.h>
#include <wx/tglbtn.h>
namespace Guayadeque {
#define guTEMPORARY_COVER_FILENAME wxT( "guayadeque-tmp-cover" )
enum guInsertAfterCurrent {
guINSERT_AFTER_CURRENT_NONE = 0,
guINSERT_AFTER_CURRENT_TRACK,
guINSERT_AFTER_CURRENT_ALBUM,
guINSERT_AFTER_CURRENT_ARTIST,
};
// -------------------------------------------------------------------------------- //
enum guSongCoverType {
GU_SONGCOVER_NONE = 0,
GU_SONGCOVER_FILE,
GU_SONGCOVER_ID3TAG,
GU_SONGCOVER_RADIO,
GU_SONGCOVER_PODCAST
};
// -------------------------------------------------------------------------------- //
enum guPlayMode {
guPLAYER_PLAYMODE_NONE = 0,
guPLAYER_PLAYMODE_SMART,
guPLAYER_PLAYMODE_REPEAT_PLAYLIST,
guPLAYER_PLAYMODE_REPEAT_TRACK
};
// -------------------------------------------------------------------------------- //
class guCurrentTrack : public guTrack
{
public:
// Only for the Current Played song
bool m_Loaded;
unsigned int m_PlayTime; // how many secs the song have been played
guSongCoverType m_CoverType;
wxString m_CoverPath;
wxImage * m_CoverImage;
int m_ASRating;
guCurrentTrack()
{
m_Loaded = false;
m_CoverImage = NULL;
m_ASRating = guAS_RATING_NONE;
m_Number = 0;
m_Rating = 0;
m_Year = 0;
m_Offset = 0;
}
guCurrentTrack& operator=(const guTrack &Src)
{
m_Loaded = true;
m_Type = Src.m_Type;
m_SongId = Src.m_SongId;
m_SongName = Src.m_SongName;
m_AlbumId = Src.m_AlbumId;
m_AlbumName = Src.m_AlbumName;
m_ArtistId = Src.m_ArtistId;
m_ArtistName = Src.m_ArtistName;
m_AlbumArtistId = Src.m_AlbumArtistId;
m_AlbumArtist = Src.m_AlbumArtist;
m_GenreId = Src.m_GenreId;
m_GenreName = Src.m_GenreName;
m_PathId = Src.m_PathId;
m_FileName = Src.m_FileName;
m_Number = Src.m_Number;
m_Year = Src.m_Year;
m_Offset = Src.m_Offset;
m_Length = Src.m_Length;
m_Format = Src.m_Format;
m_Bitrate = Src.m_Bitrate;
m_PlayCount = Src.m_PlayCount;
m_Rating = Src.m_Rating;
m_LastPlay = Src.m_LastPlay;
m_AddedTime = Src.m_AddedTime;
m_CoverId = Src.m_CoverId;
m_Disk = Src.m_Disk;
m_Comments = Src.m_Comments;
m_ComposerId = Src.m_ComposerId;
m_Composer = Src.m_Composer;
m_PlayTime = 0;
m_ASRating = guAS_RATING_NONE;
m_MediaViewer = Src.m_MediaViewer;
guLogMessage( wxT( "Track starts at %i with length %i" ), m_Offset, m_Length );
//CoverType = GU_SONGCOVER_NONE;
if( m_Type == guTRACK_TYPE_RADIOSTATION )
{
m_CoverType = GU_SONGCOVER_RADIO;
}
else if( m_Type == guTRACK_TYPE_PODCAST )
{
m_CoverType = GU_SONGCOVER_PODCAST;
}
else if( m_CoverId )
{
m_CoverType = GU_SONGCOVER_FILE;
}
else
{
m_CoverType = GU_SONGCOVER_NONE;
}
m_CoverPath = wxEmptyString;
if( m_CoverImage )
delete m_CoverImage;
m_CoverImage = NULL;
return *this;
}
~guCurrentTrack()
{
if( m_CoverImage )
{
delete m_CoverImage;
}
}
void Update( const guTrack &track )
{
m_Loaded = true;
m_Type = track.m_Type;
m_SongId = track.m_SongId;
m_SongName = track.m_SongName;
m_AlbumId = track.m_AlbumId;
m_AlbumName = track.m_AlbumName;
m_ArtistId = track.m_ArtistId;
m_ArtistName = track.m_ArtistName;
m_AlbumArtistId = track.m_AlbumArtistId;
m_AlbumArtist = track.m_AlbumArtist;
m_GenreId = track.m_GenreId;
m_GenreName = track.m_GenreName;
m_PathId = track.m_PathId;
m_FileName = track.m_FileName;
m_Number = track.m_Number;
m_Year = track.m_Year;
m_Offset = track.m_Offset;
m_Length = track.m_Length;
m_Format = track.m_Format;
m_Bitrate = track.m_Bitrate;
m_PlayCount = track.m_PlayCount;
m_Rating = track.m_Rating;
m_LastPlay = track.m_LastPlay;
m_AddedTime = track.m_AddedTime;
m_CoverId = track.m_CoverId;
m_Disk = track.m_Disk;
m_Comments = track.m_Comments;
m_ComposerId = track.m_ComposerId;
m_Composer = track.m_Composer;
m_MediaViewer = track.m_MediaViewer;
if( m_CoverImage )
{
delete m_CoverImage;
m_CoverImage = NULL;
}
}
void SetCoverImage( wxImage * image )
{
if( m_CoverImage )
{
delete m_CoverImage;
}
m_CoverImage = image;
}
};
class guSmartAddTracksThread;
class guUpdatePlayerCoverThread;
// -------------------------------------------------------------------------------- //
class guPlayerPanel : public wxPanel
{
private :
guRoundButton * m_PrevTrackButton;
guRoundButton * m_NextTrackButton;
guRoundButton * m_PlayButton;
guRoundButton * m_StopButton;
guToggleRoundButton * m_RecordButton;
//
guRoundButton * m_ForceGaplessButton;
//guToggleRoundButton * m_SmartPlayButton;
//guToggleRoundButton * m_RepeatPlayButton;
guRoundButton * m_PlayModeButton;
guRoundButton * m_RandomPlayButton;
//
guRoundButton * m_EqualizerButton;
guRoundButton * m_VolumeButton;
wxSlider * m_VolumeBar;
//
wxStaticBitmap * m_PlayerCoverBitmap;
guAutoScrollText * m_TitleLabel;
guAutoScrollText * m_AlbumLabel;
guAutoScrollText * m_ArtistLabel;
wxStaticText * m_YearLabel;
guRating * m_Rating;
guToggleRoundButton * m_LoveBanButton;
wxBoxSizer * m_BitRateSizer;
wxStaticText * m_BitRateLabel;
wxStaticText * m_CodecLabel;
wxBoxSizer * m_PosLabelSizer;
wxStaticText * m_PositionLabel;
wxSlider * m_PlayerPositionSlider;
guDbLibrary * m_Db;
guMainFrame * m_MainFrame;
guPlayList * m_PlayListCtrl;
guDBusNotify * m_NotifySrv;
guPlayerFilters * m_PlayerFilters;
guPlayerVumeters * m_PlayerVumeters;
guMediaCtrl * m_MediaCtrl;
guMediaRecordCtrl * m_MediaRecordCtrl;
guCurrentTrack m_MediaSong;
guTrack m_NextSong;
int m_LastPlayState;
double m_LastVolume;
wxFileOffset m_LastCurPos;
wxFileOffset m_LastLength;
bool m_ShowNotifications;
int m_ShowNotificationsTime;
bool m_EnableEq;
bool m_EnableVolCtls;
double m_CurVolume;
//int m_PlayLoop;
//bool m_PlaySmart;
int m_PlayMode;
bool m_PlayRandom;
int m_PlayRandomMode;
bool m_SliderIsDragged;
long m_LastTotalLen;
bool m_SilenceDetected;
bool m_AboutToEndDetected;
bool m_FadeInStarted;
wxArrayInt m_SmartAddedTracks;
wxArrayString m_SmartAddedArtists;
int m_SmartMaxTracksList;
int m_SmartMaxArtistsList;
bool m_SmartSearchEnabled;
int m_SmartPlayAddTracks;
int m_SmartPlayMinTracksToPlay;
bool m_DelTracksPlayed;
unsigned int m_TrackStartPos;
bool m_SilenceDetector;
int m_SilenceDetectorLevel;
int m_SilenceDetectorTime;
bool m_ForceGapless;
int m_FadeOutTime;
bool m_PendingScrob;
// AudioScrobble
guAudioScrobble * m_AudioScrobble;
bool m_AudioScrobbleEnabled;
//guSmartAddTracksThread * m_SmartAddTracksThread;
guSmartModeThread * m_SmartAddTracksThread;
int m_BufferGaugeId;
long m_NextTrackId;
long m_CurTrackId;
bool m_TrackChanged;
bool m_ShowRevTime;
//bool m_PendingNewRecordName;
bool m_ErrorFound;
int m_SavedPlayedTrack;
wxString m_LastTmpCoverFile;
// guUpdatePlayerCoverThread * m_UpdateCoverThread;
void OnVolumeMouseWheel( wxMouseEvent &event );
void OnVolumeChanged( wxScrollEvent &event );
void OnVolumeClicked( wxCommandEvent &event );
void OnVolumeRightClicked( wxCommandEvent &event );
//void OnPlayerCoverBitmapMouseOver( wxCommandEvent &event );
void OnLeftClickPlayerCoverBitmap( wxMouseEvent &event );
void OnPlayerPositionSliderBeginSeek( wxScrollEvent &event );
void OnPlayerPositionSliderEndSeek( wxScrollEvent &event );
void OnPlayerPositionSliderChanged( wxScrollEvent &event );
void OnPlayerPositionSliderMouseWheel( wxMouseEvent &event );
//
void OnPlayListUpdated( wxCommandEvent &event );
void OnPlayListDClick( wxCommandEvent &event );
void LoadMedia( guFADERPLAYBIN_PLAYTYPE playtype, const bool forceskip = false );
void OnMediaLoaded( guMediaEvent &event );
void OnMediaPlayStarted( void );
void SavePlayedTrack( const bool forcesave = false );
void OnMediaFinished( guMediaEvent &event );
void OnMediaFadeOutFinished( guMediaEvent &event );
void OnMediaFadeInStarted( guMediaEvent &event );
void OnMediaTags( guMediaEvent &event );
void OnMediaBitrate( guMediaEvent &event );
void OnMediaCodec( guMediaEvent &event );
void OnMediaBuffering( guMediaEvent &event );
void OnMediaLevel( guMediaEvent &event );
void OnMediaError( guMediaEvent &event );
void OnMediaState( guMediaEvent &event );
void OnMediaPosition( guMediaEvent &event );
void OnMediaLength( guMediaEvent &event );
void SetNextTrack( const guTrack * Song );
// SmartPlay Events
void SmartAddTracks( const guTrack &CurSong );
void OnSmartEndThread( wxCommandEvent &event );
void OnSmartAddTracks( wxCommandEvent &event );
void OnUpdatedRadioTrack( wxCommandEvent &event );
void OnTitleNameDClicked( wxMouseEvent &event );
void OnAlbumNameDClicked( wxMouseEvent &event );
void OnArtistNameDClicked( wxMouseEvent &event );
void OnYearDClicked( wxMouseEvent &event );
void OnTimeDClicked( wxMouseEvent &event ) { m_ShowRevTime = !m_ShowRevTime;
UpdatePositionLabel( GetPosition() ); }
void OnRatingChanged( guRatingEvent &event );
void CheckFiltersEnable( void );
void OnConfigUpdated( wxCommandEvent &event );
void SendRecordSplitEvent( void );
void OnCoverUpdated( wxCommandEvent &event ); // Once the cover have been found shows it
void OnAddTracks( wxCommandEvent &event );
void OnRemoveTrack( wxCommandEvent &event );
void OnRepeat( wxCommandEvent &event );
void OnLoop( wxCommandEvent &event );
void OnRandom( wxCommandEvent &event );
void OnSetVolume( wxCommandEvent &event );
void PlayModeChanged();
void UpdatePlayModeButton();
public :
guPlayerPanel( wxWindow * parent, guDbLibrary * db,
guPlayList * playlist, guPlayerFilters * filters );
virtual ~guPlayerPanel();
guMainFrame * MainFrame( void ) { return m_MainFrame; }
void SetPlayList( const guTrackArray &SongList );
void AddToPlayList( const guTrackArray &SongList, const bool allowplay = true, const int aftercurrent = guINSERT_AFTER_CURRENT_NONE );
void AddToPlayList( const wxString &FileName, const int aftercurrent = guINSERT_AFTER_CURRENT_NONE );
void AddToPlayList( const wxArrayString &files, const int aftercurrent = guINSERT_AFTER_CURRENT_NONE );
void AddToPlayList( const wxArrayString &files, const bool play, const int aftercurrent );
void ClearPlayList( void ) { m_PlayListCtrl->ClearItems(); }
void SetPlayList( const wxArrayString &files );
guPlayList * PlayListCtrl( void ) { return m_PlayListCtrl; }
double GetVolume() { return m_CurVolume; }
void SetVolume( double volume );
bool SetPosition( int pos );
int GetPosition();
void TrackListChanged( void );
const guCurrentTrack * GetCurrentTrack() { return &m_MediaSong; }
int GetCurrentItem();
int GetItemCount();
const guTrack * GetTrack( int index );
void RemoveItem( int itemnum );
bool GetPlayLoop();
bool GetPlaySmart();
int GetPlayMode();
void SetPlayMode( const int playmode );
void UpdatePlayListFilters( void );
void SetCurrentCoverImage( wxImage * coverimage, const guSongCoverType CoverType, const wxString &CoverPath = wxEmptyString );
void UpdateCoverImage( const bool shownotify = true );
int GetCaps();
const guMediaState GetState( void );
void OnPrevTrackButtonClick( wxCommandEvent &event );
void OnNextTrackButtonClick( wxCommandEvent &event );
void OnPrevAlbumButtonClick( wxCommandEvent &event );
void OnNextAlbumButtonClick( wxCommandEvent &event );
void OnPlayButtonClick( wxCommandEvent &event );
void OnStopButtonClick( wxCommandEvent &event );
void OnStopAtEnd( wxCommandEvent &event );
void OnRecordButtonClick( wxCommandEvent &event );
//void OnSmartPlayButtonClick( wxCommandEvent &event );
void OnRandomPlayButtonClick( wxCommandEvent &event );
//void OnRepeatPlayButtonClick( wxCommandEvent &event );
void OnLoveBanButtonClick( wxCommandEvent &event );
void OnEqualizerButtonClicked( wxCommandEvent &event );
void OnEqualizerRightButtonClicked( wxCommandEvent &event );
void OnVolCtlToggle( wxCommandEvent &event );
void OnForceGaplessClick( wxCommandEvent &event );
void OnPlayModeButtonClicked( wxCommandEvent &event );
void SetArtistLabel( const wxString &artistname );
void SetAlbumLabel( const wxString &albumname );
void SetTitleLabel( const wxString &trackname );
void SetRatingLabel( const int Rating );
int GetRating( void ) { return m_MediaSong.m_Rating; }
void SetRating( const int rating );
void UpdatePositionLabel( const unsigned int curpos );
void SetCodecLabel( const wxString &codec, const wxString &tooltip );
void SetBitRateLabel( const int bitrate );
void SetBitRate( int bitrate );
void SetCodec( const wxString &codec );
void UpdatedTracks( const guTrackArray * tracks );
void UpdatedTrack( const guTrack * track );
void UpdateLabels( void );
void SetPlayerVumeters( guPlayerVumeters * vumeters ) { m_PlayerVumeters = vumeters; }
void ResetVumeterLevel( void );
void SetNotifySrv( guDBusNotify * notify ) { m_NotifySrv = notify; }
void SendNotifyInfo( wxImage * image );
void SetForceGapless( const bool forcegapless );
bool GetForceGapless( void ) { return m_ForceGapless; }
bool GetAudioScrobbleEnabled( void ) { return m_AudioScrobbleEnabled; }
void UpdateCover( const bool shownotify = true, const bool deleted = false ); // Start the thread that search for the cover
wxString LastTmpCoverFile( void ) { return m_LastTmpCoverFile; }
void SetLastTmpCoverFile( const wxString &lastcoverfile ) { m_LastTmpCoverFile = lastcoverfile; }
void StopAtEnd( void ) { m_MediaSong.m_Type = guTrackType( ( int ) m_MediaSong.m_Type ^ guTRACK_TYPE_STOP_HERE ); }
void MediaViewerClosed( guMediaViewer * mediaviewer );
void CheckStartPlaying( void );
void OnUpdatePipeline( wxCommandEvent &event );
//friend class guSmartAddTracksThread;
};
// -------------------------------------------------------------------------------- //
class guUpdatePlayerCoverThread : public wxThread
{
protected :
guDbLibrary * m_Db;
guPlayerPanel * m_PlayerPanel;
guCurrentTrack * m_CurrentTrack;
guMainFrame * m_MainFrame;
bool m_ShowNotify;
bool m_Deleted;
public:
guUpdatePlayerCoverThread( guDbLibrary * db, guMainFrame * mainframe, guPlayerPanel * playerpanel,
guCurrentTrack * currenttrack, const bool shownotify, const bool deleted = false );
~guUpdatePlayerCoverThread();
virtual ExitCode Entry();
};
}
#endif
// -------------------------------------------------------------------------------- //
| 21,664
|
C++
|
.h
| 445
| 42.916854
| 161
| 0.531189
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,729
|
PlayerFilters.h
|
anonbeat_guayadeque/src/ui/player/PlayerFilters.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __PLAYERFILTERS_H__
#define __PLAYERFILTERS_H__
#include "DbLibrary.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/choice.h>
#include <wx/sizer.h>
#include <wx/panel.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
class guPlayerFilters : public wxPanel
{
protected :
wxChoice * m_FilterAllowChoice;
wxChoice * m_FilterDenyChoice;
guListItems m_FilterPlayLists;
guDbLibrary * m_Db;
public :
guPlayerFilters( wxWindow * parent, guDbLibrary * db );
~guPlayerFilters();
void UpdateFilters( void );
void EnableFilters( const bool enable );
int GetAllowSelection( void );
int GetDenySelection( void );
int GetAllowFilterId( void );
int GetDenyFilterId( void );
void SetAllowFilterId( const int id );
void SetDenyFilterId( const int id );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 2,231
|
C++
|
.h
| 57
| 37
| 86
| 0.57374
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,730
|
SplashWin.h
|
anonbeat_guayadeque/src/ui/splash/SplashWin.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __SPLASHWIN_H__
#define __SPLASHWIN_H__
#include <wx/bitmap.h>
#include <wx/colour.h>
#include <wx/font.h>
#include <wx/frame.h>
#include <wx/gdicmn.h>
#include <wx/hyperlink.h>
#include <wx/icon.h>
#include <wx/image.h>
#include <wx/settings.h>
#include <wx/sizer.h>
#include <wx/statbmp.h>
#include <wx/stattext.h>
#include <wx/string.h>
#include <wx/timer.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
class guSplashFrame : public wxFrame
{
private:
protected:
wxHyperlinkCtrl * m_Email;
wxStaticText * m_Version;
wxHyperlinkCtrl * m_HomePage;
wxHyperlinkCtrl * m_Donate;
wxBitmap * m_Bitmap;
wxTimer m_Timer;
// event handlers, overide them in your derived class
void OnSplashClick( wxMouseEvent& event );
void OnEraseBackground( wxEraseEvent &event );
public:
guSplashFrame( wxWindow * parent, int timeout = 4000 ); //, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,358 ), long style = 0|wxTAB_TRAVERSAL );
~guSplashFrame();
void OnCloseWindow( wxCloseEvent &event );
void OnTimeout( wxTimerEvent &event );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 2,406
|
C++
|
.h
| 61
| 37.606557
| 239
| 0.611825
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,731
|
ToggleRoundButton.h
|
anonbeat_guayadeque/src/ui/toggleroundbutton/ToggleRoundButton.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __TOGGLEROUNDBUTTON_H__
#define __TOGGLEROUNDBUTTON_H__
#include "RoundButton.h"
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
class guToggleRoundButton : public guRoundButton
{
protected :
bool m_Value;
protected :
virtual void OnPaint( wxPaintEvent &event );
virtual void OnMouseEvents( wxMouseEvent &event );
public :
guToggleRoundButton( wxWindow * parent, const wxImage &image, const wxImage &selimage, const wxImage &hoverimage );
virtual ~guToggleRoundButton();
bool GetValue( void ) { return m_Value; }
void SetValue( bool value );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 1,836
|
C++
|
.h
| 42
| 41.642857
| 119
| 0.575435
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,732
|
MediaViewerLibrary.h
|
anonbeat_guayadeque/src/ui/mediaviewer/MediaViewerLibrary.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __MEDIAVIEWERLIBRARY_H__
#define __MEDIAVIEWERLIBRARY_H__
#include "MediaViewer.h"
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
class guMediaViewerLibrary : public guMediaViewer
{
protected :
public :
guMediaViewerLibrary( wxWindow * parent, guMediaCollection &mediacollection, const int basecommand, guMainFrame * mainframe, const int mode, guPlayerPanel * playerpanel );
~guMediaViewerLibrary();
//virtual void CreateCollectionMenu( wxMenu * menu, const int basecommand ) {}
};
}
#endif
// -------------------------------------------------------------------------------- //
| 1,718
|
C++
|
.h
| 37
| 44.783784
| 175
| 0.590556
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,733
|
MediaViewer.h
|
anonbeat_guayadeque/src/ui/mediaviewer/MediaViewer.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __MEDIAVIEWER_H__
#define __MEDIAVIEWER_H__
#include "AlbumBrowser.h"
#include "AuiNotebook.h"
#include "Collections.h"
#include "LibPanel.h"
#include "PlayerPanel.h"
#include "PlayListPanel.h"
#include "Preferences.h"
#include "TreePanel.h"
#include <wx/dynarray.h>
namespace Guayadeque {
enum guMediaViewerMode {
guMEDIAVIEWER_MODE_NONE = -1,
guMEDIAVIEWER_MODE_LIBRARY,
guMEDIAVIEWER_MODE_ALBUMBROWSER,
guMEDIAVIEWER_MODE_TREEVIEW,
guMEDIAVIEWER_MODE_PLAYLISTS
};
enum guMediaViewerCommand {
guMEDIAVIEWER_SHOW_LIBRARY,
guMEDIAVIEWER_SHOW_ALBUMBROWSER,
guMEDIAVIEWER_SHOW_TREEVIEW,
guMEDIAVIEWER_SHOW_PLAYLISTS,
guMEDIAVIEWER_SHOW_TEXTSEARCH,
guMEDIAVIEWER_SHOW_LABELS,
guMEDIAVIEWER_SHOW_GENRES,
guMEDIAVIEWER_SHOW_ARTISTS,
guMEDIAVIEWER_SHOW_COMPOSERS,
guMEDIAVIEWER_SHOW_ALBUMARTISTS,
guMEDIAVIEWER_SHOW_ALBUMS,
guMEDIAVIEWER_SHOW_YEARS,
guMEDIAVIEWER_SHOW_RATINGS,
guMEDIAVIEWER_SHOW_PLAYCOUNTS
};
enum guMediaViewerSelect {
guMEDIAVIEWER_SELECT_TRACK,
guMEDIAVIEWER_SELECT_ARTIST,
guMEDIAVIEWER_SELECT_ALBUM,
guMEDIAVIEWER_SELECT_ALBUMARTIST,
guMEDIAVIEWER_SELECT_COMPOSER,
guMEDIAVIEWER_SELECT_YEAR,
guMEDIAVIEWER_SELECT_GENRE
};
#define guCONTEXTMENU_EDIT_TRACKS ( 1 << 0 )
#define guCONTEXTMENU_DOWNLOAD_COVERS ( 1 << 1 )
#define guCONTEXTMENU_EMBED_COVERS ( 1 << 2 )
#define guCONTEXTMENU_COPY_TO ( 1 << 3 )
#define guCONTEXTMENU_LINKS ( 1 << 4 )
#define guCONTEXTMENU_COMMANDS ( 1 << 5 )
#define guCONTEXTMENU_DELETEFROMLIBRARY ( 1 << 6 )
#define guCONTEXTMENU_DEFAULT ( guCONTEXTMENU_EDIT_TRACKS | guCONTEXTMENU_DOWNLOAD_COVERS |\
guCONTEXTMENU_EMBED_COVERS | guCONTEXTMENU_COPY_TO |\
guCONTEXTMENU_LINKS | guCONTEXTMENU_COMMANDS |\
guCONTEXTMENU_DELETEFROMLIBRARY )
class guMainFrame;
class guLibUpdateThread;
class guLibCleanThread;
class guCopyToAction;
class guUpdateCoversThread;
// -------------------------------------------------------------------------------- //
class guMediaViewer : public wxPanel
{
protected :
bool m_IsDefault;
guMediaCollection * m_MediaCollection;
guDbLibrary * m_Db;
guMainFrame * m_MainFrame;
guPlayerPanel * m_PlayerPanel;
int m_BaseCommand;
int m_ViewMode;
wxThread * m_UpdateThread;
guLibCleanThread * m_CleanThread;
wxBoxSizer * m_FiltersSizer;
guCopyToPattern * m_CopyToPattern;
guUpdateCoversThread * m_UpdateCoversThread;
wxChoice * m_FilterChoice;
wxBitmapButton * m_AddFilterButton;
wxBitmapButton * m_DelFilterButton;
wxBitmapButton * m_EditFilterButton;
wxSearchCtrl * m_SearchTextCtrl;
wxBitmapButton * m_LibrarySelButton;
wxBitmapButton * m_AlbumBrowserSelButton;
wxBitmapButton * m_TreeViewSelButton;
wxBitmapButton * m_PlaylistsSelButton;
guLibPanel * m_LibPanel;
guAlbumBrowser * m_AlbumBrowser;
guTreeViewPanel * m_TreeViewPanel;
guPlayListPanel * m_PlayListPanel;
wxTimer m_TextChangedTimer;
bool m_DoneClearSearchText;
bool m_InstantSearchEnabled;
bool m_EnterSelectSearchEnabled;
wxString m_ConfigPath;
wxArrayString m_DynFilterArray;
wxString m_SearchText;
int m_ContextMenuFlags;
wxString m_SmartPlaylistName;
int m_SmartPlaylistId;
wxArrayInt m_SmartTracksList;
wxArrayString m_SmartArtistsList;
void OnViewChanged( wxCommandEvent &event );
// Search Str events
void OnSearchActivated( wxCommandEvent &event );
void OnSearchCancelled( wxCommandEvent &event );
void OnSearchSelected( wxCommandEvent &event );
void OnTextChangedTimer( wxTimerEvent &event );
virtual bool DoTextSearch( void );
virtual void CreateControls( void );
virtual void PlayAllTracks( const bool enqueue );
virtual void OnConfigUpdated( wxCommandEvent &event );
void OnAddFilterClicked( wxCommandEvent &event );
void OnDelFilterClicked( wxCommandEvent &event );
void OnEditFilterClicked( wxCommandEvent &event );
void OnFilterSelected( wxCommandEvent &event );
void SetFilter( const wxString &filter );
void OnCleanFinished( wxCommandEvent &event ) { CleanFinished(); }
void OnLibraryUpdated( wxCommandEvent &event ) { LibraryUpdated(); }
void OnAddPath( void );
virtual void LoadMediaDb( void );
virtual void CreateAcceleratorTable( void );
virtual void OnGenreSetSelection( wxCommandEvent &event );
virtual void OnAlbumArtistSetSelection( wxCommandEvent &event );
virtual void OnComposerSetSelection( wxCommandEvent &event );
virtual void OnArtistSetSelection( wxCommandEvent &event );
virtual void OnAlbumSetSelection( wxCommandEvent &event );
virtual void OnUpdateLabels( wxCommandEvent &event );
virtual void OnSmartAddTracks( wxCommandEvent &event );
public :
guMediaViewer( wxWindow * parent, guMediaCollection & mediacollection, const int basecommand, guMainFrame * mainframe, const int mode, guPlayerPanel * playerpanel );
~guMediaViewer();
virtual void InitMediaViewer( const int mode );
virtual wxString ConfigPath( void ) { return m_ConfigPath; }
int GetBaseCommand( void ) { return m_BaseCommand; }
bool IsDefault( void ) { return m_IsDefault; }
void SetDefault( const bool isdefault ) { m_IsDefault = isdefault; }
void ClearSearchText( void );
void GoToSearch( void );
virtual int GetContextMenuFlags( void ) { return m_ContextMenuFlags; }
virtual void CreateContextMenu( wxMenu * menu, const int windowid = wxNOT_FOUND );
virtual void CreateCopyToMenu( wxMenu * menu );
int GetViewMode( void ) { return m_ViewMode; }
virtual void SetViewMode( const int mode );
guDbLibrary * GetDb( void ) { return m_Db; }
guPlayerPanel * GetPlayerPanel( void ) { return m_PlayerPanel; }
void SetPlayerPanel( guPlayerPanel * playerpanel );
guMainFrame * GetMainFrame( void ) { return m_MainFrame; }
guLibPanel * GetLibPanel( void ) { return m_LibPanel; }
guAlbumBrowser * GetAlbumBrowser( void ) { return m_AlbumBrowser; }
guTreeViewPanel * GetTreeViewPanel( void ) { return m_TreeViewPanel; }
guPlayListPanel * GetPlayListPanel( void ) { return m_PlayListPanel; }
virtual bool CreateLibraryView( void );
virtual bool CreateAlbumBrowserView( void );
virtual bool CreateTreeView( void );
virtual bool CreatePlayListView( void );
virtual void SetMenuState( const bool enabled = true );
virtual void ShowPanel( const int id, const bool enabled );
virtual void HandleCommand( const int command );
// Collections related
guMediaCollection * GetMediaCollection( void ) { return m_MediaCollection; }
virtual void SetCollection( guMediaCollection &collection, const int basecommand );
virtual wxString GetUniqueId( void ) { return m_MediaCollection->m_UniqueId; }
virtual int GetType( void ) { return m_MediaCollection->m_Type; }
virtual wxString GetName( void ) { return m_MediaCollection->m_Name; }
virtual wxArrayString GetPaths( void ) { return m_MediaCollection->m_Paths; }
virtual wxArrayString GetCoverWords( void ) { return m_MediaCollection->m_CoverWords; }
virtual bool GetUpdateOnStart( void ) { return m_MediaCollection->m_UpdateOnStart; }
virtual bool GetScanPlaylists( void ) { return m_MediaCollection->m_ScanPlaylists; }
virtual bool GetScanFollowSymLinks( void ) { return m_MediaCollection->m_ScanFollowSymLinks; }
virtual bool GetScanEmbeddedCovers( void ) { return m_MediaCollection->m_ScanEmbeddedCovers; }
virtual bool GetEmbeddMetadata( void ) { return m_MediaCollection->m_EmbeddMetadata; }
virtual wxString GetDefaultCopyAction( void ) { return m_MediaCollection->m_DefaultCopyAction; }
virtual int GetLastUpdate( void ) { return m_MediaCollection->m_LastUpdate; }
virtual void SetLastUpdate( void );
virtual void UpgradeLibrary( void );
virtual void UpdateLibrary( const wxString &path = wxEmptyString );
virtual void UpdateFinished( void );
virtual void CleanLibrary( void );
virtual void CleanFinished( void );
virtual void UpdatePlaylists( void );
virtual void LibraryUpdated( void );
virtual void UpdateCovers( void );
virtual void UpdateCoversFinished( void );
virtual void ImportFiles( void ) { ImportFiles( new guTrackArray() ); }
virtual void ImportFiles( guTrackArray * tracks );
virtual void ImportFiles( const wxArrayString &files );
virtual void SaveLayout( wxXmlNode * xmlnode );
virtual void LoadLayout( wxXmlNode * xmlnode );
virtual wxString GetSelInfo( void );
virtual void UpdatedTrack( const int updatedby, const guTrack * track );
virtual void UpdatedTracks( const int updatedby, const guTrackArray * tracks );
virtual int CopyTo( guTrack * track, guCopyToAction ©toaction, wxString &filename, const int index );
virtual void NormalizeTracks( guTrackArray * tracks, const bool isdrag = false ) {}
virtual void DownloadAlbumCover( const int albumid );
virtual void SelectAlbumCover( const int albumid );
virtual void EmbedAlbumCover( const int albumid );
virtual bool SetAlbumCover( const int albumid, const wxString &coverpath, const bool update = true );
virtual bool SetAlbumCover( const int albumid, const wxString &albumpath, wxImage * coverimg );
virtual bool SetAlbumCover( const int albumid, const wxString &albumpath, wxString &coverpath );
virtual void DeleteAlbumCover( const int albumid );
virtual void DeleteAlbumCover( const wxArrayInt &albumids );
virtual void AlbumCoverChanged( const int album, const bool deleted = false );
virtual wxString GetCoverName( const int albumid );
virtual wxBitmapType GetCoverType( void ) { return wxBITMAP_TYPE_JPEG; }
virtual int GetCoverMaxSize( void ) { return 0; }
virtual wxImage * GetAlbumCover( const int albumid, int &coverid, wxString &coverpath,
const wxString &artistname = wxEmptyString, const wxString &albumname = wxEmptyString );
virtual int GetAlbumCoverId( const int albumid ) { return m_Db->GetAlbumCoverId( albumid ); }
virtual bool FindMissingCover( const int albumid, const wxString &artistname,
const wxString &albumname, const wxString &albumpath );
virtual void SetSelection( const int type, const int id );
virtual void PlayListUpdated( void );
virtual void EditProperties( void );
virtual void DeleteTracks( const guTrackArray * tracks );
virtual void UpdateTracks( const guTrackArray &tracks, const guImagePtrArray &images,
const wxArrayString &lyrics, const wxArrayInt &changedflags );
virtual void SetTracksRating( guTrackArray &tracks, const int rating );
// Copy to support functions
virtual wxString AudioPath( void );
virtual wxString Pattern( void );
virtual int AudioFormats( void );
virtual int TranscodeFormat( void );
virtual int TranscodeScope( void );
virtual int TranscodeQuality( void );
virtual bool MoveFiles( void );
virtual int PlaylistFormats( void );
virtual wxString PlaylistPath( void );
virtual int CoverFormats( void ) { return 2; } //guPORTABLEMEDIA_COVER_FORMAT_JPEG
virtual wxString CoverName( void ) { return GetCoverName( wxNOT_FOUND ); }
virtual int CoverSize( void ) { return 0; }
virtual void CreateSmartPlaylist( const wxString &artistname, const wxString &trackname );
virtual void CreateBestOfPlaylist( const guTrack &track );
virtual void CreateBestOfPlaylist( const wxString &artistname );
};
WX_DEFINE_ARRAY_PTR( guMediaViewer *, guMediaViewerArray );
// -------------------------------------------------------------------------------- //
class guUpdateCoversThread : public wxThread
{
private:
guMediaViewer * m_MediaViewer;
int m_GaugeId;
public:
guUpdateCoversThread( guMediaViewer * mediaviewer, int gaugeid );
~guUpdateCoversThread();
virtual ExitCode Entry();
};
// -------------------------------------------------------------------------------- //
class guMediaViewerDropTarget : public wxDropTarget
{
protected :
guMediaViewer * m_MediaViewer;
public :
guMediaViewerDropTarget( guMediaViewer * libpanel );
~guMediaViewerDropTarget();
virtual wxDragResult OnData( wxCoord x, wxCoord y, wxDragResult def );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 15,675
|
C++
|
.h
| 280
| 50.846429
| 169
| 0.618553
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,734
|
AudioCdPanel.h
|
anonbeat_guayadeque/src/ui/mediaviewer/audiocd/AudioCdPanel.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __AUDIOCDPANEL_H__
#define __AUDIOCDPANEL_H__
#include "AuiManagerPanel.h"
#include "DbLibrary.h"
#include "ListView.h"
#include "PlayerPanel.h"
namespace Guayadeque {
#include <wx/wx.h>
typedef enum {
guAUDIOCD_COLUMN_NUMBER,
guAUDIOCD_COLUMN_TITLE,
guAUDIOCD_COLUMN_ARTIST,
guAUDIOCD_COLUMN_ALBUMARTIST,
guAUDIOCD_COLUMN_ALBUM,
guAUDIOCD_COLUMN_GENRE,
guAUDIOCD_COLUMN_COMPOSER,
guAUDIOCD_COLUMN_DISK,
guAUDIOCD_COLUMN_LENGTH,
guAUDIOCD_COLUMN_YEAR,
guAUDIOCD_COLUMN_COUNT
} guAudioCd_Column;
// -------------------------------------------------------------------------------- //
class guCdTracksListBox : public guListView
{
protected :
guTrackArray m_AudioCdTracks;
int m_LastColumnRightClicked;
int m_LastRowRightClicked;
int m_Order;
bool m_OrderDesc;
wxArrayString m_ColumnNames;
void AppendFastEditMenu( wxMenu * menu, const int selcount ) const;
virtual void CreateContextMenu( wxMenu * Menu ) const;
virtual wxString OnGetItemText( const int row, const int column ) const;
virtual void GetItemsList( void );
virtual int GetSelectedSongs( guTrackArray * tracks, const bool isdrag = false ) const;
void GetAllSongs( guTrackArray * tracks );
void OnConfigUpdated( wxCommandEvent &event );
void CreateAcceleratorTable();
void OnItemColumnRClicked( wxListEvent &event );
public :
guCdTracksListBox( wxWindow * parent );
~guCdTracksListBox();
void SetTrackList( guTrackArray &audiocdtracks );
void ClearTracks( void );
virtual void ReloadItems( bool reset = true );
virtual wxString inline GetItemName( const int item ) const;
virtual int inline GetItemId( const int item ) const;
int GetLastColumnClicked( void ) { return m_LastColumnRightClicked; }
int GetLastRowClicked( void ) { return m_LastRowRightClicked; }
wxVariant GetLastDataClicked( void );
void SetOrder( int order );
int GetOrder( void ) { return m_Order; }
bool GetOrderDesc( void ) { return m_OrderDesc; }
const wxArrayString & GetColumnNames( void ) const { return m_ColumnNames; }
void UpdatedTracks( guTrackArray * tracks );
void GetCounters( wxLongLong * count, wxLongLong * len, wxLongLong * size );
friend class guAudioCdPanel;
};
// -------------------------------------------------------------------------------- //
class guAudioCdPanel : public wxPanel
{
protected:
guCdTracksListBox * m_CdTracksListBox;
guPlayerPanel * m_PlayerPanel;
void OnAudioCdTrackActivated( wxCommandEvent &event );
void OnSelectAudioCdTracks( const bool enqueue, const int aftercurrent = 0 );
void OnAudioCdTrackPlay( wxCommandEvent &event );
void OnAudioCdTrackEnqueue( wxCommandEvent &event );
void OnAudioCdTrackCopyTo( wxCommandEvent &event );
void OnAudioCdRefresh( wxCommandEvent &event );
void OnSongSetField( wxCommandEvent &event );
void OnSongEditField( wxCommandEvent &event );
public:
guAudioCdPanel( wxWindow * parent, guPlayerPanel * playerpanel );
~guAudioCdPanel();
void GetCounters( wxLongLong * count, wxLongLong * len, wxLongLong * size );
void UpdateVolume( const bool added );
void SetAudioCdTracks( guTrackArray &audiocdtracks );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 5,196
|
C++
|
.h
| 104
| 46.317308
| 107
| 0.566739
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,735
|
AlbumBrowser.h
|
anonbeat_guayadeque/src/ui/mediaviewer/albumbrowser/AlbumBrowser.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __ALBUMBROWSER_H__
#define __ALBUMBROWSER_H__
#include "AutoScrollText.h"
#include "DbLibrary.h"
#include "DynamicPlayList.h"
#include "PlayerPanel.h"
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/statbmp.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/sizer.h>
#include <wx/srchctrl.h>
#include <wx/panel.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
class guAlbumBrowserItem
{
public :
unsigned int m_AlbumId;
wxString m_ArtistName;
unsigned int m_ArtistId;
wxString m_AlbumName;
unsigned int m_Year;
unsigned int m_TrackCount;
unsigned int m_CoverId;
wxBitmap * m_CoverBitmap;
guAlbumBrowserItem()
{
m_AlbumId = wxNOT_FOUND;
m_Year = 0;
m_ArtistId = wxNOT_FOUND;
m_TrackCount = 0;
m_CoverBitmap = NULL;
};
~guAlbumBrowserItem()
{
if( m_CoverBitmap )
delete m_CoverBitmap;
};
};
WX_DECLARE_OBJARRAY( guAlbumBrowserItem, guAlbumBrowserItemArray );
class guAlbumBrowser;
class guMediaViewer;
// -------------------------------------------------------------------------------- //
class guAlbumBrowserItemPanel : public wxPanel
{
protected :
int m_Index;
guAlbumBrowserItem * m_AlbumBrowserItem;
guAlbumBrowser * m_AlbumBrowser;
wxPoint m_DragStart;
int m_DragCount;
// GUI
wxBoxSizer * m_MainSizer;
wxStaticBitmap * m_Bitmap;
guAutoScrollText * m_ArtistLabel;
guAutoScrollText * m_AlbumLabel;
guAutoScrollText * m_TracksLabel;
wxTimer m_BitmapTimer;
void OnContextMenu( wxContextMenuEvent &event );
void OnSearchLinkClicked( wxCommandEvent &event );
void OnPlayClicked( wxCommandEvent &event );
void OnEnqueueClicked( wxCommandEvent &event );
void OnCopyToClipboard( wxCommandEvent &event );
void OnAlbumSelectName( wxCommandEvent &event );
void OnArtistSelectName( wxCommandEvent &event );
void OnCommandClicked( wxCommandEvent &event );
void OnAlbumDownloadCoverClicked( wxCommandEvent &event );
void OnAlbumSelectCoverClicked( wxCommandEvent &event );
void OnAlbumDeleteCoverClicked( wxCommandEvent &event );
void OnAlbumEmbedCoverClicked( wxCommandEvent &event );
void OnAlbumCopyToClicked( wxCommandEvent &event );
void OnAlbumEditLabelsClicked( wxCommandEvent &event );
void OnAlbumEditTracksClicked( wxCommandEvent &event );
void OnAlbumDClicked( wxMouseEvent &event );
void OnMouse( wxMouseEvent &event );
void OnBeginDrag( wxCommandEvent &event );
void OnCoverBeginDrag( wxCommandEvent &event );
int GetDragFiles( guDataObjectComposite * files );
void OnBitmapClicked( wxMouseEvent &event );
void OnTimer( wxTimerEvent &event );
public :
guAlbumBrowserItemPanel( wxWindow * parent, const int index, guAlbumBrowserItem * albumitem = NULL );
~guAlbumBrowserItemPanel();
void SetAlbumItem( const int index, guAlbumBrowserItem * albumitem, wxBitmap * blankcd );
void UpdateDetails( void );
void SetAlbumCover( const wxString &cover );
};
WX_DEFINE_ARRAY_PTR( guAlbumBrowserItemPanel *, guAlbumBrowserItemPanelArray );
WX_DEFINE_ARRAY_PTR( wxStaticText *, guStaticTextArray );
class guUpdateAlbumDetails;
// -------------------------------------------------------------------------------- //
class guAlbumBrowser : public wxPanel
{
protected :
guMediaViewer * m_MediaViewer;
guDbLibrary * m_Db;
guPlayerPanel * m_PlayerPanel;
guAlbumBrowserItemArray m_AlbumItems;
wxMutex m_AlbumItemsMutex;
guAlbumBrowserItemPanelArray m_ItemPanels;
wxMutex m_ItemPanelsMutex;
guUpdateAlbumDetails * m_UpdateDetails;
wxMutex m_UpdateDetailsMutex;
unsigned int m_ItemStart; // The first element in a page
unsigned int m_LastItemStart;
unsigned int m_ItemCount; // The number of elements in a page
unsigned int m_AlbumsCount; // The number of albums in database
unsigned int m_PagesCount; // The number of pages to scroll
wxBitmap * m_BlankCD;
wxTimer m_RefreshTimer;
guDynPlayList m_DynFilter;
guAlbumBrowserItem * m_LastAlbumBrowserItem;
int m_DragCount;
wxPoint m_DragStart;
bool m_MouseWasLeftUp;
bool m_MouseSelecting;
wxString m_LastSearchString;
int m_SortSelected;
wxString m_ConfigPath;
wxTimer m_BitmapClickTimer;
// GUI
wxBoxSizer * m_MainSizer;
wxBoxSizer * m_AlbumBrowserSizer;
wxGridSizer * m_AlbumsSizer;
wxStaticText * m_NavLabel;
wxSlider * m_NavSlider;
wxSize m_LastSize;
wxArrayString m_TextSearchFilter;
wxBoxSizer * m_BigCoverSizer;
wxButton * m_BigCoverBackBtn;
wxStaticBitmap * m_BigCoverBitmap;
guAutoScrollText * m_BigCoverAlbumLabel;
guAutoScrollText * m_BigCoverArtistLabel;
guAutoScrollText * m_BigCoverDetailsLabel;
wxListBox * m_BigCoverTracksListBox;
guStaticTextArray m_BigCoverTracksItems;
guTrackArray m_BigCoverTracks;
bool m_BigCoverShowed;
bool m_BigCoverTracksContextMenu;
int GetItemStart( void ) { return m_ItemStart; }
int GetItemCount( void ) { return m_ItemCount; }
int GetAlbumsCount( void ) { return m_AlbumsCount; }
void OnChangedSize( wxSizeEvent &event );
void OnChangingPosition( wxScrollEvent& event );
void SetCurrentPage( int page );
void OnRefreshTimer( wxTimerEvent &event );
void OnAddFilterClicked( wxCommandEvent &event );
void OnDelFilterClicked( wxCommandEvent &event );
void OnEditFilterClicked( wxCommandEvent &event );
void OnSortSelected( wxCommandEvent &event );
void OnUpdateDetails( wxCommandEvent &event );
void OnMouseWheel( wxMouseEvent& event );
virtual void NormalizeTracks( guTrackArray * tracks, const bool isdrag = false );
virtual void OnBitmapClicked( guAlbumBrowserItem * albumitem, const wxPoint &position );
virtual void OnAlbumSelectName( const int albumid );
virtual void OnArtistSelectName( const int artistid );
void OnGoToSearch( wxCommandEvent &event );
void OnConfigUpdated( wxCommandEvent &event );
void CreateAcceleratorTable( void );
bool DoTextSearch( const wxString &searchtext );
void OnBigCoverBackClicked( wxCommandEvent &event );
void OnBigCoverBitmapClicked( wxMouseEvent &event );
void OnBigCoverBitmapDClicked( wxMouseEvent &event );
void OnBigCoverTracksDClicked( wxCommandEvent &event );
void DoBackToAlbums( void );
int GetSelectedTracks( guTrackArray * tracks );
void DoSelectTracks( const guTrackArray &tracks, const bool append, const int aftercurrent = 0 );
void OnBigCoverContextMenu( wxContextMenuEvent &event );
void OnBigCoverTracksContextMenu( wxContextMenuEvent &event );
void OnBigCoverPlayClicked( wxCommandEvent &event );
void OnBigCoverEnqueueClicked( wxCommandEvent &event );
void OnBigCoverCopyToClipboard( wxCommandEvent &event );
void OnBigCoverAlbumSelectName( wxCommandEvent &event );
void OnBigCoverArtistSelectName( wxCommandEvent &event );
void OnBigCoverCommandClicked( wxCommandEvent &event );
void OnBigCoverDownloadCoverClicked( wxCommandEvent &event );
void OnBigCoverSelectCoverClicked( wxCommandEvent &event );
void OnBigCoverDeleteCoverClicked( wxCommandEvent &event );
void OnBigCoverEmbedCoverClicked( wxCommandEvent &event );
void OnBigCoverCopyToClicked( wxCommandEvent &event );
void OnBigCoverEditLabelsClicked( wxCommandEvent &event );
void OnBigCoverEditTracksClicked( wxCommandEvent &event );
void OnBigCoverSearchLinkClicked( wxCommandEvent &event );
void OnBigCoverTracksPlayClicked( wxCommandEvent &event );
void OnBigCoverTracksEnqueueClicked( wxCommandEvent &event );
void OnBigCoverTracksEditLabelsClicked( wxCommandEvent &event );
void OnBigCoverTracksEditTracksClicked( wxCommandEvent &event );
void OnBigCoverTracksMouseMoved( wxMouseEvent &event );
void OnBigCoverTracksBeginDrag( wxCommandEvent &event );
void OnBigCoverTracksPlaylistSave( wxCommandEvent &event );
void OnBigCoverTracksSmartPlaylist( wxCommandEvent &event );
void OnTimerTimeout( wxTimerEvent &event );
void CreateControls( void );
void CalculateMaxItemHeight( void );
virtual void OnKeyDown( wxKeyEvent &event );
public :
//guAlbumBrowser( wxWindow * parent, guDbLibrary * db, guPlayerPanel * playerpanel );
guAlbumBrowser( wxWindow * parent, guMediaViewer * mediaviewer );
virtual ~guAlbumBrowser();
virtual int GetContextMenuFlags( void );
virtual void SetLastAlbumItem( guAlbumBrowserItem * item ) { m_LastAlbumBrowserItem = item; }
virtual void CreateContextMenu( wxMenu * Menu );
void RefreshCount( void );
void ClearUpdateDetailsThread( void );
void RefreshPageCount( void );
void ReloadItems( void );
void RefreshAll( void );
void UpdateNavLabel( const int page );
virtual void SelectAlbum( const int albumid, const bool append, const int aftercurrent = 0 );
virtual int GetAlbumTracks( const int albumid, guTrackArray * tracks );
virtual void OnCommandClicked( const int commandid, const int albumid );
virtual void OnCommandClicked( const int commandid, const guTrackArray &tracks );
virtual void OnAlbumDownloadCoverClicked( const int albumid );
virtual void OnAlbumSelectCoverClicked( const int albumid );
virtual void OnAlbumDeleteCoverClicked( const int albumid );
virtual void OnAlbumEmbedCoverClicked( const int albumid );
virtual void OnAlbumCopyToClicked( const int albumid, const int commandid );
virtual void OnAlbumEditLabelsClicked( const guAlbumBrowserItem * albumitem );
virtual void OnAlbumEditTracksClicked( const int albumid );
void LibraryUpdated( void );
wxString GetAlbumCoverFile( const int albumid );
void SetAlbumCover( const int albumid, const wxString &cover );
void SetFilter( const wxString &filterstr );
int GetSortSelected( void ) { return m_SortSelected; }
virtual void AlbumCoverChanged( const int albumid );
void SetPlayerPanel( guPlayerPanel * playerpanel ) { m_PlayerPanel = playerpanel; }
wxString GetSelInfo( void );
friend class guUpdateAlbumDetails;
friend class guAlbumBrowserItemPanel;
friend class guMediaViewer;
};
// -------------------------------------------------------------------------------- //
class guAlbumBrowserDropTarget : public wxDropTarget
{
private:
guAlbumBrowserItemPanel * m_AlbumBrowserItemPanel;
guMediaViewer * m_MediaViewer;
public:
guAlbumBrowserDropTarget( guMediaViewer * mediaviewer, guAlbumBrowserItemPanel * itempanel );
~guAlbumBrowserDropTarget() {}
virtual wxDragResult OnData( wxCoord x, wxCoord y, wxDragResult def );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 15,626
|
C++
|
.h
| 273
| 52.941392
| 128
| 0.550991
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,736
|
TreePanel.h
|
anonbeat_guayadeque/src/ui/mediaviewer/treeview/TreePanel.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __TREEPANEL_H__
#define __TREEPANEL_H__
#include "AuiManagerPanel.h"
#include "DbLibrary.h"
#include "PlayerPanel.h"
#include "LibPanel.h"
#include "SoListBox.h"
#include "TreeViewFilter.h"
#include "TVSoListBox.h"
#include <wx/aui/aui.h>
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/statbmp.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/panel.h>
#include <wx/statline.h>
#include <wx/listctrl.h>
#include <wx/splitter.h>
#include <wx/frame.h>
#include <wx/treectrl.h>
#include <wx/imaglist.h>
#include <wx/srchctrl.h>
namespace Guayadeque {
#define guPANEL_TREEVIEW_TEXTSEARCH ( 1 << 0 )
#define guPANEL_TREEVIEW_VISIBLE_DEFAULT ( 0 )
class guTreeViewPanel;
// -------------------------------------------------------------------------------- //
class guTreeViewData : public wxTreeItemData
{
public :
int m_Id;
int m_Type;
guTreeViewData( const int id, const int type ) { m_Id = id; m_Type = type; }
int GetData( void ) { return m_Id; }
void SetData( int id ) { m_Id = id; }
int GetType( void ) { return m_Type; }
void SetType( int type ) { m_Type = type; }
};
// -------------------------------------------------------------------------------- //
// guTreeViewTreeCtrl
// -------------------------------------------------------------------------------- //
class guTreeViewTreeCtrl : public wxTreeCtrl
{
protected :
guDbLibrary * m_Db;
guTreeViewPanel * m_TreeViewPanel;
wxArrayString m_TextFilters;
wxImageList * m_ImageList;
wxTreeItemId m_RootId;
wxTreeItemId m_FiltersId;
wxTreeItemId m_LibraryId;
wxArrayString m_FilterEntries;
wxArrayInt m_FilterLayout;
int m_CurrentFilter;
wxString m_ConfigPath;
void OnContextMenu( wxTreeEvent &event );
void OnBeginDrag( wxTreeEvent &event );
void OnConfigUpdated( wxCommandEvent &event );
void CreateAcceleratorTable( void );
void LoadFilterLayout( void );
void OnSearchLinkClicked( wxCommandEvent &event );
void OnCommandClicked( wxCommandEvent &event );
public :
guTreeViewTreeCtrl( wxWindow * parent, guDbLibrary * db, guTreeViewPanel * treeviewpanel );
~guTreeViewTreeCtrl();
void ReloadItems( void );
void ReloadFilters( void );
virtual int GetContextMenuFlags( void );
void SetCurrentFilter( const int curfilter ) { m_CurrentFilter = curfilter; LoadFilterLayout(); ReloadFilters(); }
wxString GetFilterEntry( const int index ) { return m_FilterEntries[ index ]; }
void AppendFilterEntry( const wxString &filterentry ) { m_FilterEntries.Add( filterentry ); ReloadFilters(); }
void DeleteFilterEntry( const int index ) { if( m_FilterEntries.Count() == 1 ) return; m_FilterEntries.RemoveAt( index ); ReloadFilters(); }
void SetFilterEntry( const int index, const wxString &filterentry ) { m_FilterEntries[ index ] = filterentry; ReloadFilters(); }
void GetItemFilterEntry( const wxTreeItemId &treeitemid, guTreeViewFilterEntry &filterentry );
bool IsFilterItem( const wxTreeItemId &item );
bool IsFilterEntry( const wxTreeItemId &item ) { return GetItemParent( item ) == m_FiltersId; }
void SetTextFilters( const wxArrayString &textfilters ) { m_TextFilters = textfilters; }
void ClearTextFilters( void ) { m_TextFilters.Clear(); }
DECLARE_EVENT_TABLE()
friend class guTreeViewPanel;
};
// -------------------------------------------------------------------------------- //
class guTreeViewPanel : public guAuiManagerPanel
{
protected :
guMediaViewer * m_MediaViewer;
guDbLibrary * m_Db;
guPlayerPanel * m_PlayerPanel;
wxSplitterWindow * m_MainSplitter;
guTreeViewTreeCtrl * m_TreeViewCtrl;
guTVSoListBox * m_TVTracksListBox;
wxTimer m_TreeItemSelectedTimer;
wxString m_ConfigPath;
wxString m_LastSearchString;
void OnTreeViewSelected( wxTreeEvent &event );
void OnTreeViewActivated( wxTreeEvent &event );
void OnTreeViewPlay( wxCommandEvent &event );
void OnTreeViewEnqueue( wxCommandEvent &event );
void OnTreeViewNewFilter( wxCommandEvent &event );
void OnTreeViewEditFilter( wxCommandEvent &event );
void OnTreeViewDeleteFilter( wxCommandEvent &event );
void OnTreeViewEditLabels( wxCommandEvent &event );
void OnTreeViewEditTracks( wxCommandEvent &event );
void OnTreeViewSaveToPlayList( wxCommandEvent &event );
void OnTreeViewCopyTo( wxCommandEvent &event );
virtual void OnTVTracksActivated( wxCommandEvent &event );
void OnTVTracksPlayClicked( wxCommandEvent &event );
void OnTVTracksQueueClicked( wxCommandEvent &event );
void OnTVTracksEditLabelsClicked( wxCommandEvent &event );
void OnTVTracksEditTracksClicked( wxCommandEvent &event );
void OnTVTracksCopyToClicked( wxCommandEvent &event );
void OnTVTracksSavePlayListClicked( wxCommandEvent &event );
void OnTVTracksSetRating( wxCommandEvent &event );
void OnTVTracksSetField( wxCommandEvent &event );
void OnTVTracksEditField( wxCommandEvent &event );
void OnTVTracksSelectGenre( wxCommandEvent &event );
void OnTVTracksSelectAlbumArtist( wxCommandEvent &event );
void OnTVTracksSelectComposer( wxCommandEvent &event );
void OnTVTracksSelectArtist( wxCommandEvent &event );
void OnTVTracksSelectAlbum( wxCommandEvent &event );
void OnTreeItemSelectedTimer( wxTimerEvent &event );
void OnTVTracksDeleteLibrary( wxCommandEvent &event );
void OnTVTracksDeleteDrive( wxCommandEvent &event );
virtual void NormalizeTracks( guTrackArray * tracks, const bool isdrag = false );
virtual void SendPlayListUpdatedEvent( void );
void OnGoToSearch( wxCommandEvent &event );
bool DoTextSearch( const wxString &searchtext );
void OnTrackListColClicked( wxListEvent &event );
void CreateControls( void );
public :
guTreeViewPanel( wxWindow * parent, guMediaViewer * mediaviewer );
~guTreeViewPanel();
virtual void InitPanelData( void );
virtual int GetContextMenuFlags( void );
virtual void CreateCopyToMenu( wxMenu * menu );
virtual void CreateContextMenu( wxMenu * menu, const int windowid );
void GetTreeViewCounters( wxLongLong * count, wxLongLong * len, wxLongLong * size ) { m_TVTracksListBox->GetCounters( count, len, size ); }
void UpdatedTracks( const guTrackArray * tracks );
void UpdatedTrack( const guTrack * track );
virtual int GetListViewColumnCount( void ) { return guSONGS_COLUMN_COUNT; }
virtual bool GetListViewColumnData( const int id, int * index, int * width, bool * enabled ) { return m_TVTracksListBox->GetColumnData( id, index, width, enabled ); }
virtual bool SetListViewColumnData( const int id, const int index, const int width, const bool enabled, const bool refresh = false ) { return m_TVTracksListBox->SetColumnData( id, index, width, enabled, refresh ); }
void GetAllTracks( guTrackArray * tracks ) { m_TVTracksListBox->GetAllSongs( tracks ); }
void RefreshAll( void );
void SetPlayerPanel( guPlayerPanel * playerpanel ) { m_PlayerPanel = playerpanel; }
wxString ConfigPath( void ) { return m_ConfigPath; }
friend class guTreeViewTreeCtrl;
friend class guMediaViewer;
};
}
#endif
// -------------------------------------------------------------------------------- //
| 9,900
|
C++
|
.h
| 181
| 51.01105
| 230
| 0.592919
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,737
|
TVSoListBox.h
|
anonbeat_guayadeque/src/ui/mediaviewer/treeview/TVSoListBox.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __TVSOLISTBOX_H__
#define __TVSOLISTBOX_H__
#include "SoListBox.h"
#include "TreeViewFilter.h"
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
class guTVSoListBox : public guSoListBox
{
protected :
guTreeViewFilterArray m_Filters;
wxLongLong m_TracksSize;
wxLongLong m_TracksLength;
wxArrayString m_TextFilters;
virtual void GetItemsList( void );
virtual wxString GetSearchText( int item ) const;
virtual void ItemsCheckRange( const int start, const int end ) { m_ItemsFirst = 0; m_ItemsLast = 0; }
virtual void CreateAcceleratorTable();
public :
guTVSoListBox( wxWindow * parent, guMediaViewer * mediaviewer, wxString confname, int style = 0 );
~guTVSoListBox();
void SetFilters( guTreeViewFilterArray &filters );
virtual int GetSelectedSongs( guTrackArray * Songs, const bool isdrag = false ) const;
virtual void GetAllSongs( guTrackArray * Songs );
virtual int GetItemId( const int row ) const;
virtual wxString GetItemName( const int row ) const;
void GetCounters( wxLongLong * count, wxLongLong * len, wxLongLong * size );
virtual void SetTracksOrder( const int order )
{
if( m_TracksOrder != order )
m_TracksOrder = order;
else
m_TracksOrderDesc = !m_TracksOrderDesc;
}
void SetTextFilters( const wxArrayString &textfilters ) { m_TextFilters = textfilters; }
void ClearTextFilters( void ) { m_TextFilters.Clear(); }
};
}
#endif
// -------------------------------------------------------------------------------- //
| 2,837
|
C++
|
.h
| 60
| 43.85
| 112
| 0.590069
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,738
|
TreeViewFilter.h
|
anonbeat_guayadeque/src/ui/mediaviewer/treeview/TreeViewFilter.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// This Program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This Program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __TREEVIEWFILTER_H__
#define __TREEVIEWFILTER_H__
#include <wx/dynarray.h>
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
class guTreeViewFilterItem
{
public :
int m_Id;
int m_Type;
guTreeViewFilterItem( const int type, const int id ) { m_Id = id; m_Type = type; }
int Id( void ) { return m_Id; }
void Id( int id ) { m_Id = id; }
int Type( void ) { return m_Type; }
void Type( int type ) { m_Type = type; }
};
WX_DECLARE_OBJARRAY(guTreeViewFilterItem, guTreeViewFilterEntry);
WX_DECLARE_OBJARRAY(guTreeViewFilterEntry, guTreeViewFilterArray);
}
#endif
// -------------------------------------------------------------------------------- //
| 1,839
|
C++
|
.h
| 42
| 41.880952
| 86
| 0.557295
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.