[gnome-software/wip/jrocha/fix-updates-list: 1/3] Add a method to quickly check if an app is updatable



commit 3f9bad69b4a6b1e9510ee1b05f07eff00ddc41fa
Author: Joaquim Rocha <jrocha endlessm com>
Date:   Tue Oct 18 18:18:56 2016 +0200

    Add a method to quickly check if an app is updatable
    
    This is a convenience function to avoid having to check the
    GS_APP_STATE_UPDATABLE and GS_APP_STATE_UPDATABLE_LIVE states.

 src/gs-app.c |   21 +++++++++++++++++++++
 src/gs-app.h |    1 +
 2 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index d0aef4a..167c7bd 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -2801,6 +2801,27 @@ gs_app_is_installed (GsApp *app)
 }
 
 /**
+ * gs_app_is_updatable:
+ * @app: a #GsApp
+ *
+ * Gets whether the app is updatable or not.
+ *
+ * Returns: %TRUE if the app is updatable, %FALSE otherwise.
+ *
+ * Since: 3.24
+ **/
+gboolean
+gs_app_is_updatable (GsApp *app)
+{
+       AsAppState state;
+
+       g_return_val_if_fail (GS_IS_APP (app), FALSE);
+
+       return (app->state == AS_APP_STATE_UPDATABLE) ||
+              (app->state == AS_APP_STATE_UPDATABLE_LIVE);
+}
+
+/**
  * gs_app_get_categories:
  * @app: a #GsApp
  *
diff --git a/src/gs-app.h b/src/gs-app.h
index 6b89e6f..3e3cc22 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -284,6 +284,7 @@ void                 gs_app_add_quirk               (GsApp          *app,
 void            gs_app_remove_quirk            (GsApp          *app,
                                                 AsAppQuirk      quirk);
 gboolean        gs_app_is_installed            (GsApp          *app);
+gboolean        gs_app_is_updatable            (GsApp          *app);
 G_END_DECLS
 
 #endif /* __GS_APP_H */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]