[gnome-builder] flatpak: add menu item to update downloads
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] flatpak: add menu item to update downloads
- Date: Wed, 8 Mar 2017 00:47:31 +0000 (UTC)
commit 16ff9be5ee6d8eb3f00b1189fd8586a4e9472bcf
Author: Christian Hergert <chergert redhat com>
Date: Tue Mar 7 16:45:19 2017 -0800
flatpak: add menu item to update downloads
This adds an action and menu item to update the project dependencies from
the flatpak remote repositories.
plugins/flatpak/Makefile.am | 2 +
plugins/flatpak/gbp-flatpak-plugin.c | 8 +-
.../flatpak/gbp-flatpak-resources.gresource.xml | 1 +
plugins/flatpak/gbp-flatpak-workbench-addin.c | 120 ++++++++++++++++++++
plugins/flatpak/gbp-flatpak-workbench-addin.h | 32 +++++
plugins/flatpak/gtk/menus.ui | 14 +++
6 files changed, 175 insertions(+), 2 deletions(-)
---
diff --git a/plugins/flatpak/Makefile.am b/plugins/flatpak/Makefile.am
index 5a5440e..fd097fa 100644
--- a/plugins/flatpak/Makefile.am
+++ b/plugins/flatpak/Makefile.am
@@ -39,6 +39,8 @@ libflatpak_plugin_la_SOURCES = \
gbp-flatpak-transfer.h \
gbp-flatpak-util.c \
gbp-flatpak-util.h \
+ gbp-flatpak-workbench-addin.c \
+ gbp-flatpak-workbench-addin.h \
$(NULL)
nodist_libflatpak_plugin_la_SOURCES = \
diff --git a/plugins/flatpak/gbp-flatpak-plugin.c b/plugins/flatpak/gbp-flatpak-plugin.c
index 76a7df9..27db656 100644
--- a/plugins/flatpak/gbp-flatpak-plugin.c
+++ b/plugins/flatpak/gbp-flatpak-plugin.c
@@ -19,12 +19,13 @@
#include <libpeas/peas.h>
#include <ide.h>
-#include "gbp-flatpak-configuration-provider.h"
-#include "gbp-flatpak-runtime-provider.h"
#include "gbp-flatpak-application-addin.h"
+#include "gbp-flatpak-configuration-provider.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
peas_register_types (PeasObjectModule *module)
@@ -49,4 +50,7 @@ peas_register_types (PeasObjectModule *module)
peas_object_module_register_extension_type (module,
IDE_TYPE_PREFERENCES_ADDIN,
GBP_TYPE_FLATPAK_PREFERENCES_ADDIN);
+ peas_object_module_register_extension_type (module,
+ IDE_TYPE_WORKBENCH_ADDIN,
+ GBP_TYPE_FLATPAK_WORKBENCH_ADDIN);
}
diff --git a/plugins/flatpak/gbp-flatpak-resources.gresource.xml
b/plugins/flatpak/gbp-flatpak-resources.gresource.xml
index 52c931d..7fba1b1 100644
--- a/plugins/flatpak/gbp-flatpak-resources.gresource.xml
+++ b/plugins/flatpak/gbp-flatpak-resources.gresource.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/builder/plugins/flatpak-plugin">
+ <file>gtk/menus.ui</file>
<file>gbp-flatpak-clone-widget.ui</file>
</gresource>
</gresources>
diff --git a/plugins/flatpak/gbp-flatpak-workbench-addin.c b/plugins/flatpak/gbp-flatpak-workbench-addin.c
new file mode 100644
index 0000000..089b187
--- /dev/null
+++ b/plugins/flatpak/gbp-flatpak-workbench-addin.c
@@ -0,0 +1,120 @@
+/* gbp-flatpak-workbench-addin.c
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert 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-workbench-addin"
+
+#include "gbp-flatpak-workbench-addin.h"
+
+struct _GbpFlatpakWorkbenchAddin
+{
+ GObject parent;
+ GSimpleActionGroup *actions;
+ IdeWorkbench *workbench;
+};
+
+static void
+gbp_flatpak_workbench_addin_load (IdeWorkbenchAddin *addin,
+ IdeWorkbench *workbench)
+{
+ GbpFlatpakWorkbenchAddin *self = (GbpFlatpakWorkbenchAddin *)addin;
+ IdeContext *context;
+
+ g_assert (GBP_IS_FLATPAK_WORKBENCH_ADDIN (self));
+ g_assert (IDE_IS_WORKBENCH (workbench));
+
+ self->workbench = workbench;
+
+ context = ide_workbench_get_context (workbench);
+ if (context != NULL)
+ gtk_widget_insert_action_group (GTK_WIDGET (workbench), "flatpak", G_ACTION_GROUP (self->actions));
+}
+
+static void
+gbp_flatpak_workbench_addin_unload (IdeWorkbenchAddin *addin,
+ IdeWorkbench *workbench)
+{
+ GbpFlatpakWorkbenchAddin *self = (GbpFlatpakWorkbenchAddin *)addin;
+
+ 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 = NULL;
+}
+
+static void
+workbench_addin_iface_init (IdeWorkbenchAddinInterface *iface)
+{
+ iface->load = gbp_flatpak_workbench_addin_load;
+ iface->unload = gbp_flatpak_workbench_addin_unload;
+}
+
+static void
+gbp_flatpak_workbench_addin_update_dependencies (GSimpleAction *action,
+ GVariant *param,
+ gpointer user_data)
+{
+ GbpFlatpakWorkbenchAddin *self = user_data;
+ IdeBuildManager *manager;
+ IdeBuildPipeline *pipeline;
+
+ g_assert (G_IS_SIMPLE_ACTION (action));
+ g_assert (GBP_IS_FLATPAK_WORKBENCH_ADDIN (self));
+
+ manager = ide_context_get_build_manager (ide_workbench_get_context (self->workbench));
+ pipeline = ide_build_manager_get_pipeline (manager);
+ ide_build_pipeline_invalidate_phase (pipeline, IDE_BUILD_PHASE_DOWNLOADS);
+ ide_build_manager_execute_async (manager, IDE_BUILD_PHASE_DOWNLOADS, NULL, NULL, NULL);
+}
+
+G_DEFINE_TYPE_EXTENDED (GbpFlatpakWorkbenchAddin, gbp_flatpak_workbench_addin, G_TYPE_OBJECT, 0,
+ G_IMPLEMENT_INTERFACE (IDE_TYPE_WORKBENCH_ADDIN, workbench_addin_iface_init))
+
+static void
+gbp_flatpak_workbench_addin_finalize (GObject *object)
+{
+ GbpFlatpakWorkbenchAddin *self = (GbpFlatpakWorkbenchAddin *)object;
+
+ g_clear_object (&self->actions);
+
+ G_OBJECT_CLASS (gbp_flatpak_workbench_addin_parent_class)->finalize (object);
+}
+
+static void
+gbp_flatpak_workbench_addin_class_init (GbpFlatpakWorkbenchAddinClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gbp_flatpak_workbench_addin_finalize;
+}
+
+static void
+gbp_flatpak_workbench_addin_init (GbpFlatpakWorkbenchAddin *self)
+{
+ static const GActionEntry actions[] = {
+ { "update-dependencies", gbp_flatpak_workbench_addin_update_dependencies },
+ };
+
+ self->actions = g_simple_action_group_new ();
+
+ g_action_map_add_action_entries (G_ACTION_MAP (self->actions),
+ actions,
+ G_N_ELEMENTS (actions),
+ self);
+}
diff --git a/plugins/flatpak/gbp-flatpak-workbench-addin.h b/plugins/flatpak/gbp-flatpak-workbench-addin.h
new file mode 100644
index 0000000..2389f6d
--- /dev/null
+++ b/plugins/flatpak/gbp-flatpak-workbench-addin.h
@@ -0,0 +1,32 @@
+/* gbp-flatpak-workbench-addin.h
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert 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_WORKBENCH_ADDIN_H
+#define GBP_FLATPAK_WORKBENCH_ADDIN_H
+
+#include <ide.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_FLATPAK_WORKBENCH_ADDIN (gbp_flatpak_workbench_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpFlatpakWorkbenchAddin, gbp_flatpak_workbench_addin, GBP, FLATPAK_WORKBENCH_ADDIN,
GObject)
+
+G_END_DECLS
+
+#endif /* GBP_FLATPAK_WORKBENCH_ADDIN_H */
diff --git a/plugins/flatpak/gtk/menus.ui b/plugins/flatpak/gtk/menus.ui
new file mode 100644
index 0000000..05a37a7
--- /dev/null
+++ b/plugins/flatpak/gtk/menus.ui
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<interface>
+ <menu id="gear-menu">
+ <section id="gear-menu-flatpak-section">
+ <submenu id="gear-menu-flatpak-section-submenu">
+ <attribute name="label" translatable="yes">Flatpak</attribute>
+ <item>
+ <attribute name="label" translatable="yes">_Download Dependencies</attribute>
+ <attribute name="action">flatpak.update-dependencies</attribute>
+ </item>
+ </submenu>
+ </section>
+ </menu>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]