Root/src/main_window.cc

Source at commit 9387c0dd58913fda7211152214fc69e884f7da22 created 10 years 8 months ago.
By Mirko Lindner, add history and "go to top" functions
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
31log_define("vido.main_window");
32
33main_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
39bool main_window::actions(int key)
40{
41    static int key_b = 98;
42    static int key_h = 104;
43    static int key_q = 113;
44    static int key_r = 114;
45    static int key_s = 115;
46    static int key_t = 116;
47
48    if (key == key_q)
49    {
50        log_debug("quit requested");
51        quit();
52    }
53    else if(key == key_r)
54    {
55        log_debug("random");
56        show_random();
57    }
58    else if(key == key_s)
59    {
60        log_debug("search");
61        search_window(this);
62    }else if(key == key_t){
63        GoToTop();
64    }else if(key == key_h){
65        show_history();
66    }else{
67      log_debug("key pressed: " << key);
68    }
69    
70    return true;
71
72}
73
74bool main_window::on_my_key_press_event(GdkEventKey *Key)
75{
76    if (Key->keyval == gdk_keyval_from_name("Control_R"))
77    {
78        ctrl_state = 1;
79    }
80    else
81    {
82      if (ctrl_state == 1)
83      {
84          actions(Key->keyval);
85      }
86    }
87
88    log_debug("Key Presssed is " << gdk_keyval_name(Key->keyval));
89    return true;
90}
91
92bool main_window::on_my_key_release_event(GdkEventKey *Key)
93{
94    if (Key->keyval == gdk_keyval_from_name("Control_R"))
95    {
96        ctrl_state = 0;
97    }
98
99    return true;
100}
101
102bool main_window::quit()
103{
104    hide();
105    return false;
106}
107

Archive Download this file

Branches:
development
master



interactive