forked from Mirrors/flatpak-builder
lib: Move app launching to XdgAppInstallation
parent
e7903a8033
commit
874fce2b77
|
@ -299,9 +299,6 @@ xdg_app_compose_ref (gboolean app,
|
|||
const char *arch,
|
||||
GError **error)
|
||||
{
|
||||
if (branch == NULL)
|
||||
branch = "master";
|
||||
|
||||
if (!xdg_app_is_valid_name (name))
|
||||
{
|
||||
if (app)
|
||||
|
@ -311,7 +308,7 @@ xdg_app_compose_ref (gboolean app,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (!xdg_app_is_valid_branch (branch))
|
||||
if (branch && !xdg_app_is_valid_branch (branch))
|
||||
{
|
||||
xdg_app_fail (error, "'%s' is not a valid branch name", branch);
|
||||
return NULL;
|
||||
|
@ -339,6 +336,9 @@ xdg_app_build_runtime_ref (const char *runtime,
|
|||
const char *branch,
|
||||
const char *arch)
|
||||
{
|
||||
if (branch == NULL)
|
||||
branch = "master";
|
||||
|
||||
if (arch == NULL)
|
||||
arch = xdg_app_get_arch ();
|
||||
|
||||
|
@ -350,6 +350,9 @@ xdg_app_build_app_ref (const char *app,
|
|||
const char *branch,
|
||||
const char *arch)
|
||||
{
|
||||
if (branch == NULL)
|
||||
branch = "master";
|
||||
|
||||
if (arch == NULL)
|
||||
arch = xdg_app_get_arch ();
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ main (int argc, char *argv[])
|
|||
}
|
||||
|
||||
g_print ("\n**** Getting installed gedit master\n");
|
||||
app1 = xdg_app_installation_get_installed_ref (installation,
|
||||
app1 = xdg_app_installation_get_installed_ref (installation,
|
||||
XDG_APP_REF_KIND_APP,
|
||||
"org.gnome.gedit",
|
||||
NULL, "master", NULL, NULL);
|
||||
|
@ -148,7 +148,14 @@ main (int argc, char *argv[])
|
|||
xdg_app_installed_ref_get_origin (app1),
|
||||
xdg_app_installed_ref_get_deploy_dir (app1),
|
||||
xdg_app_installed_ref_get_is_current (app1));
|
||||
xdg_app_installed_ref_launch (app1, NULL, NULL);
|
||||
}
|
||||
if (!xdg_app_installation_launch (installation,
|
||||
"org.gnome.gedit",
|
||||
NULL, NULL, NULL,
|
||||
NULL, &error))
|
||||
{
|
||||
g_print ("launch gedit error: %s\n", error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
g_print ("\n**** Getting current installed gedit\n");
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "xdg-app-remote-private.h"
|
||||
#include "xdg-app-enum-types.h"
|
||||
#include "xdg-app-dir.h"
|
||||
#include "xdg-app-run.h"
|
||||
#include "xdg-app-error.h"
|
||||
|
||||
typedef struct _XdgAppInstallationPrivate XdgAppInstallationPrivate;
|
||||
|
@ -135,6 +136,53 @@ xdg_app_installation_get_is_user (XdgAppInstallation *self)
|
|||
return xdg_app_dir_is_user (priv->dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* xdg_app_installation_launch:
|
||||
* @self: a #XdgAppInstallation
|
||||
* @name: ...
|
||||
* @arch: (nullable):...
|
||||
* @branch: (nullable): ...
|
||||
* @commit: (nullable): ...
|
||||
* @cancellable: (nullable): a #GCancellable
|
||||
* @error: return location for a #GError
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*/
|
||||
gboolean
|
||||
xdg_app_installation_launch (XdgAppInstallation *self,
|
||||
const char *name,
|
||||
const char *arch,
|
||||
const char *branch,
|
||||
const char *commit,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self);
|
||||
g_autofree char *app_ref = NULL;
|
||||
g_autoptr(XdgAppDeploy) app_deploy = NULL;
|
||||
|
||||
app_ref =
|
||||
xdg_app_build_app_ref (name, branch, arch);
|
||||
|
||||
app_deploy =
|
||||
xdg_app_dir_load_deployed (priv->dir, app_ref,
|
||||
commit,
|
||||
cancellable, error);
|
||||
if (app_deploy == NULL)
|
||||
return FALSE;
|
||||
|
||||
return xdg_app_run_app (app_ref,
|
||||
app_deploy,
|
||||
NULL,
|
||||
NULL,
|
||||
XDG_APP_RUN_FLAG_BACKGROUND,
|
||||
NULL,
|
||||
NULL, 0,
|
||||
cancellable, error);
|
||||
}
|
||||
|
||||
|
||||
static XdgAppInstalledRef *
|
||||
get_ref (XdgAppInstallation *self,
|
||||
const char *full_ref,
|
||||
|
@ -172,7 +220,6 @@ get_ref (XdgAppInstallation *self,
|
|||
commit,
|
||||
origin,
|
||||
deploy_path,
|
||||
priv->dir,
|
||||
is_current);
|
||||
}
|
||||
|
||||
|
@ -181,8 +228,8 @@ get_ref (XdgAppInstallation *self,
|
|||
* @self: a #XdgAppInstallation
|
||||
* @kind: ...
|
||||
* @name: ...
|
||||
* @arch: ...
|
||||
* @branch: ...
|
||||
* @arch: (nullable): ...
|
||||
* @branch: (nullable): ...
|
||||
* @cancellable: (nullable): a #GCancellable
|
||||
* @error: return location for a #GError
|
||||
*
|
||||
|
|
|
@ -61,6 +61,13 @@ typedef void (*XdgAppProgressCallback)(const char *status,
|
|||
gpointer user_data);
|
||||
|
||||
XDG_APP_EXTERN gboolean xdg_app_installation_get_is_user (XdgAppInstallation *self);
|
||||
XDG_APP_EXTERN gboolean xdg_app_installation_launch (XdgAppInstallation *self,
|
||||
const char *name,
|
||||
const char *arch,
|
||||
const char *branch,
|
||||
const char *commit,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
XDG_APP_EXTERN GPtrArray *xdg_app_installation_list_installed_refs (XdgAppInstallation *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
|
|
@ -32,7 +32,6 @@ XdgAppInstalledRef *xdg_app_installed_ref_new (const char *full_ref,
|
|||
const char *commit,
|
||||
const char *origin,
|
||||
const char *deploy_dir,
|
||||
XdgAppDir *dir,
|
||||
gboolean current);
|
||||
|
||||
#endif /* __XDG_APP_INSTALLED_REF_PRIVATE_H__ */
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
#include "xdg-app-utils.h"
|
||||
#include "xdg-app-installed-ref.h"
|
||||
#include "xdg-app-enum-types.h"
|
||||
#include "xdg-app-run.h"
|
||||
#include "xdg-app-dir.h"
|
||||
|
||||
typedef struct _XdgAppInstalledRefPrivate XdgAppInstalledRefPrivate;
|
||||
|
||||
|
@ -35,8 +33,6 @@ struct _XdgAppInstalledRefPrivate
|
|||
gboolean is_current;
|
||||
char *origin;
|
||||
char *deploy_dir;
|
||||
|
||||
XdgAppDir *dir;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (XdgAppInstalledRef, xdg_app_installed_ref, XDG_APP_TYPE_REF)
|
||||
|
@ -57,7 +53,6 @@ xdg_app_installed_ref_finalize (GObject *object)
|
|||
|
||||
g_free (priv->origin);
|
||||
g_free (priv->deploy_dir);
|
||||
g_object_unref (priv->dir);
|
||||
|
||||
G_OBJECT_CLASS (xdg_app_installed_ref_parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -206,49 +201,14 @@ xdg_app_installed_ref_load_metadata (XdgAppInstalledRef *self,
|
|||
return metadata;
|
||||
}
|
||||
|
||||
gboolean
|
||||
xdg_app_installed_ref_launch (XdgAppInstalledRef *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
XdgAppInstalledRefPrivate *priv = xdg_app_installed_ref_get_instance_private (self);
|
||||
g_autofree char *app_ref = NULL;
|
||||
g_autoptr(XdgAppDeploy) app_deploy = NULL;
|
||||
|
||||
app_ref =
|
||||
xdg_app_build_app_ref (xdg_app_ref_get_name (XDG_APP_REF (self)),
|
||||
xdg_app_ref_get_branch (XDG_APP_REF (self)),
|
||||
xdg_app_ref_get_arch (XDG_APP_REF (self)));
|
||||
|
||||
|
||||
app_deploy =
|
||||
xdg_app_dir_load_deployed (priv->dir, app_ref,
|
||||
xdg_app_ref_get_commit (XDG_APP_REF (self)),
|
||||
cancellable, error);
|
||||
if (app_deploy == NULL)
|
||||
return FALSE;
|
||||
|
||||
return xdg_app_run_app (app_ref,
|
||||
app_deploy,
|
||||
NULL,
|
||||
NULL,
|
||||
XDG_APP_RUN_FLAG_BACKGROUND,
|
||||
NULL,
|
||||
NULL, 0,
|
||||
cancellable, error);
|
||||
|
||||
}
|
||||
|
||||
XdgAppInstalledRef *
|
||||
xdg_app_installed_ref_new (const char *full_ref,
|
||||
const char *commit,
|
||||
const char *origin,
|
||||
const char *deploy_dir,
|
||||
XdgAppDir *dir,
|
||||
gboolean is_current)
|
||||
{
|
||||
XdgAppRefKind kind = XDG_APP_REF_KIND_APP;
|
||||
XdgAppInstalledRefPrivate *priv;
|
||||
XdgAppInstalledRef *ref;
|
||||
g_auto(GStrv) parts = NULL;
|
||||
|
||||
|
@ -268,8 +228,5 @@ xdg_app_installed_ref_new (const char *full_ref,
|
|||
"deploy-dir", deploy_dir,
|
||||
NULL);
|
||||
|
||||
priv = xdg_app_installed_ref_get_instance_private (ref);
|
||||
priv->dir = g_object_ref (dir);
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
|
|
@ -54,8 +54,5 @@ XDG_APP_EXTERN gboolean xdg_app_installed_ref_get_is_current (XdgAppInstalle
|
|||
XDG_APP_EXTERN char * xdg_app_installed_ref_load_metadata (XdgAppInstalledRef *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
XDG_APP_EXTERN gboolean xdg_app_installed_ref_launch (XdgAppInstalledRef *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
#endif /* __XDG_APP_INSTALLED_REF_H__ */
|
||||
|
|
Loading…
Reference in New Issue