]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/timer.cpp
* modules/gui/wxwindows: do not use INSERT_ELEM in c++ code.
[vlc] / modules / gui / wxwindows / timer.cpp
index 3d88da14a7f11f23a9b8fa1377583cf1458fed36..773c5d08c2880e2c040fe8b600ad60b399a9a612 100644 (file)
 
 //void DisplayStreamDate( wxControl *, intf_thread_t *, int );
 
-/* Callback prototype */
+/* Callback prototypes */
 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
                         vlc_value_t old_val, vlc_value_t new_val, void *param );
+static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
+                       vlc_value_t old_val, vlc_value_t new_val, void *param );
 
 /*****************************************************************************
  * Constructor.
@@ -49,6 +51,7 @@ Timer::Timer( intf_thread_t *_p_intf, Interface *_p_main_interface )
 {
     p_intf = _p_intf;
     p_main_interface = _p_main_interface;
+    b_init = 0;
     i_old_playing_status = PAUSE_S;
     i_old_rate = INPUT_RATE_DEFAULT;
 
@@ -59,6 +62,7 @@ Timer::Timer( intf_thread_t *_p_intf, Interface *_p_main_interface )
     if( p_playlist != NULL )
     {
         var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
+        var_AddCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
         vlc_object_release( p_playlist );
     }
 
@@ -74,6 +78,7 @@ Timer::~Timer()
     if( p_playlist != NULL )
     {
         var_DelCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
+        var_DelCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
         vlc_object_release( p_playlist );
     }
 }
@@ -90,20 +95,35 @@ Timer::~Timer()
  *****************************************************************************/
 void Timer::Notify()
 {
+    input_thread_t *p_input = NULL;
+#if defined( __WXMSW__ ) /* Work-around a bug with accelerators */
+    if( !b_init )
+    {
+        p_main_interface->Init();
+        b_init = VLC_TRUE;
+    }
+#endif
+
     vlc_mutex_lock( &p_intf->change_lock );
 
     /* Update the input */
     if( p_intf->p_sys->p_input == NULL )
     {
-        p_intf->p_sys->p_input =
-            (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
-                                               FIND_ANYWHERE );
+        playlist_t *p_playlist =
+            (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+                                           FIND_ANYWHERE );
+        if( p_playlist != NULL )
+        {
+            p_intf->p_sys->p_input = p_playlist->p_input;
+            vlc_object_release( p_playlist );
+        }
 
         /* Refresh interface */
         if( p_intf->p_sys->p_input )
         {
             p_main_interface->slider->SetValue( 0 );
             b_old_seekable = VLC_FALSE;
+            b_disc_shown = VLC_FALSE;
 
             p_main_interface->statusbar->SetStatusText(
                 wxU(p_intf->p_sys->p_input->input.p_item->psz_name), 2 );
@@ -114,7 +134,13 @@ void Timer::Notify()
     }
     else if( p_intf->p_sys->p_input->b_dead )
     {
-        /* Hide slider */
+        /* Hide slider and Disc Buttons */
+        p_main_interface->disc_frame->Hide();
+        p_main_interface->slider_sizer->Hide(
+            p_main_interface->disc_frame );
+        p_main_interface->slider_sizer->Layout();
+        p_main_interface->slider_sizer->Fit( p_main_interface->slider_frame );
+
         p_main_interface->slider_frame->Hide();
         p_main_interface->frame_sizer->Hide(
             p_main_interface->slider_frame );
@@ -127,11 +153,9 @@ void Timer::Notify()
         p_main_interface->statusbar->SetStatusText( wxT(""), 0 );
         p_main_interface->statusbar->SetStatusText( wxT(""), 2 );
 
-        vlc_object_release( p_intf->p_sys->p_input );
         p_intf->p_sys->p_input = NULL;
     }
 
-
     if( p_intf->p_sys->p_input )
     {
         input_thread_t *p_input = p_intf->p_sys->p_input;
@@ -144,24 +168,76 @@ void Timer::Notify()
             /* New input or stream map change */
             p_intf->p_sys->b_playing = 1;
 
+            /* Update the item name */
+            p_main_interface->statusbar->SetStatusText(
+                wxU(p_intf->p_sys->p_input->input.p_item->psz_name), 2 );
+
             /* Manage the slider */
             /* FIXME --fenrir */
             /* Change the name of b_old_seekable into b_show_bar or something like that */
             var_Get( p_input, "position", &pos );
 
-            if( !b_old_seekable )
+            vlc_value_t val;
+            var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &val, NULL );
+            if( val.i_int > 0 && !b_disc_shown )
+            {
+                b_disc_shown = VLC_TRUE;
+                vlc_value_t val;
+
+                    #define HELP_MENU N_("Menu")
+                    #define HELP_PCH N_("Previous chapter")
+                    #define HELP_NCH N_("Next chapter")
+                    #define HELP_PTR N_("Previous track")
+                    #define HELP_NTR N_("Next track")
+
+                var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &val,
+                            NULL );
+
+                if( val.i_int > 0 )
+                {
+                    p_main_interface->disc_menu_button->Show();
+                    p_main_interface->disc_sizer->Show(
+                        p_main_interface->disc_menu_button );
+                    p_main_interface->disc_sizer->Layout();
+                    p_main_interface->disc_sizer->Fit(
+                        p_main_interface->disc_frame );
+
+                    p_main_interface->disc_menu_button->SetToolTip(
+                        wxU(_( HELP_MENU ) ) );
+                    p_main_interface->disc_prev_button->SetToolTip(
+                        wxU(_( HELP_PCH ) ) );
+                    p_main_interface->disc_next_button->SetToolTip(
+                        wxU(_( HELP_NCH ) ) );
+                }
+                else
+                {
+                    p_main_interface->disc_menu_button->Hide();
+                    p_main_interface->disc_sizer->Hide(
+                        p_main_interface->disc_menu_button );
+
+                    p_main_interface->disc_prev_button->SetToolTip(
+                        wxU(_( HELP_PTR ) ) );
+                    p_main_interface->disc_next_button->SetToolTip(
+                        wxU(_( HELP_NTR ) ) );
+                }
+
+                p_main_interface->disc_frame->Show();
+                p_main_interface->slider_sizer->Show(
+                    p_main_interface->disc_frame );
+            }
+
+            if( ! b_old_seekable )
             {
                 if( pos.f_float > 0.0 )
                 {
-                    /* Done like this, as it's the only way to know if the slider
-                     * has to be displayed */
+                    /* Done like this, as it's the only way to know if the */
+                    /* slider has to be displayed */
                     b_old_seekable = VLC_TRUE;
                     p_main_interface->slider_frame->Show();
                     p_main_interface->frame_sizer->Show(
                         p_main_interface->slider_frame );
                     p_main_interface->frame_sizer->Layout();
                     p_main_interface->frame_sizer->Fit( p_main_interface );
-
                 }
             }
 
@@ -285,6 +361,13 @@ void Timer::Notify()
         i_old_playing_status = PAUSE_S;
     }
 
+    /* Show the interface, if requested */
+    if( p_intf->p_sys->b_intf_show )
+    {
+        p_main_interface->Raise();
+        p_intf->p_sys->b_intf_show = VLC_FALSE;
+    }
+
     if( p_intf->b_die )
     {
         vlc_mutex_unlock( &p_intf->change_lock );
@@ -315,3 +398,15 @@ static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
 
     return VLC_SUCCESS;
 }
+
+/*****************************************************************************
+ * IntfShowCB: callback triggered by the intf-show playlist variable.
+ *****************************************************************************/
+static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
+                       vlc_value_t old_val, vlc_value_t new_val, void *param )
+{
+    intf_thread_t *p_intf = (intf_thread_t *)param;
+    p_intf->p_sys->b_intf_show = VLC_TRUE;
+
+    return VLC_SUCCESS;
+}