/*************************************************************************** * Copyright (C) 2009 by Mirko Lindner,,, * * vegyraupe@mira * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ // newer (non customized) versions of this file go to main_window.cc_new // This file is for your program, I won't touch it again! #include "config.h" #include "main_window.hh" extern void show_random(); extern void search_window(main_window *window); main_window::main_window() { this->signal_key_press_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_press_event)); this->signal_key_release_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_release_event)); } main_window::~main_window() { } bool main_window::actions(int key) { // // 115 == s // // 114 == r printf("actions key:%i q:%i",int(key), 113); if (key == int(113)) { printf("quit requested"); this->quit(); } else if(key == int(114)) { // gtk_html_load_from_string(GTK_HTML(html_wg), "me", -1); show_random(); printf("random"); } else if(key == int(115)) { search_window(this); printf("search"); } return true; } bool main_window::on_my_key_press_event(GdkEventKey *Key) { // printf("ctrl set value nows: %i\n", *ctrl_state); if (Key->keyval == gdk_keyval_from_name("Control_L")){ ctrl_state = 1; // printf("ctrl set value nows: %i\n", ctrl_state); }else{ if (ctrl_state == 1){ // printf("key num: %i", Key->keyval); this->actions(Key->keyval); // printf("\n Key Presssed is %s with ctrl held\n",gdk_keyval_name(Key->keyval)); } } printf("\n Key Presssed is %s\n",gdk_keyval_name(Key->keyval)); return true; } bool main_window::on_my_key_release_event(GdkEventKey *Key) { // printf("ctrl set value nows: %i\n", *ctrl_state); if (Key->keyval == gdk_keyval_from_name("Control_L")){ ctrl_state = 0; // printf("ctrl set value nows: %i\n", ctrl_state); } // printf("\n Key released is %s\n",gdk_keyval_name(Key->keyval)); return true; } bool main_window::quit() { hide(); return 0; }