FIX: windows build process: enable png build
[navit-package] / navit / gui.c
index 3f4b931..8dc1dca 100644 (file)
@@ -31,6 +31,7 @@ struct gui {
        struct gui_methods meth;
        struct gui_priv *priv;
        struct attr **attrs;
+       struct attr parent;
 };
 
 struct gui *
@@ -38,7 +39,7 @@ gui_new(struct attr *parent, struct attr **attrs)
 {
        struct gui *this_;
        struct attr *type_attr;
-       struct gui_priv *(*guitype_new)(struct navit *nav, struct gui_methods *meth, struct attr **attrs);
+       struct gui_priv *(*guitype_new)(struct navit *nav, struct gui_methods *meth, struct attr **attrs, struct gui *gui);
        struct attr cbl;
        if (! (type_attr=attr_search(attrs, NULL, attr_type))) {
                return NULL;
@@ -53,16 +54,48 @@ gui_new(struct attr *parent, struct attr **attrs)
        cbl.type=attr_callback_list;
        cbl.u.callback_list=callback_list_new();
        this_->attrs=attr_generic_add_attr(this_->attrs, &cbl);
-       this_->priv=guitype_new(parent->u.navit, &this_->meth, this_->attrs);
+       this_->priv=guitype_new(parent->u.navit, &this_->meth, this_->attrs, this_);
+       this_->parent=*parent;
        return this_;
 }
 
 int
 gui_get_attr(struct gui *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
 {
+       int ret;
+       if (this_->meth.get_attr) {
+               ret=this_->meth.get_attr(this_->priv, type, attr);
+               if (ret)
+                       return ret;
+       }
+       if (type == this_->parent.type) {
+               *attr=this_->parent;
+               return 1;
+       }
        return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
 }
 
+
+int
+gui_set_attr(struct gui *this_, struct attr *attr)
+{
+       int ret=1;
+       if (this_->meth.set_attr)
+               ret=this_->meth.set_attr(this_->priv, attr);
+       if (ret == 1)
+               this_->attrs=attr_generic_set_attr(this_->attrs, attr);
+       return ret != 0;
+}
+
+int
+gui_add_attr(struct gui *this_, struct attr *attr)
+{
+       int ret=0;
+       if (this_->meth.add_attr) 
+               ret=this_->meth.add_attr(this_->priv, attr);
+       return ret;
+}
+
 struct menu *
 gui_menubar_new(struct gui *gui)
 {