[emerillon-plugins: 1/4] Add sample-vala plugin



commit b3bfd238af8500def9f3de1b07f7bd7d917e12fa
Author: Simon Wenner <simon wenner ch>
Date:   Thu May 6 23:20:09 2010 +0200

    Add sample-vala plugin

 configure.ac                                       |   21 ++++++-
 plugins/sample-vala/Makefile.am                    |   56 ++++++++++++++++
 plugins/sample-vala/sample-vala-plugin.vala        |   68 ++++++++++++++++++++
 .../sample-vala/sample-vala.emerillon-plugin.in    |    7 ++
 4 files changed, 151 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 92ee527..fd444be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,7 +59,7 @@ AC_SUBST(EMERILLON_CFLAGS)
 
 AC_MSG_CHECKING([which plugins to build])
 
-ALL_PLUGINS="bixi"
+ALL_PLUGINS="bixi sample-vala"
 USEFUL_PLUGINS="bixi"
 DEFAULT_PLUGINS="bixi"
 
@@ -284,6 +284,24 @@ then
 	fi
 fi
 
+# **************
+# Sample-Vala
+# **************
+plugin_defined sample-vala
+if test "$?" = 1
+then
+	AM_PROG_VALAC([0.8.1])
+
+	PKG_CHECK_MODULES(SAMPLEVALA,
+		[ gtk+-2.0 >= 2.12.0 ],
+		[],[have_sample-vala_deps=no])
+	AC_SUBST(SAMPLEVALA_LIBS)
+	AC_SUBST(SAMPLEVALA_CFLAGS)
+	if test "x$have_sample-vala_deps" = "xno"
+	then
+		undef_plugin sample-vala "Sample-Vala plugin dependencies not satisfied."
+	fi
+fi
 
 if test -z "$disabled_plugins"
 then
@@ -306,6 +324,7 @@ AC_CONFIG_FILES([
 Makefile
 plugins/Makefile
 plugins/bixi/Makefile
+plugins/sample-vala/Makefile
 po/Makefile.in])
 
 AC_OUTPUT
diff --git a/plugins/sample-vala/Makefile.am b/plugins/sample-vala/Makefile.am
new file mode 100644
index 0000000..b8d2fa5
--- /dev/null
+++ b/plugins/sample-vala/Makefile.am
@@ -0,0 +1,56 @@
+# Vala example plugin
+plugindir = $(libdir)/emerillon/plugins
+
+INCLUDES = \
+	-I$(top_srcdir) 				\
+	$(EMERILLON_CFLAGS) 			\
+	$(SAMPLEVALA_CFLAGS)			\
+	$(WARN_CFLAGS)					\
+	-DEMERILLON_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"	\
+	-include config.h
+
+BUILT_SOURCES = samplevala.vala.stamp
+
+AM_VALAFLAGS = \
+	--pkg gtk+-2.0 \
+	--pkg emerillon \
+	--pkg clutter-1.0 \
+	--pkg ethos-1.0 \
+	--pkg ethos-ui-1.0 \
+	$(NULL)
+
+plugin_LTLIBRARIES = libsamplevala.la
+
+libsamplevala_la_VALASOURCES = \
+	sample-vala-plugin.vala
+
+libsamplevala_la_SOURCES = \
+	samplevala.vala.stamp	\
+	$(libsamplevala_la_VALASOURCES:.vala=.c)	\
+	$(NULL)
+
+samplevala.vala.stamp: $(libsamplevala_la_VALASOURCES)
+	$(VALAC) -C $(AM_VALAFLAGS) $^
+	touch $@
+
+libsamplevala_la_LDFLAGS = \
+	$(PLUGIN_LIBTOOL_FLAGS)		\
+	$(EMERILLON_LIBS)		\
+	$(sample-vala_LIBS)
+
+# Plugin Info
+
+plugin_in_files = sample-vala.emerillon-plugin.in
+
+%.emerillon-plugin: %.emerillon-plugin.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(AM_V_GEN)$(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
+
+plugin_DATA = $(plugin_in_files:.emerillon-plugin.in=.emerillon-plugin)
+
+EXTRA_DIST = $(plugin_in_files)
+
+CLEANFILES = $(plugin_DATA)	\
+	samplevala.vala.stamp	\
+	$(libsamplevala_la_VALASOURCES:.vala=.c)
+
+DISTCLEANFILES = $(plugin_DATA)
+
diff --git a/plugins/sample-vala/sample-vala-plugin.vala b/plugins/sample-vala/sample-vala-plugin.vala
new file mode 100644
index 0000000..44c6c07
--- /dev/null
+++ b/plugins/sample-vala/sample-vala-plugin.vala
@@ -0,0 +1,68 @@
+/* 
+ * Emerillon Vala plugin example.
+ * 
+ * This plugin prints a message when it is loaded and unloaded.
+ * Implementing the 'Ethos.UI.Configurable' interface is optional. It is only
+ * needed if you want a configuration dialog.
+ * 
+ * To compile it run: ./configure --with-plugins=really-all
+ */
+
+using GLib;
+using Gtk;
+using Ethos;
+
+public class SampleValaPlugin : Ethos.Plugin, Ethos.UI.Configurable
+{
+  /* A reference to the Emerillon main window */
+  private unowned Emerillon.Window window;
+  
+  /* The constructor registers the callbacks to start and stop the plugin */
+  construct
+  {
+    this.activated.connect (activate_plugin);
+    this.deactivated.connect (deactivate_plugin);
+  }
+
+  /* This function gets called when the plugin is loaded.
+   * Initilize your plugin and add menu entries or a sidebar.
+   */
+  public void activate_plugin ()
+  {
+    this.window = Emerillon.Window.dup_default ();
+
+    GLib.message ("SampleValaPlugin activated.");
+  }
+
+  /* This functions gets called when the plugin is unloaded.
+   * Make sure that you undo all the changes of your plugin in Emerillon.
+   */
+  public void deactivate_plugin ()
+  {
+    GLib.message ("SampleValaPlugin deactivated.");
+  }
+  
+  /* Implementation of the 'Ethos.Configurable' interface.
+   * This function creates a small dialog with a close button.
+   */
+  public void configure (Gtk.Widget parent)
+  {
+    var dialog = new Gtk.Dialog.with_buttons ("Vala Example Plugin",
+        (Gtk.Window) parent, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
+        Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE,
+        null);
+    Gtk.Container content_area = (Gtk.Container) dialog.get_content_area ();
+    var label = new Gtk.Label ("Welcome to the Vala example configuration.");
+    content_area.add (label);
+    content_area.set_size_request (-1, 100);
+    dialog.response.connect ((id) => { dialog.destroy (); });
+    dialog.show_all ();
+    dialog.run ();
+  }
+}
+
+/* Main plugin function. */
+public Ethos.Plugin? ethos_plugin_register ()
+{
+  return new SampleValaPlugin ();
+}
diff --git a/plugins/sample-vala/sample-vala.emerillon-plugin.in b/plugins/sample-vala/sample-vala.emerillon-plugin.in
new file mode 100644
index 0000000..95c7710
--- /dev/null
+++ b/plugins/sample-vala/sample-vala.emerillon-plugin.in
@@ -0,0 +1,7 @@
+[Emerillon Plugin]
+_Name=Vala Example
+Module=samplevala
+_Description=An example plugin written in Vala.
+IAge=1
+Authors=
+Copyright=



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