]> err.no Git - libchamplain/commitdiff
Make python bindings wrap enums correctly
authorMichael Sheldon <mike@mikeasoft.com>
Sat, 28 Feb 2009 00:15:39 +0000 (00:15 +0000)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Sun, 1 Mar 2009 20:53:19 +0000 (22:53 +0200)
Update animated-marker.py and launcheer-gtk.py to use enums
Rename "button" to "combo" in launcher-gtk.py for the combobox

bindings/python/champlain/pychamplainmodule.c
bindings/python/demos/animated-marker.py
bindings/python/demos/launcher-gtk.py

index dca998c2b5b2a26507225e48b1b931897e3cc9dd..5c87cb9a1d074ee22e4decf6f93b5034d6cabd20 100644 (file)
@@ -3,6 +3,7 @@
 #include <pygobject.h>
 
 void champlain_register_classes (PyObject *d);
+void champlain_add_constants(PyObject *module, const gchar *strip_prefix);
 DL_EXPORT(void) initchamplain(void);
 extern PyMethodDef champlain_functions[];
 
@@ -17,6 +18,7 @@ initchamplain(void)
        d = PyModule_GetDict (m);
        
        champlain_register_classes (d);
+       champlain_add_constants(m, "CHAMPLAIN_");
        
        if (PyErr_Occurred ()) {
                PyErr_Print();
index 2930bb8500e2ff0a794029c451d796d0aba5f774..e7e218f7d55d2a434f0773b6435b506fec552171 100755 (executable)
@@ -59,7 +59,6 @@ def create_marker():
 
        behaviour = clutter.BehaviourScale(0.5, 0.5, 2.0, 2.0)
        
-       #alpha = clutter_alpha_new_full (timeline, CLUTTER_ALPHA_SINE_INC, NULL, g_object_unref);
        behaviour.set_alpha(alpha)
        behaviour.apply(bg)
 
@@ -96,7 +95,7 @@ def main():
 
        # Finish initialising the map view
        actor.set_property("zoom-level", 5)
-       #actor.set_property("scroll-mode", champlain.SCROLL_MODE_KINETIC)
+       actor.set_property("scroll-mode", champlain.SCROLL_MODE_KINETIC)
   
        actor.center_on(45.466, -73.75)
        stage.show()
index 67f41d49158e5f0c6a09e56d0c99f6288ee75c6e..e77cfd6a5a82c7e9056c7efa4b6e77e6a01a55ec 100755 (executable)
@@ -23,11 +23,11 @@ def zoom_changed(spinbutton, view):
 def map_source_changed(widget, view):
     selection = widget.get_active_text()
     if selection == "Open Street Map":
-        view.set_property("map-source", "openstreetmap")  # champlain.MAP_SOURCE_OPENSTREETMAP)
+        view.set_property("map-source", champlain.MAP_SOURCE_OPENSTREETMAP)
     elif selection == "Open Arial Map":
-        view.set_property("map-source", "openarialmap")  # champlain.MAP_SOURCE_OPENARIALMAP)
+        view.set_property("map-source", champlain.MAP_SOURCE_OPENARIALMAP)
     elif selection == "Maps for free - Relief":
-        view.set_property("map-source", "mapsforfree-relief")  # champlain.MAP_SOURCE_MAPSFORFREE_RELIEF)
+        view.set_property("map-source", champlain.MAP_SOURCE_MAPSFORFREE_RELIEF)
     else:
         raise RuntimeException("Illegal state: active text of combobox invalid")
 
@@ -56,7 +56,7 @@ window.connect("destroy", lambda w: gtk.main_quit)
 vbox = gtk.VBox(False, 12)
 
 view = champlain.View()
-view.set_property("scroll-mode", "kinetic")  # champlain.SCROLL_MODE_KINETIC)
+view.set_property("scroll-mode", champlain.SCROLL_MODE_KINETIC)
 view.set_property("zoom-level", 5)
 
 #layer = create_marker_layer()
@@ -78,12 +78,13 @@ bbox.add(button)
 #button.connect("toggled", toggle_layer, layer)
 #bbox.add(button)
 
-button = gtk.combo_box_new_text()
-button.append_text("Open Street Map")
-button.append_text("Open Arial Map")
-button.append_text("Maps for free - Relief")
-button.connect("changed", map_source_changed, view)
-bbox.add(button)
+combo = gtk.combo_box_new_text()
+combo.append_text("Open Street Map")
+combo.append_text("Open Arial Map")
+combo.append_text("Maps for free - Relief")
+combo.set_active(0)
+combo.connect("changed", map_source_changed, view)
+bbox.add(combo)
 
 button = gtk.SpinButton(gtk.Adjustment(lower=0, upper=20, value=1))
 button.connect("changed", zoom_changed, view)