Remove unused variable
[vte.git] / python / cat.py
1 #!/usr/bin/python
2 import sys
3 import string
4 import getopt
5 import gtk
6 import vte
7
8 def main_quit(object, *args):
9         gtk.main_quit()
10
11 def commit_cb(object, *args):
12         (text, length) = args
13         # Echo the text input by the user to stdout.  Note that the string's
14         # length isn't always going to be right.
15         if (0):
16                 sys.stdout.write(text)
17                 sys.stdout.flush()
18         else:
19         # Test the get_text() function.
20                 for line in (string.splitfields(object.get_text(),"\n")):
21                         if (line.__len__() > 0):
22                                 print line
23         # Also display it.
24         object.feed(text, length)
25
26 if __name__ == '__main__':
27         font = "fixed 12"
28         scrollback = 100
29         # Let the user override them.
30         (shorts, longs) = getopt.getopt(sys.argv[1:], "f:", ["font="])
31         for argpair in (shorts + longs):
32                 if ((argpair[0] == '-f') or (argpair[0] == '--font')):
33                         print "Setting font to `" + argpair[1] + "'."
34                         font = argpair[1]
35         window = gtk.Window()
36         window.connect("delete-event", main_quit)
37
38         terminal = vte.Terminal()
39         terminal.set_cursor_blinks(gtk.TRUE)
40         terminal.set_emulation("xterm")
41         terminal.set_font_from_string(font)
42         terminal.set_scrollback_lines(1000)
43         terminal.set_audible_bell(gtk.TRUE)
44         terminal.set_visible_bell(gtk.FALSE)
45         terminal.connect("commit", commit_cb)
46         terminal.show()
47
48         scrollbar = gtk.VScrollbar()
49         scrollbar.set_adjustment(terminal.get_adjustment())
50
51         box = gtk.HBox()
52         box.pack_start(terminal)
53         box.pack_start(scrollbar)
54
55         window.add(box)
56         window.show_all()
57         gtk.main()