From 2e7201cfb7361d2b59fd53ea9a3241f0cc788940 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 17 Jul 2025 18:36:11 +0100 Subject: [PATCH 1/2] Override add_tooltip(s) for CtagsSymbolOutline --- src/SymbolPane/C/CtagsSymbolOutline.vala | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/SymbolPane/C/CtagsSymbolOutline.vala b/src/SymbolPane/C/CtagsSymbolOutline.vala index 92b540cde..101606306 100644 --- a/src/SymbolPane/C/CtagsSymbolOutline.vala +++ b/src/SymbolPane/C/CtagsSymbolOutline.vala @@ -275,10 +275,35 @@ public class Scratch.Services.CtagsSymbolOutline : Scratch.Services.SymbolOutlin destroy_root (root); root = new_root; + add_tooltips (store.root); return false; }); } + protected override void add_tooltips (Code.Widgets.SourceList.ExpandableItem root) { + foreach (var parent in root.children) { + if (parent is Code.Widgets.SourceList.ExpandableItem) { + add_tooltip ((Code.Widgets.SourceList.ExpandableItem) parent); + } + } + } + + private void add_tooltip (Code.Widgets.SourceList.ExpandableItem parent) { + if (parent is CtagsSymbol) { + var item = ((CtagsSymbol)parent); + item.tooltip = Markup.escape_text ("%s".printf ( + doc.get_slice ( + item.line, + 0, + item.line, + 0 + ) + )); + } + + add_tooltips (parent); + } + private void destroy_root (Code.Widgets.SourceList.ExpandableItem to_destroy) { var children = iterate_children (to_destroy); to_destroy.clear (); From d6bb7b6afa1ac75e9101117ef9735622ec25c259 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 17 Jul 2025 18:55:40 +0100 Subject: [PATCH 2/2] Look on previous line for method type --- src/SymbolPane/C/CtagsSymbolOutline.vala | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/SymbolPane/C/CtagsSymbolOutline.vala b/src/SymbolPane/C/CtagsSymbolOutline.vala index 101606306..888f572b3 100644 --- a/src/SymbolPane/C/CtagsSymbolOutline.vala +++ b/src/SymbolPane/C/CtagsSymbolOutline.vala @@ -291,11 +291,18 @@ public class Scratch.Services.CtagsSymbolOutline : Scratch.Services.SymbolOutlin private void add_tooltip (Code.Widgets.SourceList.ExpandableItem parent) { if (parent is CtagsSymbol) { var item = ((CtagsSymbol)parent); + var start = item.line; + var end = item.line; + // The type of a method is often on the previous line + if (item.symbol_type == SymbolType.METHOD) { + start = start > 0 ? start - 1 : start; + } + item.tooltip = Markup.escape_text ("%s".printf ( doc.get_slice ( - item.line, + start, 0, - item.line, + end, 0 ) ));