GTK3 DND-Function don't except files

Hi,

up to now I worked with the following dnd function. It worked very well, I could drop files and http-adresses from browser.

Now I changed to Linux mint 19.2, dnd with files will not work anymore.

Unfortunately the dnd function aren't well described.

UH

def create_drop_space cb
cb.drag_dest_set( Gtk::DestDefaults::ALL, [['text/plain', 0, 0]], Gdk::DragAction::COPY)
cb.signal_connect('drag_data_received') do |w, context, x, y, data, info, time|
#Encoding.default_internal
type=data.text[0..4] # what is dropped ?
path=data.text[0..data.text.length] # length of dropped
aS=data.data
kwords=cb.active_iter[0].split(',')
save_dnd_data data, kwords
end

end

Hi,

Could you show runnable script instead of snippet?

Thanks,

···

--
kou

In <d1aa0074-4c07-c7f8-4d56-06878d8df435@unitybox.de>
  "GTK3 DND-Function don't except files" on Sat, 28 Sep 2019 08:58:21 +0200,
  ulli bei Unity <upahermann@unitybox.de> wrote:

Hi,

up to now I worked with the following dnd function. It worked very
well, I could drop files and http-adresses from browser.

Now I changed to Linux mint 19.2, dnd with files will not work
anymore.

Unfortunately the dnd function aren't well described.

UH

def create_drop_space cb
cb.drag_dest_set( Gtk::DestDefaults::ALL, [['text/plain', 0, 0]],
Gdk::DragAction::COPY)
cb.signal_connect('drag_data_received') do |w, context, x, y,
data, info, time|
#Encoding.default_internal
type=data.text[0..4] # what is dropped ?
path=data.text[0..data.text.length] # length of dropped
aS=data.data
kwords=cb.active_iter[0].split(',')
save_dnd_data data, kwords
end

end

Hi

Hi,

up to now I worked with the following dnd function. It worked very well,
I could drop files and http-adresses from browser.

Now I changed to Linux mint 19.2, dnd with files will not work anymore.

Unfortunately the dnd function aren't well described.

UH

def create_drop_space cb
cb.drag_dest_set( Gtk::DestDefaults::ALL, [['text/plain', 0, 0]],
Gdk::DragAction::COPY)

you should add

     cb.drag_dest_add_uri_targets

here, to also get URIs, which are used for file dropping.

 cb\.signal\_connect\(&#39;drag\_data\_received&#39;\) do |w, context, x, y, data,

info, time|
#Encoding.default_internal
type=data.text[0..4] # what is dropped ?
path=data.text[0..data.text.length] # length of dropped
aS=data.data
kwords=cb.active_iter[0].split(',')
save_dnd_data data, kwords

you should finalize the drag action with

        Gdk.drop_finish context, true, time

If you do not finish the drop action correctly, you may get unexpected
results. Sometimes it is seen as the drag-image flying back from the
drop point to the drag point

Hope it helps, cheers detlef

···

Am 28.09.19 um 08:58 schrieb ulli bei Unity:

 end

end

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>

Hi,

enclosed the snippet. I use ruby-gtk3 3.2.4-1 now.
With ruby-gtk3 2.2.5 all files would be accepted (pdf,txt, images).
Now only url from browser.

Regards
UH

···

#---------------------------------------------------------------------------------------------------------------------------
#!/usr/bin/env ruby

require "gtk3"
require "pry"

def create_drop_space cb
cb.drag_dest_set( Gtk::DestDefaults::ALL, [['text/plain', 0, 0]], Gdk::DragAction::COPY)
cb.signal_connect('drag_data_received') do |w, context, x, y, data, info, time|
#Encoding.default_internal
type=data.text[0..4] # what is dropped ?
path=data.text[0..data.text.length] # length of dropped
p "i got it"
save_dnd_data data
end

end

# in the db and update the pathtree
def save_dnd_data data
type=data.text[0..4] # what is dropped ?
path=data.text[0..data.text.length] # length of dropped
case type
when 'file:'
p 'file'

 when &#39;https&#39;
     p &#39;https&#39;

 when &#39;http:'
        p &#39;http:'
 end

end

window = Gtk::Window.new("Gtk::ComboBox sample")
window.signal_connect("destroy") {Gtk.main_quit}

#
# Text only
#
@combo1 = Gtk::ComboBoxText.new() #(:entry => true)
["foo", "bar", "fuga", "hoge"].each do |val|
@combo1.append_text(val)
end
@combo1.active = 1

@combo1.signal_connect("changed") do
# p "combo1: #{@combo1.active}, #{@combo1.active_iter[0]}"
# @combo1.active = 1
@combo1 = Gtk::ComboBoxText.new
["moon", "mars"].each do |val|
@combo1.append_text(val)
end
@combo1.active = 0
@combo1.remove_all
end

button = Gtk::Button.new(:label => "close")
button.signal_connect("clicked") do
@combo1.remove_all
#Gtk.main_quit
end

# Show main window
create_drop_space(@combo1)
vbox = Gtk::Box.new(:vertical)
vbox.add(@combo1)
vbox.add(button)
window.add(vbox).show_all

Gtk.main

#---------------------------------------------------------------------------------------------------------------------------

Am 29.09.19 um 00:41 schrieb Sutou Kouhei:

Hi,

Could you show runnable script instead of snippet?

Thanks,
--
kou

In <d1aa0074-4c07-c7f8-4d56-06878d8df435@unitybox.de>
   "GTK3 DND-Function don't except files" on Sat, 28 Sep 2019 08:58:21 +0200,
   ulli bei Unity <upahermann@unitybox.de> wrote:

Hi,

up to now I worked with the following dnd function. It worked very
well, I could drop files and http-adresses from browser.

Now I changed to Linux mint 19.2, dnd with files will not work
anymore.

Unfortunately the dnd function aren't well described.

UH

def create_drop_space cb
cb.drag_dest_set( Gtk::DestDefaults::ALL, [['text/plain', 0, 0]],
Gdk::DragAction::COPY)
cb.signal_connect('drag_data_received') do |w, context, x, y,
data, info, time|
#Encoding.default_internal
type=data.text[0..4] # what is dropped ?
path=data.text[0..data.text.length] # length of dropped
aS=data.data
kwords=cb.active_iter[0].split(',')
save_dnd_data data, kwords
end

end

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>

Hi,

In <02a9e84f-ba06-fe78-8e36-fa97168a16a4@unitybox.de>
  "Re: GTK3 DND-Function don't except files" on Mon, 30 Sep 2019 11:10:56 +0200,

enclosed the snippet. I use ruby-gtk3 3.2.4-1 now.

Thanks.

How about changing

cb.drag_dest_set( Gtk::DestDefaults::ALL, [['text/plain', 0, 0]], Gdk::DragAction::COPY)

to

  cb.drag_dest_set(Gtk::DestDefaults::ALL, nil, Gdk::DragAction::COPY)
  cb.drag_dest_add_text_targets
  cb.drag_dest_add_image_targets
  cb.drag_dest_add_uri_targets

?

See also comments from Detlef:
  http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/440375

With ruby-gtk3 2.2.5 all files would be accepted (pdf,txt, images).
Now only url from browser.

How did you drag PDF, text and images? Which application did
you use? Nautilus?

Thanks,

···

ulli bei Unity <upahermann@unitybox.de> wrote:
--
kou