Drag an URL from mozilla location bar, drop on a Ruby program?

E

Erik Terpstra

Is it possible to drag an URL from the mozilla location bar and drop it
on a Ruby program for further processing?

I am using XFree86, I can probably draw an empty window with RubyGTK or
something, but is it possible to process data that is dragged from
another application (like Mozilla)?

TIA,

Erik.
 
M

Masao Mutoh

Hi,

Is it possible to drag an URL from the mozilla location bar and drop it
on a Ruby program for further processing?

I am using XFree86, I can probably draw an empty window with RubyGTK or
something, but is it possible to process data that is dragged from
another application (like Mozilla)?

Here is a sample for Ruby/GTK2.

----------------
require 'gtk2'

Gtk.init

label = Gtk::Label.new("Drop Here")
Gtk::Drag.dest_set(label, Gtk::Drag::DEST_DEFAULT_ALL,
[["text/plain", 0, 0]],
Gdk::DragContext::ACTION_COPY| Gdk::DragContext::ACTION_MOVE)

label.signal_connect("drag_data_received") do |w, context, x, y, data, info, time|
p data.data #You can get the URL from mozilla.
Gtk::Drag.finish(context, true, false, 0)
end

Gtk::Window.new.add(label).set_default_size(100, 100).show_all

Gtk.main
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top