[emerillon-plugins] port sample-vala and image-export to emerillon 0.1.90 (Peas, GTK3, Champlain 0.12)



commit a208d148d5c0a14ff3f9bcab2fd478ab6be541b5
Author: Simon Wenner <simon wenner ch>
Date:   Sun Sep 11 02:58:52 2011 +0200

    port sample-vala and image-export to emerillon 0.1.90 (Peas, GTK3, Champlain 0.12)

 configure.ac                                       |   14 ++--
 plugins/image-export/Makefile.am                   |   12 +-
 ....emerillon-plugin.in => image-export.plugin.in} |    2 +-
 plugins/image-export/image-export.vala             |   98 ++++++++++----------
 plugins/sample-vala/Makefile.am                    |   12 +-
 plugins/sample-vala/sample-vala-plugin.vala        |   61 +++++++------
 ...a.emerillon-plugin.in => sample-vala.plugin.in} |    6 +-
 7 files changed, 107 insertions(+), 98 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 1d92d93..bcab313 100644
--- a/configure.ac
+++ b/configure.ac
@@ -53,12 +53,12 @@ GNOME_DOC_INIT
 # **********
 
 PKG_CHECK_MODULES([EMERILLON], [
-	glib-2.0 >= 2.12.0
-	gtk+-2.0 >= 2.12.0
-	ethos-1.0 >= 0.2
-	ethos-ui-1.0 >= 0.2
-	emerillon >= 0.1.2
-	champlain-0.8 > 0.7.1
+	glib-2.0 >= 2.25.10
+	gtk+-3.0 >= 3.0.0
+	emerillon >= 0.1.90
+	champlain-0.12 >= 0.11.0
+	libpeas-1.0 >= 1.0
+	libpeas-gtk-1.0 >= 1.0
 ])
 AC_SUBST(EMERILLON_LIBS)
 AC_SUBST(EMERILLON_CFLAGS)
@@ -303,7 +303,7 @@ then
 	AM_PROG_VALAC([0.9.1])
 
 	PKG_CHECK_MODULES(SAMPLEVALA,
-		[ champlain-0.8 > 0.7.1 ],
+		[ champlain-0.12 >= 0.11.0 ],
 		[],[have_sample_vala_deps=no])
 	AC_SUBST(SAMPLEVALA_LIBS)
 	AC_SUBST(SAMPLEVALA_CFLAGS)
diff --git a/plugins/image-export/Makefile.am b/plugins/image-export/Makefile.am
index 3c7a054..4b19ecf 100644
--- a/plugins/image-export/Makefile.am
+++ b/plugins/image-export/Makefile.am
@@ -12,11 +12,11 @@ INCLUDES = \
 BUILT_SOURCES = image-export.vala.stamp
 
 AM_VALAFLAGS = \
-	--pkg gtk+-2.0 \
-	--pkg champlain-0.6 \
+	--pkg gtk+-3.0 \
+	--pkg champlain-0.12 \
 	--pkg clutter-1.0 \
 	--pkg emerillon \
-	--pkg ethos-1.0 \
+	--pkg Peas-1.0 \
 	--pkg gconf-2.0 \
 	$(NULL)
 
@@ -41,11 +41,11 @@ libimage_export_la_LDFLAGS = \
 
 # Plugin Info
 
-plugin_in_files = image-export.emerillon-plugin.in
+plugin_in_files = image-export.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: %.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)
+plugin_DATA = $(plugin_in_files:.plugin.in=.plugin)
 
 EXTRA_DIST = $(plugin_in_files)
 
diff --git a/plugins/image-export/image-export.emerillon-plugin.in b/plugins/image-export/image-export.plugin.in
similarity index 90%
rename from plugins/image-export/image-export.emerillon-plugin.in
rename to plugins/image-export/image-export.plugin.in
index b1d9c23..2e92008 100644
--- a/plugins/image-export/image-export.emerillon-plugin.in
+++ b/plugins/image-export/image-export.plugin.in
@@ -1,4 +1,4 @@
-[Emerillon Plugin]
+[Plugin]
 _Name=Image Exporter
 Module=image-export
 _Description=Exports the map as a PNG image.
diff --git a/plugins/image-export/image-export.vala b/plugins/image-export/image-export.vala
index 2e7eb2d..bcf3837 100644
--- a/plugins/image-export/image-export.vala
+++ b/plugins/image-export/image-export.vala
@@ -18,25 +18,26 @@
  */
 
 using GLib;
-using Ethos;
+using Peas;
 using Champlain;
 using GConf;
 
-public class ImageExportPlugin : Ethos.Plugin
+public class ImageExportPlugin : GLib.Object, Peas.Activatable
 {
-  private unowned Emerillon.Window window;
+  public weak GLib.Object object { get; construct; }
+  private weak Emerillon.Window window;
   private Champlain.View view;
   private Gtk.ActionGroup action_group;
   private uint ui_id;
 
-  construct
-	{
-    this.activated.connect (activate_plugin);
-    this.deactivated.connect (deactivate_plugin);
+  public ImageExportPlugin ()
+  {
+    /* constructor chain up hint */
+    GLib.Object ();
   }
 
-  public void activate_plugin ()
-	{
+  public void activate ()
+  {
     this.window = Emerillon.Window.dup_default ();
     this.view = window.get_map_view ();
 
@@ -48,38 +49,37 @@ public class ImageExportPlugin : Ethos.Plugin
 
     Gtk.Action action;
     action =  new Gtk.Action ("ImageExportActionSave",
-				_("Export as _image"), "", Gtk.STOCK_SAVE_AS);
+        _("Export as _image"), "", Gtk.Stock.SAVE_AS);
     action_group.add_action (action);
     action.activate.connect (save_as_image_callback);
 
     action =  new Gtk.Action ("ImageExportActionMail",
-				_("Attach to _email"), "", "");
+        _("Attach to _email"), "", "");
     action_group.add_action (action);
     action.activate.connect (attach_to_email_callback);
 
     manager.insert_action_group (action_group, -1);
 
     string ui = """<ui>
-			<menubar name="MainMenu">
-				<menu name="Edit" action="Edit">
-				<placeholder name="EditPluginMenu">
-					<menuitem name="ImageExportItemSave" action="ImageExportActionSave" />
-					<menuitem name="ImageExportItemMail" action="ImageExportActionMail" />
-				</placeholder>
-				</menu>
-			</menubar>
+        <menubar name="MainMenu">
+            <menu name="Edit" action="Edit">
+            <placeholder name="EditPluginMenu">
+                <menuitem name="ImageExportItemSave" action="ImageExportActionSave" />
+                <menuitem name="ImageExportItemMail" action="ImageExportActionMail" />
+            </placeholder>
+            </menu>
+        </menubar>
     </ui>""";
 
     try {
       ui_id = manager.add_ui_from_string (ui, ui.length);
     }
-		catch (GLib.Error e)
-		{
+    catch (GLib.Error e) {
       GLib.error ("%s", e.message);
     }
   }
 
-  public void deactivate_plugin ()
+  public void deactivate ()
   {
     /* remove the buttons */
     Gtk.UIManager manager = window.get_ui_manager ();
@@ -87,6 +87,10 @@ public class ImageExportPlugin : Ethos.Plugin
     manager.remove_action_group (action_group);
   }
 
+  public void update_state ()
+  {
+  }
+
   private void grab_and_save_image (string path) throws GLib.Error
   {
     /* create an image of the stage */
@@ -96,46 +100,44 @@ public class ImageExportPlugin : Ethos.Plugin
     int height = (int) clutter_stage.height;
 
     var pixbuf = new Gdk.Pixbuf.from_data (pixels, Gdk.Colorspace.RGB,
-				true, 8, width, height, width * 4, null);
+        true, 8, width, height, width * 4, null);
     /* save it as png file */
     pixbuf.save (path, "png", null, null);
   }
 
-  public void save_as_image_callback (Gtk.Action action)
+  private void save_as_image_callback (Gtk.Action action)
   {
     /* create the save dialog */
     var file_chooser = new Gtk.FileChooserDialog (_("Save as png image"),
-				null, Gtk.FileChooserAction.SAVE, Gtk.STOCK_CANCEL,
-				Gtk.ResponseType.CANCEL, Gtk.STOCK_SAVE, Gtk.ResponseType.ACCEPT,
-				null);
+        null, Gtk.FileChooserAction.SAVE, Gtk.Stock.CANCEL,
+        Gtk.ResponseType.CANCEL, Gtk.Stock.SAVE, Gtk.ResponseType.ACCEPT,
+        null);
 
     file_chooser.set_current_name (_("map.png"));
     file_chooser.set_do_overwrite_confirmation (true);
 
     if (file_chooser.run () == Gtk.ResponseType.ACCEPT)
     {
-			string path = file_chooser.get_filename ();
-			try {
-				grab_and_save_image (path);
-			}
-			catch (GLib.Error e)
-			{
-				/* saving failed */
-				var dialog = new Gtk.MessageDialog (file_chooser,
-						Gtk.DialogFlags.DESTROY_WITH_PARENT,
-						Gtk.MessageType.ERROR,
-						Gtk.ButtonsType.CLOSE,
-						_("Error"));
-				dialog.secondary_text = e.message;
-				dialog.position = Gtk.WindowPosition.CENTER_ON_PARENT;
-				dialog.run ();
-				dialog.destroy ();
-			}
+      string path = file_chooser.get_filename ();
+      try {
+        grab_and_save_image (path);
+      }
+      catch (GLib.Error e) {
+        /* saving failed */
+        var dialog = new Gtk.MessageDialog (file_chooser,
+                Gtk.DialogFlags.DESTROY_WITH_PARENT,
+                Gtk.MessageType.ERROR,
+                Gtk.ButtonsType.CLOSE,
+                _("Error"));
+        dialog.secondary_text = e.message;
+        dialog.run ();
+        dialog.destroy ();
+      }
     }
     file_chooser.destroy ();
   }
 
-  public void attach_to_email_callback (Gtk.Action action)
+  private void attach_to_email_callback (Gtk.Action action)
   {
     /* get the default email application */
     var gc = GConf.Client.get_default ();
@@ -192,7 +194,9 @@ public class ImageExportPlugin : Ethos.Plugin
   }
 }
 
-public Ethos.Plugin? ethos_plugin_register ()
+[ModuleInit]
+public void peas_register_types (GLib.TypeModule module)
 {
-  return new ImageExportPlugin ();
+  var objmodule = module as Peas.ObjectModule;
+  objmodule.register_extension_type (typeof(Peas.Activatable), typeof(ImageExportPlugin));
 }
diff --git a/plugins/sample-vala/Makefile.am b/plugins/sample-vala/Makefile.am
index 1092f94..38bd35c 100644
--- a/plugins/sample-vala/Makefile.am
+++ b/plugins/sample-vala/Makefile.am
@@ -12,11 +12,11 @@ INCLUDES = \
 BUILT_SOURCES = samplevala.vala.stamp
 
 AM_VALAFLAGS = \
-	--pkg gtk+-2.0 \
+	--pkg gtk+-3.0 \
 	--pkg emerillon \
 	--pkg clutter-1.0 \
-	--pkg ethos-1.0 \
-	--pkg ethos-ui-1.0 \
+	--pkg Peas-1.0 \
+	--pkg PeasGtk-1.0 \
 	$(NULL)
 
 plugin_LTLIBRARIES = libsamplevala.la
@@ -40,11 +40,11 @@ libsamplevala_la_LDFLAGS = \
 
 # Plugin Info
 
-plugin_in_files = sample-vala.emerillon-plugin.in
+plugin_in_files = sample-vala.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: %.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)
+plugin_DATA = $(plugin_in_files:.plugin.in=.plugin)
 
 EXTRA_DIST = $(plugin_in_files)
 
diff --git a/plugins/sample-vala/sample-vala-plugin.vala b/plugins/sample-vala/sample-vala-plugin.vala
index 71555db..f516408 100644
--- a/plugins/sample-vala/sample-vala-plugin.vala
+++ b/plugins/sample-vala/sample-vala-plugin.vala
@@ -18,34 +18,37 @@
 
 /**
  * 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
+ * Implementing the 'PeasGtk.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;
+using PeasGtk;
+using Emerillon;
 
-public class SampleValaPlugin : Ethos.Plugin, Ethos.UI.Configurable
+public class SampleValaPlugin : GLib.Object, Peas.Activatable, PeasGtk.Configurable
 {
+  public weak GLib.Object object { get; construct; }
+
   /* A reference to the Emerillon main window */
   private unowned Emerillon.Window window;
-  
-  /* The constructor registers the callbacks to start and stop the plugin */
-  construct
+
+  /* The constructor */
+  public SampleValaPlugin ()
   {
-    this.activated.connect (activate_plugin);
-    this.deactivated.connect (deactivate_plugin);
+    /* constructor chain up hint */
+    GLib.Object ();
   }
 
   /* This function gets called when the plugin is loaded.
    * Initilize your plugin and add menu entries or a sidebar.
    */
-  public void activate_plugin ()
+  public void activate ()
   {
     this.window = Emerillon.Window.dup_default ();
 
@@ -55,32 +58,34 @@ public class SampleValaPlugin : Ethos.Plugin, Ethos.UI.Configurable
   /* 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 ()
+  public void deactivate ()
   {
     GLib.message ("SampleValaPlugin deactivated.");
   }
-  
-  /* Implementation of the 'Ethos.Configurable' interface.
-   * This function creates a small dialog with a close button.
+
+  /* This function gets called when the internal state of the application changes.
+   * We don't need this function, but we have to provide it.
+   */
+  public void update_state ()
+  {
+  }
+
+  /* Implementation of the 'PeasGtk.Configurable' interface.
+   * This function creates the widgets inside a small dialog with a close button.
    */
-  public void configure (Gtk.Widget parent)
+  public Gtk.Widget create_configure_widget ()
   {
-    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 ();
+
+    return label;
   }
 }
 
 /* Main plugin function. */
-public Ethos.Plugin? ethos_plugin_register ()
+[ModuleInit]
+public void peas_register_types (GLib.TypeModule module)
 {
-  return new SampleValaPlugin ();
+  var objmodule = module as Peas.ObjectModule;
+  objmodule.register_extension_type (typeof(Peas.Activatable), typeof(SampleValaPlugin));
+  objmodule.register_extension_type (typeof(PeasGtk.Configurable), typeof(SampleValaPlugin));
 }
diff --git a/plugins/sample-vala/sample-vala.emerillon-plugin.in b/plugins/sample-vala/sample-vala.plugin.in
similarity index 50%
rename from plugins/sample-vala/sample-vala.emerillon-plugin.in
rename to plugins/sample-vala/sample-vala.plugin.in
index 95c7710..f35e8ba 100644
--- a/plugins/sample-vala/sample-vala.emerillon-plugin.in
+++ b/plugins/sample-vala/sample-vala.plugin.in
@@ -1,7 +1,7 @@
-[Emerillon Plugin]
+[Plugin]
 _Name=Vala Example
 Module=samplevala
 _Description=An example plugin written in Vala.
 IAge=1
-Authors=
-Copyright=
+Authors=Simon Wenner <simon wenner ch>
+Copyright=Copyright  2010 Simon Wenner



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