Re: [libcroco-list] sewfox minimal application



Hi

Here is a new version that dumps the box model tree on stdout 

Le mar 17/02/2004 à 17:04, Stephane Bonhomme a écrit :
> Hi all
> 
> Here is a minimal gtk application that displays a xml file using a css
> stylesheet with sewfox. 
> 
> It only depends on libsewfox and I hope it will be useful for debugging
> purpose
> 
> It could be great if it were included in the test dir of the sewfox
> source tree. 
> 
>  
> Stephane
-- 
    Stéphane Bonhomme - Formations, Conseil et Réalisations
 Ingénierie Documentaire - Technologies Web - Logiciels Libres
   s bonhomme wanadoo fr - http://perso.wanadoo.fr/s.bonhomme
              04 76 17 09 40 / 06 88 57 27 08

#include <stdio.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <sewfox/sx-box-view.h>




static gboolean delete_event( GtkWidget *widget,
                              GdkEvent  *event,
                              gpointer   data )
{

    gtk_main_quit ();
    return FALSE;
}

static void usage () {
  g_print ("usage : minifox <xmlfile> <cssfile>\n");
}

int main(int argc, char **argv) {
  GtkWidget *window;
  GtkWidget *scroll;
  SXBoxView * layout;
  SXBoxModel *box_model = NULL ;
  enum CRStatus status = CR_OK ;

 
  gtk_init (&argc, &argv);
  if (argc != 3) {
    usage ();
    return 1;
  }
  
  g_print ("Rendering xml: %s - css: %s \n",argv[1],argv[2]);
  layout = sx_box_view_new_from_xml_css_paths(argv[1], argv[2]);

  if (layout != NULL ) {
    /* dump box model on stdout */
    status = sx_box_view_get_box_model(layout, &box_model) ;
    if (status == CR_OK && box_model) {
      sx_box_dump_to_file ((SXBox*)box_model, 2, stdout) ;
    }

    /* builds app window */
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    g_signal_connect (G_OBJECT (window), "delete_event",
		      G_CALLBACK (delete_event), NULL);
    
    scroll = gtk_scrolled_window_new (NULL, NULL) ;
    gtk_container_add (GTK_CONTAINER (window), scroll) ;

    gtk_container_add (GTK_CONTAINER (scroll), GTK_WIDGET (layout)) ;
  
    gtk_widget_show_all (window);
    gtk_main ();
  } else {
    g_print ("error during sewfox rendering\n");
    return 1;
  }

  return 0;
}


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