#!/usr/bin/python2
#-----------------------------------------------------------------------
# Openbox Key Editor
# Copyright (C) 2009 nsf <no.smile.face@gmail.com>
# v1.1 - Code migrated from PyGTK to PyGObject github.com/stevenhoneyman/obkey
# v1.2pre1 - solve a minor bug on copy-paste bug github.com/luffah/obkey
# v1.2pre2 - 19.06.2016 - structured presentation of actions... github.com/luffah/obkey
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#-----------------------------------------------------------------------

import sys, os
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
from gi.repository import GObject
#~ import obkey_classes
import obkey_classes as obkey_classes
import xml.dom.minidom

def die(widget, data=None):
	Gtk.main_quit()

# get rc file
path = os.getenv("HOME") + "/.config/openbox/rc.xml"
if len(sys.argv) == 2:
	path = sys.argv[1]

ob = obkey_classes.OpenboxConfig()
ob.load(path)

win = Gtk.Window(Gtk.WindowType.TOPLEVEL)
win.set_default_size(800,480)
win.set_title(obkey_classes.config_title)
win.connect("destroy", die)

tbl = obkey_classes.PropertyTable()
al = obkey_classes.ActionList(tbl)
ktbl = obkey_classes.KeyTable(al, ob)

vbox = Gtk.VPaned()
vbox.pack1(tbl.widget, True, False)
vbox.pack2(al.widget, True, False)

hbox = Gtk.HPaned()
hbox.pack1(ktbl.widget, True, False)
hbox.pack2(vbox, False, False)

win.add(hbox)
win.show_all()
# get rid of stupid autocalculation
w, h = win.get_size()
hbox.set_position(w-250)
ktbl.view.grab_focus()
Gtk.main()
