[gnome-builder/wip/plugins: 15/36] workbench: add peas extension set for workbench
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/plugins: 15/36] workbench: add peas extension set for workbench
- Date: Mon, 8 Jun 2015 20:28:08 +0000 (UTC)
commit b3688ae106c743397a39273b9b7952819f549f5a
Author: Christian Hergert <christian hergert me>
Date: Fri Jun 5 23:57:13 2015 -0700
workbench: add peas extension set for workbench
src/Makefile.am | 4 +-
src/workbench/gb-workbench-addin.c | 78 ++++++++++++++++++++++++++++++++++
src/workbench/gb-workbench-addin.h | 43 +++++++++++++++++++
src/workbench/gb-workbench-private.h | 2 +
src/workbench/gb-workbench.c | 35 +++++++++++++++
5 files changed, 161 insertions(+), 1 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 6b4b3e9..1f71f5e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -161,10 +161,12 @@ libgnome_builder_la_SOURCES = \
vim/gb-vim.h \
workbench/gb-workbench-actions.c \
workbench/gb-workbench-actions.h \
+ workbench/gb-workbench-addin.c \
+ workbench/gb-workbench-addin.h \
workbench/gb-workbench-private.h \
+ workbench/gb-workbench-types.h \
workbench/gb-workbench.c \
workbench/gb-workbench.h \
- workbench/gb-workbench-types.h \
workspace/gb-workspace.c \
workspace/gb-workspace.h \
workspace/gb-workspace-pane.c \
diff --git a/src/workbench/gb-workbench-addin.c b/src/workbench/gb-workbench-addin.c
new file mode 100644
index 0000000..0baaa65
--- /dev/null
+++ b/src/workbench/gb-workbench-addin.c
@@ -0,0 +1,78 @@
+/* gb-workbench-addin.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * 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/>.
+ */
+
+#include <glib/gi18n.h>
+
+#include "gb-workbench.h"
+#include "gb-workbench-addin.h"
+
+G_DEFINE_INTERFACE (GbWorkbenchAddin, gb_workbench_addin, G_TYPE_OBJECT)
+
+enum {
+ PROP_0,
+ PROP_WORKBENCH,
+ LAST_PROP
+};
+
+enum {
+ LOAD,
+ UNLOAD,
+ LAST_SIGNAL
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+static guint gSignals [LAST_SIGNAL];
+
+static void
+gb_workbench_addin_default_init (GbWorkbenchAddinInterface *iface)
+{
+ gParamSpecs [PROP_WORKBENCH] =
+ g_param_spec_object ("workbench",
+ _("Workbench"),
+ _("The workbench window."),
+ GB_TYPE_WORKBENCH,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_interface_install_property (iface, gParamSpecs [PROP_WORKBENCH]);
+
+ gSignals [LOAD] = g_signal_new ("load",
+ G_TYPE_FROM_INTERFACE (iface),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GbWorkbenchAddinInterface, load),
+ NULL, NULL, NULL, G_TYPE_NONE, 0);
+
+ gSignals [UNLOAD] = g_signal_new ("unload",
+ G_TYPE_FROM_INTERFACE (iface),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GbWorkbenchAddinInterface, unload),
+ NULL, NULL, NULL, G_TYPE_NONE, 0);
+}
+
+void
+gb_workbench_addin_load (GbWorkbenchAddin *self)
+{
+ g_return_if_fail (GB_IS_WORKBENCH_ADDIN (self));
+
+ g_signal_emit (self, gSignals [LOAD], 0);
+}
+void
+gb_workbench_addin_unload (GbWorkbenchAddin *self)
+{
+ g_return_if_fail (GB_IS_WORKBENCH_ADDIN (self));
+
+ g_signal_emit (self, gSignals [UNLOAD], 0);
+}
diff --git a/src/workbench/gb-workbench-addin.h b/src/workbench/gb-workbench-addin.h
new file mode 100644
index 0000000..63b0866
--- /dev/null
+++ b/src/workbench/gb-workbench-addin.h
@@ -0,0 +1,43 @@
+/* gb-workbench-addin.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * 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 GB_WORKBENCH_ADDIN_H
+#define GB_WORKBENCH_ADDIN_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_WORKBENCH_ADDIN (gb_workbench_addin_get_type ())
+
+G_DECLARE_INTERFACE (GbWorkbenchAddin, gb_workbench_addin, GB, WORKBENCH_ADDIN, GObject)
+
+struct _GbWorkbenchAddinInterface
+{
+ GTypeInterface parent;
+
+ void (*load) (GbWorkbenchAddin *self);
+ void (*unload) (GbWorkbenchAddin *self);
+};
+
+void gb_workbench_addin_load (GbWorkbenchAddin *self);
+void gb_workbench_addin_unload (GbWorkbenchAddin *self);
+
+G_END_DECLS
+
+#endif /* GB_WORKBENCH_ADDIN_H */
diff --git a/src/workbench/gb-workbench-private.h b/src/workbench/gb-workbench-private.h
index 1786639..de83f43 100644
--- a/src/workbench/gb-workbench-private.h
+++ b/src/workbench/gb-workbench-private.h
@@ -20,6 +20,7 @@
#define GB_WORKBENCH_PRIVATE_H
#include <gtk/gtk.h>
+#include <libpeas/peas.h>
#include <ide.h>
#include "gb-command-bar.h"
@@ -42,6 +43,7 @@ struct _GbWorkbench
IdeContext *context;
GCancellable *unload_cancellable;
gchar *current_folder_uri;
+ PeasExtensionSet *extensions;
/* Template references */
GbCommandBar *command_bar;
diff --git a/src/workbench/gb-workbench.c b/src/workbench/gb-workbench.c
index 5a1f811..50165b2 100644
--- a/src/workbench/gb-workbench.c
+++ b/src/workbench/gb-workbench.c
@@ -30,6 +30,7 @@
#include "gb-workbench-actions.h"
#include "gb-workbench-private.h"
#include "gb-workbench.h"
+#include "gb-workbench-addin.h"
#include "gb-workspace.h"
#include "gb-workspace-pane.h"
#include "gb-project-tree.h"
@@ -566,8 +567,25 @@ gb_workbench_class_init (GbWorkbenchClass *klass)
}
static void
+gb_workbench__extension_added (PeasExtensionSet *set,
+ PeasPluginInfo *plugin_info,
+ GbWorkbenchAddin *addin)
+{
+ gb_workbench_addin_load (addin);
+}
+
+static void
+gb_workbench__extension_removed (PeasExtensionSet *set,
+ PeasPluginInfo *plugin_info,
+ GbWorkbenchAddin *addin)
+{
+ gb_workbench_addin_unload (addin);
+}
+
+static void
gb_workbench_init (GbWorkbench *self)
{
+ PeasEngine *engine;
g_autoptr(GbCommandProvider) gaction_provider = NULL;
g_autoptr(GbCommandProvider) vim_provider = NULL;
@@ -593,6 +611,23 @@ gb_workbench_init (GbWorkbench *self)
gb_settings_init_window (GTK_WINDOW (self));
+ engine = peas_engine_get_default ();
+ self->extensions = peas_extension_set_new (engine,
+ GB_TYPE_WORKBENCH_ADDIN,
+ "workbench", self,
+ NULL);
+ peas_extension_set_foreach (self->extensions,
+ (PeasExtensionSetForeachFunc)gb_workbench__extension_added,
+ NULL);
+ g_signal_connect (self->extensions,
+ "extension-added",
+ G_CALLBACK (gb_workbench__extension_added),
+ self);
+ g_signal_connect (self->extensions,
+ "extension-removed",
+ G_CALLBACK (gb_workbench__extension_removed),
+ self);
+
IDE_EXIT;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]