[gnome-builder] todo: remove previous entries when saving buffer
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] todo: remove previous entries when saving buffer
- Date: Tue, 26 Jan 2016 03:52:50 +0000 (UTC)
commit 6817c002a0352d35a72e34e6b0b32a608e4c8525
Author: Christian Hergert <chergert redhat com>
Date: Tue Jan 26 04:43:53 2016 +0100
todo: remove previous entries when saving buffer
When we save a file, walk through the list of items in the treeview.
Remove any file that matches the GFile that was just saved.
Afterwards, parse TODO items as normal, re-populating the treeview.
https://bugzilla.gnome.org/review?bug=760728
plugins/todo/todo_plugin/__init__.py | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/plugins/todo/todo_plugin/__init__.py b/plugins/todo/todo_plugin/__init__.py
index f091e41..672b533 100644
--- a/plugins/todo/todo_plugin/__init__.py
+++ b/plugins/todo/todo_plugin/__init__.py
@@ -72,7 +72,8 @@ class TodoWorkbenchAddin(GObject.Object, Ide.WorkbenchAddin):
# Get the underline GFile
file = buf.get_file().get_file()
- # XXX: Clear existing items from this file
+ # Clear any existing items matching this file
+ self.panel.clear_file(file)
# Mine the file for todo items
self.mine(file)
@@ -203,6 +204,18 @@ class TodoPanel(Gtk.Bin):
iter = self.model.append()
self.model.set_value(iter, 0, item)
+ def clear_file(self, file):
+ iter = self.model.get_iter_first()
+ while iter != None:
+ todo_item, = self.model.get(iter, 0)
+ if todo_item.props.file.equal(file):
+ # If remove() returns false, it was the last item in the store.
+ # Otherwise, iter was advanced for us.
+ if not self.model.remove(iter):
+ break
+ continue
+ iter = self.model.iter_next(iter)
+
def on_query_tooltip(self, treeview, x, y, keyboard, tooltip):
x, y = treeview.convert_widget_to_bin_window_coords(x, y)
try:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]