work in progress
[src/app-framework-main.git] / src / wgt-info.c
index ddecb9a..61779e0 100644 (file)
@@ -334,7 +334,7 @@ static void dump_desc(struct wgt_desc *desc, FILE *f, const char *prefix)
        }
 }
 
-struct wgt_info *wgt_info_get(struct wgt *wgt, int icons, int features, int preferences)
+struct wgt_info *wgt_info_create(struct wgt *wgt, int icons, int features, int preferences)
 {
        int rc;
        struct wgt_info *result;
@@ -366,11 +366,30 @@ struct wgt_info *wgt_info_get(struct wgt *wgt, int icons, int features, int pref
        return result;
 }
 
+struct wgt_info *wgt_info_createat(int dirfd, const char *pathname, int icons, int features, int preferences)
+{
+       struct wgt_info *result = NULL;
+       struct wgt *wgt = wgt_createat(dirfd, pathname);
+       if (wgt) {
+               result = wgt_info_create(wgt, icons, features, preferences);
+               wgt_unref(wgt);
+       }
+       return result;
+}
+
 const struct wgt_desc *wgt_info_desc(struct wgt_info *ifo)
 {
+       assert(ifo);
        return &ifo->desc;
 }
 
+struct wgt *wgt_info_wgt(struct wgt_info *ifo)
+{
+       assert(ifo);
+       assert(ifo->wgt);
+       return ifo->wgt;
+}
+
 void wgt_info_addref(struct wgt_info *ifo)
 {
        assert(ifo);
@@ -404,3 +423,21 @@ void wgt_info_dump(struct wgt_info *ifo, int fd, const char *prefix)
        }
 }
 
+const struct wgt_desc_feature *wgt_info_feature(struct wgt_info *ifo, const char *name)
+{
+       const struct wgt_desc_feature *result = ifo->desc.features;
+       while(result && strcmp(result->name, name))
+               result = result->next;
+       return result;
+}
+
+const char *wgt_info_param(const struct wgt_desc_feature *feature, const char *name)
+{
+       const struct wgt_desc_param *param = feature->params;
+       while(param) {
+               if (0 == strcmp(name, param->name))
+                       return param->value;
+       }
+       return NULL;
+}
+