1 /*****************************************************************************
2 * slider_manager.cpp : Manage an input slider
3 *****************************************************************************
4 * Copyright (C) 2000-2005 the VideoLAN team
5 * $Id: timer.cpp 11981 2005-08-03 15:03:23Z xtophe $
7 * Authors: Clément Stenac <zorglub@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 #include "main_slider_manager.hpp"
25 #include "interface.hpp"
29 /*****************************************************************************
31 *****************************************************************************/
32 MainSliderManager::MainSliderManager( intf_thread_t *_p_intf,
33 Interface *_p_main_intf ) :
34 SliderManager( _p_intf )
36 p_main_intf = _p_main_intf;
37 _slider = p_main_intf->slider;
40 MainSliderManager::~MainSliderManager()
42 vlc_mutex_lock( &p_intf->change_lock );
43 if( p_intf->p_sys->p_input ) vlc_object_release( p_intf->p_sys->p_input );
44 p_intf->p_sys->p_input = NULL;
45 vlc_mutex_unlock( &p_intf->change_lock );
48 /*****************************************************************************
50 *****************************************************************************/
52 void MainSliderManager::UpdateInput()
54 playlist_t *p_playlist =
55 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
57 if( p_playlist != NULL )
59 LockPlaylist( p_intf->p_sys, p_playlist );
60 p_input = p_intf->p_sys->p_input = p_playlist->p_input;
61 if( p_intf->p_sys->p_input )
62 vlc_object_yield( p_intf->p_sys->p_input );
63 UnlockPlaylist( p_intf->p_sys, p_playlist );
64 vlc_object_release( p_playlist );
68 void MainSliderManager::UpdateNowPlaying()
70 char *psz_now_playing = vlc_input_item_GetInfo(
71 p_intf->p_sys->p_input->input.p_item,
72 _("Meta-information"), _(VLC_META_NOW_PLAYING) );
73 if( psz_now_playing && *psz_now_playing )
75 p_main_intf->statusbar->SetStatusText(
76 wxString(wxU(psz_now_playing)) + wxT( " - " ) +
77 wxU(p_intf->p_sys->p_input->input.p_item->psz_name), 2 );
81 p_main_intf->statusbar->SetStatusText(
82 wxU(p_intf->p_sys->p_input->input.p_item->psz_name), 2 );
84 free( psz_now_playing );
87 void MainSliderManager::UpdateButtons( vlc_bool_t b_play )
91 p_main_intf->TogglePlayButton( PLAYING_S );
92 #ifdef wxHAS_TASK_BAR_ICON
93 if( p_main_intf->p_systray )
95 p_main_intf->p_systray->UpdateTooltip(
96 wxU( p_intf->p_sys->p_input->input.p_item->psz_name ) +
97 wxString(wxT(" - ")) + wxU(_("Playing")));
103 p_main_intf->TogglePlayButton( PAUSE_S );
104 p_main_intf->statusbar->SetStatusText( wxT(""), 0 );
105 p_main_intf->statusbar->SetStatusText( wxT(""), 2 );
106 #ifdef wxHAS_TASK_BAR_ICON
107 if( p_main_intf->p_systray )
109 p_main_intf->p_systray->UpdateTooltip( wxString(wxT("VLC media player - ")) + wxU(_("Stopped")) );
115 void MainSliderManager::HideControls()
117 p_main_intf->m_controls_timer.Start(200, wxTIMER_ONE_SHOT);
120 void MainSliderManager::DontHide()
122 p_main_intf->m_controls_timer.Stop();
124 /* New input or stream map change */
125 p_intf->p_sys->b_playing = VLC_TRUE;
128 void MainSliderManager::UpdateDiscButtons()
131 var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &val, NULL );
132 if( val.i_int > 0 && !p_main_intf->disc_frame->IsShown() )
136 #define HELP_MENU N_("Menu")
137 #define HELP_PCH N_("Previous chapter")
138 #define HELP_NCH N_("Next chapter")
139 #define HELP_PTR N_("Previous track")
140 #define HELP_NTR N_("Next track")
142 var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &val, NULL );
146 p_main_intf->disc_menu_button->Show();
147 p_main_intf->disc_sizer->Show(
148 p_main_intf->disc_menu_button );
149 p_main_intf->disc_sizer->Layout();
150 p_main_intf->disc_sizer->Fit(
151 p_main_intf->disc_frame );
152 p_main_intf->disc_menu_button->SetToolTip(
153 wxU(_( HELP_MENU ) ) );
154 p_main_intf->disc_prev_button->SetToolTip(
155 wxU(_( HELP_PCH ) ) );
156 p_main_intf->disc_next_button->SetToolTip(
157 wxU(_( HELP_NCH ) ) );
161 p_main_intf->disc_menu_button->Hide();
162 p_main_intf->disc_sizer->Hide(
163 p_main_intf->disc_menu_button );
164 p_main_intf->disc_prev_button->SetToolTip(
165 wxU(_( HELP_PTR ) ) );
166 p_main_intf->disc_next_button->SetToolTip(
167 wxU(_( HELP_NTR ) ) );
170 p_main_intf->ShowDiscFrame();
172 else if( val.i_int == 0 && p_main_intf->disc_frame->IsShown() )
174 p_main_intf->HideDiscFrame();
178 vlc_bool_t MainSliderManager::IsShown()
180 return p_main_intf->slider_frame->IsShown();
183 void MainSliderManager::ShowSlider()
185 p_main_intf->ShowSlider();
188 void MainSliderManager::HideSlider()
190 p_main_intf->m_slider_timer.Start( 200, wxTIMER_ONE_SHOT );
193 vlc_bool_t MainSliderManager::IsFree()
195 return p_intf->p_sys->b_slider_free;
198 vlc_bool_t MainSliderManager::IsPlaying()
200 return p_intf->p_sys->b_playing;
203 void MainSliderManager::UpdateTime( char *psz_time, char *psz_total )
205 p_main_intf->statusbar->SetStatusText(
206 wxU(psz_time) + wxString(wxT(" / ")) +wxU(psz_total), 0 );