416 | | return |
417 | | # FIXME Bellow lines are commented in order to have journal access, |
418 | | # but we are facing an upstream bug with Vte.Terminal.get_text, |
419 | | # info on SL#3645, upstream gnome Bug #676999 |
420 | | # |
421 | | # if not self.metadata['mime_type']: |
422 | | # self.metadata['mime_type'] = 'text/plain' |
423 | | # |
424 | | # data = {} |
425 | | # data['current-tab'] = self._notebook.get_current_page() |
426 | | # data['tabs'] = [] |
427 | | # |
428 | | # for i in range(self._notebook.get_n_pages()): |
429 | | # page = self._notebook.get_nth_page(i) |
430 | | # |
431 | | # def selected_cb(terminal, c, row, cb_data): |
432 | | # return 1 |
433 | | # scrollback_text = page.vt.get_text(selected_cb, False) |
434 | | # |
435 | | # scrollback_lines = scrollback_text.split('\n') |
436 | | # |
437 | | # # Note- this currently gets the child's initial environment |
438 | | # # rather than the current environment, making it not very useful. |
439 | | # environment = open('/proc/%d/environ' % |
440 | | # page.pid, 'r').read().split('\0') |
441 | | # |
442 | | # cwd = os.readlink('/proc/%d/cwd' % page.pid) |
443 | | # |
444 | | # tab_state = {'env': environment, 'cwd': cwd, |
445 | | # 'scrollback': scrollback_lines} |
446 | | # |
447 | | # data['tabs'].append(tab_state) |
448 | | # |
449 | | # fd = open(file_path, 'w') |
450 | | # text = simplejson.dumps(data) |
451 | | # fd.write(text) |
452 | | # fd.close() |
| 416 | if not self.metadata['mime_type']: |
| 417 | self.metadata['mime_type'] = 'text/plain' |
| 418 | |
| 419 | data = {} |
| 420 | data['current-tab'] = self._notebook.get_current_page() |
| 421 | data['tabs'] = [] |
| 422 | |
| 423 | for i in range(self._notebook.get_n_pages()): |
| 424 | page = self._notebook.get_nth_page(i) |
| 425 | |
| 426 | def selected_cb(terminal, c, row, cb_data): |
| 427 | return 1 |
| 428 | scrollback_text = page.vt.get_text(selected_cb, False) |
| 429 | |
| 430 | scrollback_lines = scrollback_text[0].split('\n') |
| 431 | |
| 432 | # Note- this currently gets the child's initial environment |
| 433 | # rather than the current environment, making it not very useful. |
| 434 | environment = open('/proc/%d/environ' % |
| 435 | page.pid, 'r').read().split('\0') |
| 436 | |
| 437 | cwd = os.readlink('/proc/%d/cwd' % page.pid) |
| 438 | |
| 439 | tab_state = {'env': environment, 'cwd': cwd, |
| 440 | 'scrollback': scrollback_lines} |
| 441 | |
| 442 | data['tabs'].append(tab_state) |
| 443 | |
| 444 | fd = open(file_path, 'w') |
| 445 | text = simplejson.dumps(data) |
| 446 | fd.write(text) |
| 447 | fd.close() |