diff -pru dillo-CLEAN/dpi/Makefile.am dillo-WORK/dpi/Makefile.am
--- dillo-CLEAN/dpi/Makefile.am	2007-04-02 04:17:38.000000000 +0200
+++ dillo-WORK/dpi/Makefile.am	2007-04-02 04:17:51.000000000 +0200
@@ -1,4 +1,4 @@
-AM_CFLAGS = @GLIB_CFLAGS@
+AM_CFLAGS = @GLIB_CFLAGS@ @GTK_CFLAGS@
 AM_CXXFLAGS = @GLIB_CFLAGS@
 
 bookmarksdir = $(libdir)/dillo/dpi/bookmarks
@@ -9,6 +9,7 @@ hellodir = $(libdir)/dillo/dpi/hello
 filedir = $(libdir)/dillo/dpi/file
 cookiesdir = $(libdir)/dillo/dpi/cookies
 datauridir = $(libdir)/dillo/dpi/datauri
+tabsdir = $(libdir)/dillo/dpi/tabs
 bookmarks_PROGRAMS = bookmarks.dpi
 downloads_PROGRAMS = downloads.dpi
 ftp_PROGRAMS = ftp.filter.dpi
@@ -17,6 +18,7 @@ hello_PROGRAMS = hello.filter.dpi
 file_PROGRAMS = file.dpi
 cookies_PROGRAMS = cookies.dpi
 datauri_PROGRAMS = datauri.filter.dpi
+tabs_PROGRAMS = tabs.dpi
 
 bookmarks_dpi_LDADD = @GLIB_LIBS@ ../dpip/libDpip.a
 if DLGUI
@@ -30,7 +32,7 @@ hello_filter_dpi_LDADD = @GLIB_LIBS@ ../
 file_dpi_LDADD = @GLIB_LIBS@ @LIBPTHREAD_LIBS@ ../dpip/libDpip.a
 cookies_dpi_LDADD = @GLIB_LIBS@ ../dpip/libDpip.a
 datauri_filter_dpi_LDADD = @GLIB_LIBS@ ../dpip/libDpip.a
-
+tabs_dpi_LDADD = @GLIB_LIBS@ @GTK_LIBS@ ../dpip/libDpip.a
 file_dpi_LDFLAGS = @LIBPTHREAD_LDFLAGS@
 
 bookmarks_dpi_SOURCES = bookmarks.c dpiutil.c dpiutil.h
@@ -45,4 +47,5 @@ hello_filter_dpi_SOURCES = hello.c dpiut
 file_dpi_SOURCES = file.c dpiutil.c dpiutil.h
 cookies_dpi_SOURCES = cookies.c dpiutil.c dpiutil.h
 datauri_filter_dpi_SOURCES = datauri.c dpiutil.c dpiutil.h
+tabs_dpi_SOURCES = tabs.c dpiutil.c dpiutil.h
 
diff -pru dillo-CLEAN/dpi/tabs.c dillo-WORK/dpi/tabs.c
--- dillo-CLEAN/dpi/tabs.c	2007-04-02 04:18:05.000000000 +0200
+++ dillo-WORK/dpi/tabs.c	2007-04-02 04:17:51.000000000 +0200
@@ -0,0 +1,307 @@
+/* example-start notebook notebook.c */
+
+#include <stdio.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h> 
+
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <glib.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <ctype.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/un.h>
+#include <time.h>
+#include <netdb.h>
+#include <fcntl.h>
+#include <signal.h>
+
+
+
+/* This function rotates the position of the tabs */
+void rotate_book( GtkButton   *button,
+                  GtkNotebook *notebook )
+{
+   gtk_notebook_set_tab_pos (notebook, (notebook->tab_pos +1) %4);
+}
+
+/* Add/Remove the page tabs and the borders */
+void tabsborder_book( GtkButton   *button,
+                      GtkNotebook *notebook )
+{
+    gint tval = FALSE;
+    gint bval = FALSE;
+    if (notebook->show_tabs == 0)
+            tval = TRUE; 
+    if (notebook->show_border == 0)
+            bval = TRUE;
+    
+    gtk_notebook_set_show_tabs (notebook, tval);
+    gtk_notebook_set_show_border (notebook, bval);
+}
+
+/* Remove a page from the notebook */
+void remove_book( GtkButton   *button,
+                  GtkNotebook *notebook )
+{
+    gint page;
+    
+    page = gtk_notebook_get_current_page(notebook);
+    gtk_notebook_remove_page (notebook, page);
+    /* Need to refresh the widget -- 
+     This forces the widget to redraw itself. */
+    gtk_widget_draw(GTK_WIDGET(notebook), NULL);
+}
+
+gint delete( GtkWidget *widget,
+             GtkWidget *event,
+             gpointer   data )
+{
+    gtk_main_quit();
+    return(FALSE);
+}
+
+void input_callback(gpointer data, gint fd, GdkInputCondition condition) {
+   ssize_t st;
+   gchar buf[16384];
+   GtkWidget *dillo_socket;
+   GtkWidget *label;
+   GtkWidget *notebook;
+//   guint32 xid;
+   GtkWidget *event_box;
+
+   struct sockaddr_un spun;
+   int temp_sock_descriptor;
+   unsigned int address_size;
+
+   address_size = sizeof(struct sockaddr_un);
+      temp_sock_descriptor =
+         accept(STDIN_FILENO, (struct sockaddr *)&spun, &address_size);
+      if (temp_sock_descriptor == -1) {
+         perror("[accept]");
+//         exit(1);
+      }
+
+   notebook = data;
+   
+   /* can't use fread() */
+   do
+      st = read(temp_sock_descriptor, buf, 16384);
+   while (st < 0 && errno == EINTR);
+   
+   if (st == -1)
+      perror("[sock_handler_read]");
+
+   printf("[tabs.dpi]: %s", buf);
+
+	                                      
+
+   dillo_socket = gtk_socket_new();
+
+   label = gtk_label_new ("Dillo:");
+   gtk_widget_show (label);
+
+//   event_box = gtk_event_box_new();
+//   gtk_container_add(GTK_CONTAINER(event_box), label);
+//   gtk_widget_show (event_box);
+
+//   gtk_notebook_append_page (GTK_NOTEBOOK (notebook), dillo_socket, event_box);
+   gtk_notebook_append_page (GTK_NOTEBOOK (notebook), dillo_socket, label);
+   gtk_notebook_set_homogeneous_tabs(GTK_NOTEBOOK (notebook), TRUE);											  
+
+   gtk_widget_realize(dillo_socket);
+   gtk_widget_show(dillo_socket);
+//gtk_signal_connect(GTK_OBJECT(dillo_socket),"destroy",GTK_SIGNAL_FUNC(socket_destroy_cb),??);
+													 
+													 
+//   xid = GDK_WINDOW_XWINDOW(dillo_socket->window);
+//   printf("[tabs.dpi]: %d", GDK_WINDOW_XWINDOW(xid));
+			
+  
+   st = sprintf(buf, "<dpi cmd='new_window_answer' xid='%ld' >",
+                GDK_WINDOW_XWINDOW(dillo_socket->window));
+   printf("[tabs.dpi]: %s", buf);
+   
+   write(temp_sock_descriptor, buf, st);
+}
+					  
+					  
+
+/*
+ * Task: given a tag and an attribute name, return its value.
+ *       (character stuffing is removed here)
+ * Return value: the attribute value, or NULL if not present or malformed.
+ * (copied from bookmarks.c)
+ */
+char *Get_attr_value(char *tag, size_t tagsize, char *attrname)
+{
+   char *p, *q, *ltag, quote, *start, *val = NULL;
+
+   ltag = g_strndup(tag, tagsize);
+   if ((p = strstr(ltag, attrname)) &&
+       (p = strchr(p, '=')) &&
+       (p = strpbrk(p, "'\"")) ) {
+      quote = *p;
+      start = ++p;
+      while ((q = strchr(p, quote)) && q[1] == quote)
+         p = q + 2;
+      if (q) {
+         val = g_strndup(start, (guint)(q - start));
+         for (p = q = val; (*q = *p); ++p, ++q)
+            if ((*p == '"' || *p == '\'') && p[1] == p[0])
+               ++p;
+      }
+   }
+   g_free(ltag);
+
+   return val;
+}
+
+
+
+int main( int argc,
+          char *argv[] )
+{
+    GtkWidget *window;
+    GtkWidget *button;
+    GtkWidget *table;
+    GtkWidget *notebook;
+//    GtkWidget *frame;
+//    GtkWidget *label;
+//    GtkWidget *checkbutton;
+//    int i;
+//    char bufferf[32];
+//    char bufferl[32];
+
+
+   gtk_init (&argc, &argv);
+
+    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+    
+    gtk_signal_connect (GTK_OBJECT (window), "delete_event",
+                        GTK_SIGNAL_FUNC (delete), NULL);
+    
+//    gtk_container_set_border_width (GTK_CONTAINER (window), 10);
+   
+    table = gtk_table_new(3,6,FALSE);
+    gtk_container_add (GTK_CONTAINER (window), table);
+
+    /* Create a new notebook, place the position of the tabs */
+    notebook = gtk_notebook_new ();
+    gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
+   gtk_notebook_set_homogeneous_tabs(GTK_NOTEBOOK (notebook), TRUE);											  
+   gtk_table_attach_defaults(GTK_TABLE(table), notebook, 0,6,0,1);
+    gtk_widget_show(notebook);
+    
+   gdk_input_add(STDIN_FILENO, GDK_INPUT_READ,input_callback, notebook);
+
+
+    /* Let's append a bunch of pages to the notebook */
+//    for (i=0; i < 5; i++) {
+//        sprintf(bufferf, "Append Frame %d", i+1);
+//        sprintf(bufferl, "Page %d", i+1);
+//        
+//        frame = gtk_frame_new (bufferf);
+//        gtk_container_set_border_width (GTK_CONTAINER (frame), 10);
+//        gtk_widget_set_usize (frame, 100, 75);
+//        gtk_widget_show (frame);
+//        
+//        label = gtk_label_new (bufferf);
+//        gtk_container_add (GTK_CONTAINER (frame), label);
+//        gtk_widget_show (label);
+//        
+//        label = gtk_label_new (bufferl);
+//        gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label);
+//    }
+      
+    /* Now let's add a page to a specific spot */
+//    checkbutton = gtk_check_button_new_with_label ("Check me please!");
+//    gtk_widget_set_usize(checkbutton, 100, 75);
+//    gtk_widget_show (checkbutton);
+   
+//    label = gtk_label_new ("Add page");
+//    gtk_notebook_insert_page (GTK_NOTEBOOK (notebook), checkbutton, label, 2);
+    
+    /* Now finally let's prepend pages to the notebook */
+//    for (i=0; i < 5; i++) {
+//        sprintf(bufferf, "Prepend Frame %d", i+1);
+//        sprintf(bufferl, "PPage %d", i+1);
+//        
+//        frame = gtk_frame_new (bufferf);
+//        gtk_container_set_border_width (GTK_CONTAINER (frame), 10);
+//        gtk_widget_set_usize (frame, 100, 75);
+//        gtk_widget_show (frame);
+        
+//        label = gtk_label_new (bufferf);
+//        gtk_container_add (GTK_CONTAINER (frame), label);
+//        gtk_widget_show (label);
+        
+//        label = gtk_label_new (bufferl);
+//        gtk_notebook_prepend_page (GTK_NOTEBOOK(notebook), frame, label);
+//    }
+    
+    /* Set what page to start at (page 4) */
+//    gtk_notebook_set_page (GTK_NOTEBOOK(notebook), 3);
+
+    /* Create a bunch of buttons */
+    button = gtk_button_new_with_label ("close");
+    gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
+                               GTK_SIGNAL_FUNC (delete), NULL);
+    gtk_table_attach_defaults(GTK_TABLE(table), button, 0,1,1,2);
+    gtk_widget_show(button);
+    
+    button = gtk_button_new_with_label ("next page");
+    gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
+                               (GtkSignalFunc) gtk_notebook_next_page,
+                               GTK_OBJECT (notebook));
+    gtk_table_attach_defaults(GTK_TABLE(table), button, 1,2,1,2);
+    gtk_widget_show(button);
+    
+    button = gtk_button_new_with_label ("prev page");
+    gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
+                               (GtkSignalFunc) gtk_notebook_prev_page,
+                               GTK_OBJECT (notebook));
+    gtk_table_attach_defaults(GTK_TABLE(table), button, 2,3,1,2);
+    gtk_widget_show(button);
+    
+    button = gtk_button_new_with_label ("tab position");
+    gtk_signal_connect (GTK_OBJECT (button), "clicked",
+                        (GtkSignalFunc) rotate_book,
+                        GTK_OBJECT(notebook));
+    gtk_table_attach_defaults(GTK_TABLE(table), button, 3,4,1,2);
+    gtk_widget_show(button);
+    
+    button = gtk_button_new_with_label ("tabs/border on/off");
+    gtk_signal_connect (GTK_OBJECT (button), "clicked",
+                        (GtkSignalFunc) tabsborder_book,
+                        GTK_OBJECT (notebook));
+    gtk_table_attach_defaults(GTK_TABLE(table), button, 4,5,1,2);
+    gtk_widget_show(button);
+    
+    button = gtk_button_new_with_label ("remove page");
+    gtk_signal_connect (GTK_OBJECT (button), "clicked",
+                        (GtkSignalFunc) remove_book,
+                        GTK_OBJECT(notebook));
+    gtk_table_attach_defaults(GTK_TABLE(table), button, 5,6,1,2);
+    gtk_widget_show(button);
+    
+    gtk_widget_show(table);
+    gtk_widget_show(window);
+    
+    gtk_main ();
+    
+    return(0);
+}
+/* example-end */
+
diff -pru dillo-CLEAN/src/dillo.c dillo-WORK/src/dillo.c
--- dillo-CLEAN/src/dillo.c	2007-04-02 04:17:38.000000000 +0200
+++ dillo-WORK/src/dillo.c	2007-04-02 04:17:51.000000000 +0200
@@ -81,6 +81,7 @@ enum {
  * Global variables from command line options;
  */
 gboolean dillo_dbg_rendering = FALSE;
+gboolean ask_xid = FALSE;
 
 /*
  * Forward declarations
@@ -239,6 +240,9 @@ gint main(int argc, char *argv[])
      case DILLO_CLI_XID:
         if (opt_argv[0][0] >= '0' && opt_argv[0][0] <= '9') {
            xid = strtol(opt_argv[0], NULL, 10);
+        } else if (opt_argv[0][0] == 'a' || opt_argv[0][0] == 'A'){
+	   /* -xid ask */
+	   ask_xid = TRUE;
         } else {
            g_printerr("Error: the XID must be an unsigned decimal numerical "
                       "value.\nThe offending value was: %s\n", opt_argv[0]);
diff -pru dillo-CLEAN/src/dillo.h dillo-WORK/src/dillo.h
--- dillo-CLEAN/src/dillo.h	2007-04-02 04:17:38.000000000 +0200
+++ dillo-WORK/src/dillo.h	2007-04-02 04:17:51.000000000 +0200
@@ -5,5 +5,6 @@
 #include "web.h"
 
 extern gboolean dillo_dbg_rendering;
+extern gboolean ask_xid;
 
 #endif /* __DILLO_H__ */
diff -pru dillo-CLEAN/src/interface.c dillo-WORK/src/interface.c
--- dillo-CLEAN/src/interface.c	2007-04-02 04:17:38.000000000 +0200
+++ dillo-WORK/src/interface.c	2007-04-02 04:17:51.000000000 +0200
@@ -859,6 +859,22 @@ a_Interface_browser_window_new(gint widt
    /* initialize nav_stack struct in browser_window struct */
    a_Nav_init(bw);
 
+   if (ask_xid) {
+      char *dpip_tag, *s, *cmd;
+      
+      /* ask xid to tabs.dpi */
+      cmd = a_Dpip_build_cmd("cmd=%s", "new_window");
+      dpip_tag = a_Dpi_send_blocking_cmd("tabs", cmd);
+
+      if (dpip_tag != NULL) {
+         s = a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "xid");
+	 xid = strtol(s, NULL, 10);
+	 g_free(dpip_tag);
+	 g_free(s);
+      }
+      g_free(cmd);
+   }
+
    if (!xid)
        bw->main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    else
