Root/
Source at commit 7a95279f5e36778faf6d2ef9b01136e054bb8660 created 14 years 1 month ago. By Mirko Lindner, switch from "connect" to "connect_notify" | |
---|---|
1 | /*************************************************************************** |
2 | * Copyright (C) 2009 by Mirko Lindner,,, * |
3 | * vegyraupe@mira * |
4 | * * |
5 | * This program is free software; you can redistribute it and/or modify * |
6 | * it under the terms of the GNU General Public License as published by * |
7 | * the Free Software Foundation; either version 2 of the License, or * |
8 | * (at your option) any later version. * |
9 | * * |
10 | * This program is distributed in the hope that it will be useful, * |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 | * GNU General Public License for more details. * |
14 | * * |
15 | * You should have received a copy of the GNU General Public License * |
16 | * along with this program; if not, write to the * |
17 | * Free Software Foundation, Inc., * |
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | ***************************************************************************/ |
20 | |
21 | |
22 | // newer (non customized) versions of this file go to main_window.cc_new |
23 | |
24 | // This file is for your program, I won't touch it again! |
25 | |
26 | #include "config.h" |
27 | #include "main_window.hh" |
28 | #include "vido.hh" |
29 | #include <cxxtools/log.h> |
30 | |
31 | log_define("vido.main_window"); |
32 | |
33 | main_window::main_window() |
34 | { |
35 | sigc::connection press_id; |
36 | sigc::connection release_id; |
37 | |
38 | } |
39 | |
40 | void main_window::connect_all() |
41 | { |
42 | (*this).add_events( Gdk::BUTTON_PRESS_MASK ) ; |
43 | log_debug("connecting all"); |
44 | // (*this).press_id = signal_key_press_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_press_event)); |
45 | // (*this).release_id = signal_key_release_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_release_event)); |
46 | // (*this).press_id = |
47 | (*this).press_id = (*this).signal_key_press_event().connect_notify(sigc::mem_fun(*this,&main_window::on_notify_key_press_event)); |
48 | (*this).release_id = (*this).signal_key_press_event().connect_notify(sigc::mem_fun(*this,&main_window::on_notify_key_release_event)); |
49 | log_debug((*this).press_id << " " << (*this).release_id); |
50 | } |
51 | |
52 | void main_window::disconnect_all() |
53 | { |
54 | log_debug("disconnecting all"); |
55 | (*this).press_id.disconnect(); |
56 | (*this).release_id.disconnect(); |
57 | log_debug((*this).press_id << " " << (*this).release_id); |
58 | } |
59 | |
60 | bool main_window::actions(int key) |
61 | { |
62 | // log_debug("in actions" << (*this).press_id << " " << (*this).release_id); |
63 | static int key_b = 98; |
64 | static int key_f = 102; |
65 | static int key_h = 104; |
66 | static int key_q = 113; |
67 | static int key_r = 114; |
68 | static int key_s = 115; |
69 | static int key_t = 116; |
70 | static int key_f1 = 65470; |
71 | static int left = 65361; |
72 | static int top = 65362; |
73 | static int right = 65363; |
74 | static int bottom = 65364; |
75 | |
76 | |
77 | // key commands only available if ctrl pressed |
78 | if ((ctrl_state == 1) && ((*this).press_id == 1)) |
79 | { |
80 | (*this).disconnect_all(); |
81 | if (key == key_q) |
82 | { |
83 | // log_debug("quit requested"); |
84 | quit(); |
85 | } |
86 | else if(key == key_r) |
87 | { |
88 | // log_debug("random"); |
89 | show_random(); |
90 | } |
91 | else if(key == key_s) |
92 | { |
93 | log_debug("search"); |
94 | search_window(this); |
95 | }else if(key == key_t){ |
96 | GoToTop(); |
97 | }else if(key == key_h){ |
98 | show_history(); |
99 | }else if(key == key_f){ |
100 | history_jump(1); |
101 | }else if(key == key_b){ |
102 | history_jump(-1); |
103 | }else{ |
104 | (*this).connect_all(); |
105 | // log_debug("key pressed: " << key); |
106 | } |
107 | // other commands |
108 | }else{ |
109 | if(key == key_f1){ |
110 | (*this).disconnect_all(); |
111 | show_help(); |
112 | } |
113 | } |
114 | return true; |
115 | |
116 | } |
117 | |
118 | void main_window::on_notify_key_press_event(GdkEventKey *Key) |
119 | { |
120 | |
121 | if (Key->keyval == gdk_keyval_from_name("Control_R")) |
122 | { |
123 | ctrl_state = 1; |
124 | } |
125 | else |
126 | { |
127 | actions(Key->keyval); |
128 | } |
129 | log_debug("Key Presssed is " << Key->keyval); |
130 | } |
131 | |
132 | void main_window::on_notify_key_release_event(GdkEventKey *Key) |
133 | { |
134 | if (Key->keyval == gdk_keyval_from_name("Control_R")) |
135 | { |
136 | ctrl_state = 0; |
137 | } |
138 | |
139 | } |
140 | |
141 | // bool main_window::on_my_key_press_event(GdkEventKey *Key) |
142 | // { |
143 | // if (Key->keyval == gdk_keyval_from_name("Control_R")) |
144 | // { |
145 | // ctrl_state = 1; |
146 | // } |
147 | // else |
148 | // { |
149 | // actions(Key->keyval); |
150 | // } |
151 | // log_debug("Key Presssed is " << Key->keyval); |
152 | // return true; |
153 | // } |
154 | |
155 | // bool main_window::on_my_key_release_event(GdkEventKey *Key) |
156 | // { |
157 | // if (Key->keyval == gdk_keyval_from_name("Control_R")) |
158 | // { |
159 | // ctrl_state = 0; |
160 | // } |
161 | // |
162 | // return true; |
163 | // } |
164 | |
165 | bool main_window::quit() |
166 | { |
167 | hide(); |
168 | return false; |
169 | } |
170 |
Branches:
development
master