Re: [pygtk] gtk_clipboard_set_with_data: (skip)

2011-08-30 Thread Tomeu Vizoso
On Fri, Jul 1, 2011 at 14:25, Pavel Holejsovsky
pavel.holejsov...@gmail.com wrote:
 Hi Giuseppe,

 On 7/1/2011 10:21 AM, Giuseppe Penone wrote:

 I'm a GTK+ developer that used to work in pygtk2 and now ported the code
 to pygobject introspection.
 For my (GPL) application http://giuspen.com/cherrytree I absolutely need
 the function gtk_clipboard_set_with_data
 that I see you marhed as NON introspectable.
 I wanted to ask you that function will ever be binded/what alternative
 should I use instead.

 I marked the function as (skip) because AFAIK current version of
 gobject-introspection really can't handle it; the reason is that this
 function shares single user_data field for 2 closures (get_func and
 clear_func), and this is not supported.

 In order to be supported by current introspection, a new function would have
 to be added into GTK, which has one user_data for each callback.

I think best would be to add a bindable alternative that accepts 2
GClosure arguments. Then bindings can just marshall those and not try
to do complex stuff with several user_datas, GDestroyNotify, etc.

Plus, if we keep the supported arguments simpler, we can give better
error messages when people pass an incorrect number or types of
arguments.

See the patch in https://bugzilla.gnome.org/review?bug=621092 for an
example of how to do this.

 An alternate solution is to provide some 'manual binding', i.e. binding this
 function directly, not through introspection.  Sorry, I'm not involved with
 python so I'm not sure how it works.  Maybe asking at
 irc://irc.gnome.org/python could help?

Right now we don't carry C extensions to Gtk+ and I hope we don't try
to. All the functionality in Gtk+ is supposed to be accessible through
bindable APIs, so it's there where we have to fix these.

Regards,

Tomeu

 Sorry that I cannot be more helpful,
 Pavel
 ___
 pygtk mailing list   pygtk@daa.com.au
 http://www.daa.com.au/mailman/listinfo/pygtk
 Read the PyGTK FAQ: http://faq.pygtk.org/

___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


Re: [pygtk] gtk_clipboard_set_with_data: (skip)

2011-08-29 Thread Pavel Holejsovsky

Hi Giuseppe,

On 7/1/2011 10:21 AM, Giuseppe Penone wrote:

I'm a GTK+ developer that used to work in pygtk2 and now ported the code
to pygobject introspection.
For my (GPL) application http://giuspen.com/cherrytree I absolutely need
the function gtk_clipboard_set_with_data
that I see you marhed as NON introspectable.
I wanted to ask you that function will ever be binded/what alternative
should I use instead.


I marked the function as (skip) because AFAIK current version of 
gobject-introspection really can't handle it; the reason is that this 
function shares single user_data field for 2 closures (get_func and 
clear_func), and this is not supported.


In order to be supported by current introspection, a new function would 
have to be added into GTK, which has one user_data for each callback.


An alternate solution is to provide some 'manual binding', i.e. binding 
this function directly, not through introspection.  Sorry, I'm not 
involved with python so I'm not sure how it works.  Maybe asking at 
irc://irc.gnome.org/python could help?


Sorry that I cannot be more helpful,
Pavel
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


Re: [pygtk] gtk_clipboard_set_with_data: (skip)

2011-07-02 Thread Giuseppe Penone
Hello Hart,
I know ctypes because I use them to wrap some xlib functionalities.
I will try this rpythonic wrapper.
Thank you for the tip,
best regards,
Giuseppe.


On Sat, Jul 2, 2011 at 03:33, Hart's Antler bhart...@yahoo.com wrote:

 Hi Giuseppe,
 Did you already know about the generated ctypes bindings to gtk?  It
 already supports gtk_clipboard_set_with_data.

 gtk_clipboard_set_with_data = _rpythonic_function_( 
 gtk_clipboard_set_with_data,
 ctypes.c_int, [
 (clipboard, ctypes.POINTER(_GtkClipboard)),
 (targets, ctypes.POINTER(_GtkTargetEntry)),
 (n_targets, ctypes.c_uint),
 (get_func, ctypes.CFUNCTYPE(ctypes.c_void_p,
 ctypes.POINTER(_GtkClipboard),ctypes.POINTER(_GtkSelectionData),ctypes.c_uint,ctypes.POINTER(ctypes.c_void_p),)),
 (clear_func, ctypes.CFUNCTYPE(ctypes.c_void_p,
 ctypes.POINTER(_GtkClipboard),ctypes.POINTER(ctypes.c_void_p),)),
 (user_data, ctypes.POINTER(ctypes.c_void_p)),] )


 I know no one is interested in using gtk with a ctypes like API, that's too
 low level.  To make things easy and more like the original pygtk, an object
 oriented API is also generated ontop of the low level ctypes API.  It here's
 a usage example:


 import os,sys, time
 if '..' not in sys.path: sys.path.append( '..' )
 import rpythonic
 gtk = rpythonic.module( 'gtk' )
 assert gtk
 gtk.init()
 win = gtk.window_new( gtk.GTK_WINDOW_TOPLEVEL )
 win.set_title('hello world')
 win.set_default_size( 320, 240 )
 def exit(*args): gtk.main_quit()
 win.connect( 'destroy', exit )
 frame = gtk.frame_new('hello world')
 win.add( frame )
 button = gtk.button_new_with_label(test)
 frame.add( button )
 def callback(*args): print('python callback')
 button.connect( 'clicked', callback )
 win.show_all()
 gtk.main()


 The latest ctypes gtk is precached in
 RPythonic/rpythonic/cache/genctypes/gtk
 http://rpythonic.googlecode.com/files/RPythonic-0.3.7.tar.bz2

 by the way, there is also a precached version for gtk3.
 -hart

 --- On *Fri, 7/1/11, Giuseppe Penone gius...@gmail.com* wrote:


 From: Giuseppe Penone gius...@gmail.com
 Subject: [pygtk] gtk_clipboard_set_with_data: (skip)
 To: phol...@src.gnome.org
 Cc: pygtk pygtk@daa.com.au
 Date: Friday, 1 July, 2011, 1:21 AM


 Hi Pavel,

 I'm a GTK+ developer that used to work in pygtk2 and now ported the code to
 pygobject introspection.
 For my (GPL) application http://giuspen.com/cherrytree I absolutely need
 the function gtk_clipboard_set_with_data
 that I see you marhed as NON introspectable.
 I wanted to ask you that function will ever be binded/what alternative
 should I use instead.

 Thank you and best regards,
 Giuseppe.

 -Inline Attachment Follows-

 ___
 pygtk mailing list   pygtk@daa.com.auhttp://mc/compose?to=pygtk@daa.com.au
 http://www.daa.com.au/mailman/listinfo/pygtk
 Read the PyGTK FAQ: http://faq.pygtk.org/


___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Re: [pygtk] gtk_clipboard_set_with_data: (skip)

2011-07-01 Thread Hart's Antler
Hi Giuseppe, Did you already know about the generated ctypes bindings to gtk?  
It already supports gtk_clipboard_set_with_data.
gtk_clipboard_set_with_data = _rpythonic_function_( 
gtk_clipboard_set_with_data, ctypes.c_int, [  (clipboard,   
ctypes.POINTER(_GtkClipboard)), (targets, 
ctypes.POINTER(_GtkTargetEntry)),   (n_targets,   ctypes.c_uint), 
(get_func,ctypes.CFUNCTYPE(ctypes.c_void_p, 
ctypes.POINTER(_GtkClipboard),ctypes.POINTER(_GtkSelectionData),ctypes.c_uint,ctypes.POINTER(ctypes.c_void_p),)),
 (clear_func,  ctypes.CFUNCTYPE(ctypes.c_void_p, 
ctypes.POINTER(_GtkClipboard),ctypes.POINTER(ctypes.c_void_p),)), 
(user_data,   ctypes.POINTER(ctypes.c_void_p)),] )

I know no one is interested in using gtk with a ctypes like API, that's too low 
level.  To make things easy and more like the original pygtk, an object 
oriented API is also generated ontop of the low level ctypes API.  It here's 
a usage example:

import os,sys, timeif '..' not in sys.path: sys.path.append( '..' )import 
rpythonicgtk = rpythonic.module( 'gtk' )assert gtkgtk.init()win = 
gtk.window_new( gtk.GTK_WINDOW_TOPLEVEL )win.set_title('hello 
world')win.set_default_size( 320, 240 )def exit(*args): 
gtk.main_quit()win.connect( 'destroy', exit )frame = gtk.frame_new('hello 
world')win.add( frame )button = gtk.button_new_with_label(test)frame.add( 
button )def callback(*args): print('python callback')button.connect( 'clicked', 
callback )win.show_all()gtk.main()

The latest ctypes gtk is precached in 
RPythonic/rpythonic/cache/genctypes/gtkhttp://rpythonic.googlecode.com/files/RPythonic-0.3.7.tar.bz2
by the way, there is also a precached version for gtk3.-hart
--- On Fri, 7/1/11, Giuseppe Penone gius...@gmail.com wrote:

From: Giuseppe Penone gius...@gmail.com
Subject: [pygtk] gtk_clipboard_set_with_data: (skip)
To: phol...@src.gnome.org
Cc: pygtk pygtk@daa.com.au
Date: Friday, 1 July, 2011, 1:21 AM

Hi Pavel,

I'm a GTK+ developer that used to work in pygtk2 and now ported the code to 
pygobject introspection.
For my (GPL) application http://giuspen.com/cherrytree I absolutely need the 
function gtk_clipboard_set_with_data



that I see you marhed as NON introspectable.
I wanted to ask you that function will ever be binded/what alternative should I 
use instead.

Thank you and best regards,
Giuseppe.


-Inline Attachment Follows-

___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/