[gnome-software/wip/ubuntu] 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/ubuntu] Add a convenience function to check if an app is installed
- Date: Fri, 23 Sep 2016 04:01:31 +0000 (UTC)
commit a13fb0a5e5cf5830daa61723b5cffe078e26b63b
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 | 2 +-
2 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index 2770a03..f9477c4 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -1909,6 +1909,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 5e6d566..7c35521 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -245,7 +245,7 @@ gboolean gs_app_has_quirk (GsApp *app,
AsAppQuirk quirk);
void gs_app_add_quirk (GsApp *app,
AsAppQuirk quirk);
-
+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]