elkowar/eww · error

Error, Graph widget shoudln't have any children

Error message

Error, Graph widget shoudln't have any children

What it means

Eww's Graph widget is implemented as a GTK container only to satisfy GTK's widget protocol, but it draws its values itself and must never receive child widgets. When GTK (or user code) calls `add` on the Graph container, eww immediately routes the call into the error-handling context instead of accepting the child. This is an internal-invariant guard against a structurally invalid widget tree.

Solutions

  1. Remove any child widgets nested inside the `graph` element in your eww config; graph takes only its `value` attribute.
  2. If writing Rust code against the widget, do not call `.add()` on a Graph instance.
  3. Feed the graph data via its `:value` attribute / script var instead of child widgets.

Example fix

// before
(graph :value x
  (box :orientation "h" (label :text "hi")))
// after
(graph :value x)
Defensive patterns

Strategy: validation

Validate before calling

fn validate_graph_config(node: &WidgetNode) -> Result<(), String> {
    if !node.children.is_empty() {
        return Err("graph widget must not have children; use the `value` attribute instead".into());
    }
    Ok(())
}

Prevention

When it happens

Trigger: Calling `add` (or `ContainerExt::add`) on a GraphPriv/Graph widget instance; a config nesting children inside a `graph` widget declaration.

Common situations: Users write eww config XML/YAML that places a child (text, box, etc.) inside a `graph` widget; library code that generically adds children to all containers.


AI-assisted analysis of elkowar/eww@48f5aa8b37 (2026-09-08). Data as JSON: /api/errors/dc0d31254405fc8f. Report an issue: GitHub.

Appendix: source

Thrown at crates/eww/src/widgets/graph.rs:177

        klass.set_css_name("graph");
    }
}

impl Default for Graph {
    fn default() -> Self {
        Self::new()
    }
}

impl Graph {
    pub fn new() -> Self {
        glib::Object::new::<Self>()
    }
}

impl ContainerImpl for GraphPriv {
    fn add(&self, _widget: &gtk::Widget) {
        error_handling_ctx::print_error(anyhow!("Error, Graph widget shoudln't have any children"));
    }
}

impl BinImpl for GraphPriv {}
impl WidgetImpl for GraphPriv {
    fn preferred_width(&self) -> (i32, i32) {
        let thickness = *self.thickness.borrow() as i32;
        (thickness, thickness)
    }

    fn preferred_width_for_height(&self, height: i32) -> (i32, i32) {
        (height, height)
    }

    fn preferred_height(&self) -> (i32, i32) {
        let thickness = *self.thickness.borrow() as i32;
        (thickness, thickness)
    }

View on GitHub (pinned to 48f5aa8b37)