[gnome-software/uajain/flatpak-autoupdates-fix: 2/3] GsFlatpakTransaction: Add a property corresponding to --no-deploy



commit fd01e1b36faa640e0b8a89cdf6ca8e82cbfb9cfa
Author: Umang Jain <mailumangjain gmail com>
Date:   Fri Oct 4 06:17:59 2019 -0400

    GsFlatpakTransaction: Add a property corresponding to --no-deploy
    
    Add a property corresponding to flatpak's --no-deploy to
    GsFlatpakTransaction and use the helper method instead,
    in the flatpak-plugin.
    
    This is also done as a ground-work to let the FlatpakTransaction
    know if an update was a autoupdate(non-interactive) or a manual
    update(interaction) in subsequent commit.
    
    https://gitlab.gnome.org/GNOME/gnome-software/issues/819

 plugins/flatpak/gs-flatpak-transaction.c | 39 ++++++++++++++++++++++++++++++++
 plugins/flatpak/gs-flatpak-transaction.h |  3 +++
 plugins/flatpak/gs-plugin-flatpak.c      |  2 +-
 3 files changed, 43 insertions(+), 1 deletion(-)
---
diff --git a/plugins/flatpak/gs-flatpak-transaction.c b/plugins/flatpak/gs-flatpak-transaction.c
index c6b49909..ff0da9f1 100644
--- a/plugins/flatpak/gs-flatpak-transaction.c
+++ b/plugins/flatpak/gs-flatpak-transaction.c
@@ -15,6 +15,12 @@ struct _GsFlatpakTransaction {
        FlatpakTransaction       parent_instance;
        GHashTable              *refhash;       /* ref:GsApp */
        GError                  *first_operation_error;
+       gboolean                 no_deploy;
+};
+
+enum {
+       PROP_ZERO,
+       PROP_NO_DEPLOY
 };
 
 enum {
@@ -41,6 +47,18 @@ gs_flatpak_transaction_finalize (GObject *object)
        G_OBJECT_CLASS (gs_flatpak_transaction_parent_class)->finalize (object);
 }
 
+void
+gs_flatpak_transaction_set_no_deploy (FlatpakTransaction *transaction, gboolean no_deploy)
+{
+       GsFlatpakTransaction *self;
+
+       g_return_if_fail (GS_IS_FLATPAK_TRANSACTION (transaction));
+
+       self = GS_FLATPAK_TRANSACTION (transaction);
+       self->no_deploy = no_deploy;
+       flatpak_transaction_set_no_deploy (transaction, no_deploy);
+}
+
 GsApp *
 gs_flatpak_transaction_get_app_by_ref (FlatpakTransaction *transaction, const gchar *ref)
 {
@@ -348,11 +366,28 @@ _transaction_add_new_remote (FlatpakTransaction *transaction,
        return FALSE;
 }
 
+static void
+gs_flatpak_transaction_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+       FlatpakTransaction *self = FLATPAK_TRANSACTION (object);
+
+       switch (prop_id) {
+       case PROP_NO_DEPLOY:
+               gs_flatpak_transaction_set_no_deploy (self, g_value_get_boolean (value));
+               break;
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+               break;
+       }
+}
+
 static void
 gs_flatpak_transaction_class_init (GsFlatpakTransactionClass *klass)
 {
+       GParamSpec *pspec;
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
        FlatpakTransactionClass *transaction_class = FLATPAK_TRANSACTION_CLASS (klass);
+       object_class->set_property = gs_flatpak_transaction_set_property;
        object_class->finalize = gs_flatpak_transaction_finalize;
        transaction_class->ready = _transaction_ready;
        transaction_class->add_new_remote = _transaction_add_new_remote;
@@ -362,6 +397,10 @@ gs_flatpak_transaction_class_init (GsFlatpakTransactionClass *klass)
        transaction_class->choose_remote_for_ref = _transaction_choose_remote_for_ref;
        transaction_class->end_of_lifed = _transaction_end_of_lifed;
 
+       pspec = g_param_spec_boolean ("no-deploy", NULL, NULL,
+                                     FALSE, G_PARAM_READWRITE);
+       g_object_class_install_property (object_class, PROP_NO_DEPLOY, pspec);
+
        signals[SIGNAL_REF_TO_APP] =
                g_signal_new ("ref-to-app",
                              G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
diff --git a/plugins/flatpak/gs-flatpak-transaction.h b/plugins/flatpak/gs-flatpak-transaction.h
index 2caa289d..245f708a 100644
--- a/plugins/flatpak/gs-flatpak-transaction.h
+++ b/plugins/flatpak/gs-flatpak-transaction.h
@@ -26,5 +26,8 @@ void                   gs_flatpak_transaction_add_app         (FlatpakTransaction     
*transaction,
 gboolean                gs_flatpak_transaction_run             (FlatpakTransaction     *transaction,
                                                                 GCancellable           *cancellable,
                                                                 GError                 **error);
+void                    gs_flatpak_transaction_set_no_deploy   (FlatpakTransaction     *transaction,
+                                                                gboolean                no_deploy);
+
 
 G_END_DECLS
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
index 007eab75..097c03fb 100644
--- a/plugins/flatpak/gs-plugin-flatpak.c
+++ b/plugins/flatpak/gs-plugin-flatpak.c
@@ -470,7 +470,7 @@ gs_plugin_download (GsPlugin *plugin, GsAppList *list,
                gs_flatpak_error_convert (error);
                return FALSE;
        }
-       flatpak_transaction_set_no_deploy (transaction, TRUE);
+       gs_flatpak_transaction_set_no_deploy (transaction, TRUE);
        for (guint i = 0; i < gs_app_list_length (list_tmp); i++) {
                GsApp *app = gs_app_list_index (list_tmp, i);
                g_autofree gchar *ref = NULL;


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