Problem
sync_sidebar_widgets() has a 30+ line match p { SidebarPanel::Git => { da.grab_focus() } ... } block that maps each panel variant to its DrawingArea ref for focus grab, plus a parallel loop for panel box visibility. Every new panel requires adding another arm.
Proposed fix
Store panel DAs in a HashMap<&str, Rc<RefCell<Option<DrawingArea>>>> keyed by panel ID string (e.g. "panel:git" → git_sidebar_da_ref). The focus-grab and visibility loops become a single lookup:
if let Some(da_ref) = self.panel_da_map.get(panel_id) {
if let Some(ref da) = *da_ref.borrow() {
da.grab_focus();
}
}
Same for panel box visibility — a parallel panel_box_map.
Context
Identified during #385 GTK sidebar migration (Session 375). The match arms are boilerplate that scales linearly with panel count.
Problem
sync_sidebar_widgets()has a 30+ linematch p { SidebarPanel::Git => { da.grab_focus() } ... }block that maps each panel variant to its DrawingArea ref for focus grab, plus a parallel loop for panel box visibility. Every new panel requires adding another arm.Proposed fix
Store panel DAs in a
HashMap<&str, Rc<RefCell<Option<DrawingArea>>>>keyed by panel ID string (e.g."panel:git"→git_sidebar_da_ref). The focus-grab and visibility loops become a single lookup:Same for panel box visibility — a parallel
panel_box_map.Context
Identified during #385 GTK sidebar migration (Session 375). The match arms are boilerplate that scales linearly with panel count.