1
0
mirror of git://projects.qi-hardware.com/vido.git synced 2024-12-22 14:13:21 +02:00

switch from "connect" to "connect_notify"

Signed-off-by: Mirko Lindner <mirko@sharism.cc>
This commit is contained in:
Mirko Lindner 2010-02-22 11:56:08 +01:00
parent 93a9bc198d
commit 7a95279f5e
2 changed files with 43 additions and 9 deletions

View File

@ -39,9 +39,13 @@ main_window::main_window()
void main_window::connect_all() void main_window::connect_all()
{ {
(*this).add_events( Gdk::BUTTON_PRESS_MASK ) ;
log_debug("connecting 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).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)); // (*this).release_id = signal_key_release_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_release_event));
// (*this).press_id =
(*this).press_id = (*this).signal_key_press_event().connect_notify(sigc::mem_fun(*this,&main_window::on_notify_key_press_event));
(*this).release_id = (*this).signal_key_press_event().connect_notify(sigc::mem_fun(*this,&main_window::on_notify_key_release_event));
log_debug((*this).press_id << " " << (*this).release_id); log_debug((*this).press_id << " " << (*this).release_id);
} }
@ -64,6 +68,11 @@ bool main_window::actions(int key)
static int key_s = 115; static int key_s = 115;
static int key_t = 116; static int key_t = 116;
static int key_f1 = 65470; static int key_f1 = 65470;
static int left = 65361;
static int top = 65362;
static int right = 65363;
static int bottom = 65364;
// key commands only available if ctrl pressed // key commands only available if ctrl pressed
if ((ctrl_state == 1) && ((*this).press_id == 1)) if ((ctrl_state == 1) && ((*this).press_id == 1))
@ -106,8 +115,9 @@ bool main_window::actions(int key)
} }
bool main_window::on_my_key_press_event(GdkEventKey *Key) void main_window::on_notify_key_press_event(GdkEventKey *Key)
{ {
if (Key->keyval == gdk_keyval_from_name("Control_R")) if (Key->keyval == gdk_keyval_from_name("Control_R"))
{ {
ctrl_state = 1; ctrl_state = 1;
@ -116,20 +126,42 @@ bool main_window::on_my_key_press_event(GdkEventKey *Key)
{ {
actions(Key->keyval); actions(Key->keyval);
} }
// log_debug("Key Presssed is " << Key->keyval); log_debug("Key Presssed is " << Key->keyval);
return true;
} }
bool main_window::on_my_key_release_event(GdkEventKey *Key) void main_window::on_notify_key_release_event(GdkEventKey *Key)
{ {
if (Key->keyval == gdk_keyval_from_name("Control_R")) if (Key->keyval == gdk_keyval_from_name("Control_R"))
{ {
ctrl_state = 0; ctrl_state = 0;
} }
return true;
} }
// bool main_window::on_my_key_press_event(GdkEventKey *Key)
// {
// if (Key->keyval == gdk_keyval_from_name("Control_R"))
// {
// ctrl_state = 1;
// }
// else
// {
// actions(Key->keyval);
// }
// log_debug("Key Presssed is " << Key->keyval);
// return true;
// }
// bool main_window::on_my_key_release_event(GdkEventKey *Key)
// {
// if (Key->keyval == gdk_keyval_from_name("Control_R"))
// {
// ctrl_state = 0;
// }
//
// return true;
// }
bool main_window::quit() bool main_window::quit()
{ {
hide(); hide();

View File

@ -35,8 +35,10 @@ class main_window : public Gtk::Window
private: private:
bool actions(int); bool actions(int);
int ctrl_state; int ctrl_state;
bool on_my_key_press_event(GdkEventKey *event); // bool on_my_key_press_event(GdkEventKey *event);
bool on_my_key_release_event(GdkEventKey *event); void on_notify_key_press_event(GdkEventKey *event);
void on_notify_key_release_event(GdkEventKey *event);
// bool on_my_key_release_event(GdkEventKey *event);
bool quit(); bool quit();
}; };