]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwidgets/menus.cpp
Removes trailing spaces. Removes tabs.
[vlc] / modules / gui / wxwidgets / menus.cpp
index 28a0a350159993b35078c6fa5c037f8ad6d85339..5c36511f2c084a7d3a126e6eb6340042052e48fc 100644 (file)
  *****************************************************************************/
 
 #include <vlc/vlc.h>
-#include <vlc/intf.h>
+#include <vlc_interface.h>
 
 #include "wxwidgets.hpp"
 #include "interface.hpp"
 
-#include <vector>
-#include <string>
-using namespace std;
+#include <wx/dynarray.h>
+WX_DEFINE_ARRAY(int, ArrayOfInts);
+WX_DEFINE_ARRAY_PTR(const char *, ArrayOfStrings);
+
 
 class wxMenuItemExt: public wxMenuItem
 {
@@ -54,13 +55,13 @@ public:
     Menu( intf_thread_t *p_intf, int i_start_id );
     virtual ~Menu();
 
-    void Populate( vector<string> &, vector<int> &);
+    void Populate( ArrayOfStrings &, ArrayOfInts &);
     void Clear();
 
 private:
     wxMenu *CreateDummyMenu();
     void   CreateMenuItem( wxMenu *, const char *, vlc_object_t * );
-    wxMenu *CreateChoicesMenu( char *, vlc_object_t *, bool );
+    wxMenu *CreateChoicesMenu( const char *, vlc_object_t *, bool );
 
     DECLARE_EVENT_TABLE();
 
@@ -143,11 +144,11 @@ wxMenu *MiscMenu( intf_thread_t *p_intf )
 /*****************************************************************************
  * Builders for the dynamic menus
  *****************************************************************************/
-#define PUSH_VAR( var ) rs_varnames.push_back( var ); \
-                        ri_objects.push_back( p_object->i_object_id );
+#define PUSH_VAR( var ) rs_varnames.Add( var ); \
+                        ri_objects.Add( p_object->i_object_id )
 
-int InputAutoMenuBuilder( vlc_object_t *p_object,
-                          vector<int> &ri_objects, vector<string> &rs_varnames )
+int InputAutoMenuBuilder( vlc_object_t *p_object, ArrayOfInts &ri_objects,
+                          ArrayOfStrings &rs_varnames )
 {
     PUSH_VAR( "bookmark");
     PUSH_VAR( "title" );
@@ -158,8 +159,8 @@ int InputAutoMenuBuilder( vlc_object_t *p_object,
     return VLC_SUCCESS;
 }
 
-int VideoAutoMenuBuilder( vlc_object_t *p_object,
-                          vector<int> &ri_objects, vector<string> &rs_varnames )
+int VideoAutoMenuBuilder( vlc_object_t *p_object, ArrayOfInts &ri_objects,
+                          ArrayOfStrings &rs_varnames )
 {
     PUSH_VAR( "fullscreen" );
     PUSH_VAR( "zoom" );
@@ -175,14 +176,15 @@ int VideoAutoMenuBuilder( vlc_object_t *p_object,
                                                  FIND_PARENT );
     if( p_dec_obj != NULL )
     {
+        vlc_object_t *p_object = p_dec_obj;
         PUSH_VAR( "ffmpeg-pp-q" );
         vlc_object_release( p_dec_obj );
     }
     return VLC_SUCCESS;
 }
 
-int AudioAutoMenuBuilder( vlc_object_t *p_object,
-                          vector<int> &ri_objects, vector<string> &rs_varnames )
+int AudioAutoMenuBuilder( vlc_object_t *p_object, ArrayOfInts &ri_objects,
+                          ArrayOfStrings &rs_varnames )
 {
     PUSH_VAR( "audio-device" );
     PUSH_VAR( "audio-channels" );
@@ -191,9 +193,8 @@ int AudioAutoMenuBuilder( vlc_object_t *p_object,
     return VLC_SUCCESS;
 }
 
-int IntfAutoMenuBuilder( intf_thread_t *p_intf,
-                         vector<int> &ri_objects, vector<string> &rs_varnames,
-                         bool is_popup)
+int IntfAutoMenuBuilder( intf_thread_t *p_intf, ArrayOfInts &ri_objects,
+                         ArrayOfStrings &rs_varnames, bool is_popup)
 {
     /* vlc_object_find is needed because of the dialogs provider case */
     vlc_object_t *p_object;
@@ -208,7 +209,9 @@ int IntfAutoMenuBuilder( intf_thread_t *p_intf,
 #endif
         }
         else
+        {
             PUSH_VAR( "intf-switch" );
+        }
         PUSH_VAR( "intf-add" );
         PUSH_VAR( "intf-skins" );
         vlc_object_release( p_object );
@@ -220,22 +223,23 @@ int IntfAutoMenuBuilder( intf_thread_t *p_intf,
 /*****************************************************************************
  * Popup menus
  *****************************************************************************/
-#define PUSH_VAR( var ) as_varnames.push_back( var ); \
-                        ai_objects.push_back( p_object->i_object_id );
-#define PUSH_SEPARATOR if( ai_objects.size() != i_last_separator ) { \
-                            ai_objects.push_back( 0 ); \
-                            as_varnames.push_back( "" ); \
-                            i_last_separator = ai_objects.size(); }
+#define PUSH_VAR( var ) as_varnames.Add( var ); \
+                        ai_objects.Add( p_object->i_object_id )
+
+#define PUSH_SEPARATOR if( ai_objects.GetCount() != i_last_separator ) { \
+                            ai_objects.Add( 0 ); \
+                            as_varnames.Add( "" ); \
+                            i_last_separator = ai_objects.GetCount(); }
 
 #define POPUP_BOILERPLATE \
     unsigned int i_last_separator = 0; \
-    vector<int> ai_objects; \
-    vector<string> as_varnames; \
+    ArrayOfInts ai_objects; \
+    ArrayOfStrings as_varnames; \
     playlist_t *p_playlist = (playlist_t *) vlc_object_find( p_intf, \
                                           VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );\
     if( !p_playlist ) \
         return; \
-    input_thread_t *p_input = p_playlist->p_input;
+    input_thread_t *p_input = p_playlist->p_input
 
 #define CREATE_POPUP    \
     Menu popupmenu( p_intf, PopupMenu_Events ); \
@@ -243,6 +247,7 @@ int IntfAutoMenuBuilder( intf_thread_t *p_intf,
     p_intf->p_sys->p_popup_menu = &popupmenu; \
     p_parent->PopupMenu( &popupmenu, pos.x, pos.y ); \
     p_intf->p_sys->p_popup_menu = NULL; \
+    i_last_separator = 0 /* stop compiler warning */
 
 #define POPUP_STATIC_ENTRIES \
     if( p_input != NULL ) \
@@ -266,7 +271,7 @@ int IntfAutoMenuBuilder( intf_thread_t *p_intf,
     } \
     else \
     { \
-        if( p_playlist && p_playlist->i_size ) \
+        if( p_playlist && !playlist_IsEmpty( p_playlist ) ) \
         { \
             popupmenu.InsertSeparator( 0 ); \
             popupmenu.Insert( 0, Play_Event, wxU(_("Play")) ); \
@@ -275,7 +280,7 @@ int IntfAutoMenuBuilder( intf_thread_t *p_intf,
     } \
     \
     popupmenu.Append( MenuDummy_Event, wxU(_("Miscellaneous")), \
-                      MiscMenu( p_intf ), wxT("") ); \
+                      MiscMenu( p_intf ), wxT("") )
 
 
 void VideoPopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
@@ -285,10 +290,10 @@ void VideoPopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
     if( p_input )
     {
         vlc_object_yield( p_input );
-        as_varnames.push_back( "video-es" );
-        ai_objects.push_back( p_input->i_object_id );
-        as_varnames.push_back( "spu-es" );
-        ai_objects.push_back( p_input->i_object_id );
+        as_varnames.Add( "video-es" );
+        ai_objects.Add( p_input->i_object_id );
+        as_varnames.Add( "spu-es" );
+        ai_objects.Add( p_input->i_object_id );
         vlc_object_t *p_vout = (vlc_object_t *)vlc_object_find( p_input,
                                                 VLC_OBJECT_VOUT, FIND_CHILD );
         if( p_vout )
@@ -309,8 +314,8 @@ void AudioPopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
     if( p_input )
     {
         vlc_object_yield( p_input );
-        as_varnames.push_back( "audio-es" );
-        ai_objects.push_back( p_input->i_object_id );
+        as_varnames.Add( "audio-es" );
+        ai_objects.Add( p_input->i_object_id );
         vlc_object_t *p_aout = (vlc_object_t *)vlc_object_find( p_input,
                                              VLC_OBJECT_AOUT, FIND_ANYWHERE );
         if( p_aout )
@@ -333,7 +338,7 @@ void MiscPopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
     if( p_input )
     {
         vlc_object_yield( p_input );
-        as_varnames.push_back( "audio-es" );
+        as_varnames.Add( "audio-es" );
         InputAutoMenuBuilder( VLC_OBJECT(p_input), ai_objects, as_varnames );
         PUSH_SEPARATOR;
     }
@@ -364,10 +369,10 @@ void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
 
         /* Video menu */
         PUSH_SEPARATOR;
-        as_varnames.push_back( "video-es" );
-        ai_objects.push_back( p_input->i_object_id );
-        as_varnames.push_back( "spu-es" );
-        ai_objects.push_back( p_input->i_object_id );
+        as_varnames.Add( "video-es" );
+        ai_objects.Add( p_input->i_object_id );
+        as_varnames.Add( "spu-es" );
+        ai_objects.Add( p_input->i_object_id );
         vlc_object_t *p_vout = (vlc_object_t *)vlc_object_find( p_input,
                                                 VLC_OBJECT_VOUT, FIND_CHILD );
         if( p_vout )
@@ -377,8 +382,8 @@ void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
         }
         /* Audio menu */
         PUSH_SEPARATOR
-        as_varnames.push_back( "audio-es" );
-        ai_objects.push_back( p_input->i_object_id );
+        as_varnames.Add( "audio-es" );
+        ai_objects.Add( p_input->i_object_id );
         vlc_object_t *p_aout = (vlc_object_t *)vlc_object_find( p_input,
                                              VLC_OBJECT_AOUT, FIND_ANYWHERE );
         if( p_aout )
@@ -414,8 +419,8 @@ void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
 wxMenu *AudioMenu( intf_thread_t *_p_intf, wxWindow *p_parent, wxMenu *p_menu )
 {
     vlc_object_t *p_object;
-    vector<int> ai_objects;
-    vector<string> as_varnames;
+    ArrayOfInts ai_objects;
+    ArrayOfStrings as_varnames;
 
     p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INPUT,
                                                 FIND_ANYWHERE );
@@ -448,8 +453,8 @@ wxMenu *AudioMenu( intf_thread_t *_p_intf, wxWindow *p_parent, wxMenu *p_menu )
 wxMenu *VideoMenu( intf_thread_t *_p_intf, wxWindow *p_parent, wxMenu *p_menu )
 {
     vlc_object_t *p_object;
-    vector<int> ai_objects;
-    vector<string> as_varnames;
+    ArrayOfInts ai_objects;
+    ArrayOfStrings as_varnames;
 
     p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INPUT,
                                                 FIND_ANYWHERE );
@@ -482,8 +487,8 @@ wxMenu *VideoMenu( intf_thread_t *_p_intf, wxWindow *p_parent, wxMenu *p_menu )
 wxMenu *NavigMenu( intf_thread_t *_p_intf, wxWindow *p_parent, wxMenu *p_menu )
 {
     vlc_object_t *p_object;
-    vector<int> ai_objects;
-    vector<string> as_varnames;
+    ArrayOfInts ai_objects;
+    ArrayOfStrings as_varnames;
 
     p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INPUT,
                                                 FIND_ANYWHERE );
@@ -511,8 +516,8 @@ wxMenu *SettingsMenu( intf_thread_t *_p_intf, wxWindow *p_parent,
                       wxMenu *p_menu )
 {
     vlc_object_t *p_object;
-    vector<int> ai_objects;
-    vector<string> as_varnames;
+    ArrayOfInts ai_objects;
+    ArrayOfStrings as_varnames;
 
     p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INTF,
                                                 FIND_PARENT );
@@ -552,7 +557,8 @@ Menu::~Menu()
 /*****************************************************************************
  * Public methods.
  *****************************************************************************/
-void Menu::Populate( vector<string> & ras_varnames, vector<int> & rai_objects )
+void Menu::Populate( ArrayOfStrings & ras_varnames,
+                     ArrayOfInts & rai_objects )
 {
     vlc_object_t *p_object;
     vlc_bool_t b_section_empty = VLC_FALSE;
@@ -560,9 +566,9 @@ void Menu::Populate( vector<string> & ras_varnames, vector<int> & rai_objects )
 
     i_item_id = i_start_id;
 
-    for( i = 0; i < rai_objects.size() ; i++ )
+    for( i = 0; i < (int)rai_objects.GetCount() ; i++ )
     {
-        if( ras_varnames[i] == ""  )
+        if( !ras_varnames[i] || !*ras_varnames[i] )
         {
             if( b_section_empty )
             {
@@ -576,7 +582,7 @@ void Menu::Populate( vector<string> & ras_varnames, vector<int> & rai_objects )
 
         if( rai_objects[i] == 0  )
         {
-            Append( MenuDummy_Event, wxU(ras_varnames[i].c_str()) );
+            Append( MenuDummy_Event, wxU(ras_varnames[i]) );
             b_section_empty = VLC_FALSE;
             continue;
         }
@@ -586,7 +592,7 @@ void Menu::Populate( vector<string> & ras_varnames, vector<int> & rai_objects )
         if( p_object == NULL ) continue;
 
         b_section_empty = VLC_FALSE;
-        CreateMenuItem( this, ras_varnames[i].c_str(), p_object );
+        CreateMenuItem( this, ras_varnames[i], p_object );
         vlc_object_release( p_object );
     }
 
@@ -625,7 +631,7 @@ void Menu::Clear( )
 /*****************************************************************************
  * Private methods.
  *****************************************************************************/
-static bool IsMenuEmpty( char *psz_var, vlc_object_t *p_object,
+static bool IsMenuEmpty( const char *psz_var, vlc_object_t *p_object,
                          bool b_root = TRUE )
 {
     vlc_value_t val, val_list;
@@ -642,7 +648,7 @@ static bool IsMenuEmpty( char *psz_var, vlc_object_t *p_object,
 
     if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE )
     {
-        /* Very evil hack ! intf-switch can have only one value */ 
+        /* Very evil hack ! intf-switch can have only one value */
         if( !strcmp( psz_var, "intf-switch" ) ) return FALSE;
         if( val.i_int == 1 && b_root ) return TRUE;
         else return FALSE;
@@ -740,7 +746,7 @@ void Menu::CreateMenuItem( wxMenu *menu, const char *psz_var,
     if( text.psz_string ) free( text.psz_string );
 }
 
-wxMenu *Menu::CreateChoicesMenu( char *psz_var, vlc_object_t *p_object,
+wxMenu *Menu::CreateChoicesMenu( const char *psz_var, vlc_object_t *p_object,
                                  bool b_root )
 {
     vlc_value_t val, val_list, text_list;
@@ -993,10 +999,10 @@ void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event )
         vlc_value_t val;
 
         val.i_int =
-            p_intf->p_vlc->p_hotkeys[event.GetId() - i_hotkey_event].i_key;
+            p_intf->p_libvlc->p_hotkeys[event.GetId() - i_hotkey_event].i_key;
 
         /* Get the key combination and send it to the hotkey handler */
-        var_Set( p_intf->p_vlc, "key-pressed", val );
+        var_Set( p_intf->p_libvlc, "key-pressed", val );
         return;
     }