sugar-toolkit-gtk3/activities/terminal/TerminalActivity.py

62 lines
1.5 KiB
Python
Raw Normal View History

2006-06-23 03:51:29 +02:00
import gtk
import vte
2006-06-23 04:56:24 +02:00
import pango
2006-06-23 03:51:29 +02:00
from sugar.activity.Activity import Activity
_TERMINAL_ACTIVITY_TYPE = "_terminal._tcp"
class Terminal(gtk.HBox):
2006-06-23 04:46:09 +02:00
def __init__(self):
gtk.HBox.__init__(self, False, 4)
2006-06-23 03:51:29 +02:00
2006-06-23 04:46:09 +02:00
self._vte = vte.Terminal()
self._configure_vte()
self._vte.set_size(30, 5)
self._vte.set_size_request(200, 50)
self._vte.show()
self.pack_start(self._vte)
self._scrollbar = gtk.VScrollbar(self._vte.get_adjustment())
self._scrollbar.show()
self.pack_start(self._scrollbar, False, False, 0)
self._vte.connect("child-exited", lambda term: term.fork_command())
2006-06-23 03:51:29 +02:00
2006-06-23 04:46:09 +02:00
self._vte.fork_command()
2006-07-12 22:45:13 +02:00
2006-06-23 03:51:29 +02:00
def _configure_vte(self):
self._vte.set_font(pango.FontDescription('Monospace 10'))
2006-06-23 04:46:09 +02:00
self._vte.set_colors(gtk.gdk.color_parse ('#AAAAAA'),
gtk.gdk.color_parse ('#000000'),
[])
self._vte.set_cursor_blinks(False)
self._vte.set_audible_bell(False)
self._vte.set_scrollback_lines(100)
self._vte.set_allow_bold(True)
self._vte.set_scroll_on_keystroke(False)
self._vte.set_scroll_on_output(False)
self._vte.set_emulation('xterm')
self._vte.set_visible_bell(False)
def on_gconf_notification(self, client, cnxn_id, entry, what):
self.reconfigure_vte()
2006-06-23 03:51:29 +02:00
2006-06-23 04:46:09 +02:00
def on_vte_button_press(self, term, event):
if event.button == 3:
self.do_popup(event)
return True
2006-06-23 03:51:29 +02:00
2006-06-23 04:46:09 +02:00
def on_vte_popup_menu(self, term):
pass
2006-06-23 03:51:29 +02:00
class TerminalActivity(Activity):
2006-08-07 16:26:54 +02:00
def __init__(self, service):
Activity.__init__(self, service)
2006-06-23 03:51:29 +02:00
2006-07-12 22:45:13 +02:00
self.set_title("Terminal")
2006-06-23 03:51:29 +02:00
terminal = Terminal()
2006-07-12 22:45:13 +02:00
self.add(terminal)
2006-06-23 03:51:29 +02:00
terminal.show()