From 647f57df67306ed3127d05d706a0e0afc129ab47 Mon Sep 17 00:00:00 2001 From: Michael Sheldon Date: Sat, 28 Feb 2009 00:15:39 +0000 Subject: [PATCH] Make python bindings wrap enums correctly 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 | 2 ++ bindings/python/demos/animated-marker.py | 3 +-- bindings/python/demos/launcher-gtk.py | 21 ++++++++++--------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/bindings/python/champlain/pychamplainmodule.c b/bindings/python/champlain/pychamplainmodule.c index dca998c..5c87cb9 100644 --- a/bindings/python/champlain/pychamplainmodule.c +++ b/bindings/python/champlain/pychamplainmodule.c @@ -3,6 +3,7 @@ #include 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(); diff --git a/bindings/python/demos/animated-marker.py b/bindings/python/demos/animated-marker.py index 2930bb8..e7e218f 100755 --- a/bindings/python/demos/animated-marker.py +++ b/bindings/python/demos/animated-marker.py @@ -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() diff --git a/bindings/python/demos/launcher-gtk.py b/bindings/python/demos/launcher-gtk.py index 67f41d4..e77cfd6 100755 --- a/bindings/python/demos/launcher-gtk.py +++ b/bindings/python/demos/launcher-gtk.py @@ -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) -- 2.39.5