]> err.no Git - libchamplain/commitdiff
Update python bindings to support new ChamplainMapSourceDesc API
authorMike Sheldon <mike@mikeasoft.com>
Tue, 5 May 2009 13:32:02 +0000 (14:32 +0100)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Tue, 5 May 2009 20:32:33 +0000 (16:32 -0400)
Update launcher-gtk.py example to use new ChamplainMapSourceDesc API

bindings/python/champlain/pychamplain.defs
bindings/python/champlain/pychamplain.override
bindings/python/demos/launcher-gtk.py
bindings/python/update-binding.sh

index e10dfa60f9ee2ae0c3b9ba144bdec99a7ba4109e..50de7d896ac00063ac559c8b91fbd9fb3cfe8dfa 100644 (file)
 
 
 
+;; From champlain-map-source-desc.h
+
+
+
 ;; From champlain-map-source-factory.h
 
 (define-function map_source_factory_get_type
 (define-method get_list
   (of-object "ChamplainMapSourceFactory")
   (c-name "champlain_map_source_factory_get_list")
-  (return-type "gchar**")
+  (return-type "GSList*")
 )
 
 (define-method create
   (c-name "champlain_map_source_factory_register")
   (return-type "gboolean")
   (parameters
-    '("const-gchar*" "id")
-    '("ChamplainMapSourceConstructor" "callback")
+    '("ChamplainMapSourceDesc*" "desc")
   )
 )
 
index ee6388a5ed5e78145f9b6fa4c967fed992235ea4..c2eb25dfcb590bb1922fad76e5e73f63e672b569 100644 (file)
@@ -23,25 +23,25 @@ ignore
 override champlain_map_source_factory_get_list kwargs
 static PyObject *
 _wrap_champlain_map_source_factory_get_list(PyGObject *self) {
-       gchar **list;
-       gchar *item;
+       GSList *iter, *list;
        PyObject *ret;
-       int i = 0;
 
        list = champlain_map_source_factory_get_list(CHAMPLAIN_MAP_SOURCE_FACTORY(self->obj));
        
        ret = PyList_New(0);
-       item = list[i];
-       while (item != NULL) {
-               PyList_Append (ret, PyString_FromString(item));
-               item = list[++i];
+       for(iter = list; iter != NULL; iter = iter->next) {
+               PyObject *item = PyDict_New();
+               ChamplainMapSourceDesc *desc = (ChamplainMapSourceDesc *) iter->data;
+               PyDict_SetItemString(item, "id", PyString_FromString(desc->id));
+               PyDict_SetItemString(item, "name", PyString_FromString(desc->name));
+               PyDict_SetItemString(item, "license", PyString_FromString(desc->license));
+               PyDict_SetItemString(item, "license_uri", PyString_FromString(desc->license_uri));
+               PyDict_SetItemString(item, "min_zoom_level", PyInt_FromLong(desc->min_zoom_level));
+               PyDict_SetItemString(item, "max_zoom_level", PyInt_FromLong(desc->max_zoom_level));
+               PyList_Append(ret, item);
+               Py_DECREF(item);
        }
 
-       if (!list) {
-               Py_INCREF (Py_None);
-               return Py_None;
-       }
-       
        return ret;
 }
 %%
index 8c6d266a5daeaf2f2db854f0ea48e76ff819b041..6728eed45bf367f4c369239c0c73b06406294b1e 100755 (executable)
@@ -43,8 +43,12 @@ class LauncherGTK:
 
                combo = gtk.combo_box_new_text()
                self.map_source_factory = champlain.map_source_factory_get_default()
+               liststore = gtk.ListStore(str, str)
                for source in self.map_source_factory.get_list():
-                       combo.append_text(source)
+                       liststore.append([source["id"], source["name"]])
+                       combo.append_text(source["name"])
+               combo.set_model(liststore)
+               combo.set_attributes(combo.get_cells()[0], text=1)
                combo.set_active(0)
                combo.connect("changed", self.map_source_changed)
                bbox.add(combo)
@@ -86,8 +90,10 @@ class LauncherGTK:
                self.view.set_property("zoom-level", self.spinbutton.get_value_as_int())
 
        def map_source_changed(self, widget):
-               selection = widget.get_active_text()
-               source = self.map_source_factory.create(selection);
+               model = widget.get_model()
+               iter = widget.get_active_iter()
+               id = model.get_value(iter, 0)
+               source = self.map_source_factory.create(id);
                self.view.set_property("map-source", source)
 
        def map_zoom_changed(self, widget, value):
index fd2d1435c089b99499aa78768ab559a615bd541f..0e79f2be00385ed3f8a7788b400306cbc7024f3e 100755 (executable)
@@ -11,6 +11,7 @@ python /usr/share/pygobject/2.0/codegen/h2def.py      \
        champlain-defines.h                     \
        champlain-layer.h                       \
        champlain-map-source.h                  \
+       champlain-map-source-desc.h             \
        champlain-map-source-factory.h          \
        champlain-network-map-source.h          \
        champlain-marker.h                      \