]> git.sesse.net Git - vlc/commitdiff
* wx/vlm: add "Load" & "Save" buttons
authorYoann Peronneau <yoann@videolan.org>
Fri, 25 Nov 2005 23:55:17 +0000 (23:55 +0000)
committerYoann Peronneau <yoann@videolan.org>
Fri, 25 Nov 2005 23:55:17 +0000 (23:55 +0000)
modules/gui/wxwidgets/dialogs/vlm/vlm_panel.cpp
modules/gui/wxwidgets/dialogs/vlm/vlm_panel.hpp

index 1322c05a19c840b43dfb52004093880733c2870f..537eb87ab2d96c835dd5361cd34d054574730c3b 100644 (file)
@@ -30,10 +30,16 @@ 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( Load_Event, VLMPanel::OnLoad )
+   EVT_BUTTON( Save_Event, VLMPanel::OnSave )
 END_EVENT_TABLE()
 
 
@@ -42,6 +48,7 @@ VLMPanel::VLMPanel( intf_thread_t *_p_intf, wxWindow *_p_parent ) :
        timer( this, Timer_Event )
 {
     p_intf = _p_intf;
+    p_parent = _p_parent;
 
     p_vlm = new VLMWrapper( p_intf );
     p_vlm->AttachVLM();
@@ -62,6 +69,13 @@ VLMPanel::VLMPanel( intf_thread_t *_p_intf, wxWindow *_p_parent ) :
     panel_sizer->Add( p_notebook, 1 , wxEXPAND | wxALL, 5 );
 #endif
 
+    wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
+    button_sizer->Add( new wxButton( this, Close_Event, 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") ) ) );
+    panel_sizer->Add( button_sizer, 0 , wxEXPAND | wxALL, 5 );
+
     panel_sizer->Layout();
     SetSizerAndFit( panel_sizer );
 
@@ -186,6 +200,38 @@ void VLMPanel::Update()
     p_vlm->UnlockVLM();
 }
 
+void VLMPanel::OnClose( wxCommandEvent &event )
+{
+    ((VLMFrame*)p_parent)->OnClose( *( new wxCloseEvent() ) );
+}
+
+void VLMPanel::OnLoad( wxCommandEvent &event )
+{
+    p_file_dialog = new wxFileDialog( NULL, wxT(""), wxT(""), wxT(""),
+                                      wxT("*"), wxOPEN | wxMULTIPLE );
+    if( p_file_dialog == NULL ) return;
+
+    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() );
+    }
+    Update();
+}
+
+void VLMPanel::OnSave( wxCommandEvent &event )
+{
+    p_file_dialog = new wxFileDialog( NULL, wxT(""), wxT(""), wxT(""),
+                                      wxT("*"), wxSAVE | wxOVERWRITE_PROMPT );
+    if( p_file_dialog == NULL ) return;
+
+    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() );
+    }
+}
+
 /*************************
  * Broadcasts management
  *************************/
@@ -444,7 +490,6 @@ void VLMAddStreamPanel::OnChooseOutput( wxCommandEvent &event )
  ****************************************************************************/
 enum
 {
-    Close_Event,
 };
 
 BEGIN_EVENT_TABLE( VLMFrame, wxFrame )
index e51ea42088bfc02e7b7b29021de44e9fd9de2999..ab51c4746efb421d2ca47bd00d0de34cb76d8ba7 100644 (file)
@@ -74,7 +74,6 @@ namespace wxvlc
 
         OpenDialog *p_open_dialog;
         SoutDialog *p_sout_dialog;
-        wxFileDialog *p_file_dialog;
 
         DECLARE_EVENT_TABLE();
     };
@@ -95,9 +94,15 @@ namespace wxvlc
     private:
         VLMWrapper *p_vlm;
         intf_thread_t *p_intf;
+        wxWindow *p_parent;
 
+        wxFileDialog *p_file_dialog;
         wxTimer timer;
         void OnTimer( wxTimerEvent &);
+        void OnClose( wxCommandEvent& );
+        void OnLoad( wxCommandEvent& );
+        void OnSave( wxCommandEvent& );
+
         /** Notebook */
         wxNotebook *p_notebook;
         DECLARE_EVENT_TABLE();
@@ -136,10 +141,10 @@ namespace wxvlc
         virtual ~VLMFrame();
 
         void Update();
+        void OnClose( wxCloseEvent& );
     private:
         VLMPanel *vlm_panel;
         DECLARE_EVENT_TABLE();
-        void OnClose( wxCloseEvent& );
     };
 
     /** This class is the edit dialog for a stream