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 23:33:18.000000000 +0100 +++ Gtk2-MozEmbed-0.03/Makefile.PL 2005-03-26 00:48:26.195264152 +0100 @@ -55,11 +55,14 @@ ); my $mozembed = ExtUtils::Depends->new('Gtk2::MozEmbed', 'Gtk2'); -$mozembed->set_inc($pkgcfg{cflags}); + +my $incdir = '-I' . `pkg-config --variable=includedir mozilla-gtkmozembed`; +chomp($incdir); +$mozembed->set_inc($pkgcfg{cflags}, $incdir); $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{dom.typemap build/gtkmozembed2perl.typemap}); $mozembed->install(qw(gtkmozembed2perl.h build/gtkmozembed2perl-autogen.h)); $mozembed->save_config('build/IFiles.pm'); @@ -67,6 +70,8 @@ my $libdir = `pkg-config --variable=libdir mozilla-gtkmozembed`; chomp($libdir); +our $CC = 'g++'; + WriteMakefile( NAME => 'Gtk2::MozEmbed', VERSION_FROM => 'MozEmbed.pm', @@ -74,6 +79,9 @@ XSPROTOARG => '-noprototypes', MAN3PODS => \%pod_files, LD => "LD_RUN_PATH=$libdir $Config{ld}", + CC => $CC, + LD => '$(CC)', + XSOPT => '-C++', $mozembed->get_makefile_vars, ); 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 23:33:17.000000000 +0100 +++ Gtk2-MozEmbed-0.03/examples/pumzilla 2005-03-26 00:39:00.458269248 +0100 @@ -157,6 +157,8 @@ return $pumzilla -> { _embed }; }); + $embed->signal_connect(dom_mouse_click => sub {print "click!\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 23:33:17.000000000 +0100 +++ Gtk2-MozEmbed-0.03/gtkmozembed2perl.h 2005-03-26 00:00:01.058912008 +0100 @@ -21,7 +21,17 @@ #ifndef _GTKMOZEMBED2PERL_H_ #define _GTKMOZEMBED2PERL_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif #include +#ifdef __cplusplus +} +#endif #include #include "gtkmozembed2perl-version.h" @@ -44,6 +54,13 @@ * #endif */ + +SV * newSVnsIDOMKeyEvent (nsIDOMKeyEvent *event); +nsIDOMKeyEvent * SvnsIDOMKeyEvent (SV *event); +SV * newSVnsIDOMMouseEvent (nsIDOMMouseEvent *event); +nsIDOMMouseEvent * SvnsIDOMMouseEvent (SV *event); + + #include "gtkmozembed2perl-autogen.h" #endif /* _GTKMOZEMBED2PERL_H_ */ 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 23:33:17.000000000 +0100 +++ Gtk2-MozEmbed-0.03/xs/GtkMozEmbed.xs 2005-03-26 14:21:27.485333160 +0100 @@ -19,7 +19,13 @@ */ #include "gtkmozembed2perl.h" +#ifdef __cplusplus +extern "C" { +#endif #include "gperl_marshal.h" +#ifdef __cplusplus +} +#endif /* ------------------------------------------------------------------------- */ @@ -129,6 +135,127 @@ /* ------------------------------------------------------------------------- */ +/* conversion functions for dom_* signals */ + +SV * +newSVnsIDOMKeyEvent (nsIDOMKeyEvent *event) +{ + SV *sv = newSV (0); + return sv_setref_pv (sv, "Gtk2::MozEmbed::KeyEvent", event); +} + +nsIDOMKeyEvent * +SvnsIDOMKeyEvent (SV *event) +{ + return INT2PTR (nsIDOMKeyEvent *, SvIV (SvRV (event))); +} + +SV * +newSVnsIDOMMouseEvent (nsIDOMMouseEvent *event) +{ + SV *sv = newSV (0); + return sv_setref_pv (sv, "Gtk2::MozEmbed::MouseEvent", event); +} + +nsIDOMMouseEvent * +SvnsIDOMMouseEvent (SV *event) +{ + return INT2PTR (nsIDOMMouseEvent *, SvIV (SvRV (event))); +} + +/* the following two can probably be combined + if we can find the signal name */ + +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; +} + +/* ------------------------------------------------------------------------- */ + MODULE = Gtk2::MozEmbed PACKAGE = Gtk2::MozEmbed PREFIX = gtk_moz_embed_ BOOT: @@ -140,6 +267,33 @@ /* gperl_signal_set_marshaller_for (GTK_TYPE_MOZ_EMBED_SINGLE, "new_window_orphan", gtk2perl_moz_embed_new_window_marshal); */ + 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); =for object Gtk2::MozEmbed::main @@ -508,3 +662,166 @@ # gtk_moz_embed_single_get (class) # C_ARGS: # /* void */ + +# --------------------------------------------------------------------------- # + +MODULE = Gtk2::MozEmbed PACKAGE = Gtk2::MozEmbed::KeyEvent + +# cf. mozilla-source-1.7.5/embedding/browser/gtk/tests/TestGtkEmbed.cpp +# and /usr/include/mozilla/dom/nsIDOMKeyEvent.h + +# /* readonly attribute unsigned long charCode; */ +# NS_IMETHOD GetCharCode(PRUint32 *aCharCode) = 0; +# /* readonly attribute unsigned long keyCode; */ +# NS_IMETHOD GetKeyCode(PRUint32 *aKeyCode) = 0; +# errrm, do I have to add all those enums? + +int +GetCharCode (event) + nsIDOMKeyEvent * event; + ALIAS: + Gtk2::MozEmbed::KeyEvent::GetCharCode = 1 + PREINIT: + PRUint32 code; + CODE: + switch (ix) { + case 0: event->GetCharCode(&code); break; + case 1: event->GetKeyCode(&code); break; + default: code = 0; + } + RETVAL = (int)code; + OUTPUT: + RETVAL + +# /* readonly attribute boolean ctrlKey; */ +# NS_IMETHOD GetCtrlKey(PRBool *aCtrlKey) = 0; +# /* readonly attribute boolean shiftKey; */ +# NS_IMETHOD GetShiftKey(PRBool *aShiftKey) = 0; +# /* readonly attribute boolean altKey; */ +# NS_IMETHOD GetAltKey(PRBool *aAltKey) = 0; +# /* readonly attribute boolean metaKey; */ +# NS_IMETHOD GetMetaKey(PRBool *aMetaKey) = 0; + +gboolean +GetCtrlKey (event) + nsIDOMKeyEvent * event; + ALIAS: + Gtk2::MozEmbed::KeyEvent::GetShiftKey = 1 + Gtk2::MozEmbed::KeyEvent::GetAltKey = 2 + Gtk2::MozEmbed::KeyEvent::GetMetaKey = 3 + PREINIT: + PRBool key; + CODE: + switch (ix) { + case 0: event->GetCtrlKey(&key); break; + case 1: event->GetShiftKey(&key); break; + case 2: event->GetAltKey(&key); break; + case 3: event->GetMetaKey(&key); break; + default: key = 0; + } + RETVAL = (gboolean)key; + OUTPUT: + RETVAL + +# XXX: worry about InitKeyEvent later... + +# --------------------------------------------------------------------------- # + +MODULE = Gtk2::MozEmbed PACKAGE = Gtk2::MozEmbed::MouseEvent + +# cf. mozilla-source-1.7.5/embedding/browser/gtk/tests/TestGtkEmbed.cpp +# and /usr/include/mozilla/nsIDOMMouseEvent.h + +# examples in gtk2-perl-xs/Gnome2/xs/GnomeConfig.xs + +# for some reason in pumzilla when I do +# $embed->signal_connect(dom_mouse_click => sub { +# foreach my $arg (@_) { +# print "'", ref($arg), "'\n"; +# } +# return 1; +# }); +# only the first arg prints Gtk2::MozEmbed, +# but the second one apparently isn't a Gtk2::MozEmbed::MouseEvent. +# Do I need to do the stuff in `maps' like for Gtk2::MozEmbed? + +# /* readonly attribute long screenX; */ +# NS_IMETHOD GetScreenX(PRInt32 *aScreenX) = 0; +# /* readonly attribute long screenY; */ +# NS_IMETHOD GetScreenY(PRInt32 *aScreenY) = 0; +# /* readonly attribute long clientX; */ +# NS_IMETHOD GetClientX(PRInt32 *aClientX) = 0; +# /* readonly attribute long clientY; */ +# NS_IMETHOD GetClientY(PRInt32 *aClientY) = 0; + +int +GetScreenX (event) + nsIDOMMouseEvent * event; + ALIAS: + Gtk2::MozEmbed::MouseEvent::GetScreenY = 1 + Gtk2::MozEmbed::MouseEvent::GetClientX = 2 + Gtk2::MozEmbed::MouseEvent::GetClientY = 3 + PREINIT: + PRInt32 pos; + CODE: + switch (ix) { + case 0: event->GetScreenX(&pos); break; + case 1: event->GetScreenY(&pos); break; + case 2: event->GetClientX(&pos); break; + case 3: event->GetClientY(&pos); break; + default: pos = 0; + } + RETVAL = (int)pos; + OUTPUT: + RETVAL + +# /* readonly attribute boolean ctrlKey; */ +# NS_IMETHOD GetCtrlKey(PRBool *aCtrlKey) = 0; +# /* readonly attribute boolean shiftKey; */ +# NS_IMETHOD GetShiftKey(PRBool *aShiftKey) = 0; +# /* readonly attribute boolean altKey; */ +# NS_IMETHOD GetAltKey(PRBool *aAltKey) = 0; +# /* readonly attribute boolean metaKey; */ +# NS_IMETHOD GetMetaKey(PRBool *aMetaKey) = 0; + +gboolean +GetCtrlKey (event) + nsIDOMMouseEvent * event; + ALIAS: + Gtk2::MozEmbed::MouseEvent::GetShiftKey = 1 + Gtk2::MozEmbed::MouseEvent::GetAltKey = 2 + Gtk2::MozEmbed::MouseEvent::GetMetaKey = 3 + PREINIT: + PRBool key; + CODE: + switch (ix) { + case 0: event->GetCtrlKey(&key); break; + case 1: event->GetShiftKey(&key); break; + case 2: event->GetAltKey(&key); break; + case 3: event->GetMetaKey(&key); break; + default: key = 0; + } + RETVAL = (gboolean)key; + OUTPUT: + RETVAL + +# /* readonly attribute unsigned short button; */ +# NS_IMETHOD GetButton(PRUint16 *aButton) = 0; + +int +GetButton (event) + nsIDOMMouseEvent * event; + PREINIT: + PRUint16 button; + CODE: + event->GetButton(&button); + /* XXX: need to convert short to int */ + RETVAL = (int)button; + OUTPUT: + RETVAL + +# uh-oh, need to handle nsIDOMEventTarget type for this... +# /* readonly attribute nsIDOMEventTarget relatedTarget; */ +# NS_IMETHOD GetRelatedTarget(nsIDOMEventTarget * *aRelatedTarget) = 0; + +# XXX: worry about InitMouseEvent later...