Both this patch and the latest version's gtk.py file
call the function  _gtk.gtk_tree_item_get_subtree to
access the item's subtree.  Where is this function
defined/generated?  I see a "set_subtree" gtk function,
but the 'get' operation seems to be provided by the
GTK_TREE_ITEM_SUBTREE(item) macro.

Am I totally daft, or is the wrapper trying to access a
function that doesn't exist?

Regards,
Mike

----- Original Message -----
From: John Ehresman <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, December 09, 1999 1:15 PM
Subject: [pygtk] Patches for GtkTreeItem.subtree


>
> Hi,
>
> I encountered problems when I tried to access the subtree attribute of
> a GtkItem instance.  I think I've solved them (I solved my immediate
> problems, at least) by making several changes to pygtk.  I've attached
> diffs for gtk.py and generate/generate.py made against the pygtk 0.6.3
> distribution. The changes are:
>
> * A typo corrected in GtkTreeItem.__getattr__ and a wrapper around
>   _gtk.gtk_tree_item_get_subtree to convert the C extension object ref to
>   a Python class instance.
> * Modified generate.py to emit C code to check for a NULL GtkObject when
>   returning a field of the GtkObject.  If NULL is found, a reference to
>   the Python None object is returned.
> * Modified _obj2inst in gtk.py to return None if the input argument is
>   None.
>
> With these changes, the subtree attribute will be None if the item does
> not have a subtree, and a GtkTree instance if it does.
>
> Thanks to all the people who have contributed to pygtk, especially James
> Henstridge.
>
> John
>
> diff -c for gtk.py
> *** gtk.py Fri Dec  3 15:32:24 1999
> --- /home/jpe/down/pygtk-0.6.3/gtk.py Thu Sep 30 01:33:14 1999
> ***************
> *** 782,791 ****
>   self._o = _gtk.gtk_tree_item_new_with_label(label)
>   def __getattr__(self, attr):
>   attrs = {
> ! 'subtree': (lambda o:
> !                            _obj2inst(_gtk.gtk_tree_item_get_subtree(o)))
>   }
> ! if attrs.has_key(attr):
>   return attrs[attr](self._o)
>   return GtkItem.__getattr__(self, attr)
>   def set_subtree(self, subtree):
> --- 782,790 ----
>   self._o = _gtk.gtk_tree_item_new_with_label(label)
>   def __getattr__(self, attr):
>   attrs = {
> ! 'subtree': _gtk.gtk_tree_item_get_subtree,
>   }
> ! if attrs.has_key(attrs):
>   return attrs[attr](self._o)
>   return GtkItem.__getattr__(self, attr)
>   def set_subtree(self, subtree):
> ***************
> *** 2484,2491 ****
>   _gtk.gtk_accel_group_remove(self._ag, key, mods, obj._o)
>
>   def _obj2inst(obj):
> - if obj == None:
> - return None
>   objname = _gtk.gtk_type_name(_gtk.GTK_OBJECT_TYPE(obj))
>   if _name2cls.has_key(objname):
>   return _name2cls[objname](_obj=obj)
> --- 2483,2488 ----
>
> diff -c for generate/generate.py:
> *** generate/generate.py        Fri Dec  3 15:24:46 1999
> --- /home/jpe/down/pygtk-0.6.3/generate/generate.py     Thu Sep 30
> 01:33:15 1999
> ***************
> *** 421,435 ****
>                         impl.write(funcCall)
>                         impl.write(');\n')
>                 elif retType in objects.keys():
> !                       impl.write('    {\n')
> !                       impl.write('        GtkObject* _o = (GtkObject*)')
> !                       impl.write(funcCall)
> !                       impl.write(';\n')
> !                       impl.write('        if ( _o != NULL )\n')
> !                       impl.write('            return PyGtk_New(_o);\n')
> !                       impl.write('        Py_INCREF(Py_None);\n')
> !                       impl.write('        return Py_None;\n')
> !                       impl.write('    }\n')
>                 else:
>                         print "%s: unknown return type '%s'" % (name,
retType)
>                         return 1
> --- 421,429 ----
>                         impl.write(funcCall)
>                         impl.write(');\n')
>                 elif retType in objects.keys():
> !                       impl.write('    return PyGtk_New((GtkObject *)')
> !                       impl.write(funcCall)
> !                       impl.write(');\n')
>                 else:
>                         print "%s: unknown return type '%s'" % (name,
retType)
>                         return 1
>
>
>
>
>
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
>

To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]

Reply via email to