"Fossies" - the Fresh Open Source Software Archive

Member "xcdroast-1.19/src/create.c" (5 Nov 2018, 270300 Bytes) of package /linux/misc/xcdroast-1.19.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "create.c" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.18_vs_1.19.

    1 /*
    2  *  create.c
    3  *
    4  *  Create Disc functions
    5  *  20.11.99 tn
    6  *
    7  *
    8  *  Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
    9  *
   10  *  This file is part of xcdroast.
   11  *
   12  *  This program is free software; you can redistribute it and/or modify
   13  *  it under the terms of the GNU General Public License as published by
   14  *  the Free Software Foundation; either version 2 of the License, or
   15  *  (at your option) any later version.
   16  *
   17  *  This program is distributed in the hope that it will be useful,
   18  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   20  *  GNU General Public License for more details.
   21  *
   22  *  You should have received a copy of the GNU General Public License
   23  *  along with this program; if not, write to the Free Software
   24  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   25  */
   26 
   27 #ifdef HAVE_CONFIG_H
   28 # include <config.h>
   29 #endif
   30 
   31 #include "largefile.h"
   32 
   33 #include <locale.h>
   34 #include "gettext.h"
   35 
   36 #include <stdio.h>
   37 #include <sys/stat.h>
   38 #include <stdlib.h>
   39 #include <fcntl.h>
   40 #include <string.h>
   41 #include <strings.h>
   42 
   43 #if ENABLE_NLS
   44 # define _(String) gettext (String)
   45 # define N_(String) gettext_noop (String)
   46 #else
   47 # define _(String) (String)
   48 # define N_(String) (String)
   49 #endif
   50 #define GTK_ENABLE_BROKEN
   51 
   52 #include <gtk/gtk.h>
   53 #include <gdk/gdk.h>
   54 #include <gdk/gdkkeysyms.h>
   55 
   56 #include "xcdrdata.h"
   57 #include "xcdroast.h"
   58 #include "main.h"
   59 #include "../xpms/minidata.xpm"
   60 #include "../xpms/miniaudio.xpm"
   61 #include "../xpms/mininodata.xpm"
   62 #include "../xpms/masteradd.xpm"
   63 #include "../xpms/masterdel.xpm"
   64 
   65 extern gint debug;
   66 extern gchar configdir[MAXLINE];
   67 extern gchar sharedir[MAXLINE];
   68 extern GtkWidget *toplevel;
   69 extern GtkWidget *sidespace;
   70 extern GtkWidget *workspace;
   71 extern GtkWidget *actionspace;
   72 extern gint wav_in;
   73 extern GtkWidget *wav_quit_button;
   74 extern gint wavplay_quit;
   75 extern gint submenu;
   76 extern track_read_set_t trackreadset;
   77 extern writerreader_devices_t **writerreaderdevs;
   78 extern setup_data_t setupdata;
   79 extern current_set_t curset;
   80 extern cd_info_t cdinfo;
   81 extern track_info_t **trackinfo;
   82 extern GtkCList *cdlist, *imglist;
   83 extern GtkWidget *imglist_l1, *imglist_l2, *imglist_l3;
   84 extern GtkWidget *cdlist_l1, *cdlist_l2, *cdlist_l3, *cdlist_l4;
   85 extern GtkWidget *vrylist_l1, *vrylist_l2, *vrylist_l3, *vrylist_l4;
   86 extern GList *imagelist;
   87 extern GtkWidget *ctree_okbutton;
   88 extern GtkWidget *dupl_cd_mode_omenu, *crea_cd_mode_omenu, *crea_cd_burnfree_check, *crea_cd_nofixate_check;
   89 
   90 /*
   91  * some stuff for the select-functions of the sidebar buttons
   92  */
   93 extern guint side_handlers2[8];
   94 extern GtkWidget *side_widgets2[8];
   95 extern img_logo_t img;
   96 
   97 GtkCList *imglist2;
   98 GList *writelist;
   99 GtkWidget *isoopts[24];
  100 master_param_t masterparam;
  101 gchar **charset_types;
  102 gchar *master_fname1 = NULL;
  103 gchar *master_fname2 = NULL;
  104 GtkWidget *mkisofs_calc_timeout_dialog;
  105 static GtkWidget *isoopt_omenu;
  106 static GtkWidget *isoopt_cmenu;
  107 static GtkWidget *isoopt_cmenu2;
  108 static GtkWidget *isoopt_centry;
  109 static GtkWidget *isoopt_centry2;
  110 static GtkWidget *bootable_frame1;
  111 static GtkWidget *bootable_frame2;
  112 static GtkWidget *isoheader[7];
  113 static GtkWidget *master_avail_entry, *master_ms_button, *master_ms_button2;
  114 static gint master_ms_button_signal, master_ms_button2_signal;
  115 static gint session_current_state;
  116 static GtkWidget *bootimg_entry, *master_loadsizetbl;
  117 
  118 extern void draw_info_menu();
  119 extern void draw_play_tracks_menu();
  120 extern void draw_delete_menu();
  121 extern void devices_setup_read(gint row, GtkWidget *tbl, gint showspeed);
  122 extern void devices_setup_image(gint row, GtkWidget *tbl);
  123 extern void devices_setup_write(gint row, GtkWidget *tbl);
  124 extern void readoptions_selected(GtkWidget *item, gpointer nr);
  125 extern void verifyoptions_selected(GtkWidget *item, gpointer nr);
  126 extern void set_image_prefix_callback(GtkWidget *widget, gpointer data);
  127 extern void writeoptions_selected(GtkWidget *item, gpointer nr);
  128 extern void writemode_selected(GtkWidget *item, gpointer data);
  129 extern void cdrtype_selected(GtkWidget *item, gpointer mode);
  130 extern void show_atip_info(GtkWidget *widget, gpointer data);
  131 extern void blankcd_clicked(GtkWidget *widget, gpointer data);
  132 extern void adv_write_options_clicked(GtkWidget *widget, gpointer data);
  133 extern void undo_selections(GtkWidget *clist, gint row, gint column,
  134     GdkEventButton *event, gpointer data);
  135 extern void do_lock(gint plusgrab);
  136 extern void do_unlock(gint plusgrab);
  137 extern void display_advisooptions();
  138 
  139 static void fill_session_view(gint checkmedia);
  140 static void set_sessionsize_unknown();
  141 
  142 /* --------------- */
  143 
  144 /*
  145  * fill the entries in the read_tracks_menu
  146  */
  147 void fill_read_tracks(gint dontupdatecd) {
  148 gchar tmp[MAXLINE];
  149 gchar tmp2[MAXLINE];
  150 gchar tmp3[MAXLINE];
  151 gchar titlestr[MAXLINE];
  152 gint overwritefree, normalfree, biggestfree, overwritefreebiggest;
  153 GtkStyle *style;
  154 gchar *data[2];
  155 GdkPixmap *pixmap1, *pixmap2;
  156 GdkBitmap *mask1, *mask2;
  157 gint i, lcount;
  158 
  159     overwritefree = 0;
  160     overwritefreebiggest = 0;
  161 
  162     /* update disc-info */
  163         if (curset.reader_devnr != -1) {
  164                 get_cd_toc_and_volid(curset.reader_devnr);
  165         }
  166 
  167         /* file prefix */
  168         if (strcmp(curset.file_prefix,"") == 0) {
  169                 g_free(curset.file_prefix);
  170                 curset.file_prefix = g_strdup(IMGFILEPREFIX);
  171         }
  172         gtk_entry_set_text(GTK_ENTRY(imglist_l1), curset.file_prefix);
  173     gtk_entry_set_position(GTK_ENTRY(imglist_l1), 0);
  174 
  175         /* free size */
  176         normalfree = determine_free_space(&biggestfree);
  177         convert_kbytes2mbminstring(normalfree,tmp3);
  178 
  179         /* additional free space when overwriting files? */
  180         if (cdinfo.nr_tracks > 0 && overwritefree > 0) {
  181                 convert_kbytes2mbstring(normalfree+overwritefree, tmp2);
  182                 g_snprintf(tmp,MAXLINE,"%s (%s)", tmp3, tmp2);
  183         } else {
  184                 strcpy(tmp,tmp3);
  185         }
  186         gtk_entry_set_text(GTK_ENTRY(imglist_l2), tmp);
  187     gtk_entry_set_position(GTK_ENTRY(imglist_l2), 0);
  188 
  189         /* biggest free block */
  190         convert_kbytes2mbminstring(biggestfree,tmp3);
  191 
  192         if (cdinfo.nr_tracks > 0 && overwritefreebiggest > 0) {
  193                 convert_kbytes2mbstring(biggestfree+overwritefreebiggest, tmp2);
  194                 g_snprintf(tmp,MAXLINE,"%s (%s)", tmp3, tmp2);
  195         } else {
  196                 strcpy(tmp,tmp3);
  197         }
  198         gtk_entry_set_text(GTK_ENTRY(imglist_l3), tmp);
  199     gtk_entry_set_position(GTK_ENTRY(imglist_l3), 0);
  200 
  201 
  202     /* don't change anything on the disc side */
  203     if (dontupdatecd) return;
  204 
  205     /* fill track-listing */
  206         /* clean up first */
  207         gtk_clist_clear(cdlist);
  208 
  209         /* disc loaded? */
  210         if (cdinfo.nr_tracks == -1) {
  211                 gtk_entry_set_text(GTK_ENTRY(cdlist_l1), _("No Disc loaded"));    
  212                 gtk_entry_set_text(GTK_ENTRY(cdlist_l2),"");    
  213                 return;
  214         }
  215         if (cdinfo.nr_tracks == -2) {
  216                 gtk_entry_set_text(GTK_ENTRY(cdlist_l1), return_media_type(curset.reader_devnr));    
  217                 gtk_entry_set_text(GTK_ENTRY(cdlist_l2),"");    
  218                 return;
  219         }
  220 
  221         style = gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(cdlist)));
  222         pixmap1 = gdk_pixmap_create_from_xpm_d(cdlist->clist_window,
  223                 &mask1, &style->bg[GTK_STATE_NORMAL],(gchar **)minidata_xpm);
  224         pixmap2 = gdk_pixmap_create_from_xpm_d(cdlist->clist_window,
  225                 &mask2, &style->bg[GTK_STATE_NORMAL],(gchar **)miniaudio_xpm);
  226 
  227         data[0] = NULL;
  228         lcount = 0;
  229 
  230         for (i = 0; i < cdinfo.nr_tracks; i++) {
  231 
  232         strcpy(titlestr,"");
  233 
  234         /* we have cd-text for this track? */
  235                 if (setupdata.option_displaycdtext) {
  236                         if (trackinfo[i]->title != NULL && 
  237                             trackinfo[i]->title[0] != '\0' ) {
  238                 strcpy(titlestr, trackinfo[i]->title);
  239                         }
  240                 }
  241 
  242                 /* have we a cddb-title for this track? */
  243                 if (trackinfo[i]->cddb_ttitle != NULL) {
  244             strcpy(titlestr, trackinfo[i]->cddb_ttitle);
  245                 } else
  246                 if (trackinfo[i]->volname != NULL) {
  247             strcpy(titlestr, trackinfo[i]->volname);
  248         }
  249 
  250                 if (trackinfo[i]->type == 0) {
  251                         convert_frames2mbstring(trackinfo[i]->size,tmp2);
  252             if (strcmp(titlestr,"") == 0) {
  253                 strcpy(titlestr,_("data track"));
  254             }
  255                         g_snprintf(tmp,MAXLINE,"%2d. %s [%s]",
  256                                 trackinfo[i]->track_nr,
  257                                 titlestr, tmp2);
  258                         data[1] = convert_for_gtk2(tmp);
  259                         gtk_clist_append(cdlist,data);
  260                         gtk_clist_set_pixmap(cdlist,lcount,0,pixmap1,mask1);
  261                         lcount++;
  262                 } else {
  263                         convert_frames2minstring(trackinfo[i]->size,tmp2);
  264             if (strcmp(titlestr,"") == 0) {
  265                 strcpy(titlestr,_("audio track"));
  266             }
  267                         g_snprintf(tmp,MAXLINE,"%2d. %s [%s]",
  268                                 trackinfo[i]->track_nr,
  269                                 titlestr, tmp2);
  270                         data[1] = convert_for_gtk2(tmp);
  271                         gtk_clist_append(cdlist,data);
  272                         gtk_clist_set_pixmap(cdlist,lcount,0,pixmap2,mask2);
  273                         lcount++;
  274                 }
  275     }
  276 
  277         /* display CD label */
  278         if (cdinfo.title && cdinfo.artist && 
  279                 cdinfo.title[0] != '\0' && setupdata.option_displaycdtext) {
  280                 g_snprintf(tmp,MAXLINE,"%s / %s", cdinfo.title, cdinfo.artist);
  281                 gtk_entry_set_text(GTK_ENTRY(cdlist_l1), tmp);
  282                 gtk_entry_set_position(GTK_ENTRY(cdlist_l1),0);
  283         } else 
  284         if (cdinfo.cddb_dtitle != NULL) {
  285                 gtk_entry_set_text(GTK_ENTRY(cdlist_l1), cdinfo.cddb_dtitle);   
  286                 gtk_entry_set_position(GTK_ENTRY(cdlist_l1),0);
  287         } else {
  288                 gtk_entry_set_text(GTK_ENTRY(cdlist_l1),"");    
  289         }
  290 
  291     /* nothing selected at first */
  292         convert_sectors2mbminstring(0, tmp);
  293         gtk_entry_set_text(GTK_ENTRY(cdlist_l2), tmp);
  294 }
  295 
  296 
  297 /*
  298  * update currently selected track sizes
  299  */
  300 static void update_read_size(gint clickrow) {
  301 GList *sel;
  302 gint row;
  303 gint sizecount, disc_type;
  304 gchar tmp[MAXLINE];
  305 
  306     sizecount = 0;
  307 
  308         /* loop through all selected tracks */
  309         sel = cdlist->selection;
  310         while (sel) {
  311                 row = GPOINTER_TO_INT(sel->data);               
  312         sizecount += trackinfo[row]->size;
  313                 sel = sel->next;
  314         }
  315 
  316     /* get disc type */
  317     disc_type = determine_disc_type(tmp,0);
  318 
  319     /* display track size */
  320     if (disc_type == 1 || disc_type == 2) { /* Audio or Mixed Mode CD */
  321         convert_frames2mbminstring(sizecount, tmp);
  322     } else {                        /* Data CD/DVD/BD and CD Extra */
  323         convert_sectors2mbminstring(sizecount, tmp);
  324     }
  325         gtk_entry_set_text(GTK_ENTRY(cdlist_l2), tmp);
  326 }
  327 
  328 
  329 /*
  330  * callbacks for button in read-screen
  331  */
  332 static void readsometracks_clicked(GtkWidget *widget, gpointer data) {
  333 track_read_param_t *trackparam;
  334 gfloat per;
  335 gint ret, sizecount,nrtracks;
  336 gint overwrite, overwritebiggest;
  337 GList *sel;
  338 gint row, sectorstoread,stat;
  339 gint datacount, audiocount, sectsize;
  340 
  341         /* no disc reader defined */
  342         if (curset.reader_devnr == -1) {
  343                 show_dialog(ICO_ERROR,_("No disc reader defined in Setup."), T_OK, NULL, NULL, 0);
  344                 return;
  345         }
  346 
  347     datacount = 0;
  348     audiocount = 0;
  349     sectsize = get_sectorsize(curset.reader_devnr);
  350 
  351         /* now check if our disc information is still valid */
  352         get_cd_toc_and_volid(curset.reader_devnr);
  353 
  354         /* disc loaded? */
  355         if (cdinfo.nr_tracks < 0) {
  356                 /* update screen ... */
  357                 fill_read_tracks(0);
  358                 show_dialog(ICO_WARN,_("No Disc loaded in read device."),T_OK,NULL,NULL,0);
  359                 return;
  360         }
  361 
  362     sizecount = 0;
  363     nrtracks = 0;
  364         /* loop through all selected tracks to get number and sum of size */
  365         sel = cdlist->selection;
  366         while (sel) {
  367                 row = GPOINTER_TO_INT(sel->data);               
  368         sizecount += trackinfo[row]->size;
  369         nrtracks++;
  370                 sel = sel->next;
  371         }
  372 
  373     /* no tracks selected */
  374     if (nrtracks == 0) {
  375                 show_dialog(ICO_WARN,_("No tracks selected"),T_OK,NULL,NULL,0);
  376                 return;
  377     }
  378 
  379         /* lets check if the file-prefix-entry is up to date */
  380         set_image_prefix_callback(imglist_l1, NULL); 
  381 
  382         /* free structure first */
  383     clear_trackreadset();
  384 
  385         /* fill structure */
  386         trackreadset.nrtracks = nrtracks;
  387 
  388         sel = cdlist->selection;
  389         while (sel) {
  390                 row = GPOINTER_TO_INT(sel->data);               
  391 
  392                 /* allocate memory */
  393                 trackparam = g_new0(track_read_param_t,1);
  394 
  395                 trackparam->trackinfo_index = row;
  396                 trackparam->starttrack = trackinfo[row]->track_nr;
  397                 trackparam->endtrack = 0;
  398                 trackparam->tracktype = trackinfo[row]->type;
  399                 per = (gfloat)trackinfo[row]->size * 100.0  / sizecount;
  400                 trackparam->percent = per;
  401                 
  402                 if (trackparam->tracktype == 0) {
  403                         /* data track */
  404             datacount++;
  405                         trackparam->kbyte = trackinfo[row]->size *
  406                                 (DATASECTORSIZE/1024);
  407                         trackparam->frames = trackinfo[row]->size;
  408                         trackparam->startoffset = trackinfo[row]->start_sec;
  409                         if (row == cdinfo.nr_tracks-1) {
  410                                 /* last track - leadout is track-end */
  411                                 trackparam->endoffset = cdinfo.leadout - 2;     
  412                         } else {
  413                                 /* sub 150 (2 sec leadout),
  414                                    sub 2 (2 run out sectors) */
  415                                 trackparam->endoffset = 
  416                                         trackinfo[row+1]->start_sec -150-2; 
  417                         }
  418             /*
  419              * now do a paranoia check
  420              * in some cases we skip to much of a track
  421              */
  422                         sectorstoread = trackparam->endoffset -
  423                                 trackparam->startoffset;
  424             if (sectorstoread < trackinfo[row]->isosize) {
  425                                 trackparam->endoffset =
  426                                         trackparam->startoffset +
  427                                                 trackinfo[row]->isosize;
  428                                 trackparam->kbyte = trackinfo[row]->isosize * 2;
  429                 dodebug(1,"readsometracks_clicked: corrected data track size from %d to %d sectors.\n", sectorstoread, trackinfo[row]->isosize);
  430             }
  431                 } else {
  432                         /* audio */
  433             audiocount++;
  434                         trackparam->kbyte = trackinfo[row]->size *
  435                                 CDDAFRAME/1024;
  436                         trackparam->frames = trackinfo[row]->size;
  437                 }
  438 
  439                 trackreadset.trackparams = g_list_append(
  440                         trackreadset.trackparams, trackparam);
  441 
  442                 sel = sel->next;
  443         }
  444 
  445     /* sectorsize firmware bug detection */
  446     if (datacount > 0 && sectsize != 2048) {
  447                 ret = show_dialog(ICO_WARN,_("Your drive seems to have a faulty firmware which will not allow to read\ndata tracks reliably. Try to install a firmwire update or read your\ndata Discs with another drive. It is not recommended to continue."), T_ANYWAY, T_CANCEL, NULL, 1);
  448                 if (ret == 1) {
  449                         /* abort */
  450                         return;
  451                 }
  452     }
  453 
  454         /* assign disk space */
  455         stat = allocate_track_filenames(&overwrite, &overwritebiggest); 
  456         if (stat == 1) {
  457                 /* not enough space */
  458                 ret = show_dialog(ICO_WARN,_("Not enough disk space available!\nDo you want to continue anyway or to abort?"), T_ANYWAY, T_CANCEL, NULL, 1);
  459                 if (ret == 1) {
  460                         /* abort */
  461                         return;
  462                 }
  463         }
  464 
  465     /* no writeable dirs */
  466     if (stat == 2) {
  467         show_dialog(ICO_WARN,_("No image-directories with write permissions found.\nPlease check your settings in the Setup."), T_OK, NULL, NULL, 1);
  468         return;
  469     }
  470 
  471         /* overwriting a link? */
  472         if (stat == 3) {
  473                 /* FIX HERE USING GETTEXT FOR NEXT RELEASE */
  474                 show_dialog(ICO_WARN,"Not allowing to overwrite a symlink.\nChoose another \"File prefix\".", T_OK, NULL, NULL, 1);
  475                 return;
  476         }
  477 
  478         /* warn we are going to overwrite some files */
  479         if (setupdata.option_overwritewarn == 1 && overwrite > 0) {
  480                 ret = show_dialog(ICO_WARN,_("You are going to overwrite old track images on your\nhard disk. Cancel now, if you don't want to do that\nand choose another \"File prefix\"."), T_ANYWAY, T_CANCEL, NULL, 1);
  481                 if (ret == 1) {
  482                         /* abort */
  483                         return;
  484                 }
  485         }
  486 
  487     /* assign an empty toc-filename */
  488         g_free(trackreadset.tocfile);
  489         trackreadset.tocfile = g_strdup("");
  490 
  491         /* now all parameters for reading are set - lets begin */
  492         show_and_do_read_tracks(curset.reader_devnr, 0);
  493 }
  494 
  495 
  496 static void read_select_all(GtkWidget *widget, gpointer data) {
  497 
  498         gtk_clist_select_all(cdlist);
  499 }
  500 
  501 static void read_select_none(GtkWidget *widget, gpointer data) {
  502 
  503         gtk_clist_unselect_all(cdlist);
  504 }
  505 
  506 static void read_select_row(GtkWidget *clist, gint row, gint col,
  507         GdkEventButton *event, gpointer data) {
  508 
  509         update_read_size(row);
  510 }
  511 
  512 
  513 /*
  514  * draw the read tracks menu
  515  */
  516 static void draw_read_tracks() {
  517 gchar tmp[MAXLINE];
  518 GtkWidget *hbox, *vbox;
  519 GtkWidget *f1,*f2, *f3;
  520 GtkWidget *b1;
  521 GtkWidget *e1;
  522 GtkWidget *l1;
  523 GtkWidget *tbl, *check, *dummy;
  524 GtkCList *clist;
  525 gchar *titles[2];
  526 GtkWidget *scrolled_win, *list;
  527 
  528         /* prepare draw area */
  529         clear_actionspace();
  530 
  531         f1 = gtk_frame_new(_("Devices-Setup"));
  532         set_font_and_color_frame(f1,PANGO_BOLD,NULL);
  533         gtk_box_pack_start(GTK_BOX(actionspace),f1,FALSE,FALSE,5);
  534         gtk_widget_show(f1);
  535 
  536         tbl = gtk_table_new(2,16*4,TRUE); 
  537         gtk_table_set_col_spacing(GTK_TABLE(tbl),4*4-1,5);
  538         gtk_table_set_col_spacing(GTK_TABLE(tbl),15*4-2,5);
  539         gtk_container_set_border_width(GTK_CONTAINER (tbl),5);
  540         gtk_container_add(GTK_CONTAINER(f1),tbl);
  541         gtk_widget_show(tbl);
  542 
  543         devices_setup_read(0, tbl, 1);
  544         devices_setup_image(1, tbl);
  545 
  546         /* left and right info-frames */
  547         tbl = gtk_table_new(1,2,TRUE);
  548         gtk_table_set_col_spacings(GTK_TABLE(tbl),10);
  549         gtk_box_pack_start(GTK_BOX(actionspace),tbl,TRUE,TRUE,10);
  550         gtk_widget_show(tbl);
  551         vbox = gtk_vbox_new(FALSE,10);
  552         gtk_table_attach_defaults(GTK_TABLE(tbl),vbox,1,2,0,1);
  553     if (!curset.isProDVD) {
  554             f1 = gtk_frame_new(_("Disc-Information"));
  555     } else {
  556             f1 = gtk_frame_new(_("CD/DVD-Information"));
  557     }
  558         set_font_and_color_frame(f1,PANGO_BOLD,NULL);
  559         gtk_table_attach_defaults(GTK_TABLE(tbl),f1,0,1,0,1);
  560         gtk_widget_show(f1);
  561         f2 = gtk_frame_new(_("Image-Information"));
  562         set_font_and_color_frame(f2,PANGO_BOLD,NULL);
  563         gtk_box_pack_start(GTK_BOX(vbox),f2,TRUE,TRUE,0);
  564         gtk_widget_show(f2);
  565         f3 = gtk_frame_new(_("Read options"));
  566         set_font_and_color_frame(f3,PANGO_BOLD,NULL);
  567         gtk_box_pack_start(GTK_BOX(vbox),f3,FALSE,FALSE,0);
  568         gtk_widget_show(f3);
  569         gtk_widget_show(vbox);
  570 
  571         /* button bar at the bottom */
  572         hbox = gtk_hbox_new(FALSE,5);
  573         gtk_box_pack_start(GTK_BOX(actionspace),hbox,FALSE,TRUE,10);
  574         gtk_widget_show(hbox);
  575 
  576         b1 = gtk_button_new_with_label(_("Select all"));
  577         gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,10);
  578         gtk_signal_connect(GTK_OBJECT(b1),"clicked",
  579                 GTK_SIGNAL_FUNC(read_select_all), NULL);
  580     define_tooltip(b1,_("Selects all tracks of the currently inserted Disc for reading."));
  581         gtk_widget_show(b1);
  582 
  583         b1 = gtk_button_new_with_label(_("Select none"));
  584         gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,10);
  585         gtk_signal_connect(GTK_OBJECT(b1),"clicked",
  586                 GTK_SIGNAL_FUNC(read_select_none), NULL);
  587     define_tooltip(b1,_("Deselects all tracks of the currently inserted Disc."));
  588         gtk_widget_show(b1);
  589 
  590         dummy = gtk_label_new("");
  591         gtk_box_pack_start(GTK_BOX(hbox),dummy,FALSE,FALSE,10);
  592         gtk_widget_show(dummy);
  593 
  594         b1 = gtk_button_new_with_label(_("Read selected tracks"));
  595         gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,10);
  596         gtk_widget_show(b1);
  597     define_tooltip(b1,_("Reads all selected tracks from the Disc and saves them in the Image Directory."));
  598         gtk_signal_connect(GTK_OBJECT(b1), "clicked",
  599                 GTK_SIGNAL_FUNC(readsometracks_clicked), NULL);
  600 
  601     /* left frame */
  602         vbox = gtk_vbox_new(FALSE,0);
  603         gtk_container_add(GTK_CONTAINER(f1),vbox);
  604         gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
  605         gtk_widget_show(vbox);
  606 
  607         scrolled_win = gtk_scrolled_window_new (NULL, NULL);
  608         gtk_box_pack_start(GTK_BOX(vbox),scrolled_win,TRUE,TRUE,0);
  609         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
  610                 GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
  611         gtk_widget_show(scrolled_win);
  612         
  613         titles[0] = "";
  614         titles[1] = _("Tracks");
  615         list = gtk_clist_new_with_titles(2,titles);
  616         gtk_container_add (GTK_CONTAINER (scrolled_win), list);
  617         gtk_widget_realize(list);
  618         clist = GTK_CLIST(list);
  619         cdlist = clist;
  620         gtk_signal_connect(GTK_OBJECT(clist), "select_row",
  621                 GTK_SIGNAL_FUNC(read_select_row),NULL);
  622         gtk_signal_connect(GTK_OBJECT(clist), "unselect_row",
  623                 GTK_SIGNAL_FUNC(read_select_row),NULL);
  624     gtk_clist_set_column_width(cdlist, 0, 16);
  625         gtk_clist_set_column_auto_resize(cdlist, 1, TRUE);
  626     gtk_clist_set_selection_mode (clist, GTK_SELECTION_MULTIPLE);
  627     gtk_widget_show(list);
  628 
  629         tbl = gtk_table_new(2,8,TRUE);
  630         gtk_table_set_row_spacings(GTK_TABLE(tbl),10);
  631         gtk_table_set_col_spacings(GTK_TABLE(tbl),10);
  632         gtk_box_pack_start(GTK_BOX(vbox),tbl,FALSE,FALSE,10);
  633         gtk_widget_show(tbl);
  634 
  635         l1 = rightjust_gtk_label_new(_("Label:"));
  636         gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,2,0,1);
  637         gtk_widget_show(l1);
  638 
  639         e1 = gtk_entry_new();
  640         cdlist_l1 = e1;
  641         gtk_entry_set_editable(GTK_ENTRY(e1),FALSE);
  642         gtk_table_attach_defaults(GTK_TABLE(tbl),e1,2,8,0,1);
  643         gtk_widget_show(e1);
  644         l1 = rightjust_gtk_label_new(_("Selected:"));
  645         gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,2,1,2);
  646         gtk_widget_show(l1);
  647 
  648         e1 = gtk_entry_new();
  649         cdlist_l2 = e1;
  650         gtk_entry_set_editable(GTK_ENTRY(e1),FALSE);
  651         gtk_table_attach_defaults(GTK_TABLE(tbl),e1,2,8,1,2);
  652         gtk_widget_show(e1);
  653 
  654         /* right info frame */
  655         vbox = gtk_vbox_new(FALSE,0);
  656         gtk_container_add(GTK_CONTAINER(f2),vbox);
  657         gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
  658         gtk_widget_show(vbox);
  659 
  660         tbl = gtk_table_new(4,8,TRUE);
  661         gtk_table_set_row_spacings(GTK_TABLE(tbl),10);
  662         gtk_table_set_col_spacings(GTK_TABLE(tbl),10);
  663         gtk_box_pack_start(GTK_BOX(vbox),tbl,FALSE,FALSE,10);
  664         gtk_widget_show(tbl);
  665 
  666         l1 = rightjust_gtk_label_new(_("File prefix:"));
  667         gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,4,0,1);
  668         gtk_widget_show(l1);
  669 
  670         e1 = gtk_entry_new();
  671         gtk_entry_set_max_length(GTK_ENTRY(e1), MAXENTRY);
  672         imglist_l1 = e1;
  673         gtk_signal_connect(GTK_OBJECT(e1), "activate",
  674                 GTK_SIGNAL_FUNC(set_image_prefix_callback),NULL);
  675         gtk_table_attach_defaults(GTK_TABLE(tbl),e1,4,8,0,1);
  676         gtk_widget_show(e1);
  677     g_snprintf(tmp,MAXLINE,"%s %s", _("This is the prefix of the filenames of the tracks saved to the hard disk."), _("Change this name if you want to read another Disc or to create another Disc image."));
  678     define_tooltip(e1,tmp);     /* concatenated text */
  679 
  680         l1 = rightjust_gtk_label_new(_("Free space:"));
  681         gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,4,1,2);
  682         gtk_widget_show(l1);
  683 
  684         e1 = gtk_entry_new();
  685         imglist_l2 = e1;
  686         gtk_entry_set_editable(GTK_ENTRY(e1),FALSE);
  687         gtk_table_attach_defaults(GTK_TABLE(tbl),e1,4,8,1,2);
  688         gtk_widget_show(e1);
  689     define_tooltip(e1, _("If the Image Directory is set to \"Automatic\" this is the free hard disk space of all the image directories: Data / Audio"));
  690 
  691         l1 = leftjust_gtk_label_new(_("biggest available block of that:"));
  692         gtk_table_attach_defaults(GTK_TABLE(tbl),l1,1,8,2,3);
  693         gtk_widget_show(l1);
  694 
  695         e1 = gtk_entry_new();
  696         imglist_l3 = e1;
  697         gtk_entry_set_editable(GTK_ENTRY(e1),FALSE);
  698         gtk_table_attach_defaults(GTK_TABLE(tbl),e1,4,8,3,4);
  699         gtk_widget_show(e1);
  700     define_tooltip(e1, _("The largest free space currently straight available: Data / Audio"));
  701 
  702         /* options frame */
  703         vbox = gtk_vbox_new(FALSE,0);
  704         gtk_container_add(GTK_CONTAINER(f3),vbox);
  705         gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
  706         gtk_widget_show(vbox);
  707 
  708         tbl = gtk_table_new(1,8,TRUE);
  709         gtk_table_set_col_spacings(GTK_TABLE(tbl),10);
  710         gtk_box_pack_start(GTK_BOX(vbox),tbl,FALSE,FALSE,10);
  711         gtk_widget_show(tbl);
  712 
  713     /* index scan? */
  714         check = gtk_check_button_new_with_label(_("Do index scan"));
  715         gtk_signal_connect(GTK_OBJECT(check),"clicked",
  716                 GTK_SIGNAL_FUNC(readoptions_selected),GINT_TO_POINTER(0));
  717         gtk_table_attach_defaults(GTK_TABLE(tbl),check,1,8,0,1);
  718         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
  719                 curset.indexscan);
  720     define_tooltip(check, _("Long-lasting audio tracks may be subdivided with indices, some audio CDs are recorded with pre-emphasis. If this option is enabled, the copy will be exactly as the original. Please note that some drives may need a little time to scan."));
  721         gtk_widget_show(check);
  722 
  723     /* deemphasize? */
  724         check = gtk_check_button_new_with_label(_("Audio deemphasis"));
  725         gtk_signal_connect(GTK_OBJECT(check),"clicked",
  726                 GTK_SIGNAL_FUNC(readoptions_selected),GINT_TO_POINTER(1));
  727         gtk_table_attach_defaults(GTK_TABLE(tbl),check,1,8,1,2);
  728         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
  729                 curset.deemphasize);
  730     define_tooltip(check, _("Some audio CDs are recorded with pre-emphasis. This option detects and deemphasizes such audio tracks. This is mandatory if you want to convert the files e.g. to flac, ogg or mp3. By contrast, all Audio CD players would perform the deemphasis automatically."));
  731         gtk_widget_show(check);
  732 
  733     gtk_widget_show(actionspace);
  734 
  735     /* fill entries */
  736     fill_read_tracks(0);
  737 }
  738 
  739 
  740 /*
  741  * fill the entries in the verify_tracks_menu
  742  */
  743 void fill_verify_tracks(gint dontupdateimglist) {
  744 gchar tmp[MAXLINE], tmp2[MAXLINE];
  745 gchar titlestr[MAXLINE];
  746 GList *loop;
  747 GtkStyle *style;
  748 gchar *data[2];
  749 GdkPixmap *pixmap1, *pixmap2, *pixmap3;
  750 GdkBitmap *mask1, *mask2, *mask3;
  751 gchar basename[MAXLINE], imgdir[MAXLINE], fname[MAXLINE], *p;
  752 gint lcount, count, disc_type;
  753 image_files_t *entry;
  754 
  755 
  756     /* update disc info */
  757         if (curset.reader_devnr != -1) {
  758                 get_cd_toc_and_volid(curset.reader_devnr);
  759         }
  760 
  761         /* disc loaded? */
  762         if (cdinfo.nr_tracks == -1) {
  763                 gtk_entry_set_text(GTK_ENTRY(vrylist_l1), _("No Disc loaded"));    
  764                 gtk_entry_set_text(GTK_ENTRY(vrylist_l2),"");   
  765                 gtk_entry_set_text(GTK_ENTRY(vrylist_l3),"");   
  766                 gtk_entry_set_text(GTK_ENTRY(vrylist_l4),"");   
  767         }
  768         if (cdinfo.nr_tracks == -2) {
  769                 gtk_entry_set_text(GTK_ENTRY(vrylist_l1), return_media_type(curset.reader_devnr));    
  770                 gtk_entry_set_text(GTK_ENTRY(vrylist_l2),"");   
  771                 gtk_entry_set_text(GTK_ENTRY(vrylist_l3),"");   
  772                 gtk_entry_set_text(GTK_ENTRY(vrylist_l4),"");   
  773         }
  774 
  775     if (cdinfo.nr_tracks > 0) {
  776             /* get and display disc type */
  777             disc_type = determine_disc_type(tmp,0);
  778             gtk_entry_set_text(GTK_ENTRY(vrylist_l1), tmp); 
  779 
  780             /* display CD label */
  781             if (cdinfo.title && cdinfo.artist && 
  782                     cdinfo.title[0] != '\0' && setupdata.option_displaycdtext) {
  783                     g_snprintf(tmp,MAXLINE,"%s / %s", cdinfo.title, cdinfo.artist);
  784             gtk_entry_set_text(GTK_ENTRY(vrylist_l2), tmp);
  785                     gtk_entry_set_position(GTK_ENTRY(vrylist_l2),0);
  786             } else 
  787             if (cdinfo.cddb_dtitle != NULL) {
  788                     gtk_entry_set_text(GTK_ENTRY(vrylist_l2), cdinfo.cddb_dtitle);
  789                     gtk_entry_set_position(GTK_ENTRY(vrylist_l2),0);
  790             } else {
  791                     gtk_entry_set_text(GTK_ENTRY(vrylist_l2),"");    
  792             }
  793 
  794             /* display disc size */
  795         if (disc_type == 1 || disc_type == 2) { /* Audio or Mixed Mode CD */
  796                 convert_frames2mbminstring(cdinfo.total_size, tmp);
  797         } else {            /* Data CD/DVD/BD and CD Extra */
  798                 convert_sectors2mbminstring(cdinfo.total_size, tmp);
  799         }
  800             gtk_entry_set_text(GTK_ENTRY(vrylist_l3), tmp);
  801 
  802             /* nr tracks */ 
  803             g_snprintf(tmp,MAXLINE,"%d",cdinfo.nr_tracks);
  804             gtk_entry_set_text(GTK_ENTRY(vrylist_l4), tmp);
  805     }
  806 
  807     /* now draw image-list */
  808     if (dontupdateimglist) return;
  809 
  810         /* clean up first */
  811         gtk_clist_clear(imglist);
  812 
  813         style = gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(imglist)));
  814         pixmap1 = gdk_pixmap_create_from_xpm_d(imglist->clist_window,
  815                 &mask1, &style->bg[GTK_STATE_NORMAL],(gchar **)minidata_xpm);
  816         pixmap2 = gdk_pixmap_create_from_xpm_d(imglist->clist_window,
  817                 &mask2, &style->bg[GTK_STATE_NORMAL],(gchar **)miniaudio_xpm);
  818         pixmap3 = gdk_pixmap_create_from_xpm_d(imglist->clist_window,
  819                 &mask3, &style->bg[GTK_STATE_NORMAL],(gchar **)mininodata_xpm);
  820 
  821 
  822     data[0] = NULL;
  823         strcpy(imgdir,"");
  824         count = 1;
  825     lcount = 0;
  826 
  827         /* check image-selector */
  828         if (curset.image_index != -1) {
  829                 /* no automatic setting? */
  830                 strncpy(imgdir,(gchar *)g_list_nth_data(setupdata.image_dirs,
  831                         curset.image_index), MAXLINE);
  832         }
  833 
  834         loop = g_list_first(imagelist);
  835         while (loop) {
  836                 entry = loop->data;
  837 
  838                 /* get the base-dirname */
  839                 strncpy(basename,entry->path,MAXLINE);  
  840                 p = rindex(basename,'/');
  841                 *p = '\0';
  842                 if (strcmp(basename,"") == 0) {
  843                         strcpy(basename,"/");
  844                 }
  845         strcpy(fname, p+1);
  846 
  847                 if (strcmp(basename,imgdir) != 0 && imgdir[0] != '\0') {
  848                         /* skip not selected dirs */
  849                         loop = loop->next;
  850                         continue;
  851                 }
  852 
  853         if (entry->readable == 0) {
  854             /* don't display not readable files */
  855                         loop = loop->next;
  856                         continue;
  857                 }
  858 
  859         strcpy(titlestr,"");
  860         assign_trackname(titlestr, entry);
  861 
  862         /* no title found - so use filename as title */
  863         if (strcmp(titlestr,"") == 0) {
  864             strcpy(titlestr,fname);
  865         }
  866 
  867                 /* iso9600-track/ unknown  */
  868                 if (entry->type == 0 || entry->type == 3) {
  869                         convert_frames2mbstring((gint)((off_t)entry->size/DATASECTORSIZE),
  870                                 tmp2);
  871                         g_snprintf(tmp,MAXLINE,"%2d. %s [%s]",
  872                                 count, titlestr, tmp2);
  873                         data[1] = convert_for_gtk2(tmp);
  874                         gtk_clist_append(imglist,data);
  875                         if (entry->type == 0) {
  876                                 gtk_clist_set_pixmap(imglist,lcount,0,pixmap1,mask1);   
  877                         } else {
  878                                 gtk_clist_set_pixmap(imglist,lcount,0,pixmap3,mask3);   
  879                         }
  880                         count++;
  881             lcount++;
  882                 }
  883 
  884                 /* valid wav-file */
  885                 if (entry->type == 1) {
  886                         convert_frames2minstring((gint)((off_t)entry->size/CDDAFRAME), tmp2);
  887                         g_snprintf(tmp,MAXLINE,"%2d. %s [%s]",
  888                                 count, titlestr, tmp2);
  889                         data[1] = convert_for_gtk2(tmp);
  890                         gtk_clist_append(imglist,data);
  891                         gtk_clist_set_pixmap(imglist,lcount,0,pixmap2,mask2);   
  892                         lcount++;
  893                         count++;
  894                 }       
  895 
  896         loop = loop->next;
  897     }
  898 
  899         /* nothing selected - no size of files */
  900         convert_kbytes2mbminstring(0, tmp);
  901         gtk_entry_set_text(GTK_ENTRY(imglist_l1), tmp);  
  902 }
  903 
  904 
  905 /*
  906  * find out which trackfilename is in which row
  907  * this is a little complicated because I have to recreate the
  908  * exact order of tracks as they are filled by fill_verify_tracks
  909  */
  910 static gint get_trackname_from_row(gint row, gchar *tname) {
  911 GList *loop;
  912 image_files_t *entry;
  913 gint count;
  914 gchar basename[MAXLINE], imgdir[MAXLINE], fname[MAXLINE], *p;
  915 
  916     strcpy(imgdir,"");
  917     count = 0;
  918 
  919         /* check image-selector */
  920         if (curset.image_index != -1) {
  921                 /* no automatic setting? */
  922                 strncpy(imgdir,(gchar *)g_list_nth_data(setupdata.image_dirs,
  923                         curset.image_index), MAXLINE);
  924         }
  925 
  926         loop = g_list_first(imagelist);
  927         while (loop) {
  928                 entry = loop->data;
  929 
  930                 /* get the base-dirname */
  931                 strncpy(basename,entry->path,MAXLINE);  
  932                 p = rindex(basename,'/');
  933                 *p = '\0';
  934                 if (strcmp(basename,"") == 0) {
  935                         strcpy(basename,"/");
  936                 }
  937                 strcpy(fname, p+1);
  938 
  939                 if (strcmp(basename,imgdir) != 0 && imgdir[0] != '\0') {
  940                         /* skip not selected dirs */
  941                         loop = loop->next;
  942                         continue;
  943                 }
  944 
  945                 if (entry->readable == 0) {
  946                         /* don't display not readable files */
  947                         loop = loop->next;
  948                         continue;
  949                 }
  950 
  951         if (entry->type == 0 || entry->type == 3 || entry->type == 1) {
  952 
  953             /* matching row found */
  954             if (count == row) {
  955                 strcpy(tname, entry->path);
  956                 return 0;
  957             }   
  958             count++;
  959         }
  960 
  961                 loop = loop->next;
  962         }
  963 
  964     /* no match */
  965     return 1;
  966 }
  967 
  968 
  969 /*
  970  * update currently selected track-sizes
  971  */
  972 static void update_verify_size(gint clickrow) {
  973 GList *sel;
  974 gint row;
  975 gint sizecount;
  976 gchar tmp[MAXLINE];
  977 
  978     sizecount = 0;
  979 
  980     /* loop through all selected tracks */
  981     sel = imglist->selection;
  982         while (sel) {
  983         row = GPOINTER_TO_INT(sel->data);               
  984         if (get_trackname_from_row(row, tmp) == 0) {
  985             /*
  986              * we get now the full track-filename in tmp
  987              * now get its size (in Bytes)
  988              */
  989             sizecount+=(gint) ((off_t)get_size_from_imagelist(tmp) >>10);
  990         }
  991         sel = sel->next;
  992     }
  993     convert_kbytes2mbminstring(sizecount, tmp);
  994     gtk_entry_set_text(GTK_ENTRY(imglist_l1), tmp);
  995 }
  996 
  997 
  998 /*
  999  * callbacks for verify menu
 1000  */
 1001 static void verifysometracks_clicked(GtkWidget *widget, gpointer data) {
 1002 track_read_param_t *trackparam;
 1003 GList *sellist;
 1004 gfloat per;
 1005 gint sizecount,nrtracks;
 1006 gint tracknr, size, type, sectorstoread;
 1007 GList *sel;
 1008 gint row, stat, stat2, abort;
 1009 gchar tmp[MAXLINE];
 1010 gchar volname[MAXLINE];
 1011 gchar *cell;
 1012 gchar *pt;
 1013 
 1014         /* no disc reader defined */
 1015         if (curset.reader_devnr == -1) {
 1016                 show_dialog(ICO_ERROR,_("No disc reader defined in Setup."), T_OK, NULL, NULL, 0);
 1017                 return;
 1018         }
 1019         /* now check if our disc information is still valid */
 1020         get_cd_toc_and_volid(curset.reader_devnr);
 1021         /* update screen ... */
 1022         fill_verify_tracks(1);
 1023 
 1024         /* disc loaded? */
 1025         if (cdinfo.nr_tracks < 0) {
 1026                 show_dialog(ICO_WARN,_("No Disc loaded in read device."),T_OK,NULL,NULL,0);
 1027                 return;
 1028         }
 1029 
 1030         sizecount = 0;
 1031         nrtracks = 0;
 1032         /* loop through all selected tracks to get number */
 1033         sel = imglist->selection;
 1034         while (sel) {
 1035                 row = GPOINTER_TO_INT(sel->data);               
 1036                 nrtracks++;
 1037                 sel = sel->next;
 1038         }
 1039 
 1040         /* no tracks selected */
 1041         if (nrtracks == 0) {
 1042                 show_dialog(ICO_WARN,_("No tracks selected"),T_OK,NULL,NULL,0);
 1043                 return;
 1044         }
 1045 
 1046     /* check if all the tracks selected match the current disc */
 1047     abort = 0;
 1048     sellist = NULL;
 1049     sel = imglist->selection;
 1050         while (sel) {
 1051                 row = GPOINTER_TO_INT(sel->data);
 1052                 if (get_trackname_from_row(row, tmp) == 0) {
 1053             /*
 1054              * we get now the full track-filename in tmp
 1055              * check if track can be verified
 1056              */
 1057             stat = check_vrfy_track(tmp);
 1058             stat2 = 0;
 1059 
 1060             /* get image-title from list */
 1061             gtk_clist_get_text(imglist,row,1,&cell);
 1062 
 1063             if (stat == 0) {
 1064                 /* all ok */
 1065                         sel = sel->next;
 1066                 continue;
 1067             }
 1068 
 1069             if (stat == 1) {
 1070                 /*
 1071                  * no info file
 1072                  * perhaps it is a self-mastered track?
 1073                  */
 1074                 if (get_volname_from_imagelist(tmp,volname) == 0) {
 1075                     if (cdinfo.nr_tracks == 1) {
 1076                         pt = trackinfo[0]->volname;
 1077                         if (pt) {
 1078                             if (strcmp(volname,pt) == 0) {  
 1079                                 /*
 1080                                  * ah nice, the isoname of the
 1081                                  * track does match the disc
 1082                                  * - allow verifying
 1083                                  */
 1084                                         sel = sel->next;
 1085                                 continue;
 1086                             }
 1087                         } else {
 1088                             /* special case, no volname at all set by both */
 1089                             if (strcmp(volname,"") == 0) {
 1090                                         sel = sel->next;
 1091                                 continue;
 1092                             }
 1093                         }
 1094 
 1095                     }
 1096                 }
 1097 
 1098                 g_snprintf(tmp,MAXLINE,_("No Info-file found for track \"%s\".\nTherefore verification is impossible.\nUnselecting this track..."),cell);
 1099                 stat2 = show_dialog(ICO_WARN,tmp,T_OK,T_CANCEL,_("Verify anyway"),0);
 1100             }
 1101             if (stat == 2) {
 1102                 /* track does not match to disc */
 1103                 g_snprintf(tmp,MAXLINE,_("Track \"%s\" does\nnot fit to the currently inserted Disc. Therefore verification\nis impossible. Unselecting this track..."),cell);
 1104                 stat2 = show_dialog(ICO_WARN,tmp,T_OK,T_CANCEL,NULL,0);
 1105             }
 1106             if (stat == 3) {
 1107                 /* don't verify audio */
 1108                 g_snprintf(tmp,MAXLINE,_("Can't verify audio track \"%s\"\nbecause you choose not to verify audio tracks.\nUnselecting this track..."),cell);
 1109                 stat2 = show_dialog(ICO_WARN,tmp,T_OK,T_CANCEL,NULL,0);
 1110             }
 1111 
 1112             /* aborting selected */
 1113             if (stat2 == 1) {
 1114                 abort = 1;
 1115                 break;
 1116             } 
 1117             
 1118             /* no info file, but verify anyway */
 1119             if (stat2 == 2) {
 1120                         sel = sel->next;
 1121                 continue;
 1122             }
 1123 
 1124             /*
 1125              * save track nr - we are not allowed to unselect tracks
 1126              * while we parsing the selection itself
 1127              */
 1128             sellist = g_list_append(sellist, GINT_TO_POINTER(row));
 1129                 }
 1130                 sel = sel->next;
 1131         }
 1132 
 1133     /* unselect all not fitting tracks */
 1134     sel = g_list_first(sellist);
 1135     while (sel) {
 1136         row = GPOINTER_TO_INT(sel->data);
 1137         gtk_clist_unselect_row(imglist, row, 0);
 1138         sel = sel->next;
 1139     }
 1140     g_list_free(sellist);
 1141 
 1142     /* user aborted? */
 1143     if (abort) return;
 1144 
 1145     /*
 1146      * now check if any tracks are still selected
 1147      * and calculate sum of size
 1148      */
 1149     sizecount = 0;
 1150     nrtracks = 0;
 1151     /* loop through all selected tracks to get number */
 1152     sel = imglist->selection;
 1153     while (sel) {
 1154         row = GPOINTER_TO_INT(sel->data);               
 1155         if (get_trackname_from_row(row, tmp) == 0) {
 1156             /*
 1157              * we get now the full track-filename in tmp
 1158              * now get its size (in Bytes)
 1159              */
 1160             sizecount+=(gint) ((off_t)get_size_from_imagelist(tmp) >> 10);
 1161         }
 1162         nrtracks++;
 1163         sel = sel->next;
 1164     }
 1165 
 1166         /* no tracks selected */
 1167         if (nrtracks == 0) {
 1168                 show_dialog(ICO_WARN,_("No tracks selected"),T_OK,NULL,NULL,0);
 1169                 return;
 1170         }
 1171 
 1172     /*
 1173      * so...if we are here, we have at least
 1174      * one selected track that matches our disc
 1175      * free structure first
 1176      */
 1177     clear_trackreadset();
 1178 
 1179         /* fill structure */
 1180         trackreadset.nrtracks = nrtracks;
 1181 
 1182         sel = imglist->selection;
 1183         while (sel) {
 1184                 row = GPOINTER_TO_INT(sel->data);               
 1185 
 1186                 if (get_trackname_from_row(row, tmp) != 0) {
 1187             sel = sel->next; continue;
 1188         }
 1189                 /* we get now the full track-filename in tmp */
 1190 
 1191         tracknr = get_tracknr_from_imagelist(tmp);
 1192         if (get_type_from_imagelist(tmp) == 1) {
 1193             /* audio */
 1194             type = 1;
 1195         } else {
 1196             /* data */
 1197             type = 0;
 1198         }
 1199         size = (gint) ((off_t)get_size_from_imagelist(tmp) >> 10);
 1200 
 1201         /* no info-file, therefore tracknr 0 */
 1202         if (tracknr == 0) {
 1203             /*
 1204              * we can only guess what the track could be -
 1205              * track 1 seems to be the most sensible choice
 1206              */
 1207             tracknr = 1;
 1208         }
 1209 
 1210                 /* allocate memory */
 1211                 trackparam = g_new0(track_read_param_t,1);
 1212 
 1213             trackparam->trackinfo_index = tracknr-1;
 1214                 trackparam->starttrack = tracknr;
 1215                 trackparam->endtrack = 0;
 1216                 trackparam->tracktype = type;
 1217                 per = (gfloat)size / sizecount;
 1218                 trackparam->percent = per;
 1219                 g_free(trackparam->trackfile);
 1220                 trackparam->trackfile = g_strdup(tmp);
 1221 
 1222         if (type == 0) {
 1223             /* data track */
 1224                         trackparam->kbyte = trackinfo[tracknr-1]->size *
 1225                                 (DATASECTORSIZE/1024);
 1226                         trackparam->frames = trackinfo[tracknr-1]->size;
 1227                         trackparam->startoffset = trackinfo[tracknr-1]->start_sec;
 1228                         if (tracknr-1 == cdinfo.nr_tracks-1) {
 1229                                 /* last track - leadout is track-end */
 1230                                 trackparam->endoffset = cdinfo.leadout - 2;     
 1231                         } else {
 1232                                 /* sub 150 (2 sec leadout),
 1233                                    sub 2 (2 run out sectors) */
 1234                                 trackparam->endoffset = 
 1235                                         trackinfo[tracknr]->start_sec -150-2; 
 1236                         }
 1237             /*
 1238              * now do a paranoia check
 1239              * in some cases we skip to much of a track
 1240              */
 1241                         sectorstoread = trackparam->endoffset -
 1242                                 trackparam->startoffset;
 1243             if (sectorstoread < trackinfo[tracknr-1]->isosize) {
 1244                                 trackparam->endoffset =
 1245                                         trackparam->startoffset +
 1246                                                 trackinfo[tracknr-1]->isosize;
 1247                                 trackparam->kbyte = trackinfo[tracknr-1]->isosize * 2;
 1248                 dodebug(1,"verifysometracks_clicked: corrected data track size from %d to %d sectors.\n", sectorstoread, trackinfo[tracknr-1]->isosize);
 1249             }
 1250                 } else {
 1251                         /* audio */
 1252                         trackparam->kbyte = trackinfo[tracknr-1]->size *
 1253                                 CDDAFRAME/1024;
 1254                         trackparam->frames = trackinfo[tracknr-1]->size;
 1255                 }
 1256 
 1257         
 1258                 trackreadset.trackparams = g_list_append(
 1259                         trackreadset.trackparams, trackparam);
 1260 
 1261                 sel = sel->next;
 1262         }
 1263 
 1264         /* assign an empty toc-filename */
 1265         g_free(trackreadset.tocfile);
 1266         trackreadset.tocfile = g_strdup("");
 1267 
 1268         /* now all parameters for verifying are set - lets begin */
 1269         show_and_do_verify_tracks(curset.reader_devnr);
 1270 }
 1271 
 1272 
 1273 static void verify_select_all(GtkWidget *widget, gpointer data) {
 1274 
 1275         gtk_clist_select_all(imglist);
 1276 }
 1277 
 1278 static void verify_select_none(GtkWidget *widget, gpointer data) {
 1279 
 1280         gtk_clist_unselect_all(imglist);
 1281 }
 1282 
 1283 static void verify_select_row(GtkWidget *clist, gint row, gint col,
 1284         GdkEventButton *event, gpointer data) {
 1285 
 1286         update_verify_size(row);
 1287 }
 1288 
 1289 
 1290 /*
 1291  * draw verify-tracks menu
 1292  */
 1293 static void draw_verify_tracks() {
 1294 GtkWidget *hbox, *vbox;
 1295 GtkWidget *f1, *f2, *f3;
 1296 GtkWidget *b1;
 1297 GtkWidget *e1;
 1298 GtkWidget *l1, *dummy;
 1299 GtkWidget *tbl, *check;
 1300 gchar *titles[2];
 1301 GtkWidget *scrolled_win, *img_list;
 1302 
 1303         /* prepare draw area */
 1304         clear_actionspace();
 1305 
 1306         f1 = gtk_frame_new(_("Devices-Setup"));
 1307         set_font_and_color_frame(f1,PANGO_BOLD,NULL);
 1308         gtk_box_pack_start(GTK_BOX(actionspace),f1,FALSE,FALSE,5);
 1309         gtk_widget_show(f1);
 1310 
 1311         tbl = gtk_table_new(2,16*4,TRUE); 
 1312         gtk_table_set_col_spacing(GTK_TABLE(tbl),4*4-1,5);
 1313         gtk_table_set_col_spacing(GTK_TABLE(tbl),15*4-2,5);
 1314         gtk_container_set_border_width(GTK_CONTAINER (tbl),5);
 1315         gtk_container_add(GTK_CONTAINER(f1),tbl);
 1316         gtk_widget_show(tbl);
 1317 
 1318         devices_setup_read(0, tbl, 1);
 1319         devices_setup_image(1, tbl);
 1320 
 1321         /* left and right info-frames */
 1322         tbl = gtk_table_new(1,2,TRUE);
 1323         gtk_table_set_col_spacings(GTK_TABLE(tbl),10);
 1324         gtk_box_pack_start(GTK_BOX(actionspace),tbl,TRUE,TRUE,10);
 1325         gtk_widget_show(tbl);
 1326         vbox = gtk_vbox_new(FALSE,10);
 1327         gtk_table_attach_defaults(GTK_TABLE(tbl),vbox,0,1,0,1);
 1328     if (!curset.isProDVD) {
 1329             f1 = gtk_frame_new(_("Disc-Information"));
 1330     } else {
 1331             f1 = gtk_frame_new(_("CD/DVD-Information"));
 1332     }
 1333         set_font_and_color_frame(f1,PANGO_BOLD,NULL);
 1334         gtk_box_pack_start(GTK_BOX(vbox),f1,TRUE,TRUE,0);
 1335         gtk_widget_show(f1);
 1336         f3 = gtk_frame_new(_("Verify options"));
 1337         set_font_and_color_frame(f3,PANGO_BOLD,NULL);
 1338         gtk_box_pack_start(GTK_BOX(vbox),f3,FALSE,FALSE,0);
 1339         gtk_widget_show(f3);
 1340         f2 = gtk_frame_new(_("Tracks to verify"));
 1341         set_font_and_color_frame(f2,PANGO_BOLD,NULL);
 1342         gtk_table_attach_defaults(GTK_TABLE(tbl),f2,1,2,0,1);
 1343         gtk_widget_show(f2);
 1344         gtk_widget_show(vbox);
 1345 
 1346         /* button bar at the bottom */
 1347         hbox = gtk_hbox_new(FALSE,5);
 1348         gtk_box_pack_start(GTK_BOX(actionspace),hbox,FALSE,TRUE,10);
 1349         gtk_widget_show(hbox);
 1350 
 1351         b1 = gtk_button_new_with_label(_("Select all"));
 1352         gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,10);
 1353         gtk_signal_connect(GTK_OBJECT(b1),"clicked",
 1354                 GTK_SIGNAL_FUNC(verify_select_all), NULL);
 1355     define_tooltip(b1,_("Selects all displayed images on the hard disk for verifying."));
 1356         gtk_widget_show(b1);
 1357 
 1358         b1 = gtk_button_new_with_label(_("Select none"));
 1359         gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,10);
 1360         gtk_signal_connect(GTK_OBJECT(b1),"clicked",
 1361                 GTK_SIGNAL_FUNC(verify_select_none), NULL);
 1362     define_tooltip(b1,_("Deselects all displayed images."));
 1363         gtk_widget_show(b1);
 1364 
 1365         dummy = gtk_label_new("");
 1366         gtk_box_pack_start(GTK_BOX(hbox),dummy,FALSE,FALSE,10);
 1367         gtk_widget_show(dummy);
 1368 
 1369         b1 = gtk_button_new_with_label(_("Verify selected tracks"));
 1370         gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,10);
 1371         gtk_widget_show(b1);
 1372         gtk_signal_connect(GTK_OBJECT(b1), "clicked",
 1373                 GTK_SIGNAL_FUNC(verifysometracks_clicked), NULL);
 1374     define_tooltip(b1,_("If the images do match the currently inserted Disc, start to read the images again and compare them with their copies on the hard disk."));
 1375 
 1376         /* left info frame */
 1377         vbox = gtk_vbox_new(FALSE,0);
 1378         gtk_container_add(GTK_CONTAINER(f1),vbox);
 1379         gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
 1380         gtk_widget_show(vbox);
 1381 
 1382         tbl = gtk_table_new(4,8,TRUE);
 1383         gtk_table_set_row_spacings(GTK_TABLE(tbl),10);
 1384         gtk_table_set_col_spacings(GTK_TABLE(tbl),10);
 1385         gtk_box_pack_start(GTK_BOX(vbox),tbl,FALSE,FALSE,10);
 1386         gtk_widget_show(tbl);
 1387         
 1388         l1 = rightjust_gtk_label_new(_("Type:"));
 1389         gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,2,0,1);
 1390         gtk_widget_show(l1);
 1391 
 1392         e1 = gtk_entry_new();
 1393         vrylist_l1 = e1;
 1394         gtk_entry_set_editable(GTK_ENTRY(e1),FALSE);
 1395         gtk_table_attach_defaults(GTK_TABLE(tbl),e1,2,8,0,1);
 1396         gtk_widget_show(e1);
 1397 
 1398         l1 = rightjust_gtk_label_new(_("Label:"));
 1399         gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,2,1,2);
 1400         gtk_widget_show(l1);
 1401 
 1402         e1 = gtk_entry_new();
 1403         vrylist_l2 = e1;
 1404         gtk_entry_set_editable(GTK_ENTRY(e1),FALSE);
 1405         gtk_table_attach_defaults(GTK_TABLE(tbl),e1,2,8,1,2);
 1406         gtk_widget_show(e1);
 1407 
 1408         l1 = rightjust_gtk_label_new(_("Size:"));
 1409         gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,2,2,3);
 1410         gtk_widget_show(l1);
 1411 
 1412         e1 = gtk_entry_new();
 1413         vrylist_l3 = e1;
 1414         gtk_entry_set_editable(GTK_ENTRY(e1),FALSE);
 1415         gtk_table_attach_defaults(GTK_TABLE(tbl),e1,2,8,2,3);
 1416         gtk_widget_show(e1);
 1417 
 1418         l1 = rightjust_gtk_label_new(_("Tracks:"));
 1419         gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,2,3,4);
 1420         gtk_widget_show(l1);
 1421 
 1422         e1 = gtk_entry_new();
 1423         vrylist_l4 = e1;
 1424         gtk_entry_set_editable(GTK_ENTRY(e1),FALSE);
 1425         gtk_table_attach_defaults(GTK_TABLE(tbl),e1,2,8,3,4);
 1426         gtk_widget_show(e1);
 1427 
 1428         /* options frame */
 1429         vbox = gtk_vbox_new(FALSE,0);
 1430         gtk_container_add(GTK_CONTAINER(f3),vbox);
 1431         gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
 1432         gtk_widget_show(vbox);
 1433 
 1434         tbl = gtk_table_new(2,8,TRUE);
 1435         gtk_table_set_col_spacings(GTK_TABLE(tbl),10);
 1436         gtk_box_pack_start(GTK_BOX(vbox),tbl,FALSE,FALSE,10);
 1437         gtk_widget_show(tbl);
 1438 
 1439         check = gtk_check_button_new_with_label(_("Don't verify audio tracks"));
 1440         gtk_signal_connect(GTK_OBJECT(check),"clicked",
 1441                 GTK_SIGNAL_FUNC(verifyoptions_selected),GINT_TO_POINTER(0));
 1442         gtk_table_attach_defaults(GTK_TABLE(tbl),check,1,8,0,1);
 1443         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 1444                 curset.noaudioverify);
 1445         gtk_widget_show(check);
 1446         define_tooltip(check, _("Skips verification of audio tracks, because a lot of optical disc drives are not able to read audio data reliably."));
 1447         
 1448         check = gtk_check_button_new_with_label(_("Abort after verify fail"));
 1449         gtk_signal_connect(GTK_OBJECT(check),"clicked",
 1450                 GTK_SIGNAL_FUNC(verifyoptions_selected),GINT_TO_POINTER(1));
 1451         gtk_table_attach_defaults(GTK_TABLE(tbl),check,1,8,1,2);
 1452         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 1453                 curset.verifyfailabort);
 1454         gtk_widget_show(check);
 1455         define_tooltip(check, _("Abort Verifying when one mismatch was found. Otherwise X-CD-Roast does continue to verify the other tracks anyway."));
 1456         
 1457     /* right frame */
 1458         vbox = gtk_vbox_new(FALSE,0);
 1459         gtk_container_add(GTK_CONTAINER(f2),vbox);
 1460         gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
 1461         gtk_widget_show(vbox);
 1462 
 1463         scrolled_win = gtk_scrolled_window_new (NULL, NULL);
 1464         gtk_box_pack_start(GTK_BOX(vbox),scrolled_win,TRUE,TRUE,0);
 1465         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
 1466                 GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
 1467         gtk_widget_show(scrolled_win);
 1468         
 1469         titles[0] = g_strdup("");
 1470         titles[1] = _("Images");
 1471         img_list = gtk_clist_new_with_titles(2,titles);
 1472         gtk_container_add (GTK_CONTAINER (scrolled_win), img_list);
 1473         imglist = GTK_CLIST(img_list);
 1474         gtk_signal_connect(GTK_OBJECT(imglist), "select_row",
 1475                 GTK_SIGNAL_FUNC(verify_select_row),NULL);
 1476         gtk_signal_connect(GTK_OBJECT(imglist), "unselect_row",
 1477                 GTK_SIGNAL_FUNC(verify_select_row),NULL);
 1478         gtk_clist_set_column_width(imglist, 0, 16);
 1479         gtk_clist_set_column_auto_resize(imglist, 1, TRUE);
 1480     gtk_clist_set_selection_mode (imglist, GTK_SELECTION_MULTIPLE);
 1481         gtk_widget_show(img_list);
 1482     gtk_widget_realize(img_list);
 1483 
 1484         tbl = gtk_table_new(1,8,TRUE);
 1485         gtk_table_set_row_spacings(GTK_TABLE(tbl),10);
 1486         gtk_table_set_col_spacings(GTK_TABLE(tbl),10);
 1487         gtk_box_pack_start(GTK_BOX(vbox),tbl,FALSE,FALSE,10);
 1488         gtk_widget_show(tbl);
 1489         
 1490         l1 = rightjust_gtk_label_new(_("Selected:"));
 1491         gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,2,0,1);
 1492         gtk_widget_show(l1);
 1493 
 1494         e1 = gtk_entry_new();
 1495         imglist_l1 = e1;
 1496         gtk_entry_set_editable(GTK_ENTRY(e1),FALSE);
 1497         gtk_table_attach_defaults(GTK_TABLE(tbl),e1,2,8,0,1);
 1498         gtk_widget_show(e1);
 1499 
 1500     gtk_widget_show(actionspace);
 1501 
 1502     /* fill entries */
 1503     fill_verify_tracks(0);
 1504 }
 1505 
 1506 
 1507 /*
 1508  * callback for the "Write tracks" button
 1509  */
 1510 static void writesometracks_clicked(GtkWidget *widget, gpointer data) {
 1511 gint ret, stat;
 1512 gint spaceneededoncd;
 1513 gint64 tmpsize, tmpsize2;
 1514 gchar tmptoc[MAXLINE];
 1515 GList *loop;
 1516 track_read_param_t *trackparam;
 1517 gint cdsize, avail, found;
 1518 gint msinfo1, msinfo2, m1, m2;
 1519 gint msdisk1, msdisk2;
 1520 gint founddata, foundaudio;
 1521 
 1522         /* no disc writer defined */
 1523         if (curset.writer_devnr == -1) {
 1524                 show_dialog(ICO_ERROR,_("No disc writer defined in Setup."), T_OK, NULL, NULL, 0);
 1525                 return;
 1526         }
 1527 
 1528     /* see if we have anything selected at all */
 1529     if (g_list_first(trackreadset.trackparams) == NULL) {
 1530         show_dialog(ICO_WARN,_("No Tracks layouted for writing"),T_OK,NULL,NULL,0);
 1531         return;
 1532     }
 1533 
 1534     msinfo1 = -1;
 1535     msinfo2 = -1;
 1536 
 1537     /* count what type of tracks we are handling */
 1538     foundaudio = 0;
 1539     founddata = 0;
 1540     loop = g_list_first(trackreadset.trackparams);
 1541     while(loop) {
 1542         trackparam = loop->data;
 1543         if (trackparam->trackfile != NULL) {
 1544             if (trackparam->tracktype == 0)
 1545                 founddata++;
 1546             if (trackparam->tracktype == 1)
 1547                 foundaudio++;
 1548         }
 1549         loop = loop->next;
 1550     }
 1551 
 1552     /* in multisession mode allow only to write one track at a time */
 1553     if (curset.multisession == 1) {
 1554 
 1555         /* allow only one data and no mixed tracks */
 1556         if (founddata > 1) {
 1557             show_dialog(ICO_WARN,_("In multi session mode only one data track can be written at a time."),T_OK,NULL,NULL,0);
 1558             return;
 1559         }
 1560         if (founddata > 0 && foundaudio > 0) {
 1561             show_dialog(ICO_WARN,_("In multi session mode you can't write both audio\nand data tracks at the same time."),T_OK,NULL,NULL,0);
 1562             return;
 1563         }
 1564 
 1565         /* ok, one file to write...get msinfo data */
 1566         loop = g_list_first(trackreadset.trackparams);
 1567         trackparam = loop->data;
 1568         if (trackparam->trackfile != NULL 
 1569             && trackparam->tracktype == 0) {
 1570             get_msinfo_from_imagelist(trackparam->trackfile,
 1571                 &msinfo1, &msinfo2);
 1572             dodebug(2,"got msinfo: %d,%d from inf-file: %s\n", msinfo1, msinfo2, trackparam->trackfile);
 1573         }   
 1574     } else {
 1575         /*
 1576          * no multisession..
 1577          * see if there is a track in the list
 1578          * that requires multisession
 1579          */
 1580         found = 0;
 1581         loop = g_list_first(trackreadset.trackparams);
 1582         while(loop) {
 1583             trackparam = loop->data;
 1584             if (trackparam->trackfile != NULL) {
 1585                 get_msinfo_from_imagelist(trackparam->trackfile,
 1586                     &m1, &m2);
 1587                 if (m1 >= 0 || m2 >= 0) {
 1588                     found = 1;
 1589                 }               
 1590             }
 1591             loop = loop->next;
 1592         }
 1593 
 1594         /* warn about multisession */
 1595         if (found) {
 1596                     ret = show_dialog(ICO_WARN,_("You are trying to write a multi session image\nwithout having multi session enabled.\nThis can result in an unreadable Disc."),T_ANYWAY,T_CANCEL,NULL,1);
 1597                     if (ret == 1) {
 1598                 return; 
 1599             }
 1600         }
 1601     }
 1602     
 1603     /*
 1604      * now check if the disc is the right one
 1605      * for our multisession needs
 1606      */
 1607     if (curset.multisession == 1) {
 1608         get_cd_toc_and_volid(curset.writer_devnr);
 1609             if (cdinfo.nr_tracks != -1) {
 1610                     get_msinfo_info(curset.writer_devnr, 
 1611                                 &msdisk1, &msdisk2);
 1612             } else {
 1613                     /* no disc loaded? abort */
 1614                     show_dialog(ICO_WARN,_("A Disc is required in the Writer before\na session can be added.\nPlease insert a Disc and try again."),T_OK,NULL,NULL,0);
 1615                         return;
 1616         }
 1617 
 1618         /* does the session info match to disc? (only for data tracks) */
 1619         if ((msdisk1 != msinfo1 || msdisk2 != msinfo2) && founddata > 0) {
 1620             ret = show_dialog(ICO_WARN,_("You are trying to write a session to a multi session Disc,\nwhere the current sessions do not match.\nThis can result in an unreadable Disc."), T_ANYWAY, T_CANCEL, NULL, 1);
 1621             if (ret == 1) {
 1622                 return; 
 1623             }
 1624         }
 1625     }
 1626 
 1627     tmpsize = (gint64)trackreadset.cdsize * 1024;
 1628     spaceneededoncd = (gint) ((gint64)tmpsize/CDDAFRAME);
 1629 
 1630     /*
 1631      * first check if all tracks we need are available on hd
 1632      * don't check for file sizes, we assume the user did not
 1633      * modify them since the last update of the imagelist
 1634      */
 1635         stat = check_write_files(1);
 1636         switch(stat) {
 1637                 /* files with wrong size */
 1638                 case 1:
 1639                         break;
 1640                 /* files missing */
 1641                 case 2:
 1642                         show_dialog(ICO_ERROR,_("Some of the image files you want to write are missing.\nPlease update the image directory."),T_OK,NULL,NULL,0);
 1643                         return;
 1644 
 1645                 /* no permission/invalid */
 1646                 case 3:
 1647                         show_dialog(ICO_ERROR,_("You don't have permission to read all the track-files or\nthe tracks are not regular files on the hard drive."),T_OK,NULL,NULL,0);
 1648                         return;
 1649 
 1650         /* invalid isrc or mcn */
 1651         case 4:
 1652             ret = show_dialog(ICO_WARN,_("Some of the audio files you want to write have been recorded\nwith an invalid ISRC or MCN id. X-CD-Roast can clear these\ninvalid ids for you and continue or you have to abort now."),"Clear and continue",T_CANCEL,NULL,1);
 1653             if (ret == 1) {
 1654                 /* abort */
 1655                 return;
 1656             } else {
 1657                 /* clear ids */
 1658                 stat = clear_isrc_mcn_from_tracks();
 1659                 if (stat == 1) {
 1660                     /* error resetting ids */
 1661                     show_dialog(ICO_ERROR,_("Failed to clear the ISRC or MCN id in all tracks.\nPerhaps you have no write permission on the .inf files?\nPlease correct the problem and try again."),T_OK,NULL,NULL,0); 
 1662                     return;
 1663                 }
 1664             }
 1665             break;
 1666     }
 1667 
 1668         /* check if enough space on disc? */
 1669         dodebug(2,"Sectors required: %d, Mediatype = %d\n", spaceneededoncd,
 1670                 curset.cdrtype);
 1671 
 1672         if (curset.cdrtype < 1000) {
 1673                 cdsize = curset.cdrtype*60*75;
 1674         } else {
 1675                 /* capacity of a DVD in bytes */
 1676                 tmpsize2 = (gint64)curset.cdrtype * 1000 * 1000;
 1677                 /* and now in sectors */
 1678                 tmpsize2 = tmpsize2 / 2048;
 1679 
 1680                 cdsize = (gint) tmpsize2;
 1681         }
 1682         avail = cdsize;
 1683 
 1684         /* we want to write multisession? consider session overhead */
 1685         if (curset.multisession == 1) {
 1686                 if (cdinfo.nr_tracks > 0) {
 1687                         /*
 1688              * additional sessions
 1689              * about 13 MiB
 1690              */
 1691                         avail -= 6900;
 1692                 } else {
 1693                         /*
 1694              * first session
 1695              * about 22 MiB
 1696              */
 1697                         avail -= 11400;
 1698                 }
 1699         }
 1700 
 1701         if (spaceneededoncd > avail) {
 1702         if (!is_dvdwriter(curset.writer_devnr)) {
 1703                     ret = show_dialog(ICO_WARN,_("There may be not enough space on the CD-R available.\nYou can continue at own risk, but the resulting CD\nmight not be readable."),T_ANYWAY,T_CANCEL,NULL,1);
 1704         } else {
 1705             /* perhaps we want to write a dvd? */
 1706             ret = show_dialog(ICO_WARN,_("There may be not enough space on the CD-R available.\nPerhaps you want to write a DVD, but you have not selected\nthe correct media size? You can continue at own\nrisk, but the resulting CD might not be readable."),T_ANYWAY,T_CANCEL,NULL,1);
 1707         }
 1708                 if (ret == 1) {
 1709                         /* aborted */
 1710                         return;
 1711                 }       
 1712         }
 1713 
 1714     /*
 1715      * check if wrong write mode
 1716      * for CD-Text is selected
 1717      */
 1718     if (curset.writecdtext) {
 1719         gshort i, wrmode;
 1720         i = get_writerreaderdevs_index(curset.writer_devnr);
 1721         wrmode = (writerreaderdevs[i]->writer_mode);
 1722         if (wrmode != 0 && wrmode != 3 && wrmode != 4) {
 1723             ret = show_dialog(ICO_WARN,_("Hint: The CD-Text will not be written.\nFor this, you need the Write Mode:\n \"DAO\" or \"raw96r\" or \"raw96p\"."),T_ANYWAY,T_CANCEL,NULL,1);
 1724             if (ret) {
 1725                 return;
 1726             }
 1727         }
 1728     }
 1729 
 1730     /*
 1731      * ok, now we are sure that all tracks are fine
 1732      * ...prompt for disc
 1733      */
 1734     if (curset.multisession == 0) {
 1735         ret = show_dialog(ICO_INFO,pleaseinsertmedia(),T_OK,T_CANCEL,NULL,0);
 1736     } else {
 1737         /* multisession */
 1738         if (msinfo2 > 0) {
 1739             /* add new session */
 1740             if (curset.cdrtype >= 1000 && is_dvdwriter(curset.writer_devnr)) {
 1741                 ret = show_dialog(ICO_INFO,_("Ready to add a new session to a multi session DVD?"),T_OK,T_CANCEL,NULL,0);
 1742             } else {
 1743                 ret = show_dialog(ICO_INFO,_("Ready to add a new session to a multi session CD?"),T_OK,T_CANCEL,NULL,0);
 1744             }
 1745         } else {
 1746             /* write first session */
 1747             if (curset.cdrtype >= 1000 && is_dvdwriter(curset.writer_devnr)) {
 1748                 ret = show_dialog(ICO_INFO,_("Ready to write the first session of a multi session DVD?"),T_OK,T_CANCEL,NULL,0);
 1749             } else {
 1750                 ret = show_dialog(ICO_INFO,_("Ready to write the first session of a multi session CD?"),T_OK,T_CANCEL,NULL,0);
 1751             }
 1752         }
 1753     }
 1754     if (ret != 0) {
 1755         return;
 1756     }
 1757 
 1758     /*
 1759      * if we have to write CD-Text then
 1760      * edit the .inf files from cdda2wav
 1761      */
 1762     if (curset.writecdtext) {
 1763         loop = g_list_first(trackreadset.trackparams);
 1764         while(loop) {
 1765             trackparam = loop->data;
 1766             if (trackparam->trackfile != NULL) {
 1767                 generate_tmp_tocfile_name(tmptoc);
 1768                 edit_xinf_for_cd_text(trackparam->trackfile,
 1769                     tmptoc);
 1770             }
 1771             loop = loop->next;
 1772         }   
 1773 
 1774     }
 1775 
 1776     /* start writing */
 1777         show_and_do_write_tracks(curset.writer_devnr, -1, 0);
 1778 }
 1779 
 1780 
 1781 /*
 1782  * callback for fixate disc
 1783  */
 1784 static void fixate_clicked(GtkWidget *widget, gpointer data) {
 1785 gint ret;
 1786 
 1787         /* no disc writer defined */
 1788         if (curset.writer_devnr == -1) {
 1789                 show_dialog(ICO_ERROR,_("No disc writer defined in Setup."), T_OK, NULL, NULL, 0);
 1790                 return;
 1791         }
 1792 
 1793         /* prompt for disc */
 1794         ret = show_dialog(ICO_INFO,pleaseinsertmedia(),T_OK,T_CANCEL,NULL,0);
 1795         if (ret != 0) {
 1796                 return;
 1797         }
 1798 
 1799     /* start fixating */
 1800     show_and_do_write_tracks(curset.writer_devnr, -1, 2);
 1801 }
 1802 
 1803 
 1804 /*
 1805  * redraw the selected-tracks list
 1806  */
 1807 void redraw_writelist(GtkCList *llist, GtkWidget *lentry) {
 1808 GList *loop;
 1809 gchar *track;
 1810 gchar tmp[MAXLINE];
 1811 gchar tmp2[MAXLINE];
 1812 gchar titlestr[MAXLINE];
 1813 GtkStyle *style;
 1814 gchar *data[2];
 1815 GdkPixmap *pixmap1, *pixmap2, *pixmap3;
 1816 GdkBitmap *mask1, *mask2, *mask3;
 1817 gchar basename[MAXLINE], fname[MAXLINE], *p;
 1818 image_files_t *entry;
 1819 gint count,lcount;
 1820 gint sizecount;
 1821 gint toprow, topcol;
 1822 
 1823     /* get current scroll position */
 1824         if(!gtk_clist_get_selection_info(llist, 0, 0, &toprow, &topcol)) {
 1825                 toprow = 0;
 1826                 topcol = 0;
 1827         }
 1828 
 1829         /* clean up first */
 1830     gtk_clist_freeze(llist);
 1831         gtk_clist_clear(llist);
 1832 
 1833         style = gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(imglist)));
 1834         pixmap1 = gdk_pixmap_create_from_xpm_d(llist->clist_window,
 1835                 &mask1, &style->bg[GTK_STATE_NORMAL],(gchar **)minidata_xpm);
 1836         pixmap2 = gdk_pixmap_create_from_xpm_d(llist->clist_window,
 1837                 &mask2, &style->bg[GTK_STATE_NORMAL],(gchar **)miniaudio_xpm);
 1838         pixmap3 = gdk_pixmap_create_from_xpm_d(llist->clist_window,
 1839                 &mask3, &style->bg[GTK_STATE_NORMAL],(gchar **)mininodata_xpm);
 1840 
 1841         data[0] = NULL;
 1842     count = 1;
 1843     lcount = 0;
 1844     sizecount = 0;
 1845 
 1846     loop = g_list_first(writelist);
 1847     while (loop) {
 1848         track = loop->data;
 1849         entry = get_entry_from_imagelist(track);
 1850         if (entry == NULL) {
 1851             /* should never happen */
 1852             loop = loop->next;
 1853             continue;
 1854         }
 1855                 /* get the base-dirname */
 1856                 strncpy(basename,entry->path,MAXLINE);  
 1857                 p = rindex(basename,'/');
 1858                 *p = '\0';
 1859                 if (strcmp(basename,"") == 0) {
 1860                         strcpy(basename,"/");
 1861                 }
 1862                 strcpy(fname, p+1);
 1863     
 1864         sizecount+=(gint) ((off_t)get_size_from_imagelist(track) >> 10);
 1865                 strcpy(titlestr,"");
 1866                 assign_trackname(titlestr, entry);
 1867 
 1868                 /* no title found - so use filename as title */
 1869                 if (strcmp(titlestr,"") == 0) {
 1870                         strcpy(titlestr,fname);
 1871                 }
 1872 
 1873                 /* iso9600-track/ unknown  */
 1874                 if (entry->type == 0 || entry->type == 3) {
 1875                         convert_frames2mbstring((gint)((off_t)entry->size/DATASECTORSIZE),
 1876                                 tmp2);
 1877                         g_snprintf(tmp,MAXLINE,"%2d. %s [%s]",
 1878                                 count, titlestr, tmp2);
 1879                         data[1] = convert_for_gtk2(tmp);
 1880                         gtk_clist_append(llist,data);
 1881                         if (entry->type == 0) {
 1882                                 gtk_clist_set_pixmap(llist,lcount,0,pixmap1,mask1);   
 1883                         } else {
 1884                                 gtk_clist_set_pixmap(llist,lcount,0,pixmap3,mask3);   
 1885                         }
 1886                         count++;
 1887                         lcount++;
 1888                 }
 1889 
 1890                 /* valid wav-file */
 1891                 if (entry->type == 1) {
 1892                         convert_frames2minstring((gint)((off_t)entry->size/CDDAFRAME), tmp2);
 1893                         g_snprintf(tmp,MAXLINE,"%2d. %s [%s]",
 1894                                 count, titlestr, tmp2);
 1895                         data[1] = convert_for_gtk2(tmp);
 1896                         gtk_clist_append(llist,data);
 1897                         gtk_clist_set_pixmap(llist,lcount,0,pixmap2,mask2);   
 1898                         lcount++;
 1899                         count++;
 1900                 }       
 1901         
 1902         loop = loop->next;
 1903     }
 1904 
 1905     /* now scroll to remembered position */
 1906     gtk_clist_moveto(llist, toprow, topcol, 0.0, 0.0);
 1907     gtk_clist_thaw(llist);
 1908     
 1909         convert_kbytes2mbminstring(sizecount, tmp);
 1910         gtk_entry_set_text(GTK_ENTRY(lentry), tmp);
 1911 }
 1912 
 1913 
 1914 /*
 1915  * fill the tracks-to-write list
 1916  */
 1917 void fill_writelist2(GtkCList *llist, GtkWidget *lentry) {
 1918 GList *loop;
 1919 track_read_param_t *trackparam;
 1920 gchar track[MAXLINE];
 1921 gchar tmp[MAXLINE];
 1922 gchar tmp2[MAXLINE];
 1923 gchar titlestr[MAXLINE];
 1924 GtkStyle *style;
 1925 gchar *data[2];
 1926 GdkPixmap *pixmap1, *pixmap2, *pixmap3;
 1927 GdkBitmap *mask1, *mask2, *mask3;
 1928 gchar basename[MAXLINE], fname[MAXLINE], *p;
 1929 image_files_t *entry;
 1930 gint count,lcount;
 1931 gint toprow, topcol;
 1932 
 1933     /* get current scroll position */
 1934         if(!gtk_clist_get_selection_info(llist, 0, 0, &toprow, &topcol)) {
 1935                 toprow = 0;
 1936                 topcol = 0;
 1937         }
 1938 
 1939         /* clean up first */
 1940     gtk_clist_freeze(llist);
 1941         gtk_clist_clear(llist);
 1942 
 1943         style = gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(imglist)));
 1944         pixmap1 = gdk_pixmap_create_from_xpm_d(llist->clist_window,
 1945                 &mask1, &style->bg[GTK_STATE_NORMAL],(gchar **)minidata_xpm);
 1946         pixmap2 = gdk_pixmap_create_from_xpm_d(llist->clist_window,
 1947                 &mask2, &style->bg[GTK_STATE_NORMAL],(gchar **)miniaudio_xpm);
 1948         pixmap3 = gdk_pixmap_create_from_xpm_d(llist->clist_window,
 1949                 &mask3, &style->bg[GTK_STATE_NORMAL],(gchar **)mininodata_xpm);
 1950 
 1951         data[0] = NULL;
 1952     count = 1;
 1953     lcount = 0;
 1954 
 1955     loop = g_list_first(trackreadset.trackparams);
 1956     while (loop) {
 1957         trackparam = loop->data;
 1958 
 1959         strcpy(track, trackparam->trackfile);
 1960 
 1961         entry = get_entry_from_imagelist(track);
 1962         if (entry == NULL) {
 1963             /* should never happen */
 1964             loop = loop->next;
 1965             continue;
 1966         }
 1967                 /* get the base-dirname */
 1968                 strncpy(basename,track,MAXLINE);  
 1969                 p = rindex(basename,'/');
 1970                 *p = '\0';
 1971                 if (strcmp(basename,"") == 0) {
 1972                         strcpy(basename,"/");
 1973                 }
 1974                 strcpy(fname, p+1);
 1975     
 1976                 strcpy(titlestr,"");
 1977                 assign_trackname(titlestr, entry);
 1978 
 1979                 /* no title found - so use filename as title */
 1980                 if (strcmp(titlestr,"") == 0) {
 1981                         strcpy(titlestr,fname);
 1982                 }
 1983 
 1984                 /* data  */
 1985                 if (trackparam->tracktype == 0) {
 1986                         convert_frames2mbstring((gint)((off_t)entry->size/DATASECTORSIZE),
 1987                                 tmp2);
 1988                         g_snprintf(tmp,MAXLINE,"%2d. %s [%s]",
 1989                                 count, titlestr, tmp2);
 1990                         data[1] = convert_for_gtk2(tmp);
 1991                         gtk_clist_append(llist,data);
 1992                         if (entry->type == 0) {
 1993                                 gtk_clist_set_pixmap(llist,lcount,0,pixmap1,mask1);   
 1994                         } else {
 1995                                 gtk_clist_set_pixmap(llist,lcount,0,pixmap3,mask3);   
 1996                         }
 1997                         count++;
 1998                         lcount++;
 1999                 }
 2000 
 2001                 /* valid wav-file */
 2002                 if (entry->type == 1) {
 2003                         convert_frames2minstring((gint)((off_t)entry->size/CDDAFRAME), tmp2);
 2004                         g_snprintf(tmp,MAXLINE,"%2d. %s [%s]",
 2005                                 count, titlestr, tmp2);
 2006                         data[1] = convert_for_gtk2(tmp);
 2007                         gtk_clist_append(llist,data);
 2008                         gtk_clist_set_pixmap(llist,lcount,0,pixmap2,mask2);   
 2009                         lcount++;
 2010                         count++;
 2011                 }       
 2012         
 2013         loop = loop->next;
 2014     }
 2015 
 2016     /* now scroll to remembered position */
 2017     gtk_clist_moveto(llist, toprow, topcol, 0.0, 0.0);
 2018     gtk_clist_thaw(llist);
 2019     
 2020         convert_kbytes2mbminstring(trackreadset.cdsize, tmp);
 2021         gtk_entry_set_text(GTK_ENTRY(lentry), tmp);
 2022 }
 2023 
 2024 
 2025 static void write_delete_tracks(GtkWidget *widget, gpointer data) {
 2026 gint nrtracks;
 2027 GList *sel, *loop, *loop2;
 2028 gint row;
 2029 
 2030         nrtracks = 0;
 2031 
 2032     /* get the list of track-filenames to remove from the write-list */
 2033         sel = cdlist->selection;
 2034         while (sel) {
 2035                 row = GPOINTER_TO_INT(sel->data);
 2036         loop = g_list_nth(g_list_first(writelist),row);
 2037         if (loop && loop->data) {
 2038             /* mark as deleted */
 2039             g_free(loop->data);
 2040             loop->data = NULL;
 2041         }
 2042                 nrtracks++;
 2043                 sel = sel->next;
 2044         }
 2045 
 2046         /* no tracks selected */
 2047         if (nrtracks == 0) {
 2048                 show_dialog(ICO_WARN,_("No tracks selected"),T_OK,NULL,NULL,0);
 2049                 return;
 2050         }
 2051 
 2052     /* now really remove from list */
 2053     loop = g_list_first(writelist);
 2054     while (loop) {
 2055         loop2 = loop->next;
 2056         if (loop->data == NULL) {
 2057             writelist = g_list_remove_link(writelist, loop);
 2058         }
 2059         loop = loop2;
 2060     }
 2061 
 2062     redraw_writelist(cdlist,cdlist_l1);
 2063     fill_write_tracks();
 2064 }
 2065 
 2066 
 2067 static void write_add_tracks(GtkWidget *widget, gpointer data) {
 2068 gint nrtracks;
 2069 GList *sel;
 2070 gint row;
 2071 gchar tmp[MAXLINE];
 2072 
 2073         nrtracks = 0;
 2074 
 2075     /* get the list of track-filenames to add to the write-list */
 2076         sel = imglist->selection;
 2077         while (sel) {
 2078                 row = GPOINTER_TO_INT(sel->data);
 2079                 if (get_trackname_from_row(row, tmp) == 0) {
 2080                         /*
 2081              * we get now the full track-filename in tmp
 2082              * add to list
 2083              */
 2084             writelist = g_list_append(writelist,g_strdup(tmp));
 2085         }
 2086                 nrtracks++;
 2087                 sel = sel->next;
 2088         }
 2089 
 2090         /* no tracks selected */
 2091         if (nrtracks == 0) {
 2092                 show_dialog(ICO_WARN,_("No tracks selected"),T_OK,NULL,NULL,0);
 2093                 return;
 2094         }
 2095 
 2096     redraw_writelist(cdlist,cdlist_l1);
 2097     fill_write_tracks();
 2098 }
 2099 
 2100 
 2101 /*
 2102  * accept tracklayout button
 2103  */
 2104 static void accept_layout_clicked(GtkWidget *widget, gpointer notebook) {
 2105 GList *loop;
 2106 track_read_param_t *trackparam;
 2107 gchar *track;
 2108 gint count,cdsize;
 2109 image_files_t *entry;
 2110 gfloat per;
 2111 
 2112     if (notebook) {
 2113         /* see if we have anything selected at all */
 2114         if (g_list_first(writelist) == NULL) {
 2115             show_dialog(ICO_WARN,_("No Tracks layouted for writing"),T_OK,NULL,NULL,0);
 2116             return;
 2117         }
 2118     }
 2119 
 2120     /*
 2121      * fill the trackreadset with our tracks to write
 2122      * clear first
 2123      */
 2124     clear_trackreadset();
 2125 
 2126     cdsize = 0;
 2127     count = 1;
 2128 
 2129         loop = g_list_first(writelist);
 2130         while (loop) {
 2131                 track = loop->data;
 2132                 entry = get_entry_from_imagelist(track);
 2133                 if (entry == NULL) {
 2134                         /* should never happen */
 2135                         loop = loop->next;
 2136                         continue;
 2137                 }
 2138 
 2139                 /* allocate memory */
 2140                 trackparam = g_new0(track_read_param_t,1);
 2141 
 2142                 trackparam->trackinfo_index = -1;
 2143                 trackparam->starttrack = count;
 2144                 trackparam->endtrack = 0;
 2145         if (entry->type == 1) {
 2146             /* audio */
 2147             trackparam->tracktype = 1;
 2148             trackparam->frames = (gint) ((off_t)entry->size/CDDAFRAME);
 2149         } else {
 2150             /* data */
 2151             trackparam->tracktype = 0;
 2152             trackparam->frames = (gint) ((off_t)entry->size/DATASECTORSIZE);
 2153         }
 2154         trackparam->kbyte = (gint) ((off_t)entry->size >> 10);  
 2155         g_free(trackparam->trackfile);
 2156         trackparam->trackfile = g_strdup(track);
 2157 
 2158         cdsize += trackparam->kbyte;
 2159                 trackreadset.nrtracks++;        
 2160         count++;
 2161 
 2162         trackreadset.trackparams = g_list_append(
 2163             trackreadset.trackparams, trackparam);
 2164 
 2165                 loop = loop->next;
 2166         }
 2167 
 2168         trackreadset.cdsize = cdsize;
 2169 
 2170         /* ok..all data read - now calculate the percentages */
 2171         loop = g_list_first(trackreadset.trackparams);
 2172         while(loop) {
 2173                 trackparam = loop->data;
 2174                 per = (gfloat)trackparam->kbyte / cdsize;
 2175                 trackparam->percent = per;
 2176 
 2177                 loop = loop->next;
 2178         }
 2179 
 2180         if (debug > 1) 
 2181                 print_trackreadset();
 2182 
 2183     /* fill listing on page 1 */
 2184     fill_writelist2(imglist2,imglist_l2);
 2185 
 2186     if (notebook) {
 2187         /* now change notebook tab back to page 1 */
 2188         gtk_notebook_set_page(GTK_NOTEBOOK(notebook), 1);
 2189     }
 2190 }
 2191 
 2192 
 2193 /*
 2194  * called when you change tabs in the write tracks menu
 2195  * detect when switching from layout to view mode
 2196  */
 2197 static void writetracks_notebookswitch(GtkWidget *widget, GtkNotebookPage *page, gint page_num) {
 2198 gint curpage;
 2199 
 2200     curpage = gtk_notebook_get_current_page(GTK_NOTEBOOK(widget));
 2201 
 2202     /* user clicked "write tracks" while in "layout tracks" */
 2203     if (curpage == 0 && page_num == 1) {    
 2204         /* simulate click on accept layout */
 2205         accept_layout_clicked(widget, NULL);
 2206     }
 2207 }
 2208 
 2209 
 2210 void fill_write_tracks() {
 2211 gchar tmp[MAXLINE], tmp2[MAXLINE];
 2212 gchar titlestr[MAXLINE];
 2213 GList *loop;
 2214 GtkStyle *style;
 2215 gchar *data[2];
 2216 GdkPixmap *pixmap1, *pixmap2, *pixmap3;
 2217 GdkBitmap *mask1, *mask2, *mask3;
 2218 gchar basename[MAXLINE], imgdir[MAXLINE], fname[MAXLINE], *p;
 2219 gint lcount, count;
 2220 image_files_t *entry;
 2221 gint toprow, topcol;
 2222 
 2223     /* get current scroll position */
 2224         if(!gtk_clist_get_selection_info(imglist, 0, 0, &toprow, &topcol)) {
 2225                 toprow = 0;
 2226                 topcol = 0;
 2227         }
 2228 
 2229         /* clean up first */
 2230     gtk_clist_freeze(imglist);
 2231         gtk_clist_clear(imglist);
 2232 
 2233         style = gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(imglist)));
 2234         pixmap1 = gdk_pixmap_create_from_xpm_d(imglist->clist_window,
 2235                 &mask1, &style->bg[GTK_STATE_NORMAL],(gchar **)minidata_xpm);
 2236         pixmap2 = gdk_pixmap_create_from_xpm_d(imglist->clist_window,
 2237                 &mask2, &style->bg[GTK_STATE_NORMAL],(gchar **)miniaudio_xpm);
 2238         pixmap3 = gdk_pixmap_create_from_xpm_d(imglist->clist_window,
 2239                 &mask3, &style->bg[GTK_STATE_NORMAL],(gchar **)mininodata_xpm);
 2240 
 2241         data[0] = NULL;
 2242         strcpy(imgdir,"");
 2243         count = 1;
 2244         lcount = 0;
 2245 
 2246         /* check image-selector */
 2247         if (curset.image_index != -1) {
 2248                 /* no automatic setting? */
 2249                 strncpy(imgdir,(gchar *)g_list_nth_data(setupdata.image_dirs,
 2250                         curset.image_index), MAXLINE);
 2251         }
 2252 
 2253         loop = g_list_first(imagelist);
 2254         while (loop) {
 2255                 entry = loop->data;
 2256 
 2257                 /* get the base-dirname */
 2258                 strncpy(basename,entry->path,MAXLINE);  
 2259                 p = rindex(basename,'/');
 2260                 *p = '\0';
 2261                 if (strcmp(basename,"") == 0) {
 2262                         strcpy(basename,"/");
 2263                 }
 2264                 strcpy(fname, p+1);
 2265 
 2266                 if (strcmp(basename,imgdir) != 0 && imgdir[0] != '\0') {
 2267                         /* skip not selected dirs */
 2268                         loop = loop->next;
 2269                         continue;
 2270                 }
 2271 
 2272                 if (entry->readable == 0) {
 2273                         /* don't display not readable files */
 2274                         loop = loop->next;
 2275                         continue;
 2276                 }
 2277 
 2278                 strcpy(titlestr,"");
 2279         assign_trackname(titlestr, entry);
 2280 
 2281                 /* no title found - so use filename as title */
 2282                 if (strcmp(titlestr,"") == 0) {
 2283                         strcpy(titlestr,fname);
 2284                 }
 2285 
 2286                 /* iso9600-track/ unknown  */
 2287                 if (entry->type == 0 || entry->type == 3) {
 2288                         convert_frames2mbstring((gint)((off_t)entry->size/DATASECTORSIZE),
 2289                                 tmp2);
 2290                         g_snprintf(tmp,MAXLINE,"%2d. %s [%s] (%s)",
 2291                                 count, titlestr, tmp2, entry->path);
 2292                         data[1] = convert_for_gtk2(tmp);
 2293                         gtk_clist_append(imglist,data);
 2294 
 2295             if (is_on_writelist(entry->path)) {
 2296                 /* already on writelist? change color */
 2297                 set_clist_row_color(imglist,
 2298                     lcount,SELECTEDCLISTCOL);
 2299             }
 2300 
 2301                         if (entry->type == 0) {
 2302                                 gtk_clist_set_pixmap(imglist,lcount,0,pixmap1,mask1);   
 2303                         } else {
 2304                                 gtk_clist_set_pixmap(imglist,lcount,0,pixmap3,mask3);   
 2305                         }
 2306                         count++;
 2307                         lcount++;
 2308                 }
 2309 
 2310                 /* valid wav-file */
 2311                 if (entry->type == 1) {
 2312                         convert_frames2minstring((gint)((off_t)entry->size/CDDAFRAME), tmp2);
 2313                         g_snprintf(tmp,MAXLINE,"%2d. %s [%s] (%s)",
 2314                                 count, titlestr, tmp2, entry->path);
 2315                         data[1] = convert_for_gtk2(tmp);
 2316                         gtk_clist_append(imglist,data);
 2317 
 2318             if (is_on_writelist(entry->path)) {
 2319                 /* already on writelist? change color */
 2320                 set_clist_row_color(imglist,
 2321                     lcount,SELECTEDCLISTCOL);
 2322             }
 2323 
 2324                         gtk_clist_set_pixmap(imglist,lcount,0,pixmap2,mask2);   
 2325                         lcount++;
 2326                         count++;
 2327                 }       
 2328 
 2329                 loop = loop->next;
 2330         }
 2331 
 2332     /* now scroll to remembered position */
 2333     gtk_clist_moveto(imglist, toprow, topcol, 0.0, 0.0);
 2334     gtk_clist_thaw(imglist);
 2335 
 2336         /* nothing selected - no size of files */
 2337         convert_kbytes2mbminstring(0, tmp);
 2338         gtk_entry_set_text(GTK_ENTRY(imglist_l1), tmp);  
 2339     
 2340     /* dummy focus of entry to make sure the clists got no focus,
 2341        which might be funny in drag&drop */
 2342     gtk_widget_grab_focus(imglist_l1);
 2343 }
 2344 
 2345 
 2346 /*
 2347  * allow to drag tracks out of the right track window
 2348  */
 2349 static void writetracks_request_dnddata(GtkWidget *widget, GdkDragContext *dc,
 2350         GtkSelectionData *selection_data, guint info, guint t, 
 2351         gpointer data) {
 2352 gboolean data_sent = FALSE;
 2353 GtkCList *clist;
 2354 GList *sel;
 2355 gint row, focusrow, bufcount;
 2356 gchar tmp[MAXLINE];
 2357 gchar tmp2[MAXLINE];
 2358 gchar bigtmp[MAXLINE*10];
 2359 gint use_selection;
 2360 
 2361     clist = GTK_CLIST(widget);
 2362     focusrow = clist->focus_row;
 2363     use_selection = 0;
 2364 
 2365     /* see if any other rows are selected */
 2366         sel = clist->selection;
 2367         while (sel) {
 2368                 row = GPOINTER_TO_INT(sel->data);
 2369         if (row == focusrow) {
 2370                         /* we focused a row that is selected, remember */
 2371                         use_selection = 1;
 2372         }
 2373                 sel = sel->next;
 2374         }
 2375 
 2376         /* Selected row in bounds? */
 2377         if ((focusrow >= 0) && (focusrow < clist->rows) && (GTK_WIDGET_HAS_FOCUS(widget))) {
 2378 
 2379                 /* return single track from focused line */
 2380                 if (use_selection == 0) {
 2381             if (get_trackname_from_row(focusrow, tmp) == 0) {
 2382                 g_snprintf(bigtmp,MAXLINE*10,"xcdr:%s", tmp);
 2383                 gtk_selection_data_set(
 2384                     selection_data,
 2385                     GDK_SELECTION_TYPE_STRING, 8,
 2386                     (const unsigned char *) bigtmp, strlen(bigtmp));
 2387                 data_sent = TRUE;
 2388             }   
 2389         } else {
 2390             /* return not from focus but all selected */
 2391             strcpy(bigtmp,"");
 2392             bufcount = 0;   
 2393                 sel = clist->selection;
 2394                 while (sel) {
 2395                         row = GPOINTER_TO_INT(sel->data);
 2396                         if (get_trackname_from_row(row, tmp) == 0) {
 2397                     g_snprintf(tmp2,MAXLINE,"xcdr:%s\r\n", tmp);
 2398 
 2399                     bufcount+=strlen(tmp2);
 2400                     if (bufcount < MAXLINE*10) {
 2401                         strcat(bigtmp,tmp2);
 2402                     }
 2403                 }
 2404                         sel = sel->next;
 2405             }
 2406             if (bufcount > 0) {
 2407                                 gtk_selection_data_set(
 2408                                         selection_data,
 2409                                         GDK_SELECTION_TYPE_STRING, 8, 
 2410                                         (const unsigned char *) bigtmp, strlen(bigtmp));
 2411                                 data_sent = TRUE;
 2412             }
 2413         }
 2414     }
 2415 
 2416         /* we have to send something even in an error case */
 2417         if (!data_sent) {
 2418                 const gchar *cstrptr = "Error";
 2419 
 2420                 gtk_selection_data_set(
 2421                         selection_data,
 2422                         GDK_SELECTION_TYPE_STRING, 8,
 2423                         (const unsigned char *) cstrptr, strlen(cstrptr));
 2424         }
 2425 }
 2426 
 2427 
 2428 /*
 2429  * allow to drag tracks out of the left track window
 2430  * to have them deleted
 2431  */
 2432 static void writetracksleft_request_dnddata(GtkWidget *widget, 
 2433     GdkDragContext *dc,
 2434         GtkSelectionData *selection_data, guint info, guint t, 
 2435         gpointer data) {
 2436 gboolean data_sent = FALSE;
 2437 GtkCList *clist;
 2438 GList *sel, *loop;
 2439 gint row, focusrow, bufcount;
 2440 gchar tmp2[MAXLINE];
 2441 gchar bigtmp[MAXLINE*10];
 2442 gint use_selection;
 2443 
 2444     clist = GTK_CLIST(widget);
 2445     focusrow = clist->focus_row;
 2446     use_selection = 0;
 2447 
 2448     /* see if any other rows are selected */
 2449         sel = clist->selection;
 2450         while (sel) {
 2451                 row = GPOINTER_TO_INT(sel->data);
 2452         if (row == focusrow) {
 2453                         /* we focused a row that is selected, remember */
 2454                         use_selection = 1;
 2455         }
 2456                 sel = sel->next;
 2457         }
 2458 
 2459         /* Selected row in bounds? */
 2460         if ((focusrow >= 0) && (focusrow < clist->rows) && (GTK_WIDGET_HAS_FOCUS(widget))) {
 2461 
 2462                 /* return single track from focused line */
 2463                 if (use_selection == 0) {
 2464             loop = g_list_nth(g_list_first(writelist),focusrow);
 2465             if (loop && loop->data) {
 2466                 g_snprintf(bigtmp, MAXLINE, "xrmv:%d", focusrow);
 2467                 gtk_selection_data_set(
 2468                     selection_data,
 2469                     GDK_SELECTION_TYPE_STRING, 8,
 2470                     (const unsigned char *) bigtmp, strlen(bigtmp));
 2471                 data_sent = TRUE;
 2472             }   
 2473         } else {
 2474             /* return not from focus but all selected */
 2475             strcpy(bigtmp,"");
 2476             bufcount = 0;   
 2477                 sel = clist->selection;
 2478                 while (sel) {
 2479                         row = GPOINTER_TO_INT(sel->data);
 2480                 loop = g_list_nth(g_list_first(writelist),row);
 2481                 if (loop && loop->data) {
 2482                     g_snprintf(tmp2, MAXLINE, "xrmv:%d\r\n", row);
 2483                     bufcount+=strlen(tmp2);
 2484                     if (bufcount < MAXLINE*10) {
 2485                         strcat(bigtmp,tmp2);
 2486                     }
 2487                 }
 2488                         sel = sel->next;
 2489             }
 2490             if (bufcount > 0) {
 2491                                 gtk_selection_data_set(
 2492                                         selection_data,
 2493                                         GDK_SELECTION_TYPE_STRING, 8, 
 2494                                         (const unsigned char *) bigtmp, strlen(bigtmp));
 2495                                 data_sent = TRUE;
 2496             }
 2497         }
 2498     }
 2499 
 2500         /* we have to send something even in an error case */
 2501         if (!data_sent) {
 2502                 const gchar *cstrptr = "Error";
 2503 
 2504                 gtk_selection_data_set(
 2505                         selection_data,
 2506                         GDK_SELECTION_TYPE_STRING, 8,
 2507                         (const unsigned char *) cstrptr, strlen(cstrptr));
 2508         }
 2509 }
 2510 
 2511 
 2512 /*
 2513  * move the rows from the reorderlist before the given droprow
 2514  * quite complex because we can select more than one row to move
 2515  */
 2516 static void writetracks_drag_reorder(GList *reorderlist, gint droprow) {
 2517 GList *loop, *l1;
 2518 gint srcrow;
 2519 gint smallest, highest;
 2520 gint count;
 2521 
 2522     /* empty list? nothing to do */
 2523     if (!reorderlist)
 2524         return;
 2525 
 2526     /* sort reorderlist first */
 2527     sort_int_glist(reorderlist);
 2528 
 2529     loop = g_list_first(reorderlist);
 2530     smallest = GPOINTER_TO_INT(loop->data);
 2531 
 2532     loop = g_list_last(reorderlist);
 2533     highest = GPOINTER_TO_INT(loop->data);
 2534 
 2535     if (droprow == -1) {
 2536         /* dropped beyond last track? assume its the last */
 2537         droprow = g_list_length(writelist)-1;
 2538     }
 2539 
 2540     /* move up? */
 2541     if (droprow < smallest) {
 2542       loop = g_list_last(reorderlist);
 2543       count = 0;
 2544       while (loop) {
 2545         srcrow = GPOINTER_TO_INT(loop->data);
 2546         l1 = g_list_nth(g_list_first(writelist), srcrow+count);
 2547 
 2548             if (srcrow+count > droprow) {
 2549                     writelist = g_list_insert(writelist, l1->data, droprow);
 2550                     writelist = g_list_remove_link(writelist, l1);
 2551             } else {
 2552                     writelist = g_list_insert(writelist, l1->data, droprow+1);
 2553                     writelist = g_list_remove_link(writelist, l1);
 2554             }
 2555         count++;
 2556 
 2557         loop = loop->prev;
 2558       }     
 2559     } else 
 2560 
 2561     /* move down */
 2562     if (droprow > highest) {
 2563       loop = g_list_first(reorderlist);
 2564       count = 0;
 2565       while (loop) {
 2566         srcrow = GPOINTER_TO_INT(loop->data);
 2567         l1 = g_list_nth(g_list_first(writelist), srcrow-count);
 2568 
 2569             if (srcrow-count > droprow) {
 2570                     writelist = g_list_insert(writelist, l1->data, droprow);
 2571                     writelist = g_list_remove_link(writelist, l1);
 2572             } else {
 2573                     writelist = g_list_insert(writelist, l1->data, droprow+1);
 2574                     writelist = g_list_remove_link(writelist, l1);
 2575             }
 2576         count++;
 2577 
 2578         loop = loop->next;
 2579       }     
 2580     } else {
 2581         /*
 2582          * mixed case - tracks moved around somewhere in the middle
 2583          * ignore for now
 2584          */
 2585         ;
 2586     }
 2587 }
 2588 
 2589 
 2590 /*
 2591  * called when a drag is received on the left write-tracks clist
 2592  * also handles reordering when drag was received from same window
 2593  */
 2594 static void writetracks_drag_received(GtkWidget *widget, 
 2595         GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data,
 2596         guint info, guint t, gpointer data) {
 2597 GList *input, *reorderlist, *loop;
 2598 GtkWidget *source_widget;
 2599 GtkCList *clist;
 2600 gboolean same;
 2601 gchar *text;
 2602 gint droprow, dropcolumn, srcrow, count;
 2603 gchar *match;
 2604 
 2605     input = NULL;
 2606     reorderlist = NULL;
 2607 
 2608         /* nothing received? ignore */
 2609         if(selection_data == NULL)
 2610                 return;
 2611         if(selection_data->length < 0)
 2612                 return;
 2613 
 2614         /* Source and target widgets are the same? */
 2615         source_widget = gtk_drag_get_source_widget(dc);
 2616         same = (source_widget == widget) ? TRUE : FALSE;
 2617     
 2618     clist = GTK_CLIST(widget);
 2619 
 2620     /*
 2621          * Calculate the row and column at which the drop has occured
 2622          * over on the clist based on the given x and y coordinates.
 2623          */
 2624         if(!gtk_clist_get_selection_info(
 2625                 clist,
 2626                 x,
 2627                 y - ((clist->flags & GTK_CLIST_SHOW_TITLES) ?
 2628                         clist->column_title_area.height +
 2629                         clist->column_title_area.y : 0),
 2630                 &droprow, &dropcolumn)) {
 2631                 droprow = -1;
 2632                 dropcolumn = 0;
 2633         }
 2634 
 2635         if ((info == DRAG_TAR_INFO_0) ||
 2636            (info == DRAG_TAR_INFO_1) ||
 2637            (info == DRAG_TAR_INFO_2)) {
 2638         if (same) {
 2639             /* we just reorder, watch for xrmv event */
 2640             match = "xrmv:";
 2641         } else {
 2642             /* no reorder, but a drop from right window */
 2643             match = "xcdr:";
 2644         }
 2645 
 2646                 text = (char *) selection_data->data;
 2647         if (extract_glist_drag_filenames(text, selection_data->length,
 2648             match, &input)) {
 2649 
 2650             loop = g_list_first(input);
 2651             count = 0;
 2652             while(loop) {
 2653                 if (loop->data != NULL) {
 2654                     dodebug(3,"Received from drag: %s\n", (gchar *)loop->data);
 2655                     if (same) {
 2656                         srcrow = atoi((gchar *)loop->data);
 2657                         reorderlist = g_list_append(reorderlist, GINT_TO_POINTER(srcrow)); 
 2658                     } else {
 2659                         /* insert tracks at the position of the drag */
 2660                         writelist = g_list_insert(writelist,g_strdup((gchar *)loop->data), droprow+count);
 2661                     }
 2662 
 2663                     /* take care of correct order */
 2664                     if (droprow != -1) {
 2665                         count++;
 2666                     }
 2667                 }
 2668                 loop = loop->next;
 2669             }
 2670         }
 2671         if (same) {
 2672             /* perform set of reorders */
 2673             writetracks_drag_reorder(reorderlist, droprow);
 2674             g_list_free(reorderlist);   
 2675         }
 2676 
 2677         free_glist(&input);
 2678         redraw_writelist(cdlist,cdlist_l1);
 2679         fill_write_tracks();
 2680 
 2681     }
 2682 }
 2683 
 2684 
 2685 /*
 2686  * called when a drag is received on the right write-tracks clist
 2687  * which is a remove action
 2688  */
 2689 static void writetracksright_drag_received(GtkWidget *widget, 
 2690         GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data,
 2691         guint info, guint t, gpointer data) {
 2692 GList *input, *loop, *wrlist;
 2693 gchar *text;
 2694 gint row;
 2695 
 2696     input = NULL;
 2697 
 2698         /* nothing received? ignore */
 2699         if(selection_data == NULL)
 2700                 return;
 2701         if(selection_data->length < 0)
 2702                 return;
 2703 
 2704         if ((info == DRAG_TAR_INFO_0) ||
 2705            (info == DRAG_TAR_INFO_1) ||
 2706            (info == DRAG_TAR_INFO_2)) {
 2707                 text = (char *) selection_data->data;
 2708         if (extract_glist_drag_filenames(text, selection_data->length,
 2709             "xrmv:", &input)) {
 2710 
 2711             loop = g_list_first(input);
 2712             while(loop) {
 2713                 if (loop->data != NULL) {
 2714                     dodebug(3,"Received from drag: %s\n", (gchar *)loop->data);
 2715                     /* row number we dragged off */
 2716                     row = atoi((gchar *)loop->data);
 2717 
 2718                     /* mark that row deleted in the writelist */
 2719                     wrlist = g_list_nth(g_list_first(writelist),row);
 2720                     if (wrlist->data) {
 2721                         g_free(wrlist->data);
 2722                         wrlist->data = NULL;
 2723                     }       
 2724                 }
 2725                 loop = loop->next;
 2726             }
 2727 
 2728             /* now remove the marked nodes really from the list */
 2729             loop = g_list_first(writelist);
 2730             while (loop) {
 2731                 wrlist = loop->next;
 2732                 if (loop->data == NULL) {
 2733                     writelist = g_list_remove_link(writelist, loop);
 2734                 }
 2735                 loop = wrlist;
 2736             }
 2737         }
 2738 
 2739         free_glist(&input);
 2740         redraw_writelist(cdlist,cdlist_l1);
 2741         fill_write_tracks();
 2742     }
 2743 }
 2744 
 2745 
 2746 /*
 2747  * draw the write-tracks menu
 2748  */
 2749 static void draw_write_tracks() {
 2750 gchar tmp[MAXLINE];
 2751 gchar tmp2[MAXLINE];
 2752 gchar tmptoc[MAXLINE];
 2753 GtkWidget *hbox, *vbox;
 2754 GtkWidget *f1,*f2;
 2755 GtkWidget *b1, *dummy;
 2756 GtkWidget *e1, *check;
 2757 GtkWidget *l1;
 2758 GtkWidget *tbl;
 2759 GtkWidget *sep;
 2760 GtkWidget *omenu;
 2761 GtkWidget *menu;
 2762 GtkWidget *menu_item;
 2763 gint cdrtypes[] = CDR_TYPES_MIN;
 2764 gint dvdtypes[] = DVD_TYPES_MB;
 2765 static const gchar *writemodes[] = WRITE_MODES;
 2766 static const gchar *helpwritemodes[] = HELP_WRITE_MODES;
 2767 gint i, tmpval;
 2768 gint menuidx, menuhistory;
 2769 GtkWidget *notebook, *halign;
 2770 gchar *titles[2];
 2771 GtkWidget *scrolled_win, *img_list, *cd_list, *img_list2;
 2772 GtkTargetEntry target_entry[3];
 2773 
 2774         target_entry[0].target = DRAG_TAR_NAME_0;
 2775         target_entry[0].flags = 0;
 2776         target_entry[0].info = DRAG_TAR_INFO_0;
 2777         target_entry[1].target = DRAG_TAR_NAME_1;
 2778         target_entry[1].flags = 0;
 2779         target_entry[1].info = DRAG_TAR_INFO_1;
 2780         target_entry[2].target = DRAG_TAR_NAME_2;
 2781         target_entry[2].flags = 0;
 2782         target_entry[2].info = DRAG_TAR_INFO_2;
 2783 
 2784         /* prepare draw area */
 2785         clear_actionspace();
 2786 
 2787     /* initializion of global pointers */
 2788     dupl_cd_mode_omenu = NULL;
 2789         crea_cd_mode_omenu = NULL;
 2790         crea_cd_burnfree_check = NULL;
 2791     crea_cd_nofixate_check = NULL;
 2792 
 2793         f1 = gtk_frame_new(_("Devices-Setup"));
 2794         set_font_and_color_frame(f1,PANGO_BOLD,NULL);
 2795         gtk_box_pack_start(GTK_BOX(actionspace),f1,FALSE,FALSE,5);
 2796         gtk_widget_show(f1);
 2797 
 2798         tbl = gtk_table_new(2,16*4,TRUE); 
 2799         gtk_table_set_col_spacing(GTK_TABLE(tbl),4*4-1,5);
 2800         gtk_table_set_col_spacing(GTK_TABLE(tbl),15*4-2,5);
 2801         gtk_container_set_border_width(GTK_CONTAINER (tbl),5);
 2802         gtk_container_add(GTK_CONTAINER(f1),tbl);
 2803         gtk_widget_show(tbl);
 2804 
 2805         devices_setup_image(0, tbl);
 2806         devices_setup_write(1, tbl);
 2807 
 2808         gtk_widget_show(actionspace);
 2809 
 2810     /* notebook tabs */
 2811         notebook = gtk_notebook_new();
 2812         gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
 2813         gtk_box_pack_start(GTK_BOX(actionspace),notebook,TRUE,TRUE,2);
 2814         gtk_widget_show(notebook);
 2815 
 2816         gtk_signal_connect (GTK_OBJECT (notebook), "switch_page",
 2817         GTK_SIGNAL_FUNC (writetracks_notebookswitch), NULL);
 2818 
 2819     /*
 2820      * first tab "Layout tracks"
 2821      */
 2822     vbox = gtk_vbox_new(FALSE,0);
 2823     l1 = gtk_label_new(_("Layout tracks"));
 2824     gtk_widget_show_all(vbox);
 2825     gtk_notebook_append_page(GTK_NOTEBOOK (notebook),vbox,l1);
 2826 
 2827         /* left and right info-frames */
 2828         tbl = gtk_table_new(1,2,TRUE);
 2829     gtk_container_set_border_width(GTK_CONTAINER (tbl),5);
 2830         gtk_table_set_col_spacings(GTK_TABLE(tbl),5);
 2831         gtk_box_pack_start(GTK_BOX(vbox),tbl,TRUE,TRUE,0);
 2832         gtk_widget_show(tbl);
 2833         f1 = gtk_frame_new(_("Tracks to write"));
 2834         set_font_and_color_frame(f1,PANGO_BOLD,NULL);
 2835         gtk_table_attach_defaults(GTK_TABLE(tbl),f1,0,1,0,1);
 2836         gtk_widget_show(f1);
 2837         f2 = gtk_frame_new(_("Image-Information"));
 2838         set_font_and_color_frame(f2,PANGO_BOLD,NULL);
 2839         gtk_table_attach_defaults(GTK_TABLE(tbl),f2,1,2,0,1);
 2840         gtk_widget_show(f2);
 2841 
 2842         /* button bar at the bottom */
 2843         hbox = gtk_hbox_new(TRUE,10);
 2844         gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,TRUE,5);
 2845         gtk_widget_show(hbox);
 2846     halign = gtk_alignment_new(0.5, 0.5, 0.5, 0);
 2847         gtk_box_pack_start(GTK_BOX(hbox),halign,TRUE,TRUE,10);
 2848     gtk_widget_show(halign);
 2849 
 2850         b1 = gtk_button_new_with_label(_("Accept track layout"));
 2851     gtk_container_add(GTK_CONTAINER(halign),b1);
 2852         gtk_widget_show(b1);
 2853         gtk_signal_connect(GTK_OBJECT(b1), "clicked",
 2854                 GTK_SIGNAL_FUNC(accept_layout_clicked), notebook);
 2855         define_tooltip(b1,_("When you are satisfied with the tracks and the order you set for writing (use drag'n'drop to reorder them), click here to transfer the selection to the write menu."));
 2856 
 2857         /* left info frame */
 2858         vbox = gtk_vbox_new(FALSE,0);
 2859         gtk_container_add(GTK_CONTAINER(f1),vbox);
 2860         gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
 2861         gtk_widget_show(vbox);
 2862 
 2863         scrolled_win = gtk_scrolled_window_new (NULL, NULL);
 2864         gtk_box_pack_start(GTK_BOX(vbox),scrolled_win,TRUE,TRUE,0);
 2865         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
 2866                 GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
 2867         gtk_widget_show(scrolled_win);
 2868         
 2869         titles[0] = g_strdup("");
 2870         titles[1] = _("Images");
 2871         cd_list = gtk_clist_new_with_titles(2,titles);
 2872         gtk_container_add (GTK_CONTAINER (scrolled_win), cd_list);
 2873         cdlist = GTK_CLIST(cd_list);
 2874         gtk_clist_set_column_width(cdlist, 0, 16);
 2875         gtk_clist_set_column_auto_resize(cdlist, 1, TRUE);
 2876     gtk_clist_set_selection_mode (cdlist, GTK_SELECTION_MULTIPLE);
 2877     gtk_clist_set_use_drag_icons(cdlist, TRUE);
 2878     gtk_widget_realize(cd_list);
 2879 
 2880         if(!GTK_WIDGET_NO_WINDOW(cd_list)) {
 2881         /* we can receive drags */
 2882                 gtk_drag_dest_set(
 2883                         cd_list,
 2884                         GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT |
 2885                         GTK_DEST_DEFAULT_DROP,
 2886                         target_entry,
 2887                         sizeof(target_entry) / sizeof(GtkTargetEntry),
 2888                         GDK_ACTION_MOVE | GDK_ACTION_COPY
 2889                 );
 2890             gtk_signal_connect(GTK_OBJECT(cd_list), "drag_data_received",
 2891                     GTK_SIGNAL_FUNC(writetracks_drag_received), 
 2892             NULL);
 2893 
 2894         /* and we can send drags */
 2895                 gtk_drag_source_set(
 2896                         cd_list, 
 2897                         GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
 2898                         target_entry,
 2899                         sizeof(target_entry) / sizeof(GtkTargetEntry),
 2900                         GDK_ACTION_MOVE);
 2901                 gtk_signal_connect(
 2902                         GTK_OBJECT(cd_list), "drag_data_get",
 2903                         GTK_SIGNAL_FUNC(writetracksleft_request_dnddata), NULL);
 2904 
 2905     }
 2906         gtk_widget_show(cd_list);
 2907 
 2908         tbl = gtk_table_new(1,8,TRUE);
 2909         gtk_table_set_col_spacings(GTK_TABLE(tbl),10);
 2910         gtk_box_pack_start(GTK_BOX(vbox),tbl,FALSE,FALSE,5);
 2911         gtk_widget_show(tbl);
 2912         
 2913         l1 = rightjust_gtk_label_new(_("Size:"));
 2914         gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,2,0,1);
 2915         gtk_widget_show(l1);
 2916 
 2917         e1 = gtk_entry_new();
 2918         cdlist_l1 = e1;
 2919         gtk_entry_set_editable(GTK_ENTRY(e1),FALSE);
 2920         gtk_table_attach_defaults(GTK_TABLE(tbl),e1,2,8,0,1);
 2921         gtk_widget_show(e1);
 2922 
 2923         hbox = gtk_hbox_new(FALSE,2);
 2924         gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,TRUE,5);
 2925         gtk_widget_show(hbox);
 2926         b1 = gtk_button_new_with_label(_("All"));
 2927         gtk_signal_connect(GTK_OBJECT(b1),"clicked",
 2928                 GTK_SIGNAL_FUNC(read_select_all), NULL);
 2929         gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,3);
 2930         gtk_widget_show(b1);
 2931         define_tooltip(b1,_("Selects all displayed tracks so that you can remove them from the list with a single click."));
 2932         b1 = gtk_button_new_with_label(_("None"));
 2933         gtk_signal_connect(GTK_OBJECT(b1),"clicked",
 2934                 GTK_SIGNAL_FUNC(read_select_none), NULL);
 2935         gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,3);
 2936         gtk_widget_show(b1);
 2937         define_tooltip(b1,_("Deselects all displayed tracks."));
 2938 
 2939         dummy = gtk_label_new("");
 2940         gtk_box_pack_start(GTK_BOX(hbox),dummy,FALSE,FALSE,5);
 2941         gtk_widget_show(dummy);
 2942 
 2943         b1 = gtk_button_new_with_label(_("Remove"));
 2944         gtk_signal_connect(GTK_OBJECT(b1),"clicked",
 2945                 GTK_SIGNAL_FUNC(write_delete_tracks), NULL);
 2946         gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,3);
 2947         gtk_widget_show(b1);
 2948         define_tooltip(b1,_("Remove the selected tracks from this list."));
 2949 
 2950         /* right info frame */
 2951         vbox = gtk_vbox_new(FALSE,0);
 2952         gtk_container_add(GTK_CONTAINER(f2),vbox);
 2953         gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
 2954         gtk_widget_show(vbox);
 2955 
 2956         scrolled_win = gtk_scrolled_window_new (NULL, NULL);
 2957         gtk_box_pack_start(GTK_BOX(vbox),scrolled_win,TRUE,TRUE,0);
 2958         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
 2959                 GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
 2960         gtk_widget_show(scrolled_win);
 2961         
 2962         titles[0] = g_strdup("");
 2963         titles[1] = _("Images");
 2964         img_list = gtk_clist_new_with_titles(2,titles);
 2965         gtk_signal_connect(GTK_OBJECT(img_list), "select_row",
 2966                 GTK_SIGNAL_FUNC(verify_select_row),NULL);
 2967         gtk_signal_connect(GTK_OBJECT(img_list), "unselect_row",
 2968                 GTK_SIGNAL_FUNC(verify_select_row),NULL);
 2969         gtk_container_add (GTK_CONTAINER (scrolled_win), img_list);
 2970         imglist = GTK_CLIST(img_list);
 2971         gtk_clist_set_column_width(imglist, 0, 16);
 2972         gtk_clist_set_column_auto_resize(imglist, 1, TRUE);
 2973     gtk_clist_set_selection_mode (imglist, GTK_SELECTION_MULTIPLE);
 2974     gtk_widget_realize(img_list);
 2975 
 2976         if(!GTK_WIDGET_NO_WINDOW(img_list)) {
 2977                 /* we can drag out of the list */
 2978                 gtk_drag_source_set(
 2979                         img_list, 
 2980                         GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
 2981                         target_entry,
 2982                         sizeof(target_entry) / sizeof(GtkTargetEntry),
 2983                         GDK_ACTION_MOVE);
 2984                 gtk_signal_connect(
 2985                         GTK_OBJECT(img_list), "drag_data_get",
 2986                         GTK_SIGNAL_FUNC(writetracks_request_dnddata), NULL);
 2987 
 2988                 /* we can receive drags */
 2989                 gtk_drag_dest_set(
 2990                         img_list,
 2991                         GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT |
 2992                         GTK_DEST_DEFAULT_DROP,
 2993                         target_entry,
 2994                         sizeof(target_entry) / sizeof(GtkTargetEntry),
 2995                         GDK_ACTION_MOVE | GDK_ACTION_COPY
 2996                 );
 2997                 gtk_signal_connect(GTK_OBJECT(img_list), "drag_data_received",
 2998                         GTK_SIGNAL_FUNC(writetracksright_drag_received), 
 2999                         NULL);
 3000     }
 3001         gtk_widget_show(img_list);
 3002 
 3003         tbl = gtk_table_new(1,8,TRUE);
 3004         gtk_table_set_col_spacings(GTK_TABLE(tbl),10);
 3005         gtk_box_pack_start(GTK_BOX(vbox),tbl,FALSE,FALSE,5);
 3006         gtk_widget_show(tbl);
 3007         
 3008         l1 = rightjust_gtk_label_new(_("Selected:"));
 3009         gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,2,0,1);
 3010         gtk_widget_show(l1);
 3011 
 3012         e1 = gtk_entry_new();
 3013         imglist_l1 = e1;
 3014         gtk_entry_set_editable(GTK_ENTRY(e1),FALSE);
 3015         gtk_table_attach_defaults(GTK_TABLE(tbl),e1,2,8,0,1);
 3016         gtk_widget_show(e1);
 3017 
 3018         hbox = gtk_hbox_new(FALSE,2);
 3019         gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,TRUE,5);
 3020         gtk_widget_show(hbox);
 3021         b1 = gtk_button_new_with_label(_("All"));
 3022         gtk_signal_connect(GTK_OBJECT(b1),"clicked",
 3023                 GTK_SIGNAL_FUNC(verify_select_all), NULL);
 3024         gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,3);
 3025         gtk_widget_show(b1);
 3026         define_tooltip(b1,_("Selects all displayed tracks so that you can add them to the selection you want to write with a single click."));
 3027         b1 = gtk_button_new_with_label(_("None"));
 3028         gtk_signal_connect(GTK_OBJECT(b1),"clicked",
 3029                 GTK_SIGNAL_FUNC(verify_select_none), NULL);
 3030         gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,3);
 3031         gtk_widget_show(b1);
 3032         define_tooltip(b1,_("Deselects all displayed images."));
 3033 
 3034         dummy = gtk_label_new("");
 3035         gtk_box_pack_start(GTK_BOX(hbox),dummy,FALSE,FALSE,5);
 3036         gtk_widget_show(dummy);
 3037 
 3038         b1 = gtk_button_new_with_label(_("Add"));
 3039         gtk_signal_connect(GTK_OBJECT(b1),"clicked",
 3040                 GTK_SIGNAL_FUNC(write_add_tracks), NULL);
 3041         gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,3);
 3042         gtk_widget_show(b1);
 3043         define_tooltip(b1,_("Add all selected images to the left list - the tracks that should be written to a Disc."));
 3044 
 3045     /*
 3046      * second tab "Write Tracks"
 3047      */
 3048     vbox = gtk_vbox_new(FALSE,0);
 3049     l1 = gtk_label_new(_("Write tracks"));
 3050     gtk_widget_show_all(vbox);
 3051     gtk_notebook_append_page(GTK_NOTEBOOK (notebook),vbox,l1);
 3052 
 3053         /* left and right info-frames */
 3054         tbl = gtk_table_new(1,2,TRUE);
 3055         gtk_container_set_border_width(GTK_CONTAINER (tbl),5);
 3056         gtk_table_set_col_spacings(GTK_TABLE(tbl),5);
 3057         gtk_box_pack_start(GTK_BOX(vbox),tbl,TRUE,TRUE,0);
 3058         gtk_widget_show(tbl);
 3059         f1 = gtk_frame_new(_("Tracks to write"));
 3060         set_font_and_color_frame(f1,PANGO_BOLD,NULL);
 3061         gtk_table_attach_defaults(GTK_TABLE(tbl),f1,0,1,0,1);
 3062         gtk_widget_show(f1);
 3063         f2 = gtk_frame_new(_("Write parameters"));
 3064         set_font_and_color_frame(f2,PANGO_BOLD,NULL);
 3065         gtk_table_attach_defaults(GTK_TABLE(tbl),f2,1,2,0,1);
 3066         gtk_widget_show(f2);
 3067 
 3068         /* button bar at the bottom */
 3069         hbox = gtk_hbox_new(TRUE,10);
 3070         gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,TRUE,5);
 3071         gtk_widget_show(hbox);
 3072         b1 = gtk_button_new_with_label(_("Write tracks"));
 3073         gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,10);
 3074         gtk_widget_show(b1);
 3075         gtk_signal_connect(GTK_OBJECT(b1), "clicked",
 3076                 GTK_SIGNAL_FUNC(writesometracks_clicked), NULL);
 3077         define_tooltip(b1,_("Write all selected tracks to a Disc."));
 3078 
 3079         b1 = gtk_button_new_with_label(_("Fixate Disc only"));
 3080         gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,10);
 3081         gtk_widget_show(b1);
 3082         gtk_signal_connect(GTK_OBJECT(b1), "clicked",
 3083                 GTK_SIGNAL_FUNC(fixate_clicked), NULL);
 3084         define_tooltip(b1,_("Just fixate (finalize) the Disc, if for some reason the Disc has been written but not fixated. Hint: To finalize an audio CD you need the \"TAO\" write mode."));
 3085 
 3086     if (!curset.isProDVD) {
 3087             b1 = gtk_button_new_with_label(_("Blank Disc"));
 3088     } else {
 3089             b1 = gtk_button_new_with_label(_("Blank CD/DVD+-RW"));
 3090     }
 3091         gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,10);
 3092         gtk_widget_show(b1);
 3093         gtk_signal_connect(GTK_OBJECT(b1), "clicked",
 3094                 GTK_SIGNAL_FUNC(blankcd_clicked), NULL);
 3095         define_tooltip(b1,_("Blanks a rewritable Disc inserted in the Writer."));
 3096 
 3097     /* left info frame */
 3098         vbox = gtk_vbox_new(FALSE,0);
 3099         gtk_container_add(GTK_CONTAINER(f1),vbox);
 3100         gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
 3101         gtk_widget_show(vbox);
 3102 
 3103         scrolled_win = gtk_scrolled_window_new (NULL, NULL);
 3104         gtk_box_pack_start(GTK_BOX(vbox),scrolled_win,TRUE,TRUE,0);
 3105         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
 3106                 GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
 3107         gtk_widget_show(scrolled_win);
 3108         
 3109         titles[0] = g_strdup("");
 3110         titles[1] = _("Images");
 3111         img_list2 = gtk_clist_new_with_titles(2,titles);
 3112         gtk_container_add (GTK_CONTAINER (scrolled_win), img_list2);
 3113         imglist2 = GTK_CLIST(img_list2);
 3114         gtk_signal_connect(GTK_OBJECT(imglist2), "select_row",
 3115                 GTK_SIGNAL_FUNC(undo_selections),NULL);
 3116         gtk_clist_set_column_width(imglist2, 0, 16);
 3117         gtk_clist_set_column_auto_resize(imglist2, 1, TRUE);
 3118         gtk_widget_show(img_list2);
 3119         gtk_widget_realize(img_list2);
 3120 
 3121         tbl = gtk_table_new(2,8,TRUE);
 3122         gtk_table_set_col_spacings(GTK_TABLE(tbl),10);
 3123         gtk_table_set_row_spacings(GTK_TABLE(tbl),5);
 3124         gtk_box_pack_start(GTK_BOX(vbox),tbl,FALSE,FALSE,5);
 3125         gtk_widget_show(tbl);
 3126         
 3127         l1 = rightjust_gtk_label_new(_("Size:"));
 3128         gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,2,0,1);
 3129         gtk_widget_show(l1);
 3130 
 3131         e1 = gtk_entry_new();
 3132         imglist_l2 = e1;
 3133         gtk_entry_set_editable(GTK_ENTRY(e1),FALSE);
 3134         gtk_table_attach_defaults(GTK_TABLE(tbl),e1,2,8,0,1);
 3135         gtk_widget_show(e1);
 3136 
 3137         check = gtk_check_button_new_with_label(_("Write as multi session"));
 3138         gtk_signal_connect(GTK_OBJECT(check),"clicked",
 3139                 GTK_SIGNAL_FUNC(writeoptions_selected),GINT_TO_POINTER(5));
 3140         gtk_table_attach_defaults(GTK_TABLE(tbl),check,1,8,1,2);
 3141         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 3142                 curset.multisession);
 3143         gtk_widget_show(check);
 3144         define_tooltip(check,_("Write the Disc in such a way, that it is possible to append further data (in a new session) at a later time. Please note that for the first session you need 22 MiB extra space on the Disc and all additional sessions take 13 MiB extra each."));
 3145 
 3146         /* right info frame */
 3147         vbox = gtk_vbox_new(FALSE,0);
 3148         gtk_container_add(GTK_CONTAINER(f2),vbox);
 3149         gtk_container_set_border_width (GTK_CONTAINER (vbox), 7);
 3150         gtk_widget_show(vbox);
 3151 
 3152         tbl = gtk_table_new(9,16,FALSE);
 3153         gtk_table_set_row_spacing(GTK_TABLE(tbl),0,2);
 3154         gtk_table_set_row_spacing(GTK_TABLE(tbl),1,5);
 3155         gtk_table_set_row_spacing(GTK_TABLE(tbl),2,5);
 3156         gtk_table_set_col_spacings(GTK_TABLE(tbl),2);
 3157         gtk_table_set_col_spacing(GTK_TABLE(tbl),14,0);
 3158         gtk_box_pack_start(GTK_BOX(vbox),tbl,FALSE,FALSE,0);
 3159         gtk_widget_show(tbl);
 3160         
 3161     /* disc type */
 3162 
 3163     l1 = rightjust_gtk_label_new(_("Disc Type:"));
 3164     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,6,0,1);
 3165     gtk_widget_show(l1);
 3166 
 3167     omenu = gtk_option_menu_new();
 3168     menu = gtk_menu_new();
 3169     menuidx = 0; menuhistory = 0;
 3170 
 3171     i = 0;
 3172     tmpval = curset.cdrtype;
 3173     while (cdrtypes[i] != 0) {
 3174         /* construct minute-list */
 3175         g_snprintf(tmp,MAXLINE,"%d min",abs(cdrtypes[i]));
 3176 
 3177         menu_item = gtk_menu_item_new_with_label(tmp);
 3178         gtk_signal_connect(GTK_OBJECT(menu_item),
 3179             "activate", GTK_SIGNAL_FUNC(cdrtype_selected),
 3180             GINT_TO_POINTER(abs(cdrtypes[i])));
 3181         gtk_menu_append (GTK_MENU (menu), menu_item);
 3182         if (tmpval == abs(cdrtypes[i])) { 
 3183             menuhistory = menuidx;
 3184         }
 3185         /* default set defined by negativ value */
 3186         if (tmpval == 0 && cdrtypes[i] < 0) {
 3187             menuhistory = menuidx;
 3188             curset.cdrtype = abs(cdrtypes[i]);
 3189         }
 3190         menuidx++;
 3191         gtk_widget_show (menu_item);
 3192         i++;
 3193         }
 3194 
 3195     i = 0;
 3196     tmpval = curset.cdrtype;
 3197     while (dvdtypes[i] != 0) {
 3198         /* construct GB-list */
 3199         g_snprintf(tmp2,MAXLINE,"%.2f", (gfloat)dvdtypes[i]/1000);
 3200         if (tmp2[strlen(tmp2)-1] == '0') {
 3201             tmp2[strlen(tmp2)-1] = '\0'; /* strip off last 0 */
 3202         }
 3203         g_snprintf(tmp,MAXLINE,"%s GB",tmp2); /*decimal prefix*/
 3204 
 3205         menu_item = gtk_menu_item_new_with_label(tmp);
 3206         gtk_signal_connect(GTK_OBJECT(menu_item),
 3207         "activate", GTK_SIGNAL_FUNC(cdrtype_selected),
 3208         GINT_TO_POINTER(dvdtypes[i]));
 3209         gtk_menu_append (GTK_MENU (menu), menu_item);
 3210         if (tmpval == abs(dvdtypes[i])) {
 3211             menuhistory = menuidx;
 3212         }
 3213         menuidx++;
 3214         gtk_widget_show (menu_item);
 3215         i++;
 3216     }
 3217 
 3218     gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
 3219     gtk_option_menu_set_history(GTK_OPTION_MENU (omenu),menuhistory);
 3220     gtk_table_attach_defaults(GTK_TABLE(tbl),omenu,6,10,0,1);
 3221     gtk_widget_show(omenu);
 3222     define_tooltip(omenu,_("The capacity of the currently used Disc."));
 3223 
 3224     b1 = gtk_button_new_with_label(_("ATIP-Info"));
 3225     gtk_signal_connect (GTK_OBJECT (b1), "clicked",
 3226         GTK_SIGNAL_FUNC(show_atip_info),NULL);
 3227     gtk_table_attach_defaults(GTK_TABLE(tbl),b1,10,16,0,1);
 3228     gtk_widget_show(b1);
 3229     define_tooltip(b1,_("Read detailed information from a (empty) Disc."));
 3230 
 3231         /* write mode */
 3232 
 3233         l1 = rightjust_gtk_label_new(_("Write Mode:"));
 3234         gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,6,1,2);
 3235         gtk_widget_show(l1);
 3236 
 3237     omenu = gtk_option_menu_new ();
 3238     menu = gtk_menu_new();
 3239     crea_cd_mode_omenu = omenu;
 3240 
 3241     i = 0;
 3242     while (writemodes[i]) {
 3243         menu_item = gtk_menu_item_new_with_label(_(writemodes[i]));
 3244         gtk_signal_connect(GTK_OBJECT(menu_item), "activate",
 3245             GTK_SIGNAL_FUNC(writemode_selected),
 3246             GINT_TO_POINTER(i));
 3247         gtk_menu_append (GTK_MENU (menu), menu_item);
 3248         gtk_widget_show (menu_item);
 3249         if (helpwritemodes[i]) 
 3250                 define_tooltip(menu_item,(gchar *)_(helpwritemodes[i]));
 3251         i++;
 3252     }
 3253 
 3254     gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
 3255     preselect_write_mode_menu(omenu, curset.writer_devnr);
 3256         gtk_table_attach_defaults(GTK_TABLE(tbl),omenu,6,16,1,2);
 3257     gtk_widget_show(omenu);
 3258         g_snprintf(tmp,MAXLINE,"%s %s",_("Choose which mode you want to use for writing CDs. Try \"DAO\" first, because this is the best one for all modern disc writers."), _("Click an option and hold the button to get additional help for each mode."));
 3259         define_tooltip(omenu,tmp);  /* concatenated text */
 3260 
 3261     /*
 3262      * disable selection of write modes
 3263      * if the user hasn't got the permission
 3264      * or if DVD or BD or if multisession
 3265      */
 3266     if ((!isroot() && !setupdata.root_option_change_writeparam)
 3267       || curset.cdrtype > 1000 || curset.multisession) {
 3268                 gtk_widget_set_sensitive(omenu,FALSE);
 3269     }
 3270 
 3271         sep = gtk_hseparator_new();
 3272         gtk_table_attach_defaults(GTK_TABLE(tbl),sep,0,16,2,3);
 3273         gtk_widget_show(sep);
 3274 
 3275         check = gtk_check_button_new_with_label(_("Simulation write"));
 3276         gtk_signal_connect(GTK_OBJECT(check),"clicked",
 3277                 GTK_SIGNAL_FUNC(writeoptions_selected),GINT_TO_POINTER(0));
 3278         gtk_table_attach_defaults(GTK_TABLE(tbl),check,2,16,3,4);
 3279         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 3280                 curset.writesimul);
 3281         gtk_widget_show(check);
 3282         define_tooltip(check,_("Just simulate the burning process. Please note that DVD+ media and Blu-ray media do not support simulation writes."));
 3283 
 3284         check = gtk_check_button_new_with_label(_("Eject after write"));
 3285         gtk_signal_connect(GTK_OBJECT(check),"clicked",
 3286                 GTK_SIGNAL_FUNC(writeoptions_selected),GINT_TO_POINTER(1));
 3287         gtk_table_attach_defaults(GTK_TABLE(tbl),check,2,16,4,5);
 3288         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 3289                 curset.writeeject);
 3290         gtk_widget_show(check);
 3291         define_tooltip(check,_("Eject the Disc after the burning was completed."));
 3292         
 3293         check = gtk_check_button_new_with_label(_("Pad Tracks"));
 3294         gtk_signal_connect(GTK_OBJECT(check),"clicked",
 3295                 GTK_SIGNAL_FUNC(writeoptions_selected),GINT_TO_POINTER(2));
 3296         gtk_table_attach_defaults(GTK_TABLE(tbl),check,2,16,5,6);
 3297         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 3298                 curset.writepad);
 3299         gtk_widget_show(check);
 3300         define_tooltip(check,_("Pads data-tracks with zeros to eliminate reading problems on some systems and adapts the length of audio-tracks for CD writing. This must be enabled when you want to burn wav-files not created with X-CD-Roast."));
 3301        
 3302         check = gtk_check_button_new_with_label(_("Do not fixate after write"));
 3303     crea_cd_nofixate_check = check;
 3304         gtk_signal_connect(GTK_OBJECT(check),"clicked",
 3305                 GTK_SIGNAL_FUNC(writeoptions_selected),GINT_TO_POINTER(4));
 3306         gtk_table_attach_defaults(GTK_TABLE(tbl),check,2,16,6,7);
 3307     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 3308         curset.nofixate);
 3309     /*
 3310      * disable nofixate checkbox
 3311      * for multisession mode
 3312      */
 3313         if (curset.multisession) {
 3314         gtk_widget_set_sensitive(check,FALSE);
 3315     }
 3316         gtk_widget_show(check);
 3317         define_tooltip(check,_("This prevents the Writer from fixating (finalizing) the Disc after writing. You can use this to create an audio CD in several steps. Just make sure to fixate after the last track. (Or use the \"Fixate Disc only\" button.) Hint: This does only work in Track-At-Once mode."));
 3318       
 3319         check = gtk_check_button_new_with_label(_("Enable protection from Buffer Underruns"));
 3320     crea_cd_burnfree_check = check;
 3321 
 3322         gtk_signal_connect(GTK_OBJECT(check),"clicked",
 3323                 GTK_SIGNAL_FUNC(writeoptions_selected),GINT_TO_POINTER(8));
 3324         gtk_table_attach_defaults(GTK_TABLE(tbl),check,2,16,7,8);
 3325         if (does_support_burnproof(curset.writer_devnr)) {
 3326                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 3327                         curset.writeburnfree);
 3328         }
 3329         gtk_widget_show(check);
 3330         define_tooltip(check,_("When available it does enable protection from Buffer Underrun errors. Supported are Sanyo BURN-Proof, Ricoh Just-Link and similar."));
 3331 
 3332         if (!does_support_burnproof(curset.writer_devnr))
 3333                 gtk_widget_set_sensitive(check,FALSE);
 3334  
 3335         check = gtk_check_button_new_with_label(_("Write CD-Text"));
 3336         gtk_signal_connect(GTK_OBJECT(check),"clicked",
 3337                 GTK_SIGNAL_FUNC(writeoptions_selected),GINT_TO_POINTER(6));
 3338         gtk_table_attach_defaults(GTK_TABLE(tbl),check,2,8,8,9);
 3339         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 3340                 curset.writecdtext);
 3341         gtk_widget_show(check);
 3342         define_tooltip(check,_("Writes CD-Text information to the CD-R/RW when your CD Writer is supporting it. This usually works only when writing in DAO or raw96 mode."));
 3343 
 3344         b1 = gtk_button_new_with_label(_("Edit titles"));
 3345         gtk_signal_connect (GTK_OBJECT (b1), "clicked",
 3346                 GTK_SIGNAL_FUNC(edit_cdtext_clicked), GINT_TO_POINTER(2));
 3347         gtk_table_attach_defaults(GTK_TABLE(tbl),b1,8,16,8,9);
 3348         gtk_widget_show(b1);
 3349         define_tooltip(b1,_("Edits the title and performer information of your tracks before they are written to a CD-R/RW with CD-Text."));
 3350 
 3351     b1 = gtk_button_new_with_label(_("Advanced options"));
 3352         gtk_signal_connect (GTK_OBJECT (b1), "clicked",
 3353                 GTK_SIGNAL_FUNC(adv_write_options_clicked), NULL);
 3354     gtk_box_pack_end(GTK_BOX(vbox),b1,FALSE,FALSE,0);
 3355         gtk_widget_show(b1);
 3356     define_tooltip(b1,_("Set additional write options for advanced users."));
 3357 
 3358     /* init write-list again - so each time we enter this menu
 3359        we start with an empty set */
 3360     free_glist(&writelist);
 3361     clear_trackreadset();
 3362 
 3363     /* write fresh tmp tocfile */
 3364     generate_tmp_tocfile_name(tmptoc);
 3365     create_tmp_writetracks_tocfile(tmptoc);
 3366 
 3367         /* fill entries */
 3368     fill_write_tracks();
 3369     redraw_writelist(cdlist,cdlist_l1);
 3370     fill_writelist2(imglist2,imglist_l2);
 3371 }
 3372 
 3373 static void dirview_selected(GtkWidget *item, GtkWidget *entry) {
 3374 gint sel;
 3375 gchar path[MAXLINE];
 3376 
 3377         sel = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(item));
 3378     masterparam.show_only_dirs = sel;   
 3379 
 3380     /* save entry */
 3381     strncpy(path,gtk_entry_get_text(GTK_ENTRY(entry)),MAXLINE);
 3382     convert_for_gtk2_filename(path);
 3383 
 3384     /* redraw the tree to the current setting */
 3385     ctree_change_viewmode(!masterparam.show_only_dirs, 
 3386         masterparam.show_hidden_files);
 3387 
 3388     /* now expand back to the level we described in the entry-field */
 3389     if (path[0] == '/') {
 3390         gtk_entry_set_text(GTK_ENTRY(entry),path);
 3391     }
 3392     ctree_expand_manualpath(entry, NULL);
 3393 }
 3394 
 3395 static void hiddenview_selected(GtkWidget *item, GtkWidget *entry) {
 3396 gint sel;
 3397 gchar path[MAXLINE];
 3398 
 3399         sel = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(item));
 3400     masterparam.show_hidden_files = sel;    
 3401 
 3402     /* save entry */
 3403     strncpy(path,gtk_entry_get_text(GTK_ENTRY(entry)),MAXLINE);
 3404     convert_for_gtk2_filename(path);
 3405 
 3406     /* redraw the tree to the current setting */
 3407     ctree_change_viewmode(!masterparam.show_only_dirs, 
 3408         masterparam.show_hidden_files);
 3409 
 3410     /* now expand back to the level we described in the entry-field */
 3411     if (path[0] == '/') {
 3412         gtk_entry_set_text(GTK_ENTRY(entry),path);
 3413     }
 3414     ctree_expand_manualpath(entry, NULL);
 3415 }
 3416 
 3417 static void entry_masterdir_callback(GtkWidget *widget, gpointer data) {
 3418 gchar dir[MAXLINE];
 3419 
 3420     /* expand tilde */
 3421         strcpy(dir,gtk_entry_get_text(GTK_ENTRY(widget)));
 3422         check_tilde(dir);
 3423         gtk_entry_set_text(GTK_ENTRY(widget), dir);
 3424 
 3425     ctree_expand_manualpath(widget, NULL);
 3426 }
 3427 
 3428 
 3429 /*
 3430  * calculate redir path for a master path and add it
 3431  */
 3432 static gint add_mult_mstr_file(gchar *path, gint stat, gchar *redir, gchar *common) {
 3433 mstr_redirect_t *mstr;
 3434 gchar redir2[MAXLINE];
 3435 gchar redir3[MAXLINE];
 3436 gchar reducedpath[MAXLINE];
 3437 gchar filename[MAXLINE];
 3438 
 3439     /* path already added? ignore */
 3440     if (check_in_mstr_glist(&masterparam.mstr_redir, path) != 0) {
 3441         return 0;
 3442     }
 3443 
 3444     /* handling a file or a directory here? */
 3445     if (is_directory(path)) {
 3446         strcpy(filename, "");
 3447     } else {
 3448         get_purefile(path, filename);
 3449     }
 3450 
 3451     /* get base path of our given directory */
 3452     strncpy(redir2, path, MAXLINE);
 3453     get_basedir(redir2);
 3454     if (redir2 == NULL) { strcpy(redir2,"/"); }
 3455 
 3456     /* add a slash now, too */
 3457         if (strlen(redir2) > 0) {
 3458             if (redir2[strlen(redir2)-1] != '/') {
 3459                     strcat(redir2,"/");
 3460                 }       
 3461     }
 3462 
 3463         /* and if we are adding a file, add its filename */
 3464         if (strlen(redir2) + strlen(filename) < MAXLINE) {
 3465             strcat(redir2, filename);
 3466         }
 3467 
 3468     /* might be needed if stat == 2 */
 3469     get_reducedpath(common, reducedpath);
 3470 
 3471     /* allocate new entry */
 3472     mstr = g_new0(mstr_redirect_t,1);
 3473     mstr->mstr_path = g_strdup(path);
 3474     masterparam.mstr_redir = g_list_append(masterparam.mstr_redir, mstr);
 3475 
 3476     /* add with full path */
 3477     if (stat == 0) {
 3478         if (strlen(redir2) > 0) {
 3479             add_redir_mstr_glist( &masterparam.mstr_redir,
 3480                     path, redir2);
 3481         }
 3482         return 1;
 3483     } 
 3484     /* add with common part removed */
 3485     if (stat == 1) {
 3486         strncpy(redir3,redir2+strlen(common), MAXLINE);
 3487         if (strlen(redir3) > 0) {
 3488             add_redir_mstr_glist( &masterparam.mstr_redir,
 3489                     path, redir3);
 3490         }
 3491         return 1;
 3492     }
 3493     /* add with common part removed (one level less) */
 3494     if (stat == 2) {
 3495         strncpy(redir3,redir2+strlen(reducedpath), MAXLINE);
 3496         if (strlen(redir3) > 0) {
 3497             add_redir_mstr_glist( &masterparam.mstr_redir,
 3498                     path, redir3);
 3499         }
 3500         return 1;
 3501     }
 3502     /* add with common part replaced */
 3503     if (stat == 3) {
 3504         strncpy(redir3,redir2+strlen(common), MAXLINE);
 3505         strncpy(redir2,redir, MAXLINE);
 3506         strcat(redir2, redir3);
 3507         if (strlen(redir2) > 1) {
 3508             if (redir2[0] == '/' && redir2[1] == '/') {
 3509                 /* on slash to much - remove it */
 3510                 strncpy(redir3, redir2+1, MAXLINE);
 3511                 strncpy(redir2, redir3, MAXLINE);
 3512             }
 3513         }
 3514         if (strlen(redir2) > 0) {
 3515             add_redir_mstr_glist( &masterparam.mstr_redir,
 3516                     path, redir2);
 3517         }
 3518         return 1;
 3519     }
 3520 
 3521     return 0;
 3522 }
 3523 
 3524 
 3525 /*
 3526  * add a glist with filenames to the master-directories
 3527  */
 3528 static void add_master_dir_multiple(GList *sel_dirs) {
 3529 gchar redir[MAXLINE], dir[MAXLINE];
 3530 mstr_redirect_t *mstr;
 3531 gint stat, added;
 3532 GList *loop;
 3533 gchar commonstr[MAXLINE];
 3534  
 3535     added = 0;
 3536 
 3537     /* handling for single selected files */
 3538     if (g_list_length(sel_dirs) == 1) {
 3539         loop = g_list_first(sel_dirs);
 3540         strncpy(dir, loop->data, MAXLINE);
 3541 
 3542             /* valid file? */
 3543             if (is_file(dir) == 0) {
 3544                     show_dialog(ICO_INFO,_("No valid path specified"),T_OK,NULL,NULL,0);        
 3545                     return;
 3546             }
 3547     
 3548         /* add to glist */
 3549         if (check_in_mstr_glist(&masterparam.mstr_redir, dir) == 0) {
 3550 
 3551             /* show menu selecting where to add the file */
 3552             stat = show_mstr_redir(dir, redir);
 3553             if (stat == 0) {
 3554                 mstr = g_new0(mstr_redirect_t,1);
 3555                 mstr->mstr_path = g_strdup(dir);
 3556                 masterparam.mstr_redir = g_list_append(masterparam.mstr_redir, mstr);
 3557                 if (strlen(redir) > 0) {
 3558                     add_redir_mstr_glist(
 3559                         &masterparam.mstr_redir,
 3560                         dir, redir);
 3561                 }
 3562                 added = 1;
 3563             }
 3564 
 3565         } else {
 3566             /* path already added */
 3567                     show_dialog(ICO_WARN,_("Path already added"),T_OK,NULL,NULL,0); 
 3568             return;
 3569         }
 3570     } else {
 3571         /*
 3572          * multiple files selected
 3573          * get common path component
 3574          */
 3575         get_common_path_component(sel_dirs, commonstr);
 3576 
 3577         stat = show_mstr_redir_multi(commonstr, 
 3578                 g_list_length(sel_dirs), redir);
 3579         if (stat >= 0) {
 3580             loop = g_list_first(sel_dirs);
 3581             while (loop) {
 3582                 added += add_mult_mstr_file(
 3583                     (gchar *) loop->data,
 3584                     stat, redir, commonstr);
 3585 
 3586                 loop = loop->next;
 3587             }
 3588         }
 3589     }
 3590 
 3591     if (added) {
 3592         ctree_unselect_all();
 3593     }
 3594 
 3595     fill_session_view(0);
 3596 }
 3597 
 3598 
 3599 /*
 3600  * callback for add-button in master-source
 3601  */
 3602 static void add_master_dir(GtkWidget *widget, GtkWidget *entry) {
 3603 gchar dir[MAXLINE];
 3604 GList *sel_dirs;
 3605 
 3606     sel_dirs = NULL;
 3607 
 3608         strcpy(dir,gtk_entry_get_text(GTK_ENTRY(entry)));
 3609     strip_string(dir);
 3610 
 3611     /* empty string? abort */
 3612     if (!*dir) return;
 3613 
 3614     /* expand tilde */
 3615         check_tilde(dir);
 3616         gtk_entry_set_text(GTK_ENTRY(entry), dir);
 3617     convert_for_gtk2_filename(dir);
 3618 
 3619     if (dir[0] == '(') {
 3620         /* multiple selected? get from ctree */
 3621         ctree_get_selected(&sel_dirs);
 3622     } else {
 3623         sel_dirs=g_list_append(sel_dirs, g_strdup(dir));
 3624     }
 3625 
 3626     add_master_dir_multiple(sel_dirs);
 3627     free_glist(&sel_dirs);
 3628 }
 3629 
 3630 
 3631 /*
 3632  * exclude a glist from the master directories
 3633  */
 3634 static void exclude_master_dir_multiple(GList *sel_dirs) {
 3635 GList *loop;
 3636 gint added;
 3637 
 3638     added = 0;
 3639 
 3640     loop = g_list_first(sel_dirs);
 3641     while (loop) {
 3642         /* add to glist */
 3643         if (check_in_glist(&masterparam.exclude_paths, loop->data ) == 0) {
 3644             masterparam.exclude_paths = g_list_append(
 3645                 masterparam.exclude_paths, g_strdup(loop->data));
 3646             added = 1;
 3647         } else {
 3648             /* path already added */
 3649             if (g_list_length(sel_dirs) == 1) 
 3650                 show_dialog(ICO_WARN,_("Path already added"),T_OK,NULL,NULL,0);
 3651         }
 3652         loop = loop->next;
 3653     }
 3654 
 3655     if (added) {
 3656         ctree_unselect_all();
 3657     }
 3658 
 3659     fill_session_view(0);
 3660 }
 3661 
 3662 
 3663 /*
 3664  * callback for exclude-button in master-source
 3665  */
 3666 static void exclude_master_dir(GtkWidget *widget, GtkWidget *entry) {
 3667 gchar dir[MAXLINE];
 3668 GList *sel_dirs;
 3669 
 3670     sel_dirs = NULL;
 3671 
 3672     /* multiple dirs selected? */
 3673         strcpy(dir,gtk_entry_get_text(GTK_ENTRY(entry)));
 3674     strip_string(dir);
 3675     convert_for_gtk2_filename(dir);
 3676 
 3677     /* empty string? abort */
 3678     if (!*dir) return;
 3679 
 3680     if (dir[0] == '(') {
 3681         /* multiple selected? get from ctree */
 3682         ctree_get_selected(&sel_dirs);
 3683     } else {
 3684         sel_dirs=g_list_append(sel_dirs, g_strdup(dir));
 3685     }
 3686 
 3687     exclude_master_dir_multiple(sel_dirs);
 3688     free_glist(&sel_dirs);
 3689 }
 3690 
 3691 
 3692 /*
 3693  * callback for remove-button in master-source
 3694  */
 3695 static void remove_master_dir(GtkWidget *widget, gpointer data) {
 3696 GList *sel;
 3697 gint row, type;
 3698 gchar *rowdata;
 3699 gchar tmp2[MAXLINE];
 3700 gint nrtracks = 0;
 3701 
 3702     nrtracks = 0;
 3703 
 3704     sel = cdlist->selection;
 3705     while (sel) {
 3706         row = GPOINTER_TO_INT(sel->data);
 3707         type = GPOINTER_TO_INT(gtk_clist_get_row_data(cdlist,row));
 3708         if (type == 0) {
 3709             /* invalid row */
 3710             show_dialog(ICO_WARN,_("No valid path specified"),T_OK,NULL,NULL,0); 
 3711         } else {
 3712             gtk_clist_get_text(cdlist,row,1,&rowdata);
 3713             extract_mstr_path_from_clist(rowdata, tmp2);
 3714             if (type == 1) {
 3715                 del_mstr_glist_link(&masterparam.mstr_redir,
 3716                     tmp2, 1);
 3717             } else {
 3718                 del_glist_link(&masterparam.exclude_paths,
 3719                     tmp2);
 3720             }   
 3721         }
 3722         nrtracks++;
 3723         sel = sel->next;
 3724     }
 3725 
 3726     /* no tracks selected */
 3727     if (nrtracks == 0) {
 3728         show_dialog(ICO_INFO,_("No path selected to remove"),T_OK,NULL,NULL,0); 
 3729     } else {
 3730         fill_session_view(0);
 3731     }
 3732 }
 3733 
 3734 
 3735 /*
 3736  * called when path are dragged off from the master path window
 3737  */
 3738 void remove_master_dir_by_drag(GList *sel) {
 3739 GList *loop;
 3740 gchar *path;
 3741 gint type, count;
 3742 gchar tmp2[MAXLINE];
 3743 
 3744     count = 0;
 3745     loop = g_list_first(sel);
 3746     while (loop) {
 3747         path = (gchar *)loop->data;
 3748         if (path) {
 3749             /* extract type and real path */
 3750             if (strlen(path) > 2 && path[1] == ';') {
 3751                 type = path[0] - (gint)'0';
 3752                 strncpy(tmp2, path+2, MAXLINE);
 3753 
 3754                 if (type == 1) {
 3755                     del_mstr_glist_link(
 3756                         &masterparam.mstr_redir,
 3757                         tmp2, 1);
 3758                 } else 
 3759                 if (type == 2) {
 3760                     del_glist_link(
 3761                         &masterparam.exclude_paths,
 3762                         tmp2);
 3763                 }
 3764                 count++;
 3765             }
 3766         }
 3767         loop = loop->next;
 3768     }
 3769 
 3770     /* we actually deleted something? */
 3771     if (count > 0) {
 3772         /* redraw */
 3773         fill_session_view(0);
 3774         
 3775         /* and force the focus to be somewhere else
 3776            because it looks strange */
 3777         gtk_widget_grab_focus(cdlist_l1);
 3778     }
 3779 }
 3780 
 3781 
 3782 /*
 3783  * callback for redirect path (single and multiple)
 3784  */
 3785 static void redirect_master_dir(GtkWidget *widget, gpointer data) {
 3786 GList *sel, *sel_dirs, *loop;
 3787 gint row, type, count;
 3788 gint type0, type1, type2;
 3789 gchar *rowdata;
 3790 gchar tmp[MAXLINE];
 3791 gchar tmp2[MAXLINE];
 3792 gchar tmp3[MAXLINE];
 3793 gchar commonstr[MAXLINE];
 3794 gchar filename[MAXLINE];
 3795 
 3796     sel_dirs = NULL;
 3797 
 3798     sel = cdlist->selection;
 3799     count = g_list_length(sel);
 3800 
 3801     if (count == 1) {
 3802         row = GPOINTER_TO_INT(sel->data);
 3803         type = GPOINTER_TO_INT(gtk_clist_get_row_data(cdlist,row));
 3804         if (type == 0) {
 3805             /* invalid row */
 3806             show_dialog(ICO_WARN,_("No valid path specified"),T_OK,NULL,NULL,0); 
 3807         } else 
 3808         if (type == 2) {
 3809             /* excluded row */
 3810             show_dialog(ICO_WARN,_("An excluded path cannot be redirected"),T_OK,NULL,NULL,0); 
 3811         } else {
 3812             gtk_clist_get_text(cdlist,row,1,&rowdata);
 3813             extract_mstr_path_from_clist(rowdata, tmp2);
 3814             get_redir_path_from_mstr_glist(&masterparam.mstr_redir,
 3815                 tmp2, tmp);
 3816             if (show_request_redirect_path(tmp2, tmp) == 0) {
 3817                 if (strlen(tmp) > 0) {
 3818                     add_redir_mstr_glist(
 3819                         &masterparam.mstr_redir,
 3820                         tmp2, tmp);
 3821                 } else {
 3822                     /* remove redirection */
 3823                     del_mstr_glist_link(
 3824                         &masterparam.mstr_redir,
 3825                         tmp2, -1);
 3826                 }
 3827             }
 3828 
 3829             fill_session_view(0);
 3830         }
 3831     } else 
 3832     if (count == 0) {
 3833         show_dialog(ICO_INFO,_("No path selected to redirect"),T_OK,NULL,NULL,0); 
 3834     } else {
 3835         /*
 3836          * multiple paths selected
 3837          * first check if all selected paths are of same time
 3838          */
 3839         type0 = 0;
 3840         type1 = 0;
 3841         type2 = 0;
 3842         loop = g_list_first(sel);
 3843         while (loop) {
 3844             row = GPOINTER_TO_INT(loop->data);
 3845             type = GPOINTER_TO_INT(gtk_clist_get_row_data(cdlist,row));
 3846             if (type == 0) {
 3847                 type0++;
 3848             }
 3849             if (type == 1) {
 3850                 type1++;
 3851             }
 3852             if (type == 2) {
 3853                 type2++;
 3854             }
 3855             loop = loop->next;
 3856         }
 3857         if (type0 > 0) {
 3858             /* invalid row */
 3859             show_dialog(ICO_WARN,_("No valid path specified"),T_OK,NULL,NULL,0); 
 3860         } else 
 3861         if (type2 > 0) {
 3862             /* excluded row */
 3863             show_dialog(ICO_WARN,_("An excluded path cannot be redirected"),T_OK,NULL,NULL,0); 
 3864         } else {
 3865             /*
 3866              * all ok so far - only master paths selected
 3867              * create glist with the selected paths
 3868              */
 3869             loop = g_list_first(sel);
 3870             while (loop) {
 3871                 row = GPOINTER_TO_INT(loop->data);
 3872                 gtk_clist_get_text(cdlist,row,1,&rowdata);
 3873                 extract_mstr_path_from_clist(rowdata, tmp2);
 3874                 sel_dirs=g_list_append(sel_dirs, g_strdup(tmp2));
 3875 
 3876                 loop = loop->next;
 3877             }
 3878 
 3879             /* get common path component */
 3880             get_common_path_component(sel_dirs, commonstr);
 3881 
 3882             if (show_request_redirect_path_multiple(commonstr, g_list_length(sel_dirs), tmp) == 0) {
 3883                 if (strlen(tmp) > 0) {
 3884 
 3885                     loop = g_list_first(sel_dirs);
 3886                     while (loop) {
 3887                         if (is_directory(loop->data)) {
 3888                             add_redir_mstr_glist(
 3889                                 &masterparam.mstr_redir,
 3890                                 loop->data, tmp);
 3891                         } else {
 3892                             /* redirecting a file? */
 3893                             get_purefile(loop->data, filename);             
 3894                             g_snprintf(tmp3,MAXLINE,"%s%s", tmp, filename);
 3895                             add_redir_mstr_glist(
 3896                                 &masterparam.mstr_redir,
 3897                                 loop->data, tmp3);
 3898                         }
 3899                         loop = loop->next;
 3900                     }
 3901                 } else {
 3902                     /* remove redirection */
 3903                     loop = g_list_first(sel_dirs);
 3904                     while (loop) {
 3905                         del_mstr_glist_link(
 3906                             &masterparam.mstr_redir,
 3907                             loop->data, -1);
 3908 
 3909                         loop = loop->next;
 3910                     }
 3911                 }
 3912             }
 3913 
 3914             fill_session_view(0);
 3915 
 3916         }
 3917     }
 3918 
 3919 }
 3920 
 3921 
 3922 /*
 3923  * fill the session-view clist
 3924  * if checkmedia = -1, then don't check, but show info about update button
 3925  */
 3926 static void fill_session_view(gint checkmedia) {
 3927 GtkStyle *style;
 3928 gchar *data[2];
 3929 GdkPixmap *pixmap1, *pixmap2, *pixmap3, *pixmap4;
 3930 GdkBitmap *mask1, *mask2, *mask3, *mask4;
 3931 gint i, j, lcount, orglcount;
 3932 gchar tmp[MAXLINE];
 3933 gchar tmp2[MAXLINE];
 3934 gchar tmp3[MAXLINE];
 3935 GList *loop;
 3936 mstr_redirect_t *mstr;
 3937 gint msinfo1, msinfo2;
 3938 gint toprow, topcol;
 3939 
 3940     /* get current scroll position */
 3941         if(!gtk_clist_get_selection_info(cdlist, 0, 0, &toprow, &topcol)) {
 3942                 toprow = 0;
 3943                 topcol = 0;
 3944         }
 3945 
 3946         /* clean up first */
 3947     gtk_clist_freeze(cdlist);
 3948         gtk_clist_clear(cdlist);
 3949 
 3950         style = gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(cdlist)));
 3951         pixmap1 = gdk_pixmap_create_from_xpm_d(cdlist->clist_window,
 3952                 &mask1, &style->bg[GTK_STATE_NORMAL],(gchar **)minidata_xpm);
 3953         pixmap2 = gdk_pixmap_create_from_xpm_d(cdlist->clist_window,
 3954                 &mask2, &style->bg[GTK_STATE_NORMAL],(gchar **)miniaudio_xpm);
 3955         pixmap3 = gdk_pixmap_create_from_xpm_d(cdlist->clist_window,
 3956                 &mask3, &style->bg[GTK_STATE_NORMAL],(gchar **)masteradd_xpm);
 3957         pixmap4 = gdk_pixmap_create_from_xpm_d(cdlist->clist_window,
 3958                 &mask4, &style->bg[GTK_STATE_NORMAL],(gchar **)masterdel_xpm);
 3959 
 3960         lcount = 0;
 3961     msinfo1 = -1;
 3962     msinfo2 = -1;
 3963         data[0] = NULL;
 3964 
 3965         /* no disc loaded? */
 3966         if (cdinfo.nr_tracks == -1) {
 3967         strncpy(tmp3, _("No Disc loaded"), MAXLINE);
 3968         data[1] = convert_for_gtk2(tmp3); 
 3969                 gtk_clist_append(cdlist,data);
 3970         gtk_clist_set_row_data(cdlist,lcount,GINT_TO_POINTER(0));
 3971         lcount++;
 3972         } else {
 3973         /* at least something in drive? try to get msinfo */
 3974             if (curset.writer_devnr != -1 && checkmedia == 1) {
 3975             get_msinfo_info(curset.writer_devnr, &msinfo1, 
 3976                 &msinfo2);
 3977         }
 3978     }
 3979 
 3980     if (checkmedia == 1) {
 3981         /* save session info */
 3982         masterparam.last_session_start = msinfo1;
 3983         masterparam.next_session_start = msinfo2;
 3984 
 3985         /* remember we requested the session info */
 3986         session_current_state = 1;
 3987     }
 3988 
 3989     if (checkmedia == -1) {
 3990         /*
 3991          * just entered menu new?
 3992          * set state to "we don't know session info yet"
 3993          */
 3994         session_current_state = 0;
 3995     }
 3996 
 3997     /* empty disc loaded */
 3998         if (cdinfo.nr_tracks == -2) {
 3999         strncpy(tmp3, return_media_type(curset.writer_devnr), MAXLINE);
 4000         data[1] = convert_for_gtk2(tmp3); 
 4001                 gtk_clist_append(cdlist,data);
 4002         gtk_clist_set_row_data(cdlist,lcount,GINT_TO_POINTER(0));
 4003         gtk_clist_set_selectable(cdlist,lcount,FALSE);
 4004         lcount++;
 4005     }
 4006 
 4007     if (session_current_state == 0 && cdinfo.nr_tracks > 0) {
 4008         /*
 4009          * disc inserted, but we haven't checked for msinfo?
 4010          * tell the user to click 'update' to see more
 4011          */
 4012         strncpy(tmp3, _("Click \"Update Session view\" to"), MAXLINE);
 4013         data[1] = convert_for_gtk2(tmp3); 
 4014                 gtk_clist_append(cdlist,data);
 4015         gtk_clist_set_row_data(cdlist,lcount,GINT_TO_POINTER(0));
 4016         gtk_clist_set_selectable(cdlist,lcount,FALSE);
 4017         lcount++;
 4018         strncpy(tmp3, _("check the sessions of the media."), MAXLINE);
 4019         data[1] = convert_for_gtk2(tmp3); 
 4020                 gtk_clist_append(cdlist,data);
 4021         gtk_clist_set_row_data(cdlist,lcount,GINT_TO_POINTER(0));
 4022         gtk_clist_set_selectable(cdlist,lcount,FALSE);
 4023         lcount++;
 4024     
 4025         /* invalidate session info */
 4026         masterparam.last_session_start = -1;
 4027         masterparam.next_session_start = -1;
 4028 
 4029     } else {
 4030         /* display track listing */
 4031              for (i = 0; i < cdinfo.nr_tracks; i++) {
 4032                     if (trackinfo[i]->type == 0) {
 4033                            convert_frames2mbstring(trackinfo[i]->size,tmp2);
 4034                             g_snprintf(tmp,MAXLINE,"%2d. %s [%s]",
 4035                                   trackinfo[i]->track_nr,
 4036                                      _("data track"), tmp2);
 4037                 data[1] = convert_for_gtk2(tmp); 
 4038                             gtk_clist_append(cdlist,data);
 4039                             gtk_clist_set_pixmap(cdlist,lcount,0,pixmap1,mask1);
 4040                 gtk_clist_set_row_data(cdlist,lcount,GINT_TO_POINTER(0));
 4041                           lcount++;
 4042                     } else {
 4043                             convert_frames2minstring(trackinfo[i]->size,tmp2);
 4044                             g_snprintf(tmp,MAXLINE,"%2d. %s [%s]",
 4045                                     trackinfo[i]->track_nr,
 4046                                     _("audio track"), tmp2);
 4047                 data[1] = convert_for_gtk2(tmp); 
 4048                             gtk_clist_append(cdlist,data);
 4049                             gtk_clist_set_pixmap(cdlist,lcount,0,pixmap2,mask2);
 4050                 gtk_clist_set_row_data(cdlist,lcount,GINT_TO_POINTER(0));
 4051                             lcount++;
 4052                  }
 4053         }
 4054     }
 4055 
 4056     /* draw separator */
 4057     strcpy(tmp,"_________________");
 4058     data[1] = convert_for_gtk2(tmp); 
 4059         gtk_clist_append(cdlist,data);
 4060     gtk_clist_set_row_data(cdlist,lcount,GINT_TO_POINTER(0));
 4061     gtk_clist_set_selectable(cdlist,lcount,FALSE);
 4062     lcount++;
 4063     strcpy(tmp,"");
 4064     data[1] = convert_for_gtk2(tmp); 
 4065         gtk_clist_append(cdlist,data);
 4066     gtk_clist_set_row_data(cdlist,lcount,GINT_TO_POINTER(0));
 4067     gtk_clist_set_selectable(cdlist,lcount,FALSE);
 4068     lcount++;
 4069 
 4070     orglcount = lcount;
 4071 
 4072     /* draw master-dirs */
 4073     loop = g_list_first(masterparam.mstr_redir);
 4074     while (loop) {
 4075         mstr = (mstr_redirect_t *) loop->data;
 4076         if (mstr) {
 4077             if (mstr->mstr_path && !mstr->redir_path) {
 4078                 /* no redir available */
 4079                 strncpy(tmp3, mstr->mstr_path,  MAXLINE);
 4080                 data[1] = convert_for_gtk2(tmp3); 
 4081             } else 
 4082             if (mstr->mstr_path && mstr->redir_path) {
 4083                 g_snprintf(tmp,MAXLINE,"%s => %s", 
 4084                     mstr->mstr_path, mstr->redir_path); 
 4085                 data[1] = convert_for_gtk2(tmp); 
 4086             } else {
 4087                 data[1] = "";
 4088             }
 4089         } else {
 4090             data[1] = "";
 4091         }
 4092         
 4093                 gtk_clist_append(cdlist,data);
 4094                 gtk_clist_set_pixmap(cdlist,lcount,0,pixmap3,mask3);
 4095         gtk_clist_set_row_data(cdlist,lcount,GINT_TO_POINTER(1));
 4096                 lcount++;
 4097 
 4098         loop = loop->next;
 4099     }
 4100 
 4101     /* draw exclude-dirs */
 4102     loop = g_list_first(masterparam.exclude_paths);
 4103     while (loop) {
 4104         strncpy(tmp3, (gchar *)loop->data,  MAXLINE);
 4105         data[1] = convert_for_gtk2(tmp3); 
 4106 
 4107                 gtk_clist_append(cdlist,data);
 4108                 gtk_clist_set_pixmap(cdlist,lcount,0,pixmap4,mask4);
 4109         gtk_clist_set_row_data(cdlist,lcount,GINT_TO_POINTER(2));
 4110                 lcount++;
 4111 
 4112         loop = loop->next;
 4113     }
 4114 
 4115     /* make session-size invalid, because we changed the paths */
 4116     set_sessionsize_unknown();
 4117 
 4118     /* have we added any paths? No? Show help about right click */
 4119     if (orglcount == lcount) {
 4120         strncpy(tmp3, _("(right click for context menu)"),  MAXLINE);
 4121         data[1] = convert_for_gtk2(tmp3); 
 4122             gtk_clist_append(cdlist,data);
 4123         gtk_clist_set_row_data(cdlist,lcount,GINT_TO_POINTER(0));
 4124         gtk_clist_set_selectable(cdlist,lcount,FALSE);
 4125         lcount++;
 4126         data[1] = "";
 4127         for (j = 0; j < 6; j++) {
 4128                 gtk_clist_append(cdlist,data);
 4129             gtk_clist_set_row_data(cdlist,lcount,GINT_TO_POINTER(0));
 4130             gtk_clist_set_selectable(cdlist,lcount,FALSE);
 4131             lcount++;
 4132         }
 4133         strncpy(tmp3, _("          Drop files to exclude here ->"), MAXLINE);
 4134         data[1] = convert_for_gtk2(tmp3); 
 4135             gtk_clist_append(cdlist,data);
 4136         gtk_clist_set_row_data(cdlist,lcount,GINT_TO_POINTER(0));
 4137         gtk_clist_set_selectable(cdlist,lcount,FALSE);
 4138         lcount++;
 4139 
 4140     }
 4141 
 4142     /* now scroll to remembered position */
 4143     gtk_clist_moveto(cdlist, toprow, topcol, 0.0, 0.0);
 4144     gtk_clist_thaw(cdlist);
 4145 
 4146 }
 4147 
 4148 
 4149 /*
 4150  * calculate free and used space and display
 4151  */
 4152 static void fill_session_available() {
 4153 gchar tmp[MAXLINE];
 4154 gint cdsize, used, avail;
 4155 gint64 tmpsize;
 4156 
 4157     /*
 4158      * current available size according to media-selector
 4159      * in sectors
 4160      */
 4161     if (curset.cdrtype < 1000) {
 4162         cdsize = curset.cdrtype*60*75;
 4163     } else {
 4164                 /* capacity of a DVD in bytes */
 4165                 tmpsize = (gint64)curset.cdrtype * 1000 * 1000;
 4166                 /* and now in sectors */
 4167                 tmpsize = tmpsize / 2048;
 4168 
 4169         cdsize = (gint) tmpsize;
 4170     }
 4171     used = 0;
 4172     avail = cdsize;
 4173 
 4174     /* we want to write multisession? consider session overhead */
 4175     if (curset.multisession == 1) {
 4176         if (cdinfo.nr_tracks > 0) {
 4177             /*
 4178              * additional sessions
 4179              * about 13 MiB
 4180              */
 4181             avail -= 6900;
 4182         } else {
 4183             /*
 4184              * first session
 4185              * about 22 MiB
 4186              */
 4187             avail -= 11400;
 4188         }
 4189         /*
 4190          * disable/enable write mode selector in "Create Disc" menu
 4191          * also depends on the rights the user has got and on cdrtype;
 4192          * disable/enable the nofixate checkbox as well
 4193          */
 4194         if (crea_cd_mode_omenu && curset.writer_devnr != -1) {
 4195             gtk_widget_set_sensitive(crea_cd_mode_omenu, FALSE);
 4196         }
 4197         if (crea_cd_nofixate_check && curset.writer_devnr != -1) {
 4198             gtk_widget_set_sensitive(crea_cd_nofixate_check,FALSE);
 4199         }
 4200     } else {
 4201         if ((isroot() || setupdata.root_option_change_writeparam)
 4202           && curset.cdrtype < 1000
 4203           && crea_cd_mode_omenu && curset.writer_devnr != -1) {
 4204             gtk_widget_set_sensitive(crea_cd_mode_omenu, TRUE);
 4205         }
 4206         if (crea_cd_nofixate_check && curset.writer_devnr != -1) {
 4207             gtk_widget_set_sensitive(crea_cd_nofixate_check,TRUE);
 4208         }
 4209     }
 4210 
 4211     /* multisession disc with some sessions? */
 4212     if (masterparam.next_session_start > 0) {
 4213         used += masterparam.next_session_start;
 4214         avail -= masterparam.next_session_start;
 4215     }
 4216     /* transform sectors into MiB */
 4217     used = used * (DATASECTORSIZE/1024)/1024;
 4218     avail = avail * (DATASECTORSIZE/1024)/1024;
 4219 
 4220     /* tracks, but not yet checked for msinfo? */
 4221     if (cdinfo.nr_tracks > 0 && session_current_state == 0) {
 4222         strncpy(tmp,_("Unknown"), MAXLINE);
 4223     } else 
 4224     /* tracks, but no multisession? */
 4225     if (cdinfo.nr_tracks > 0 && masterparam.next_session_start == -1) {
 4226         strncpy(tmp,_("Disc closed"), MAXLINE);
 4227     } else {
 4228         /* empty/no disc or multisession disc */
 4229         g_snprintf(tmp,MAXLINE,"%d MiB / %d MiB", used, avail);
 4230     }
 4231     gtk_entry_set_text(GTK_ENTRY(master_avail_entry), tmp);
 4232 
 4233     /* tracks, but not yet checked for msinfo? */
 4234     if (cdinfo.nr_tracks > 0 && session_current_state == 0) {
 4235         g_snprintf(tmp,MAXLINE," - / %d MiB", avail);
 4236     } else 
 4237     /* tracks, but no multisession? (display in menu5) */
 4238     if (cdinfo.nr_tracks > 0 && masterparam.next_session_start == -1) {
 4239         g_snprintf(tmp,MAXLINE," - / %d MiB", avail);
 4240     } else {
 4241         /* empty/no disc or multisession disc */
 4242         g_snprintf(tmp,MAXLINE,"%d MiB / %d MiB", used, avail);
 4243     }
 4244     if (cdlist_l1) {
 4245         gtk_entry_set_text(GTK_ENTRY(cdlist_l1), tmp);
 4246     }
 4247 }
 4248 
 4249 
 4250 /*
 4251  * check disc in writer device and redraw
 4252  */
 4253 static void session_view_update(GtkWidget *widget, gpointer data) {
 4254 GdkCursor *cursor;
 4255 
 4256         do_lock(1);
 4257         /* change cursor to watch */
 4258         cursor = gdk_cursor_new(GDK_WATCH);
 4259         gdk_window_set_cursor(GTK_WIDGET(toplevel)->window,cursor);
 4260 
 4261         while (gtk_events_pending())
 4262                 gtk_main_iteration();
 4263 
 4264         if (curset.writer_devnr != -1) {
 4265                 get_cd_toc_and_volid(curset.writer_devnr);
 4266         }
 4267     /* called from button */
 4268     if (widget) {
 4269         fill_session_view(1);
 4270     } else {
 4271         /* called from startup */
 4272         fill_session_view(-1);
 4273     }
 4274 
 4275     fill_session_available();
 4276 
 4277         /* reset cursor */
 4278         gdk_window_set_cursor(GTK_WIDGET(toplevel)->window,NULL);
 4279     gdk_cursor_destroy (cursor);
 4280 
 4281         do_unlock(1);
 4282 }
 4283 
 4284 
 4285 /*
 4286  * called when a context menu entry is selected
 4287  */
 4288 static void context_response(gint nr) {
 4289 gchar tmp[MAXLINE];
 4290 gchar tmp2[MAXLINE];
 4291 gint stat;
 4292     
 4293     /* select all */
 4294     if (nr == 0) {
 4295         gtk_clist_select_all(cdlist);
 4296     }
 4297 
 4298     /* unselect all */
 4299     if (nr == 1) {
 4300         gtk_clist_unselect_all(cdlist);
 4301     }
 4302 
 4303     /* load list selected? */
 4304     if (nr == 2) {
 4305         /* show fileselector */
 4306         show_file_selector(_("Load list of paths to master"), MODE_OPEN, SAVEMASTERLIST,tmp);
 4307 
 4308         if (strcmp(tmp,"") != 0) {
 4309             stat = load_master_list(tmp);
 4310             if (stat == 1) {
 4311                 /* load failed */
 4312                 g_snprintf(tmp2,MAXLINE,_("Error reading file %s"),tmp);
 4313                 show_dialog(ICO_ERROR,tmp2, T_OK, NULL, NULL, 0);
 4314             }
 4315             fill_session_view(0);
 4316         }
 4317     }
 4318 
 4319     /* save list selected? */
 4320     if (nr == 3) {
 4321         /* show fileselector */
 4322         show_file_selector(_("Save list of paths to master"), MODE_SAVE, SAVEMASTERLIST,tmp);
 4323 
 4324         if (strcmp(tmp,"") != 0) {
 4325             stat = save_master_list(tmp);
 4326             if (stat == 1) {
 4327                 /* save failed */
 4328                 g_snprintf(tmp2,MAXLINE,_("Error writing file %s"),tmp);
 4329                 show_dialog(ICO_ERROR,tmp2, T_OK, NULL, NULL, 0);
 4330             }
 4331             if (stat == 0) {
 4332                 /* save ok */
 4333                 show_dialog(ICO_INFO,_("List of paths to master saved successfully"), T_OK, NULL, NULL, 0);
 4334             }
 4335         }
 4336     }
 4337 
 4338     /* delete list selected ? */
 4339     if (nr == 4) {
 4340         stat = show_dialog(ICO_WARN,_("Are you sure you want to remove all\nthe paths from the list?"),T_YES,T_NO,NULL,0);
 4341         if (stat == 1) return;
 4342 
 4343         /* user is sure, so clear list */
 4344         clear_mstr_glist(&masterparam.mstr_redir);
 4345         free_glist(&masterparam.exclude_paths);
 4346 
 4347         fill_session_view(0);
 4348     }
 4349 }
 4350 
 4351 
 4352 /*
 4353  * called when a context menu entry is selected in the directory view
 4354  */
 4355 static void context_response2(gint nr) {
 4356     
 4357     /* unselect all selected? */
 4358     if (nr == 0) {
 4359         ctree_unselect_all();
 4360     }
 4361 }
 4362 
 4363 
 4364 /*
 4365  * called by a click on the session-view or directory-view
 4366  */
 4367 static gint activate_context(GtkWidget *widget, GdkEvent *event) {
 4368 
 4369     if (event->button.button == 3) {
 4370         /* show context menu */
 4371         gtk_menu_popup(GTK_MENU(widget), NULL, NULL, 
 4372             NULL, NULL, event->button.button, event->button.time);
 4373         return TRUE;
 4374     }
 4375     return FALSE;
 4376 }
 4377 
 4378 static gint mstr_press_event(GtkWidget *widget, GdkEventKey *event) {
 4379 
 4380     /* see if backspace or delete key is pressed in master menu */
 4381     if (event->keyval == GDK_BackSpace ||
 4382         event->keyval == GDK_Delete) {
 4383         gtk_button_clicked(GTK_BUTTON(widget));
 4384     }
 4385 
 4386     return TRUE;
 4387 }
 4388 
 4389 
 4390 /*
 4391  * called when a drag is received on the entry
 4392  */
 4393 static void entry_masterdir_drag_received(GtkWidget *widget, 
 4394         GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data,
 4395         guint info, guint t, gpointer data) {
 4396 gchar *text;
 4397 gchar newdir[MAXLINE];
 4398 
 4399         /* nothing received? ignore */
 4400         if(selection_data == NULL)
 4401                 return;
 4402         if(selection_data->length < 0)
 4403                 return;
 4404 
 4405         if ((info == DRAG_TAR_INFO_0) ||
 4406            (info == DRAG_TAR_INFO_1) ||
 4407            (info == DRAG_TAR_INFO_2)) {
 4408                 text = (char *) selection_data->data;
 4409                 if (extract_single_drag_filename(text, selection_data->length, newdir)) {
 4410                         /* extracted the plain filename from drag */
 4411                         if (strcmp(newdir,"") != 0) {
 4412                 dodebug(3,"Received from drag: %s\n", newdir);
 4413                                 gtk_entry_set_text(data, newdir);
 4414 
 4415                 /* scroll to that path in the dir browser */
 4416                 ctree_expand_manualpath(data, NULL);
 4417             }
 4418         }
 4419     }
 4420 }
 4421 
 4422 
 4423 /*
 4424  * called when a drag is received on the masterdir clist
 4425  */
 4426 static void masterdirs_drag_received(GtkWidget *widget, 
 4427         GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data,
 4428         guint info, guint t, gpointer data) {
 4429 GList *input, *loop;
 4430 gchar *text;
 4431 gint action;
 4432 
 4433     input = NULL;
 4434     action = GPOINTER_TO_INT(data);
 4435 
 4436         /* nothing received? ignore */
 4437         if(selection_data == NULL)
 4438                 return;
 4439         if(selection_data->length < 0)
 4440                 return;
 4441 
 4442         if ((info == DRAG_TAR_INFO_0) ||
 4443            (info == DRAG_TAR_INFO_1) ||
 4444            (info == DRAG_TAR_INFO_2)) {
 4445                 text = (char *) selection_data->data;
 4446         if (extract_glist_drag_filenames(text, selection_data->length,
 4447             "file:", &input)) {
 4448 
 4449             if (debug) {
 4450                 loop = g_list_first(input);
 4451                 while(loop) {
 4452                     if (loop->data != NULL)
 4453                         dodebug(3,"Received from drag: %s\n", (gchar *)loop->data);
 4454                     loop = loop->next;
 4455                 }
 4456             }
 4457 
 4458             /* add or exclude action? */
 4459             if (action == 0) {
 4460                 exclude_master_dir_multiple(input);
 4461             } else {
 4462                 add_master_dir_multiple(input);
 4463             }
 4464             free_glist(&input);
 4465         }
 4466     }
 4467 }
 4468 
 4469 
 4470 /*
 4471  * allow to drag tracks out of the left track window
 4472  * to have them deleted
 4473  */
 4474 static void masterdirs_request_dnddata(GtkWidget *widget, 
 4475         GdkDragContext *dc,
 4476         GtkSelectionData *selection_data, guint info, guint t, 
 4477         gpointer data) {
 4478 gboolean data_sent = FALSE;
 4479 GtkCList *clist;
 4480 GList *sel;
 4481 gint row, focusrow, bufcount, type;
 4482 gchar tmp[MAXLINE], tmp2[MAXLINE];
 4483 gchar bigtmp[MAXLINE*10];
 4484 gint use_selection;
 4485 gchar *rowdata;
 4486 
 4487         clist = GTK_CLIST(widget);
 4488         focusrow = clist->focus_row;
 4489         use_selection = 0;
 4490 
 4491 
 4492         /* see if any other rows are selected */
 4493         sel = clist->selection;
 4494         while (sel) {
 4495                 row = GPOINTER_TO_INT(sel->data);
 4496                 if (row == focusrow) {
 4497                         /* we focused a row that is selected, remember */
 4498                         use_selection = 1;
 4499                 }
 4500                 sel = sel->next;
 4501         }
 4502 
 4503         /* Selected row in bounds? */
 4504         if ((focusrow >= 0) && (focusrow < clist->rows) && (GTK_WIDGET_HAS_FOCUS(widget))) {
 4505 
 4506                 /* return single track from focused line */
 4507                 if (use_selection == 0) {
 4508             type = GPOINTER_TO_INT(gtk_clist_get_row_data(clist,focusrow));
 4509             gtk_clist_get_text(clist,focusrow,1,&rowdata);
 4510             extract_mstr_path_from_clist(rowdata, tmp2);
 4511     
 4512                         g_snprintf(bigtmp, MAXLINE*10, "xrmv:%d;%s", type, tmp2);
 4513                         gtk_selection_data_set(
 4514                                         selection_data,
 4515                                         GDK_SELECTION_TYPE_STRING, 8,
 4516                                         (const unsigned char *) bigtmp, strlen(bigtmp));
 4517                         data_sent = TRUE;
 4518                 } else {
 4519                         /* return not from focus but all selected */
 4520                         strcpy(bigtmp,"");
 4521                         bufcount = 0;   
 4522                         sel = clist->selection;
 4523                         while (sel) {
 4524                                 row = GPOINTER_TO_INT(sel->data);
 4525                 type = GPOINTER_TO_INT(gtk_clist_get_row_data(clist,row));
 4526                 gtk_clist_get_text(clist,row,1,&rowdata);
 4527                 extract_mstr_path_from_clist(rowdata, tmp);
 4528                             g_snprintf(tmp2, MAXLINE, "xrmv:%d;%s\r\n", type, tmp);
 4529 
 4530                                 bufcount+=strlen(tmp2);
 4531                                 if (bufcount < MAXLINE*10) {
 4532                                     strcat(bigtmp,tmp2);
 4533                                 }
 4534 
 4535                                 sel = sel->next;
 4536                         }
 4537                         if (bufcount > 0) {
 4538                                 gtk_selection_data_set(
 4539                                         selection_data,
 4540                                         GDK_SELECTION_TYPE_STRING, 8, 
 4541                                         (const unsigned char *) bigtmp, strlen(bigtmp));
 4542                                 data_sent = TRUE;
 4543                         }
 4544                 }
 4545         }
 4546 
 4547         /* we have to send something even in an error case */
 4548         if (!data_sent) {
 4549                 const gchar *cstrptr = "Error";
 4550 
 4551                 gtk_selection_data_set(
 4552                         selection_data,
 4553                         GDK_SELECTION_TYPE_STRING, 8,
 4554                         (const unsigned char *) cstrptr, strlen(cstrptr));
 4555         }
 4556 }
 4557 
 4558 
 4559 /*
 4560  * first submenu of master menu
 4561  */
 4562 static void draw_master_menu1(GtkWidget *box) {
 4563 GtkWidget *vbox, *hbox, *hhbox;
 4564 GtkWidget *f1,* f2, *f3;
 4565 GtkWidget *e1, *l1, *entry1;
 4566 GtkWidget *tbl, *b1, *delpixmap, *align;
 4567 GtkWidget *scrolled_win, *cd_list;
 4568 GtkWidget *check, *event_box;
 4569 GtkCTree *ctree;
 4570 GtkWidget *context_menu, *context_items, *context_menu2;
 4571 static const gchar *context_text[] = CONTEXT_MSTRMENU;
 4572 gint i;
 4573 gchar tmp[MAXLINE];
 4574 gchar base_tree[MAXLINE];
 4575 gchar *p;
 4576 GtkTargetEntry target_entry[3];
 4577 GdkPixmap *pixmap;
 4578 GdkBitmap *mask;
 4579 GtkStyle *style;
 4580 
 4581         /* required for drag&drop setup */
 4582         target_entry[0].target = DRAG_TAR_NAME_0;
 4583         target_entry[0].flags = 0;
 4584         target_entry[0].info = DRAG_TAR_INFO_0;
 4585         target_entry[1].target = DRAG_TAR_NAME_1;
 4586         target_entry[1].flags = 0;
 4587         target_entry[1].info = DRAG_TAR_INFO_1;
 4588         target_entry[2].target = DRAG_TAR_NAME_2;
 4589         target_entry[2].flags = 0;
 4590         target_entry[2].info = DRAG_TAR_INFO_2;
 4591 
 4592     cdlist_l1 = NULL;
 4593 
 4594         /* left and right info-frames */
 4595         tbl = gtk_table_new(1,2,TRUE);
 4596         gtk_container_set_border_width(GTK_CONTAINER (tbl),5);
 4597         gtk_table_set_col_spacings(GTK_TABLE(tbl),5);
 4598         gtk_box_pack_start(GTK_BOX(box),tbl,TRUE,TRUE,0);
 4599         gtk_widget_show(tbl);
 4600         f1 = gtk_frame_new(_("Session view"));
 4601         set_font_and_color_frame(f1,PANGO_BOLD,NULL);
 4602         gtk_table_attach_defaults(GTK_TABLE(tbl),f1,0,1,0,1);
 4603         gtk_widget_show(f1);
 4604         f2 = gtk_frame_new(_("File/Directory view"));
 4605         set_font_and_color_frame(f2,PANGO_BOLD,NULL);
 4606         gtk_table_attach_defaults(GTK_TABLE(tbl),f2,1,2,0,1);
 4607         gtk_widget_show(f2);
 4608 
 4609         /* left info frame */
 4610         vbox = gtk_vbox_new(FALSE,0);
 4611         gtk_container_add(GTK_CONTAINER(f1),vbox);
 4612         gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
 4613         gtk_widget_show(vbox);
 4614 
 4615     hhbox = gtk_hbox_new(FALSE,0);
 4616     gtk_box_pack_start(GTK_BOX(vbox),hhbox,TRUE,TRUE,0);
 4617     gtk_widget_show(hhbox);
 4618 
 4619         scrolled_win = gtk_scrolled_window_new (NULL, NULL);
 4620         gtk_box_pack_start(GTK_BOX(hhbox),scrolled_win,TRUE,TRUE,3);
 4621         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
 4622                 GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
 4623         gtk_widget_show(scrolled_win);
 4624 
 4625     cd_list = gtk_clist_new(2);
 4626     gtk_container_add (GTK_CONTAINER (scrolled_win), cd_list);
 4627     cdlist = GTK_CLIST(cd_list);
 4628         gtk_clist_set_column_width(cdlist, 0, 16);
 4629         gtk_clist_set_column_auto_resize(cdlist, 1, TRUE);
 4630     gtk_clist_set_selection_mode (cdlist, GTK_SELECTION_MULTIPLE);
 4631 
 4632     /* init context menu */
 4633     context_menu = gtk_menu_new();
 4634     i = 0;
 4635     while(context_text[i]) {
 4636         context_items = gtk_menu_item_new_with_label(
 4637                     _(context_text[i]));
 4638         gtk_menu_append(GTK_MENU(context_menu), context_items);
 4639         gtk_signal_connect_object (GTK_OBJECT (context_items), 
 4640             "activate", GTK_SIGNAL_FUNC(context_response),
 4641             GINT_TO_POINTER(i));
 4642         gtk_widget_show(context_items);
 4643         i++;
 4644     }
 4645 
 4646     gtk_signal_connect_object(GTK_OBJECT(cdlist), "button_press_event",
 4647         GTK_SIGNAL_FUNC(activate_context), GTK_OBJECT(context_menu));
 4648 
 4649     /* drag&drop setup */
 4650         gtk_widget_realize(cd_list);
 4651         if(!GTK_WIDGET_NO_WINDOW(cd_list)) {
 4652                 gtk_drag_dest_set(
 4653                         cd_list,
 4654                         GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT |
 4655                         GTK_DEST_DEFAULT_DROP,
 4656                         target_entry,
 4657                         sizeof(target_entry) / sizeof(GtkTargetEntry),
 4658                         GDK_ACTION_MOVE | GDK_ACTION_COPY
 4659                 );
 4660             gtk_signal_connect(GTK_OBJECT(cd_list), "drag_data_received",
 4661                     GTK_SIGNAL_FUNC(masterdirs_drag_received), 
 4662             GINT_TO_POINTER(1));
 4663 
 4664         /* we can send drags, too */
 4665                 gtk_drag_source_set(
 4666                         cd_list, 
 4667                         GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
 4668                         target_entry,
 4669                         sizeof(target_entry) / sizeof(GtkTargetEntry),
 4670                         GDK_ACTION_MOVE);
 4671                 gtk_signal_connect(
 4672                         GTK_OBJECT(cd_list), "drag_data_get",
 4673                         GTK_SIGNAL_FUNC(masterdirs_request_dnddata), NULL);
 4674     }
 4675     gtk_widget_show(cd_list);
 4676 
 4677     /* little drag-to-exclude field */
 4678     f3 = gtk_frame_new(NULL);
 4679     gtk_frame_set_shadow_type(GTK_FRAME(f3),GTK_SHADOW_IN);
 4680         gtk_widget_set_size_request(f3, 20, -1);
 4681     gtk_box_pack_start(GTK_BOX(hhbox),f3,FALSE,FALSE,0);
 4682         gtk_widget_show(f3);
 4683 
 4684 
 4685     /* needed so we can receive events */
 4686     event_box = gtk_event_box_new();
 4687     gtk_container_add(GTK_CONTAINER(f3), event_box);
 4688     gtk_widget_show(event_box);
 4689     
 4690     /* top align */
 4691     align = gtk_alignment_new(0.0,0.0,0,0);
 4692     gtk_container_add(GTK_CONTAINER(event_box), align);
 4693     gtk_widget_show(align);
 4694     
 4695     /* all little delete icon */
 4696     style = gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(f3)));
 4697     pixmap = gdk_pixmap_create_from_xpm_d(f3->window,
 4698                 &mask, &style->bg[GTK_STATE_NORMAL],(gchar **)masterdel_xpm);
 4699     delpixmap = gtk_image_new_from_pixmap(pixmap, mask);
 4700     gtk_container_add(GTK_CONTAINER(align), delpixmap);
 4701     gtk_widget_show(delpixmap);
 4702 
 4703     /* and let us receive drags */
 4704     gtk_widget_realize(event_box);
 4705         if(!GTK_WIDGET_NO_WINDOW(event_box)) {
 4706                 gtk_drag_dest_set(event_box, GTK_DEST_DEFAULT_MOTION |
 4707                   GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
 4708                   target_entry, sizeof(target_entry) / sizeof(GtkTargetEntry),
 4709                   GDK_ACTION_MOVE | GDK_ACTION_COPY);
 4710 
 4711                 gtk_signal_connect(GTK_OBJECT(event_box), "drag_data_received",
 4712                     GTK_SIGNAL_FUNC(masterdirs_drag_received), 
 4713             GINT_TO_POINTER(0));
 4714         }
 4715 
 4716     define_tooltip(event_box, _("Drag files or directories on this field when you want them to be excluded from the generated ISO9660 image."));
 4717 
 4718 
 4719         tbl = gtk_table_new(1,8,TRUE);
 4720         gtk_table_set_col_spacings(GTK_TABLE(tbl),10);
 4721         gtk_table_set_row_spacings(GTK_TABLE(tbl),3);
 4722         gtk_box_pack_start(GTK_BOX(vbox),tbl,FALSE,FALSE,5);
 4723         gtk_widget_show(tbl);
 4724 
 4725         l1 = rightjust_gtk_label_new(_("Used/Available:"));
 4726         gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,4,0,1);
 4727         gtk_widget_show(l1);
 4728 
 4729         e1 = gtk_entry_new();
 4730         master_avail_entry = e1;
 4731         gtk_entry_set_editable(GTK_ENTRY(e1),FALSE);
 4732         gtk_table_attach_defaults(GTK_TABLE(tbl),e1,4,8,0,1);
 4733         gtk_widget_show(e1);
 4734     define_tooltip(e1, _("The space already used on the Disc by old sessions and the still available space."));
 4735 
 4736     /* buttons at bottom */
 4737         hbox = gtk_hbox_new(TRUE,10);
 4738         gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,TRUE,5);
 4739         gtk_widget_show(hbox);
 4740         b1 = gtk_button_new_with_label(_("Remove"));
 4741         gtk_signal_connect(GTK_OBJECT(b1), "clicked",
 4742                 GTK_SIGNAL_FUNC(remove_master_dir), NULL);
 4743 
 4744         gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,3);
 4745         gtk_widget_show(b1);
 4746     define_tooltip(b1, _("Removes the currently selected master directories."));
 4747 
 4748     gtk_signal_connect_object(GTK_OBJECT(cdlist), "key_press_event",
 4749         (GtkSignalFunc) mstr_press_event, GTK_OBJECT(b1));
 4750 
 4751         b1 = gtk_button_new_with_label(_("Redirect"));
 4752         gtk_signal_connect(GTK_OBJECT(b1), "clicked",
 4753                 GTK_SIGNAL_FUNC(redirect_master_dir), NULL);
 4754         gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,3);
 4755         gtk_widget_show(b1);
 4756     define_tooltip(b1, _("Redirect the currently selected master directory to another virtual location on the Disc, without changing anything in the source data."));
 4757 
 4758         hbox = gtk_hbox_new(TRUE,0);
 4759         gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,TRUE,0);
 4760         gtk_widget_show(hbox);
 4761         b1 = gtk_button_new_with_label(_("Update Session view"));
 4762         gtk_signal_connect(GTK_OBJECT(b1), "clicked",
 4763                 GTK_SIGNAL_FUNC(session_view_update), NULL);
 4764         gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,3);
 4765         gtk_widget_show(b1);
 4766     define_tooltip(b1, _("Rechecks the inserted Disc for session information. (Useful when you just changed the Disc.)"));
 4767 
 4768         /* right info frame */
 4769         vbox = gtk_vbox_new(FALSE,0);
 4770         gtk_container_add(GTK_CONTAINER(f2),vbox);
 4771         gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
 4772         gtk_widget_show(vbox);
 4773 
 4774         scrolled_win = gtk_scrolled_window_new (NULL, NULL);
 4775         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
 4776                 GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
 4777         gtk_box_pack_start(GTK_BOX(vbox),scrolled_win,TRUE,TRUE,0);
 4778     gtk_widget_realize(scrolled_win);
 4779         gtk_widget_show(scrolled_win);
 4780 
 4781         entry1 = gtk_entry_new();
 4782         gtk_entry_set_max_length(GTK_ENTRY(entry1), MAXENTRY);
 4783         gtk_signal_connect(GTK_OBJECT(entry1), "activate",
 4784                 GTK_SIGNAL_FUNC(entry_masterdir_callback),NULL);
 4785         gtk_box_pack_start(GTK_BOX(vbox),entry1,FALSE,FALSE,3);
 4786         gtk_widget_show(entry1);
 4787         gtk_drag_dest_set(entry1, GTK_DEST_DEFAULT_MOTION |
 4788                 GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
 4789                 target_entry, sizeof(target_entry) / sizeof(GtkTargetEntry),
 4790                 GDK_ACTION_MOVE | GDK_ACTION_COPY);
 4791         gtk_signal_connect(GTK_OBJECT(entry1), "drag_data_received",
 4792                 GTK_SIGNAL_FUNC(entry_masterdir_drag_received), 
 4793         GTK_ENTRY(entry1));
 4794 
 4795     /* special case, use homedir as filetree base? */
 4796     if (strcmp(FILETREEBASE,"$HOME") == 0) {
 4797         p = get_pw_home((gint)geteuid());
 4798         if (p) {
 4799             strncpy(base_tree, p, MAXLINE);
 4800         } else {
 4801             /* fallback in case user got no home dir? */
 4802             strncpy(base_tree, "/tmp", MAXLINE);
 4803         }
 4804     } else {
 4805         strncpy(base_tree, FILETREEBASE, MAXLINE);
 4806     }
 4807 
 4808     ctree_okbutton = NULL;
 4809         ctree = create_directory_ctree(base_tree,NULL,toplevel,entry1, 
 4810             !masterparam.show_only_dirs,
 4811             masterparam.show_hidden_files, 1);
 4812     gtk_clist_set_column_auto_resize(GTK_CLIST(ctree),0,TRUE); 
 4813     gtk_clist_set_selection_mode (GTK_CLIST(ctree), GTK_SELECTION_MULTIPLE);
 4814  
 4815         gtk_container_add (GTK_CONTAINER (scrolled_win), GTK_WIDGET (ctree));
 4816         gtk_widget_show( GTK_WIDGET (ctree));
 4817 
 4818     /* init context menu */
 4819     context_menu2 = gtk_menu_new();
 4820     context_items = gtk_menu_item_new_with_label(
 4821                     _("Unselect all"));
 4822     gtk_menu_append(GTK_MENU(context_menu2), context_items);
 4823     gtk_signal_connect_object (GTK_OBJECT (context_items), 
 4824         "activate", GTK_SIGNAL_FUNC(context_response2),
 4825         GINT_TO_POINTER(0));
 4826     gtk_widget_show(context_items);
 4827 
 4828     gtk_signal_connect_object(GTK_OBJECT(ctree), "button_press_event",
 4829         GTK_SIGNAL_FUNC(activate_context), GTK_OBJECT(context_menu2));
 4830 
 4831         tbl = gtk_table_new(2,8,TRUE);
 4832         gtk_table_set_col_spacings(GTK_TABLE(tbl),10);
 4833         gtk_box_pack_start(GTK_BOX(vbox),tbl,FALSE,FALSE,0);
 4834         gtk_widget_show(tbl);
 4835 
 4836         check = gtk_check_button_new_with_label(_("Display directories only"));
 4837     gtk_signal_connect(GTK_OBJECT(check),"clicked",
 4838                 GTK_SIGNAL_FUNC(dirview_selected), entry1);
 4839         gtk_table_attach_defaults(GTK_TABLE(tbl),check,1,8,0,1);
 4840         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 4841                 masterparam.show_only_dirs);
 4842         gtk_widget_show(check);
 4843     define_tooltip(check, _("Do only show directories in the fileselector above and don't display single files."));
 4844 
 4845         check = gtk_check_button_new_with_label(_("Display hidden files"));
 4846     gtk_signal_connect(GTK_OBJECT(check),"clicked",
 4847                 GTK_SIGNAL_FUNC(hiddenview_selected), entry1);
 4848         gtk_table_attach_defaults(GTK_TABLE(tbl),check,1,8,1,2);
 4849         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 4850                 masterparam.show_hidden_files);
 4851         gtk_widget_show(check);
 4852     define_tooltip(check, _("Show hidden files (files beginning with a dot) in the fileselector above."));
 4853 
 4854     /* buttons at bottom */
 4855         hbox = gtk_hbox_new(TRUE,10);
 4856         gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,TRUE,5);
 4857         gtk_widget_show(hbox);
 4858         b1 = gtk_button_new_with_label(_("Add"));
 4859     gtk_signal_connect(GTK_OBJECT(b1),"clicked",
 4860                 GTK_SIGNAL_FUNC(add_master_dir), entry1);
 4861         gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,3);
 4862         gtk_widget_show(b1);
 4863     define_tooltip(b1, _("Add the selected path to the master directories."));
 4864 
 4865         b1 = gtk_button_new_with_label(_("Exclude"));
 4866     gtk_signal_connect(GTK_OBJECT(b1),"clicked",
 4867                 GTK_SIGNAL_FUNC(exclude_master_dir), entry1);
 4868         gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,3);
 4869         gtk_widget_show(b1);
 4870     g_snprintf(tmp,MAXLINE,"%s %s",_("Exclude the selected path from the master directories, which means that all data in that path will not be included in the image."), _("Or enter a shell wild-card-style pattern that matches a part of a filename to exclude. For example '*.o' and 'core' will exclude all files ending in '.o' or called 'core' from being mastered to Disc. (Enter without quotes)"));
 4871     define_tooltip(b1, tmp);    /* concatenated text */
 4872 
 4873     /* by default go to home dir of user in dir browser */
 4874     if (g_get_home_dir()) {
 4875         gtk_entry_set_text(GTK_ENTRY(entry1), g_get_home_dir());
 4876         ctree_expand_manualpath(entry1, NULL);
 4877         ctree_unselect_all();
 4878     }
 4879 
 4880     /* update session-view */
 4881     session_view_update(NULL,NULL);
 4882 }
 4883 
 4884 
 4885 /*
 4886  * redraw the option-grid
 4887  */
 4888 static void draw_option_grid(gint val) {
 4889 gint i;
 4890 gint types[][24] = MASTER_TYPES;
 4891 
 4892     if (val == -1) {
 4893         /* custom setting? */
 4894         return;
 4895     }
 4896 
 4897     /*
 4898      * only draw the ones visiable
 4899      * in normal (not adv.) dialog
 4900      */
 4901     for(i = 0; i < 24; i++) {
 4902         switch(i) {
 4903           case 0:
 4904           case 1:
 4905           case 2:
 4906           case 3:
 4907           case 4:
 4908           case 5:
 4909           case 6:
 4910           case 7:
 4911           case 10:
 4912           case 11:
 4913           case 13:
 4914           case 16:
 4915                 gtk_toggle_button_set_active(
 4916                 GTK_TOGGLE_BUTTON(isoopts[i]), types[val][i]);
 4917             break;
 4918           default:
 4919             /* set the non-visible too */
 4920             masterparam.opt[i] = types[val][i];
 4921             break;
 4922         }
 4923     }           
 4924 
 4925     /* set joilet charset */
 4926     gtk_option_menu_set_history(GTK_OPTION_MENU(isoopt_cmenu), 
 4927         masterparam.charset);
 4928         if (masterparam.cust_charset != NULL) {
 4929         gtk_entry_set_text(GTK_ENTRY(isoopt_centry),
 4930             masterparam.cust_charset);
 4931     }
 4932     if (strcmp(charset_types[masterparam.charset],"custom"