gBroutin / gstreamer-java

Automatically exported from code.google.com/p/gstreamer-java
0 stars 0 forks source link

extend GObject: add possibility to list properties #116

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Add functionality which original GObject has.

I propose next changes.

Add one line to GObjectAPI interface:
    Pointer g_object_class_list_properties(Pointer oclass, IntByReference size); 

Add two methods to GObject implementation:
    public List<String> listPropertyNames() {
        GObjectAPI.GParamSpec[] lst = listProperties();
        List<String> result = new ArrayList<String>(lst.length);
        for (int i = 0; i < lst.length; i++) {
            result.add(lst[i].g_name);
        }
        return result; 
    }
    private GObjectAPI.GParamSpec[] listProperties() {
        IntByReference len = new IntByReference();
        Pointer ptrs = GOBJECT_API.g_object_class_list_properties(handle().getPointer(0), len);
        if (ptrs == null)
            return null;

        GParamSpec[] props = new GParamSpec[len.getValue()];
        int offset = 0;
        for (int i = 0; i < len.getValue(); i++) {
            props[i] = new GObjectAPI.GParamSpec(ptrs.getPointer(offset));
            offset += Pointer.SIZE;
        }
        return props;
    }

I have checked this code - it works for me.

Original issue reported on code.google.com by igor.laz...@gmail.com on 20 Nov 2012 at 2:49

GoogleCodeExporter commented 8 years ago
thnaks.
r580.

Original comment by lfar...@lfarkas.org on 26 Nov 2012 at 12:10