[gnome-builder: 81/139] flatpak: port to new libide designs
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder: 81/139] flatpak: port to new libide designs
- Date: Thu, 10 Jan 2019 04:24:07 +0000 (UTC)
commit 9adbe36d16959de54b60eb03a8b07d061443bf4c
Author: Christian Hergert <chergert redhat com>
Date: Wed Jan 9 17:20:41 2019 -0800
flatpak: port to new libide designs
This ports a number of components in the flatpak plugin to use new desgins
afforded by libide-code, libide-foundry, libide-gui, and others. It also
simplifies the integration of cloning a project from manifest using the
new greeter APIs.
.../{gbp-flatpak-plugin.c => flatpak-plugin.c} | 20 +-
src/plugins/flatpak/flatpak.gresource.xml | 6 +-
src/plugins/flatpak/flatpak.plugin | 14 +-
.../flatpak/gbp-flatpak-application-addin.c | 128 +++++++++++--
.../flatpak/gbp-flatpak-application-addin.h | 4 +-
.../flatpak/gbp-flatpak-build-system-discovery.h | 2 +-
.../flatpak/gbp-flatpak-build-target-provider.c | 3 +-
.../flatpak/gbp-flatpak-build-target-provider.h | 2 +-
src/plugins/flatpak/gbp-flatpak-build-target.h | 2 +-
src/plugins/flatpak/gbp-flatpak-clone-widget.c | 80 +++++---
src/plugins/flatpak/gbp-flatpak-clone-widget.h | 2 +-
src/plugins/flatpak/gbp-flatpak-clone-widget.ui | 61 +++---
.../flatpak/gbp-flatpak-configuration-provider.c | 29 +--
.../flatpak/gbp-flatpak-configuration-provider.h | 2 +-
.../flatpak/gbp-flatpak-dependency-updater.c | 3 +-
.../flatpak/gbp-flatpak-dependency-updater.h | 2 +-
src/plugins/flatpak/gbp-flatpak-download-stage.c | 4 +-
src/plugins/flatpak/gbp-flatpak-download-stage.h | 8 +-
src/plugins/flatpak/gbp-flatpak-genesis-addin.c | 206 ---------------------
src/plugins/flatpak/gbp-flatpak-genesis-addin.h | 31 ----
src/plugins/flatpak/gbp-flatpak-manifest.c | 31 +---
src/plugins/flatpak/gbp-flatpak-manifest.h | 5 +-
src/plugins/flatpak/gbp-flatpak-pipeline-addin.c | 33 ++--
src/plugins/flatpak/gbp-flatpak-pipeline-addin.h | 2 +-
.../flatpak/gbp-flatpak-preferences-addin.c | 1 +
.../flatpak/gbp-flatpak-preferences-addin.h | 2 +-
src/plugins/flatpak/gbp-flatpak-runner.c | 6 +-
src/plugins/flatpak/gbp-flatpak-runner.h | 2 +-
src/plugins/flatpak/gbp-flatpak-runtime-provider.c | 42 +++--
src/plugins/flatpak/gbp-flatpak-runtime-provider.h | 2 +-
src/plugins/flatpak/gbp-flatpak-runtime.c | 89 +++++----
src/plugins/flatpak/gbp-flatpak-runtime.h | 5 +-
src/plugins/flatpak/gbp-flatpak-sources.c | 2 +-
.../flatpak/gbp-flatpak-subprocess-launcher.h | 2 +-
src/plugins/flatpak/gbp-flatpak-transfer.c | 18 +-
src/plugins/flatpak/gbp-flatpak-transfer.h | 10 +-
src/plugins/flatpak/gbp-flatpak-util.c | 14 +-
src/plugins/flatpak/gbp-flatpak-util.h | 2 +-
src/plugins/flatpak/gbp-flatpak-workbench-addin.c | 97 +++++++---
src/plugins/flatpak/gbp-flatpak-workbench-addin.h | 2 +-
src/plugins/flatpak/meson.build | 51 ++---
41 files changed, 472 insertions(+), 555 deletions(-)
---
diff --git a/src/plugins/flatpak/gbp-flatpak-plugin.c b/src/plugins/flatpak/flatpak-plugin.c
similarity index 88%
rename from src/plugins/flatpak/gbp-flatpak-plugin.c
rename to src/plugins/flatpak/flatpak-plugin.c
index c987ec774..375e3db0c 100644
--- a/src/plugins/flatpak/gbp-flatpak-plugin.c
+++ b/src/plugins/flatpak/flatpak-plugin.c
@@ -1,4 +1,4 @@
-/* gbp-flatpak-plugin.c
+/* flatpak-plugin.c
*
* Copyright 2016-2019 Christian Hergert <chergert redhat com>
*
@@ -18,24 +18,29 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
+#define G_LOG_DOMAIN "flatpak-plugin"
+
+#include "config.h"
+
#include <libpeas/peas.h>
-#include <ide.h>
+#include <libide-code.h>
+#include <libide-foundry.h>
+#include <libide-gui.h>
#include "gbp-flatpak-application-addin.h"
#include "gbp-flatpak-build-system-discovery.h"
#include "gbp-flatpak-build-target-provider.h"
#include "gbp-flatpak-configuration-provider.h"
#include "gbp-flatpak-dependency-updater.h"
-#include "gbp-flatpak-genesis-addin.h"
#include "gbp-flatpak-pipeline-addin.h"
#include "gbp-flatpak-preferences-addin.h"
#include "gbp-flatpak-runtime-provider.h"
#include "gbp-flatpak-workbench-addin.h"
-void
-gbp_flatpak_register_types (PeasObjectModule *module)
+_IDE_EXTERN void
+_gbp_flatpak_register_types (PeasObjectModule *module)
{
- ide_vcs_register_ignored (".flatpak-builder");
+ ide_g_file_add_ignored_pattern (".flatpak-builder");
peas_object_module_register_extension_type (module,
IDE_TYPE_BUILD_SYSTEM_DISCOVERY,
@@ -55,9 +60,6 @@ gbp_flatpak_register_types (PeasObjectModule *module)
peas_object_module_register_extension_type (module,
IDE_TYPE_APPLICATION_ADDIN,
GBP_TYPE_FLATPAK_APPLICATION_ADDIN);
- peas_object_module_register_extension_type (module,
- IDE_TYPE_GENESIS_ADDIN,
- GBP_TYPE_FLATPAK_GENESIS_ADDIN);
peas_object_module_register_extension_type (module,
IDE_TYPE_BUILD_PIPELINE_ADDIN,
GBP_TYPE_FLATPAK_PIPELINE_ADDIN);
diff --git a/src/plugins/flatpak/flatpak.gresource.xml b/src/plugins/flatpak/flatpak.gresource.xml
index 2523c2a28..e24f61d3d 100644
--- a/src/plugins/flatpak/flatpak.gresource.xml
+++ b/src/plugins/flatpak/flatpak.gresource.xml
@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
- <gresource prefix="/org/gnome/builder/plugins">
+ <gresource prefix="/plugins/flatpak">
<file>flatpak.plugin</file>
- </gresource>
- <gresource prefix="/org/gnome/builder/plugins/flatpak-plugin">
- <file>gbp-flatpak-clone-widget.ui</file>
+ <file preprocess="xml-stripblanks">gbp-flatpak-clone-widget.ui</file>
</gresource>
</gresources>
diff --git a/src/plugins/flatpak/flatpak.plugin b/src/plugins/flatpak/flatpak.plugin
index 1116a3366..2d7e9bc7c 100644
--- a/src/plugins/flatpak/flatpak.plugin
+++ b/src/plugins/flatpak/flatpak.plugin
@@ -1,9 +1,11 @@
[Plugin]
-Module=flatpak-plugin
-Name=Flatpak
-Description=Provides support for building with Flatpak
Authors=Christian Hergert <christian hergert me>
-Copyright=Copyright © 2016 Christian Hergert
Builtin=true
-Depends=git-plugin;
-Embedded=gbp_flatpak_register_types
+Copyright=Copyright © 2016-2018 Christian Hergert
+Depends=buildui;editor;git;
+Description=Provides support for building with Flatpak
+Embedded=_gbp_flatpak_register_types
+Hidden=true
+Module=flatpak
+Name=Flatpak
+X-At-Startup=true
diff --git a/src/plugins/flatpak/gbp-flatpak-application-addin.c
b/src/plugins/flatpak/gbp-flatpak-application-addin.c
index e4b5e2e13..feddde9ed 100644
--- a/src/plugins/flatpak/gbp-flatpak-application-addin.c
+++ b/src/plugins/flatpak/gbp-flatpak-application-addin.c
@@ -20,12 +20,18 @@
#define G_LOG_DOMAIN "gbp-flatpak-application-addin"
+#include "config.h"
+
+#include <glib/gi18n.h>
#include <glib/gstdio.h>
+#include <libide-greeter.h>
+#include <libide-gui.h>
#include <errno.h>
#include <flatpak.h>
#include <unistd.h>
#include "gbp-flatpak-application-addin.h"
+#include "gbp-flatpak-clone-widget.h"
#include "gbp-flatpak-runtime.h"
#include "gbp-flatpak-util.h"
@@ -42,7 +48,7 @@ typedef struct
gchar *arch;
gchar *branch;
GPtrArray *installations;
- IdeProgress *progress;
+ IdeNotification *progress;
FlatpakInstalledRef *ref;
guint did_added : 1;
} InstallRequest;
@@ -69,6 +75,13 @@ struct _GbpFlatpakApplicationAddin
* ptrarray) will not be affected.
*/
GPtrArray *installations;
+
+ /* The addin attempts to delay loading any flatpak information until
+ * it has been requested (by the runtime provider for example). Doing
+ * so helps speed up initial application startup at the cost of a bit
+ * slower project setup time.
+ */
+ guint has_loaded : 1;
};
typedef struct
@@ -91,7 +104,7 @@ static BuiltinFlatpakRepo builtin_flatpak_repos[] = {
{ "gnome-nightly", "https://sdk.gnome.org/gnome-nightly.flatpakrepo" },
};
-static void gbp_flatpak_application_addin_reload (GbpFlatpakApplicationAddin *self);
+static void gbp_flatpak_application_addin_lazy_reload (GbpFlatpakApplicationAddin *self);
static void
copy_devhelp_docs_into_user_data_dir_worker (IdeTask *task,
@@ -233,7 +246,7 @@ install_info_installation_changed (GFileMonitor *monitor,
self = g_object_ref (info->self);
- gbp_flatpak_application_addin_reload (self);
+ gbp_flatpak_application_addin_lazy_reload (self);
IDE_EXIT;
}
@@ -310,7 +323,7 @@ locate_sdk_free (LocateSdk *locate)
}
static void
-gbp_flatpak_application_addin_reload (GbpFlatpakApplicationAddin *self)
+gbp_flatpak_application_addin_lazy_reload (GbpFlatpakApplicationAddin *self)
{
g_autofree gchar *user_path = NULL;
g_autoptr(GFile) user_file = NULL;
@@ -322,6 +335,8 @@ gbp_flatpak_application_addin_reload (GbpFlatpakApplicationAddin *self)
g_assert (GBP_IS_FLATPAK_APPLICATION_ADDIN (self));
+ self->has_loaded = TRUE;
+
/* Clear any previous installations */
g_clear_pointer (&self->installations, g_ptr_array_unref);
self->installations = g_ptr_array_new_with_free_func ((GDestroyNotify)install_info_free);
@@ -395,8 +410,6 @@ gbp_flatpak_application_addin_load (IdeApplicationAddin *addin,
instance = self;
- gbp_flatpak_application_addin_reload (self);
-
settings = g_settings_new ("org.gnome.builder");
if (g_settings_get_boolean (settings, "clear-cache-at-startup"))
@@ -451,8 +464,6 @@ gbp_flatpak_application_addin_unload (IdeApplicationAddin *addin,
* Gets an array of runtimes available on the system.
*
* Returns: (transfer container) (element-type Flatpak.InstalledRef): Array of runtimes.
- *
- * Since: 3.32
*/
GPtrArray *
gbp_flatpak_application_addin_get_runtimes (GbpFlatpakApplicationAddin *self)
@@ -463,6 +474,9 @@ gbp_flatpak_application_addin_get_runtimes (GbpFlatpakApplicationAddin *self)
g_assert (GBP_IS_FLATPAK_APPLICATION_ADDIN (self));
+ if (!self->has_loaded)
+ gbp_flatpak_application_addin_lazy_reload (self);
+
ret = g_ptr_array_new_with_free_func (g_object_unref);
for (guint i = 0; i < self->installations->len; i++)
@@ -495,8 +509,6 @@ gbp_flatpak_application_addin_get_runtimes (GbpFlatpakApplicationAddin *self)
* Gets an array of flatpak installations on the system.
*
* Returns: (transfer container) (element-type Flatpak.Installation): Array of installations
- *
- * Since: 3.32
*/
GPtrArray *
gbp_flatpak_application_addin_get_installations (GbpFlatpakApplicationAddin *self)
@@ -507,6 +519,9 @@ gbp_flatpak_application_addin_get_installations (GbpFlatpakApplicationAddin *sel
g_assert (GBP_IS_FLATPAK_APPLICATION_ADDIN (self));
+ if (!self->has_loaded)
+ gbp_flatpak_application_addin_lazy_reload (self);
+
ret = g_ptr_array_new_with_free_func (g_object_unref);
/* Might be NULL before things have loaded at startup */
@@ -651,7 +666,7 @@ gbp_flatpak_application_addin_install_runtime_worker (IdeTask *task,
id,
arch,
branch,
- ide_progress_flatpak_progress_callback,
+ ide_notification_flatpak_progress_callback,
request->progress,
cancellable,
&error);
@@ -716,7 +731,7 @@ gbp_flatpak_application_addin_install_runtime_worker (IdeTask *task,
id,
arch,
branch,
- ide_progress_flatpak_progress_callback,
+ ide_notification_flatpak_progress_callback,
request->progress,
cancellable,
&error);
@@ -747,7 +762,7 @@ gbp_flatpak_application_addin_install_runtime_async (GbpFlatpakApplicationAddin
const gchar *arch,
const gchar *branch,
GCancellable *cancellable,
- IdeProgress **progress,
+ IdeNotification **progress,
GAsyncReadyCallback callback,
gpointer user_data)
{
@@ -773,7 +788,7 @@ gbp_flatpak_application_addin_install_runtime_async (GbpFlatpakApplicationAddin
request->arch = g_strdup (arch);
request->branch = g_strdup (branch);
request->installations = g_ptr_array_ref (self->installations);
- request->progress = ide_progress_new ();
+ request->progress = ide_notification_new ();
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_set_source_tag (task, gbp_flatpak_application_addin_install_runtime_async);
@@ -873,11 +888,92 @@ gbp_flatpak_application_addin_has_runtime (GbpFlatpakApplicationAddin *self,
IDE_RETURN (FALSE);
}
+static void
+gbp_flatpak_application_addin_add_option_entries (IdeApplicationAddin *addin,
+ IdeApplication *app)
+{
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_FLATPAK_APPLICATION_ADDIN (addin));
+ g_assert (G_IS_APPLICATION (app));
+
+ g_application_add_main_option (G_APPLICATION (app),
+ "manifest",
+ 'm',
+ G_OPTION_FLAG_IN_MAIN,
+ G_OPTION_ARG_FILENAME,
+ _("Clone a project using flatpak manifest"),
+ _("MANIFEST"));
+}
+
+static void
+gbp_flatpak_application_addin_clone_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GbpFlatpakCloneWidget *clone = (GbpFlatpakCloneWidget *)object;
+ g_autoptr(IdeGreeterWorkspace) workspace = user_data;
+ g_autoptr(GError) error = NULL;
+
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_FLATPAK_CLONE_WIDGET (clone));
+ g_assert (IDE_IS_GREETER_WORKSPACE (workspace));
+
+ if (!gbp_flatpak_clone_widget_clone_finish (clone, result, &error))
+ g_warning ("%s", error->message);
+
+ ide_greeter_workspace_end (workspace);
+}
+
+static void
+gbp_flatpak_application_addin_handle_command_line (IdeApplicationAddin *addin,
+ IdeApplication *application,
+ GApplicationCommandLine *cmdline)
+{
+ g_autofree gchar *manifest = NULL;
+ GbpFlatpakCloneWidget *clone;
+ IdeGreeterWorkspace *workspace;
+ IdeWorkbench *workbench;
+ GVariantDict *options;
+
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_FLATPAK_APPLICATION_ADDIN (addin));
+ g_assert (IDE_IS_APPLICATION (application));
+ g_assert (G_IS_APPLICATION_COMMAND_LINE (cmdline));
+
+ if (!(options = g_application_command_line_get_options_dict (cmdline)) ||
+ !g_variant_dict_contains (options, "manifest") ||
+ !g_variant_dict_lookup (options, "manifest", "^ay", &manifest))
+ return;
+
+ workbench = ide_workbench_new ();
+ ide_application_add_workbench (application, workbench);
+
+ workspace = ide_greeter_workspace_new (application);
+ ide_workbench_add_workspace (workbench, IDE_WORKSPACE (workspace));
+
+ clone = g_object_new (GBP_TYPE_FLATPAK_CLONE_WIDGET,
+ "manifest", manifest,
+ "visible", TRUE,
+ NULL);
+ ide_workspace_add_surface (IDE_WORKSPACE (workspace), IDE_SURFACE (clone));
+ ide_workspace_set_visible_surface (IDE_WORKSPACE (workspace), IDE_SURFACE (clone));
+
+ ide_workbench_focus_workspace (workbench, IDE_WORKSPACE (workspace));
+
+ ide_greeter_workspace_begin (workspace);
+ gbp_flatpak_clone_widget_clone_async (clone,
+ NULL,
+ gbp_flatpak_application_addin_clone_cb,
+ g_object_ref (workspace));
+}
+
static void
application_addin_iface_init (IdeApplicationAddinInterface *iface)
{
iface->load = gbp_flatpak_application_addin_load;
iface->unload = gbp_flatpak_application_addin_unload;
+ iface->add_option_entries = gbp_flatpak_application_addin_add_option_entries;
+ iface->handle_command_line = gbp_flatpak_application_addin_handle_command_line;
}
G_DEFINE_TYPE_EXTENDED (GbpFlatpakApplicationAddin,
@@ -897,8 +993,6 @@ gbp_flatpak_application_addin_class_init (GbpFlatpakApplicationAddinClass *klass
* This signal is emitted when a new runtime is discovered. No deduplication
* is dealt with here, so consumers will need to ensure they have not seen
* the runtime before by deduplicating with id/arch/branch.
- *
- * Since: 3.32
*/
signals [RUNTIME_ADDED] = g_signal_new ("runtime-added",
G_TYPE_FROM_CLASS (klass),
@@ -914,8 +1008,6 @@ gbp_flatpak_application_addin_class_init (GbpFlatpakApplicationAddinClass *klass
* This signal is emitted when the addin reloads, which is generally
* triggered by one of the flatpak installations changing, so other
* components can indirectly monitor that.
- *
- * Since: 3.32
*/
signals [RELOAD] = g_signal_new ("reload",
G_TYPE_FROM_CLASS (klass),
diff --git a/src/plugins/flatpak/gbp-flatpak-application-addin.h
b/src/plugins/flatpak/gbp-flatpak-application-addin.h
index 6c228a4cc..ce4ae7820 100644
--- a/src/plugins/flatpak/gbp-flatpak-application-addin.h
+++ b/src/plugins/flatpak/gbp-flatpak-application-addin.h
@@ -21,7 +21,7 @@
#pragma once
#include <flatpak.h>
-#include <ide.h>
+#include <libide-gui.h>
G_BEGIN_DECLS
@@ -48,7 +48,7 @@ void gbp_flatpak_application_addin_install_runtime_async
const gchar
*arch,
const gchar
*branch,
GCancellable
*cancellable,
- IdeProgress
**progress,
+ IdeNotification
**progress,
GAsyncReadyCallback
callback,
gpointer
user_data);
gboolean gbp_flatpak_application_addin_install_runtime_finish (GbpFlatpakApplicationAddin
*self,
diff --git a/src/plugins/flatpak/gbp-flatpak-build-system-discovery.h
b/src/plugins/flatpak/gbp-flatpak-build-system-discovery.h
index 2304570b2..f047f95a1 100644
--- a/src/plugins/flatpak/gbp-flatpak-build-system-discovery.h
+++ b/src/plugins/flatpak/gbp-flatpak-build-system-discovery.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-foundry.h>
G_BEGIN_DECLS
diff --git a/src/plugins/flatpak/gbp-flatpak-build-target-provider.c
b/src/plugins/flatpak/gbp-flatpak-build-target-provider.c
index db47fe2b9..92906226d 100644
--- a/src/plugins/flatpak/gbp-flatpak-build-target-provider.c
+++ b/src/plugins/flatpak/gbp-flatpak-build-target-provider.c
@@ -50,7 +50,7 @@ gbp_flatpak_build_target_provider_get_targets_async (IdeBuildTargetProvider *pro
ide_task_set_priority (task, G_PRIORITY_LOW);
context = ide_object_get_context (IDE_OBJECT (self));
- config_manager = ide_context_get_configuration_manager (context);
+ config_manager = ide_configuration_manager_from_context (context);
config = ide_configuration_manager_get_current (config_manager);
targets = g_ptr_array_new_with_free_func (g_object_unref);
@@ -63,7 +63,6 @@ gbp_flatpak_build_target_provider_get_targets_async (IdeBuildTargetProvider *pro
command = gbp_flatpak_manifest_get_command (GBP_FLATPAK_MANIFEST (config));
target = g_object_new (GBP_TYPE_FLATPAK_BUILD_TARGET,
- "context", context,
"command", command,
NULL);
diff --git a/src/plugins/flatpak/gbp-flatpak-build-target-provider.h
b/src/plugins/flatpak/gbp-flatpak-build-target-provider.h
index c5a48dc8d..285694c04 100644
--- a/src/plugins/flatpak/gbp-flatpak-build-target-provider.h
+++ b/src/plugins/flatpak/gbp-flatpak-build-target-provider.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-foundry.h>
G_BEGIN_DECLS
diff --git a/src/plugins/flatpak/gbp-flatpak-build-target.h b/src/plugins/flatpak/gbp-flatpak-build-target.h
index 2217fc787..10c29e59a 100644
--- a/src/plugins/flatpak/gbp-flatpak-build-target.h
+++ b/src/plugins/flatpak/gbp-flatpak-build-target.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-foundry.h>
G_BEGIN_DECLS
diff --git a/src/plugins/flatpak/gbp-flatpak-clone-widget.c b/src/plugins/flatpak/gbp-flatpak-clone-widget.c
index 4b475d1fd..89cc550cc 100644
--- a/src/plugins/flatpak/gbp-flatpak-clone-widget.c
+++ b/src/plugins/flatpak/gbp-flatpak-clone-widget.c
@@ -24,7 +24,10 @@
#include <glib/gi18n.h>
#include <json-glib/json-glib.h>
#include <libgit2-glib/ggit.h>
-#include <ide.h>
+#include <libide-greeter.h>
+#include <libide-gui.h>
+#include <libide-threading.h>
+#include <libide-vcs.h>
#include "gbp-flatpak-clone-widget.h"
#include "gbp-flatpak-sources.h"
@@ -33,7 +36,7 @@
struct _GbpFlatpakCloneWidget
{
- GtkBin parent_instance;
+ IdeSurface parent_instance;
GtkProgressBar *clone_progress;
@@ -54,12 +57,12 @@ typedef enum {
typedef struct
{
- SourceType type;
- IdeVcsUri *uri;
- gchar *branch;
- gchar *sha;
- gchar *name;
- gchar **patches;
+ SourceType type;
+ IdeVcsUri *uri;
+ gchar *branch;
+ gchar *sha;
+ gchar *name;
+ gchar **patches;
} ModuleSource;
typedef struct
@@ -76,7 +79,7 @@ enum {
LAST_PROP
};
-G_DEFINE_TYPE (GbpFlatpakCloneWidget, gbp_flatpak_clone_widget, GTK_TYPE_BIN)
+G_DEFINE_TYPE (GbpFlatpakCloneWidget, gbp_flatpak_clone_widget, IDE_TYPE_SURFACE)
static void
module_source_free (void *data)
@@ -122,24 +125,33 @@ static void
gbp_flatpak_clone_widget_set_manifest (GbpFlatpakCloneWidget *self,
const gchar *manifest)
{
- gchar *ptr;
+ g_autofree gchar *name = NULL;
+ g_autofree gchar *title = NULL;
+ const gchar *ptr;
- g_free (self->manifest);
- g_free (self->app_id_override);
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_FLATPAK_CLONE_WIDGET (self));
+ g_assert (manifest != NULL);
+
+ g_clear_pointer (&self->manifest, g_free);
+ g_clear_pointer (&self->app_id_override, g_free);
+
+ name = g_path_get_basename (manifest);
+ /* translators: %s is replaced with the name of the flatpak manifest */
+ title = g_strdup_printf (_("Cloning project %s"), name);
+ ide_surface_set_title (IDE_SURFACE (self), title);
/* if the filename does not end with .json, just set it right away,
* even if it may fail later.
*/
- ptr = g_strrstr (manifest, ".json");
- if (!ptr)
+ if (!(ptr = g_strrstr (manifest, ".json")))
{
self->manifest = g_strdup (manifest);
return;
}
/* search for the first '+' after the .json extension */
- ptr = strchr (ptr, '+');
- if (!ptr)
+ if (!(ptr = strchr (ptr, '+')))
{
self->manifest = g_strdup (manifest);
return;
@@ -230,7 +242,7 @@ gbp_flatpak_clone_widget_class_init (GbpFlatpakCloneWidgetClass *klass)
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
gtk_widget_class_set_css_name (widget_class, "flatpakclonewidget");
- gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/builder/plugins/flatpak-plugin/gbp-flatpak-clone-widget.ui");
+ gtk_widget_class_set_template_from_resource (widget_class, "/plugins/flatpak/gbp-flatpak-clone-widget.ui");
gtk_widget_class_bind_template_child (widget_class, GbpFlatpakCloneWidget, clone_progress);
}
@@ -244,21 +256,30 @@ gbp_flatpak_clone_widget_init (GbpFlatpakCloneWidget *self)
static gboolean
open_after_timeout (gpointer user_data)
{
+ g_autoptr(IdeProjectInfo) project_info = NULL;
g_autoptr(IdeTask) task = user_data;
- DownloadRequest *req;
GbpFlatpakCloneWidget *self;
- IdeWorkbench *workbench;
+ DownloadRequest *req;
+ GtkWidget *workspace;
IDE_ENTRY;
req = ide_task_get_task_data (task);
self = ide_task_get_source_object (task);
+
g_assert (GBP_IS_FLATPAK_CLONE_WIDGET (self));
+ g_assert (req != NULL);
+ g_assert (G_IS_FILE (req->project_file));
- workbench = ide_widget_get_workbench (GTK_WIDGET (self));
- g_assert (IDE_IS_WORKBENCH (workbench));
+ /* Maybe we were shut mid-operation? */
+ if (!(workspace = gtk_widget_get_ancestor (GTK_WIDGET (self), IDE_TYPE_GREETER_WORKSPACE)))
+ IDE_RETURN (G_SOURCE_REMOVE);
- ide_workbench_open_project_async (workbench, req->project_file, NULL, NULL, NULL);
+ project_info = ide_project_info_new ();
+ ide_project_info_set_file (project_info, req->project_file);
+ ide_project_info_set_directory (project_info, req->project_file);
+
+ ide_greeter_workspace_open_project (IDE_GREETER_WORKSPACE (workspace), project_info);
IDE_RETURN (G_SOURCE_REMOVE);
}
@@ -370,7 +391,6 @@ download_flatpak_sources_if_required (GbpFlatpakCloneWidget *self,
g_autoptr(GgitObject) parsed_rev = NULL;
g_autoptr(GgitRemoteCallbacks) callbacks = NULL;
g_autoptr(GgitRepository) repository = NULL;
- g_autoptr(IdeProgress) progress = NULL;
GType git_callbacks_type;
/* First, try to open an existing repository at this path */
@@ -387,16 +407,19 @@ download_flatpak_sources_if_required (GbpFlatpakCloneWidget *self,
if (repository == NULL)
{
+ g_autoptr(IdeNotification) progress = ide_notification_new ();
+
/* HACK: we don't want libide to depend on libgit2 just yet, so for
* now, we just lookup the GType of the object we need from the git
* plugin by name.
*/
- git_callbacks_type = g_type_from_name ("IdeGitRemoteCallbacks");
+ git_callbacks_type = g_type_from_name ("GbpGitRemoteCallbacks");
g_assert (git_callbacks_type != 0);
- callbacks = g_object_new (git_callbacks_type, NULL);
- g_object_get (callbacks, "progress", &progress, NULL);
- g_object_bind_property (progress, "fraction", self->clone_progress, "fraction", 0);
+ callbacks = g_object_new (git_callbacks_type,
+ "progress", progress,
+ NULL);
+ g_object_bind_property (progress, "progress", self->clone_progress, "fraction", 0);
fetch_options = ggit_fetch_options_new ();
ggit_fetch_options_set_remote_callbacks (fetch_options, callbacks);
@@ -745,8 +768,7 @@ gbp_flatpak_clone_widget_clone_async (GbpFlatpakCloneWidget *self,
}
}
- destination = ide_application_get_projects_directory (IDE_APPLICATION_DEFAULT);
- g_assert (G_IS_FILE (destination));
+ destination = g_file_new_for_path (ide_get_projects_dir ());
if (self->child_name)
{
diff --git a/src/plugins/flatpak/gbp-flatpak-clone-widget.h b/src/plugins/flatpak/gbp-flatpak-clone-widget.h
index d004a5b34..70bf5c178 100644
--- a/src/plugins/flatpak/gbp-flatpak-clone-widget.h
+++ b/src/plugins/flatpak/gbp-flatpak-clone-widget.h
@@ -26,7 +26,7 @@ G_BEGIN_DECLS
#define GBP_TYPE_FLATPAK_CLONE_WIDGET (gbp_flatpak_clone_widget_get_type())
-G_DECLARE_FINAL_TYPE (GbpFlatpakCloneWidget, gbp_flatpak_clone_widget, GBP, FLATPAK_CLONE_WIDGET, GtkBin)
+G_DECLARE_FINAL_TYPE (GbpFlatpakCloneWidget, gbp_flatpak_clone_widget, GBP, FLATPAK_CLONE_WIDGET, IdeSurface)
void gbp_flatpak_clone_widget_clone_async (GbpFlatpakCloneWidget *self,
GCancellable *cancellable,
diff --git a/src/plugins/flatpak/gbp-flatpak-clone-widget.ui b/src/plugins/flatpak/gbp-flatpak-clone-widget.ui
index a626cf66c..c49580178 100644
--- a/src/plugins/flatpak/gbp-flatpak-clone-widget.ui
+++ b/src/plugins/flatpak/gbp-flatpak-clone-widget.ui
@@ -1,48 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <!-- interface-requires gtk+ 3.18 -->
- <template class="GbpFlatpakCloneWidget" parent="GtkBin">
+ <!-- interface-requires gtk+ 3.24 -->
+ <template class="GbpFlatpakCloneWidget" parent="IdeSurface">
<child>
- <object class="GtkOverlay" id="page_clone_remote">
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <property name="valign">center</property>
+ <property name="vexpand">true</property>
<property name="visible">true</property>
- <child type="overlay">
- <object class="GtkProgressBar" id="clone_progress">
- <property name="valign">start</property>
- <property name="fraction">0.0</property>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">document-save-symbolic</property>
+ <property name="pixel-size">128</property>
<property name="visible">true</property>
+ <property name="margin">12</property>
<style>
- <class name="osd"/>
+ <class name="dim-label"/>
</style>
</object>
</child>
<child>
- <object class="GtkBox">
- <property name="orientation">vertical</property>
- <property name="spacing">12</property>
- <property name="valign">center</property>
- <property name="vexpand">true</property>
+ <object class="GtkProgressBar" id="clone_progress">
+ <property name="halign">center</property>
+ <property name="width-request">500</property>
+ <property name="fraction">0.0</property>
<property name="visible">true</property>
- <child>
- <object class="GtkImage">
- <property name="icon-name">document-save-symbolic</property>
- <property name="pixel-size">128</property>
- <property name="visible">true</property>
- <property name="margin">12</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Downloading application sources…</property>
- <property name="margin-bottom">24</property>
- <property name="visible">true</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="label" translatable="yes">Downloading application sources…</property>
+ <property name="margin-bottom">24</property>
+ <property name="visible">true</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
</object>
</child>
</object>
diff --git a/src/plugins/flatpak/gbp-flatpak-configuration-provider.c
b/src/plugins/flatpak/gbp-flatpak-configuration-provider.c
index f094732c2..5f2c7bfab 100644
--- a/src/plugins/flatpak/gbp-flatpak-configuration-provider.c
+++ b/src/plugins/flatpak/gbp-flatpak-configuration-provider.c
@@ -23,6 +23,7 @@
#include <flatpak.h>
#include <glib/gi18n.h>
#include <json-glib/json-glib.h>
+#include <libide-vcs.h>
#include <string.h>
#include "gbp-flatpak-configuration-provider.h"
@@ -152,7 +153,6 @@ load_manifest_worker (IdeTask *task,
g_autoptr(GbpFlatpakManifest) manifest = NULL;
g_autoptr(GError) error = NULL;
g_autofree gchar *name = NULL;
- IdeContext *context;
GFile *file = task_data;
g_assert (IDE_IS_TASK (task));
@@ -160,12 +160,13 @@ load_manifest_worker (IdeTask *task,
g_assert (G_IS_FILE (file));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
- context = ide_object_get_context (IDE_OBJECT (self));
name = g_file_get_basename (file);
- manifest = gbp_flatpak_manifest_new (context, file, name);
+ manifest = gbp_flatpak_manifest_new (file, name);
+ ide_object_append (IDE_OBJECT (self), IDE_OBJECT (manifest));
if (!g_initable_init (G_INITABLE (manifest), cancellable, &error))
{
+ ide_clear_and_destroy_object (&manifest);
ide_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -248,7 +249,7 @@ reload_manifest_cb (GObject *object,
g_ptr_array_add (self->configs, g_object_ref (new_manifest));
context = ide_object_get_context (IDE_OBJECT (self));
- manager = ide_context_get_configuration_manager (context);
+ manager = ide_configuration_manager_from_context (context);
current = ide_configuration_manager_get_current (manager);
is_active = current == IDE_CONFIGURATION (old_manifest);
@@ -298,7 +299,6 @@ gbp_flatpak_configuration_provider_load_worker (IdeTask *task,
{
GbpFlatpakConfigurationProvider *self = source_object;
g_autoptr(GPtrArray) manifests = NULL;
- IdeContext *context;
GPtrArray *files = task_data;
g_assert (IDE_IS_TASK (task));
@@ -306,7 +306,6 @@ gbp_flatpak_configuration_provider_load_worker (IdeTask *task,
g_assert (files != NULL);
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
- context = ide_object_get_context (IDE_OBJECT (self));
manifests = g_ptr_array_new_with_free_func (g_object_unref);
for (guint i = 0; i < files->len; i++)
@@ -319,10 +318,12 @@ gbp_flatpak_configuration_provider_load_worker (IdeTask *task,
g_assert (G_IS_FILE (file));
name = g_file_get_basename (file);
- manifest = gbp_flatpak_manifest_new (context, file, name);
+ manifest = gbp_flatpak_manifest_new (file, name);
+ ide_object_append (IDE_OBJECT (self), IDE_OBJECT (manifest));
if (!g_initable_init (G_INITABLE (manifest), cancellable, &error))
{
+ ide_clear_and_destroy_object (&manifest);
g_message ("%s is not a flatpak manifest, skipping: %s",
name, error->message);
continue;
@@ -425,13 +426,13 @@ gbp_flatpak_configuration_provider_monitor_changed (GbpFlatpakConfigurationProvi
{
g_autoptr(GbpFlatpakManifest) manifest = NULL;
g_autoptr(GError) error = NULL;
- IdeContext *context;
- context = ide_object_get_context (IDE_OBJECT (self));
- manifest = gbp_flatpak_manifest_new (context, file, name);
+ manifest = gbp_flatpak_manifest_new (file, name);
+ ide_object_append (IDE_OBJECT (self), IDE_OBJECT (manifest));
if (!g_initable_init (G_INITABLE (manifest), NULL, &error))
{
+ ide_clear_and_destroy_object (&manifest);
g_message ("%s is not a flatpak manifest, skipping: %s",
name, error->message);
return;
@@ -471,9 +472,9 @@ gbp_flatpak_configuration_provider_load_async (IdeConfigurationProvider *provide
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
context = ide_object_get_context (IDE_OBJECT (self));
- vcs = ide_context_get_vcs (context);
- workdir = ide_vcs_get_working_directory (vcs);
- monitor = ide_context_get_monitor (context);
+ vcs = ide_vcs_from_context (context);
+ workdir = ide_vcs_get_workdir (vcs);
+ monitor = ide_context_peek_child_typed (context, IDE_TYPE_VCS_MONITOR);
task = ide_task_new (provider, cancellable, callback, user_data);
ide_task_set_source_tag (task, gbp_flatpak_configuration_provider_load_async);
@@ -563,7 +564,7 @@ gbp_flatpak_configuration_provider_load_finish (IdeConfigurationProvider *provi
{
IdeConfiguration *config = guess_best_config (configs);
IdeContext *context = ide_object_get_context (IDE_OBJECT (self));
- IdeConfigurationManager *manager = ide_context_get_configuration_manager (context);
+ IdeConfigurationManager *manager = ide_configuration_manager_from_context (context);
g_assert (IDE_IS_CONFIGURATION (config));
diff --git a/src/plugins/flatpak/gbp-flatpak-configuration-provider.h
b/src/plugins/flatpak/gbp-flatpak-configuration-provider.h
index 25a276cf5..fd5bccaf9 100644
--- a/src/plugins/flatpak/gbp-flatpak-configuration-provider.h
+++ b/src/plugins/flatpak/gbp-flatpak-configuration-provider.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-foundry.h>
G_BEGIN_DECLS
diff --git a/src/plugins/flatpak/gbp-flatpak-dependency-updater.c
b/src/plugins/flatpak/gbp-flatpak-dependency-updater.c
index 07a9923a6..a427250c4 100644
--- a/src/plugins/flatpak/gbp-flatpak-dependency-updater.c
+++ b/src/plugins/flatpak/gbp-flatpak-dependency-updater.c
@@ -83,7 +83,7 @@ gbp_flatpak_dependency_updater_update_async (IdeDependencyUpdater *updater,
context = ide_object_get_context (IDE_OBJECT (self));
g_assert (IDE_IS_CONTEXT (context));
- manager = ide_context_get_build_manager (context);
+ manager = ide_build_manager_from_context (context);
g_assert (IDE_IS_BUILD_MANAGER (manager));
pipeline = ide_build_manager_get_pipeline (manager);
@@ -119,6 +119,7 @@ gbp_flatpak_dependency_updater_update_async (IdeDependencyUpdater *updater,
ide_build_manager_rebuild_async (manager,
IDE_BUILD_PHASE_CONFIGURE,
NULL,
+ NULL,
gbp_flatpak_dependency_updater_update_cb,
g_steal_pointer (&task));
}
diff --git a/src/plugins/flatpak/gbp-flatpak-dependency-updater.h
b/src/plugins/flatpak/gbp-flatpak-dependency-updater.h
index 5d71456ec..7d2b32f56 100644
--- a/src/plugins/flatpak/gbp-flatpak-dependency-updater.h
+++ b/src/plugins/flatpak/gbp-flatpak-dependency-updater.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-foundry.h>
G_BEGIN_DECLS
diff --git a/src/plugins/flatpak/gbp-flatpak-download-stage.c
b/src/plugins/flatpak/gbp-flatpak-download-stage.c
index fe3169bb4..5651b781e 100644
--- a/src/plugins/flatpak/gbp-flatpak-download-stage.c
+++ b/src/plugins/flatpak/gbp-flatpak-download-stage.c
@@ -21,6 +21,7 @@
#define G_LOG_DOMAIN "gbp-flatpak-download-stage"
#include <glib/gi18n.h>
+#include <libide-gui.h>
#include "gbp-flatpak-download-stage.h"
#include "gbp-flatpak-manifest.h"
@@ -49,6 +50,7 @@ static GParamSpec *properties [N_PROPS];
static void
gbp_flatpak_download_stage_query (IdeBuildStage *stage,
IdeBuildPipeline *pipeline,
+ GPtrArray *targets,
GCancellable *cancellable)
{
GbpFlatpakDownloadStage *self = (GbpFlatpakDownloadStage *)stage;
@@ -192,7 +194,7 @@ gbp_flatpak_download_stage_class_init (GbpFlatpakDownloadStageClass *klass)
* The "state-dir" is the flatpak-builder state directory, to be used
* as a parameter to "flatpak-builder --state-dir".
*
- * Since: 3.32
+ * Since: 3.28
*/
properties [PROP_STATE_DIR] =
g_param_spec_string ("state-dir",
diff --git a/src/plugins/flatpak/gbp-flatpak-download-stage.h
b/src/plugins/flatpak/gbp-flatpak-download-stage.h
index 70d5225d0..3dff748e8 100644
--- a/src/plugins/flatpak/gbp-flatpak-download-stage.h
+++ b/src/plugins/flatpak/gbp-flatpak-download-stage.h
@@ -20,17 +20,13 @@
#pragma once
-#include <ide.h>
+#include <libide-foundry.h>
G_BEGIN_DECLS
#define GBP_TYPE_FLATPAK_DOWNLOAD_STAGE (gbp_flatpak_download_stage_get_type())
-G_DECLARE_FINAL_TYPE (GbpFlatpakDownloadStage,
- gbp_flatpak_download_stage,
- GBP,
- FLATPAK_DOWNLOAD_STAGE,
- IdeBuildStageLauncher)
+G_DECLARE_FINAL_TYPE (GbpFlatpakDownloadStage, gbp_flatpak_download_stage, GBP, FLATPAK_DOWNLOAD_STAGE,
IdeBuildStageLauncher)
void gbp_flatpak_download_stage_force_update (GbpFlatpakDownloadStage *self);
diff --git a/src/plugins/flatpak/gbp-flatpak-manifest.c b/src/plugins/flatpak/gbp-flatpak-manifest.c
index 8217c9926..2a5a02bd3 100644
--- a/src/plugins/flatpak/gbp-flatpak-manifest.c
+++ b/src/plugins/flatpak/gbp-flatpak-manifest.c
@@ -343,12 +343,11 @@ gbp_flatpak_manifest_initable_init (GInitable *initable,
g_auto(GStrv) build_commands = NULL;
g_auto(GStrv) post_install = NULL;
const gchar *app_id_field = "app-id";
- IdeContext *context;
+ g_autoptr(IdeContext) context = NULL;
+ g_autoptr(GFile) workdir = NULL;
JsonObject *root_obj;
JsonObject *primary;
JsonNode *root;
- IdeVcs *vcs;
- GFile *workdir;
gsize len = 0;
g_assert (GBP_IS_FLATPAK_MANIFEST (self));
@@ -377,9 +376,8 @@ gbp_flatpak_manifest_initable_init (GInitable *initable,
display_name = g_file_get_basename (self->file);
ide_configuration_set_display_name (IDE_CONFIGURATION (self), display_name);
- context = ide_object_get_context (IDE_OBJECT (self));
- vcs = ide_context_get_vcs (context);
- workdir = ide_vcs_get_working_directory (vcs);
+ context = ide_object_ref_context (IDE_OBJECT (self));
+ workdir = ide_context_ref_workdir (context);
dir_name = g_file_get_basename (workdir);
root_obj = json_node_get_object (root);
@@ -655,12 +653,13 @@ gbp_flatpak_manifest_init (GbpFlatpakManifest *self)
}
GbpFlatpakManifest *
-gbp_flatpak_manifest_new (IdeContext *context,
- GFile *file,
+gbp_flatpak_manifest_new (GFile *file,
const gchar *id)
{
+ g_return_val_if_fail (G_IS_FILE (file), NULL);
+ g_return_val_if_fail (id != NULL, NULL);
+
return g_object_new (GBP_TYPE_FLATPAK_MANIFEST,
- "context", context,
"id", id,
"file", file,
NULL);
@@ -672,8 +671,6 @@ gbp_flatpak_manifest_new (IdeContext *context,
* Gets the #GFile for the manifest.
*
* Returns: (transfer none): a #GFile
- *
- * Since: 3.32
*/
GFile *
gbp_flatpak_manifest_get_file (GbpFlatpakManifest *self)
@@ -688,8 +685,6 @@ gbp_flatpak_manifest_get_file (GbpFlatpakManifest *self)
*
* Gets the name of the primary module, which is usually the last
* module of manifest.
- *
- * Since: 3.32
*/
const gchar *
gbp_flatpak_manifest_get_primary_module (GbpFlatpakManifest *self)
@@ -703,8 +698,6 @@ gbp_flatpak_manifest_get_primary_module (GbpFlatpakManifest *self)
* gbp_flatpak_manifest_get_command:
*
* Gets the "command" specified in the manifest.
- *
- * Since: 3.32
*/
const gchar *
gbp_flatpak_manifest_get_command (GbpFlatpakManifest *self)
@@ -718,8 +711,6 @@ gbp_flatpak_manifest_get_command (GbpFlatpakManifest *self)
* gbp_flatpak_manifest_get_build_args:
*
* Gets the "build-args" from the manifest as a string array.
- *
- * Since: 3.32
*/
const gchar * const *
gbp_flatpak_manifest_get_build_args (GbpFlatpakManifest *self)
@@ -733,8 +724,6 @@ gbp_flatpak_manifest_get_build_args (GbpFlatpakManifest *self)
* gbp_flatpak_manifest_get_finish_args:
*
* Gets the "finish-args" from the manifest as a string array.
- *
- * Since: 3.32
*/
const gchar * const *
gbp_flatpak_manifest_get_finish_args (GbpFlatpakManifest *self)
@@ -748,8 +737,6 @@ gbp_flatpak_manifest_get_finish_args (GbpFlatpakManifest *self)
* gbp_flatpak_manifest_get_sdk_extensions:
*
* Gets the "sdk-extensions" from the manifest as a string array.
- *
- * Since: 3.32
*/
const gchar * const *
gbp_flatpak_manifest_get_sdk_extensions (GbpFlatpakManifest *self)
@@ -764,8 +751,6 @@ gbp_flatpak_manifest_get_sdk_extensions (GbpFlatpakManifest *self)
*
* Gets the path for the manifest. This is equivalent to calling
* g_file_get_path() with the result of gbp_flatpak_manifest_get_file().
- *
- * Since: 3.32
*/
gchar *
gbp_flatpak_manifest_get_path (GbpFlatpakManifest *self)
diff --git a/src/plugins/flatpak/gbp-flatpak-manifest.h b/src/plugins/flatpak/gbp-flatpak-manifest.h
index e38decf74..2103ee0ed 100644
--- a/src/plugins/flatpak/gbp-flatpak-manifest.h
+++ b/src/plugins/flatpak/gbp-flatpak-manifest.h
@@ -21,7 +21,7 @@
#pragma once
-#include <ide.h>
+#include <libide-foundry.h>
G_BEGIN_DECLS
@@ -29,8 +29,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GbpFlatpakManifest, gbp_flatpak_manifest, GBP, FLATPAK_MANIFEST, IdeConfiguration)
-GbpFlatpakManifest *gbp_flatpak_manifest_new (IdeContext *context,
- GFile *file,
+GbpFlatpakManifest *gbp_flatpak_manifest_new (GFile *file,
const gchar *id);
GFile *gbp_flatpak_manifest_get_file (GbpFlatpakManifest *self);
const gchar *gbp_flatpak_manifest_get_primary_module (GbpFlatpakManifest *self);
diff --git a/src/plugins/flatpak/gbp-flatpak-pipeline-addin.c
b/src/plugins/flatpak/gbp-flatpak-pipeline-addin.c
index 670024f14..e70f5c17e 100644
--- a/src/plugins/flatpak/gbp-flatpak-pipeline-addin.c
+++ b/src/plugins/flatpak/gbp-flatpak-pipeline-addin.c
@@ -112,10 +112,15 @@ sniff_flatpak_builder_version (GbpFlatpakPipelineAddin *self)
static void
always_run_query_handler (IdeBuildStage *stage,
- IdeBuildPipeline *pipeline)
+ GPtrArray *targets,
+ IdeBuildPipeline *pipeline,
+ GCancellable *cancellable,
+ gpointer user_data)
{
- g_return_if_fail (IDE_IS_BUILD_STAGE (stage));
- g_return_if_fail (IDE_IS_BUILD_PIPELINE (pipeline));
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (IDE_IS_BUILD_STAGE (stage));
+ g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
+ g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
ide_build_stage_set_completed (stage, FALSE);
}
@@ -157,7 +162,7 @@ register_mkdirs_stage (GbpFlatpakPipelineAddin *self,
ide_build_stage_mkdirs_add_path (IDE_BUILD_STAGE_MKDIRS (mkdirs), repo_dir, TRUE, 0750, FALSE);
ide_build_stage_mkdirs_add_path (IDE_BUILD_STAGE_MKDIRS (mkdirs), staging_dir, TRUE, 0750, TRUE);
- stage_id = ide_build_pipeline_connect (pipeline, IDE_BUILD_PHASE_PREPARE, PREPARE_MKDIRS, mkdirs);
+ stage_id = ide_build_pipeline_attach (pipeline, IDE_BUILD_PHASE_PREPARE, PREPARE_MKDIRS, mkdirs);
ide_build_pipeline_addin_track (IDE_BUILD_PIPELINE_ADDIN (self), stage_id);
@@ -192,6 +197,7 @@ reap_staging_dir_cb (GObject *object,
static void
check_for_build_init_files (IdeBuildStage *stage,
IdeBuildPipeline *pipeline,
+ GPtrArray *targets,
GCancellable *cancellable,
const gchar *staging_dir)
{
@@ -201,6 +207,7 @@ check_for_build_init_files (IdeBuildStage *stage,
gboolean completed = FALSE;
gboolean parent_exists;
+ g_assert (IDE_IS_MAIN_THREAD ());
g_assert (IDE_IS_BUILD_STAGE (stage));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
g_assert (staging_dir != NULL);
@@ -329,7 +336,6 @@ register_build_init_stage (GbpFlatpakPipelineAddin *self,
stage = g_object_new (IDE_TYPE_BUILD_STAGE_LAUNCHER,
"name", _("Preparing build directory"),
- "context", context,
"launcher", launcher,
NULL);
@@ -356,7 +362,7 @@ register_build_init_stage (GbpFlatpakPipelineAddin *self,
(GClosureNotify)g_free,
0);
- stage_id = ide_build_pipeline_connect (pipeline,
+ stage_id = ide_build_pipeline_attach (pipeline,
IDE_BUILD_PHASE_PREPARE,
PREPARE_BUILD_INIT,
stage);
@@ -380,10 +386,9 @@ register_downloads_stage (GbpFlatpakPipelineAddin *self,
stage = g_object_new (GBP_TYPE_FLATPAK_DOWNLOAD_STAGE,
"name", _("Downloading dependencies"),
- "context", context,
"state-dir", self->state_dir,
NULL);
- stage_id = ide_build_pipeline_connect (pipeline, IDE_BUILD_PHASE_DOWNLOADS, 0, stage);
+ stage_id = ide_build_pipeline_attach (pipeline, IDE_BUILD_PHASE_DOWNLOADS, 0, stage);
ide_build_pipeline_addin_track (IDE_BUILD_PIPELINE_ADDIN (self), stage_id);
return TRUE;
@@ -460,11 +465,10 @@ register_dependencies_stage (GbpFlatpakPipelineAddin *self,
stage = g_object_new (IDE_TYPE_BUILD_STAGE_LAUNCHER,
"name", _("Building dependencies"),
- "context", context,
"launcher", launcher,
NULL);
- stage_id = ide_build_pipeline_connect (pipeline, IDE_BUILD_PHASE_DEPENDENCIES, 0, stage);
+ stage_id = ide_build_pipeline_attach (pipeline, IDE_BUILD_PHASE_DEPENDENCIES, 0, stage);
ide_build_pipeline_addin_track (IDE_BUILD_PIPELINE_ADDIN (self), stage_id);
return TRUE;
@@ -512,11 +516,10 @@ register_build_finish_stage (GbpFlatpakPipelineAddin *self,
stage = g_object_new (IDE_TYPE_BUILD_STAGE_LAUNCHER,
"name", _("Finalizing flatpak build"),
- "context", context,
"launcher", launcher,
NULL);
- stage_id = ide_build_pipeline_connect (pipeline, IDE_BUILD_PHASE_COMMIT, COMMIT_BUILD_FINISH, stage);
+ stage_id = ide_build_pipeline_attach (pipeline, IDE_BUILD_PHASE_COMMIT, COMMIT_BUILD_FINISH, stage);
ide_build_pipeline_addin_track (IDE_BUILD_PIPELINE_ADDIN (self), stage_id);
return TRUE;
@@ -558,7 +561,6 @@ register_build_export_stage (GbpFlatpakPipelineAddin *self,
stage = g_object_new (IDE_TYPE_BUILD_STAGE_LAUNCHER,
"name", _("Exporting staging directory"),
- "context", context,
"launcher", launcher,
NULL);
@@ -567,7 +569,7 @@ register_build_export_stage (GbpFlatpakPipelineAddin *self,
G_CALLBACK (always_run_query_handler),
NULL);
- stage_id = ide_build_pipeline_connect (pipeline, IDE_BUILD_PHASE_COMMIT, COMMIT_BUILD_EXPORT, stage);
+ stage_id = ide_build_pipeline_attach (pipeline, IDE_BUILD_PHASE_COMMIT, COMMIT_BUILD_EXPORT, stage);
ide_build_pipeline_addin_track (IDE_BUILD_PIPELINE_ADDIN (self), stage_id);
return TRUE;
@@ -644,7 +646,6 @@ register_build_bundle_stage (GbpFlatpakPipelineAddin *self,
stage = g_object_new (IDE_TYPE_BUILD_STAGE_LAUNCHER,
"name", _("Creating flatpak bundle"),
- "context", context,
"launcher", launcher,
NULL);
@@ -660,7 +661,7 @@ register_build_bundle_stage (GbpFlatpakPipelineAddin *self,
(GClosureNotify)g_free,
0);
- stage_id = ide_build_pipeline_connect (pipeline, IDE_BUILD_PHASE_EXPORT, EXPORT_BUILD_BUNDLE, stage);
+ stage_id = ide_build_pipeline_attach (pipeline, IDE_BUILD_PHASE_EXPORT, EXPORT_BUILD_BUNDLE, stage);
ide_build_pipeline_addin_track (IDE_BUILD_PIPELINE_ADDIN (self), stage_id);
return TRUE;
diff --git a/src/plugins/flatpak/gbp-flatpak-pipeline-addin.h
b/src/plugins/flatpak/gbp-flatpak-pipeline-addin.h
index 97b99c4d6..4a307ec56 100644
--- a/src/plugins/flatpak/gbp-flatpak-pipeline-addin.h
+++ b/src/plugins/flatpak/gbp-flatpak-pipeline-addin.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-foundry.h>
G_BEGIN_DECLS
diff --git a/src/plugins/flatpak/gbp-flatpak-preferences-addin.c
b/src/plugins/flatpak/gbp-flatpak-preferences-addin.c
index aafdf9bf6..04e4f2087 100644
--- a/src/plugins/flatpak/gbp-flatpak-preferences-addin.c
+++ b/src/plugins/flatpak/gbp-flatpak-preferences-addin.c
@@ -23,6 +23,7 @@
#include <flatpak.h>
#include <glib/gi18n.h>
+#include <libide-gui.h>
#include "gbp-flatpak-application-addin.h"
#include "gbp-flatpak-preferences-addin.h"
diff --git a/src/plugins/flatpak/gbp-flatpak-preferences-addin.h
b/src/plugins/flatpak/gbp-flatpak-preferences-addin.h
index 16aabe69a..207d1b22d 100644
--- a/src/plugins/flatpak/gbp-flatpak-preferences-addin.h
+++ b/src/plugins/flatpak/gbp-flatpak-preferences-addin.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-gui.h>
G_BEGIN_DECLS
diff --git a/src/plugins/flatpak/gbp-flatpak-runner.c b/src/plugins/flatpak/gbp-flatpak-runner.c
index aa83156de..2925784df 100644
--- a/src/plugins/flatpak/gbp-flatpak-runner.c
+++ b/src/plugins/flatpak/gbp-flatpak-runner.c
@@ -68,7 +68,7 @@ gbp_flatpak_runner_fixup_launcher (IdeRunner *runner,
g_assert (IDE_IS_SUBPROCESS_LAUNCHER (launcher));
context = ide_object_get_context (IDE_OBJECT (self));
- config_manager = ide_context_get_configuration_manager (context);
+ config_manager = ide_configuration_manager_from_context (context);
config = ide_configuration_manager_get_current (config_manager);
app_id = ide_configuration_get_app_id (config);
@@ -152,9 +152,7 @@ gbp_flatpak_runner_new (IdeContext *context,
g_return_val_if_fail (IDE_IS_CONTEXT (context), NULL);
- self = g_object_new (GBP_TYPE_FLATPAK_RUNNER,
- "context", context,
- NULL);
+ self = g_object_new (GBP_TYPE_FLATPAK_RUNNER, NULL);
if (binary_path != NULL)
ide_runner_append_argv (IDE_RUNNER (self), binary_path);
diff --git a/src/plugins/flatpak/gbp-flatpak-runner.h b/src/plugins/flatpak/gbp-flatpak-runner.h
index 8fe1fd3d2..0f7d226fd 100644
--- a/src/plugins/flatpak/gbp-flatpak-runner.h
+++ b/src/plugins/flatpak/gbp-flatpak-runner.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-foundry.h>
G_BEGIN_DECLS
diff --git a/src/plugins/flatpak/gbp-flatpak-runtime-provider.c
b/src/plugins/flatpak/gbp-flatpak-runtime-provider.c
index 88d7294bb..3e71a0f77 100644
--- a/src/plugins/flatpak/gbp-flatpak-runtime-provider.c
+++ b/src/plugins/flatpak/gbp-flatpak-runtime-provider.c
@@ -24,8 +24,6 @@
#include <ostree.h>
#include <string.h>
-#include "util/ide-posix.h"
-
#include "gbp-flatpak-application-addin.h"
#include "gbp-flatpak-manifest.h"
#include "gbp-flatpak-runtime.h"
@@ -57,7 +55,7 @@ typedef struct
struct _GbpFlatpakRuntimeProvider
{
- GObject parent_instance;
+ IdeObject parent_instance;
IdeRuntimeManager *manager;
GPtrArray *runtimes;
};
@@ -68,7 +66,7 @@ static void gbp_flatpak_runtime_provider_load (IdeRuntimeProvider *pr
static void gbp_flatpak_runtime_provider_unload (IdeRuntimeProvider *provider,
IdeRuntimeManager *manager);
-G_DEFINE_TYPE_WITH_CODE (GbpFlatpakRuntimeProvider, gbp_flatpak_runtime_provider, G_TYPE_OBJECT,
+G_DEFINE_TYPE_WITH_CODE (GbpFlatpakRuntimeProvider, gbp_flatpak_runtime_provider, IDE_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (IDE_TYPE_RUNTIME_PROVIDER, runtime_provider_iface_init))
static void
@@ -115,6 +113,20 @@ is_same_runtime (GbpFlatpakRuntime *runtime,
gbp_flatpak_runtime_get_branch (runtime)) == 0);
}
+static void
+monitor_transfer (GbpFlatpakRuntimeProvider *self,
+ GbpFlatpakTransfer *transfer)
+{
+ g_autoptr(IdeNotification) notif = NULL;
+
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_FLATPAK_RUNTIME_PROVIDER (self));
+ g_assert (GBP_IS_FLATPAK_TRANSFER (transfer));
+
+ notif = ide_transfer_create_notification (IDE_TRANSFER (transfer));
+ ide_notification_attach (notif, IDE_OBJECT (self));
+}
+
static void
runtime_added_cb (GbpFlatpakRuntimeProvider *self,
FlatpakInstalledRef *ref,
@@ -123,7 +135,6 @@ runtime_added_cb (GbpFlatpakRuntimeProvider *self,
g_autoptr(GbpFlatpakRuntime) new_runtime = NULL;
g_autoptr(GError) error = NULL;
const gchar *name;
- IdeContext *context;
IDE_ENTRY;
@@ -153,13 +164,16 @@ runtime_added_cb (GbpFlatpakRuntimeProvider *self,
* We didn't already have this runtime, so go ahead and just
* add it now (and keep a copy so we can find it later).
*/
- context = ide_object_get_context (IDE_OBJECT (self->manager));
- new_runtime = gbp_flatpak_runtime_new (context, ref, NULL, &error);
+ new_runtime = gbp_flatpak_runtime_new (ref, NULL, &error);
if (new_runtime == NULL)
- g_warning ("Failed to create GbpFlatpakRuntime: %s", error->message);
+ {
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
+ g_warning ("Failed to create GbpFlatpakRuntime: %s", error->message);
+ }
else
{
+ ide_object_append (IDE_OBJECT (self), IDE_OBJECT (new_runtime));
ide_runtime_manager_add (self->manager, IDE_RUNTIME (new_runtime));
g_ptr_array_add (self->runtimes, g_steal_pointer (&new_runtime));
}
@@ -327,6 +341,7 @@ gbp_flatpak_runtime_provider_locate_sdk_cb (GObject *object,
g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL;
g_autofree gchar *docs_id = NULL;
+ GbpFlatpakRuntimeProvider *self;
IdeTransferManager *transfer_manager;
InstallRuntime *install;
GCancellable *cancellable;
@@ -339,13 +354,15 @@ gbp_flatpak_runtime_provider_locate_sdk_cb (GObject *object,
g_assert (IDE_IS_TASK (task));
g_assert (!ide_task_get_completed (task));
+ self = ide_task_get_source_object (task);
install = ide_task_get_task_data (task);
cancellable = ide_task_get_cancellable (task);
+ g_assert (GBP_IS_FLATPAK_RUNTIME_PROVIDER (self));
g_assert (install != NULL);
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
- transfer_manager = ide_application_get_transfer_manager (IDE_APPLICATION_DEFAULT);
+ transfer_manager = ide_transfer_manager_get_default ();
if (!gbp_flatpak_application_addin_locate_sdk_finish (app_addin,
result,
@@ -377,6 +394,7 @@ gbp_flatpak_runtime_provider_locate_sdk_cb (GObject *object,
install->arch,
install->branch,
FALSE);
+ monitor_transfer (self, transfer);
ide_transfer_manager_execute_async (transfer_manager,
IDE_TRANSFER (transfer),
cancellable,
@@ -402,6 +420,7 @@ gbp_flatpak_runtime_provider_locate_sdk_cb (GObject *object,
install->sdk_arch,
install->sdk_branch,
FALSE);
+ monitor_transfer (self, transfer);
ide_transfer_manager_execute_async (transfer_manager,
IDE_TRANSFER (transfer),
cancellable,
@@ -425,6 +444,7 @@ gbp_flatpak_runtime_provider_locate_sdk_cb (GObject *object,
install->arch,
install->branch,
FALSE);
+ monitor_transfer (self, transfer);
ide_transfer_manager_execute_async (transfer_manager,
IDE_TRANSFER (transfer),
cancellable,
@@ -583,7 +603,7 @@ gbp_flatpak_runtime_provider_bootstrap_cb (GObject *object,
state->branch);
context = ide_object_get_context (IDE_OBJECT (self->manager));
- runtime_manager = ide_context_get_runtime_manager (context);
+ runtime_manager = ide_runtime_manager_from_context (context);
runtime = ide_runtime_manager_get_runtime (runtime_manager, runtime_id);
if (runtime == NULL)
@@ -656,7 +676,7 @@ gbp_flatpak_runtime_provider_bootstrap_async (IdeRuntimeProvider *provider,
GbpFlatpakApplicationAddin *addin;
const gchar * const *sdk_exts;
- transfer_manager = ide_application_get_transfer_manager (IDE_APPLICATION_DEFAULT);
+ transfer_manager = ide_transfer_manager_get_default ();
addin = gbp_flatpak_application_addin_get_default ();
sdk_exts = gbp_flatpak_manifest_get_sdk_extensions (GBP_FLATPAK_MANIFEST (state->config));
diff --git a/src/plugins/flatpak/gbp-flatpak-runtime-provider.h
b/src/plugins/flatpak/gbp-flatpak-runtime-provider.h
index 0bf5a9922..25aab0cb2 100644
--- a/src/plugins/flatpak/gbp-flatpak-runtime-provider.h
+++ b/src/plugins/flatpak/gbp-flatpak-runtime-provider.h
@@ -26,6 +26,6 @@ G_BEGIN_DECLS
#define GBP_TYPE_FLATPAK_RUNTIME_PROVIDER (gbp_flatpak_runtime_provider_get_type())
-G_DECLARE_FINAL_TYPE (GbpFlatpakRuntimeProvider, gbp_flatpak_runtime_provider, GBP,
FLATPAK_RUNTIME_PROVIDER, GObject)
+G_DECLARE_FINAL_TYPE (GbpFlatpakRuntimeProvider, gbp_flatpak_runtime_provider, GBP,
FLATPAK_RUNTIME_PROVIDER, IdeObject)
G_END_DECLS
diff --git a/src/plugins/flatpak/gbp-flatpak-runtime.c b/src/plugins/flatpak/gbp-flatpak-runtime.c
index 6e62ed5a6..d53a2ef7c 100644
--- a/src/plugins/flatpak/gbp-flatpak-runtime.c
+++ b/src/plugins/flatpak/gbp-flatpak-runtime.c
@@ -69,20 +69,19 @@ strv_empty (gchar **strv)
static const gchar *
get_builddir (GbpFlatpakRuntime *self)
{
- IdeContext *context = ide_object_get_context (IDE_OBJECT (self));
- IdeBuildManager *build_manager = ide_context_get_build_manager (context);
- IdeBuildPipeline *pipeline = ide_build_manager_get_pipeline (build_manager);
- const gchar *builddir = ide_build_pipeline_get_builddir (pipeline);
+ g_autoptr(IdeContext) context = ide_object_ref_context (IDE_OBJECT (self));
+ g_autoptr(IdeBuildManager) build_manager = ide_build_manager_ref_from_context (context);
+ g_autoptr(IdeBuildPipeline) pipeline = ide_build_manager_ref_pipeline (build_manager);
- return builddir;
+ return ide_build_pipeline_get_builddir (pipeline);
}
static gchar *
get_staging_directory (GbpFlatpakRuntime *self)
{
- IdeContext *context = ide_object_get_context (IDE_OBJECT (self));
- IdeBuildManager *build_manager = ide_context_get_build_manager (context);
- IdeBuildPipeline *pipeline = ide_build_manager_get_pipeline (build_manager);
+ g_autoptr(IdeContext) context = ide_object_ref_context (IDE_OBJECT (self));
+ g_autoptr(IdeBuildManager) build_manager = ide_build_manager_ref_from_context (context);
+ g_autoptr(IdeBuildPipeline) pipeline = ide_build_manager_ref_pipeline (build_manager);
return gbp_flatpak_get_staging_dir (pipeline);
}
@@ -143,7 +142,7 @@ gbp_flatpak_runtime_contains_program_in_path (IdeRuntime *runtime,
NULL);
}
- return !dzl_str_empty0 (stdout_buf);
+ return !ide_str_empty0 (stdout_buf);
}
}
@@ -169,21 +168,21 @@ gbp_flatpak_runtime_create_launcher (IdeRuntime *runtime,
const gchar *builddir = NULL;
const gchar *project_path = NULL;
const gchar * const *build_args = NULL;
- IdeContext *context;
- IdeConfigurationManager *config_manager;
+ g_autoptr(IdeConfigurationManager) config_manager = NULL;
+ g_autoptr(IdeContext) context = NULL;
IdeConfiguration *configuration;
IdeVcs *vcs;
- context = ide_object_get_context (IDE_OBJECT (self));
- config_manager = ide_context_get_configuration_manager (context);
- configuration = ide_configuration_manager_get_current (config_manager);
+ context = ide_object_ref_context (IDE_OBJECT (self));
+ config_manager = ide_configuration_manager_ref_from_context (context);
+ configuration = ide_configuration_manager_ref_current (config_manager);
build_path = get_staging_directory (self);
builddir = get_builddir (self);
/* Find the project directory path */
- vcs = ide_context_get_vcs (context);
- project_path = g_file_peek_path (ide_vcs_get_working_directory (vcs));
+ vcs = ide_vcs_ref_from_context (context);
+ project_path = g_file_peek_path (ide_vcs_get_workdir (vcs));
/* Add 'flatpak build' and the specified arguments to the launcher */
ide_subprocess_launcher_push_argv (ret, "flatpak");
@@ -210,7 +209,7 @@ gbp_flatpak_runtime_create_launcher (IdeRuntime *runtime,
NULL);
ide_subprocess_launcher_setenv (ret, "CCACHE_DIR", ccache_dir, FALSE);
- if (!dzl_str_empty0 (project_path))
+ if (!ide_str_empty0 (project_path))
{
g_autofree gchar *filesystem_option_src = NULL;
g_autofree gchar *filesystem_option_build = NULL;
@@ -274,7 +273,7 @@ get_binary_name (GbpFlatpakRuntime *self,
IdeBuildTarget *build_target)
{
IdeContext *context = ide_object_get_context (IDE_OBJECT (self));
- IdeConfigurationManager *config_manager = ide_context_get_configuration_manager (context);
+ IdeConfigurationManager *config_manager = ide_configuration_manager_from_context (context);
IdeConfiguration *config = ide_configuration_manager_get_current (config_manager);
g_autofree gchar *build_target_name = ide_build_target_get_name (build_target);
g_auto(GStrv) argv = ide_build_target_get_argv (build_target);
@@ -292,21 +291,16 @@ get_binary_name (GbpFlatpakRuntime *self,
const gchar *command;
command = gbp_flatpak_manifest_get_command (GBP_FLATPAK_MANIFEST (config));
- if (!dzl_str_empty0 (command))
+ if (!ide_str_empty0 (command))
return g_strdup (command);
}
/* Use the build target name if there's no command in the manifest */
- if (!dzl_str_empty0 (build_target_name))
+ if (!ide_str_empty0 (build_target_name))
return g_steal_pointer (&build_target_name);
- /* Use the project name as a last resort */
- {
- IdeProject *project;
-
- project = ide_context_get_project (context);
- return g_strdup (ide_project_get_name (project));
- }
+ /* Use the project id as a last resort */
+ return ide_context_dup_project_id (context);
}
static IdeRunner *
@@ -328,7 +322,9 @@ gbp_flatpak_runtime_create_runner (IdeRuntime *runtime,
if (build_target != NULL)
binary_name = get_binary_name (self, build_target);
- runner = IDE_RUNNER (gbp_flatpak_runner_new (context, build_path, binary_name));
+ if ((runner = IDE_RUNNER (gbp_flatpak_runner_new (context, build_path, binary_name))))
+ ide_object_append (IDE_OBJECT (self), IDE_OBJECT (runner));
+
if (build_target != NULL)
ide_runner_set_build_target (runner, build_target);
@@ -774,8 +770,7 @@ locate_deploy_dir (const gchar *sdk_id)
}
GbpFlatpakRuntime *
-gbp_flatpak_runtime_new (IdeContext *context,
- FlatpakInstalledRef *ref,
+gbp_flatpak_runtime_new (FlatpakInstalledRef *ref,
GCancellable *cancellable,
GError **error)
{
@@ -787,30 +782,54 @@ gbp_flatpak_runtime_new (IdeContext *context,
g_autofree gchar *display_name = NULL;
g_autofree gchar *triplet = NULL;
g_autoptr(IdeTriplet) triplet_object = NULL;
+ g_autoptr(GString) category = NULL;
const gchar *name;
const gchar *arch;
const gchar *branch;
const gchar *deploy_dir;
- g_return_val_if_fail (IDE_IS_CONTEXT (context), NULL);
g_return_val_if_fail (FLATPAK_IS_INSTALLED_REF (ref), NULL);
+ g_return_val_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable), NULL);
- name = flatpak_ref_get_name (FLATPAK_REF (ref));
arch = flatpak_ref_get_arch (FLATPAK_REF (ref));
+
+ name = flatpak_ref_get_name (FLATPAK_REF (ref));
branch = flatpak_ref_get_branch (FLATPAK_REF (ref));
deploy_dir = flatpak_installed_ref_get_deploy_dir (ref);
triplet_object = ide_triplet_new (arch);
triplet = g_strdup_printf ("%s/%s/%s", name, arch, branch);
id = g_strdup_printf ("flatpak:%s", triplet);
- metadata = flatpak_installed_ref_load_metadata (ref, cancellable, error);
- if (metadata == NULL)
+ category = g_string_new ("Flatpak/");
+
+ if (g_str_has_prefix (name, "org.gnome."))
+ g_string_append (category, "GNOME/");
+ else if (g_str_has_prefix (name, "org.freedesktop."))
+ g_string_append (category, "FreeDesktop.org/");
+ else if (g_str_has_prefix (name, "org.kde."))
+ g_string_append (category, "KDE/");
+
+ if (ide_str_equal0 (flatpak_get_default_arch (), arch))
+ g_string_append (category, name);
+ else
+ g_string_append_printf (category, "%s (%s)", name, arch);
+
+ if (!(metadata = flatpak_installed_ref_load_metadata (ref, cancellable, error)))
return NULL;
keyfile = g_key_file_new ();
if (!g_key_file_load_from_bytes (keyfile, metadata, 0, error))
return NULL;
+ if (g_key_file_has_group (keyfile, "ExtensionOf"))
+ {
+ g_set_error (error,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ "Runtime is an extension");
+ return NULL;
+ }
+
sdk = g_key_file_get_string (keyfile, "Runtime", "sdk", NULL);
if (g_str_equal (arch, flatpak_get_default_arch ()))
@@ -826,10 +845,10 @@ gbp_flatpak_runtime_new (IdeContext *context,
deploy_dir = sdk_deploy_dir;
return g_object_new (GBP_TYPE_FLATPAK_RUNTIME,
- "context", context,
"id", id,
"triplet", triplet_object,
"branch", branch,
+ "category", category->str,
"deploy-dir", deploy_dir,
"display-name", display_name,
"platform", name,
diff --git a/src/plugins/flatpak/gbp-flatpak-runtime.h b/src/plugins/flatpak/gbp-flatpak-runtime.h
index 1d17ee217..b41705ee0 100644
--- a/src/plugins/flatpak/gbp-flatpak-runtime.h
+++ b/src/plugins/flatpak/gbp-flatpak-runtime.h
@@ -21,7 +21,7 @@
#pragma once
#include <flatpak.h>
-#include <ide.h>
+#include <libide-foundry.h>
G_BEGIN_DECLS
@@ -29,8 +29,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GbpFlatpakRuntime, gbp_flatpak_runtime, GBP, FLATPAK_RUNTIME, IdeRuntime)
-GbpFlatpakRuntime *gbp_flatpak_runtime_new (IdeContext *context,
- FlatpakInstalledRef *ref,
+GbpFlatpakRuntime *gbp_flatpak_runtime_new (FlatpakInstalledRef *ref,
GCancellable *cancellable,
GError **error);
IdeTriplet *gbp_flatpak_runtime_get_triplet (GbpFlatpakRuntime *self);
diff --git a/src/plugins/flatpak/gbp-flatpak-sources.c b/src/plugins/flatpak/gbp-flatpak-sources.c
index bcbd731d5..c7cc1a686 100644
--- a/src/plugins/flatpak/gbp-flatpak-sources.c
+++ b/src/plugins/flatpak/gbp-flatpak-sources.c
@@ -28,7 +28,7 @@
/* This file includes modified code from
* flatpak/builder/builder-source-archive.c
- * Written by Alexander Larsson, originally licensed under GPL 2.1.
+ * Written by Alexander Larsson, originally licensed under GPL 2.1+.
* Copyright Red Hat, Inc. 2015
*/
diff --git a/src/plugins/flatpak/gbp-flatpak-subprocess-launcher.h
b/src/plugins/flatpak/gbp-flatpak-subprocess-launcher.h
index eea30086e..4536d8054 100644
--- a/src/plugins/flatpak/gbp-flatpak-subprocess-launcher.h
+++ b/src/plugins/flatpak/gbp-flatpak-subprocess-launcher.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-threading.h>
G_BEGIN_DECLS
diff --git a/src/plugins/flatpak/gbp-flatpak-transfer.c b/src/plugins/flatpak/gbp-flatpak-transfer.c
index 3c6159a22..4a4ef344c 100644
--- a/src/plugins/flatpak/gbp-flatpak-transfer.c
+++ b/src/plugins/flatpak/gbp-flatpak-transfer.c
@@ -125,20 +125,20 @@ task_completed (GbpFlatpakTransfer *self,
static void
proxy_notify (GbpFlatpakTransfer *self,
GParamSpec *pspec,
- IdeProgress *progress)
+ IdeNotification *progress)
{
g_assert (GBP_IS_FLATPAK_TRANSFER (self));
g_assert (pspec != NULL);
- g_assert (IDE_IS_PROGRESS (progress));
+ g_assert (IDE_IS_NOTIFICATION (progress));
- if (g_strcmp0 (pspec->name, "message") == 0)
+ if (g_strcmp0 (pspec->name, "body") == 0)
{
- g_autofree gchar *message = ide_progress_get_message (progress);
+ g_autofree gchar *message = ide_notification_dup_body (progress);
ide_transfer_set_status (IDE_TRANSFER (self), message);
}
- if (g_strcmp0 (pspec->name, "fraction") == 0)
- ide_transfer_set_progress (IDE_TRANSFER (self), ide_progress_get_fraction (progress));
+ if (g_strcmp0 (pspec->name, "progress") == 0)
+ ide_transfer_set_progress (IDE_TRANSFER (self), ide_notification_get_progress (progress));
}
static void
@@ -172,7 +172,7 @@ gbp_flatpak_transfer_execute_async (IdeTransfer *transfer,
GbpFlatpakTransfer *self = (GbpFlatpakTransfer *)transfer;
GbpFlatpakApplicationAddin *addin;
g_autoptr(IdeTask) task = NULL;
- g_autoptr(IdeProgress) progress = NULL;
+ g_autoptr(IdeNotification) progress = NULL;
IDE_ENTRY;
@@ -220,13 +220,13 @@ gbp_flatpak_transfer_execute_async (IdeTransfer *transfer,
g_steal_pointer (&task));
g_signal_connect_object (progress,
- "notify::fraction",
+ "notify::progress",
G_CALLBACK (proxy_notify),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (progress,
- "notify::message",
+ "notify::body",
G_CALLBACK (proxy_notify),
self,
G_CONNECT_SWAPPED);
diff --git a/src/plugins/flatpak/gbp-flatpak-transfer.h b/src/plugins/flatpak/gbp-flatpak-transfer.h
index 4fa7a0acb..5091cd294 100644
--- a/src/plugins/flatpak/gbp-flatpak-transfer.h
+++ b/src/plugins/flatpak/gbp-flatpak-transfer.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-core.h>
G_BEGIN_DECLS
@@ -28,9 +28,9 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GbpFlatpakTransfer, gbp_flatpak_transfer, GBP, FLATPAK_TRANSFER, IdeTransfer)
-GbpFlatpakTransfer *gbp_flatpak_transfer_new (const gchar *id,
- const gchar *arch,
- const gchar *branch,
- gboolean force_update);
+GbpFlatpakTransfer *gbp_flatpak_transfer_new (const gchar *id,
+ const gchar *arch,
+ const gchar *branch,
+ gboolean force_update);
G_END_DECLS
diff --git a/src/plugins/flatpak/gbp-flatpak-util.c b/src/plugins/flatpak/gbp-flatpak-util.c
index 8baf10848..2bf9cd5db 100644
--- a/src/plugins/flatpak/gbp-flatpak-util.c
+++ b/src/plugins/flatpak/gbp-flatpak-util.c
@@ -22,6 +22,8 @@
#include <flatpak.h>
#include <string.h>
+#include <libide-foundry.h>
+#include <libide-vcs.h>
#include "gbp-flatpak-util.h"
@@ -37,16 +39,16 @@ gbp_flatpak_get_staging_dir (IdeBuildPipeline *pipeline)
g_autofree gchar *branch = NULL;
g_autofree gchar *name = NULL;
g_autoptr (IdeTriplet) triplet = NULL;
- IdeContext *context;
- IdeVcs *vcs;
- IdeToolchain *toolchain;
+ g_autoptr(IdeContext) context = NULL;
+ g_autoptr(IdeVcs) vcs = NULL;
+ g_autoptr(IdeToolchain) toolchain = NULL;
g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
- context = ide_object_get_context (IDE_OBJECT (pipeline));
- vcs = ide_context_get_vcs (context);
+ context = ide_object_ref_context (IDE_OBJECT (pipeline));
+ vcs = ide_vcs_ref_from_context (context);
branch = ide_vcs_get_branch_name (vcs);
- toolchain = ide_build_pipeline_get_toolchain (pipeline);
+ toolchain = ide_build_pipeline_ref_toolchain (pipeline);
triplet = ide_toolchain_get_host_triplet (toolchain);
name = g_strdup_printf ("%s-%s", ide_triplet_get_arch (triplet), branch);
diff --git a/src/plugins/flatpak/gbp-flatpak-util.h b/src/plugins/flatpak/gbp-flatpak-util.h
index d71917620..eb599badd 100644
--- a/src/plugins/flatpak/gbp-flatpak-util.h
+++ b/src/plugins/flatpak/gbp-flatpak-util.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-foundry.h>
G_BEGIN_DECLS
diff --git a/src/plugins/flatpak/gbp-flatpak-workbench-addin.c
b/src/plugins/flatpak/gbp-flatpak-workbench-addin.c
index 85a9b0e2c..4dbceb4cd 100644
--- a/src/plugins/flatpak/gbp-flatpak-workbench-addin.c
+++ b/src/plugins/flatpak/gbp-flatpak-workbench-addin.c
@@ -21,6 +21,7 @@
#define G_LOG_DOMAIN "gbp-flatpak-workbench-addin"
#include <glib/gi18n.h>
+#include <libide-io.h>
#include "gbp-flatpak-application-addin.h"
#include "gbp-flatpak-download-stage.h"
@@ -32,7 +33,7 @@ struct _GbpFlatpakWorkbenchAddin
GSimpleActionGroup *actions;
IdeWorkbench *workbench;
- IdeWorkbenchMessage *message;
+ IdeNotification *message;
};
static void
@@ -41,13 +42,13 @@ check_sysdeps_cb (GObject *object,
gpointer user_data)
{
GbpFlatpakApplicationAddin *app_addin = (GbpFlatpakApplicationAddin *)object;
- g_autoptr(IdeWorkbenchMessage) message = user_data;
+ g_autoptr(GbpFlatpakWorkbenchAddin) self = user_data;
g_autoptr(GError) error = NULL;
gboolean has_sysdeps;
g_assert (GBP_IS_FLATPAK_APPLICATION_ADDIN (app_addin));
g_assert (G_IS_ASYNC_RESULT (result));
- g_assert (IDE_IS_WORKBENCH_MESSAGE (message));
+ g_assert (GBP_IS_FLATPAK_WORKBENCH_ADDIN (self));
has_sysdeps = gbp_flatpak_application_addin_check_sysdeps_finish (app_addin, result, &error);
@@ -56,57 +57,95 @@ check_sysdeps_cb (GObject *object,
IDE_TRACE_MSG ("which flatpak-builder resulted in %s", error->message);
#endif
- gtk_widget_set_visible (GTK_WIDGET (message), has_sysdeps == FALSE);
+ if (!has_sysdeps)
+ {
+ IdeContext *context;
+
+ context = ide_workbench_get_context (self->workbench);
+ ide_notification_attach (self->message, IDE_OBJECT (context));
+ }
}
static void
-gbp_flatpak_workbench_addin_load (IdeWorkbenchAddin *addin,
- IdeWorkbench *workbench)
+gbp_flatpak_workbench_addin_workspace_added (IdeWorkbenchAddin *addin,
+ IdeWorkspace *workspace)
{
GbpFlatpakWorkbenchAddin *self = (GbpFlatpakWorkbenchAddin *)addin;
GbpFlatpakApplicationAddin *app_addin;
- IdeContext *context;
+ g_assert (IDE_IS_MAIN_THREAD ());
g_assert (GBP_IS_FLATPAK_WORKBENCH_ADDIN (self));
- g_assert (IDE_IS_WORKBENCH (workbench));
+ g_assert (IDE_IS_WORKSPACE (workspace));
- self->workbench = workbench;
+ if (!IDE_IS_PRIMARY_WORKSPACE (workspace))
+ return;
- context = ide_workbench_get_context (workbench);
- if (context != NULL)
- gtk_widget_insert_action_group (GTK_WIDGET (workbench), "flatpak", G_ACTION_GROUP (self->actions));
+ gtk_widget_insert_action_group (GTK_WIDGET (workspace), "flatpak",
+ G_ACTION_GROUP (self->actions));
- self->message = g_object_new (IDE_TYPE_WORKBENCH_MESSAGE,
- "id", "org.gnome.builder.flatpak.install",
- "title", _("Your computer is missing flatpak-builder"),
- "subtitle", _("This program is necessary for building Flatpak applications.
Would you like to install it?"),
- "show-close-button", TRUE,
- "visible", FALSE,
+ self->message = g_object_new (IDE_TYPE_NOTIFICATION,
+ "title", _("Missing system dependencies"),
+ "body", _("The “flatpak-builder” program is necessary for building
Flatpak-based applications. Builder can install it for you."),
+ "icon-name", "dialog-warning-symbolic",
+ "urgent", TRUE,
NULL);
- ide_workbench_message_add_action (self->message, _("Install"), "flatpak.install-flatpak-builder");
- ide_workbench_push_message (workbench, self->message);
+ ide_notification_add_button (self->message,
+ _("Install"),
+ NULL,
+ "flatpak.install-flatpak-builder");
app_addin = gbp_flatpak_application_addin_get_default ();
gbp_flatpak_application_addin_check_sysdeps_async (app_addin,
NULL,
check_sysdeps_cb,
- g_object_ref (self->message));
+ g_object_ref (self));
+
}
static void
-gbp_flatpak_workbench_addin_unload (IdeWorkbenchAddin *addin,
- IdeWorkbench *workbench)
+gbp_flatpak_workbench_addin_workspace_removed (IdeWorkbenchAddin *addin,
+ IdeWorkspace *workspace)
+{
+ GbpFlatpakWorkbenchAddin *self = (GbpFlatpakWorkbenchAddin *)addin;
+
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_FLATPAK_WORKBENCH_ADDIN (self));
+ g_assert (IDE_IS_WORKSPACE (workspace));
+
+ if (!IDE_IS_PRIMARY_WORKSPACE (workspace))
+ return;
+
+ gtk_widget_insert_action_group (GTK_WIDGET (workspace), "flatpak", NULL);
+
+ if (self->message != NULL)
+ {
+ ide_notification_withdraw (self->message);
+ g_clear_object (&self->message);
+ }
+}
+
+static void
+gbp_flatpak_workbench_addin_load (IdeWorkbenchAddin *addin,
+ IdeWorkbench *workbench)
{
GbpFlatpakWorkbenchAddin *self = (GbpFlatpakWorkbenchAddin *)addin;
+ g_assert (IDE_IS_MAIN_THREAD ());
g_assert (GBP_IS_FLATPAK_WORKBENCH_ADDIN (self));
g_assert (IDE_IS_WORKBENCH (workbench));
- gtk_widget_insert_action_group (GTK_WIDGET (workbench), "flatpak", NULL);
+ self->workbench = workbench;
+}
+
+static void
+gbp_flatpak_workbench_addin_unload (IdeWorkbenchAddin *addin,
+ IdeWorkbench *workbench)
+{
+ GbpFlatpakWorkbenchAddin *self = (GbpFlatpakWorkbenchAddin *)addin;
- gtk_widget_destroy (GTK_WIDGET (self->message));
+ g_assert (GBP_IS_FLATPAK_WORKBENCH_ADDIN (self));
+ g_assert (IDE_IS_WORKBENCH (workbench));
- self->message = NULL;
self->workbench = NULL;
}
@@ -115,6 +154,8 @@ workbench_addin_iface_init (IdeWorkbenchAddinInterface *iface)
{
iface->load = gbp_flatpak_workbench_addin_load;
iface->unload = gbp_flatpak_workbench_addin_unload;
+ iface->workspace_added = gbp_flatpak_workbench_addin_workspace_added;
+ iface->workspace_removed = gbp_flatpak_workbench_addin_workspace_removed;
}
static void
@@ -148,7 +189,7 @@ gbp_flatpak_workbench_addin_install_cb (GObject *object,
else
{
IdeContext *context = ide_workbench_get_context (self->workbench);
- IdeConfigurationManager *config_manager = ide_context_get_configuration_manager (context);
+ IdeConfigurationManager *config_manager = ide_configuration_manager_from_context (context);
/* TODO: It would be nice to have a cleaner way to re-setup the pipeline
* because we know it is invalidated.
@@ -180,7 +221,7 @@ gbp_flatpak_workbench_addin_install_flatpak_builder (GSimpleAction *action,
g_assert (GBP_IS_FLATPAK_WORKBENCH_ADDIN (self));
transfer = ide_pkcon_transfer_new (packages);
- manager = ide_application_get_transfer_manager (IDE_APPLICATION_DEFAULT);
+ manager = ide_transfer_manager_get_default ();
g_simple_action_set_enabled (action, FALSE);
diff --git a/src/plugins/flatpak/gbp-flatpak-workbench-addin.h
b/src/plugins/flatpak/gbp-flatpak-workbench-addin.h
index 9ce19fd78..4c13b0066 100644
--- a/src/plugins/flatpak/gbp-flatpak-workbench-addin.h
+++ b/src/plugins/flatpak/gbp-flatpak-workbench-addin.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-gui.h>
G_BEGIN_DECLS
diff --git a/src/plugins/flatpak/meson.build b/src/plugins/flatpak/meson.build
index 28982bb74..c0f8746b7 100644
--- a/src/plugins/flatpak/meson.build
+++ b/src/plugins/flatpak/meson.build
@@ -1,63 +1,44 @@
-if get_option('with_flatpak')
+if get_option('plugin_flatpak')
-flatpak_resources = gnome.compile_resources(
- 'flatpak-resources',
- 'flatpak.gresource.xml',
- c_name: 'gbp_flatpak'
-)
+if not get_option('plugin_git')
+ error('-Dplugin_git=true is required for flatpak')
+endif
-flatpak_sources = [
+plugins_sources += files([
+ 'flatpak-plugin.c',
'gbp-flatpak-application-addin.c',
- 'gbp-flatpak-application-addin.h',
'gbp-flatpak-build-system-discovery.c',
- 'gbp-flatpak-build-system-discovery.h',
- 'gbp-flatpak-build-target.c',
- 'gbp-flatpak-build-target.h',
'gbp-flatpak-build-target-provider.c',
- 'gbp-flatpak-build-target-provider.h',
+ 'gbp-flatpak-build-target.c',
'gbp-flatpak-clone-widget.c',
- 'gbp-flatpak-clone-widget.h',
'gbp-flatpak-configuration-provider.c',
- 'gbp-flatpak-configuration-provider.h',
'gbp-flatpak-dependency-updater.c',
- 'gbp-flatpak-dependency-updater.h',
'gbp-flatpak-download-stage.c',
- 'gbp-flatpak-download-stage.h',
- 'gbp-flatpak-genesis-addin.c',
- 'gbp-flatpak-genesis-addin.h',
'gbp-flatpak-manifest.c',
- 'gbp-flatpak-manifest.h',
'gbp-flatpak-pipeline-addin.c',
- 'gbp-flatpak-pipeline-addin.h',
'gbp-flatpak-preferences-addin.c',
- 'gbp-flatpak-preferences-addin.h',
- 'gbp-flatpak-plugin.c',
'gbp-flatpak-runner.c',
- 'gbp-flatpak-runner.h',
'gbp-flatpak-runtime-provider.c',
- 'gbp-flatpak-runtime-provider.h',
'gbp-flatpak-runtime.c',
- 'gbp-flatpak-runtime.h',
'gbp-flatpak-sources.c',
- 'gbp-flatpak-sources.h',
'gbp-flatpak-subprocess-launcher.c',
- 'gbp-flatpak-subprocess-launcher.h',
'gbp-flatpak-transfer.c',
- 'gbp-flatpak-transfer.h',
'gbp-flatpak-util.c',
- 'gbp-flatpak-util.h',
'gbp-flatpak-workbench-addin.c',
- 'gbp-flatpak-workbench-addin.h',
-]
+])
+
+plugin_flatpak_resources = gnome.compile_resources(
+ 'flatpak-resources',
+ 'flatpak.gresource.xml',
+ c_name: 'gbp_flatpak'
+)
-gnome_builder_plugins_deps += [
+plugins_deps += [
dependency('flatpak', version: '>= 0.8.0'),
dependency('ostree-1'),
dependency('libsoup-2.4', version: '>= 2.52.0'),
- libgit_dep,
]
-gnome_builder_plugins_sources += files(flatpak_sources)
-gnome_builder_plugins_sources += flatpak_resources[0]
+plugins_sources += plugin_flatpak_resources[0]
endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]