Malcolm Poole wrote:
Marc Weustink wrote:
Michalis Kamburelis wrote:
Malcolm Poole wrote:
I have been trying to translate gtkmozembed.h, in the hope that I
could produce FreePascal/Gtk programs incorporating an HTML
browser. Has anyone else tried this or am I trying to do the
impossible?
I have an URL [http://delphi.mozdev.org/] on my "list of interesting
URLs that I should investigate when I'll have some time" :) I didn't
investigate it yet, but maybe there's something useful for you.
I hadn't found this url before. They seem to be more interested in
producing extensions for Mozilla using Delphi than integrating Mozilla
into Delphi. But maybe I missed something.. Worth another visit.
function gtk_moz_embed_new:PGtkWidget;cdecl;external
external_library name 'gtk_moz_embed_new';
Can anyone suggest what is wrong?
Your translation seems OK, so I would look for errors in other places.
Thanks
To Malcolm, how do you call this function ?
var
...
mozilla : PGtkWidget;
function create_main_window : PMainWindow;
begin
< create window>
<create gtk_hbox>
mozilla := gtk_moz_embed_new;
<add mozilla to container>
end;
I've tried declaring mozilla as PGtkMozEmbed and also casting the
pointer returned from the function but it seems to be actually calling
the function that causes the error. I also tried creating the widget
by passing the result of gtk_moz_embed_get_type to gtk_widget_new but
with exactly the same result.
The widget should work as I have managed to create a very basic
browser in C, but what seems to be exactly the same code in Pascal
causes an exception unless the line containing gtk_moz_embed_new is
commented out.
I've tried all the compiler directives that seem remotely likely but
with no success. I'm all out of ideas and really don't want to start
writing seriuos programs in C : -(
I'm not 100% sure but I tinkered around with the GtkMozEmbed control a
while ago and I think it is a gtk2 widget and not compatible with gtk1.
I've attached the converted header file that I had started. I don't even
know if it will compile for you, as I never finished it.
HTH
Andrew
unit gtkmozembed;
interface
uses gtk2, glib2;
{
Automatically converted by H2Pas 0.99.16 from gtkmozembed.h
The following command line parameters were used:
-t
-p
-d
gtkmozembed.h
}
{ Pointers to basic pascal types, inserted by h2pas conversion program.}
{$LINKLIB gtkembedmoz}
Type
PGtkMozEmbed = ^TGtkMozEmbed;
TGtkMozEmbed = record
bin : TGtkBin;
data : pointer;
end;
PGtkMozEmbedClass = ^TGtkMozEmbedClass;
TGtkMozEmbedClass = record
parent_class : TGtkBinClass;
link_message : procedure (embed:PGtkMozEmbed);cdecl;
js_status : procedure (embed:PGtkMozEmbed);
location : procedure (embed:PGtkMozEmbed);
title : procedure (embed:PGtkMozEmbed);
progress : procedure (embed:PGtkMozEmbed; curprogress:gint;
maxprogress:gint);
progress_all : procedure (embed:PGtkMozEmbed; aURI:Pchar;
curprogress:gint; maxprogress:gint);
net_state : procedure (embed:PGtkMozEmbed; state:gint; status:guint);
net_state_all : procedure (embed:PGtkMozEmbed; aURI:Pchar;
state:gint; status:guint);
net_start : procedure (embed:PGtkMozEmbed);
net_stop : procedure (embed:PGtkMozEmbed);
new_window : procedure (embed:PGtkMozEmbed; newEmbed:PGtkMozEmbed;
chromemask:guint);
visibility : procedure (embed:PGtkMozEmbed; visibility:gboolean);
destroy_brsr : procedure (embed:PGtkMozEmbed);
open_uri : function (embed:PGtkMozEmbed; aURI:Pchar):gint;
size_to : procedure (embed:PGtkMozEmbed; width:gint; height:gint);
dom_key_down : function (embed:PGtkMozEmbed; dom_event:gpointer):gint;
dom_key_press : function (embed:PGtkMozEmbed;
dom_event:gpointer):gint;
dom_key_up : function (embed:PGtkMozEmbed; dom_event:gpointer):gint;
dom_mouse_down : function (embed:PGtkMozEmbed;
dom_event:gpointer):gint;
dom_mouse_up : function (embed:PGtkMozEmbed; dom_event:gpointer):gint;
dom_mouse_click : function (embed:PGtkMozEmbed;
dom_event:gpointer):gint;
dom_mouse_dbl_click : function (embed:PGtkMozEmbed;
dom_event:gpointer):gint;
dom_mouse_over : function (embed:PGtkMozEmbed;
dom_event:gpointer):gint;
dom_mouse_out : function (embed:PGtkMozEmbed;
dom_event:gpointer):gint;
security_change : procedure (embed:PGtkMozEmbed; request:gpointer;
state:guint);
status_change : procedure (embed:PGtkMozEmbed; request:gpointer;
status:gint; message:gpointer);
end;
type
PGtkMozEmbedProgressFlags = ^TGtkMozEmbedProgressFlags;
TGtkMozEmbedProgressFlags = (GTK_MOZ_EMBED_FLAG_START :=
1,GTK_MOZ_EMBED_FLAG_REDIRECTING := 2,
GTK_MOZ_EMBED_FLAG_TRANSFERRING := 4,
GTK_MOZ_EMBED_FLAG_NEGOTIATING := 8,
GTK_MOZ_EMBED_FLAG_STOP := 16,GTK_MOZ_EMBED_FLAG_IS_REQUEST := 65536,
GTK_MOZ_EMBED_FLAG_IS_DOCUMENT := 131072,
GTK_MOZ_EMBED_FLAG_IS_NETWORK := 262144,
GTK_MOZ_EMBED_FLAG_IS_WINDOW := 524288
);
{ These are from various networking headers }
{ NS_ERROR_UNKNOWN_HOST }
{ NS_ERROR_CONNECTION_REFUSED }
{ NS_ERROR_NETTIMEOUT }
{ NS_BINDING_ABORTED }
PGtkMozEmbedStatusFlags = ^TGtkMozEmbedStatusFlags;
TGtkMozEmbedStatusFlags = (GTK_MOZ_EMBED_STATUS_FAILED_DNS := 2152398878,
GTK_MOZ_EMBED_STATUS_FAILED_CONNECT := 2152398861,
GTK_MOZ_EMBED_STATUS_FAILED_TIMEOUT := 2152398862,
GTK_MOZ_EMBED_STATUS_FAILED_USERCANCELED := 2152398850
);
{ These used to be straight out of nsIWebNavigation.h until the API
changed. Now there's a mapping table that maps these values to the
internal values. }
PGtkMozEmbedReloadFlags = ^TGtkMozEmbedReloadFlags;
TGtkMozEmbedReloadFlags = (GTK_MOZ_EMBED_FLAG_RELOADNORMAL := 0,
GTK_MOZ_EMBED_FLAG_RELOADBYPASSCACHE := 1,
GTK_MOZ_EMBED_FLAG_RELOADBYPASSPROXY := 2,
GTK_MOZ_EMBED_FLAG_RELOADBYPASSPROXYANDCACHE := 3,
GTK_MOZ_EMBED_FLAG_RELOADCHARSETCHANGE := 4
);
{ These are straight out of nsIWebBrowserChrome.h }
PGtkMozEmbedChromeFlags = ^TGtkMozEmbedChromeFlags;
TGtkMozEmbedChromeFlags = (GTK_MOZ_EMBED_FLAG_DEFAULTCHROME := 1,
GTK_MOZ_EMBED_FLAG_WINDOWBORDERSON := 2,
GTK_MOZ_EMBED_FLAG_WINDOWCLOSEON := 4,
GTK_MOZ_EMBED_FLAG_WINDOWRESIZEON := 8,
GTK_MOZ_EMBED_FLAG_MENUBARON := 16,
GTK_MOZ_EMBED_FLAG_TOOLBARON := 32,
GTK_MOZ_EMBED_FLAG_LOCATIONBARON := 64,
GTK_MOZ_EMBED_FLAG_STATUSBARON := 128,
GTK_MOZ_EMBED_FLAG_PERSONALTOOLBARON := 256,
GTK_MOZ_EMBED_FLAG_SCROLLBARSON := 512,
GTK_MOZ_EMBED_FLAG_TITLEBARON := 1024,
GTK_MOZ_EMBED_FLAG_EXTRACHROMEON := 2048,
GTK_MOZ_EMBED_FLAG_ALLCHROME := 4094,
GTK_MOZ_EMBED_FLAG_WINDOWRAISED := 33554432,
GTK_MOZ_EMBED_FLAG_WINDOWLOWERED := 67108864,
GTK_MOZ_EMBED_FLAG_CENTERSCREEN := 134217728,
GTK_MOZ_EMBED_FLAG_DEPENDENT := 268435456,
GTK_MOZ_EMBED_FLAG_MODAL := 536870912,GTK_MOZ_EMBED_FLAG_OPENASDIALOG :=
1073741824,
GTK_MOZ_EMBED_FLAG_OPENASCHROME := 2147483648
);
{ this is a singleton object that you can hook up to to get signals
that are not handed out on a per widget basis. }
//TGtkMozEmbedSingleClass = TGtkMozEmbedSingleClass;
PGtkMozEmbedSingle = ^TGtkMozEmbedSingle;
TGtkMozEmbedSingle = record
_object : TGtkObject;
data : pointer;
end;
PGtkMozEmbedSingleClass = ^TGtkMozEmbedSingleClass;
TGtkMozEmbedSingleClass = record
parent_class : TGtkObjectClass;
new_window_orphan : procedure (embed:PGtkMozEmbedSingle;
newEmbed:PGtkMozEmbed; chromemask:guint);cdecl;
end;
{$IFDEF FPC}
{$PACKRECORDS C}
{$ENDIF}
{
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Christopher Blizzard.
* Portions created by Christopher Blizzard are Copyright (C)
* Christopher Blizzard. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <[EMAIL PROTECTED]>
* Ramiro Estrugo <[EMAIL PROTECTED]>
}
{$ifndef gtkmozembed_h}
{$define gtkmozembed_h}
{ C++ extern C conditionnal removed }
{ Tcplusplus }
//{$include <stddef.h>}
//{$include <gtk/gtk.h>}
{ was #define dname def_expr }
function GTK_TYPE_MOZ_EMBED : longint;
{ return type might be wrong }
{ was #define dname(params) para_def_expr }
{ argument types are unknown }
{ return type might be wrong }
function GTK_MOZ_EMBED(obj : pointer) : pointer;
{ was #define dname(params) para_def_expr }
{ argument types are unknown }
{ return type might be wrong }
function GTK_MOZ_EMBED_CLASS(klass : pointer) : pointer;
{ was #define dname(params) para_def_expr }
{ argument types are unknown }
{ return type might be wrong }
function GTK_IS_MOZ_EMBED(obj : pointer) : gboolean;
{ was #define dname(params) para_def_expr }
{ argument types are unknown }
{ return type might be wrong }
function GTK_IS_MOZ_EMBED_CLASS(klass : pointer) : gboolean;
function gtk_moz_embed_get_type:TGtkType;cdecl;external;
function gtk_moz_embed_new:PGtkWidget;cdecl;external;
procedure gtk_moz_embed_push_startup;cdecl;external;
procedure gtk_moz_embed_poPstartup;cdecl;external;
procedure gtk_moz_embed_set_comPpath(aPath:Pchar);cdecl;external;
procedure gtk_moz_embed_set_profile_path(aDir:Pchar;
aName:Pchar);cdecl;external;
(* Const before type ignored *)
procedure gtk_moz_embed_load_url(embed:PGtkMozEmbed;
url:Pchar);cdecl;external;
procedure gtk_moz_embed_stoPload(embed:PGtkMozEmbed);cdecl;external;
function
gtk_moz_embed_can_go_back(embed:PGtkMozEmbed):gboolean;cdecl;external;
function
gtk_moz_embed_can_go_forward(embed:PGtkMozEmbed):gboolean;cdecl;external;
procedure gtk_moz_embed_go_back(embed:PGtkMozEmbed);cdecl;external;
procedure gtk_moz_embed_go_forward(embed:PGtkMozEmbed);cdecl;external;
(* Const before type ignored *)
(* Const before type ignored *)
(* Const before type ignored *)
procedure gtk_moz_embed_render_data(embed:PGtkMozEmbed; data:Pchar;
len:guint32; base_uri:Pchar; mime_type:Pchar);cdecl;external;
(* Const before type ignored *)
(* Const before type ignored *)
procedure gtk_moz_embed_open_stream(embed:PGtkMozEmbed; base_uri:Pchar;
mime_type:Pchar);cdecl;external;
(* Const before type ignored *)
procedure gtk_moz_embed_append_data(embed:PGtkMozEmbed; data:Pchar;
len:guint32);cdecl;external;
procedure gtk_moz_embed_close_stream(embed:PGtkMozEmbed);cdecl;external;
function
gtk_moz_embed_get_link_message(embed:PGtkMozEmbed):Pchar;cdecl;external;
function gtk_moz_embed_get_js_status(embed:PGtkMozEmbed):Pchar;cdecl;external;
function gtk_moz_embed_get_title(embed:PGtkMozEmbed):Pchar;cdecl;external;
function gtk_moz_embed_get_location(embed:PGtkMozEmbed):Pchar;cdecl;external;
procedure gtk_moz_embed_reload(embed:PGtkMozEmbed;
flags:gint32);cdecl;external;
procedure gtk_moz_embed_set_chrome_mask(embed:PGtkMozEmbed;
flags:guint32);cdecl;external;
function
gtk_moz_embed_get_chrome_mask(embed:PGtkMozEmbed):guint32;cdecl;external;
{ enum types }
{ was #define dname def_expr }
function GTK_TYPE_MOZ_EMBED_PROGRESS_FLAGS : longint;
{ return type might be wrong }
{ was #define dname def_expr }
function GTK_TYPE_MOZ_EMBED_STATUS_ENUMS : longint;
{ return type might be wrong }
{ was #define dname def_expr }
function GTK_TYPE_MOZ_EMBED_RELOAD_FLAGS : longint;
{ return type might be wrong }
{ was #define dname def_expr }
function GTK_TYPE_MOZ_EMBED_CHROME_FLAGS : longint;
{ return type might be wrong }
// function gtk_moz_embed_progress_flags_get_type:TGtkType;cdecl;external;
// function gtk_moz_embed_status_enums_get_type:TGtkType;cdecl;external;
// function gtk_moz_embed_reload_flags_get_type:TGtkType;cdecl;external;
// function gtk_moz_embed_chrome_flags_get_type:TGtkType;cdecl;external;
{ These are straight out of nsIWebProgressListener.h }
function gtk_moz_embed_single_get:PGtkMozEmbedSingle;cdecl;external;
{ C++ end of extern C conditionnal removed }
{ Tcplusplus }
{$endif}
{ gtkmozembed_h }
implementation
{ was #define dname def_expr }
function GTK_TYPE_MOZ_EMBED : longint;
{ return type might be wrong }
begin
GTK_TYPE_MOZ_EMBED:=gtk_moz_embed_get_type;
end;
{ was #define dname(params) para_def_expr }
{ argument types are unknown }
{ return type might be wrong }
function GTK_MOZ_EMBED(obj : pointer) : pointer;
begin
GTK_MOZ_EMBED:=GTK_CHECK_CAST(obj,GTK_TYPE_MOZ_EMBED);
end;
{ was #define dname(params) para_def_expr }
{ argument types are unknown }
{ return type might be wrong }
function GTK_MOZ_EMBED_CLASS(klass : pointer) : pointer;
begin
GTK_MOZ_EMBED_CLASS:=GTK_CHECK_CLASS_CAST(klass,GTK_TYPE_MOZ_EMBED);
end;
{ was #define dname(params) para_def_expr }
{ argument types are unknown }
{ return type might be wrong }
function GTK_IS_MOZ_EMBED(obj : pointer) : gboolean;
begin
GTK_IS_MOZ_EMBED:=GTK_CHECK_TYPE(obj,GTK_TYPE_MOZ_EMBED);
end;
{ was #define dname(params) para_def_expr }
{ argument types are unknown }
{ return type might be wrong }
function GTK_IS_MOZ_EMBED_CLASS(klass : pointer) : gboolean;
begin
GTK_IS_MOZ_EMBED_CLASS:=GTK_CHECK_CLASS_TYPE(klass,GTK_TYPE_MOZ_EMBED);
end;
{ was #define dname def_expr }
function GTK_TYPE_MOZ_EMBED_PROGRESS_FLAGS : longint;
{ return type might be wrong }
begin
//
GTK_TYPE_MOZ_EMBED_PROGRESS_FLAGS:=gtk_moz_embed_progress_flags_get_type;
end;
{ was #define dname def_expr }
function GTK_TYPE_MOZ_EMBED_STATUS_ENUMS : longint;
{ return type might be wrong }
begin
// GTK_TYPE_MOZ_EMBED_STATUS_ENUMS:=gtk_moz_embed_status_enums_get_type;
end;
{ was #define dname def_expr }
function GTK_TYPE_MOZ_EMBED_RELOAD_FLAGS : longint;
{ return type might be wrong }
begin
// GTK_TYPE_MOZ_EMBED_RELOAD_FLAGS:=gtk_moz_embed_reload_flags_get_type;
end;
{ was #define dname def_expr }
function GTK_TYPE_MOZ_EMBED_CHROME_FLAGS : longint;
{ return type might be wrong }
begin
// GTK_TYPE_MOZ_EMBED_CHROME_FLAGS:=gtk_moz_embed_chrome_flags_get_type;
end;
end.