@@ -69,6 +69,7 @@ public class Scratch.Services.SymbolOutline : Gtk.Box {
6969 const string ACTION_PREFIX = ACTION_GROUP + " ." ;
7070 const string ACTION_SELECT = " action-select" ;
7171 const string ACTION_TOGGLE = " toggle-" ;
72+ const uint SPINNER_DELAY_MSEC = 300 ;
7273 SimpleActionGroup symbol_action_group;
7374
7475 public Scratch . Services . Document doc { get ; construct; }
@@ -86,10 +87,36 @@ public class Scratch.Services.SymbolOutline : Gtk.Box {
8687 }
8788 }
8889
90+ protected bool took_too_long;
91+ private uint show_spinner_timeout_id = 0 ;
92+ protected void before_parse () {
93+ tool_box_sensitive = true ;
94+ took_too_long = false ;
95+ show_spinner_timeout_id = Timeout . add (SPINNER_DELAY_MSEC , () = > {
96+ show_spinner_timeout_id = 0 ;
97+ stack. visible_child = spinner;
98+ spinner. start ();
99+ return Source . REMOVE ;
100+ });
101+ }
102+
103+ protected void after_parse () {
104+ if (show_spinner_timeout_id > 0 ) {
105+ Source . remove (show_spinner_timeout_id);
106+ show_spinner_timeout_id = 0 ;
107+ }
108+
109+ spinner. stop ();
110+ stack. visible_child = filter_button;
111+ tool_box_sensitive = ! took_too_long;
112+ }
113+
89114 public virtual void parse_symbols () {}
90115 public virtual void add_tooltips (Code .Widgets .SourceList .ExpandableItem root ) {}
91116
92- Gtk . MenuButton filter_button;
117+ private Gtk . MenuButton filter_button;
118+ private Gtk . Spinner spinner;
119+ private Gtk . Stack stack;
93120
94121 construct {
95122 symbol_action_group = new SimpleActionGroup ();
@@ -145,9 +172,15 @@ public class Scratch.Services.SymbolOutline : Gtk.Box {
145172
146173 filter_button. menu_model = top_model;
147174
175+ spinner = new Gtk .Spinner ();
176+ stack = new Gtk .Stack ();
177+ stack.add (filter_button );
178+ stack.add (spinner );
179+ stack. visible_child = filter_button;
180+
148181 var tool_box = new Gtk .Box (HORIZONTAL , 3 );
149182 tool_box.add (search_entry );
150- tool_box.add (filter_button );
183+ tool_box.add (stack );
151184 add (tool_box );
152185 add (store );
153186 set_up_css ();
0 commit comments