[libchamplain] Minor changes/cleanups in Python demos
- From: JiÅÃ Techet <jiritechet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain] Minor changes/cleanups in Python demos
- Date: Thu, 29 Dec 2011 15:30:10 +0000 (UTC)
commit 1bad8a82437847a9461f761f6187c9ff7f487b56
Author: JiÅÃ Techet <techet gmail com>
Date: Wed Dec 28 23:44:08 2011 +0100
Minor changes/cleanups in Python demos
.gitignore | 1 +
demos/icons/emblem-new.png | Bin 0 -> 1165 bytes
demos/launcher-gtk.py | 37 +++++++++++++++----------------------
demos/markers.py | 9 ++++-----
4 files changed, 20 insertions(+), 27 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index fd9de7e..9d21a1f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,6 +14,7 @@ autom4te.cache
*.gi
*~
*.sw?
+*.pyc
champlain-gtk/champlain-gtk-marshal.c
champlain-gtk/champlain-gtk-marshal.h
champlain-gtk/stamp-marshal
diff --git a/demos/icons/emblem-new.png b/demos/icons/emblem-new.png
new file mode 100644
index 0000000..28eb75f
Binary files /dev/null and b/demos/icons/emblem-new.png differ
diff --git a/demos/launcher-gtk.py b/demos/launcher-gtk.py
old mode 100644
new mode 100755
index a68f3f6..36f06c7
--- a/demos/launcher-gtk.py
+++ b/demos/launcher-gtk.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import sys
from gi.repository import GtkClutter, Clutter
GtkClutter.init([]) # Must be initialized before importing those:
@@ -45,24 +44,15 @@ class LauncherGTK:
self.path_layer = Champlain.PathLayer()
# Cheap approx of Highway 10
- self.path_layer.add_node(Champlain.Coordinate.new_full(45.4095,
- -73.3197))
- self.path_layer.add_node(Champlain.Coordinate.new_full(45.4104,
- -73.2846))
- self.path_layer.add_node(Champlain.Coordinate.new_full(45.4178,
- -73.2239))
- self.path_layer.add_node(Champlain.Coordinate.new_full(45.4176,
- -73.2181))
- self.path_layer.add_node(Champlain.Coordinate.new_full(45.4151,
- -73.2126))
- self.path_layer.add_node(Champlain.Coordinate.new_full(45.4016,
- -73.1926))
- self.path_layer.add_node(Champlain.Coordinate.new_full(45.3994,
- -73.1877))
- self.path_layer.add_node(Champlain.Coordinate.new_full(45.4000,
- -73.1815))
- self.path_layer.add_node(Champlain.Coordinate.new_full(45.4151,
- -73.1218))
+ self.add_node(self.path_layer, 45.4095, -73.3197)
+ self.add_node(self.path_layer, 45.4104, -73.2846)
+ self.add_node(self.path_layer, 45.4178, -73.2239)
+ self.add_node(self.path_layer, 45.4176, -73.2181)
+ self.add_node(self.path_layer, 45.4151, -73.2126)
+ self.add_node(self.path_layer, 45.4016, -73.1926)
+ self.add_node(self.path_layer, 45.3994, -73.1877)
+ self.add_node(self.path_layer, 45.4000, -73.1815)
+ self.add_node(self.path_layer, 45.4151, -73.1218)
self.view.add_layer(self.path_layer)
embed.set_size_request(640, 480)
@@ -110,6 +100,10 @@ class LauncherGTK:
self.window.add(vbox)
self.window.show_all()
+
+ def add_node(self, path_layer, lat, lon):
+ coord = Champlain.Coordinate.new_full(lat, lon)
+ path_layer.add_node(coord)
def zoom_in(self, widget):
self.view.zoom_in()
@@ -140,14 +134,13 @@ class LauncherGTK:
id = model.get_value(iter, 0)
map_source_factory = Champlain.MapSourceFactory.dup_default()
source = map_source_factory.create_cached_source(id);
- # Crashes
- #self.view.set_property("map-source", source)
+ self.view.set_property("map-source", source)
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")
+ state = view.get_state()
if state == Champlain.State.LOADING:
image.set_from_stock(Gtk.STOCK_NETWORK, Gtk.IconSize.BUTTON)
else:
diff --git a/demos/markers.py b/demos/markers.py
index 271c701..25036b0 100644
--- a/demos/markers.py
+++ b/demos/markers.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
from gi.repository import Clutter
from gi.repository import Champlain
@@ -29,24 +28,24 @@ def create_marker_layer(view):
marker.connect("button-release-event", marker_button_release_cb, view)
marker = Champlain.Label.new_from_file(
- "/usr/share/icons/gnome/24x24/emblems/emblem-generic.png")
+ "icons/emblem-generic.png")
marker.set_text("New York")
marker.set_location(40.77, -73.98)
layer.add_marker(marker)
marker = Champlain.Label.new_from_file(
- "/usr/share/icons/gnome/24x24/emblems/emblem-important.png")
+ "icons/emblem-important.png")
marker.set_location(47.130885, -70.764141)
layer.add_marker(marker)
marker = Champlain.Label.new_from_file(
- "/usr/share/icons/gnome/24x24/emblems/emblem-favorite.png")
+ "icons/emblem-favorite.png")
marker.set_draw_background(False)
marker.set_location(45.41484, -71.918907)
layer.add_marker(marker)
marker = Champlain.Label.new_from_file(
- "/usr/share/icons/gnome/24x24/emblems/emblem-new.png")
+ "icons/emblem-new.png")
marker.set_draw_background(False)
marker.set_location(50.639663, 5.570798)
layer.add_marker(marker)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]