]> git.street.me.uk Git - andy/viking.git/blobdiff - src/vikwebtool.c
Trap some errors reported by gpsbabel
[andy/viking.git] / src / vikwebtool.c
index 706313a549f405886f76e0c4bb5a5dc62158f20f..8ceff421b7642250e3d10a7170fb68f1a8a325e9 100644 (file)
 
 #include <glib/gi18n.h>
 
-#include "util.h"
-
-static void webtool_class_init ( VikWebtoolClass *klass );
-static void webtool_init ( VikWebtool *vwd );
+#include "ui_util.h"
 
 static GObjectClass *parent_class;
 
 static void webtool_finalize ( GObject *gob );
 
 static void webtool_open ( VikExtTool *self, VikWindow *vwindow );
+static void webtool_open_at_position ( VikExtTool *self, VikWindow *vwindow, VikCoord *vc );
 
-GType vik_webtool_get_type()
-{
-  static GType w_type = 0;
-
-  if (!w_type)
-  {
-    static const GTypeInfo w_info = 
-    {
-      sizeof (VikWebtoolClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc) webtool_class_init,
-      NULL, /* class_finalize */
-      NULL, /* class_data */
-      sizeof (VikWebtool),
-      0,
-      (GInstanceInitFunc) webtool_init,
-    };
-    w_type = g_type_register_static ( VIK_EXT_TOOL_TYPE, "VikWebtool", &w_info, G_TYPE_FLAG_ABSTRACT );
-  }
+G_DEFINE_ABSTRACT_TYPE (VikWebtool, vik_webtool, VIK_EXT_TOOL_TYPE)
 
-  return w_type;
-}
-
-static void webtool_class_init ( VikWebtoolClass *klass )
+static void vik_webtool_class_init ( VikWebtoolClass *klass )
 {
   GObjectClass *object_class;
   VikExtToolClass *ext_tool_class;
@@ -77,6 +53,7 @@ static void webtool_class_init ( VikWebtoolClass *klass )
 
   ext_tool_class = VIK_EXT_TOOL_CLASS ( klass );
   ext_tool_class->open = webtool_open;
+  ext_tool_class->open_at_position = webtool_open_at_position;
 }
 
 VikWebtool *vik_webtool_new ()
@@ -84,8 +61,9 @@ VikWebtool *vik_webtool_new ()
   return VIK_WEBTOOL ( g_object_new ( VIK_WEBTOOL_TYPE, NULL ) );
 }
 
-static void webtool_init ( VikWebtool *vlp )
+static void vik_webtool_init ( VikWebtool *vlp )
 {
+  // NOTHING
 }
 
 static void webtool_finalize ( GObject *gob )
@@ -98,11 +76,29 @@ static void webtool_open ( VikExtTool *self, VikWindow *vwindow )
 {
   VikWebtool *vwd = VIK_WEBTOOL ( self );
   gchar *url = vik_webtool_get_url ( vwd, vwindow );
-  open_url ( NULL, url );
+  open_url ( GTK_WINDOW(vwindow), url );
   g_free ( url );
 }
 
+static void webtool_open_at_position ( VikExtTool *self, VikWindow *vwindow, VikCoord *vc )
+{
+  VikWebtool *vwd = VIK_WEBTOOL ( self );
+  gchar *url = vik_webtool_get_url_at_position ( vwd, vwindow, vc );
+  if ( url ) {
+    open_url ( GTK_WINDOW(vwindow), url );
+    g_free ( url );
+  }
+}
+
 gchar *vik_webtool_get_url ( VikWebtool *self, VikWindow *vwindow )
 {
   return VIK_WEBTOOL_GET_CLASS( self )->get_url( self, vwindow );
 }
+
+gchar *vik_webtool_get_url_at_position ( VikWebtool *self, VikWindow *vwindow, VikCoord *vc )
+{
+  if ( VIK_WEBTOOL_GET_CLASS( self )->get_url_at_position )
+    return VIK_WEBTOOL_GET_CLASS( self )->get_url_at_position( self, vwindow, vc );
+  else
+    return NULL;
+}