[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Gtk2::MozEmbed + DOM
- From: Scott Lanning <lannings who int>
- To: Torsten Schoenfeld <kaffeetisch gmx de>
- Cc: gtk-perl-list gnome org
- Subject: Re: Gtk2::MozEmbed + DOM
- Date: Sat, 2 Apr 2005 22:36:35 +0000 (UTC)
On Wed, 30 Mar 2005, Torsten Schoenfeld wrote:
This is where the magical ExtUtils::Depends comes in. It lets modules
depend on other XS modules.
Thanks, it works!
I removed the Gtk2 dependency from Makefile.PL, but not Glib yet.
I was also thinking of changing mozilla-gtkmozembed to
mozilla-xpcom (lacking anything better, at least that would not
require GtkMozEmbed). Not sure what write_version_macros does,
though; and anyway, for the time being only Gtk2::MozEmbed would
use this module, and it already requires mozilla-gtkmozembed.
I meant to have separate .xs files, but I couldn't figure
out how to make it work so I left them in one file.
I changed Gtk2::MozEmbed to check if Mozilla::DOM is installed.
If so, c++ is used. The build depends on whether c++ is used to tell
if the marshaller parts should be included in the build. I was thinking
an ENABLE_DOM option to Makefile.PL could also be added, but I didn't
do that. Patch attached. Mozilla::DOM was just uploaded to CPAN.
diff -ru Gtk2-MozEmbed-0.03-orig/Makefile.PL Gtk2-MozEmbed-0.03/Makefile.PL
--- Gtk2-MozEmbed-0.03-orig/Makefile.PL 2005-03-23 22:33:18.000000000 +0000
+++ Gtk2-MozEmbed-0.03/Makefile.PL 2005-04-02 00:35:38.000000000 +0000
@@ -13,7 +13,8 @@
'perl-ExtUtils-Depends' => '0.20',
'perl-ExtUtils-PkgConfig' => '1.03',
'perl-Glib' => '1.06',
- 'perl-Gtk2' => '1.00',
+ 'perl-Gtk2' => '1.00', # '1.081' when that's released
+ 'perl-Mozilla-DOM' => '0.01',
'GtkMozEmbed' => '1.7',
);
@@ -36,6 +37,14 @@
exit 1; # not reached
}
+# Check if Mozilla::DOM is installed. (could use an ENABLE_DOM option)
+my $use_dom = 1;
+unless (eval "use Mozilla::DOM '$build_reqs{'perl-Mozilla-DOM'}'; 1") {
+ warn "$ \n";
+ $use_dom = 0;
+}
+
+
my %pkgcfg = ExtUtils::PkgConfig->find("mozilla-gtkmozembed >= $build_reqs{'GtkMozEmbed'}");
mkdir 'build', 0777;
@@ -54,12 +63,14 @@
"mozilla-gtkmozembed" => "GTK_MOZ_EMBED",
);
-my $mozembed = ExtUtils::Depends->new('Gtk2::MozEmbed', 'Gtk2');
+my $mozembed = ExtUtils::Depends->new('Gtk2::MozEmbed', 'Gtk2',
+ ($use_dom ? ('Mozilla::DOM') : ()));
+
$mozembed->set_inc($pkgcfg{cflags});
$mozembed->set_libs($pkgcfg{libs});
$mozembed->add_xs(@xs_files);
$mozembed->add_pm('MozEmbed.pm' => '$(INST_LIBDIR)/MozEmbed.pm');
-$mozembed->add_typemaps(map {File::Spec->catfile(cwd(), $_)} 'build/gtkmozembed2perl.typemap');
+$mozembed->add_typemaps(map {File::Spec->catfile(cwd(), $_)} qw(build/gtkmozembed2perl.typemap));
$mozembed->install(qw(gtkmozembed2perl.h build/gtkmozembed2perl-autogen.h));
$mozembed->save_config('build/IFiles.pm');
@@ -74,6 +85,7 @@
XSPROTOARG => '-noprototypes',
MAN3PODS => \%pod_files,
LD => "LD_RUN_PATH=$libdir $Config{ld}",
+ ($use_dom ? (CC => 'c++', XSOPT => '-C++') : ()),
$mozembed->get_makefile_vars,
);
diff -ru Gtk2-MozEmbed-0.03-orig/MozEmbed.pm Gtk2-MozEmbed-0.03/MozEmbed.pm
--- Gtk2-MozEmbed-0.03-orig/MozEmbed.pm 2005-03-23 22:33:17.000000000 +0000
+++ Gtk2-MozEmbed-0.03/MozEmbed.pm 2005-04-02 00:35:38.000000000 +0000
@@ -7,6 +7,7 @@
use warnings;
use Gtk2;
+eval "use Mozilla::DOM; 1;";
require DynaLoader;
diff -ru Gtk2-MozEmbed-0.03-orig/examples/pumzilla Gtk2-MozEmbed-0.03/examples/pumzilla
--- Gtk2-MozEmbed-0.03-orig/examples/pumzilla 2005-03-23 22:33:17.000000000 +0000
+++ Gtk2-MozEmbed-0.03/examples/pumzilla 2005-04-02 16:34:42.000000000 +0000
@@ -157,6 +157,58 @@
return $pumzilla -> { _embed };
});
+ # dom_key_* signals
+ foreach my $signal (map {"dom_key_$_"} qw/press down up/) {
+ $embed->signal_connect($signal => sub {
+ my ($embed, $event) = @_;
+
+ print "$signal\n";
+ if (ref $event) {
+ my %props = ();
+ foreach my $prop (qw(char_code key_code
+ ctrl_key shift_key alt_key meta_key
+ event_phase bubbles cancelable detail))
+ {
+ my $method = "get_$prop";
+ $props{$prop} = $event->$method;
+ }
+
+ foreach my $prop (sort keys %props) {
+ print "\t$prop: '$props{$prop}'\n";
+ }
+ }
+
+ return 1;
+ });
+ }
+
+ # dom_mouse_* signals
+ foreach my $signal (map {"dom_mouse_$_"} qw/click down up dbl_click over out/) {
+ $embed->signal_connect($signal => sub {
+ my ($embed, $event) = @_;
+
+ print "$signal\n";
+ if (ref $event) {
+ my %props = ();
+ foreach my $prop (qw(screen_x screen_y client_x client_y
+ ctrl_key shift_key alt_key meta_key button
+ event_phase bubbles cancelable detail))
+ {
+ next if ($prop eq 'button' or $prop eq 'detail')
+ and ($signal eq 'dom_mouse_over' or $signal eq 'dom_mouse_out');
+ my $method = "get_$prop";
+ $props{$prop} = $event->$method;
+ }
+
+ foreach my $prop (sort keys %props) {
+ print "\t$prop: '$props{$prop}'\n";
+ }
+ }
+
+ return 1;
+ });
+ }
+
$box -> show_all();
$self -> add($box);
diff -ru Gtk2-MozEmbed-0.03-orig/gtkmozembed2perl.h Gtk2-MozEmbed-0.03/gtkmozembed2perl.h
--- Gtk2-MozEmbed-0.03-orig/gtkmozembed2perl.h 2005-03-23 22:33:17.000000000 +0000
+++ Gtk2-MozEmbed-0.03/gtkmozembed2perl.h 2005-04-02 00:35:38.000000000 +0000
@@ -21,8 +21,19 @@
#ifndef _GTKMOZEMBED2PERL_H_
#define _GTKMOZEMBED2PERL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <gtk2perl.h>
+#ifdef __cplusplus /* implies Mozilla::DOM is installed */
+}
+
+#include <mozilladom2perl.h>
+#endif
+
#include <gtkmozembed.h>
#include "gtkmozembed2perl-version.h"
@@ -44,6 +55,7 @@
* #endif
*/
+
#include "gtkmozembed2perl-autogen.h"
#endif /* _GTKMOZEMBED2PERL_H_ */
Only in Gtk2-MozEmbed-0.03-orig/t: GtkMozEmbed.t~
diff -ru Gtk2-MozEmbed-0.03-orig/xs/GtkMozEmbed.xs Gtk2-MozEmbed-0.03/xs/GtkMozEmbed.xs
--- Gtk2-MozEmbed-0.03-orig/xs/GtkMozEmbed.xs 2005-03-23 22:33:17.000000000 +0000
+++ Gtk2-MozEmbed-0.03/xs/GtkMozEmbed.xs 2005-04-02 00:35:38.000000000 +0000
@@ -129,6 +129,105 @@
/* ------------------------------------------------------------------------- */
+/* the following two can probably be combined
+ if we can find the signal name */
+
+/* gint (* dom_key_press) (GtkMozEmbed *embed, gpointer dom_event); */
+
+#ifdef __cplusplus /* implies Mozilla::DOM is installed */
+
+static void
+gtk2perl_moz_embed_dom_key_marshal (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ dGPERL_CLOSURE_MARSHAL_ARGS;
+
+ GPERL_CLOSURE_MARSHAL_INIT (closure, marshal_data);
+
+ ENTER;
+ SAVETMPS;
+
+ PUSHMARK (SP);
+
+ GPERL_CLOSURE_MARSHAL_PUSH_INSTANCE (param_values);
+
+ /* param_values + 1 is the `gpointer dom_event' */
+ XPUSHs (sv_2mortal (newSVnsIDOMKeyEvent ((nsIDOMKeyEvent *)
+ g_value_get_pointer (param_values + 1))));
+
+
+ GPERL_CLOSURE_MARSHAL_PUSH_DATA;
+
+ PUTBACK;
+
+ GPERL_CLOSURE_MARSHAL_CALL (G_SCALAR);
+
+ SPAGAIN;
+
+ if (count != 1)
+ croak ("signal handlers for `dom_key_*' are supposed to "
+ "return an integer");
+
+ gperl_value_from_sv (return_value, POPs);
+
+ PUTBACK;
+
+ FREETMPS;
+ LEAVE;
+}
+
+static void
+gtk2perl_moz_embed_dom_mouse_marshal (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ dGPERL_CLOSURE_MARSHAL_ARGS;
+
+ GPERL_CLOSURE_MARSHAL_INIT (closure, marshal_data);
+
+ ENTER;
+ SAVETMPS;
+
+ PUSHMARK (SP);
+
+ GPERL_CLOSURE_MARSHAL_PUSH_INSTANCE (param_values);
+
+ /* param_values + 1 is the `gpointer dom_event' */
+ XPUSHs (sv_2mortal (newSVnsIDOMMouseEvent ((nsIDOMMouseEvent *)
+ g_value_get_pointer (param_values + 1))));
+
+
+ GPERL_CLOSURE_MARSHAL_PUSH_DATA;
+
+ PUTBACK;
+
+ GPERL_CLOSURE_MARSHAL_CALL (G_SCALAR);
+
+ SPAGAIN;
+
+ if (count != 1)
+ croak ("signal handlers for `dom_mouse_*' are supposed to "
+ "return an integer");
+
+ gperl_value_from_sv (return_value, POPs);
+
+ PUTBACK;
+
+ FREETMPS;
+ LEAVE;
+}
+
+#endif /* ifdef __cplusplus */
+
+/* ------------------------------------------------------------------------- */
+
MODULE = Gtk2::MozEmbed PACKAGE = Gtk2::MozEmbed PREFIX = gtk_moz_embed_
BOOT:
@@ -140,6 +239,35 @@
/* gperl_signal_set_marshaller_for (GTK_TYPE_MOZ_EMBED_SINGLE,
"new_window_orphan",
gtk2perl_moz_embed_new_window_marshal); */
+#ifdef __cplusplus
+ gperl_signal_set_marshaller_for (GTK_TYPE_MOZ_EMBED,
+ "dom_key_down",
+ gtk2perl_moz_embed_dom_key_marshal);
+ gperl_signal_set_marshaller_for (GTK_TYPE_MOZ_EMBED,
+ "dom_key_press",
+ gtk2perl_moz_embed_dom_key_marshal);
+ gperl_signal_set_marshaller_for (GTK_TYPE_MOZ_EMBED,
+ "dom_key_up",
+ gtk2perl_moz_embed_dom_key_marshal);
+ gperl_signal_set_marshaller_for (GTK_TYPE_MOZ_EMBED,
+ "dom_mouse_down",
+ gtk2perl_moz_embed_dom_mouse_marshal);
+ gperl_signal_set_marshaller_for (GTK_TYPE_MOZ_EMBED,
+ "dom_mouse_up",
+ gtk2perl_moz_embed_dom_mouse_marshal);
+ gperl_signal_set_marshaller_for (GTK_TYPE_MOZ_EMBED,
+ "dom_mouse_click",
+ gtk2perl_moz_embed_dom_mouse_marshal);
+ gperl_signal_set_marshaller_for (GTK_TYPE_MOZ_EMBED,
+ "dom_mouse_dbl_click",
+ gtk2perl_moz_embed_dom_mouse_marshal);
+ gperl_signal_set_marshaller_for (GTK_TYPE_MOZ_EMBED,
+ "dom_mouse_over",
+ gtk2perl_moz_embed_dom_mouse_marshal);
+ gperl_signal_set_marshaller_for (GTK_TYPE_MOZ_EMBED,
+ "dom_mouse_out",
+ gtk2perl_moz_embed_dom_mouse_marshal);
+#endif /* ifdef __cplusplus */
=for object Gtk2::MozEmbed::main
@@ -405,6 +533,10 @@
GtkMozEmbedChromeFlags
gtk_moz_embed_get_chrome_mask (embed)
GtkMozEmbed *embed
+ CODE:
+ RETVAL = (GtkMozEmbedChromeFlags) gtk_moz_embed_get_chrome_mask (embed);
+ OUTPUT:
+ RETVAL
# --------------------------------------------------------------------------- #
@@ -495,6 +627,68 @@
interrupt the loading of a new document. By returning I<TRUE> you are saying
"don't load this document."
+=item integer B<dom_key_down> (Gtk2::MozEmbed, Gtk2::MozEmbed::KeyEvent)
+
+This signal is emitted when a key is pressed down. See the DOM Level 3
+specification for more details.
+
+=item integer B<dom_key_up> (Gtk2::MozEmbed, Gtk2::MozEmbed::KeyEvent)
+
+This signal is emitted when a key is released. See the DOM Level 3
+specification for more details.
+
+=item integer B<dom_key_press> (Gtk2::MozEmbed, Gtk2::MozEmbed::KeyEvent)
+
+This signal is presumably emitted when a key is pressed and released,
+i.e. i.e. a combination of L<Gtk2::MozEmbed::main/dom_key_down> and
+L<Gtk2::MozEmbed::main/dom_key_up>. (Note however that it seems to also
+get emitted repeatedly if you hold the key down.)
+
+=item integer B<dom_mouse_down> (Gtk2::MozEmbed, Gtk2::MozEmbed::MouseEvent)
+
+This signal is emitted when "a pointing device button is pressed over an
+element. In the case of nested elements, this event type is always targeted
+at the most deeply nested element." See the DOM Level 3 specification for
+more details.
+
+=item integer B<dom_mouse_up> (Gtk2::MozEmbed, Gtk2::MozEmbed::MouseEvent)
+
+This signal is emitted when "a pointing device button is released over an
+element. In the case of nested elements, this event type is always targeted
+at the most deeply nested element. See the DOM Level 3 specification for
+more details.
+
+=item integer B<dom_mouse_click> (Gtk2::MozEmbed, Gtk2::MozEmbed::MouseEvent)
+
+This signal is emitted when "a pointing device button is clicked over
+an element. The definition of a click depends on the environment
+configuration; i.e. may depend on the screen location or the delay
+between the press and release of the pointing device button. In any case,
+the target node must be the same between the mousedown, mouseup, and click."
+In other words, it's basically L<Gtk2::MozEmbed::main/dom_mouse_down>
+followed quickly by L<Gtk2::MozEmbed::main/dom_mouse_up>. See the DOM Level 3
+specification for more details.
+
+=item integer B<dom_mouse_dbl_click> (Gtk2::MozEmbed, Gtk2::MozEmbed::MouseEvent)
+
+This signal is emitted when a mouse button is double clicked on an element.
+(The only thing I found in the DOM Level 3 specification was an example
+showing that two click events occur for a double click.)
+
+=item integer B<dom_mouse_over> (Gtk2::MozEmbed, Gtk2::MozEmbed::MouseEvent)
+
+This signal is emitted when "a pointing device is moved onto an element.
+In the case of nested elements, this event type is always targeted at
+the most deeply nested element." See the DOM Level 3 specification for
+more details.
+
+=item integer B<dom_mouse_out> (Gtk2::MozEmbed, Gtk2::MozEmbed::MouseEvent)
+
+This signal is emitted when "a pointing device is moved away from an
+element. In the case of nested elements, this event type is always
+targeted at the most deeply nested element." See the DOM Level 3
+specification for more details.
+
=back
=cut
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]