[libchamplain] Sync python demos with the main demos
- From: Jiří Techet <jiritechet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain] Sync python demos with the main demos
- Date: Wed, 16 Jun 2010 20:23:18 +0000 (UTC)
commit 9251f477f1f9e1aec019bd46d23c7963b6eff5b1
Author: Victor Godoy Poluceno <victorpoluceno gmail com>
Date: Wed Jun 9 16:56:34 2010 -0300
Sync python demos with the main demos
bindings/python/demos/animated-marker.py | 25 +++++++++++++++++++------
bindings/python/demos/launcher-gtk.py | 23 +++++++++++++++++++++++
bindings/python/demos/launcher.py | 4 ++--
bindings/python/demos/polygons.py | 4 ++--
4 files changed, 46 insertions(+), 10 deletions(-)
---
diff --git a/bindings/python/demos/animated-marker.py b/bindings/python/demos/animated-marker.py
index c20ae1a..24f20b8 100755
--- a/bindings/python/demos/animated-marker.py
+++ b/bindings/python/demos/animated-marker.py
@@ -13,8 +13,7 @@ import gobject
MARKER_SIZE = 10
MARKER_COLOR = [0.1,0.1,0.9,1.0]
-POSITION = [45.528178, -73.563788]
-SCREEN_SIZE = [640, 480]
+SCREEN_SIZE = [800, 600]
class AnimatedMarker(champlain.Marker) :
"""The AnimatedMarker will extend the champlain.Marker class"""
@@ -79,7 +78,19 @@ class AnimatedMarker(champlain.Marker) :
def start_animation(self) :
self.timeline.start()
-
+
+
+lat = 45.466
+lon = -73.75
+
+def gps_callback(view, marker):
+ global lat, lon
+ lat += 0.005
+ lon += 0.005
+ view.center_on(lat, lon)
+ marker.set_position(lat, lon)
+ return True
+
def main() :
gobject.threads_init()
@@ -91,7 +102,7 @@ def main() :
#Starting the animation, that's what we want after all !
marker.start_animation()
#Set marker position on the map
- marker.set_position(*POSITION)
+ marker.set_position(lat, lon)
stage.set_size(*SCREEN_SIZE)
actor.set_size(*SCREEN_SIZE)
@@ -102,9 +113,11 @@ def main() :
layer.add(marker)
# Finish initialising the map view
- actor.set_property("zoom-level", 5)
+ actor.set_property("zoom-level", 12)
actor.set_property("scroll-mode", champlain.SCROLL_MODE_KINETIC)
- actor.center_on(*POSITION)
+ actor.center_on(lat, lon)
+
+ gobject.timeout_add(1000, gps_callback, actor, marker)
stage.show()
diff --git a/bindings/python/demos/launcher-gtk.py b/bindings/python/demos/launcher-gtk.py
index c06d67c..9164796 100755
--- a/bindings/python/demos/launcher-gtk.py
+++ b/bindings/python/demos/launcher-gtk.py
@@ -21,6 +21,13 @@ class LauncherGTK:
embed.set_size_request(640, 480)
self.view = embed.get_view()
+ self.view.set_reactive(True)
+ self.view.connect('button-release-event', self.mouse_click_cb, self.view)
+
+ self.view.set_property('scroll-mode', champlain.SCROLL_MODE_KINETIC)
+ self.view.set_property('zoom-level', 5)
+ self.view.set_property('license-text', "Don't eat cereals with orange juice\nIt tastes bad")
+ self.view.set_property('show-scale', True)
self.layer = create_marker_layer(self.view)
self.view.add_layer(self.layer)
@@ -75,6 +82,10 @@ class LauncherGTK:
self.spinbutton.set_value(5)
bbox.add(self.spinbutton)
+ button = gtk.Image()
+ self.view.connect("notify::state", self.view_state_changed, button)
+ bbox.pack_end(button, False, False, 0)
+
vbox.pack_start(bbox, expand=False, fill=False)
vbox.add(embed)
@@ -97,6 +108,11 @@ class LauncherGTK:
self.polygon.hide()
self.layer.animate_out_all_markers()
+ def mouse_click_cb(self, actor, event, view):
+ lat, lon = view.get_coords_from_event(event)
+ print "Mouse click at: %f %f" % (lat, lon)
+ return True
+
def zoom_changed(self, widget):
self.view.set_property("zoom-level", self.spinbutton.get_value_as_int())
@@ -110,6 +126,13 @@ class LauncherGTK:
def map_zoom_changed(self, widget, value):
self.spinbutton.set_value(self.view.get_property("zoom-level"))
+ def view_state_changed(self, view, paramspec, image):
+ state = view.get_property("state")
+ if state == champlain.STATE_LOADING:
+ image.set_from_stock(gtk.STOCK_NETWORK, gtk.ICON_SIZE_BUTTON)
+ else:
+ image.clear()
+
if __name__ == "__main__":
gobject.threads_init()
diff --git a/bindings/python/demos/launcher.py b/bindings/python/demos/launcher.py
index bde4a46..912b556 100755
--- a/bindings/python/demos/launcher.py
+++ b/bindings/python/demos/launcher.py
@@ -44,7 +44,7 @@ def make_button(text):
def main():
# Create the map view
actor = champlain.View()
- actor.set_size(640, 480)
+ actor.set_size(800, 600)
actor.set_property('scroll-mode', champlain.SCROLL_MODE_KINETIC)
actor.center_on(45.466, -73.75)
actor.set_property('zoom-level', 12)
@@ -73,7 +73,7 @@ def main():
actor.add_layer(layer)
stage = clutter.Stage(default=True)
- stage.set_size(640, 480)
+ stage.set_size(800, 600)
stage.add(actor)
stage.add(buttons)
stage.show()
diff --git a/bindings/python/demos/polygons.py b/bindings/python/demos/polygons.py
index 3cce675..787b242 100755
--- a/bindings/python/demos/polygons.py
+++ b/bindings/python/demos/polygons.py
@@ -42,7 +42,7 @@ def make_button(text):
def main():
# Create the map view
actor = champlain.View()
- actor.set_size(640, 480)
+ actor.set_size(800, 600)
actor.set_property('scroll-mode', champlain.SCROLL_MODE_KINETIC)
actor.set_property('zoom-level', 9)
@@ -66,7 +66,7 @@ def main():
buttons.add(button)
stage = clutter.Stage(default=True)
- stage.set_size(640, 480)
+ stage.set_size(800, 600)
stage.add(actor)
stage.add(buttons)
stage.show()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]