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 58400 - drag/drop text fails without STRING target
drag/drop text fails without STRING target
Status: RESOLVED DUPLICATE of bug 55117
Product: gtk+
Classification: Platform
Component: Widget: Other
1.3.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2001-08-01 16:05 UTC by Skip Montanaro
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Skip Montanaro 2001-08-01 16:05:36 UTC
I asked about this on the gtk-list but got no responses responses that
would indicate why a 'STRING' target is required when dragging text between
two Gtk widgets in the same app.  I believe it may be a bug in Gtk 1.3.x
drag-n-drop, so file it here.

The following simple Python script demonstrates that a drag-and-drop
target of STRING is always needed when copying text between two widgets.
A 'text/plain' target will not work.  If you run this script and set fail
to 0 it will work.  If you set fail to 1 it will not.  The only difference
is that in the failure case only a 'text/plain' target is given.  In the
non-failure case, only a 'STRING' target is given.  It will also fail if
you define the targets list to have both 'STRING' and 'text/plain'
targets, but make the 'text/plain' target higher priority than the 
'STRING' target.

--
Skip Montanaro
skip@pobox.com


#!/usr/bin/env python

import sys
import gtk

fail = 0

def main():
    win = gtk.GtkWindow()
    win.connect('destroy', gtk.mainquit)
    table = gtk.GtkTable(2,2, gtk.TRUE)
    win.add(table)

    if fail:
        targets = [('text/plain', 0, 0)]
    else:
        targets = [('STRING', 0, 0)]

    b = gtk.GtkEntry()
    b.set_text("drag me ...")
    b.set_name("entry source")
    b.drag_source_set(gtk.GDK.BUTTON1_MASK,
                      targets,
                      (gtk.GDK.ACTION_DEFAULT|
                       gtk.GDK.ACTION_COPY))
    establish_notify(b)
    table.attach(b, 0, 1, 0, 1)
    
    b = gtk.GtkEntry()
    b.set_text('... here ...')
    b.set_name("entry dest")
    b.drag_dest_set(gtk.GTK.DEST_DEFAULT_ALL,
                    targets,
                    (gtk.GDK.ACTION_DEFAULT|
                     gtk.GDK.ACTION_COPY))
    establish_notify(b)
    table.attach(b, 1, 2, 0, 1)

    b = gtk.GtkButton(label='Quit')
    b.connect("clicked", gtk.mainquit)
    b.set_name("quit button")
    table.attach(b, 0, 2, 1, 2)

    win.show_all()
    gtk.mainloop()
    
def establish_notify(w):
    for signal in ["drag-begin","drag-data-delete","drag-data-get",
                   "drag-data-received","drag-drop","drag-end",
                   "drag-leave","drag-motion"]:
        w.connect(signal, note_signal, signal)

last_signal = ""
def note_signal(w, context, *args):
    global last_signal
    
    sig = (w.get_name(), args[-1])
    if sig == last_signal:
        sys.stdout.write(".")
        sys.stdout.flush()
    else:
        sys.stdout.write("\n%s" % (sig,))
        sys.stdout.flush()
        last_signal = sig
    if args[-1] == "drag-end":
        sys.stdout.write("\n")

    return gtk.FALSE

if __name__ == '__main__':
    main()
Comment 1 Owen Taylor 2001-08-02 03:48:18 UTC
Note that changing the target lists for GtkEntry is almost
certain to break things. GtkEntry supports DND out of the
box. Changing the target lists behind GtkEntry's back
is almost certainly going to result in flames and death.

The text/plain problem is a dup of #55117

*** This bug has been marked as a duplicate of 55117 ***