]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/menus.cpp
* modules/gui/wxwindows/*: workaround uninitialization bug in wxWidgets -> re-enabled...
[vlc] / modules / gui / wxwindows / menus.cpp
index 28b50d0ec2b49392422f4c13c18d4da20d89e933..38d070f0ccaaf23ea54c02d06ac33edb83dc4039 100644 (file)
@@ -94,6 +94,11 @@ enum
     MediaInfo_Event,
     Messages_Event,
     Preferences_Event,
+    Play_Event,
+    Pause_Event,
+    Previous_Event,
+    Next_Event,
+    Stop_Event,
     FirstAutoGenerated_Event = wxID_HIGHEST + 1999,
     SettingsMenu_Events = wxID_HIGHEST + 5000,
     AudioMenu_Events = wxID_HIGHEST + 2000,
@@ -141,37 +146,49 @@ wxMenu *MiscMenu( intf_thread_t *p_intf )
 void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
                 const wxPoint& pos )
 {
-#define MAX_POPUP_ITEMS 35
+#define MAX_POPUP_ITEMS 45
 
-    vlc_object_t *p_object;
+    int minimal = config_GetInt( p_intf, "wxwin-minimal" );
+
+    vlc_object_t *p_object, *p_input;
     char *ppsz_varnames[MAX_POPUP_ITEMS];
     int pi_objects[MAX_POPUP_ITEMS];
-    int i = 0;
+    int i = 0, i_last_separator = 0;
 
     /* Initializations */
     memset( pi_objects, 0, MAX_POPUP_ITEMS * sizeof(int) );
 
-    /* Audio menu */
-    ppsz_varnames[i++] = _("Audio menu");
-    ppsz_varnames[i++] = NULL; /* Separator */
-
-    p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
+    /* Input menu */
+    p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
                                                 FIND_ANYWHERE );
     if( p_object != NULL )
     {
-        ppsz_varnames[i] = "audio-device";
+        ppsz_varnames[i] = "bookmark";
         pi_objects[i++] = p_object->i_object_id;
-        ppsz_varnames[i] = "audio-channels";
+        ppsz_varnames[i] = "title";
         pi_objects[i++] = p_object->i_object_id;
-        ppsz_varnames[i] = "visual";
+        ppsz_varnames[i] = "chapter";
+        pi_objects[i++] = p_object->i_object_id;
+        ppsz_varnames[i] = "program";
+        pi_objects[i++] = p_object->i_object_id;
+        ppsz_varnames[i] = "navigation";
+        pi_objects[i++] = p_object->i_object_id;
+        ppsz_varnames[i] = "dvd_menus";
+        pi_objects[i++] = p_object->i_object_id;
+
+        ppsz_varnames[i] = "video-es";
+        pi_objects[i++] = p_object->i_object_id;
+        ppsz_varnames[i] = "audio-es";
+        pi_objects[i++] = p_object->i_object_id;
+        ppsz_varnames[i] = "spu-es";
         pi_objects[i++] = p_object->i_object_id;
-        vlc_object_release( p_object );
     }
+    p_input = p_object;
+    if( !p_input ) goto interfacemenu;
 
     /* Video menu */
-    ppsz_varnames[i++] = NULL; /* Separator */
-    ppsz_varnames[i++] = _("Video menu");
-    ppsz_varnames[i++] = NULL; /* Separator */
+    if( i != i_last_separator ) ppsz_varnames[i++] = NULL; /* Separator */
+    i_last_separator = i;
 
     p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
                                                 FIND_ANYWHERE );
@@ -193,6 +210,8 @@ void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
         pi_objects[i++] = p_object->i_object_id;
         ppsz_varnames[i] = "directx-wallpaper";
         pi_objects[i++] = p_object->i_object_id;
+        ppsz_varnames[i] = "video-snapshot";
+        pi_objects[i++] = p_object->i_object_id;
 
         p_dec_obj = (vlc_object_t *)vlc_object_find( p_object,
                                                      VLC_OBJECT_DECODER,
@@ -207,52 +226,43 @@ void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
         vlc_object_release( p_object );
     }
 
-    /* Input menu */
-    ppsz_varnames[i++] = NULL; /* Separator */
-    ppsz_varnames[i++] = _("Input menu");
-    ppsz_varnames[i++] = NULL; /* Separator */
+    /* Audio menu */
+    if( i != i_last_separator ) ppsz_varnames[i++] = NULL; /* Separator */
+    i_last_separator  = i;
 
-    p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
+    p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
                                                 FIND_ANYWHERE );
     if( p_object != NULL )
     {
-        ppsz_varnames[i] = "bookmark";
-        pi_objects[i++] = p_object->i_object_id;
-        ppsz_varnames[i] = "title";
-        pi_objects[i++] = p_object->i_object_id;
-        ppsz_varnames[i] = "chapter";
-        pi_objects[i++] = p_object->i_object_id;
-        ppsz_varnames[i] = "program";
-        pi_objects[i++] = p_object->i_object_id;
-        ppsz_varnames[i] = "navigation";
-        pi_objects[i++] = p_object->i_object_id;
-        ppsz_varnames[i] = "dvd_menus";
+        ppsz_varnames[i] = "audio-device";
         pi_objects[i++] = p_object->i_object_id;
-
-        ppsz_varnames[i] = "video-es";
+        ppsz_varnames[i] = "audio-channels";
         pi_objects[i++] = p_object->i_object_id;
-        ppsz_varnames[i] = "audio-es";
+        ppsz_varnames[i] = "visual";
         pi_objects[i++] = p_object->i_object_id;
-        ppsz_varnames[i] = "spu-es";
+        ppsz_varnames[i] = "equalizer";
         pi_objects[i++] = p_object->i_object_id;
-
         vlc_object_release( p_object );
     }
 
+ interfacemenu:
     /* Interface menu */
-    ppsz_varnames[i++] = NULL; /* Separator */
-    ppsz_varnames[i++] = _("Interface menu");
-    ppsz_varnames[i++] = NULL; /* Separator */
+    if( i != i_last_separator ) ppsz_varnames[i++] = NULL; /* Separator */
+    i_last_separator = i;
 
     /* vlc_object_find is needed because of the dialogs provider case */
     p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INTF,
                                                 FIND_PARENT );
     if( p_object != NULL )
     {
+#if (wxCHECK_VERSION(2,5,0))
         ppsz_varnames[i] = "intf-switch";
         pi_objects[i++] = p_object->i_object_id;
+#endif
         ppsz_varnames[i] = "intf-add";
         pi_objects[i++] = p_object->i_object_id;
+        ppsz_varnames[i] = "intf-skins";
+        pi_objects[i++] = p_object->i_object_id;
 
         vlc_object_release( p_object );
     }
@@ -262,11 +272,45 @@ void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
     popupmenu.Populate( i, ppsz_varnames, pi_objects );
 
     /* Add static entries */
-    popupmenu.AppendSeparator();
-    popupmenu.Append( MenuDummy_Event, wxU("Open"),
-                      OpenStreamMenu( p_intf ), wxT("") );
-    popupmenu.Append( MenuDummy_Event, wxU("Miscellaneous"),
+    if( p_input != NULL )
+    {
+        vlc_value_t val;
+        popupmenu.InsertSeparator( 0 );
+        if (!minimal)
+        {
+        popupmenu.Insert( 0, Stop_Event, wxU(_("Stop")) );
+        popupmenu.Insert( 0, Previous_Event, wxU(_("Previous")) );
+        popupmenu.Insert( 0, Next_Event, wxU(_("Next")) );
+        }
+
+        var_Get( p_input, "state", &val );
+        if( val.i_int == PAUSE_S )
+            popupmenu.Insert( 0, Play_Event, wxU(_("Play")) );
+        else
+            popupmenu.Insert( 0, Pause_Event, wxU(_("Pause")) );
+
+        vlc_object_release( p_input );
+    }
+    else
+    {
+        playlist_t * p_playlist =
+            (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+                                           FIND_ANYWHERE );
+        if( p_playlist && p_playlist->i_size )
+        {
+            popupmenu.InsertSeparator( 0 );
+            popupmenu.Insert( 0, Play_Event, wxU(_("Play")) );
+        }
+        if( p_playlist ) vlc_object_release( p_playlist );
+    }
+
+    popupmenu.Append( MenuDummy_Event, wxU(_("Miscellaneous")),
                       MiscMenu( p_intf ), wxT("") );
+    if (!minimal)
+    {
+    popupmenu.Append( MenuDummy_Event, wxU(_("Open")),
+                      OpenStreamMenu( p_intf ), wxT("") );
+    }
 
     p_intf->p_sys->p_popup_menu = &popupmenu;
     p_parent->PopupMenu( &popupmenu, pos.x, pos.y );
@@ -304,6 +348,8 @@ wxMenu *AudioMenu( intf_thread_t *_p_intf, wxWindow *p_parent, wxMenu *p_menu )
         pi_objects[i++] = p_object->i_object_id;
         ppsz_varnames[i] = "visual";
         pi_objects[i++] = p_object->i_object_id;
+        ppsz_varnames[i] = "equalizer";
+        pi_objects[i++] = p_object->i_object_id;
         vlc_object_release( p_object );
     }
 
@@ -362,6 +408,8 @@ wxMenu *VideoMenu( intf_thread_t *_p_intf, wxWindow *p_parent, wxMenu *p_menu )
         pi_objects[i++] = p_object->i_object_id;
         ppsz_varnames[i] = "directx-wallpaper";
         pi_objects[i++] = p_object->i_object_id;
+        ppsz_varnames[i] = "video-snapshot";
+        pi_objects[i++] = p_object->i_object_id;
 
         p_dec_obj = (vlc_object_t *)vlc_object_find( p_object,
                                                      VLC_OBJECT_DECODER,
@@ -390,7 +438,7 @@ 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 )
 {
-#define MAX_NAVIG_ITEMS 10
+#define MAX_NAVIG_ITEMS 15
 
     vlc_object_t *p_object;
     char *ppsz_varnames[MAX_NAVIG_ITEMS];
@@ -458,8 +506,10 @@ wxMenu *SettingsMenu( intf_thread_t *_p_intf, wxWindow *p_parent,
                                                 FIND_PARENT );
     if( p_object != NULL )
     {
+#if (wxCHECK_VERSION(2,5,0))
         ppsz_varnames[i] = "intf-switch";
         pi_objects[i++] = p_object->i_object_id;
+#endif
         ppsz_varnames[i] = "intf-add";
         pi_objects[i++] = p_object->i_object_id;
         vlc_object_release( p_object );
@@ -875,6 +925,47 @@ void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event )
     int i_hotkey_event = p_intf->p_sys->i_first_hotkey_event;
     int i_hotkeys = p_intf->p_sys->i_hotkeys;
 
+    if( event.GetId() >= Play_Event && event.GetId() <= Stop_Event )
+    {
+        input_thread_t *p_input;
+        playlist_t * p_playlist =
+            (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+                                           FIND_ANYWHERE );
+        if( !p_playlist ) return;
+
+        switch( event.GetId() )
+        {
+        case Play_Event:
+        case Pause_Event:
+            p_input =
+                (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
+                                                   FIND_ANYWHERE );
+            if( !p_input ) playlist_Play( p_playlist );
+            else
+            {
+                vlc_value_t val;
+                var_Get( p_input, "state", &val );
+                if( val.i_int != PAUSE_S ) val.i_int = PAUSE_S;
+                else val.i_int = PLAYING_S;
+                var_Set( p_input, "state", val );
+                vlc_object_release( p_input );
+            }
+            break;
+        case Stop_Event:
+            playlist_Stop( p_playlist );
+            break;
+        case Previous_Event:
+            playlist_Prev( p_playlist );
+            break;
+        case Next_Event:
+            playlist_Next( p_playlist );
+            break;
+        }
+
+        vlc_object_release( p_playlist );
+        return;
+    }
+
     /* Check if this is an auto generated menu item */
     if( event.GetId() < FirstAutoGenerated_Event )
     {
@@ -893,7 +984,6 @@ void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event )
 
         /* Get the key combination and send it to the hotkey handler */
         var_Set( p_intf->p_vlc, "key-pressed", val );
-       msg_Err( p_intf, "received key event: %i", event.GetId() );
         return;
     }
 
@@ -903,7 +993,7 @@ void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event )
     {
         if( p_intf->p_sys->p_popup_menu )
         {
-            p_menuitem = 
+            p_menuitem =
                 p_intf->p_sys->p_popup_menu->FindItem( event.GetId() );
         }
     }
@@ -919,7 +1009,7 @@ void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event )
 
         wxMutexGuiLeave(); // We don't want deadlocks
         var_Set( p_object, p_menuitemext->psz_var, p_menuitemext->val );
-        wxMutexGuiEnter();
+        //wxMutexGuiEnter();
 
         vlc_object_release( p_object );
     }