0

I am trying to make a GUI front-end to pacman using alpm. I recently found out that appstream can help me fetch icons, screenshots and all for a application. But I don't understand how do I do that. In the documentation for appstream there is struct AsIcon which defines information about a icon, like filename, url, size and all, but it has nothing like get_icon_for_app("app_name"). Please if someone can point me in the right direction it would be a great help. Some example code or something.

1 Answer 1

0

I started making progress on figuring this out, so I thought I would document it with a code snippet. Hopefully this will be helpful to people looking up this question.

//Create a new "pool" of metadata:
AsPool * pool = as_pool_new();

//Set the pool flags. In this case,
//I'm choosing the flag that tells it
//to load the Flatpak metadata from the standard location:
as_pool_set_flags(pool, AS_POOL_FLAG_LOAD_FLATPAK);

//Load the metadata.
//I'm supposed to pass objects for handling
//errors and cancellations, but I don't care
//right now and NULL works.
as_pool_load(pool, NULL, NULL);

//I'm getting a single component (read: app) by id,
//but it returns an array because there could be
//multiple repos with the same app, and if so it
//will return one component for each of them:
GPtrArray * components = as_pool_get_components_by_id(pool, "refname");

So that gives me a metadata pool and a component (app). From here I can use the methods to install, remove, get metadata, or whatever else I want. I think this can be a good starting point for interacting with the AppStream API.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.