diff options
author | Walter Bender <walter@sugarlabs.org> | 2014-02-11 18:01:38 (GMT) |
---|---|---|
committer | Walter Bender <walter@sugarlabs.org> | 2014-02-11 18:01:38 (GMT) |
commit | 11b7491d2862ffa7771dcb368b4d8b0f2205cd77 (patch) | |
tree | dabbb0adaca0f603892c0f9ce1f4f2176c7d8a67 | |
parent | e9c96f2eb5ccd66a4d3b43890c7ef27301adfb3c (diff) |
set tab label to file name when loading example code
-rw-r--r-- | notebook.py | 26 | ||||
-rw-r--r-- | pippy_app.py | 2 |
2 files changed, 26 insertions, 2 deletions
diff --git a/notebook.py b/notebook.py index 23b0be3..a2a65b5 100644 --- a/notebook.py +++ b/notebook.py @@ -1,3 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2014 Walter Bender +# Copyright (C) 2014 Sai Vineet +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + from gi.repository import Gtk from gi.repository import Gdk from gi.repository import GObject @@ -171,10 +189,14 @@ class SourceNotebook(AddNotebook): self) tablabel.connect("tab-close", self._tab_closed_cb) codesw.show_all() - index = self.append_page(codesw, - tablabel) + index = self.append_page(codesw, tablabel) self.props.page = index # Set new page as active tab + def set_current_label(self, label): + child = self.get_nth_page(self.get_current_page()) + widget = self.get_tab_label(child) + widget.set_text(self._purify_file(label)) + def get_text_buffer(self): tab = self.get_nth_page(self.get_current_page()).get_children() text_buffer = tab[0].get_buffer() diff --git a/pippy_app.py b/pippy_app.py index a35b175..ceba511 100644 --- a/pippy_app.py +++ b/pippy_app.py @@ -422,7 +422,9 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): self.metadata['title'] = value['name'] self.stopbutton_cb(None) self._reset_vte() + self.source_tabs.set_current_label(value['name']) self.source_tabs.get_text_view().grab_focus() + self.source_tabs.get_curret_page() def _select_func_cb(self, path): text_buffer = self.source_tabs.get_text_buffer() |