Hey,
I am trying to extract the text from Gtk::Dialog alerts generated by
gtkmozembed - for example; Javascript alerts, security warnings, etc.
However, after I retrieve the pango layout from the Gtk::Dialog and call
the
text method, it returns an empty string. Am I approaching this the wrong
way, or is it a bug?
I’ve included an example below - mozilla navigates to a https:// address
and
a security warning should pop up (as long as you haven’t disabled such
warnings in your mozilla config). I then set up a timer to check for
Gtk::Dialogs, from which I get a Pango::Layout.
Many thanks,
Andy.
#!/usr/bin/env ruby
require ‘gtkmozembed’
Gtk.init
gtk = Gtk::Window.new
Gtk::MozEmbed.set_profile_path(ENV[‘HOME’] + ‘/.mozilla’, ‘RubyGecko’)
moz = Gtk::MozEmbed.new
#moz.show
gtk.add(moz)
gtk.show_all
moz1.load_url(“https://mail.google.com/”)
Gtk::timeout_add(1000) {
obj = Gtk.current
if (obj.kind_of?(Gtk::Dialog))
#puts obj.methods.grep(/pango/)
ctx = obj.create_pango_layout
puts "Title: #{obj.title}"
puts "Text: #{ctx.text}" # empty string
false
else
true
end
}
Gtk.main