#!/usr/bin/env python
# -*- coding: utf-8 -*-

# 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.

import pygtk
pygtk.require('2.0')

import gtk, gtk.glade

class MainWindow:
    def __init__(self):
        # create widget tree ...
        xml = gtk.glade.XML('editor.glade')

        # connect handlers
        xml.signal_autoconnect(self)
	
	# clipboard
	self.clipy = gtk.Clipboard ();

        # widgets
        self.window = xml.get_widget('window')
        self.vbox1 = xml.get_widget('vbox1')
        self.toolbar1 = xml.get_widget('toolbar1')
        self.toolbutton_copy = xml.get_widget('toolbutton_copy')
        self.toolbutton_cut = xml.get_widget('toolbutton_cut')
        self.toolbutton_paste = xml.get_widget('toolbutton_paste')
        self.scrolledwindow1 = xml.get_widget('scrolledwindow1')
        self.textview = xml.get_widget('textview')
	
	# we need the textbuffer too
	self.textbuffer = self.textview.get_buffer()

    # signal handlers
    def on_window_delete_event(self, widget, obj):
        "on_window_delete_event activated"
        gtk.main_quit()

    def on_toolbutton_copy_clicked(self, obj):
        "on_toolbutton_copy_clicked activated"
        self.textbuffer.copy_clipboard (self.clipy)

    def on_toolbutton_cut_clicked(self, obj):
        "on_toolbutton_cut_clicked activated"
        self.textbuffer.cut_clipboard (self.clipy, True)

    def on_toolbutton_paste_clicked(self, obj):
        "on_toolbutton_paste_clicked activated"
        self.textbuffer.paste_clipboard (self.clipy, None, True)


# run main loop
main_window = MainWindow()
gtk.main()

