Date:2010-02-20 20:45:41 (10 years 5 months ago)
Author:Mirko Lindner
Commit:9a3ad4954d701b4c51bd96927e86efd338a56d5e
Message:refine signal handling

Signed-off-by: Mirko Lindner <mirko@sharism.cc>
Files: src/main_window.cc (3 diffs)
src/main_window.hh (1 diff)
src/vido.hh (1 diff)

Change Details

src/main_window.cc
3232
3333main_window::main_window()
3434{
35    signal_key_press_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_press_event));
36    signal_key_release_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_release_event));
35    sigc::connection press_id;
36    sigc::connection release_id;
37
38}
39
40void main_window::connect_all()
41{
42        log_debug("connecting all");
43        (*this).press_id = signal_key_press_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_press_event));
44    (*this).release_id = signal_key_release_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_release_event));
45        log_debug((*this).press_id << " " << (*this).release_id);
46}
47
48void main_window::disconnect_all()
49{
50        log_debug("disconnecting all");
51        (*this).press_id.disconnect();
52    (*this).release_id.disconnect();
53        log_debug((*this).press_id << " " << (*this).release_id);
3754}
3855
3956bool main_window::actions(int key)
4057{
58// log_debug("in actions" << (*this).press_id << " " << (*this).release_id);
4159    static int key_b = 98;
4260    static int key_f = 102;
4361    static int key_h = 104;
...... 
4563    static int key_r = 114;
4664    static int key_s = 115;
4765    static int key_t = 116;
48
49    if (key == key_q)
50    {
51        log_debug("quit requested");
52        quit();
53    }
54    else if(key == key_r)
55    {
56        log_debug("random");
57        show_random();
58    }
59    else if(key == key_s)
60    {
61        log_debug("search");
62        search_window(this);
63    }else if(key == key_t){
64        GoToTop();
65    }else if(key == key_h){
66        show_history();
67    }else if(key == key_f){
68        history_jump(1);
69    }else if(key == key_b){
70        history_jump(-1);
71    }else{
72      log_debug("key pressed: " << key);
73    }
74
75    return true;
66        static int key_f1 = 65470;
67
68        // key commands only available if ctrl pressed
69        if ((ctrl_state == 1) && ((*this).press_id == 1))
70        {
71                (*this).disconnect_all();
72                if (key == key_q)
73                {
74// log_debug("quit requested");
75                        quit();
76                }
77                else if(key == key_r)
78                {
79// log_debug("random");
80                        show_random();
81                }
82                else if(key == key_s)
83                {
84                        log_debug("search");
85                        search_window(this);
86                }else if(key == key_t){
87                        GoToTop();
88                }else if(key == key_h){
89                        show_history();
90                }else if(key == key_f){
91                        history_jump(1);
92                }else if(key == key_b){
93                        history_jump(-1);
94                }else{
95                    (*this).connect_all();
96// log_debug("key pressed: " << key);
97                }
98        // other commands
99        }else{
100            if(key == key_f1){
101                (*this).disconnect_all();
102                show_help();
103            }
104        }
105        return true;
76106
77107}
78108
...... 
84114    }
85115    else
86116    {
87      if (ctrl_state == 1)
88      {
89          actions(Key->keyval);
90      }
117            actions(Key->keyval);
91118    }
92
93    log_debug("Key Presssed is " << gdk_keyval_name(Key->keyval));
119// log_debug("Key Presssed is " << Key->keyval);
94120    return true;
95121}
96122
src/main_window.hh
2727{
2828    public:
2929      main_window();
30            sigc::connection press_id;
31            sigc::connection release_id;
32            void connect_all();
33            void disconnect_all();
3034
3135    private:
3236      bool actions(int);
src/vido.hh
3232extern void getArticleFromUrl(const gchar *url, int pos);
3333extern void getArticleFromTitle(const gchar *url);
3434extern void GoToTop();
35extern bool get_blocked();
36extern void set_blocked(bool value);
37extern void show_help();
3538
3639#endif // VIDO_HH

Archive Download the corresponding diff file

Branches:
development
master



interactive