]> git.street.me.uk Git - andy/viking.git/commitdiff
Add configuration file for external tools
authorGuilhem Bonnefille <guilhem.bonnefille@gmail.com>
Sun, 19 Jul 2009 21:14:05 +0000 (23:14 +0200)
committerGuilhem Bonnefille <guilhem.bonnefille@gmail.com>
Sun, 19 Jul 2009 21:14:05 +0000 (23:14 +0200)
Viking loads ~/.viking/external_tools.xml to create external tools.
/doc/examples/external_tools.xml is such a file.

doc/examples/external_tools.xml [new file with mode: 0644]
src/modules.c

diff --git a/doc/examples/external_tools.xml b/doc/examples/external_tools.xml
new file mode 100644 (file)
index 0000000..94f3150
--- /dev/null
@@ -0,0 +1,12 @@
+<objects>
+  <object class="VikWebtoolCenter">
+    <property name="label">Letuffe (Hiking)</property>
+    <property name="url">http://beta.letuffe.org/?layers=0B000FFFFFFFFFFFF&amp;lat=%s&amp;lon=%s&amp;zoom=%d</property>
+    <property name="id">42</property>
+  </object>
+  <object class="VikWebtoolCenter">
+    <property name="label">Osmose</property>
+    <property name="url">http://osmose.openstreetmap.fr/map/cgi-bin/index.py?layers=B00000FFFFFFFFFFFFT&amp;lat=%s&amp;lon=%s&amp;zoom=%d</property>
+    <property name="id">43</property>
+  </object>
+</objects>
index e0568cc490ee2fdfa1f9e34f44033fc97ca60d1e..5380a6009d96405142a876c698b488ade644c011 100644 (file)
 #include "config.h"
 #endif
 
+#include <glib.h>
+#include <glib/gstdio.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
 #include "modules.h"
 
 #include "google.h"
 #include "osm-traces.h"
 #include "bluemarble.h"
 #include "openaerial.h"
+#include "file.h"
+#include "vikexttools.h"
+#include "vikgobjectbuilder.h"
+
+#define VIKING_EXTTOOLS_FILE "external_tools.xml"
+
+static void
+modules_register_exttools(VikGobjectBuilder *self, GObject *object)
+{
+  g_debug (__FUNCTION__);
+  VikExtTool *tool = VIK_EXT_TOOL (object);
+  vik_ext_tools_register (tool);
+}
+
+static void
+modules_load_config(void)
+{
+  /* External tools */
+  gchar *tools = g_build_filename(a_get_viking_dir(), VIKING_EXTTOOLS_FILE, NULL);
+  if (g_access (tools, R_OK) == 0)
+  {
+       VikGobjectBuilder *builder = vik_gobject_builder_new ();
+       g_signal_connect (builder, "new-object", G_CALLBACK (modules_register_exttools), NULL);
+       vik_gobject_builder_parse (builder, tools);
+       g_object_unref (builder);
+  }
+}
 
 void modules_init()
 {
@@ -54,5 +87,8 @@ void modules_init()
 #ifdef VIK_CONFIG_OPENAERIAL
   openaerial_init();
 #endif
+  
+  /* As modules are loaded, we can load configuration files */
+  modules_load_config ();
 }