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