#!/usr/bin/env python
 
# Talat UYARER talat@uyarer.com
# GPL
 
import vte
import gtk, gobject, gconf
# Import the key binding function from the module
from deskbar.keybinder import tomboy_keybinder_bind as bindkey
 
 
def action(widget, veri):
	if veri=="gizle":
		w.iconify()
	elif veri=="cik":
		gtk.main_quit()
 
 
def terminal():
	global w,notebook,t,hiden,exit
	w = gtk.Window()
	t = vte.Terminal()
	kutu=gtk.VBox()
	dkutu=gtk.HBox()
	w.add(kutu)
	t.set_background_transparent(True)
	w.set_decorated(False)
	t.fork_command("bash") #bashi cagiriyor
	cozunurluk=gtk.gdk.screen_width() #ekranin cozunurlugunden genisligi aliyor
	w.set_size_request(cozunurluk,350) #pencerenin boyutunu belirtiyor
	w.set_skip_taskbar_hint (True) #pencere listesinde yayinlanmiyor
	w.set_keep_above(True) #her zaman ustte tutuyor
	w.move(0,0) #pencerenin konumunu belirliyor.
	dkutu.pack_start(t,True,True,0)
	scroll=gtk.VScrollbar(t.get_adjustment()) # terminale scrollbar ozelligi kazandiriyor
	dkutu.pack_start(scroll,0)
	kutu.pack_start(dkutu,True,True,0)
	d1kutu=gtk.HBox()
	exit=gtk.Button(stock=gtk.STOCK_CLOSE)
	exit.connect("clicked", action, "gizle")
	hiden=gtk.Button(stock=gtk.STOCK_QUIT)
	hiden.connect("clicked", action, "cik")
	d1kutu.pack_start(hiden,False,True,0)
	d1kutu.pack_start(exit,False,True,0)
	kutu.pack_start(d1kutu,False,True,0)
	w.show_all()
 
 
 
# Define a function to execute when the binding is activated
def onBindingPress(arg):
	if arg==1:
		w.present()
 
	else:
		w.iconify()	
 
 
# Bind to the onBindingPress function and pass "Test" as an argument
terminal()
w.iconify()
bindkey("<Ctrl><Alt>b", onBindingPress, 1)
# Establish a binding to quit the program
bindkey("<Ctrl><Alt>q",onBindingPress, 2)
print hiden.clicked
#if hiden.clicked!=-1:
#	action("cik")
#
#if exit.clicked!=-1:
#	action("gizle")
 
# Start a GTK main loop that will run until the quit binding is used
gtk.main()

