(gtype-id "CHAMPLAIN_TYPE_ZOOM_LEVEL")
)
+(define-boxed Point
+ (in-module "Champlain")
+ (c-name "ChamplainPoint")
+ (gtype-id "CHAMPLAIN_TYPE_POINT")
+ (fields
+ '("double" "lat")
+ '("double" "lon")
+ )
+)
+
;; Enumerations and flags ...
(define-enum ScrollMode
)
)
+(define-method remove_point
+ (of-object "ChamplainPolygon")
+ (c-name "champlain_polygon_remove_point")
+ (return-type "none")
+ (parameters
+ '("ChamplainPoint*" "point")
+ )
+)
+
(define-method clear_points
(of-object "ChamplainPolygon")
(c-name "champlain_polygon_clear_points")
(return-type "ChamplainLayer*")
)
+(define-method show
+ (of-object "ChamplainLayer")
+ (c-name "champlain_layer_show")
+ (return-type "none")
+)
+
+(define-method hide
+ (of-object "ChamplainLayer")
+ (c-name "champlain_layer_hide")
+ (return-type "none")
+)
+
+(define-method add_marker
+ (of-object "ChamplainLayer")
+ (c-name "champlain_layer_add_marker")
+ (return-type "none")
+ (parameters
+ '("ChamplainBaseMarker*" "marker")
+ )
+)
+
+(define-method remove_marker
+ (of-object "ChamplainLayer")
+ (c-name "champlain_layer_remove_marker")
+ (return-type "none")
+ (parameters
+ '("ChamplainBaseMarker*" "marker")
+ )
+)
+
;; From champlain-map-source.h
(return-type "gboolean")
)
+(define-function marker_set_highlight_color
+ (c-name "champlain_marker_set_highlight_color")
+ (return-type "none")
+ (parameters
+ '("ClutterColor*" "color")
+ )
+)
+
;; From champlain-base-marker.h
)
)
+(define-method set_highlighted
+ (of-object "ChamplainBaseMarker")
+ (c-name "champlain_base_marker_set_highlighted")
+ (return-type "none")
+ (parameters
+ '("gboolean" "value")
+ )
+)
+
+(define-method get_highlighted
+ (of-object "ChamplainBaseMarker")
+ (c-name "champlain_base_marker_get_highlighted")
+ (return-type "gboolean")
+)
+
;; From champlain-tile.h
(define-method get_modified_time_string
(of-object "ChamplainTile")
(c-name "champlain_tile_get_modified_time_string")
- (return-type "char*")
+ (return-type "gchar*")
)
(define-method get_etag
(of-object "ChamplainTile")
(c-name "champlain_tile_get_etag")
- (return-type "const-char*")
+ (return-type "const-gchar*")
)
(define-method set_x
(c-name "champlain_tile_set_modified_time")
(return-type "none")
(parameters
- '("GTimeVal*" "time")
+ '("const-GTimeVal*" "time")
)
)
(gpointer)pyuser_data));
}
%%
-override champlain_polygon_append_point kwargs
-static PyObject *
-_wrap_champlain_polygon_append_point(PyGObject *self, PyObject *args)
-{
- double lat, lon;
-
- if (!PyArg_ParseTuple(args, "dd:ChamplainPolygon.append_point", &lat, &lon))
- return NULL;
- champlain_polygon_append_point(CHAMPLAIN_POLYGON(self->obj), lat, lon);
- return Py_BuildValue("(dd)", lat, lon);
-}
-%%
-%%
-override champlain_polygon_insert_point kwargs
-static PyObject *
-_wrap_champlain_polygon_insert_point(PyGObject *self, PyObject *args)
-{
- double lat, lon;
- int pos;
-
- if (!PyArg_ParseTuple(args, "ddi:ChamplainPolygon.insert_point", &lat, &lon, &pos))
- return NULL;
- champlain_polygon_insert_point(CHAMPLAIN_POLYGON(self->obj), lat, lon, pos);
- return Py_BuildValue("(dd)", lat, lon);
-}
-%%
-%%
override champlain_polygon_get_points kwargs
static PyObject *
_wrap_champlain_polygon_get_points(PyGObject *self, PyObject *args)
{
GList *iter, *list = champlain_polygon_get_points(CHAMPLAIN_POLYGON(self->obj));
PyObject *ret = PyList_New(0);
+ PyObject *pypoint;
for(iter = list; iter != NULL; iter = iter->next) {
ChamplainPoint *point = (ChamplainPoint *) iter->data;
- PyObject *item = Py_BuildValue("(dd)", point->lat, point->lon);
- PyList_Append(ret, item);
- Py_DECREF(item);
+ pypoint = pyg_boxed_new(CHAMPLAIN_TYPE_POINT, point, TRUE, TRUE);
+ PyList_Append(ret, pypoint);
+ Py_DECREF(pypoint);
}
return ret;
}
%%
override champlain_view_get_coords_from_event kwargs
static PyObject *
-_wrap_champlain_view_get_coords_from_event(PyGObject *self, PyObject *args)
+_wrap_champlain_view_get_coords_from_event(PyGObject *self, PyObject *args, PyObject *kargs)
{
- double lat, lon;
+ static char *kwlist[] = {"event", NULL};
+ gdouble lat, lon;
PyObject *pyevent;
+ ClutterEvent *event;
- if (!PyArg_ParseTuple(args, "O:ChamplainView.get_coords_from_event", &pyevent))
+ if (!PyArg_ParseTupleAndKeywords(args, kargs, "O:ChamplainView.get_coords_from_event", kwlist, &pyevent))
return NULL;
- ClutterEvent *event = pyg_boxed_get (pyevent, ClutterEvent);
+ if (pyg_boxed_check(pyevent, CLUTTER_TYPE_EVENT))
+ event = pyg_boxed_get(pyevent, ClutterEvent);
+ else {
+ PyErr_SetString(PyExc_TypeError, "event should be a ClutterEvent");
+ return NULL;
+ }
+
champlain_view_get_coords_from_event(CHAMPLAIN_VIEW(self->obj), event, &lat, &lon);
return Py_BuildValue("(dd)", lat, lon);
}
_wrap_champlain_view_get_coords_at(PyGObject *self, PyObject *args)
{
guint x, y;
- double lat, lon;
+ gdouble lat, lon;
if (!PyArg_ParseTuple(args, "ii:ChamplainView.get_coords_at", &x, &y))
return NULL;
#!/usr/bin/env python
+# -*- coding: utf-8 -*-
#This is a demonstration of the libchamplain python binding.
#It will display a blue "pulsating" dot on a given position on the map
#!/usr/bin/env python
+# -*- coding: utf-8 -*-
import cluttergtk
import clutter
import champlain
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
import gobject
import clutter
import champlain
+from markers import create_marker_layer
+
PADDING = 10
def map_view_button_release_cb(actor, event, view):
actor = champlain.View()
actor.set_size(800, 600)
actor.set_property('scroll-mode', champlain.SCROLL_MODE_KINETIC)
- actor.set_property('zoom-level', 12)
actor.center_on(45.466, -73.75)
+ actor.set_property('zoom-level', 12)
# Create the buttons
buttons = clutter.Group()
button.connect('button-release-event', zoom_out, actor)
buttons.add(button)
+ # Create the markers and marker layer
+ layer = create_marker_layer(actor)
+ actor.add_layer(layer)
+
stage = clutter.stage_get_default()
stage.set_size(800, 600)
stage.add(actor)
--- /dev/null
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+import clutter
+import champlain
+import pango
+
+def marker_button_release_cb(actor, event, view):
+ if event.button != 1 and event.click_count > 1:
+ return False
+
+ print "Montreal was clicked\n"
+ return True
+
+
+def create_marker_layer(view):
+ orange = clutter.Color(0xf3, 0x94, 0x07, 0xbb)
+ black = clutter.Color(0x00, 0x00, 0x00, 0xff)
+ layer = champlain.Layer()
+
+ marker = champlain.marker_new_with_text(
+ "Montréal\n<span size=\"xx-small\">Québec</span>", "Serif 14", black,
+ orange)
+ marker.set_use_markup(True)
+ marker.set_alignment(pango.ALIGN_RIGHT)
+ marker.set_color(orange)
+
+ marker.set_position(45.528178, -73.563788)
+ layer.add_marker(marker)
+ marker.set_reactive(True)
+ marker.connect("button-release-event", marker_button_release_cb, view)
+
+ marker = champlain.marker_new_from_file(
+ "/usr/share/icons/gnome/24x24/emblems/emblem-generic.png")
+ marker.set_text("New York")
+ marker.set_position(40.77, -73.98)
+ layer.add_marker(marker)
+
+ marker = champlain.marker_new_from_file(
+ "/usr/share/icons/gnome/24x24/emblems/emblem-important.png")
+ marker.set_position(47.130885, -70.764141)
+ layer.add_marker(marker)
+
+ marker = champlain.marker_new_from_file(
+ "/usr/share/icons/gnome/24x24/emblems/emblem-favorite.png")
+ marker.set_draw_background(False)
+ marker.set_position(45.41484, -71.918907)
+ layer.add_marker(marker)
+
+ layer.show()
+ return layer