]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/iteminfo.cpp
Revert wrongly commited files in previous commit
[vlc] / modules / gui / wxwindows / iteminfo.cpp
index f870abda896df0c7a814feed875fad6a3fd584d5..b77371b5a92dfb7d03fda7b7de88b4eab1ce0704 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * iteminfo.cpp : wxWindows plugin for vlc
  *****************************************************************************
- * Copyright (C) 2000-2001 VideoLAN
- * $Id: iteminfo.cpp,v 1.3 2003/10/29 17:32:54 zorglub Exp $
+ * Copyright (C) 2000-2004 VideoLAN
+ * $Id$
  *
  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
  *
 
 #include <vlc/vlc.h>
 
-#ifdef WIN32                                                 /* mingw32 hack */
-#undef Yield
-#undef CreateDialog
-#endif
-
-/* Let vlc take care of the i18n stuff */
-#define WXINTL_NO_GETTEXT_MACRO
-
-#include <wx/wxprec.h>
-#include <wx/wx.h>
-#include <wx/notebook.h>
-#include <wx/textctrl.h>
 #include <wx/combobox.h>
-#include <wx/spinctrl.h>
 #include <wx/statline.h>
 
 #include <vlc/intf.h>
@@ -64,17 +51,13 @@ enum
 {
     Uri_Event,
     Name_Event,
-    Author_Event,
     Enabled_Event,
-    New_Event,
 };
 
 BEGIN_EVENT_TABLE(ItemInfoDialog, wxDialog)
     /* Button events */
     EVT_BUTTON(wxID_OK, ItemInfoDialog::OnOk)
     EVT_BUTTON(wxID_CANCEL, ItemInfoDialog::OnCancel)
-    /* Events generated by the panels */
-    EVT_BUTTON( New_Event, ItemInfoDialog::OnNewGroup)
 
 END_EVENT_TABLE()
 
@@ -84,7 +67,7 @@ END_EVENT_TABLE()
 ItemInfoDialog::ItemInfoDialog( intf_thread_t *_p_intf,
                                 playlist_item_t *_p_item,
                                 wxWindow* _p_parent ):
-    wxDialog( _p_parent, -1, wxU(_("Playlist Item options")),
+    wxDialog( _p_parent, -1, wxU(_("Playlist item info")),
              wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE )
 {
     /* Initializations */
@@ -100,9 +83,6 @@ ItemInfoDialog::ItemInfoDialog( intf_thread_t *_p_intf,
     /* Create the standard info panel */
     wxPanel *info_panel = InfoPanel( panel );
 
-    /* Create the group panel */
-    wxPanel *group_panel = GroupPanel( panel );
-
     /* Separation */
     wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
 
@@ -120,7 +100,6 @@ ItemInfoDialog::ItemInfoDialog( intf_thread_t *_p_intf,
     wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
     wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
     panel_sizer->Add( info_panel, 0, wxEXPAND | wxALL, 5 );
-    panel_sizer->Add( group_panel, 0, wxEXPAND | wxALL, 5 );
     panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
     panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALIGN_BOTTOM |
                       wxALL, 5 );
@@ -140,140 +119,84 @@ ItemInfoDialog::~ItemInfoDialog()
  *****************************************************************************/
 wxPanel *ItemInfoDialog::InfoPanel( wxWindow* parent )
 {
-    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
+    wxPanel *info_panel = new wxPanel( parent, -1, wxDefaultPosition,
                                   wxDefaultSize );
+    info_panel->SetAutoLayout( TRUE );
+    wxBoxSizer *info_sizer = new wxBoxSizer( wxHORIZONTAL );
 
-    wxStaticBox *panel_box = new wxStaticBox( panel, -1,
-                                   wxU(_("Item informations")) );
-    wxStaticBoxSizer *panel_sizer = new wxStaticBoxSizer( panel_box,
-                                                          wxVERTICAL );
-
-    info_subpanel = new wxPanel( panel, -1 );
+    /* Create a box to surround the controls */
+    wxStaticBox *panel_box = new wxStaticBox( info_panel, -1,
+                                   wxU(_("Item Info")) );
 
-    wxFlexGridSizer *subpanel_sizer =
-                    new wxFlexGridSizer( 3, 1 , 0 , 0 );
+    wxStaticBoxSizer *box_sizer = new wxStaticBoxSizer( panel_box,
+                                                          wxVERTICAL );
 
+    wxFlexGridSizer *sizer = new wxFlexGridSizer(2,3,20);
     /* URI Textbox */
     wxStaticText *uri_label =
-           new wxStaticText(info_subpanel, -1, wxU(_("URI")) );
-
-    uri_text =  new wxTextCtrl( info_subpanel, Uri_Event,
-                                wxU(p_item->psz_uri),
-                                wxDefaultPosition, wxSize( 300, -1 ),
-                                wxTE_PROCESS_ENTER);
+           new wxStaticText( info_panel, -1, wxU(_("URI")) );
 
-    subpanel_sizer->Add( uri_label, 0, wxALIGN_LEFT |
-                         wxALIGN_CENTER_VERTICAL );
-    subpanel_sizer->Add( uri_text, 0, wxALIGN_RIGHT |
-                         wxALIGN_CENTER_VERTICAL );
+    uri_text = new wxTextCtrl( info_panel, Uri_Event,
+        wxU(p_item->input.psz_uri), wxDefaultPosition, wxSize( 300, -1 ),
+        wxTE_PROCESS_ENTER );
 
+    sizer->Add( uri_label, 0 , wxALIGN_LEFT |wxALL , 5 );
+    sizer->Add( uri_text, 1 , wxALIGN_RIGHT | wxALL , 5 );
 
     /* Name Textbox */
     wxStaticText *name_label =
-           new wxStaticText(info_subpanel, -1, wxU(_("Name")) );
-
-    name_text =
-                   new wxTextCtrl( info_subpanel, Uri_Event,
-                                   wxU(p_item->psz_name),
-                                   wxDefaultPosition, wxSize( 300, -1 ),
-                                   wxTE_PROCESS_ENTER);
+           new wxStaticText(  info_panel, -1, wxU(_("Name")) );
 
-    subpanel_sizer->Add( name_label, 0, wxALIGN_LEFT |
-                         wxALIGN_CENTER_VERTICAL );
-    subpanel_sizer->Add( name_text, 0, wxALIGN_RIGHT |
-                         wxALIGN_CENTER_VERTICAL );
+    name_text = new wxTextCtrl( info_panel, Uri_Event,
+        wxU(p_item->input.psz_name), wxDefaultPosition, wxSize( 300, -1 ),
+        wxTE_PROCESS_ENTER );
 
-    /* Author Textbox */
-    wxStaticText *author_label =
-           new wxStaticText(info_subpanel, -1, wxU(_("Author")) );
+    sizer->Add( name_label, 0 , wxALIGN_LEFT |wxALL , 5  );
+    sizer->Add( name_text, 1 , wxALIGN_RIGHT | wxALL , 5 );
 
-    author_text =
-                   new wxTextCtrl( info_subpanel, Uri_Event,
-                                   wxU(p_item->psz_author),
-                                   wxDefaultPosition, wxSize( 300, -1 ),
-                                   wxTE_PROCESS_ENTER);
+    /* Treeview */
+    info_tree = new wxTreeCtrl( info_panel, -1, wxDefaultPosition,
+                                wxSize(220,200),
+                                wxSUNKEN_BORDER |wxTR_HAS_BUTTONS |
+                                wxTR_HIDE_ROOT );
 
-    subpanel_sizer->Add( author_label, 0, wxALIGN_LEFT |
-                         wxALIGN_CENTER_VERTICAL );
-    subpanel_sizer->Add( author_text, 0, wxALIGN_RIGHT |
-                         wxALIGN_CENTER_VERTICAL );
+    sizer->Layout();
+    box_sizer->Add( sizer, 0, wxEXPAND, 5 );
+    box_sizer->Add( info_tree, 0, wxEXPAND, 5 );
+    info_sizer->Add( box_sizer, 1, wxBOTTOM, 5 );
 
-    info_subpanel->SetSizerAndFit( subpanel_sizer );
+    info_panel->SetSizer( info_sizer );
+    info_sizer->Layout();
+    info_sizer->SetSizeHints( info_panel );
 
-    /* Stuff everything into the main panel */
-    panel_sizer->Add( info_subpanel, 1,
-                      wxEXPAND | wxALIGN_LEFT |
-                      wxALIGN_CENTER_VERTICAL | wxALL, 5 );
-
-    panel->SetSizerAndFit( panel_sizer );
+    UpdateInfo();
 
-    return panel;
+    return info_panel;
 }
 
-wxPanel *ItemInfoDialog::GroupPanel( wxWindow* parent )
+void ItemInfoDialog::UpdateInfo()
 {
-    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
-                                  wxDefaultSize );
-    wxStaticBox *panel_box = new wxStaticBox( panel, -1,
-                                   wxU(_("Group Info")) );
-    wxStaticBoxSizer *panel_sizer = new wxStaticBoxSizer( panel_box,
-                                                         wxVERTICAL);
-    wxBoxSizer *subpanel_sizer;
-    group_subpanel = new wxPanel( panel, -1 );
-    subpanel_sizer = new wxBoxSizer( wxVERTICAL) ;
-    enabled_checkbox = new wxCheckBox( group_subpanel,
-                                     -1, wxU(_("Item enabled")) );
-
-    enabled_checkbox->SetValue( p_item->b_enabled);
-
-    wxStaticText *group_label = new wxStaticText( group_subpanel,
-                                        -1, wxU(_("Group")) );
-
-    playlist_t *p_playlist =
-                (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
-                                       FIND_ANYWHERE );
-    if( p_playlist == NULL )
+    if( !info_root )
     {
-        return NULL;
+       info_root = info_tree->AddRoot( wxU( p_item->input.psz_name) );
     }
 
-    group_combo = new wxComboBox( group_subpanel, -1,
-                                 wxT(""),wxDefaultPosition, wxDefaultSize,
-                                 0, NULL,
-                                 wxCB_READONLY );
-
-    wxButton *newgroup_button = new wxButton( group_subpanel, New_Event,
-                                    wxT(_("New Group")));
-
-    for( int i=0; i< p_playlist->i_groups ; i++)
+    /* Rebuild the tree */
+    for( int i = 0; i< p_item->input.i_categories ; i++)
     {
-        group_combo->Append( wxT( p_playlist->pp_groups[i]->psz_name));
-    }
-
-    vlc_object_release ( p_playlist );
-
-    subpanel_sizer->Add( enabled_checkbox, 0, wxALIGN_RIGHT|
-                         wxALIGN_CENTER_VERTICAL );
-    subpanel_sizer->Add( group_label, 0, wxALIGN_LEFT |
-                         wxALIGN_CENTER_VERTICAL );
-
-    wxBoxSizer *group_sizer = new wxBoxSizer( wxHORIZONTAL);
-    group_sizer->Add(group_combo, 0, wxALIGN_LEFT|wxRIGHT, 5);
-    group_sizer->Add( newgroup_button, 0, wxALIGN_RIGHT|wxLEFT, 5);
-    group_sizer->Layout();
-
-    subpanel_sizer->Add( group_sizer, 0, wxALIGN_RIGHT );
-
-    group_subpanel->SetSizerAndFit( subpanel_sizer );
-
-    /* Stuff everything into the main panel */
-    panel_sizer->Add( group_subpanel, 0,
-                      wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5 );
+        wxTreeItemId cat = info_tree->AppendItem( info_root,
+                            wxU( p_item->input.pp_categories[i]->psz_name) );
 
-    panel->SetSizerAndFit( panel_sizer );
+        for( int j = 0 ; j < p_item->input.pp_categories[i]->i_infos ; j++ )
+        {
+           info_tree->AppendItem( cat , (wxString)
+               wxU(p_item->input.pp_categories[i]->pp_infos[j]->psz_name) +
+               wxT(": ") +
+               wxU(p_item->input.pp_categories[i]->pp_infos[j]->psz_value) );
+        }
 
-    /* Update panel */
-    return panel;
+        info_tree->Expand( cat );
+    }
 }
 
 /*****************************************************************************
@@ -281,35 +204,10 @@ wxPanel *ItemInfoDialog::GroupPanel( wxWindow* parent )
  *****************************************************************************/
 void ItemInfoDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
 {
-    p_item->psz_name = strdup( name_text->GetLineText(0).mb_str() );
-    p_item->psz_uri = strdup( uri_text->GetLineText(0).mb_str() );
-    p_item->psz_author = strdup( author_text->GetLineText(0).mb_str() );
-    vlc_bool_t b_old_enabled = p_item->b_enabled;
-
-    playlist_t * p_playlist =
-          (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
-                                       FIND_ANYWHERE );
-    if( p_playlist != NULL )
-    {
-        if( b_old_enabled == VLC_FALSE && enabled_checkbox->IsChecked() )
-            p_playlist->i_enabled ++;
-        else if( b_old_enabled == VLC_TRUE && !enabled_checkbox->IsChecked() )
-            p_playlist->i_enabled --;
-
-        for (int i=0 ; i< p_playlist->i_groups ; i++)
-        {
-           if( !strcasecmp( p_playlist->pp_groups[i]->psz_name,
-                           group_combo->GetValue() ))
-           {
-               p_item->i_group = p_playlist->pp_groups[i]->i_id;
-               break;
-           }
-        }
-
-        vlc_object_release( p_playlist );
-    }
-
-    p_item->b_enabled = enabled_checkbox->IsChecked() ? VLC_TRUE : VLC_FALSE ;
+    vlc_mutex_lock( &p_item->input.lock );
+    p_item->input.psz_name = strdup( name_text->GetLineText(0).mb_str() );
+    p_item->input.psz_uri = strdup( uri_text->GetLineText(0).mb_str() );
+    vlc_mutex_unlock( &p_item->input.lock );
     EndModal( wxID_OK );
 }
 
@@ -317,19 +215,3 @@ void ItemInfoDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
 {
     EndModal( wxID_CANCEL );
 }
-
-void ItemInfoDialog::OnNewGroup( wxCommandEvent& WXUNUSED(event) )
-{
-    NewGroup *p_newgroup = NULL;
-
-    p_newgroup = new NewGroup( p_intf, this );
-
-    if( p_newgroup)
-    {
-        if( p_newgroup->ShowModal() == wxID_OK && p_newgroup->psz_name)
-        {
-            group_combo->Append( wxT( p_newgroup->psz_name));
-        }
-        delete( p_newgroup );
-    }
-}