[libchamplainmm] Location: Add methods, properties and vfuncs



commit 9cc3b5ce800769d615973a5752bf8ba2bde90535
Author: Juan R. GarcĂ­a Blanco <juanrgar gmail com>
Date:   Mon Mar 3 22:37:43 2014 +0100

    Location: Add methods, properties and vfuncs
    
        * Create champlain_vfuncs.defs with Location vfuncs.
        * champlain.defs: Include champlain_vfuncs.defs
        * generate_extra_defs_libchamplain.cc: Add
        CHAMPLAIN_TYPE_LOCATION.
        * champlain_signals.defs: Regenerate to include Location
        properties.
        * Add set_location(), get_latitude(), get_longitude() methods.
        * Add ::latitude, ::longitude properties.

 champlain/src/champlain.defs                       |    1 +
 champlain/src/champlain_signals.defs               |   21 ++++++++++++++++-
 champlain/src/champlain_vfuncs.defs                |   24 ++++++++++++++++++++
 champlain/src/location.hg                          |   21 ++++++++++++++++-
 .../extradefs/generate_extra_defs_libchamplain.cc  |    3 +-
 5 files changed, 67 insertions(+), 3 deletions(-)
---
diff --git a/champlain/src/champlain.defs b/champlain/src/champlain.defs
index 68784da..c3ea4a7 100644
--- a/champlain/src/champlain.defs
+++ b/champlain/src/champlain.defs
@@ -3,3 +3,4 @@
 (include champlain_extra.defs)
 (include champlain_methods.defs)
 (include champlain_signals.defs)
+(include champlain_vfuncs.defs)
diff --git a/champlain/src/champlain_signals.defs b/champlain/src/champlain_signals.defs
index 21d60e2..f83954e 100644
--- a/champlain/src/champlain_signals.defs
+++ b/champlain/src/champlain_signals.defs
@@ -199,6 +199,26 @@
   (construct-only #f)
 )
 
+;; From ChamplainLocation
+
+(define-property latitude
+  (of-object "ChamplainLocation")
+  (prop-type "GParamDouble")
+  (docs "The latitude coordonate")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
+(define-property longitude
+  (of-object "ChamplainLocation")
+  (prop-type "GParamDouble")
+  (docs "The longitude coordonate")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
 ;; From ChamplainPathLayer
 
 (define-property closed
@@ -511,4 +531,3 @@
   (construct-only #f)
 )
 
-
diff --git a/champlain/src/champlain_vfuncs.defs b/champlain/src/champlain_vfuncs.defs
new file mode 100644
index 0000000..50f8bc2
--- /dev/null
+++ b/champlain/src/champlain_vfuncs.defs
@@ -0,0 +1,24 @@
+;; -*- scheme -*-
+; virtual function definitions
+; define-vfunc is gtkmm-specific
+
+; ChamplainLocation
+
+(define-vfunc set_location
+  (of-object "ChamplainLocation")
+  (return-type "void")
+  (parameters
+    '("gdouble" "latitude")
+    '("gdouble" "longitude")
+  )
+)
+
+(define-vfunc get_latitude
+  (of-object "ChamplainLocation")
+  (return-type "gdouble")
+)
+
+(define-vfunc get_longitude
+  (of-object "ChamplainLocation")
+  (return-type "gdouble")
+)
diff --git a/champlain/src/location.hg b/champlain/src/location.hg
index 7e05004..39c89e2 100644
--- a/champlain/src/location.hg
+++ b/champlain/src/location.hg
@@ -28,10 +28,29 @@ typedef struct _ChamplainLocationIface ChamplainLocationIface;
 
 namespace Champlain
 {
+
+/** An interface common to objects having latitude and longitude.
+ *
+ * By implementing Location the object declares that it has latitude
+ * and longitude and can be used to specify location on the map.
+ *
+ * newin{0,10}
+ */
 class Location : public Glib::Interface
 {
   _CLASS_INTERFACE(Location, ChamplainLocation, CHAMPLAIN_LOCATION, ChamplainLocationIface)
 
-  // TODO
+  _WRAP_METHOD(void set_location(double latitude, double longitude), champlain_location_set_location)
+
+  _WRAP_METHOD(double get_latitude() const, champlain_location_get_latitude)
+  _WRAP_METHOD(double get_longitude() const, champlain_location_get_longitude)
+
+  _WRAP_VFUNC(void set_location(double latitude, double longitude), set_location)
+
+  _WRAP_VFUNC(double get_latitude() const, get_latitude)
+  _WRAP_VFUNC(double get_longitude() const, get_longitude)
+
+  _WRAP_PROPERTY("longitude", double)
+  _WRAP_PROPERTY("latitude", double)
 };
 } // namespace Champlain
diff --git a/tools/extradefs/generate_extra_defs_libchamplain.cc 
b/tools/extradefs/generate_extra_defs_libchamplain.cc
index 7b0c48c..c0e8918 100644
--- a/tools/extradefs/generate_extra_defs_libchamplain.cc
+++ b/tools/extradefs/generate_extra_defs_libchamplain.cc
@@ -31,12 +31,13 @@ main(int argc, char *argv[])
             << get_defs(CHAMPLAIN_TYPE_MAP_SOURCE)
             << get_defs(CHAMPLAIN_TYPE_MAP_PROJECTION)
             << get_defs(CHAMPLAIN_TYPE_LABEL)
+            << get_defs(CHAMPLAIN_TYPE_LOCATION)
             << get_defs(CHAMPLAIN_TYPE_PATH_LAYER)
             << get_defs(CHAMPLAIN_TYPE_MARKER_LAYER)
             << get_defs(CHAMPLAIN_TYPE_STATE)
             << get_defs(CHAMPLAIN_TYPE_TILE)
             << get_defs(CHAMPLAIN_TYPE_VIEW)
-            << std::endl;
+            ;
 
   return 0;
 }


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