2009-10-28 15:47:25 +02:00
|
|
|
/***************************************************************************
|
|
|
|
* 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"
|
2009-12-28 00:37:18 +02:00
|
|
|
#include "vido.hh"
|
|
|
|
#include <cxxtools/log.h>
|
2009-10-28 15:47:25 +02:00
|
|
|
|
2009-12-28 00:37:18 +02:00
|
|
|
log_define("vido.main_window");
|
2009-10-28 15:47:25 +02:00
|
|
|
|
|
|
|
main_window::main_window()
|
|
|
|
{
|
2010-02-20 21:45:41 +02:00
|
|
|
sigc::connection press_id;
|
|
|
|
sigc::connection release_id;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void main_window::connect_all()
|
|
|
|
{
|
|
|
|
log_debug("connecting all");
|
|
|
|
(*this).press_id = signal_key_press_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_press_event));
|
|
|
|
(*this).release_id = signal_key_release_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_release_event));
|
|
|
|
log_debug((*this).press_id << " " << (*this).release_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void main_window::disconnect_all()
|
|
|
|
{
|
|
|
|
log_debug("disconnecting all");
|
|
|
|
(*this).press_id.disconnect();
|
|
|
|
(*this).release_id.disconnect();
|
|
|
|
log_debug((*this).press_id << " " << (*this).release_id);
|
2009-10-28 15:47:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool main_window::actions(int key)
|
|
|
|
{
|
2010-02-20 21:45:41 +02:00
|
|
|
// log_debug("in actions" << (*this).press_id << " " << (*this).release_id);
|
2010-01-23 21:43:28 +02:00
|
|
|
static int key_b = 98;
|
2010-01-24 15:54:33 +02:00
|
|
|
static int key_f = 102;
|
2010-01-23 21:43:28 +02:00
|
|
|
static int key_h = 104;
|
2009-12-28 00:37:18 +02:00
|
|
|
static int key_q = 113;
|
|
|
|
static int key_r = 114;
|
|
|
|
static int key_s = 115;
|
2010-01-23 21:43:28 +02:00
|
|
|
static int key_t = 116;
|
2010-02-20 21:45:41 +02:00
|
|
|
static int key_f1 = 65470;
|
|
|
|
|
|
|
|
// key commands only available if ctrl pressed
|
|
|
|
if ((ctrl_state == 1) && ((*this).press_id == 1))
|
|
|
|
{
|
|
|
|
(*this).disconnect_all();
|
|
|
|
if (key == key_q)
|
|
|
|
{
|
|
|
|
// log_debug("quit requested");
|
|
|
|
quit();
|
|
|
|
}
|
|
|
|
else if(key == key_r)
|
|
|
|
{
|
|
|
|
// log_debug("random");
|
|
|
|
show_random();
|
|
|
|
}
|
|
|
|
else if(key == key_s)
|
|
|
|
{
|
|
|
|
log_debug("search");
|
|
|
|
search_window(this);
|
|
|
|
}else if(key == key_t){
|
|
|
|
GoToTop();
|
|
|
|
}else if(key == key_h){
|
|
|
|
show_history();
|
|
|
|
}else if(key == key_f){
|
|
|
|
history_jump(1);
|
|
|
|
}else if(key == key_b){
|
|
|
|
history_jump(-1);
|
|
|
|
}else{
|
|
|
|
(*this).connect_all();
|
|
|
|
// log_debug("key pressed: " << key);
|
|
|
|
}
|
|
|
|
// other commands
|
|
|
|
}else{
|
|
|
|
if(key == key_f1){
|
|
|
|
(*this).disconnect_all();
|
|
|
|
show_help();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2009-10-28 15:47:25 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool main_window::on_my_key_press_event(GdkEventKey *Key)
|
|
|
|
{
|
2010-01-18 14:17:26 +02:00
|
|
|
if (Key->keyval == gdk_keyval_from_name("Control_R"))
|
2009-12-28 00:37:18 +02:00
|
|
|
{
|
2009-10-28 15:47:25 +02:00
|
|
|
ctrl_state = 1;
|
2009-12-28 00:37:18 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-02-20 21:45:41 +02:00
|
|
|
actions(Key->keyval);
|
2009-10-28 15:47:25 +02:00
|
|
|
}
|
2010-02-20 21:45:41 +02:00
|
|
|
// log_debug("Key Presssed is " << Key->keyval);
|
2009-10-28 15:47:25 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool main_window::on_my_key_release_event(GdkEventKey *Key)
|
|
|
|
{
|
2010-01-18 14:17:26 +02:00
|
|
|
if (Key->keyval == gdk_keyval_from_name("Control_R"))
|
2009-12-28 00:37:18 +02:00
|
|
|
{
|
2009-10-28 15:47:25 +02:00
|
|
|
ctrl_state = 0;
|
|
|
|
}
|
2009-12-28 00:37:18 +02:00
|
|
|
|
2009-10-28 15:47:25 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool main_window::quit()
|
|
|
|
{
|
|
|
|
hide();
|
2009-12-28 00:37:18 +02:00
|
|
|
return false;
|
2009-10-28 15:47:25 +02:00
|
|
|
}
|