Root/
Source at commit 5d30ead071fc7f5f38e439824e97aa5d9ccea67a created 14 years 2 months ago. By Mirko Lindner, start implemting back and forward in history | |
---|---|
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 | 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)); |
37 | } |
38 | |
39 | bool main_window::actions(int key) |
40 | { |
41 | static int key_b = 98; |
42 | static int key_f = 102; |
43 | static int key_h = 104; |
44 | static int key_q = 113; |
45 | static int key_r = 114; |
46 | static int key_s = 115; |
47 | 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; |
76 | |
77 | } |
78 | |
79 | bool main_window::on_my_key_press_event(GdkEventKey *Key) |
80 | { |
81 | if (Key->keyval == gdk_keyval_from_name("Control_R")) |
82 | { |
83 | ctrl_state = 1; |
84 | } |
85 | else |
86 | { |
87 | if (ctrl_state == 1) |
88 | { |
89 | actions(Key->keyval); |
90 | } |
91 | } |
92 | |
93 | log_debug("Key Presssed is " << gdk_keyval_name(Key->keyval)); |
94 | return true; |
95 | } |
96 | |
97 | bool main_window::on_my_key_release_event(GdkEventKey *Key) |
98 | { |
99 | if (Key->keyval == gdk_keyval_from_name("Control_R")) |
100 | { |
101 | ctrl_state = 0; |
102 | } |
103 | |
104 | return true; |
105 | } |
106 | |
107 | bool main_window::quit() |
108 | { |
109 | hide(); |
110 | return false; |
111 | } |
112 |
Branches:
development
master