summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2012-03-07 04:46:38 (GMT)
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2012-03-07 04:54:21 (GMT)
commitd53d25b59bac45049a1ee5f76517b0c251d0b1a8 (patch)
treec0e65ec3af0343fa13256406ae2f4dc65b622af1
downloadpeas-experiment-master.tar.gz
peas-experiment-master.tar.xz
Initial commitHEADmaster
-rw-r--r--.gitignore28
-rw-r--r--AUTHORS0
-rw-r--r--COPYING0
-rw-r--r--ChangeLog0
-rw-r--r--Makefile.am1
-rw-r--r--NEWS0
-rw-r--r--README0
-rwxr-xr-xautogen.sh18
-rw-r--r--configure.ac51
-rw-r--r--src/Makefile.am37
-rw-r--r--src/main.c93
-rw-r--r--src/plugins/gjshello.js35
-rw-r--r--src/plugins/gjshello.plugin5
-rw-r--r--src/plugins/gjshello2.js36
-rw-r--r--src/plugins/gjshello2.plugin5
-rw-r--r--src/test-plugin.c49
-rw-r--r--src/test-plugin.h33
17 files changed, 391 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a3c9491
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,28 @@
+Makefile
+Makefile.in
+*~
+.*.sw?
+*.o
+*.lo
+*.la
+.deps/
+.libs/
+/INSTALL
+/aclocal.m4
+/autom4te.cache/
+/config.guess
+/config.h
+/config.h.in
+/config.log
+/config.status
+/config.sub
+/configure
+/depcomp
+/install-sh
+/libtool
+/ltmain.sh
+/missing
+/stamp-h1
+/src/Test-1.0.gir
+/src/Test-1.0.typelib
+/src/main
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/AUTHORS
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/COPYING
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ChangeLog
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..af437a6
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = src
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/NEWS
diff --git a/README b/README
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/README
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..a692d63
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+# Run this to generate all the initial makefiles, etc.
+# This file was generated by skellington Wed Mar 7 14:18:46 EST 2012.
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+PKG_NAME="peas-experiment"
+
+(test -f $srcdir/configure.ac) || {
+ echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
+ echo " top-level directory"
+ exit 1
+}
+
+REQUIRED_AUTOMAKE_VERSION=1.11 \
+USE_GNOME2_MACROS=1 \
+. gnome-autogen.sh
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..0d68e93
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,51 @@
+dnl ***************************************************************************
+dnl ** configure.in for PEAS-EXPERIMENT
+dnl ***************************************************************************
+dnl
+dnl This is the project name and version number
+AC_INIT(peas-experiment, 0.0.1)
+
+AC_PREREQ(2.59)
+AC_CANONICAL_SYSTEM
+AC_CONFIG_SRCDIR(src/)
+AM_CONFIG_HEADER(config.h)
+AM_INIT_AUTOMAKE(1.11 dist-bzip2 no-dist-gzip)
+
+AM_MAINTAINER_MODE
+
+AC_PROG_CC
+# AC_PROG_F77
+AC_ISC_POSIX
+AC_STDC_HEADERS
+AM_PROG_LIBTOOL
+AC_PROG_LN_S
+
+GNOME_COMPILE_WARNINGS(yes)
+GOBJECT_INTROSPECTION_CHECK([0.9.3])
+
+dnl **************************************************************************
+dnl ** Use pkg-config to check for registered packages **
+dnl **************************************************************************
+PKG_CHECK_MODULES(TEST,
+ [
+ gtk+-3.0
+ libpeas-1.0
+ gobject-introspection-1.0
+ ])
+
+AC_SUBST(TEST_CFLAGS)
+AC_SUBST(TEST_LIBS)
+
+dnl **************************************************************************
+dnl ** Honor aclocal flags **
+dnl **************************************************************************
+ACLOCAL_AMFLAGS="\${ACLOCAL_FLAGS}"
+AC_SUBST(ACLOCAL_AMFLAGS)
+
+dnl **************************************************************************
+dnl ** Generate Makefiles **
+dnl **************************************************************************
+AC_OUTPUT([
+Makefile
+src/Makefile
+])
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..0a74f03
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,37 @@
+INCLUDES = \
+ $(TEST_CFLAGS) \
+ $(NULL)
+
+bin_PROGRAMS = \
+ main
+
+noinst_LTLIBRARIES = \
+ libtest.la
+
+# add your source files here
+main_SOURCES = \
+ main.c \
+ $(NULL)
+
+libtest_la_SOURCES = \
+ test-plugin.c \
+ test-plugin.h \
+ $(NULL)
+
+main_LDADD = \
+ $(TEST_LIBS) \
+ libtest.la \
+ $(NULL)
+
+include $(INTROSPECTION_MAKEFILE)
+INTROSPECTION_GIRS = Test-1.0.gir
+
+Test-1.0.gir: main
+Test_1_0_gir_NAMESPACE = Test
+Test_1_0_gir_VERSION = 1.0
+Test_1_0_gir_LIBS = libtest.la
+Test_1_0_gir_FILES = $(libtest_la_SOURCES)
+Test_1_0_gir_INCLUDES = Gtk-3.0
+
+typelibdir = $(libdir)/gedit/girepository-1.0
+typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..537a032
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,93 @@
+#include <gtk/gtk.h>
+
+#include <libpeas/peas.h>
+#include <girepository.h>
+
+#include "test-plugin.h"
+
+#define DEBUG g_message
+
+static void
+extension_added (PeasExtensionSet *extensions,
+ PeasPluginInfo *plugin,
+ PeasExtension *extension,
+ gpointer user_data)
+{
+ GtkWidget *grid = user_data;
+ GtkWidget *widget;
+
+ test_plugin_badger (TEST_PLUGIN (extension));
+
+ widget = test_plugin_get_widget (TEST_PLUGIN (extension));
+
+ gtk_container_add (GTK_CONTAINER (grid), widget);
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ GtkWidget *window, *grid;
+ PeasEngine *engine;
+ PeasExtensionSet *extensions, *extensions2;
+ const GList *plugins;
+ GError *error = NULL;
+
+ gtk_init (&argc, &argv);
+
+ DEBUG ("Badgers");
+
+ /* create a window */
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ g_signal_connect_swapped (window, "destroy", gtk_main_quit, NULL);
+
+ grid = gtk_grid_new ();
+ gtk_container_add (GTK_CONTAINER (window), grid);
+ gtk_widget_show_all (window);
+
+ /* NOTE: GEdit inherits the engine and includes all of this in its own
+ * class */
+ engine = peas_engine_get_default ();
+
+ peas_engine_add_search_path (engine, "plugins", NULL);
+ peas_engine_enable_loader (engine, "gjs");
+
+ /* FIXME: hax */
+ g_setenv ("GI_TYPELIB_PATH", ".:/usr/lib/girepository-1.0/", FALSE);
+
+ /* Required repositories for g-i */
+ if (!g_irepository_require (g_irepository_get_default (),
+ "Peas", "1.0", 0, &error))
+ {
+ g_critical ("Could not load Peas repository: %s", error->message);
+ g_error_free (error);
+ return 1;
+ }
+
+ if (!g_irepository_require (g_irepository_get_default (),
+ "Test", "1.0", 0, &error))
+ {
+ g_critical ("Could not load Test repository: %s", error->message);
+ g_error_free (error);
+ return 1;
+ }
+
+ /* Load all plugins */
+ plugins = peas_engine_get_plugin_list (engine);
+ for (; plugins != NULL; plugins = g_list_next (plugins))
+ {
+ PeasPluginInfo *plugin = plugins->data;
+
+ DEBUG ("Plugin: %s",
+ peas_plugin_info_get_name (plugin),
+ peas_engine_load_plugin (engine, plugin)? "loaded" : "failed");
+ }
+
+ /* get all extensions implementing TestPlugin */
+ extensions = peas_extension_set_new (engine, TEST_TYPE_PLUGIN,
+ NULL);
+ /* FIXME: connect extension-added and extension-removed */
+ peas_extension_set_foreach (extensions, extension_added, grid);
+
+ gtk_main ();
+}
diff --git a/src/plugins/gjshello.js b/src/plugins/gjshello.js
new file mode 100644
index 0000000..47d46f4
--- /dev/null
+++ b/src/plugins/gjshello.js
@@ -0,0 +1,35 @@
+const Gtk = imports.gi.Gtk;
+
+function test_plugin() {
+}
+
+test_plugin.prototype = {
+ badger: function() {
+ print("Mushroom Mushroom");
+ },
+
+ get_widget: function() {
+ let grid = new Gtk.Grid();
+ let button = new Gtk.Button({ label: "Click Me" });
+
+ grid.add(button);
+
+ button.connect('clicked', function() {
+ print("Wooo!");
+ });
+
+ let button2 = new Gtk.Button({ label: "Broken" });
+ grid.add(button2);
+
+ button2.connect('clicked', function() {
+ exec("does_not_exist();");
+ });
+
+ grid.show_all();
+ return grid;
+ },
+}
+
+var extensions = {
+ 'TestPlugin': test_plugin,
+};
diff --git a/src/plugins/gjshello.plugin b/src/plugins/gjshello.plugin
new file mode 100644
index 0000000..264bcc9
--- /dev/null
+++ b/src/plugins/gjshello.plugin
@@ -0,0 +1,5 @@
+[Plugin]
+Module=gjshello
+Loader=gjs
+IAge=2
+Name=GJS Also Says Hello
diff --git a/src/plugins/gjshello2.js b/src/plugins/gjshello2.js
new file mode 100644
index 0000000..d0f2f38
--- /dev/null
+++ b/src/plugins/gjshello2.js
@@ -0,0 +1,36 @@
+const Mainloop = imports.mainloop;
+const Gtk = imports.gi.Gtk;
+
+function test_plugin() {
+}
+
+test_plugin.prototype = {
+ badger: function() {
+ print("Mushroom Mushroom");
+ },
+
+ get_widget: function() {
+ const strings = [
+ "Badger, Badger, Badger, Badger",
+ "Mushroom, Mushroom",
+ "SNAKE!"
+ ];
+ let i = 0;
+
+ let label = new Gtk.Label();
+ label.set_label(strings[i]);
+ label.show();
+
+ Mainloop.timeout_add(500, function() {
+ i = (i + 1) % strings.length;
+ label.set_label(strings[i]);
+ return true;
+ });
+
+ return label;
+ },
+}
+
+var extensions = {
+ 'TestPlugin': test_plugin,
+};
diff --git a/src/plugins/gjshello2.plugin b/src/plugins/gjshello2.plugin
new file mode 100644
index 0000000..f728767
--- /dev/null
+++ b/src/plugins/gjshello2.plugin
@@ -0,0 +1,5 @@
+[Plugin]
+Module=gjshello2
+Loader=gjs
+IAge=2
+Name=GJS Says Hello
diff --git a/src/test-plugin.c b/src/test-plugin.c
new file mode 100644
index 0000000..504243f
--- /dev/null
+++ b/src/test-plugin.c
@@ -0,0 +1,49 @@
+#include <libpeas/peas.h>
+
+#include "test-plugin.h"
+
+G_DEFINE_INTERFACE (TestPlugin, test_plugin, G_TYPE_OBJECT);
+
+static void
+test_plugin_default_init (TestPluginInterface *iface)
+{
+ /* FIXME: can add required properties here */
+}
+
+/**
+ * test_plugin_badger:
+ * @self: self
+ */
+void
+test_plugin_badger (TestPlugin *self)
+{
+ TestPluginInterface *iface;
+
+ g_return_if_fail (TEST_IS_PLUGIN (self));
+
+ iface = TEST_PLUGIN_GET_IFACE (self);
+
+ if (iface->badger != NULL)
+ iface->badger (self);
+}
+
+/**
+ * test_plugin_get_widget:
+ * @self: self
+ *
+ * Returns: (transfer full): a widget
+ */
+GtkWidget *
+test_plugin_get_widget (TestPlugin *self)
+{
+ TestPluginInterface *iface;
+
+ g_return_if_fail (TEST_IS_PLUGIN (self));
+
+ iface = TEST_PLUGIN_GET_IFACE (self);
+
+ if (iface->get_widget != NULL)
+ return iface->get_widget (self);
+
+ g_return_val_if_reached (NULL);
+}
diff --git a/src/test-plugin.h b/src/test-plugin.h
new file mode 100644
index 0000000..510427e
--- /dev/null
+++ b/src/test-plugin.h
@@ -0,0 +1,33 @@
+#include <gtk/gtk.h>
+
+#ifndef __TEST_PLUGIN_H__
+#define __TEST_PLUGIN_H__
+
+G_BEGIN_DECLS
+
+#define TEST_TYPE_PLUGIN (test_plugin_get_type ())
+#define TEST_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_PLUGIN, TestPlugin))
+#define TEST_PLUGIN_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), TEST_TYPE_PLUGIN, TestPluginInterface))
+#define TEST_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_PLUGIN))
+#define TEST_PLUGIN_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TEST_TYPE_PLUGIN, TestPluginInterface))
+
+typedef struct _TestPlugin TestPlugin;
+typedef struct _TestPluginInterface TestPluginInterface;
+
+struct _TestPluginInterface
+{
+ GTypeInterface parent_iface;
+
+ void (* badger) (TestPlugin *self);
+
+ GtkWidget * (* get_widget) (TestPlugin *self);
+};
+
+GType test_plugin_get_type (void) G_GNUC_CONST;
+
+void test_plugin_badger (TestPlugin *self);
+GtkWidget *test_plugin_get_widget (TestPlugin *self);
+
+G_END_DECLS
+
+#endif /* __TEST_PLUGIN_H__ */