From d5c9b439d86daca6d63300a50fe49ba7b10f7fb2 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Mon, 24 Dec 2007 21:41:13 +0000 Subject: [PATCH] Fixed Shell Gadget svn: r9575 --- src/plugins/DefaultGadgets.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/plugins/DefaultGadgets.py b/src/plugins/DefaultGadgets.py index 7bea36d06..6d6545d17 100644 --- a/src/plugins/DefaultGadgets.py +++ b/src/plugins/DefaultGadgets.py @@ -249,7 +249,7 @@ class ShellGadget(Gadget): fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK) # GUI setup: self.gui.textview.set_editable(True) - self.set_text("%s $ " % command[0]) + self.set_text("%s\n$ " % command[0]) self.gui.textview.connect('key-press-event', self.on_enter) def write(self, text): @@ -287,6 +287,31 @@ class ShellGadget(Gadget): return True return False + +class PythonGadget(Gadget): + def init(self): + # GUI setup: + self.gui.textview.set_editable(True) + self.set_text("Python\n> ") + self.gui.textview.connect('key-press-event', self.on_enter) + + def on_enter(self, widget, event): + if event.keyval == 65293: # enter, where to get this? + buffer = widget.get_buffer() + line_cnt = buffer.get_line_count() + start = buffer.get_iter_at_line(line_cnt - 1) + end = buffer.get_end_iter() + line = buffer.get_text(start, end) + if line.startswith("> "): + self.append_text("\n") + line = line[2:] + self.append_text(output) + self.append_text("> ") + else: + self.append_text("\n> ") + return True + return False + register(type="gadget", name="Families Gadget", height=300, @@ -329,3 +354,10 @@ register(type="gadget", title="Shell", ) +register(type="gadget", + name="Python Gadget", + height=250, + content = ShellGadget, + title="Shell", + ) +