diff --git a/src/SymbolPane/SymbolOutline.vala b/src/SymbolPane/SymbolOutline.vala index eed99485a..3752219e9 100644 --- a/src/SymbolPane/SymbolOutline.vala +++ b/src/SymbolPane/SymbolOutline.vala @@ -87,6 +87,7 @@ public class Scratch.Services.SymbolOutline : Gtk.Box { } public virtual void parse_symbols () {} + public virtual void add_tooltips (Code.Widgets.SourceList.ExpandableItem root) {} Gtk.MenuButton filter_button; diff --git a/src/SymbolPane/Vala/ValaSymbolOutline.vala b/src/SymbolPane/Vala/ValaSymbolOutline.vala index 49a96edb4..9b038aa42 100644 --- a/src/SymbolPane/Vala/ValaSymbolOutline.vala +++ b/src/SymbolPane/Vala/ValaSymbolOutline.vala @@ -133,8 +133,8 @@ public class Scratch.Services.ValaSymbolOutline : Scratch.Services.SymbolOutline } store.root.expand_all (); + add_tooltips (store.root); store.vadjustment.set_value (adjustment_value); - return false; }); } else { @@ -145,6 +145,30 @@ public class Scratch.Services.ValaSymbolOutline : Scratch.Services.SymbolOutline }); } + protected override void add_tooltips (Code.Widgets.SourceList.ExpandableItem root) { + foreach (var parent in root.children) { + add_tooltip ((Code.Widgets.SourceList.ExpandableItem) parent); + } + } + + private void add_tooltip (Code.Widgets.SourceList.ExpandableItem parent) { + if (parent is ValaSymbolItem) { + var item = ((ValaSymbolItem)parent); + var symbol = item.symbol; + item.tooltip = "%s%s".printf ( + doc.get_slice ( + symbol.source_reference.begin.line, + symbol.source_reference.begin.column, + symbol.source_reference.end.line, + symbol.source_reference.end.column + ), + symbol.comment != null ? "\n" + symbol.comment.content : "" + ); + } + + add_tooltips (parent); + } + private void destroy_all_children (Code.Widgets.SourceList.ExpandableItem parent) { foreach (var child in parent.children) { remove (child, parent); @@ -177,7 +201,9 @@ public class Scratch.Services.ValaSymbolOutline : Scratch.Services.SymbolOutline continue; construct_child (symbol, new_root, cancellable); - Thread.yield (); + if (!cancellable.is_cancelled ()) { + Thread.yield (); + } } return new_root; @@ -199,19 +225,10 @@ public class Scratch.Services.ValaSymbolOutline : Scratch.Services.SymbolOutline parent = construct_child (symbol.scope.parent_scope.owner, given_parent, cancellable); } - var tooltip = "%s%s".printf ( - doc.get_slice ( - symbol.source_reference.begin.line, - symbol.source_reference.begin.column, - symbol.source_reference.end.line, - symbol.source_reference.end.column - ), - symbol.comment != null ? "\n" + symbol.comment.content : "" - ); var tree_child = new ValaSymbolItem ( symbol, - tooltip + "" ); parent.add (tree_child); return tree_child;