SetDropTarget( new DragAndDrop( p_intf ) );
#endif
- UpdateAcceleratorTable();
+ SetupHotkeys();
/* Start timer */
timer = new Timer( p_intf, this );
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;
- if( !accel.Ok() )
- msg_Err( p_intf, "invalid accelerator table" );
+ /* 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 );
+ }
- SetAcceleratorTable( accel );
- msg_Dbg( p_intf, "accelerator table loaded" );
+ 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" );
+ }
}
/*****************************************************************************
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)
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 )
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 )