新規作成  編集  Ruby-GNOME2 Project Website  ページ一覧  検索  更新履歴  編集履歴  RSS  ログイン

Gtk::MozEmbed

class Gtk::MozEmbed

This class wraps the GtkMozEmbed widget in a Ruby class. The GtkMozEmbed is an HTML rendering widget based on Mozilla Gecko provided by either Mozilla or Firefox.

require 'gtkmozembed'
w = Gtk::Window.new
w.title = "Lean & mean browser"
w.resize(780, 570)
w << Gtk::MozEmbed.new
w.child.chrome_mask = Gtk::MozEmbed::ALLCHROME
w.child.location = "http://www.ruby-lang.org"
w.show_all
Gtk.main

Please see the sample application ruby-gecko and RubyGecko? for more.

Class Methods

Gtk::MozEmbed.new
Constructor for the Gtk::MozEmbed object.
Gtk::MozEmbed.set_comp_path(path)
You should call this method before the constructor. The path should be set to the value of the MOZILLA_FIVE_HOME environment variable if present.
  • path: the mozilla component path (String).
  • Returns: nil.
Gtk::MozEmbed.set_profile_path(profile_path, profile_name)
You should call this method before the constructor. The profile_path parameter should be set to $ENV['HOME']+'/.mozilla'. A new profile directory with this name will be created in the profile_path directory.
  • profile_name: the name of the application using the widget (String).
  • profile_path: the path to store the profile (String).
  • Returns: nil.

Instance Methods

append_data(data)
You should feed data to the rendering stream via this method. The data should be in the mime format if you want to send some self drawn PNG or JPEG data from a Pixbuf please see: Gdk::Pixbuf#save_to_buffer
  • data: The data do be added to the rendering stream (String).
  • Returns: self.
can_go_back?
This method reflects the status of the browsing history.
  • Returns: True if the browser can go back one page.
can_go_forward?
This method reflects the status of the browsing history.
  • Returns: True if the browser can go forward one page.
chrome_mask
Get the chrome mask.
  • Returns: a combination of Moz::GtkEmbed::ChromeFlags.
chrome_mask=flags
Set the chrome mask.
close_stream
This closes the stream. This way Gtk::MozEmbed knows we are finished.
  • Returns: self.
go_back
Tells the browser to go back one page in the history.
  • Returns: the object itself.
go_forward
Tells the browser to go one page forward in the history.
  • Returns: the object itself.
js_status
The JavaScript|ECMAScript status message, useful when the "js_status" signal is raised.
  • Returns: the selected url (String).
link_message
The location of the selected link, useful when the "link_message" signal is raised.
  • Returns: the selected url.
load_url(url)
This method starts loading the given url, and returns immediately. The url should be in the form "http://www.gnome.org".
  • url: the url to load (String).
  • Returns: the object itself.
location
The current location, usefull when the "location" signal is raised.
  • Returns: the current location (String).
location=url
See Gtk::MozEmbed#load_url
  • Returns: self.
no_new_window
This method clears the code block associated via the Gtk::MozEmbed#on_new_window method.
  • Returns: self.
on_new_window { |widget, chromemask| block }
The new_window signal should not be connected directly, this method should be used instead. The block should eval to the newly created Gtk::MozEmbed widget. This method serves the purpose of creating a new window around the widget when requested.
  • Returns: self.
open_stream(base_uri, mime_type)

Bug: don't call this method if the widget is hidden.

This method sould be called to visualize self feeded html. The base_uri must be a valid base uri, this should contain the protocol name and the path separated by a colon. The mime_type should be a valid mime-type and instucts GtkMozEmbed about the data that we'll send with "<<":

  • "text/html" if an HTML is to be displayed.
  • "text/plain" if TXT data are to be displayed.
  • "image/png" if we want to send some PNG data.
  • "image/jpeg" if our data are in JPEG format.
  • "image/gif" if our data are in GIF format.
  • See /etc/mime.types for more.

moz.open_stream("file:///basepath/", "text/html") moz.append_data(" <html> <body> test <a href=\"hello.html\">this is resolved against base_path</a> </body> </html>") moz.close_stream See also #render_data.

  • base_uri: the uri that Gtk::MozEmbed will use to resolve relative addresses (String).
  • mime_type: the mime type of the data (String).
  • Returns: self.
reload(flags)
Forces a page reload of a specific type.
render_data(data, base_uri, mime_type)

Bug: don't call this method if the widget is hidden.

This function will allow you to take a chunk of random data and render it into the Gtk::MozEmbed window. See also Gtk::MozEmbed#open_stream, Gtk::MozEmbed#append_data and Gtk::MozEmbed#close_stream.

  • base_uri: the base uri for the resolver.
  • mime_type: the mime/type of the data to be rendered.
  • data: the data to be rendered.
  • Returns: self.
set_chrome_mask(flags)
Set the chrome mask.
set_location(url)
See Gtk::MozEmbed#load_url
  • Returns: self.
stop_load
Stops loading the current page.
  • Returns: the object itself.
title
The title of the currently loaded page, usefull when the "title" signal is raised.
  • Returns: the page title (String).

Signals

link_message: self

This signal is raised when the user selects or moves the mouse over a link. See alsa Gtk::MozEmbed#link_message.

js_status: self

This signal is raised when an JavaScript/ECMAScript message needs to be displayed. See also Gtk::MozEmbed#js_status.

location: self

This signal is raised when the location of the document changes. See Gtk::MozEmbed#location.

title: self

This signal is raised when the title of the displayed document changes. See Gtk::MozEmbed#title.

progress: self, cur, max

This signal is raised to let the ui update an optional the progress bar.

cur: The bytes received. max: This il the number of bytes of the document or something <1 if it cannot be determined.

net_state: self, flags, status

This signal is raised when the connection status changes.

net_start: self

This signal is raised when the widget starts to load a page asincronously.

net_stop: self

This signal is raised when the widget has finished to load a page asincronously.

new_window: self, ?, ?

DON'T BIND THIS SIGNAL. The new-window event should be handled via the Gtk::MozEmbed#on_new_window and Gtk::MozEmbed#no_new_window methods.

visibility: self, visibility

If The widget wants to show/hide itself.

visibility: true or false

destroy_browser: self

The document has requested to be closed. This usually should close the current window.

open_uri: self, uri

This signal il raised just before the widget starts to load a new page. If you return true than the loading of the uri will NOT be permitted.

uri: the requested page

ChangeLog

  • 2005-10-10 Masao? Fixed a bug of the sample.
  • 2005-03-17 MirkoMaischberger? (added #render_data, #open_stream, #append_data, #close_stream, #on_new_window)
  • 2005-02-20 MirkoMaischberger?
更新日時:2006/07/02 14:30:27
キーワード:
参照:[Gtk::MozEmbed] [Ruby/GtkMozeEmbed] [Ruby/GTK]