--- xfburn-data-composition.c.orig	2008-07-15 17:10:00.000000000 +0200
+++ xfburn-data-composition.c	2008-08-28 12:31:48.000000000 +0200
@@ -1674,24 +1674,40 @@
 }
 
 static void
-fill_image_with_composition (GtkTreeModel *model, IsoImage *image, IsoDir * parent, GtkTreeIter *iter)
-{
+fill_image_with_composition (GtkTreeModel *model, IsoImage *image, IsoDir * parent, GtkTreeIter *iter){
   do {
       DataCompositionEntryType type;
       gchar *name = NULL;
       gchar *src = NULL;
       IsoNode *node = NULL;
       IsoDir *dir = NULL;
-      int r;
+      int r, skipped;
       
+      skipped=0;
       gtk_tree_model_get (model, iter, DATA_COMPOSITION_COLUMN_TYPE, &type,
 			  DATA_COMPOSITION_COLUMN_CONTENT, &name, DATA_COMPOSITION_COLUMN_PATH, &src, -1);
 
       if (type == DATA_COMPOSITION_TYPE_DIRECTORY)
         r = iso_tree_add_new_dir (parent, name, &dir);
-      else
-        r = iso_tree_add_node (image, parent, src, &node);
-
+      else {
+        gchar * src_name=NULL;
+	src_name=strrchr(src,'/');
+	// do not include /isolinux/boot.cat into bootable cd (will be created by iso_image_set_boot_image)
+	if( (NULL != src_name && 0 == strcmp("/boot.cat",src_name))
+	    && (0==strcmp("isolinux",iso_node_get_name((IsoNode *)parent)))
+	    // is node isolinux a sub node of root node?
+	    && (iso_node_get_parent((IsoNode *)parent)==iso_node_get_parent((IsoNode *)iso_node_get_parent((IsoNode *)parent)))
+	    ) {
+		if (xfburn_settings_get_boolean ("is-bootable", TRUE)) {
+		    skipped = 1;
+		    r = 0;
+		    printf("info: bootable cd: /isolinux/boot.cat will be replaced by newly created version.\n");
+		} else
+    		    r = iso_tree_add_node (image, parent, src, &node);
+	} else {
+    	    r = iso_tree_add_node (image, parent, src, &node);
+	}
+      }
       if (r < 0) {
         if (r == ISO_NULL_POINTER)
           g_error ("Failed adding %s as a node to the image: null pointer!", src);
@@ -1704,7 +1720,7 @@
       }
 
       /* FIXME: do we need to call iso_node_ref on node? Probably not... */
-      if (type != DATA_COMPOSITION_TYPE_DIRECTORY)
+      if (skipped == 0 && type != DATA_COMPOSITION_TYPE_DIRECTORY)
         iso_node_set_name (node, name);
 
       g_free (name);
@@ -1741,6 +1757,76 @@
     fill_image_with_composition (model, image, iso_image_get_root (image), &iter);
   }
 
+  // check if boot catalog, file boot_cat, exists in newly created iso image:
+  // already done in fill_image_with_composition
+
+  if (xfburn_settings_get_boolean ("is-bootable", TRUE)) {
+        /* adds El-Torito boot info. Tunned for isolinux */
+        ElToritoBootImage *bootimg;
+	int result;
+	gchar *boot_folder="/isolinux"; // path in image (NOT in /boot)
+	gchar *boot_foldername=boot_folder+1;
+	// do not change /isolinux/boot_cat (hardcoded into fill_image_with_composition)
+	gchar *boot_cat="/isolinux/boot.cat"; // path in image (NOT in /boot)
+	gchar *boot_catname="boot.cat";
+	gchar *boot_img="/isolinux/isolinux.bin"; // path in image (NOT in /boot)
+	gchar *boot_imgname="isolinux.bin";
+	gchar *boot_img_src="/usr/share/xfburn/isolinux.bin"; // path on harddisk
+        IsoDir *dir_isolinux = NULL;
+        IsoNode *node_isolinux = NULL;
+
+	// check if folder /isolinux exists in image; if not, add folder
+//	result = iso_tree_path_to_node(image, "/isolinux", &node_isolinux);
+        result = iso_dir_get_node(iso_image_get_root (image), boot_foldername, &node_isolinux);
+        if (result <= 0) {
+    	    if (result < 0) {
+        	printf ("Error looking up %s in iso image %X\n", boot_folder, result);
+	    }
+	    if (node_isolinux && iso_node_get_type(node_isolinux) != LIBISO_DIR) {
+        	printf ("Error, not a directory, %s in iso image %X\n", boot_folder, result);
+	    }
+	    // try to add
+    	    result = iso_tree_add_new_dir (iso_image_get_root (image), boot_foldername, &dir_isolinux);
+    	    if (result < 0) {
+        	printf ("Error adding directory %s %X\n", boot_folder, result);
+	    }
+	} else {
+	    if (node_isolinux && iso_node_get_type(node_isolinux) == LIBISO_DIR) {
+		dir_isolinux=(IsoDir *)node_isolinux;
+	    } else {
+        	printf ("Error looking up %s in iso image %X\n", boot_folder, result);
+	    }
+	}
+	// check if file boot_img exists in image; if not, add file
+        result = iso_dir_get_node(dir_isolinux, boot_imgname, &node_isolinux);
+        if (result <= 0) {
+    	    if (result < 0) {
+        	printf ("Error looking up %s in iso image %X\n", boot_img, result);
+	    } else {
+	      if (node_isolinux && iso_node_get_type(node_isolinux) != LIBISO_FILE) {
+        	printf ("Error, not a file, %s in iso image %X\n", boot_img, result);
+	      }
+	    }
+	    // try to add
+    	    result = iso_tree_add_node (image, dir_isolinux, boot_img_src, &node_isolinux);
+    	    if (result < 0) {
+        	printf ("Error adding %s to folder %s/ %X\n", boot_img_src, boot_folder, result);
+	    }
+	} else {
+	    if (node_isolinux && iso_node_get_type(node_isolinux) != LIBISO_FILE) {
+        	printf ("Error, not a file, %s in iso image %X\n", boot_img, result);
+	    }
+	}
+        result = iso_image_set_boot_image(image, boot_img, ELTORITO_NO_EMUL,
+                                     boot_cat, &bootimg);
+        if (result < 0) {
+            printf ("Error adding boot image %X (does file %s exist?)\n", result, boot_img);
+        } else {
+    	    el_torito_set_load_size(bootimg, 4);
+    	    el_torito_patch_isolinux_image(bootimg);
+	}
+  }
+
   return image;
 }
 
