]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwidgets/dialogs/vlm/vlm_panel.cpp
Completely replace all ANSI CP dependend mb_str()
[vlc] / modules / gui / wxwidgets / dialogs / vlm / vlm_panel.cpp
index a8a0c99523f2cb879884463e0c808a49f8e58ef1..e67304e22b2d38d4ad25c52b5c1adcf80dbe386e 100644 (file)
@@ -2,9 +2,9 @@
  * vlm_panel.cpp: VLM Panel
  *****************************************************************************
  * Copyright (C) 2000-2005 the VideoLAN team
- * $Id: playlist.cpp 12582 2005-09-17 14:15:32Z zorglub $
+ * $Id$
  *
- * Authors: Clément Stenac <zorglub@videolan.org>
+ * Authors: Clément Stenac <zorglub@videolan.org>
  *
  * 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
@@ -18,7 +18,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #include "dialogs/vlm/vlm_panel.hpp"
 #include "dialogs/vlm/vlm_streampanel.hpp"
 #include <wx/statline.h>
 
+#include "charset.h"
+
 enum
 {
     Notebook_Event,
     Timer_Event,
-    Close_Event,
     Load_Event,
-    Save_Event,
 };
 
 BEGIN_EVENT_TABLE( VLMPanel, wxPanel)
    EVT_TIMER( Timer_Event, VLMPanel::OnTimer )
-   EVT_BUTTON( Close_Event, VLMPanel::OnClose )
+   EVT_BUTTON( wxID_CLOSE, VLMPanel::OnClose )
    EVT_BUTTON( Load_Event, VLMPanel::OnLoad )
-   EVT_BUTTON( Save_Event, VLMPanel::OnSave )
+   EVT_BUTTON( wxID_SAVE, VLMPanel::OnSave )
 END_EVENT_TABLE()
 
 
@@ -63,7 +63,9 @@ VLMPanel::VLMPanel( intf_thread_t *_p_intf, wxWindow *_p_parent ) :
     wxNotebookSizer *notebook_sizer = new wxNotebookSizer( p_notebook );
 #endif
     p_notebook->AddPage( BroadcastPanel( p_notebook ), wxU( _("Broadcasts") ) );
+#if 0
     p_notebook->AddPage( VODPanel( p_notebook ), wxU( _("VOD") ) );
+#endif
 #if (!wxCHECK_VERSION(2,5,0))
     panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
 #else
@@ -71,10 +73,10 @@ VLMPanel::VLMPanel( intf_thread_t *_p_intf, wxWindow *_p_parent ) :
 #endif
 
     wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
-    button_sizer->Add( new wxButton( this, Close_Event, wxU(_("Close") ) ) );
+    button_sizer->Add( new wxButton( this, wxID_CLOSE, wxU(_("&Close") ) ) );
     button_sizer->Add( 0, 0, 1 );
     button_sizer->Add( new wxButton( this, Load_Event, wxU(_("Load") ) ), 0, wxRIGHT, 10 );
-    button_sizer->Add( new wxButton( this, Save_Event, wxU(_("Save") ) ) );
+    button_sizer->Add( new wxButton( this, wxID_SAVE, wxU(_("&Save") ) ) );
     panel_sizer->Add( button_sizer, 0 , wxEXPAND | wxALL, 5 );
 
     panel_sizer->Layout();
@@ -212,10 +214,10 @@ void VLMPanel::OnLoad( wxCommandEvent &event )
                                       wxT("*"), wxOPEN | wxMULTIPLE );
     if( p_file_dialog == NULL ) return;
 
-    p_file_dialog->SetTitle( wxU(_("Load configuration") ) );
+    p_file_dialog->SetTitle( wxU(_("Load Configuration") ) );
     if( p_file_dialog->ShowModal() == wxID_OK )
     {
-        vlm_Load( p_vlm->GetVLM(), p_file_dialog->GetPath().mb_str() );
+        vlm_Load( p_vlm->GetVLM(), p_file_dialog->GetPath().mb_str(wxConvUTF8) );
     }
     Update();
 }
@@ -226,10 +228,10 @@ void VLMPanel::OnSave( wxCommandEvent &event )
                                       wxT("*"), wxSAVE | wxOVERWRITE_PROMPT );
     if( p_file_dialog == NULL ) return;
 
-    p_file_dialog->SetTitle( wxU(_("Save configuration") ) );
+    p_file_dialog->SetTitle( wxU(_("Save Configuration") ) );
     if( p_file_dialog->ShowModal() == wxID_OK )
     {
-        vlm_Save( p_vlm->GetVLM(), p_file_dialog->GetPath().mb_str() );
+        vlm_Save( p_vlm->GetVLM(), p_file_dialog->GetPath().mb_str(wxConvUTF8) );
     }
 }
 
@@ -249,7 +251,7 @@ wxPanel * VLMPanel::BroadcastPanel( wxWindow *parent )
 
      broadcasts_sizer->Add( box_sizer, 0, wxEXPAND|wxALL, 5 );
 
-     wxStaticLine *static_line = new wxStaticLine( broadcasts_panel );
+     wxStaticLine *static_line = new wxStaticLine( broadcasts_panel, wxID_ANY );
      broadcasts_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
 
      scrolled_broadcasts = new wxScrolledWindow( broadcasts_panel, -1,
@@ -351,10 +353,14 @@ VLMAddStreamPanel::VLMAddStreamPanel( intf_thread_t *_p_intf,
                 wxPanel( _p_parent, -1, wxDefaultPosition, wxDefaultSize )
 {
     p_intf = _p_intf;
+    p_parent = _p_parent;
     p_vlm = _p_vlm;
     b_edit = _b_edit;
     b_broadcast = _b_broadcast;
 
+    p_open_dialog = NULL;
+    p_sout_dialog = NULL;
+
     SetAutoLayout( TRUE );
 
     wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
@@ -365,13 +371,13 @@ VLMAddStreamPanel::VLMAddStreamPanel( intf_thread_t *_p_intf,
 
     upper_sizer->Add( new wxStaticText( this, -1, wxU( _("Name") ) ), 0,
                                         wxALIGN_CENTER_VERTICAL, 0 );
-    name_text = new wxTextCtrl( this, -1, wxU( _("") ), wxDefaultPosition,
+    name_text = new wxTextCtrl( this, -1, wxU( "" ), wxDefaultPosition,
                                           wxSize( 150, -1 ) );
     upper_sizer->Add( name_text , 1, wxEXPAND | wxLEFT | wxRIGHT, 5 );
 
     upper_sizer->Add( new wxStaticText( this, -1, wxU( _("Input") ) ), 0,
                                         wxALIGN_CENTER_VERTICAL, 0 );
-    input_text = new wxTextCtrl( this, -1, wxU( _("") ) ,
+    input_text = new wxTextCtrl( this, -1, wxU( "" ) ,
                       wxDefaultPosition, wxSize( 150, -1 ) );
     upper_sizer->Add( input_text , 1, wxEXPAND | wxLEFT | wxRIGHT, 5 );
     upper_sizer->Add( new wxButton( this, ChooseInput_Event, wxU( _("Choose") )  ) );
@@ -381,7 +387,7 @@ VLMAddStreamPanel::VLMAddStreamPanel( intf_thread_t *_p_intf,
 
     upper_sizer->Add( new wxStaticText( this, -1, wxU( _("Output") ) ), 0,
                                         wxALIGN_CENTER_VERTICAL, 0 );
-    output_text = new wxTextCtrl( this, -1, wxU( _("") ) ,
+    output_text = new wxTextCtrl( this, -1, wxU( "" ) ,
                       wxDefaultPosition, wxSize( 150, -1 ) );
     upper_sizer->Add( output_text, 1, wxEXPAND | wxLEFT | wxRIGHT, 5 );
     upper_sizer->Add( new wxButton( this, ChooseOutput_Event,
@@ -390,12 +396,6 @@ VLMAddStreamPanel::VLMAddStreamPanel( intf_thread_t *_p_intf,
     panel_sizer->Add( upper_sizer, 0, wxEXPAND | wxALL, 5 );
 
     wxBoxSizer *lower_sizer = new wxBoxSizer( wxHORIZONTAL );
-    lower_sizer->Add( new wxButton( this, Create_Event,
-                          wxU( _( b_edit ? "Edit" : "Create" ) ) ),
-                      0 , wxEXPAND | wxALL , 5 );
-    lower_sizer->Add( new wxButton( this, Clear_Event, wxU( _( "Clear" )  ) ),
-                      0 , wxEXPAND | wxALL , 5 );
-
     enabled_checkbox = new wxCheckBox( this, -1, wxU( _("Enabled" ) ) );
     enabled_checkbox->SetValue( true );
     lower_sizer->Add( enabled_checkbox,  1 , wxEXPAND | wxALL , 5 );
@@ -405,6 +405,17 @@ VLMAddStreamPanel::VLMAddStreamPanel( intf_thread_t *_p_intf,
         lower_sizer->Add( loop_checkbox,  1 , wxEXPAND | wxALL , 5 );
     }
 
+    if( !b_edit )
+    {
+        lower_sizer->Add( new wxButton( this, wxID_CLEAR,
+                          wxU( _( "&Clear" )  ) ),
+                         0 , wxEXPAND | wxALL , 5 );
+    }
+    lower_sizer->Add( new wxButton( this, Create_Event,
+                          wxU( _( b_edit ? "OK" : "Create" ) ) ),
+                      0 , wxEXPAND | wxALL , 5 );
+
+
     panel_sizer->Add( lower_sizer, 0 , wxEXPAND| wxALL, 5 );
     panel_sizer->Layout();
     SetSizerAndFit( panel_sizer );
@@ -430,9 +441,9 @@ void VLMAddStreamPanel::Load( VLMStream *p_stream )
 
 void VLMAddStreamPanel::OnCreate( wxCommandEvent &event )
 {
-    char *psz_name = FromLocale( name_text->GetValue().mb_str() );
-    char *psz_input = FromLocale(  input_text->GetValue().mb_str() );
-    char *psz_output = FromLocale( output_text->GetValue().mb_str() );
+    char *psz_name = wxFromLocale( name_text->GetValue() );
+    char *psz_input = wxFromLocale(  input_text->GetValue() );
+    char *psz_output = wxFromLocale( output_text->GetValue() );
     if( b_broadcast && ! b_edit )
     {
         p_vlm->AddBroadcast( psz_name, psz_input, psz_output,
@@ -457,10 +468,12 @@ void VLMAddStreamPanel::OnCreate( wxCommandEvent &event )
                         enabled_checkbox->IsChecked() ? VLC_TRUE: VLC_FALSE,
                         loop_checkbox->IsChecked() ? VLC_TRUE : VLC_FALSE );
     }
-    LocaleFree( psz_name) ; LocaleFree( psz_input ) ;
-    LocaleFree( psz_output);
+    wxLocaleFree( psz_name) ; wxLocaleFree( psz_input ) ;
+    wxLocaleFree( psz_output);
     if( !b_edit )
         OnClear( event );
+    if( b_edit )
+        p_parent->Hide();
 }
 
 void VLMAddStreamPanel::OnClear( wxCommandEvent &event )
@@ -488,7 +501,9 @@ void VLMAddStreamPanel::OnChooseOutput( wxCommandEvent &event )
 
     if( p_sout_dialog && p_sout_dialog->ShowModal() == wxID_OK )
     {
-        output_text->SetValue( (p_sout_dialog->GetOptions())[0] );
+        wxString sout = (p_sout_dialog->GetOptions())[0] ;
+        sout = sout.AfterFirst( '=' );
+        output_text->SetValue( sout );
     }
 }
 
@@ -504,7 +519,7 @@ BEGIN_EVENT_TABLE( VLMFrame, wxFrame )
 END_EVENT_TABLE()
 
 VLMFrame::VLMFrame( intf_thread_t *_p_intf, wxWindow *_p_parent ) :
-        wxFrame( _p_parent, -1, wxU( _("VLM configuration") ),
+        wxFrame( _p_parent, -1, wxU( _("VLM") ),
         wxDefaultPosition, wxSize( 640,480 ), wxDEFAULT_FRAME_STYLE )
 {
     SetIcon( *_p_intf->p_sys->p_icon );
@@ -512,7 +527,11 @@ VLMFrame::VLMFrame( intf_thread_t *_p_intf, wxWindow *_p_parent ) :
     wxBoxSizer *main_sizer = new wxBoxSizer( wxHORIZONTAL );
     vlm_panel = new VLMPanel( _p_intf, this );
 
+#if defined(WIN32)
+    main_sizer->Add( vlm_panel, 1, wxGROW, 0 );
+#else
     main_sizer->Add( vlm_panel, 1, wxEXPAND | wxALL, 5 );
+#endif
     main_sizer->Layout();
     SetSizerAndFit( main_sizer );
 }