RE: Displaying simple HTML in gtkmm app (got it!)
Chris, I've since found out that embedded mozilla is a far easier solution to displaying HTML content, images, etc., than the gtkhtml library (Thanks Murray). So this issue is moot at present. Thanks for your response anyway. Erik. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chris Vine Sent: Saturday, April 23, 2005 8:38 PM To: gtkmm-list@gnome.org Cc: [EMAIL PROTECTED] Subject: Re: Displaying simple HTML in gtkmm app (got it!) On Thursday 21 April 2005 19:06, [EMAIL PROTECTED] wrote: [snip] The other thing that I noticed about this way of implementing this is that you are limited to a single instance of a window that can render HTML. I was starting to create a C++ wrapper class, but found out that the lines: g_signal_connect( G_OBJECT( document ), request_url, G_CALLBACK( gtkhtml::url_requested ), NULL ); g_signal_connect( G_OBJECT( document ), link_clicked, G_CALLBACK( gtkhtml::link_clicked ), NULL ); are proving to be difficult to resolve. How would you connect gtk+ signals to a C++ class instance? That appears to be the question now, for me at least. I am not sure I have understood the question but if relates to making the callback aware of the class instance invoking the callback (say the one in whose constructor the call to g_signal_connect() was made) then pass the address of that instance (the this pointer) as the data argument, which is the last argument and is of type void*, thus: g_signal_connect( G_OBJECT( document ), request_url, G_CALLBACK(gtkhtml::url_requested ), this ); then gtkhtml::url_requested() would use static_cast() to cast its last argument back to a pointer of the relevant type. gtkhtml::url_requested() should have extern C linkage (and made a friend if it needs to have access to the class internals), but it looks as if it is a static class member function, which cannot have C linkage. Using a static member function will work with some compilers (eg g++) but not with others - it is implementation dependent. Chris. -- Summer is y-cumen in, lhude sing, cuccu! Groweth sed and bloweth med, springeth the wude nu. ___ gtkmm-list mailing list gtkmm-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtkmm-list ___ gtkmm-list mailing list gtkmm-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtkmm-list
Re: Displaying simple HTML in gtkmm app (got it!)
On Thursday 21 April 2005 19:06, [EMAIL PROTECTED] wrote: [snip] The other thing that I noticed about this way of implementing this is that you are limited to a single instance of a window that can render HTML. I was starting to create a C++ wrapper class, but found out that the lines: g_signal_connect( G_OBJECT( document ), request_url, G_CALLBACK( gtkhtml::url_requested ), NULL ); g_signal_connect( G_OBJECT( document ), link_clicked, G_CALLBACK( gtkhtml::link_clicked ), NULL ); are proving to be difficult to resolve. How would you connect gtk+ signals to a C++ class instance? That appears to be the question now, for me at least. I am not sure I have understood the question but if relates to making the callback aware of the class instance invoking the callback (say the one in whose constructor the call to g_signal_connect() was made) then pass the address of that instance (the this pointer) as the data argument, which is the last argument and is of type void*, thus: g_signal_connect( G_OBJECT( document ), request_url, G_CALLBACK(gtkhtml::url_requested ), this ); then gtkhtml::url_requested() would use static_cast() to cast its last argument back to a pointer of the relevant type. gtkhtml::url_requested() should have extern C linkage (and made a friend if it needs to have access to the class internals), but it looks as if it is a static class member function, which cannot have C linkage. Using a static member function will work with some compilers (eg g++) but not with others - it is implementation dependent. Chris. -- Summer is y-cumen in, lhude sing, cuccu! Groweth sed and bloweth med, springeth the wude nu. ___ gtkmm-list mailing list gtkmm-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtkmm-list
RE: Re: Displaying simple HTML in gtkmm app (got it!)
On Thu, 2005-04-21 at 14:06 -0400, [EMAIL PROTECTED] wrote: I was starting to create a C++ wrapper class, but found out that the lines: g_signal_connect( G_OBJECT( document ), request_url, G_CALLBACK( gtkhtml::url_requested ),NULL ); g_signal_connect( G_OBJECT( document ), link_clicked, G_CALLBACK( gtkhtml::link_clicked ), NULL ); are proving to be difficult to resolve. How would you connect gtk+ signals to a C++ class instance? That appears to be the question now, for me at least. You should use gmmproc, like the existing *mm projects. But I think gtkmozembedmm is a more sensible way to embed HTML. People are trying to move from gtkhtml to gecko. -- Murray Cumming [EMAIL PROTECTED] www.murrayc.com www.openismus.com ___ gtkmm-list mailing list gtkmm-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtkmm-list
Re: Displaying simple HTML in gtkmm app (got it!)
On Thursday 21 April 2005 12:11, Murray Cumming wrote: You should use gmmproc, like the existing *mm projects. But I think gtkmozembedmm is a more sensible way to embed HTML. People are trying to move from gtkhtml to gecko. Except as I read it, mozembed is gpl not lgpl, also it's much bigger since it's a whole browser. Originally I thought gtkhtml offered a simple way to display html help and reports, but it now does not seem so and now I'm thinking the optimum way is to shell out to user's native browser. Then they are always working in what they are used to and we have the full use of CSS, SVG, etc. But that I guess is OS and window manager specific, maybe quite messy? John ___ gtkmm-list mailing list gtkmm-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtkmm-list
Re: Displaying simple HTML in gtkmm app (got it!)
On Thu, 2005-04-21 at 13:51 -0600, John Taber wrote: On Thursday 21 April 2005 12:11, Murray Cumming wrote: You should use gmmproc, like the existing *mm projects. But I think gtkmozembedmm is a more sensible way to embed HTML. People are trying to move from gtkhtml to gecko. Except as I read it, mozembed is gpl not lgpl, Mozilla is under the Mozilla Public License. I think that's LGPL-like, but please see www.mozilla.org for details. This is not an invitaion to have a big uninformed licensing thread. also it's much bigger since it's a whole browser. It's also on every linux distro. Originally I thought gtkhtml offered a simple way to display html help and reports, but it now does not seem so and now I'm thinking the optimum way is to shell out to user's native browser. Then they are always working in what they are used to and we have the full use of CSS, SVG, etc. But that I guess is OS and window manager specific, maybe quite messy? It's easy with gnome-vfs, and I'm doing the same with Glom. -- Murray Cumming [EMAIL PROTECTED] www.murrayc.com www.openismus.com ___ gtkmm-list mailing list gtkmm-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtkmm-list
Re: Displaying simple HTML in gtkmm app (got it!)
On Friday 15 April 2005 09:46, [EMAIL PROTECTED] wrote: OK, so I got it working now. It's pretty much a hack job, but it'll get me by for now. Erik, thks for the post - using gtkhtml will be really useful for some of us. I'm trying to get this working in a small demo program but struggling: 1) which libs did you include when you compiled? 2) still not sure how you combined the simple c program under gtkmm - could you post the complete code listing (or email it). thks I've declared a class gtkhtml, which is a sub class of Gtk::ScrolledWindow. In this code module, I just include the simple.c source code file like so: extern C { # include simple.c }; And make sure to either remove or commnet out the int main( int argc, char** argv) code Below is the class' CTOR: gtkhtml::gtkhtml( void ) : ScrolledWindow() { // Set properties g_object_set( G_OBJECT( gtk_html_context_get () ), debug_painting, FALSE, NULL); // Create the document document = html_document_new(); g_signal_connect( G_OBJECT( document ), request_url, G_CALLBACK( url_requested ), NULL ); g_signal_connect( G_OBJECT( document ), link_clicked, G_CALLBACK( link_clicked ), NULL ); // And the view view = html_view_new(); html_view_set_document( HTML_VIEW( view ), document ); g_signal_connect( G_OBJECT( view ), request_object, G_CALLBACK( request_object ), NULL ); // ScrolledWindow that's hosting is already created. // Now wrap and add the Gtkhtml widget to the ScrolledWindow Gtk::Widget* GtkmmView = Glib::wrap( view ); add( *GtkmmView ); GtkmmView-show(); } And finally, is the LoadFile method, where you can load a file from local disk and display it in the ScrolledWindow. void gtkhtml::LoadFile( char* Filename ) { load_file( Filename ); } The only other thing is that I had to hack the /usr/include/gtkhtml-2.0/libgtkhtml/css/cssstylesheet.h header file, 'cause the structure below had a field called 'class', which g++ didn't like, so I renamed it '_class': struct _CssTail { CssTailType type; union { struct { HtmlAtom att; CssAttrMatch match; CssAttrVal val; } attr_sel; struct { HtmlAtom id; } id_sel; struct { HtmlAtom _class; } class_sel; struct { HtmlAtom name; } pseudo_sel; } t; }; ___ gtkmm-list mailing list gtkmm-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtkmm-list ___ gtkmm-list mailing list gtkmm-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtkmm-list
RE: Re: Displaying simple HTML in gtkmm app (got it!)
OK, so I got it working now. It's pretty much a hack job, but it'll get me by for now. I've declared a class gtkhtml, which is a sub class of Gtk::ScrolledWindow. In this code module, I just include the simple.c source code file like so: extern C { # include simple.c }; And make sure to either remove or commnet out the int main( int argc, char** argv) code Below is the class' CTOR: gtkhtml::gtkhtml( void ) : ScrolledWindow() { // Set properties g_object_set( G_OBJECT( gtk_html_context_get () ), debug_painting, FALSE, NULL); // Create the document document = html_document_new(); g_signal_connect( G_OBJECT( document ), request_url, G_CALLBACK( url_requested ),NULL ); g_signal_connect( G_OBJECT( document ), link_clicked, G_CALLBACK( link_clicked ), NULL ); // And the view view = html_view_new(); html_view_set_document( HTML_VIEW( view ), document ); g_signal_connect( G_OBJECT( view ), request_object, G_CALLBACK( request_object ), NULL ); // ScrolledWindow that's hosting is already created. // Now wrap and add the Gtkhtml widget to the ScrolledWindow Gtk::Widget*GtkmmView = Glib::wrap( view ); add( *GtkmmView ); GtkmmView-show(); } And finally, is the LoadFile method, where you can load a file from local disk and display it in the ScrolledWindow. void gtkhtml::LoadFile( char* Filename ) { load_file( Filename ); } The only other thing is that I had to hack the /usr/include/gtkhtml-2.0/libgtkhtml/css/cssstylesheet.h header file, 'cause the structure below had a field called 'class', which g++ didn't like, so I renamed it '_class': struct _CssTail { CssTailType type; union { struct { HtmlAtom att; CssAttrMatch match; CssAttrVal val; } attr_sel; struct { HtmlAtom id; } id_sel; struct { HtmlAtom _class; } class_sel; struct { HtmlAtom name; } pseudo_sel; } t; }; ___ gtkmm-list mailing list gtkmm-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtkmm-list