gtkmozembed 0.90.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,103 @@
1
+
2
+ /* Generated by glib-mkenums.rb ($Id: glib-mkenums.rb 3990 2010-10-27 03:38:42Z ktou $) */
3
+
4
+ #include "gtkmozembed-enum-types.h"
5
+ #include <gtkmozembed.h>
6
+
7
+
8
+
9
+ /* enumerations from "/usr/include/xulrunner-1.9.1/unstable/gtkmozembed.h" */
10
+ GType
11
+ gtk_moz_embed_progress_flags_get_type (void)
12
+ {
13
+ static GType etype = 0;
14
+ if (etype == 0) {
15
+ static const GFlagsValue values[] = {
16
+ { GTK_MOZ_EMBED_FLAG_START, "GTK_MOZ_EMBED_FLAG_START", "start" },
17
+ { GTK_MOZ_EMBED_FLAG_REDIRECTING, "GTK_MOZ_EMBED_FLAG_REDIRECTING", "redirecting" },
18
+ { GTK_MOZ_EMBED_FLAG_TRANSFERRING, "GTK_MOZ_EMBED_FLAG_TRANSFERRING", "transferring" },
19
+ { GTK_MOZ_EMBED_FLAG_NEGOTIATING, "GTK_MOZ_EMBED_FLAG_NEGOTIATING", "negotiating" },
20
+ { GTK_MOZ_EMBED_FLAG_STOP, "GTK_MOZ_EMBED_FLAG_STOP", "stop" },
21
+ { GTK_MOZ_EMBED_FLAG_IS_REQUEST, "GTK_MOZ_EMBED_FLAG_IS_REQUEST", "is-request" },
22
+ { GTK_MOZ_EMBED_FLAG_IS_DOCUMENT, "GTK_MOZ_EMBED_FLAG_IS_DOCUMENT", "is-document" },
23
+ { GTK_MOZ_EMBED_FLAG_IS_NETWORK, "GTK_MOZ_EMBED_FLAG_IS_NETWORK", "is-network" },
24
+ { GTK_MOZ_EMBED_FLAG_IS_WINDOW, "GTK_MOZ_EMBED_FLAG_IS_WINDOW", "is-window" },
25
+ { GTK_MOZ_EMBED_FLAG_RESTORING, "GTK_MOZ_EMBED_FLAG_RESTORING", "restoring" },
26
+ { 0, NULL, NULL }
27
+ };
28
+ etype = g_flags_register_static ("GtkMozEmbedProgressFlags", values);
29
+ }
30
+ return etype;
31
+ }
32
+
33
+ GType
34
+ gtk_moz_embed_status_flags_get_type (void)
35
+ {
36
+ static GType etype = 0;
37
+ if (etype == 0) {
38
+ static const GFlagsValue values[] = {
39
+ { GTK_MOZ_EMBED_STATUS_FAILED_DNS, "GTK_MOZ_EMBED_STATUS_FAILED_DNS", "dns" },
40
+ { GTK_MOZ_EMBED_STATUS_FAILED_CONNECT, "GTK_MOZ_EMBED_STATUS_FAILED_CONNECT", "connect" },
41
+ { GTK_MOZ_EMBED_STATUS_FAILED_TIMEOUT, "GTK_MOZ_EMBED_STATUS_FAILED_TIMEOUT", "timeout" },
42
+ { GTK_MOZ_EMBED_STATUS_FAILED_USERCANCELED, "GTK_MOZ_EMBED_STATUS_FAILED_USERCANCELED", "usercanceled" },
43
+ { 0, NULL, NULL }
44
+ };
45
+ etype = g_flags_register_static ("GtkMozEmbedStatusFlags", values);
46
+ }
47
+ return etype;
48
+ }
49
+
50
+ GType
51
+ gtk_moz_embed_reload_flags_get_type (void)
52
+ {
53
+ static GType etype = 0;
54
+ if (etype == 0) {
55
+ static const GFlagsValue values[] = {
56
+ { GTK_MOZ_EMBED_FLAG_RELOADNORMAL, "GTK_MOZ_EMBED_FLAG_RELOADNORMAL", "normal" },
57
+ { GTK_MOZ_EMBED_FLAG_RELOADBYPASSCACHE, "GTK_MOZ_EMBED_FLAG_RELOADBYPASSCACHE", "bypasscache" },
58
+ { GTK_MOZ_EMBED_FLAG_RELOADBYPASSPROXY, "GTK_MOZ_EMBED_FLAG_RELOADBYPASSPROXY", "bypassproxy" },
59
+ { GTK_MOZ_EMBED_FLAG_RELOADBYPASSPROXYANDCACHE, "GTK_MOZ_EMBED_FLAG_RELOADBYPASSPROXYANDCACHE", "bypassproxyandcache" },
60
+ { GTK_MOZ_EMBED_FLAG_RELOADCHARSETCHANGE, "GTK_MOZ_EMBED_FLAG_RELOADCHARSETCHANGE", "charsetchange" },
61
+ { 0, NULL, NULL }
62
+ };
63
+ etype = g_flags_register_static ("GtkMozEmbedReloadFlags", values);
64
+ }
65
+ return etype;
66
+ }
67
+
68
+ GType
69
+ gtk_moz_embed_chrome_flags_get_type (void)
70
+ {
71
+ static GType etype = 0;
72
+ if (etype == 0) {
73
+ static const GFlagsValue values[] = {
74
+ { GTK_MOZ_EMBED_FLAG_DEFAULTCHROME, "GTK_MOZ_EMBED_FLAG_DEFAULTCHROME", "defaultchrome" },
75
+ { GTK_MOZ_EMBED_FLAG_WINDOWBORDERSON, "GTK_MOZ_EMBED_FLAG_WINDOWBORDERSON", "windowborderson" },
76
+ { GTK_MOZ_EMBED_FLAG_WINDOWCLOSEON, "GTK_MOZ_EMBED_FLAG_WINDOWCLOSEON", "windowcloseon" },
77
+ { GTK_MOZ_EMBED_FLAG_WINDOWRESIZEON, "GTK_MOZ_EMBED_FLAG_WINDOWRESIZEON", "windowresizeon" },
78
+ { GTK_MOZ_EMBED_FLAG_MENUBARON, "GTK_MOZ_EMBED_FLAG_MENUBARON", "menubaron" },
79
+ { GTK_MOZ_EMBED_FLAG_TOOLBARON, "GTK_MOZ_EMBED_FLAG_TOOLBARON", "toolbaron" },
80
+ { GTK_MOZ_EMBED_FLAG_LOCATIONBARON, "GTK_MOZ_EMBED_FLAG_LOCATIONBARON", "locationbaron" },
81
+ { GTK_MOZ_EMBED_FLAG_STATUSBARON, "GTK_MOZ_EMBED_FLAG_STATUSBARON", "statusbaron" },
82
+ { GTK_MOZ_EMBED_FLAG_PERSONALTOOLBARON, "GTK_MOZ_EMBED_FLAG_PERSONALTOOLBARON", "personaltoolbaron" },
83
+ { GTK_MOZ_EMBED_FLAG_SCROLLBARSON, "GTK_MOZ_EMBED_FLAG_SCROLLBARSON", "scrollbarson" },
84
+ { GTK_MOZ_EMBED_FLAG_TITLEBARON, "GTK_MOZ_EMBED_FLAG_TITLEBARON", "titlebaron" },
85
+ { GTK_MOZ_EMBED_FLAG_EXTRACHROMEON, "GTK_MOZ_EMBED_FLAG_EXTRACHROMEON", "extrachromeon" },
86
+ { GTK_MOZ_EMBED_FLAG_ALLCHROME, "GTK_MOZ_EMBED_FLAG_ALLCHROME", "allchrome" },
87
+ { GTK_MOZ_EMBED_FLAG_WINDOWRAISED, "GTK_MOZ_EMBED_FLAG_WINDOWRAISED", "windowraised" },
88
+ { GTK_MOZ_EMBED_FLAG_WINDOWLOWERED, "GTK_MOZ_EMBED_FLAG_WINDOWLOWERED", "windowlowered" },
89
+ { GTK_MOZ_EMBED_FLAG_CENTERSCREEN, "GTK_MOZ_EMBED_FLAG_CENTERSCREEN", "centerscreen" },
90
+ { GTK_MOZ_EMBED_FLAG_DEPENDENT, "GTK_MOZ_EMBED_FLAG_DEPENDENT", "dependent" },
91
+ { GTK_MOZ_EMBED_FLAG_MODAL, "GTK_MOZ_EMBED_FLAG_MODAL", "modal" },
92
+ { GTK_MOZ_EMBED_FLAG_OPENASDIALOG, "GTK_MOZ_EMBED_FLAG_OPENASDIALOG", "openasdialog" },
93
+ { GTK_MOZ_EMBED_FLAG_OPENASCHROME, "GTK_MOZ_EMBED_FLAG_OPENASCHROME", "openaschrome" },
94
+ { 0, NULL, NULL }
95
+ };
96
+ etype = g_flags_register_static ("GtkMozEmbedChromeFlags", values);
97
+ }
98
+ return etype;
99
+ }
100
+
101
+
102
+ /* Generated data ends here */
103
+
@@ -0,0 +1,26 @@
1
+
2
+ /* Generated by glib-mkenums.rb ($Id: glib-mkenums.rb 3990 2010-10-27 03:38:42Z ktou $) */
3
+
4
+ #ifndef __GTKMOZEMBED_ENUM_TYPES_H__
5
+ #define __GTKMOZEMBED_ENUM_TYPES_H__
6
+
7
+ #include <glib-object.h>
8
+
9
+ G_BEGIN_DECLS
10
+
11
+ /* enumerations from "/usr/include/xulrunner-1.9.1/unstable/gtkmozembed.h" */
12
+ GType gtk_moz_embed_progress_flags_get_type (void);
13
+ #define GTK_TYPE_MOZ_EMBED_PROGRESS_FLAGS (gtk_moz_embed_progress_flags_get_type())
14
+ GType gtk_moz_embed_status_flags_get_type (void);
15
+ #define GTK_TYPE_MOZ_EMBED_STATUS_FLAGS (gtk_moz_embed_status_flags_get_type())
16
+ GType gtk_moz_embed_reload_flags_get_type (void);
17
+ #define GTK_TYPE_MOZ_EMBED_RELOAD_FLAGS (gtk_moz_embed_reload_flags_get_type())
18
+ GType gtk_moz_embed_chrome_flags_get_type (void);
19
+ #define GTK_TYPE_MOZ_EMBED_CHROME_FLAGS (gtk_moz_embed_chrome_flags_get_type())
20
+
21
+ G_END_DECLS
22
+
23
+ #endif /* __GTKMOZEMBED_ENUM_TYPES_H__ */
24
+
25
+ /* Generated data ends here */
26
+
@@ -0,0 +1,84 @@
1
+ /* -*- c-file-style: "ruby" -*- */
2
+ /************************************************
3
+
4
+ rbgtkmozembed-init.c -
5
+
6
+ Ruby-GNOME2 Gtk::MozEmbed - Ruby bindings for GtkMozEmbed
7
+
8
+ Copyright (C) 2009 Ruby-GNOME2 Project Team.
9
+
10
+ This library is free software; you can redistribute it and/or
11
+ modify it under the terms of the GNU Lesser General Public
12
+ License as published by the Free Software Foundation; either
13
+ version 2.1 of the License, or (at your option) any later version.
14
+
15
+ This library is distributed in the hope that it will be useful,
16
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
+ Lesser General Public License for more details.
19
+
20
+ You should have received a copy of the GNU Lesser General Public
21
+ License along with this library; if not, write to the Free Software
22
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
+ ************************************************/
24
+
25
+ #include "rbgtkmozembed.h"
26
+
27
+ #ifdef XPCOM_GLUE
28
+ # include "gtkmozembed_glue.cpp"
29
+ #endif
30
+
31
+ G_BEGIN_DECLS
32
+
33
+ #ifdef XPCOM_GLUE
34
+ static void
35
+ setup_xpcom_glue(void)
36
+ {
37
+ static const GREVersionRange greVersion = {
38
+ "1.9b", PR_TRUE,
39
+ "2", PR_TRUE
40
+ };
41
+ char xpcomPath[PATH_MAX];
42
+
43
+ nsresult rv = GRE_GetGREPathWithProperties(&greVersion, 1, nsnull, 0,
44
+ xpcomPath, sizeof(xpcomPath));
45
+ if (NS_FAILED(rv))
46
+ return;
47
+
48
+ rv = XPCOMGlueStartup(xpcomPath);
49
+ if (NS_FAILED(rv))
50
+ return;
51
+
52
+ rv = GTKEmbedGlueStartup();
53
+ if (NS_FAILED(rv))
54
+ return;
55
+
56
+ rv = GTKEmbedGlueStartupInternal();
57
+ if (NS_FAILED(rv))
58
+ return;
59
+
60
+ char *lastSlash = strrchr(xpcomPath, '/');
61
+ if (lastSlash)
62
+ *lastSlash = '\0';
63
+
64
+ gtk_moz_embed_set_path(xpcomPath);
65
+
66
+ gtk_moz_embed_push_startup();
67
+ }
68
+ #endif
69
+
70
+ void
71
+ Init_gtkmozembed(void)
72
+ {
73
+ #ifdef XPCOM_GLUE
74
+ setup_xpcom_glue();
75
+ #else
76
+ # ifdef DEFAULT_MOZILLA_FIVE_HOME
77
+ gtk_moz_embed_set_comp_path(DEFAULT_MOZILLA_FIVE_HOME);
78
+ # endif
79
+ #endif
80
+
81
+ Init_gtk_moz_embed();
82
+ }
83
+
84
+ G_END_DECLS
@@ -0,0 +1,634 @@
1
+ /* -*- c-file-style: "ruby" -*- */
2
+
3
+ /************************************************
4
+
5
+ rbgtkmozembed.c -
6
+
7
+ Ruby-GNOME2 Gtk::MozEmbed - Ruby bindings for GtkMozEmbed
8
+
9
+ Copyright (C) 2005-2007, 2009 Ruby-GNOME2 Project Team.
10
+ Copyright (C) 2005 Mirko Maischberger, All rights reserved.
11
+
12
+ This library is free software; you can redistribute it and/or
13
+ modify it under the terms of the GNU Lesser General Public
14
+ License as published by the Free Software Foundation; either
15
+ version 2.1 of the License, or (at your option) any later version.
16
+
17
+ This library is distributed in the hope that it will be useful,
18
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
+ Lesser General Public License for more details.
21
+
22
+ You should have received a copy of the GNU Lesser General Public
23
+ License along with this library; if not, write to the Free Software
24
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
+
26
+
27
+ Many thanks to Christopher Blizzard <blizzard@mozilla.org> for
28
+ writing the gtkmozembed library and to the Mozilla Foundation.
29
+
30
+ Thanks should as well go to the Gtk and GNOME developers, Yukihiro
31
+ Matsumoto for Ruby and to the Ruby-GNOME2 Team.
32
+
33
+ ************************************************/
34
+
35
+ #include "rbgtkmozembed.h"
36
+ #include "gtkmozembed-enum-types.h"
37
+
38
+ /*
39
+ * Class: Gtk::MozEmbed
40
+ *
41
+ * This class wraps the GtkMozEmbed widget in a Ruby class. The
42
+ * GtkMozEmbed is an HTML rendering widget based on Mozilla Gecko
43
+ * provided by either Mozilla or Firefox. You need to have
44
+ * libgtkmozembed.so in your library path to use and
45
+ * mozilla-gtkmozembed.pc and gtkmozembed.h in order to compile.
46
+ *
47
+ * Gtk::MozEmbed.new
48
+ * ...
49
+ * Gtk::MozEmbed.location="http://ruby-gnome2.sf.net"
50
+ * ...
51
+ *
52
+ * Please see the sample application ruby-gecko for more info and
53
+ * examples.
54
+ *
55
+ */
56
+
57
+ #define _SELF(s) (GTK_MOZ_EMBED(RVAL2GOBJ(s)))
58
+
59
+
60
+ /*
61
+ * Class method: new
62
+ *
63
+ * Constructor for the Gtk::MozEmbed object.
64
+ *
65
+ * Returns: a newly created Gtk::MozEmbed widget.
66
+ *
67
+ */
68
+ static VALUE
69
+ moz_initialize(self)
70
+ VALUE self;
71
+ {
72
+ RBGTK_INITIALIZE(self, gtk_moz_embed_new());
73
+ return Qnil;
74
+ }
75
+
76
+ /*
77
+ * Class method: set_profile_path(profile_path, profile_name)
78
+ *
79
+ * profile_path: the path to store the profile (String).
80
+ * profile_name: the name of the application using the widget (String).
81
+ *
82
+ * You should call this method before the constructor. The
83
+ * profile_path parameter should be set to $ENV['HOME']+'/.mozilla'.
84
+ *
85
+ * A new profile directory with this name will be created in the
86
+ * profile_path directory.
87
+ *
88
+ * Returns: nil.
89
+ *
90
+ */
91
+ static VALUE
92
+ moz_set_profile_path(self, profile_path, profile_name)
93
+ VALUE self, profile_path, profile_name;
94
+ {
95
+ gtk_moz_embed_set_profile_path(RVAL2CSTR(profile_path),
96
+ RVAL2CSTR(profile_name));
97
+ return Qnil;
98
+ }
99
+
100
+ /*
101
+ * Class method: set_comp_path(path)
102
+ *
103
+ * path: the mozilla component path (String).
104
+ *
105
+ * You should call this method before the constructor.
106
+ *
107
+ * The path should be something like /usr/lib/mozilla or
108
+ * /usr/lib/mozilla-firefox depending on your installation and
109
+ * distribution.
110
+ *
111
+ * We call this inside Init_gtkmozembed() and set the value at
112
+ * compile time before initializing XPCOM.
113
+ *
114
+ * Returns: nil.
115
+ *
116
+ */
117
+ static VALUE
118
+ moz_set_comp_path(self, path)
119
+ VALUE self, path;
120
+ {
121
+ gtk_moz_embed_set_comp_path(RVAL2CSTR(path));
122
+ return Qnil;
123
+ }
124
+
125
+ /*
126
+ * Method: load_url(url)
127
+ *
128
+ * url: the url to load (String).
129
+ *
130
+ * This method starts loading the given url, and returns
131
+ * immediately. The url should be in the form "http://www.gnome.org".
132
+ *
133
+ * Returns: the object itself.
134
+ *
135
+ */
136
+
137
+ /*
138
+ * Method: set_location(url)
139
+ *
140
+ * See Gtk::MozEmbed#load_url
141
+ *
142
+ * Returns: self.
143
+ */
144
+
145
+ /*
146
+ * Method: location=url
147
+ *
148
+ * See Gtk::MozEmbed#load_url
149
+ *
150
+ * Returns: self.
151
+ */
152
+
153
+ static VALUE
154
+ moz_load_url(self, url)
155
+ VALUE self, url;
156
+ {
157
+ gtk_moz_embed_load_url(_SELF(self), RVAL2CSTR(url));
158
+ return self;
159
+ }
160
+
161
+ /*
162
+ * Method: stop_load
163
+ *
164
+ * Stops loading the current page.
165
+ *
166
+ * Returns: the object itself.
167
+ *
168
+ */
169
+ static VALUE
170
+ moz_stop_load(self)
171
+ VALUE self;
172
+ {
173
+ gtk_moz_embed_stop_load(_SELF(self));
174
+ return self;
175
+ }
176
+
177
+ /*
178
+ * Method: can_go_back?
179
+ *
180
+ * This method reflects the status of the browsing history.
181
+ *
182
+ * Returns: True if the browser can go back one page.
183
+ *
184
+ */
185
+ static VALUE
186
+ moz_can_go_back(self)
187
+ VALUE self;
188
+ {
189
+ return CBOOL2RVAL(gtk_moz_embed_can_go_back(_SELF(self)));
190
+ }
191
+
192
+ /*
193
+ * Method: can_go_forward?
194
+ *
195
+ * This method reflects the status of the browsing history.
196
+ *
197
+ * Returns: True if the browser can go forward one page.
198
+ *
199
+ */
200
+ static VALUE
201
+ moz_can_go_forward(self)
202
+ VALUE self;
203
+ {
204
+ return CBOOL2RVAL(gtk_moz_embed_can_go_forward(_SELF(self)));
205
+ }
206
+
207
+ /*
208
+ * Method: go_back
209
+ *
210
+ * Tells the browser to go back one page in the history.
211
+ *
212
+ * Returns: the object itself.
213
+ *
214
+ */
215
+ static VALUE
216
+ moz_go_back(self)
217
+ VALUE self;
218
+ {
219
+ gtk_moz_embed_go_back(_SELF(self));
220
+ return self;
221
+ }
222
+
223
+ /*
224
+ * Method: go_forward
225
+ *
226
+ * Tells the browser to go one page forward in the history.
227
+ *
228
+ * Returns: the object itself.
229
+ *
230
+ */
231
+ static VALUE
232
+ moz_go_forward(self)
233
+ VALUE self;
234
+ {
235
+ gtk_moz_embed_go_forward(_SELF(self));
236
+ return self;
237
+ }
238
+
239
+ /*
240
+ * Method: location
241
+ *
242
+ * The current location, usefull when the "location" signal is raised.
243
+ *
244
+ * Returns: the current location (String).
245
+ *
246
+ */
247
+ static VALUE
248
+ moz_get_location(self)
249
+ VALUE self;
250
+ {
251
+ char* url = gtk_moz_embed_get_location(_SELF(self));
252
+ return CSTR2RVAL(url);
253
+ }
254
+
255
+
256
+ /*
257
+ * Method: link_message
258
+ *
259
+ * The location of the selected link, useful when the "link_message"
260
+ * signal is raised.
261
+ *
262
+ * Returns: the selected url.
263
+ *
264
+ */
265
+ static VALUE
266
+ moz_get_link_message(self)
267
+ VALUE self;
268
+ {
269
+ char *msg = gtk_moz_embed_get_link_message(_SELF(self));
270
+ return CSTR2RVAL(msg);
271
+ }
272
+
273
+ /*
274
+ * Method: js_status
275
+ *
276
+ * The JavaScript|ECMAScript status message, useful when the
277
+ * "js_status" signal is raised.
278
+ *
279
+ * Returns: the selected url (String).
280
+ *
281
+ */
282
+ static VALUE
283
+ moz_get_js_status(self)
284
+ VALUE self;
285
+ {
286
+ char *msg = gtk_moz_embed_get_js_status(_SELF(self));
287
+ return CSTR2RVAL(msg);
288
+ }
289
+
290
+ /*
291
+ * Method: title
292
+ *
293
+ * The title of the currently loaded page, usefull when the "title"
294
+ * signal is raised.
295
+ *
296
+ * Returns: the page title (String).
297
+ *
298
+ */
299
+ static VALUE
300
+ moz_get_title(self)
301
+ VALUE self;
302
+ {
303
+ char *title = gtk_moz_embed_get_title(_SELF(self));
304
+ return CSTR2RVAL(title);
305
+ }
306
+
307
+ /*
308
+ * Method: reload(flags)
309
+ *
310
+ * flags: one of the Gtk::MozEmbed::ReloadFlags
311
+ * (Gtk::MozEmbed::RELOADNORMAL, Gtk::MozEmbed::RELOADBYPASSCACHE,
312
+ * Gtk::MozEmbed::RELOADBYPASSPROXY, Gtk::MozEmbed::RELOADBYPASSPROXYANDCACHE).
313
+ *
314
+ * Forces a page reload of a specific type.
315
+ *
316
+ * Returns: the object itself.
317
+ *
318
+ */
319
+ static VALUE
320
+ moz_reload(self, flags)
321
+ VALUE self, flags;
322
+ {
323
+ gtk_moz_embed_reload(_SELF(self),
324
+ RVAL2GFLAGS(flags, GTK_TYPE_MOZ_EMBED_RELOAD_FLAGS));
325
+ return self;
326
+ }
327
+
328
+ /*
329
+ * Method: set_chrome_mask(flags)
330
+ *
331
+ * flags: a combination of Gtk::MozEmbed::ChromeFlags.
332
+ *
333
+ * Set the chrome mask.
334
+ *
335
+ * Returns: the object itself.
336
+ *
337
+ */
338
+
339
+ static VALUE
340
+ moz_set_chrome_mask(self, flags)
341
+ VALUE self, flags;
342
+ {
343
+ gtk_moz_embed_set_chrome_mask(_SELF(self),
344
+ RVAL2GFLAGS(flags, GTK_TYPE_MOZ_EMBED_CHROME_FLAGS));
345
+ return self;
346
+ }
347
+
348
+ /*
349
+ * Method: chrome_mask
350
+ *
351
+ * Get the chrome mask.
352
+ *
353
+ * Returns: a combination of Moz::GtkEmbed::ChromeFlags.
354
+ *
355
+ */
356
+ static VALUE
357
+ moz_get_chrome_mask(self)
358
+ VALUE self;
359
+ {
360
+ guint32 mask = gtk_moz_embed_get_chrome_mask(_SELF(self));
361
+ return GFLAGS2RVAL(mask, GTK_TYPE_MOZ_EMBED_CHROME_FLAGS);
362
+ }
363
+
364
+ /*
365
+ * Method: render_data(data, base_uri, mime_type)
366
+ *
367
+ * data: the data to be rendered.
368
+ * base_uri: the base uri for the resolver.
369
+ * mime_type: the mime/type of the data to be rendered.
370
+ *
371
+ * This function will allow you to take a chunk of random data and
372
+ * render it into the Gtk::MozEmbed window. See also
373
+ * Gtk::MozEmbed#open_stream, Gtk::MozEmbed#append_data and
374
+ * Gtk::MozEmbed#close_stream.
375
+ *
376
+ * Returns: self.
377
+ *
378
+ */
379
+ static VALUE
380
+ moz_render_data(self, data, base_uri, mime_type)
381
+ VALUE self, data, base_uri, mime_type;
382
+ {
383
+ gtk_moz_embed_render_data(_SELF(self),
384
+ RSTRING_PTR(data),
385
+ RSTRING_LEN(data),
386
+ RVAL2CSTR(base_uri),
387
+ RVAL2CSTR(mime_type));
388
+ return self;
389
+ }
390
+
391
+
392
+
393
+
394
+ static gboolean stream_open = FALSE;
395
+
396
+ /*
397
+ * Method: open_stream(base_uri, mime_type)
398
+ *
399
+ * base_uri: the uri that Gtk::MozEmbed will use to resolve
400
+ * relative addresses (String).
401
+ * mime_type: the mime type of the data (String).
402
+ *
403
+ * This method sould be called to visualize self feeded html.
404
+ *
405
+ * The base_uri must be a valid base uri, this should contain
406
+ * the protocol name and the path separated by a colon.
407
+ *
408
+ * The mime_type should be a valid mime-type and instucts
409
+ * GtkMozEmbed about the data that we'll send with "<<":
410
+ *
411
+ * * "text/html" if an HTML is to be displayed.
412
+ * * "text/plain" if TXT data are to be displayed.
413
+ * * "image/png" if we want to send some PNG data.
414
+ * * "image/jpeg" if our data are in JPEG format.
415
+ * * "image/gif" if our data are in GIF format.
416
+ * * See /etc/mime.types for more.
417
+ *
418
+ * moz.open_stream("file:///basepath/", "text/html")
419
+ * moz.append_data("
420
+ * <html>
421
+ * <body>
422
+ * test
423
+ * <a href=\"hello.html\">this is resolved against base_path</a>
424
+ * </body>
425
+ * </html>")
426
+ * moz.close_stream
427
+ *
428
+ * See also #render_data.
429
+ *
430
+ * Returns: self.
431
+ *
432
+ */
433
+ static VALUE
434
+ moz_open_stream(self, base_uri, mime_type)
435
+ VALUE self, base_uri, mime_type;
436
+ {
437
+ gchar *bu = RVAL2CSTR(base_uri);
438
+
439
+ if(!strchr(bu, ':'))
440
+ rb_raise(rb_eArgError,
441
+ "The base_uri parameter must be a valid base uri. "
442
+ "(e.g http://www.sitename.org/base/, file:///path/.../)");
443
+ gtk_moz_embed_open_stream(_SELF(self), bu, RVAL2CSTR(mime_type));
444
+ stream_open = TRUE;
445
+ return self;
446
+ }
447
+
448
+ /*
449
+ * Method: append_data(data)
450
+ *
451
+ * data: The data do be added to the rendering stream (String).
452
+ *
453
+ * You should feed data to the rendering stream via this method.
454
+ * The data should be in the mime format if you want to send some
455
+ * self drawn PNG or JPEG data from a Pixbuf please see:
456
+ * http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gdk%3A%3APixbuf#save_to_buffer
457
+ *
458
+ * Returns: self.
459
+ */
460
+ static VALUE
461
+ moz_append_data(self, data)
462
+ VALUE self, data;
463
+ {
464
+ if(!stream_open)
465
+ rb_raise(rb_eRuntimeError,
466
+ "Can't append date before open_stream"
467
+ " is called.");
468
+
469
+ gtk_moz_embed_append_data(_SELF(self),
470
+ RSTRING_PTR(data),
471
+ RSTRING_LEN(data));
472
+ return self;
473
+ }
474
+
475
+ /*
476
+ * Method: close_stream
477
+ *
478
+ * This closes the stream. This way Gtk::MozEmbed knows we
479
+ * are finished.
480
+ *
481
+ * Returns: self.
482
+ *
483
+ */
484
+ static VALUE
485
+ moz_close_stream(self)
486
+ VALUE self;
487
+ {
488
+ if(!stream_open)
489
+ rb_raise(rb_eRuntimeError,
490
+ "You should open the stream before closing it.");
491
+
492
+ gtk_moz_embed_close_stream(_SELF(self));
493
+ stream_open = FALSE;
494
+ return self;
495
+ }
496
+
497
+
498
+ /*
499
+ * Signals are automagically handled by Ruby-GNOME2.
500
+ * except for new_window which needs a custom handling.
501
+ *
502
+ */
503
+
504
+
505
+ /* The new_window signal is handled separately. */
506
+
507
+ static gulong new_win_sig = 0;
508
+
509
+ static void
510
+ moz_custom_new_window_cb(embed, retval, chromemask, func)
511
+ GtkMozEmbed *embed;
512
+ GtkMozEmbed **retval;
513
+ guint chromemask;
514
+ VALUE func;
515
+ {
516
+ VALUE new_moz =
517
+ rb_funcall(func, rb_intern("call"), 2,
518
+ GOBJ2RVAL(embed),
519
+ GFLAGS2RVAL(chromemask, GTK_TYPE_MOZ_EMBED_CHROME_FLAGS));
520
+ *retval = RVAL2GOBJ(new_moz);
521
+ }
522
+
523
+ /*
524
+ * Method: on_new_window { |widget, chromemask| block }
525
+ *
526
+ * The new_window signal should not be connected directly, this method
527
+ * should be used instead. The block should eval to the newly created
528
+ * Gtk::MozEmbed widget. This method serves the purpose of creating
529
+ * a new window around the widget when requested.
530
+ *
531
+ * Returns: self.
532
+ */
533
+ static VALUE
534
+ set_on_new_window_block(self)
535
+ VALUE self;
536
+ {
537
+ VALUE func = rb_block_proc();
538
+ G_RELATIVE(self, func);
539
+ new_win_sig =
540
+ g_signal_connect(RVAL2GOBJ(self), "new_window",
541
+ G_CALLBACK(moz_custom_new_window_cb),
542
+ (void *)func);
543
+ return self;
544
+ }
545
+
546
+ /*
547
+ * Method: no_new_window
548
+ *
549
+ * This method clears the code block associated via the
550
+ * Gtk::MozEmbed#on_new_window method.
551
+ *
552
+ * Returns: self.
553
+ */
554
+ static VALUE
555
+ clear_on_new_window_block(self)
556
+ VALUE self;
557
+ {
558
+ GObject *moz = RVAL2GOBJ(self);
559
+
560
+ if(g_signal_handler_is_connected(moz, new_win_sig))
561
+ g_signal_handler_disconnect(RVAL2GOBJ(self), new_win_sig);
562
+ else
563
+ rb_raise(rb_eRuntimeError,
564
+ "#on_new_window code block not set so it cannot be removed.");
565
+
566
+ return self;
567
+ }
568
+
569
+ /** INIT **/
570
+
571
+ void
572
+ Init_gtk_moz_embed(void)
573
+ {
574
+
575
+ VALUE moz = G_DEF_CLASS(GTK_TYPE_MOZ_EMBED, "MozEmbed", mGtk);
576
+
577
+ rb_define_module_function(moz, "set_profile_path",
578
+ moz_set_profile_path, 2);
579
+ rb_define_module_function(moz, "set_comp_path",
580
+ moz_set_comp_path, 1);
581
+
582
+ rb_define_method(moz, "initialize", moz_initialize, 0);
583
+ rb_define_method(moz, "load_url", moz_load_url, 1);
584
+ /* Alias method so that location & location= work in pair */
585
+ rb_define_method(moz, "set_location", moz_load_url, 1);
586
+ rb_define_method(moz, "stop_load", moz_stop_load, 0);
587
+ rb_define_method(moz, "can_go_back?", moz_can_go_back, 0);
588
+ rb_define_method(moz, "can_go_forward?", moz_can_go_forward, 0);
589
+ rb_define_method(moz, "go_back", moz_go_back, 0);
590
+ rb_define_method(moz, "go_forward", moz_go_forward, 0);
591
+ rb_define_method(moz, "location", moz_get_location, 0);
592
+ rb_define_method(moz, "js_status", moz_get_js_status, 0);
593
+ rb_define_method(moz, "link_message", moz_get_link_message, 0);
594
+ rb_define_method(moz, "title", moz_get_title, 0);
595
+ rb_define_method(moz, "reload", moz_reload, 1);
596
+ rb_define_method(moz, "chrome_mask", moz_get_chrome_mask, 0);
597
+ rb_define_method(moz, "set_chrome_mask", moz_set_chrome_mask, 1);
598
+ rb_define_method(moz, "render_data", moz_render_data, 3);
599
+ rb_define_method(moz, "open_stream", moz_open_stream, 2);
600
+ rb_define_method(moz, "append_data", moz_append_data, 1);
601
+ /*
602
+ * This overrides the Bin method so it's disabled:
603
+ * rb_define_method(moz, "<<", moz_append_data, 1);
604
+ */
605
+ rb_define_method(moz, "close_stream", moz_close_stream, 0);
606
+
607
+ /* overriding new_window signal to take care of retval ourself */
608
+ rb_define_method(moz, "on_new_window", set_on_new_window_block, 0);
609
+ rb_define_method(moz, "no_new_window", clear_on_new_window_block, 0);
610
+
611
+ G_DEF_SETTERS(moz);
612
+
613
+ G_DEF_CLASS(GTK_TYPE_MOZ_EMBED_PROGRESS_FLAGS, "ProgressFlags", moz);
614
+ G_DEF_CONSTANTS(moz, GTK_TYPE_MOZ_EMBED_PROGRESS_FLAGS,
615
+ "GTK_MOZ_EMBED_FLAG_");
616
+
617
+ G_DEF_CLASS(GTK_TYPE_MOZ_EMBED_STATUS_FLAGS, "StatusFlags", moz);
618
+ G_DEF_CONSTANTS(moz, GTK_TYPE_MOZ_EMBED_STATUS_FLAGS,
619
+ "GTK_MOZ_EMBED_STATUS_");
620
+
621
+ G_DEF_CLASS(GTK_TYPE_MOZ_EMBED_RELOAD_FLAGS, "ReloadFlags", moz);
622
+ G_DEF_CONSTANTS(moz, GTK_TYPE_MOZ_EMBED_RELOAD_FLAGS,
623
+ "GTK_MOZ_EMBED_FLAG_");
624
+
625
+ G_DEF_CLASS(GTK_TYPE_MOZ_EMBED_CHROME_FLAGS, "ChromeFlags", moz);
626
+ G_DEF_CONSTANTS(moz, GTK_TYPE_MOZ_EMBED_CHROME_FLAGS,
627
+ "GTK_MOZ_EMBED_FLAG_");
628
+
629
+ rb_define_const(moz, "BUILD_VERSION",
630
+ rb_ary_new3(3,
631
+ INT2FIX(GTKMOZEMBED_MAJOR_VERSION),
632
+ INT2FIX(GTKMOZEMBED_MINOR_VERSION),
633
+ INT2FIX(GTKMOZEMBED_MICRO_VERSION)));
634
+ }