forked from Mirrors/flatpak-builder
lib: Change how listing installed refs work
Now we return a GPtrArray, and the main call returns both apps and runtimes, and a new _by_kind version lets you get only a specific one.tingping/wmclass
parent
dd7693b99e
commit
b9c582bc75
|
@ -18,11 +18,9 @@ int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
XdgAppInstallation *installation;
|
XdgAppInstallation *installation;
|
||||||
XdgAppInstalledRef **apps;
|
|
||||||
XdgAppRemoteRef **refs;
|
XdgAppRemoteRef **refs;
|
||||||
XdgAppInstalledRef *app1;
|
XdgAppInstalledRef *app1;
|
||||||
XdgAppInstalledRef *app2;
|
XdgAppInstalledRef *app2;
|
||||||
XdgAppInstalledRef **runtimes;
|
|
||||||
XdgAppRemoteRef *remote_ref;
|
XdgAppRemoteRef *remote_ref;
|
||||||
XdgAppRemote **remotes;
|
XdgAppRemote **remotes;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
@ -65,42 +63,75 @@ main (int argc, char *argv[])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_print ("**** Listing all installed apps\n");
|
g_print ("\n**** Listing all installed refs\n");
|
||||||
apps = xdg_app_installation_list_installed_refs (installation,
|
{
|
||||||
XDG_APP_REF_KIND_APP,
|
g_autoptr(GPtrArray) refs = NULL;
|
||||||
NULL, NULL);
|
|
||||||
|
|
||||||
for (i = 0; apps[i] != NULL; i++)
|
refs = xdg_app_installation_list_installed_refs (installation,
|
||||||
{
|
NULL, NULL);
|
||||||
g_print ("%d %s %s %s %s %s %s %d\n",
|
|
||||||
xdg_app_ref_get_kind (XDG_APP_REF(apps[i])),
|
for (i = 0; i < refs->len; i++)
|
||||||
xdg_app_ref_get_name (XDG_APP_REF(apps[i])),
|
{
|
||||||
xdg_app_ref_get_arch (XDG_APP_REF(apps[i])),
|
XdgAppInstalledRef *ref = g_ptr_array_index(refs,i);
|
||||||
xdg_app_ref_get_version (XDG_APP_REF(apps[i])),
|
g_print ("%d %s %s %s %s %s %s %d\n",
|
||||||
xdg_app_ref_get_commit (XDG_APP_REF(apps[i])),
|
xdg_app_ref_get_kind (XDG_APP_REF(ref)),
|
||||||
xdg_app_installed_ref_get_origin (apps[i]),
|
xdg_app_ref_get_name (XDG_APP_REF(ref)),
|
||||||
xdg_app_installed_ref_get_deploy_dir (apps[i]),
|
xdg_app_ref_get_arch (XDG_APP_REF(ref)),
|
||||||
xdg_app_installed_ref_get_current (apps[i]));
|
xdg_app_ref_get_version (XDG_APP_REF(ref)),
|
||||||
g_print ("metadata:\n%s\n", xdg_app_installed_ref_load_metadata (apps[i], NULL, NULL));
|
xdg_app_ref_get_commit (XDG_APP_REF(ref)),
|
||||||
}
|
xdg_app_installed_ref_get_origin (ref),
|
||||||
|
xdg_app_installed_ref_get_deploy_dir (ref),
|
||||||
|
xdg_app_installed_ref_get_current (ref));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_print ("**** Listing all installed apps\n");
|
||||||
|
{
|
||||||
|
g_autoptr(GPtrArray) apps = NULL;
|
||||||
|
|
||||||
|
apps = xdg_app_installation_list_installed_refs_by_kind (installation,
|
||||||
|
XDG_APP_REF_KIND_APP,
|
||||||
|
NULL, NULL);
|
||||||
|
|
||||||
|
for (i = 0; i < apps->len; i++)
|
||||||
|
{
|
||||||
|
XdgAppInstalledRef *app = g_ptr_array_index(apps,i);
|
||||||
|
|
||||||
|
g_print ("%d %s %s %s %s %s %s %d\n",
|
||||||
|
xdg_app_ref_get_kind (XDG_APP_REF(app)),
|
||||||
|
xdg_app_ref_get_name (XDG_APP_REF(app)),
|
||||||
|
xdg_app_ref_get_arch (XDG_APP_REF(app)),
|
||||||
|
xdg_app_ref_get_version (XDG_APP_REF(app)),
|
||||||
|
xdg_app_ref_get_commit (XDG_APP_REF(app)),
|
||||||
|
xdg_app_installed_ref_get_origin (app),
|
||||||
|
xdg_app_installed_ref_get_deploy_dir (app),
|
||||||
|
xdg_app_installed_ref_get_current (app));
|
||||||
|
g_print ("metadata:\n%s\n", xdg_app_installed_ref_load_metadata (app, NULL, NULL));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_print ("\n**** Listing all installed runtimes\n");
|
g_print ("\n**** Listing all installed runtimes\n");
|
||||||
runtimes = xdg_app_installation_list_installed_refs (installation,
|
{
|
||||||
XDG_APP_REF_KIND_RUNTIME,
|
g_autoptr(GPtrArray) runtimes = NULL;
|
||||||
NULL, NULL);
|
|
||||||
|
|
||||||
for (i = 0; runtimes[i] != NULL; i++)
|
runtimes = xdg_app_installation_list_installed_refs_by_kind (installation,
|
||||||
{
|
XDG_APP_REF_KIND_RUNTIME,
|
||||||
g_print ("%d %s %s %s %s %s %s %d\n",
|
NULL, NULL);
|
||||||
xdg_app_ref_get_kind (XDG_APP_REF(runtimes[i])),
|
|
||||||
xdg_app_ref_get_name (XDG_APP_REF(runtimes[i])),
|
for (i = 0; i < runtimes->len; i++)
|
||||||
xdg_app_ref_get_arch (XDG_APP_REF(runtimes[i])),
|
{
|
||||||
xdg_app_ref_get_version (XDG_APP_REF(runtimes[i])),
|
XdgAppInstalledRef *runtime = g_ptr_array_index(runtimes,i);
|
||||||
xdg_app_ref_get_commit (XDG_APP_REF(runtimes[i])),
|
g_print ("%d %s %s %s %s %s %s %d\n",
|
||||||
xdg_app_installed_ref_get_origin (runtimes[i]),
|
xdg_app_ref_get_kind (XDG_APP_REF(runtime)),
|
||||||
xdg_app_installed_ref_get_deploy_dir (runtimes[i]),
|
xdg_app_ref_get_name (XDG_APP_REF(runtime)),
|
||||||
xdg_app_installed_ref_get_current (runtimes[i]));
|
xdg_app_ref_get_arch (XDG_APP_REF(runtime)),
|
||||||
}
|
xdg_app_ref_get_version (XDG_APP_REF(runtime)),
|
||||||
|
xdg_app_ref_get_commit (XDG_APP_REF(runtime)),
|
||||||
|
xdg_app_installed_ref_get_origin (runtime),
|
||||||
|
xdg_app_installed_ref_get_deploy_dir (runtime),
|
||||||
|
xdg_app_installed_ref_get_current (runtime));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_print ("\n**** Getting installed gedit master\n");
|
g_print ("\n**** Getting installed gedit master\n");
|
||||||
app1 = xdg_app_installation_get_installed_ref (installation,
|
app1 = xdg_app_installation_get_installed_ref (installation,
|
||||||
|
|
|
@ -263,20 +263,65 @@ xdg_app_installation_get_current_installed_app (XdgAppInstallation *self,
|
||||||
/**
|
/**
|
||||||
* xdg_app_installation_list_installed_refs:
|
* xdg_app_installation_list_installed_refs:
|
||||||
* @self: a #XdgAppInstallation
|
* @self: a #XdgAppInstallation
|
||||||
* @kind: the kind of installation
|
|
||||||
* @cancellable: (nullable): a #GCancellable
|
* @cancellable: (nullable): a #GCancellable
|
||||||
* @error: return location for a #GError
|
* @error: return location for a #GError
|
||||||
*
|
*
|
||||||
* Lists the installed references.
|
* Lists the installed references.
|
||||||
*
|
*
|
||||||
* Returns: (transfer full) (array zero-terminated=1): an array of
|
* Returns: (transfer container) (element-type XdgAppInstalledRef): an GPtrArray of
|
||||||
* #XdgAppInstalledRef instances
|
* #XdgAppInstalledRef instances
|
||||||
*/
|
*/
|
||||||
XdgAppInstalledRef **
|
GPtrArray *
|
||||||
xdg_app_installation_list_installed_refs (XdgAppInstallation *self,
|
xdg_app_installation_list_installed_refs (XdgAppInstallation *self,
|
||||||
XdgAppRefKind kind,
|
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
|
{
|
||||||
|
XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self);
|
||||||
|
g_auto(GStrv) raw_refs_app = NULL;
|
||||||
|
g_auto(GStrv) raw_refs_runtime = NULL;
|
||||||
|
g_autoptr(GPtrArray) refs = g_ptr_array_new_with_free_func (g_object_unref);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (!xdg_app_dir_list_refs (priv->dir,
|
||||||
|
"app",
|
||||||
|
&raw_refs_app,
|
||||||
|
cancellable, error))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 0; raw_refs_app[i] != NULL; i++)
|
||||||
|
g_ptr_array_add (refs,
|
||||||
|
get_ref (self, raw_refs_app[i], cancellable));
|
||||||
|
|
||||||
|
if (!xdg_app_dir_list_refs (priv->dir,
|
||||||
|
"runtime",
|
||||||
|
&raw_refs_runtime,
|
||||||
|
cancellable, error))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 0; raw_refs_runtime[i] != NULL; i++)
|
||||||
|
g_ptr_array_add (refs,
|
||||||
|
get_ref (self, raw_refs_runtime[i], cancellable));
|
||||||
|
|
||||||
|
return g_steal_pointer (&refs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xdg_app_installation_list_installed_refs_by_kind:
|
||||||
|
* @self: a #XdgAppInstallation
|
||||||
|
* @kind: the kind of installation
|
||||||
|
* @cancellable: (nullable): a #GCancellable
|
||||||
|
* @error: return location for a #GError
|
||||||
|
*
|
||||||
|
* Lists the installed references of a specific kind.
|
||||||
|
*
|
||||||
|
* Returns: (transfer container) (element-type XdgAppInstalledRef): an GPtrArray of
|
||||||
|
* #XdgAppInstalledRef instances
|
||||||
|
*/
|
||||||
|
GPtrArray *
|
||||||
|
xdg_app_installation_list_installed_refs_by_kind (XdgAppInstallation *self,
|
||||||
|
XdgAppRefKind kind,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self);
|
XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self);
|
||||||
g_auto(GStrv) raw_refs = NULL;
|
g_auto(GStrv) raw_refs = NULL;
|
||||||
|
@ -293,8 +338,7 @@ xdg_app_installation_list_installed_refs (XdgAppInstallation *self,
|
||||||
g_ptr_array_add (refs,
|
g_ptr_array_add (refs,
|
||||||
get_ref (self, raw_refs[i], cancellable));
|
get_ref (self, raw_refs[i], cancellable));
|
||||||
|
|
||||||
g_ptr_array_add (refs, NULL);
|
return g_steal_pointer (&refs);
|
||||||
return (XdgAppInstalledRef **)g_ptr_array_free (g_steal_pointer (&refs), FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -61,7 +61,10 @@ typedef void (*XdgAppProgressCallback)(const char *status,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
XDG_APP_EXTERN gboolean xdg_app_installation_get_is_user (XdgAppInstallation *self);
|
XDG_APP_EXTERN gboolean xdg_app_installation_get_is_user (XdgAppInstallation *self);
|
||||||
XDG_APP_EXTERN XdgAppInstalledRef **xdg_app_installation_list_installed_refs (XdgAppInstallation *self,
|
XDG_APP_EXTERN GPtrArray *xdg_app_installation_list_installed_refs (XdgAppInstallation *self,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error);
|
||||||
|
XDG_APP_EXTERN GPtrArray *xdg_app_installation_list_installed_refs_by_kind (XdgAppInstallation *self,
|
||||||
XdgAppRefKind kind,
|
XdgAppRefKind kind,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
Loading…
Reference in New Issue