Commit 6967749d authored by Gildas Bazin's avatar Gildas Bazin

* modules/gui/wxwindows/*: hotkeys support.

parent b099d449
......@@ -280,7 +280,7 @@ Interface::Interface( intf_thread_t *_p_intf ):
SetDropTarget( new DragAndDrop( p_intf ) );
#endif
UpdateAcceleratorTable();
SetupHotkeys();
/* Start timer */
timer = new Timer( p_intf, this );
......@@ -702,43 +702,38 @@ void Interface::CreateOurExtendedPanel()
extra_frame->Hide();
}
void Interface::UpdateAcceleratorTable()
void Interface::SetupHotkeys()
{
/* Set some hotkeys */
wxAcceleratorEntry entries[7];
vlc_value_t val;
int i = 0;
var_Get( p_intf->p_vlc, "key-quit", &val );
entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
ConvertHotkey( val.i_int ), Exit_Event );
var_Get( p_intf->p_vlc, "key-stop", &val );
entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
ConvertHotkey( val.i_int ), StopStream_Event );
var_Get( p_intf->p_vlc, "key-play-pause", &val );
entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
ConvertHotkey( val.i_int ), PlayStream_Event );
var_Get( p_intf->p_vlc, "key-next", &val );
entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
ConvertHotkey( val.i_int ), NextStream_Event );
var_Get( p_intf->p_vlc, "key-prev", &val );
entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
ConvertHotkey( val.i_int ), PrevStream_Event );
var_Get( p_intf->p_vlc, "key-faster", &val );
entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
ConvertHotkey( val.i_int ), FastStream_Event );
var_Get( p_intf->p_vlc, "key-slower", &val );
entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
ConvertHotkey( val.i_int ), SlowStream_Event );
wxAcceleratorTable accel( 7, entries );
struct vlc_t::hotkey *p_hotkeys = p_intf->p_vlc->p_hotkeys;
int i_hotkeys;
/* Count number of hoteys */
for( i_hotkeys = 0; p_hotkeys[i_hotkeys].psz_action != NULL; i_hotkeys++ );
p_intf->p_sys->i_first_hotkey_event = wxID_HIGHEST + 7000;
p_intf->p_sys->i_hotkeys = i_hotkeys;
wxAcceleratorEntry p_entries[i_hotkeys];
/* Setup the hotkeys as accelerators */
for( int i = 0; p_hotkeys[i].psz_action != NULL; i++ )
{
p_entries[i].Set( ConvertHotkeyModifiers( p_hotkeys[i].i_key ),
ConvertHotkey( p_hotkeys[i].i_key ),
p_intf->p_sys->i_first_hotkey_event + i );
}
wxAcceleratorTable accel( i_hotkeys, p_entries );
if( !accel.Ok() )
{
msg_Err( p_intf, "invalid accelerator table" );
}
else
{
SetAcceleratorTable( accel );
msg_Dbg( p_intf, "accelerator table loaded" );
}
}
/*****************************************************************************
......
......@@ -97,7 +97,8 @@ enum
AudioMenu_Events = wxID_HIGHEST + 2000,
VideoMenu_Events = wxID_HIGHEST + 3000,
NavigMenu_Events = wxID_HIGHEST + 4000,
PopupMenu_Events = wxID_HIGHEST + 6000
PopupMenu_Events = wxID_HIGHEST + 6000,
Hotkeys_Events = wxID_HIGHEST + 7000
};
BEGIN_EVENT_TABLE(Menu, wxMenu)
......@@ -847,6 +848,8 @@ void MenuEvtHandler::OnShowDialog( wxCommandEvent& event )
void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event )
{
wxMenuItem *p_menuitem = NULL;
int i_hotkey_event = p_intf->p_sys->i_first_hotkey_event;
int i_hotkeys = p_intf->p_sys->i_hotkeys;
/* Check if this is an auto generated menu item */
if( event.GetId() < FirstAutoGenerated_Event )
......@@ -855,6 +858,20 @@ void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event )
return;
}
/* Check if this is an hotkey event */
if( event.GetId() >= i_hotkey_event &&
event.GetId() < i_hotkey_event + i_hotkeys )
{
vlc_value_t val;
val.i_int =
p_intf->p_vlc->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 );
return;
}
if( !p_main_interface ||
(p_menuitem = p_main_interface->GetMenuBar()->FindItem(event.GetId()))
== NULL )
......
......@@ -130,6 +130,7 @@ static int Open( vlc_object_t *p_this )
msg_Err( p_intf, "out of memory" );
return VLC_ENOMEM;
}
memset( p_intf->p_sys, 0, sizeof( intf_sys_t ) );
p_intf->pf_run = Run;
......
......@@ -130,6 +130,11 @@ struct intf_sys_t
/* Popup menu */
wxMenu *p_popup_menu;
/* Hotkeys */
int i_first_hotkey_event;
int i_hotkeys;
/* Embedded vout */
VideoWindow *p_video_window;
wxBoxSizer *p_video_sizer;
};
......@@ -209,7 +214,7 @@ public:
wxGauge *volctrl;
private:
void UpdateAcceleratorTable();
void SetupHotkeys();
void CreateOurMenuBar();
void CreateOurToolBar();
void CreateOurExtendedPanel();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment