{"record":{"id":"59521d3561a922cf","repo":"elkowar/eww","slug":"error-trying-to-add-multiple-children-to-a-circul-59521d","errorCode":null,"errorMessage":"Error, trying to add multiple children to a circular-progress widget","messagePattern":"Error, trying to add multiple children to a circular-progress widget","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/eww/src/widgets/transform.rs","lineNumber":129,"sourceCode":"}\n\nimpl Default for Transform {\n    fn default() -> Self {\n        Self::new()\n    }\n}\n\nimpl Transform {\n    pub fn new() -> Self {\n        glib::Object::new::<Self>()\n    }\n}\n\nimpl ContainerImpl for TransformPriv {\n    fn add(&self, widget: &gtk::Widget) {\n        if let Some(content) = &*self.content.borrow() {\n            // TODO: Handle this error when populating children widgets instead\n            error_handling_ctx::print_error(anyhow!(\"Error, trying to add multiple children to a circular-progress widget\"));\n            self.parent_remove(content);\n        }\n        self.parent_add(widget);\n        self.content.replace(Some(widget.clone()));\n    }\n}\n\nimpl BinImpl for TransformPriv {}\nimpl WidgetImpl for TransformPriv {\n    fn draw(&self, cr: &gtk::cairo::Context) -> glib::Propagation {\n        let res: Result<()> = (|| {\n            let rotate = *self.rotate.borrow();\n            let total_width = self.obj().allocated_width() as f64;\n            let total_height = self.obj().allocated_height() as f64;\n\n            cr.save()?;\n\n            let transform_origin_x = match &*self.transform_origin_x.borrow() {","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/elkowar/eww/blob/48f5aa8b379adf29da0b0bb9ca04164f65d8bdaa/crates/eww/src/widgets/transform.rs#L111-L147","documentation":"The TransformPriv container (used by widgets like circular-progress) holds at most one child. When `add` is called while a content child already exists, eww logs this error and removes the previous child via `parent_remove` before adding the new one. It prevents silently stacking multiple children on a single-child widget.","triggerScenarios":"Calling `add` a second time on a TransformPriv/circular-progress widget that already has a content child; a config declaring more than one child inside a circular-progress widget.","commonSituations":"eww configs that nest two elements inside `circular-progress`; GTK populating children generically; code reusing the widget and re-adding content.","solutions":["Ensure the circular-progress/transform widget has exactly one child in your config (wrap multiple elements in a single `box` if needed).","If programmatically adding a new child, remove the old child first (though eww now does this automatically while logging the error).","Check for accidental duplicated child declarations in the widget markup."],"exampleFix":"// before\n(circular-progress\n  (label :text \"a\")\n  (label :text \"b\"))\n// after\n(circular-progress\n  (box :orientation \"v\"\n    (label :text \"a\")\n    (label :text \"b\")))","handlingStrategy":"validation","validationCode":"fn validate_single_child(node: &WidgetNode) -> Result<(), String> {\n    if node.children.len() > 1 {\n        return Err(format!(\"{} accepts exactly one child, got {}\", node.name, node.children.len()));\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wrap multiple children in a single `box` when using single-child widgets.","Count children in a config linter for circular-progress/transform widgets.","Avoid re-adding content to an already-populated widget instance."],"tags":[],"backgroundTag":null,"analyzedSha":"48f5aa8b379adf29da0b0bb9ca04164f65d8bdaa","analyzedAt":"2026-09-08T03:13:26.897Z","contentChangedAt":"2026-09-08T03:13:26.897Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}