Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Schampijer <simon@laptop.org>2012-11-03 14:17:09 (GMT)
committer Daniel Francis <francis@sugarlabs.org>2013-05-29 20:15:27 (GMT)
commitb90dac1ad2b8916b123e71b73848636f83fa9fe7 (patch)
treedcbc519123f8d30ac8c64a5e079399cea50679f4
parent74097db3becc980b68b29b2c51a740934e85adc5 (diff)
Get back a working activity history, SL #4131
Because of the get_text* methods to not be introspectable the functionality to store the activity session data was disabled (no tabs and respective terminal history). The upstream bug [1] will be fixed so this patch does do the following: - uncomment the riginal code - vte_terminal_fork_command_full will return a boolean indicating success and the pid - vte_terminal_get_text will return a tuple and only the first argument is the scrollback_text [1] https://bugzilla.gnome.org/show_bug.cgi?id=676999 [2] http://git.gnome.org/browse/vte/tree/src/vte.c#n3820 Signed-off-by: Simon Schampijer <simon@laptop.org> Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r--terminal.py88
1 files changed, 42 insertions, 46 deletions
diff --git a/terminal.py b/terminal.py
index 521f9be..0ee2b7a 100644
--- a/terminal.py
+++ b/terminal.py
@@ -339,15 +339,15 @@ class TerminalActivity(activity.Activity):
# Restore the scrollback buffer.
for l in tab_state['scrollback']:
- vt.feed(l + '\r\n')
-
- box.pid = vt.fork_command_full(Vte.PtyFlags.DEFAULT,
- os.environ["HOME"],
- ["/bin/bash"],
- [],
- GLib.SpawnFlags.DO_NOT_REAP_CHILD,
- None,
- None)
+ vt.feed(str(l) + '\r\n')
+
+ sucess_, box.pid = vt.fork_command_full(Vte.PtyFlags.DEFAULT,
+ os.environ["HOME"],
+ ["/bin/bash"],
+ [],
+ GLib.SpawnFlags.DO_NOT_REAP_CHILD,
+ None,
+ None)
self._notebook.props.page = index
vt.grab_focus()
@@ -413,43 +413,39 @@ class TerminalActivity(activity.Activity):
self._next_tab_button.props.sensitive = True
def write_file(self, file_path):
- return
-# FIXME Bellow lines are commented in order to have journal access,
-# but we are facing an upstream bug with Vte.Terminal.get_text,
-# info on SL#3645, upstream gnome Bug #676999
-#
-# if not self.metadata['mime_type']:
-# self.metadata['mime_type'] = 'text/plain'
-#
-# data = {}
-# data['current-tab'] = self._notebook.get_current_page()
-# data['tabs'] = []
-#
-# for i in range(self._notebook.get_n_pages()):
-# page = self._notebook.get_nth_page(i)
-#
-# def selected_cb(terminal, c, row, cb_data):
-# return 1
-# scrollback_text = page.vt.get_text(selected_cb, False)
-#
-# scrollback_lines = scrollback_text.split('\n')
-#
-# # Note- this currently gets the child's initial environment
-# # rather than the current environment, making it not very useful.
-# environment = open('/proc/%d/environ' %
-# page.pid, 'r').read().split('\0')
-#
-# cwd = os.readlink('/proc/%d/cwd' % page.pid)
-#
-# tab_state = {'env': environment, 'cwd': cwd,
-# 'scrollback': scrollback_lines}
-#
-# data['tabs'].append(tab_state)
-#
-# fd = open(file_path, 'w')
-# text = json.dumps(data)
-# fd.write(text)
-# fd.close()
+ if not self.metadata['mime_type']:
+ self.metadata['mime_type'] = 'text/plain'
+
+ data = {}
+ data['current-tab'] = self._notebook.get_current_page()
+ data['tabs'] = []
+
+ for i in range(self._notebook.get_n_pages()):
+
+ def is_selected(vte, *args):
+ return True
+
+ page = self._notebook.get_nth_page(i)
+ text, attr = page.vt.get_text(is_selected, None)
+
+ scrollback_lines = text.split('\n')
+
+ # Note- this currently gets the child's initial environment
+ # rather than the current environment, making it not very useful.
+ environment = open('/proc/%d/environ' %
+ page.pid, 'r').read().split('\0')
+
+ cwd = os.readlink('/proc/%d/cwd' % page.pid)
+
+ tab_state = {'env': environment, 'cwd': cwd,
+ 'scrollback': scrollback_lines}
+
+ data['tabs'].append(tab_state)
+
+ fd = open(file_path, 'w')
+ text = json.dumps(data)
+ fd.write(text)
+ fd.close()
def _get_conf(self, conf, var, default):
if conf.has_option('terminal', var):