diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2014-02-10 20:30:14 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2014-02-10 20:30:14 (GMT) |
commit | fe8192c40935cfb51f3e61c5ced886770daa5e1d (patch) | |
tree | c5a8a2605857fa8b4bd2b411234e3acf91f236e5 | |
parent | 46fc8d20c655975a8119edb9b33d6a45b44240e7 (diff) |
Fix upate the tree when the tab is selected
-rw-r--r-- | develop-activity/develop_app.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/develop-activity/develop_app.py b/develop-activity/develop_app.py index 07ee850..066f456 100644 --- a/develop-activity/develop_app.py +++ b/develop-activity/develop_app.py @@ -589,14 +589,9 @@ class DevelopActivity(activity.Activity): #avoid infinite recursion return if isinstance(page, sourceview_editor.GtkSourceview2Page): - source = page.full_path - tree_iter = self.model.get_iter_from_filepath(source) - if tree_iter: - tree_selection = self.treeview.get_selection() - tree_selection.unselect_all() - self.numb = True - tree_selection.select_iter(tree_iter) - self.numb = False + self.numb = True + self.activity_tree_view.select_by_file_path(page.full_path) + self.numb = False def __create_empty_file_cb(self, button): alert = Alert() @@ -691,6 +686,8 @@ class FileViewer(Gtk.ScrolledWindow): self._column.add_attribute(cell, 'text', 0) self._tree_view.append_column(self._column) self._tree_view.set_search_column(0) + # map between file_path and iter + self._opened_files = {} def load_activity(self, path, bundle): self._search_initial_filename(path, bundle) @@ -721,6 +718,7 @@ class FileViewer(Gtk.ScrolledWindow): file_path = None else: file_path = model.get_value(tree_iter, 1) + self._opened_files[file_path] = tree_iter self.emit('file-selected', file_path) def __cursor_changed_cb(self, treeview): @@ -736,6 +734,13 @@ class FileViewer(Gtk.ScrolledWindow): else: treeview.expand_row(path, False) + def select_by_file_path(self, file_path): + if file_path in self._opened_files: + tree_iter = self._opened_files[file_path] + tree_selection = self._tree_view.get_selection() + tree_selection.unselect_all() + tree_selection.select_iter(tree_iter) + def _search_initial_filename(self, activity_path, bundle): command = bundle.get_command() |