From 25e23b776ccc4835f11b867c2cc354363f466005 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cl=C3=A9ment=20Stenac?= Date: Sun, 19 Feb 2006 16:16:56 +0000 Subject: [PATCH] * Show meta-information separately * Collect more meta-information in id3 --- include/vlc_meta.h | 1 + modules/demux/util/id3tag.c | 20 +++ modules/gui/wxwidgets/dialogs/fileinfo.cpp | 9 +- modules/gui/wxwidgets/dialogs/fileinfo.hpp | 6 +- modules/gui/wxwidgets/dialogs/infopanels.cpp | 145 ++++++++++++++++--- modules/gui/wxwidgets/dialogs/infopanels.hpp | 51 ++++++- modules/gui/wxwidgets/dialogs/iteminfo.cpp | 2 +- modules/gui/wxwidgets/dialogs/iteminfo.hpp | 2 +- 8 files changed, 204 insertions(+), 32 deletions(-) diff --git a/include/vlc_meta.h b/include/vlc_meta.h index fc6933aa0c..5041fbfb92 100644 --- a/include/vlc_meta.h +++ b/include/vlc_meta.h @@ -40,6 +40,7 @@ #define VLC_META_URL N_("URL") #define VLC_META_LANGUAGE N_("Language") #define VLC_META_NOW_PLAYING N_("Now Playing") +#define VLC_META_PUBLISHER N_("Publisher") #define VLC_META_CDDB_ARTIST N_("CDDB Artist") #define VLC_META_CDDB_CATEGORY N_("CDDB Category") diff --git a/modules/demux/util/id3tag.c b/modules/demux/util/id3tag.c index a3b41dd224..15ad5f3d41 100644 --- a/modules/demux/util/id3tag.c +++ b/modules/demux/util/id3tag.c @@ -107,6 +107,26 @@ static void ParseID3Tag( demux_t *p_demux, uint8_t *p_data, int i_size ) vlc_meta_Add( (vlc_meta_t *)p_demux->p_private, VLC_META_ARTIST, psz_temp ); } + else if( !strcmp(p_frame->id, ID3_FRAME_YEAR ) ) + { + vlc_meta_Add( (vlc_meta_t *)p_demux->p_private, + VLC_META_DATE, psz_temp ); + } + else if( !strcmp(p_frame->id, ID3_FRAME_COMMENT ) ) + { + vlc_meta_Add( (vlc_meta_t *)p_demux->p_private, + VLC_META_DESCRIPTION, psz_temp ); + } + else if( strstr( (char*)p_frame->description, "Copyright" ) ) + { + vlc_meta_Add( (vlc_meta_t *)p_demux->p_private, + VLC_META_COPYRIGHT, psz_temp ); + } + else if( strstr( (char*)p_frame->description, "Publisher" ) ) + { + vlc_meta_Add( (vlc_meta_t *)p_demux->p_private, + VLC_META_PUBLISHER, psz_temp ); + } else { /* Unknown meta info */ diff --git a/modules/gui/wxwidgets/dialogs/fileinfo.cpp b/modules/gui/wxwidgets/dialogs/fileinfo.cpp index 7109f30046..a591801ef0 100644 --- a/modules/gui/wxwidgets/dialogs/fileinfo.cpp +++ b/modules/gui/wxwidgets/dialogs/fileinfo.cpp @@ -69,10 +69,12 @@ FileInfo::FileInfo( intf_thread_t *_p_intf, wxWindow *p_parent ): #if (!wxCHECK_VERSION(2,5,2)) wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook ); #endif - item_info = new ItemInfoPanel( p_intf, notebook, false ); + item_info = new MetaDataPanel( p_intf, notebook, false ); + advanced_info = new AdvancedInfoPanel( p_intf, notebook ); stats_info = new InputStatsInfoPanel( p_intf, notebook ); notebook->AddPage( item_info, wxU(_("General") ), true ); + notebook->AddPage( advanced_info, wxU(_("Advanced information") ), false ); notebook->AddPage( stats_info, wxU(_("Statistics") ), false ); #if (!wxCHECK_VERSION(2,5,2)) @@ -84,7 +86,6 @@ FileInfo::FileInfo( intf_thread_t *_p_intf, wxWindow *p_parent ): panel_sizer->Layout(); SetSizerAndFit( panel_sizer ); - if( p_playlist ) { var_AddCallback( p_playlist, "item-change", ItemChanged, this ); @@ -112,6 +113,7 @@ void FileInfo::Update() if( !p_input || p_input->b_dead || !p_input->input.p_item->psz_name ) { item_info->Clear(); + advanced_info->Clear(); stats_info->Clear(); vlc_object_release( p_playlist ); return; @@ -121,7 +123,10 @@ void FileInfo::Update() vlc_mutex_lock( &p_input->input.p_item->lock ); if( b_need_update == VLC_TRUE ) { + vlc_mutex_unlock( &p_input->input.p_item->lock ); item_info->Update( p_input->input.p_item ); + vlc_mutex_lock( &p_input->input.p_item->lock ); + advanced_info->Update( p_input->input.p_item ); } stats_info->Update( p_input->input.p_item ); vlc_mutex_unlock( &p_input->input.p_item->lock ); diff --git a/modules/gui/wxwidgets/dialogs/fileinfo.hpp b/modules/gui/wxwidgets/dialogs/fileinfo.hpp index 04268a7898..3884343cc9 100644 --- a/modules/gui/wxwidgets/dialogs/fileinfo.hpp +++ b/modules/gui/wxwidgets/dialogs/fileinfo.hpp @@ -30,7 +30,8 @@ namespace wxvlc { - class ItemInfoPanel; + class MetaDataPanel; + class AdvancedInfoPanel; class InputStatsInfoPanel; class FileInfo: public wxFrame { @@ -52,7 +53,8 @@ namespace wxvlc mtime_t last_update; - ItemInfoPanel *item_info; + MetaDataPanel *item_info; + AdvancedInfoPanel *advanced_info; InputStatsInfoPanel *stats_info; wxBoxSizer *panel_sizer; diff --git a/modules/gui/wxwidgets/dialogs/infopanels.cpp b/modules/gui/wxwidgets/dialogs/infopanels.cpp index d1169bd27c..a5217de177 100644 --- a/modules/gui/wxwidgets/dialogs/infopanels.cpp +++ b/modules/gui/wxwidgets/dialogs/infopanels.cpp @@ -25,17 +25,19 @@ #include #include +#include + #ifndef wxRB_SINGLE # define wxRB_SINGLE 0 #endif /***************************************************************************** - * General info panel + * General info (URI, name, metadata) *****************************************************************************/ -BEGIN_EVENT_TABLE( ItemInfoPanel, wxPanel ) +BEGIN_EVENT_TABLE( MetaDataPanel, wxPanel ) END_EVENT_TABLE() -ItemInfoPanel::ItemInfoPanel( intf_thread_t *_p_intf, +MetaDataPanel::MetaDataPanel( intf_thread_t *_p_intf, wxWindow* _p_parent, bool _b_modifiable ): wxPanel( _p_parent, -1 ) @@ -73,6 +75,118 @@ ItemInfoPanel::ItemInfoPanel( intf_thread_t *_p_intf, name_text = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition, wxSize( 300, -1 ), flags ); sizer->Add( name_text, 1 , wxALL|wxEXPAND , 0 ); + sizer->Layout(); + + /* Metadata */ + wxFlexGridSizer *meta_sizer = new wxFlexGridSizer(2,11,20); + meta_sizer->AddGrowableCol(1); + +#define ADD_META( string, widget ) { \ + meta_sizer->Add( new wxStaticText( this, -1, wxU(_(string) ) ),1, \ + wxTOP|wxRIGHT|wxLEFT|wxEXPAND, 0 ); \ + widget = new wxStaticText( this, -1, wxU( "" ) ); \ + meta_sizer->Add( widget, 1, wxTOP|wxRIGHT|wxLEFT|wxEXPAND, 0 ); } + + ADD_META( VLC_META_ARTIST, artist_text ); + ADD_META( VLC_META_GENRE, genre_text ); + ADD_META( VLC_META_COPYRIGHT, copyright_text ); + ADD_META( VLC_META_COLLECTION, collection_text ); + ADD_META( VLC_META_SEQ_NUM, seqnum_text ); + ADD_META( VLC_META_DESCRIPTION, description_text ); + ADD_META( VLC_META_RATING, rating_text ); + ADD_META( VLC_META_DATE, date_text ); + ADD_META( VLC_META_LANGUAGE, language_text ); + ADD_META( VLC_META_NOW_PLAYING, nowplaying_text ); + ADD_META( VLC_META_PUBLISHER, publisher_text ); + + meta_sizer->Layout(); + + panel_sizer->Add( sizer, 0, wxEXPAND | wxALL, 5 ); + panel_sizer->Add( meta_sizer, 0, wxEXPAND | wxALL, 5 ); + panel_sizer->Layout(); + SetSizerAndFit( panel_sizer ); +} + +MetaDataPanel::~MetaDataPanel() +{ +} + +void MetaDataPanel::Update( input_item_t *p_item ) +{ + /* Rebuild the tree */ + Clear(); + + uri_text->SetValue( wxU( p_item->psz_uri ) ); + name_text->SetValue( wxU( p_item->psz_name ) ); + +#define UPDATE_META( meta, widget ) { \ + char *psz_meta = vlc_input_item_GetInfo( p_item, _(VLC_META_INFO_CAT), \ + _(meta) ); \ + if( psz_meta != NULL ) \ + { \ + widget->SetLabel( wxU( psz_meta ) ); \ + } \ + } + + UPDATE_META( VLC_META_ARTIST, artist_text ); + UPDATE_META( VLC_META_GENRE, genre_text ); + UPDATE_META( VLC_META_COPYRIGHT, copyright_text ); + UPDATE_META( VLC_META_COLLECTION, collection_text ); + UPDATE_META( VLC_META_SEQ_NUM, seqnum_text ); + UPDATE_META( VLC_META_DESCRIPTION, description_text ); + UPDATE_META( VLC_META_RATING, rating_text ); + UPDATE_META( VLC_META_DATE, date_text ); + UPDATE_META( VLC_META_LANGUAGE, language_text ); + UPDATE_META( VLC_META_NOW_PLAYING, nowplaying_text ); + UPDATE_META( VLC_META_PUBLISHER, publisher_text ); + +#undef UPDATE_META +} + +char* MetaDataPanel::GetURI( ) +{ + return strdup( uri_text->GetLineText(0).mb_str() ); +} + +char* MetaDataPanel::GetName( ) +{ + return strdup( name_text->GetLineText(0).mb_str() ); +} + +void MetaDataPanel::Clear() +{ +} + +void MetaDataPanel::OnOk( ) +{ +} + +void MetaDataPanel::OnCancel( ) +{ +} + + +/***************************************************************************** + * General info panel + *****************************************************************************/ +BEGIN_EVENT_TABLE( AdvancedInfoPanel, wxPanel ) +END_EVENT_TABLE() + +AdvancedInfoPanel::AdvancedInfoPanel( intf_thread_t *_p_intf, + wxWindow* _p_parent ): + wxPanel( _p_parent, -1 ) +{ + int flags= wxTE_PROCESS_ENTER; + /* Initializations */ + p_intf = _p_intf; + p_parent = _p_parent; + + SetAutoLayout( TRUE ); + + wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL ); + + wxFlexGridSizer *sizer = new wxFlexGridSizer(2,8,20); + sizer->AddGrowableCol(1); /* Treeview */ info_tree = new wxTreeCtrl( this, -1, wxDefaultPosition, @@ -81,25 +195,20 @@ ItemInfoPanel::ItemInfoPanel( intf_thread_t *_p_intf, wxTR_HIDE_ROOT ); info_root = info_tree->AddRoot( wxU( "" ) ); - sizer->Layout(); - panel_sizer->Add( sizer, 0, wxEXPAND | wxALL, 15 ); panel_sizer->Add( info_tree, 1, wxEXPAND | wxALL, 5 ); panel_sizer->Layout(); SetSizerAndFit( panel_sizer ); } -ItemInfoPanel::~ItemInfoPanel() +AdvancedInfoPanel::~AdvancedInfoPanel() { } -void ItemInfoPanel::Update( input_item_t *p_item ) +void AdvancedInfoPanel::Update( input_item_t *p_item ) { /* Rebuild the tree */ Clear(); - uri_text->SetValue( wxU( p_item->psz_uri ) ); - name_text->SetValue( wxU( p_item->psz_name ) ); - for( int i = 0; i< p_item->i_categories ; i++) { wxTreeItemId cat = info_tree->AppendItem( info_root, @@ -117,26 +226,16 @@ void ItemInfoPanel::Update( input_item_t *p_item ) } } -char* ItemInfoPanel::GetURI( ) -{ - return strdup( uri_text->GetLineText(0).mb_str() ); -} - -char* ItemInfoPanel::GetName( ) -{ - return strdup( name_text->GetLineText(0).mb_str() ); -} - -void ItemInfoPanel::Clear() +void AdvancedInfoPanel::Clear() { info_tree->DeleteChildren( info_root ); } -void ItemInfoPanel::OnOk( ) +void AdvancedInfoPanel::OnOk( ) { } -void ItemInfoPanel::OnCancel( ) +void AdvancedInfoPanel::OnCancel( ) { } diff --git a/modules/gui/wxwidgets/dialogs/infopanels.hpp b/modules/gui/wxwidgets/dialogs/infopanels.hpp index e7888fa9e1..a355b9a1bd 100644 --- a/modules/gui/wxwidgets/dialogs/infopanels.hpp +++ b/modules/gui/wxwidgets/dialogs/infopanels.hpp @@ -30,12 +30,57 @@ namespace wxvlc { -class ItemInfoPanel: public wxPanel +class MetaDataPanel: public wxPanel { public: /* Constructor */ - ItemInfoPanel( intf_thread_t *p_intf, wxWindow *p_parent, bool ); - virtual ~ItemInfoPanel(); + MetaDataPanel( intf_thread_t *p_intf, wxWindow *p_parent, bool ); + virtual ~MetaDataPanel(); + + void Update( input_item_t *); + void Clear(); + + char* GetURI(); + char* GetName(); + + void OnOk(); + void OnCancel(); + +private: + DECLARE_EVENT_TABLE(); + + intf_thread_t *p_intf; + input_item_t *p_item; + wxWindow *p_parent; + + wxTextCtrl *uri_text; + wxTextCtrl *name_text; + wxStaticText *uri_label; + wxStaticText *name_label; + + wxStaticText *artist_text; + wxStaticText *genre_text; + wxStaticText *copyright_text; + wxStaticText *collection_text; + wxStaticText *seqnum_text; + wxStaticText *description_text; + wxStaticText *rating_text; + wxStaticText *date_text; + wxStaticText *setting_text; + wxStaticText *language_text; + wxStaticText *nowplaying_text; + wxStaticText *publisher_text; + + bool b_modifiable; +}; + + +class AdvancedInfoPanel: public wxPanel +{ +public: + /* Constructor */ + AdvancedInfoPanel( intf_thread_t *p_intf, wxWindow *p_parent ); + virtual ~AdvancedInfoPanel(); void Update( input_item_t *); void Clear(); diff --git a/modules/gui/wxwidgets/dialogs/iteminfo.cpp b/modules/gui/wxwidgets/dialogs/iteminfo.cpp index f767f903ce..116c0faec7 100644 --- a/modules/gui/wxwidgets/dialogs/iteminfo.cpp +++ b/modules/gui/wxwidgets/dialogs/iteminfo.cpp @@ -69,7 +69,7 @@ ItemInfoDialog::ItemInfoDialog( intf_thread_t *_p_intf, panel->SetAutoLayout( TRUE ); /* Create the standard info panel */ - info_panel = new ItemInfoPanel(p_intf, panel, true ); + info_panel = new MetaDataPanel(p_intf, panel, true ); info_panel->Update( &(p_item->input) ); /* Separation */ wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK ); diff --git a/modules/gui/wxwidgets/dialogs/iteminfo.hpp b/modules/gui/wxwidgets/dialogs/iteminfo.hpp index 5a096330ee..5a1549f8b4 100644 --- a/modules/gui/wxwidgets/dialogs/iteminfo.hpp +++ b/modules/gui/wxwidgets/dialogs/iteminfo.hpp @@ -57,7 +57,7 @@ private: /* Controls for the iteminfo dialog box */ wxPanel *info_subpanel; - ItemInfoPanel *info_panel; + MetaDataPanel *info_panel; wxPanel *group_subpanel; wxPanel *group_panel; -- 2.39.2