Re: Displaying simple HTML in gtkmm app (got it!)



On Friday 15 April 2005 09:46, erik_ohrnberger dme net 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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]