# Gtkmozembed pango text

**URL:** <https://www.ruby-forum.com/t/gtkmozembed-pango-text/116892>\
**Category:** Ruby-Gnome 2\
**Created:** [October 10, 2007, 10:36pm UTC](https://www.ruby-forum.com/t/gtkmozembed-pango-text/116892 "2007-10-10T22:36:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![andy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@andy](https://www.ruby-forum.com/u/andy)\
**Post date:** [October 10, 2007, 10:36pm UTC](https://www.ruby-forum.com/t/gtkmozembed-pango-text/116892/1 "2007-10-10T22:36:11Z")

</div>

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/](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
