[gnome-builder/wip/chergert/pipeline-merge: 51/76] flatpak: Create GbpFlatpakConfiguration



commit 20bc62b739dd14909da485a85def0343cb58d4f0
Author: Matthew Leeds <mleeds redhat com>
Date:   Thu Dec 22 16:08:18 2016 -0600

    flatpak: Create GbpFlatpakConfiguration
    
    This class will allow GbpFlatpakConfigurationProvider to store more
    information about manifests than it could with IdeConfiguration, such as
    which module in a manifest is the primary one (rather than a dependency).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777959

 plugins/flatpak/Makefile.am                 |    6 +-
 plugins/flatpak/gbp-flatpak-configuration.c |  160 +++++++++++++++++++++++++++
 plugins/flatpak/gbp-flatpak-configuration.h |   37 ++++++
 3 files changed, 199 insertions(+), 4 deletions(-)
---
diff --git a/plugins/flatpak/Makefile.am b/plugins/flatpak/Makefile.am
index f8edb13..4d504ac 100644
--- a/plugins/flatpak/Makefile.am
+++ b/plugins/flatpak/Makefile.am
@@ -14,6 +14,8 @@ libflatpak_plugin_la_SOURCES = \
        gbp-flatpak-application-addin.h \
        gbp-flatpak-clone-widget.c \
        gbp-flatpak-clone-widget.h \
+       gbp-flatpak-configuration.c \
+       gbp-flatpak-configuration.h \
        gbp-flatpak-configuration-provider.c \
        gbp-flatpak-configuration-provider.h \
        gbp-flatpak-genesis-addin.c \
@@ -22,15 +24,11 @@ libflatpak_plugin_la_SOURCES = \
        gbp-flatpak-pipeline-addin.h \
        gbp-flatpak-plugin.c \
        gbp-flatpak-plugin.c \
-       gbp-flatpak-runner.c \
-       gbp-flatpak-runner.c \
        gbp-flatpak-runner.h \
        gbp-flatpak-runner.h \
        gbp-flatpak-runtime-provider.c \
        gbp-flatpak-runtime-provider.h \
        gbp-flatpak-runtime.c \
-       gbp-flatpak-runtime.c \
-       gbp-flatpak-runtime.h \
        gbp-flatpak-runtime.h \
        gbp-flatpak-sources.c \
        gbp-flatpak-sources.h \
diff --git a/plugins/flatpak/gbp-flatpak-configuration.c b/plugins/flatpak/gbp-flatpak-configuration.c
new file mode 100644
index 0000000..05bf636
--- /dev/null
+++ b/plugins/flatpak/gbp-flatpak-configuration.c
@@ -0,0 +1,160 @@
+/* gbp-flatpak-configuration.c
+ *
+ * Copyright (C) 2016 Matthew Leeds <mleeds redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define G_LOG_DOMAIN "gbp-flatpak-configuration"
+
+#include "ide-debug.h"
+
+#include "gbp-flatpak-configuration.h"
+#include "buildsystem/ide-configuration.h"
+
+struct _GbpFlatpakConfiguration
+{
+  IdeConfiguration parent_instance;
+
+  GFile *manifest;
+  gchar *primary_module;
+};
+
+G_DEFINE_TYPE (GbpFlatpakConfiguration, gbp_flatpak_configuration, IDE_TYPE_CONFIGURATION)
+
+enum {
+  PROP_0,
+  PROP_MANIFEST,
+  PROP_PRIMARY_MODULE,
+  N_PROPS
+};
+
+static GParamSpec *properties [N_PROPS];
+
+GFile *gbp_flatpak_configuration_get_manifest (GbpFlatpakConfiguration *self)
+{
+  g_return_val_if_fail (GBP_IS_FLATPAK_CONFIGURATION (self), NULL);
+
+  return self->manifest;
+}
+
+const gchar *
+gbp_flatpak_configuration_get_primary_module (GbpFlatpakConfiguration *self)
+{
+  g_return_val_if_fail (GBP_IS_FLATPAK_CONFIGURATION (self), NULL);
+
+  return self->primary_module;
+}
+
+void
+gbp_flatpak_configuration_set_primary_module (GbpFlatpakConfiguration *self,
+                                              const gchar *primary_module)
+{
+  g_return_if_fail (GBP_IS_FLATPAK_CONFIGURATION (self));
+
+  g_free (self->primary_module);
+  self->primary_module = g_strdup (primary_module);
+}
+
+static void
+gbp_flatpak_configuration_get_property (GObject    *object,
+                                        guint       prop_id,
+                                        GValue     *value,
+                                        GParamSpec *pspec)
+{
+  GbpFlatpakConfiguration *self = GBP_FLATPAK_CONFIGURATION (object);
+
+  switch (prop_id)
+    {
+    case PROP_MANIFEST:
+      g_value_set_object (value, gbp_flatpak_configuration_get_manifest (self));
+      break;
+
+    case PROP_PRIMARY_MODULE:
+      g_value_set_string (value, gbp_flatpak_configuration_get_primary_module (self));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+    }
+}
+
+static void
+gbp_flatpak_configuration_set_property (GObject      *object,
+                                        guint         prop_id,
+                                        const GValue *value,
+                                        GParamSpec   *pspec)
+{
+  GbpFlatpakConfiguration *self = GBP_FLATPAK_CONFIGURATION (object);
+
+  switch (prop_id)
+    {
+    case PROP_MANIFEST:
+      self->manifest = g_value_dup_object (value);
+      break;
+
+    case PROP_PRIMARY_MODULE:
+      gbp_flatpak_configuration_set_primary_module (self, g_value_get_string (value));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+    }
+}
+
+static void
+gbp_flatpak_configuration_finalize (GObject *object)
+{
+  GbpFlatpakConfiguration *self = (GbpFlatpakConfiguration *)object;
+
+  g_clear_object (&self->manifest);
+  g_clear_pointer (&self->primary_module, g_free);
+
+  G_OBJECT_CLASS (gbp_flatpak_configuration_parent_class)->finalize (object);
+}
+
+static void
+gbp_flatpak_configuration_class_init (GbpFlatpakConfigurationClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = gbp_flatpak_configuration_finalize;
+  object_class->get_property = gbp_flatpak_configuration_get_property;
+  object_class->set_property = gbp_flatpak_configuration_set_property;
+
+  properties [PROP_MANIFEST] =
+    g_param_spec_object ("manifest",
+                         "Manifest",
+                         "Manifest file",
+                         G_TYPE_FILE,
+                         (G_PARAM_READWRITE |
+                          G_PARAM_CONSTRUCT |
+                          G_PARAM_STATIC_STRINGS));
+
+  properties [PROP_PRIMARY_MODULE] =
+    g_param_spec_string ("primary-module",
+                         "Primary module",
+                         "Primary module",
+                         NULL,
+                         (G_PARAM_READWRITE |
+                          G_PARAM_CONSTRUCT |
+                          G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_properties (object_class, N_PROPS, properties);
+}
+
+static void
+gbp_flatpak_configuration_init (GbpFlatpakConfiguration *self)
+{
+}
diff --git a/plugins/flatpak/gbp-flatpak-configuration.h b/plugins/flatpak/gbp-flatpak-configuration.h
new file mode 100644
index 0000000..1cb116a
--- /dev/null
+++ b/plugins/flatpak/gbp-flatpak-configuration.h
@@ -0,0 +1,37 @@
+/* gbp-flatpak-configuration.h
+ *
+ * Copyright (C) 2016 Matthew Leeds <mleeds redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GBP_FLATPAK_CONFIGURATION_H
+#define GBP_FLATPAK_CONFIGURATION_H
+
+#include <ide.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_FLATPAK_CONFIGURATION (gbp_flatpak_configuration_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpFlatpakConfiguration, gbp_flatpak_configuration, GBP, FLATPAK_CONFIGURATION, 
IdeConfiguration)
+
+GFile       *gbp_flatpak_configuration_get_manifest (GbpFlatpakConfiguration *self);
+const gchar *gbp_flatpak_configuration_get_primary_module (GbpFlatpakConfiguration *self);
+void         gbp_flatpak_configuration_set_primary_module (GbpFlatpakConfiguration *self,
+                                                           const gchar *primary_module);
+
+G_END_DECLS
+
+#endif /* GBP_FLATPAK_CONFIGURATION_H */


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