[gnome-software/wip/rancell/ubuntu-3-20-3: 3/56] Add a convenience function to check if an app is installed
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/rancell/ubuntu-3-20-3: 3/56] Add a convenience function to check if an app is installed
- Date: Sat, 17 Jun 2017 12:09:23 +0000 (UTC)
commit a17b19deb29fad413db95d4e20ca997d54b28e4c
Author: Joaquim Rocha <jrocha endlessm com>
Date: Thu Aug 11 00:48:49 2016 +0200
Add a convenience function to check if an app is installed
This will avoid having to check three app states all the time.
Signed-off-by: Richard Hughes <richard hughsie com>
src/gs-app.c | 22 ++++++++++++++++++++++
src/gs-app.h | 1 +
2 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index 6358120..07ef838 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -1958,6 +1958,28 @@ gs_app_set_install_date (GsApp *app, guint64 install_date)
}
/**
+ * gs_app_is_installed:
+ * @app: a #GsApp
+ *
+ * Gets whether the app is installed or not.
+ *
+ * Returns: %TRUE if the app is installed, %FALSE otherwise.
+ **/
+gboolean
+gs_app_is_installed (GsApp *app)
+{
+ AsAppState state;
+
+ g_return_val_if_fail (GS_IS_APP (app), FALSE);
+
+ state = gs_app_get_state (app);
+
+ return (state == AS_APP_STATE_INSTALLED) ||
+ (state == AS_APP_STATE_UPDATABLE) ||
+ (state == AS_APP_STATE_UPDATABLE_LIVE);
+}
+
+/**
* gs_app_get_categories:
*/
GPtrArray *
diff --git a/src/gs-app.h b/src/gs-app.h
index d09dc1d..b8f9c35 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -246,6 +246,7 @@ GError *gs_app_get_last_error (GsApp *app);
void gs_app_set_last_error (GsApp *app,
GError *error);
+gboolean gs_app_is_installed (GsApp *app);
G_END_DECLS
#endif /* __GS_APP_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]