[gnome-software/wip/rancell/ubuntu-3-20-rebase: 3/12] 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-rebase: 3/12] Add a convenience function to check if an app is installed
- Date: Fri, 16 Jun 2017 07:46:36 +0000 (UTC)
commit 4edcc9c64b8af0e6f14245db79896142df88abc1
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 1929b18..5aa48b4 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -1874,6 +1874,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 7f03df3..d1be38b 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -235,7 +235,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]