mirror of
git://projects.qi-hardware.com/vido.git
synced 2025-01-03 06:30:15 +02:00
refine signal handling
Signed-off-by: Mirko Lindner <mirko@sharism.cc>
This commit is contained in:
parent
5d30ead071
commit
9a3ad4954d
@ -32,12 +32,30 @@ log_define("vido.main_window");
|
||||
|
||||
main_window::main_window()
|
||||
{
|
||||
signal_key_press_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_press_event));
|
||||
signal_key_release_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_release_event));
|
||||
sigc::connection press_id;
|
||||
sigc::connection release_id;
|
||||
|
||||
}
|
||||
|
||||
void main_window::connect_all()
|
||||
{
|
||||
log_debug("connecting all");
|
||||
(*this).press_id = signal_key_press_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_press_event));
|
||||
(*this).release_id = signal_key_release_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_release_event));
|
||||
log_debug((*this).press_id << " " << (*this).release_id);
|
||||
}
|
||||
|
||||
void main_window::disconnect_all()
|
||||
{
|
||||
log_debug("disconnecting all");
|
||||
(*this).press_id.disconnect();
|
||||
(*this).release_id.disconnect();
|
||||
log_debug((*this).press_id << " " << (*this).release_id);
|
||||
}
|
||||
|
||||
bool main_window::actions(int key)
|
||||
{
|
||||
// log_debug("in actions" << (*this).press_id << " " << (*this).release_id);
|
||||
static int key_b = 98;
|
||||
static int key_f = 102;
|
||||
static int key_h = 104;
|
||||
@ -45,15 +63,20 @@ bool main_window::actions(int key)
|
||||
static int key_r = 114;
|
||||
static int key_s = 115;
|
||||
static int key_t = 116;
|
||||
static int key_f1 = 65470;
|
||||
|
||||
// key commands only available if ctrl pressed
|
||||
if ((ctrl_state == 1) && ((*this).press_id == 1))
|
||||
{
|
||||
(*this).disconnect_all();
|
||||
if (key == key_q)
|
||||
{
|
||||
log_debug("quit requested");
|
||||
// log_debug("quit requested");
|
||||
quit();
|
||||
}
|
||||
else if(key == key_r)
|
||||
{
|
||||
log_debug("random");
|
||||
// log_debug("random");
|
||||
show_random();
|
||||
}
|
||||
else if(key == key_s)
|
||||
@ -69,9 +92,16 @@ bool main_window::actions(int key)
|
||||
}else if(key == key_b){
|
||||
history_jump(-1);
|
||||
}else{
|
||||
log_debug("key pressed: " << key);
|
||||
(*this).connect_all();
|
||||
// log_debug("key pressed: " << key);
|
||||
}
|
||||
// other commands
|
||||
}else{
|
||||
if(key == key_f1){
|
||||
(*this).disconnect_all();
|
||||
show_help();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
@ -83,14 +113,10 @@ bool main_window::on_my_key_press_event(GdkEventKey *Key)
|
||||
ctrl_state = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ctrl_state == 1)
|
||||
{
|
||||
actions(Key->keyval);
|
||||
}
|
||||
}
|
||||
|
||||
log_debug("Key Presssed is " << gdk_keyval_name(Key->keyval));
|
||||
// log_debug("Key Presssed is " << Key->keyval);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,10 @@ class main_window : public Gtk::Window
|
||||
{
|
||||
public:
|
||||
main_window();
|
||||
sigc::connection press_id;
|
||||
sigc::connection release_id;
|
||||
void connect_all();
|
||||
void disconnect_all();
|
||||
|
||||
private:
|
||||
bool actions(int);
|
||||
|
@ -32,5 +32,8 @@ extern void search_window(main_window *window);
|
||||
extern void getArticleFromUrl(const gchar *url, int pos);
|
||||
extern void getArticleFromTitle(const gchar *url);
|
||||
extern void GoToTop();
|
||||
extern bool get_blocked();
|
||||
extern void set_blocked(bool value);
|
||||
extern void show_help();
|
||||
|
||||
#endif // VIDO_HH
|
||||
|
Loading…
Reference in New Issue
Block a user