After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 680638 - Gtk.target_table_new_from_list returns uninitialized list
Gtk.target_table_new_from_list returns uninitialized list
Status: RESOLVED OBSOLETE
Product: pygobject
Classification: Bindings
Component: introspection
3.3.x
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2012-07-26 09:14 UTC by Benny Malengier
Modified: 2013-07-25 01:55 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Benny Malengier 2012-07-26 09:14:44 UTC
Following code does not work as expected. In python log:

>>> a = Gtk.TargetEntry.new(target='test',flags=0,info=0)
>>> a                                 
<GtkTargetEntry at 0x1e42fb0> 
>>> a.target    
'test'                          
>>> b = (a.target, a.flags, a.info)
>>> b                                 
('test', 0L, 0L)                
>>> c = Gtk.TreeView._construct_target_list(Gtk.TreeView(), [b])
>>> c[0].target
'test'
>>> d = Gtk.TargetList.new(c)
>>> d
<GtkTargetList at 0x1eab820>
>>> Gtk.target_table_new_from_list(d)
[<GtkTargetEntry at 0x1a52170>]
>>> e = Gtk.target_table_new_from_list(d)
>>> e[0]
<GtkTargetEntry at 0x201c070>
>>> e[0].target
'\xe0\x0f\x10\x02'
>>> e[0].info
0L
>>> e[0].flags
34262464L

So, it is clear that passing a TargetEntry into a TargetList, then converting to TargetEntry via target_table_new_from_list gives an uninitialized targetentry, see variable e above, instead of the correct one.
This makes it impossible to debug drag and drop issues, as one can only query the targetlist of widgets, not the targetentries.
Comment 1 Benny Malengier 2012-07-26 09:55:29 UTC
Investigating further, I see adding a targetEntry leads to further problems, doing a workaround via Gdk.Atom seems to work though.
In details: 

>>> d.add_text_targets(0L)
>>> d.add_table([a])
>>> e = Gtk.target_table_new_from_list(d)
>>> [x.target for x in e]
['`\xa7\x05\x02', '\xe0\x0f\x10\x02', 'UTF8_STRING', 'COMPOUND_TEXT', 'TEXT', 'STRING', 'text/plain;charset=utf-8', 'text/plain']

So this does not work, targetentry a does not show, while the text targets do show up. We can have the test target appear however by using Gdk Atom as follows:

>>> d.add(Gdk.atom_intern('test', False), 0L,0L)
>>> e = Gtk.target_table_new_from_list(d)
>>> [x.target for x in e]
['`\xa7\x05\x02', '\xe0\x0f\x10\x02', 'UTF8_STRING', 'COMPOUND_TEXT', 'TEXT', 'STRING', 'text/plain;charset=utf-8', 'text/plain', 'test']


So now the test target does show up.
Comment 2 Benny Malengier 2012-07-26 13:46:54 UTC
The error here causes issues in porting Drag and drop to GTK3. I need to convert to use setting calling default methods with empty target list, then use the set_target_list methods like

http://developer.gnome.org/gtk3/stable/gtk3-Drag-and-Drop.html#gtk-drag-dest-set-target-list

to set a correct target list.

For this workaround in our app, see patchset 
http://gramps.svn.sourceforge.net/viewvc/gramps?view=revision&revision=20087

which uses setting target list in source and destination, after which drag and drop works as expected.
Comment 3 Simon Feltman 2013-02-25 05:54:00 UTC
This seems to be working now, please re-open with a new example if this is not the case.

In [1]: from gi.repository import Gtk

In [2]: a = Gtk.TargetEntry.new(target='test',flags=0,info=0)

In [3]: a
Out[3]: <GtkTargetEntry at 0x12cf2b0>

In [4]: a.target
Out[4]: 'test'

In [5]: b = (a.target, a.flags, a.info)

In [6]: b
Out[6]: ('test', 0, 0)

In [7]: c = Gtk._construct_target_list([b])

In [8]: c
Out[8]: [<GtkTargetEntry at 0x12dc620>]

In [9]: c[0].target
Out[9]: 'test'

In [10]: d = Gtk.TargetList.new(c)

In [11]: d
Out[11]: <GtkTargetList at 0x12c5ad0>

In [12]: e = Gtk.target_table_new_from_list(d)

In [13]: e
Out[13]: [<GtkTargetEntry at 0x13b09b0>]

In [14]: e[0].target
Out[14]: 'test'

In [15]: e[0].info
Out[15]: 0

In [16]: e[0].flags
Out[16]: 0

In [17]: d.add_text_targets(0)

In [18]: d.add_table([a])

In [19]: e = Gtk.target_table_new_from_list(d)

In [20]: [x.target for x in e]
Out[20]: 
['test',
 'test',
 'UTF8_STRING',
 'COMPOUND_TEXT',
 'TEXT',
 'STRING',
 'text/plain;charset=utf-8',
 'text/plain']
Comment 4 Germán Poo-Caamaño 2013-07-25 01:26:44 UTC
While I was porting an app I was hit by this bug.  I am using 3.4, I have not tried newer versions yet. IMVHO, this bug should have been closed as OBSOLETE instead of NOTABUG.
Comment 5 Simon Feltman 2013-07-25 01:55:49 UTC
(In reply to comment #4)
> IMVHO, this bug should have been closed as OBSOLETE
> instead of NOTABUG.

Agreed. I will use that next time when closing out old bugs which no longer show up.