1 /*****************************************************************************
2 * timer.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2005 the VideoLAN team
7 * Authors: Gildas Bazin <gbazin@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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
28 #include "input_manager.hpp"
29 #include "interface.hpp"
32 //void DisplayStreamDate( wxControl *, intf_thread_t *, int );
34 /* Callback prototypes */
35 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
36 vlc_value_t old_val, vlc_value_t new_val, void *param );
37 static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
38 vlc_value_t old_val, vlc_value_t new_val, void *param );
40 /*****************************************************************************
42 *****************************************************************************/
43 Timer::Timer( intf_thread_t *_p_intf, Interface *_p_main_interface )
46 p_main_interface = _p_main_interface;
49 var_AddCallback( p_intf->p_libvlc, "intf-show", IntfShowCB, p_intf );
51 /* Register callback for the intf-popupmenu variable */
52 playlist_t *p_playlist = pl_Yield( p_intf );
53 if( p_playlist != NULL )
55 var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
56 pl_Release( p_playlist );
59 Start( 100 /*milliseconds*/, wxTIMER_CONTINUOUS );
64 var_DelCallback( p_intf->p_libvlc, "intf-show", IntfShowCB, p_intf );
66 /* Unregister callback */
67 playlist_t *p_playlist = pl_Yield( p_intf );
68 if( p_playlist != NULL )
70 var_DelCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
71 pl_Release( p_playlist );
75 /*****************************************************************************
77 *****************************************************************************/
79 /*****************************************************************************
80 * Manage: manage main thread messages
81 *****************************************************************************
82 * In this function, called approx. 10 times a second, we check what the
83 * main program wanted to tell us.
84 *****************************************************************************/
87 #if defined( __WXMSW__ ) /* Work-around a bug with accelerators */
90 p_main_interface->Init();
95 vlc_mutex_lock( &p_intf->change_lock );
98 p_main_interface->input_manager->Update();
99 p_main_interface->Update();
101 /* Show the interface, if requested */
102 if( p_intf->p_sys->b_intf_show )
104 p_main_interface->Raise();
105 p_main_interface->Show();
106 p_intf->p_sys->b_intf_show = false;
109 if( intf_ShouldDie( p_intf ) )
111 vlc_mutex_unlock( &p_intf->change_lock );
113 /* Prepare to die, young Skywalker */
114 p_main_interface->Close(TRUE);
118 vlc_mutex_unlock( &p_intf->change_lock );
121 /*****************************************************************************
122 * PopupMenuCB: callback triggered by the intf-popupmenu playlist variable.
123 * We don't show the menu directly here because we don't want the
124 * caller to block for a too long time.
125 *****************************************************************************/
126 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
127 vlc_value_t old_val, vlc_value_t new_val, void *param )
129 intf_thread_t *p_intf = (intf_thread_t *)param;
131 if( p_intf->p_sys->pf_show_dialog )
133 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU,
141 /*****************************************************************************
142 * IntfShowCB: callback triggered by the intf-show playlist variable.
143 *****************************************************************************/
144 static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
145 vlc_value_t old_val, vlc_value_t new_val, void *param )
147 intf_thread_t *p_intf = (intf_thread_t *)param;
148 p_intf->p_sys->b_intf_show = true;