gtkmozembed 0.90.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ To use Ruby-Gecko mini-browser run
2
+
3
+ $ ruby ruby-gecko.rb
4
+
5
+ Mirko Maischberger
@@ -0,0 +1,223 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ =begin
4
+
5
+ The Ruby Gecko (featuring Gtk::* and Gtk::MozEmbed)
6
+
7
+ Copyright (C) 2005 Mirko Maischberger, All rights reserverd
8
+
9
+ This program is free software; you can redistribute it and/or
10
+ modify it under the terms of the GNU General Public License
11
+ as published by the Free Software Foundation; either version 2
12
+ of the License, or (at your option) any later version.
13
+
14
+ This program is distributed in the hope that it will be useful,
15
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ GNU General Public License for more details.
18
+
19
+ You should have received a copy of the GNU General Public License
20
+ along with this program; if not, write to the Free Software
21
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
+
23
+ =end
24
+
25
+ ## The following is commented since the comp_path gets a nice
26
+ ## default at compile time.
27
+ ##
28
+ #unless ENV['MOZILLA_FIVE_HOME']
29
+ # $stderr.print "Please set MOZILLA_FIVE_HOME environment variable to\n"
30
+ # $stderr.print "something like /usr/lib/mozilla\n"
31
+ #end
32
+
33
+ require 'gtkmozembed'
34
+
35
+ class Browser < Gtk::Window
36
+
37
+ TITLE = "The Ruby Gecko"
38
+
39
+ attr_reader :moz
40
+
41
+ def initialize
42
+
43
+ super
44
+
45
+ self.border_width = 1
46
+ self.title = TITLE
47
+ self.resize(800, 570)
48
+
49
+ # This one is needed if GtkMozEmbed can't find the comp_path
50
+ mozhome = ENV['MOZILLA_FIVE_HOME']
51
+ if mozhome
52
+ Gtk::MozEmbed.set_comp_path(mozhome)
53
+ end
54
+
55
+ # Gtk::MozEmbed :)
56
+ Gtk::MozEmbed.set_profile_path(ENV['HOME'] + '.mozilla', 'RubyGecko')
57
+
58
+ # Let's create the MozEmbed widget.
59
+ @moz = Gtk::MozEmbed.new
60
+
61
+ @moz.chrome_mask = Gtk::MozEmbed::ALLCHROME
62
+
63
+ # A Toolbar with some stock icons and self explaining beaviour
64
+ bar = Gtk::Toolbar.new
65
+
66
+ back = bar.append(Gtk::Stock::GO_BACK) {
67
+ @moz.go_back
68
+ }
69
+
70
+ forward = bar.append(Gtk::Stock::GO_FORWARD){
71
+ @moz.go_forward
72
+ }
73
+
74
+ stop = bar.append(Gtk::Stock::STOP){
75
+ @moz.stop_load
76
+ }
77
+
78
+ refresh = bar.append(Gtk::Stock::REFRESH){
79
+ @moz.reload(Gtk::MozEmbed::RELOADBYPASSCACHE)
80
+ }
81
+
82
+ home = bar.append(Gtk::Stock::HOME) {
83
+ @moz.location="http://ruby-gnome2.sourceforge.jp/"
84
+ }
85
+
86
+ home = bar.append(Gtk::Stock::ADD) {
87
+ @moz.open_stream("http://ruby-gnome2.sourceforge.jp/", "text/html")
88
+ @moz.append_data("<html>\n")
89
+ @moz.append_data("<head>\n")
90
+ @moz.append_data("<title>Self feeded test page</title>\n")
91
+ @moz.append_data("</head>\n")
92
+ @moz.append_data("<body>\n")
93
+ @moz.append_data("<h1>Method: open_stream</h1>\n")
94
+ @moz.append_data("<a target=\"_blank\" href=\"hiki.cgi?Status+of+Ruby%2FGtkMozEmbed\">")
95
+ @moz.append_data("Status of Gtk::MozEmbed</a>")
96
+ @moz.append_data("(link relative to base_uri)\n")
97
+ @moz.append_data("</body>")
98
+ @moz.append_data("</html>")
99
+ @moz.close_stream
100
+
101
+ # see alsa: Gtk::MozEmbed#render_data
102
+ }
103
+
104
+ # A text-entry to let the user change the location manually
105
+ entry = Gtk::Entry.new
106
+
107
+ # A Statusbar with link info and progress bar
108
+ statusbox = Gtk::HBox.new
109
+
110
+ status = Gtk::Statusbar.new
111
+ status.has_resize_grip=false
112
+ status_context = status.get_context_id("Link")
113
+
114
+ progress = Gtk::ProgressBar.new
115
+
116
+ statusbox.pack_start(status, true)
117
+ statusbox.pack_start(progress, false)
118
+
119
+ # Pack together
120
+ box= Gtk::VBox.new
121
+ box.pack_start(bar, false)
122
+ box.pack_start(entry, false)
123
+ box.pack_start(@moz)
124
+ box.pack_start(statusbox, false)
125
+
126
+ # Add to the main window
127
+ self.add(box)
128
+
129
+ # Connect some more signals
130
+
131
+ # When we press enter while the text-entry has
132
+ # the focus this tells mozilla to load the inserted url
133
+ entry.signal_connect('activate') {
134
+ @moz.location = entry.text
135
+ }
136
+
137
+ # When location changes (the user clicks on a link)
138
+ # this updates the text-entry value
139
+ @moz.signal_connect('location') { |widget|
140
+ $stderr.print "location signal\n"
141
+ entry.text = widget.location if entry.text != widget.location
142
+ }
143
+
144
+ # When the page title changes we update the window
145
+ # title as well
146
+ @moz.signal_connect('title') { |widget|
147
+ $stderr.print "title signal\n"
148
+ self.title = widget.title + ' - ' + TITLE
149
+ }
150
+
151
+ # Lots of this signals arive during the page loading
152
+ # to let us update the progress bar. It the web server
153
+ # tells mozilla the total page size we can update the
154
+ # progress bar with a percentage value, otherwise max
155
+ # will be -1 and we just pulse.
156
+ @moz.signal_connect('progress') { |widget, cur, max|
157
+ $stderr.print "progress signal\n"
158
+ if max < 1 or cur > max
159
+ progress.pulse
160
+ else
161
+ progress.fraction = cur.to_f / max.to_f
162
+ end
163
+ }
164
+
165
+ # This signal is raised when the user selects a link
166
+ # on a page. We update the statusbar as a real
167
+ # browser would do.
168
+ @moz.signal_connect('link_message') {
169
+ $stderr.print "link_message signal\n"
170
+ status.push(status_context, @moz.link_message)
171
+ }
172
+
173
+ # This signal is generated when mozilla starts to load a page
174
+ # We update the statusbar message and reset the progress.
175
+ @moz.signal_connect('net_start') {
176
+ $stderr.print "net_start signal\n"
177
+ status.push(status_context, "Loading " + @moz.link_message + "...")
178
+ progress.fraction = 0.0
179
+ }
180
+
181
+ # This signal is generated when mozilla stops to load a page
182
+ # We update the statusbar message and reset the progress.
183
+ @moz.signal_connect('net_stop') {
184
+ $stderr.print "net_stop signal\n"
185
+ status.push(status_context, "")
186
+ progress.fraction = 0.0
187
+ }
188
+
189
+ # This signal is generated when mozilla stops to load a page
190
+ # We update the statusbar message and reset the progress.
191
+ # This does not work at the moment...
192
+ @moz.on_new_window { |widget, mask|
193
+ $stderr.print "new_window\n"
194
+ Browser.new.moz
195
+ }
196
+
197
+ # The user is bored, let's quit.
198
+ self.signal_connect("destroy") {
199
+ $stderr.print "closing...\n"
200
+ Gtk.main_quit
201
+ }
202
+
203
+ self.show_all
204
+
205
+ end
206
+ end
207
+
208
+ Browser.new
209
+
210
+ Gtk.main
211
+
212
+
213
+ # Hint: If you use Mozilla 1.7.x gtkmozembd, you should remove
214
+ # libnullplugin.so if you want to get rid of "Default Plugin"
215
+ # window. The gtkmozembed from Firefox 1.0 has an improved nullplugin.
216
+
217
+ # Hint: You can switch between Mozilla and Firefox implementation by
218
+ # setting the library path appropiately. The Firefox version of
219
+ # GtkMozEmbed is better integrated in Gtk and has nicer scroll-bars
220
+ # and message boxes. (use LD_LIBRARY_PATH, see extconf.rb or do some
221
+ # googling)
222
+
223
+ # Happy coding, Mirko Maischberger
@@ -0,0 +1,2 @@
1
+ module GtkMozEmbedTestUtils
2
+ end
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $VERBOSE = true
4
+
5
+ ruby_gnome2_base = File.join(File.dirname(__FILE__), "..", "..")
6
+ ruby_gnome2_base = File.expand_path(ruby_gnome2_base)
7
+
8
+ glib_base = File.join(ruby_gnome2_base, "glib2")
9
+ atk_base = File.join(ruby_gnome2_base, "atk")
10
+ pango_base = File.join(ruby_gnome2_base, "pango")
11
+ gdk_pixbuf_base = File.join(ruby_gnome2_base, "gdk_pixbuf2")
12
+ gtk_base = File.join(ruby_gnome2_base, "gtk2")
13
+ gtk_moz_embed_base = File.join(ruby_gnome2_base, "gtkmozembed")
14
+
15
+ $LOAD_PATH.unshift(glib_base)
16
+ require 'test/glib-test-init'
17
+
18
+ [glib_base, atk_base, pango_base,
19
+ gdk_pixbuf_base, gtk_base, gtk_moz_embed_base].each do |target|
20
+ if system("which make > /dev/null")
21
+ `make -C #{target.dump} > /dev/null` or exit(1)
22
+ end
23
+ $LOAD_PATH.unshift(File.join(target, "ext", File.basename(target)))
24
+ $LOAD_PATH.unshift(File.join(target, "src"))
25
+ $LOAD_PATH.unshift(File.join(target, "src", "lib"))
26
+ $LOAD_PATH.unshift(File.join(target))
27
+ $LOAD_PATH.unshift(File.join(target, "lib"))
28
+ end
29
+
30
+ $LOAD_PATH.unshift(File.join(gtk_moz_embed_base, "test"))
31
+ require 'gtk-moz-embed-test-utils'
32
+
33
+ require 'gtkmozembed'
34
+
35
+ exit Test::Unit::AutoRunner.run(true)
@@ -0,0 +1,39 @@
1
+ class TestGtkMozEmbed < Test::Unit::TestCase
2
+ include GtkMozEmbedTestUtils
3
+
4
+ def setup
5
+ @embed = Gtk::MozEmbed.new
6
+ end
7
+
8
+ def test_flags_class
9
+ assert_const_defined(Gtk::MozEmbed, :ProgressFlags)
10
+ assert_const_defined(Gtk::MozEmbed, :StatusFlags)
11
+ assert_const_defined(Gtk::MozEmbed, :ReloadFlags)
12
+ assert_const_defined(Gtk::MozEmbed, :ChromeFlags)
13
+ end
14
+
15
+ def test_flags_shortcut
16
+ assert_const_defined(Gtk::MozEmbed, :START)
17
+
18
+ assert_const_defined(Gtk::MozEmbed, :FAILED_DNS)
19
+ assert_const_defined(Gtk::MozEmbed, :FAILED_USER_CANCELED)
20
+
21
+ assert_const_defined(Gtk::MozEmbed, :RELOAD_NORMAL)
22
+ assert_const_defined(Gtk::MozEmbed, :RELOAD_BYPASS_CACHE)
23
+ assert_const_defined(Gtk::MozEmbed, :RELOAD_BYPASS_PROXY)
24
+ assert_const_defined(Gtk::MozEmbed, :RELOAD_BYPASS_PROXY_AND_CACHE)
25
+ assert_const_defined(Gtk::MozEmbed, :RELOAD_CHARSET_CHANGE)
26
+
27
+ assert_const_defined(Gtk::MozEmbed, :DEFAULT_CHROME)
28
+ assert_const_defined(Gtk::MozEmbed, :WINDOW_CLOSE_ON)
29
+ assert_const_defined(Gtk::MozEmbed, :MENU_BARON)
30
+ assert_const_defined(Gtk::MozEmbed, :PERSONAL_TOOLBAR_ON)
31
+ assert_const_defined(Gtk::MozEmbed, :SCROLLBARS_ON)
32
+ assert_const_defined(Gtk::MozEmbed, :EXTRA_CHROME_ON)
33
+ assert_const_defined(Gtk::MozEmbed, :ALL_CHROME)
34
+ assert_const_defined(Gtk::MozEmbed, :WINDOW_RAISED)
35
+ assert_const_defined(Gtk::MozEmbed, :CENTER_SCREEN)
36
+ assert_const_defined(Gtk::MozEmbed, :MODAL)
37
+ assert_const_defined(Gtk::MozEmbed, :OPEN_AS_DIALOG)
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gtkmozembed
3
+ version: !ruby/object:Gem::Version
4
+ hash: 379
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 90
9
+ - 6
10
+ version: 0.90.6
11
+ platform: ruby
12
+ authors:
13
+ - The Ruby-GNOME2 Proejct Team
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-01-30 00:00:00 +09:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: gtk2
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 379
30
+ segments:
31
+ - 0
32
+ - 90
33
+ - 6
34
+ version: 0.90.6
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: Ruby/GtkMozEmbed is a Ruby binding of GtkMozEmbed a widget embedding a Mozilla Gecko renderer.
38
+ email: ruby-gnome2-devel-en@lists.sourceforge.net
39
+ executables: []
40
+
41
+ extensions:
42
+ - ext/gtkmozembed/extconf.rb
43
+ extra_rdoc_files: []
44
+
45
+ files:
46
+ - ChangeLog
47
+ - README
48
+ - Rakefile
49
+ - extconf.rb
50
+ - lib/gtkmozembed.rb
51
+ - ext/gtkmozembed/rbgtkmozembed-init.o
52
+ - ext/gtkmozembed/gtkmozembed-enum-types.h
53
+ - ext/gtkmozembed/rbgtkmozembed-init.cpp
54
+ - ext/gtkmozembed/rbgtkmozembed.o
55
+ - ext/gtkmozembed/rbgtkmozembedversion.h
56
+ - ext/gtkmozembed/Makefile
57
+ - ext/gtkmozembed/rbgtkmozembed.h
58
+ - ext/gtkmozembed/gtkmozembed-enum-types.o
59
+ - ext/gtkmozembed/extconf.rb
60
+ - ext/gtkmozembed/ruby-gtkmozembed.pc
61
+ - ext/gtkmozembed/rbgtkmozembed.c
62
+ - ext/gtkmozembed/gtkmozembed.so
63
+ - ext/gtkmozembed/gtkmozembed-enum-types.c
64
+ - ext/gtkmozembed/depend
65
+ - sample/README
66
+ - sample/COPYING
67
+ - sample/ruby-gecko.rb
68
+ - test/test-gtk-moz-embed.rb
69
+ - test/run-test.rb
70
+ - test/gtk-moz-embed-test-utils.rb
71
+ has_rdoc: true
72
+ homepage: http://ruby-gnome2.sourceforge.jp/
73
+ licenses: []
74
+
75
+ post_install_message:
76
+ rdoc_options: []
77
+
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 61
86
+ segments:
87
+ - 1
88
+ - 8
89
+ - 5
90
+ version: 1.8.5
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ hash: 3
97
+ segments:
98
+ - 0
99
+ version: "0"
100
+ requirements: []
101
+
102
+ rubyforge_project:
103
+ rubygems_version: 1.3.7
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: Ruby/GtkMozEmbed is a Ruby binding of GtkMozEmbed a widget embedding a Mozilla Gecko renderer.
107
+ test_files: []
108
+