"Fossies" - the Fresh Open Source Software Archive

Member "xcdroast-1.19/src/setup.c" (9 Nov 2018, 119501 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 "setup.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  *  setup.c
    3  *  28.3.99 tn@xcdroast.org
    4  *
    5  *
    6  *  Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
    7  *
    8  *  This file is part of xcdroast.
    9  *
   10  *  This program is free software; you can redistribute it and/or modify
   11  *  it under the terms of the GNU General Public License as published by
   12  *  the Free Software Foundation; either version 2 of the License, or
   13  *  (at your option) any later version.
   14  *
   15  *  This program is distributed in the hope that it will be useful,
   16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18  *  GNU General Public License for more details.
   19  *
   20  *  You should have received a copy of the GNU General Public License
   21  *  along with this program; if not, write to the Free Software
   22  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   23  */
   24 
   25 #ifdef HAVE_CONFIG_H
   26 # include <config.h>
   27 #endif
   28 
   29 #include "largefile.h"
   30 
   31 #include <locale.h>
   32 #include "gettext.h"
   33 
   34 #include <stdio.h>
   35 #include <stdlib.h>
   36 #include <string.h>
   37 #include <sys/types.h>
   38 #include <sys/stat.h>
   39 
   40 
   41 #if ENABLE_NLS
   42 # define _(String) gettext (String)
   43 # define N_(String) gettext_noop (String)
   44 #else
   45 # define _(String) (String)
   46 # define N_(String) (String)
   47 #endif
   48 #define GTK_ENABLE_BROKEN
   49 
   50 #include <gtk/gtk.h>
   51 #include <gdk/gdk.h>
   52 #include "xcdrdata.h"
   53 #include "xcdroast.h"
   54 #include "main.h"
   55 #include "language.h"
   56 #include "../xpms/ico_cdrom.xpm"
   57 #include "../xpms/ico_cdwriter.xpm"
   58 #include "../xpms/ico_dvdrom.xpm"
   59 #include "../xpms/ico_dvdwriter.xpm"
   60 
   61 extern GtkWidget *toplevel;
   62 extern GtkWidget *sidespace;
   63 extern GtkWidget *workspace;
   64 extern writerreader_devices_t **writerreaderdevs;
   65 extern writer_driver_t **drivers;
   66 extern gchar *language;
   67 extern setup_data_t setupdata;
   68 extern current_set_t curset;
   69 extern gchar configdir[MAXLINE];
   70 extern gchar rootconfig[MAXLINE];
   71 extern gchar xcdroast_version_loaded[MAXLINE];
   72 extern gchar sharedir[MAXLINE];
   73 extern gint altdevscan;
   74 extern img_logo_t img;
   75 
   76 
   77 static setup_data_t bak_setupdata;
   78 static writerreader_bak_t **bak_writerreader;
   79 static GtkCList *clist_list, *dev_scan_clist;
   80 #if (USER_HOST_MODE == 1)
   81 static GtkTreeView *users_clist, *hosts_clist;
   82 static GtkWidget *rootusers_entry, *roothosts_entry;
   83 #endif
   84 static GtkWidget *clist_entry, *updatesum_label, *updatebutton;
   85 static GtkWidget *cddb_entry1, *cddb_entry2, *log_entry;
   86 static GtkWidget *cddb_entry3, *cddb_entry4, *cddb_opt1, *cddb_opt2;
   87 static GtkWidget *btn_testdsp, *readslider1, *readslider2, *readslider3, *readslider4, *readspd1, *readspd2, *readspd3, *readspd4;
   88 static GtkWidget *cdr_drv_omenu, *cdr_mode_omenu, *rdr_para_check, *rdr_htoa_check;
   89 static GtkObject *cdr_spd_adj, *cdr_fifo_adj;
   90 static GtkWidget *writer_frame, *reader_frame;
   91 static GtkObject *rdr_spd_adj, *rdr_ovrl_adj, *rdr_pararahd_adj, *rdr_paraovrl_adj, *rdr_pararetr;
   92 static GtkWidget *writer_omenu, *reader_omenu;
   93 static gint nrs_dialog_done;
   94 static GtkWidget *nrs_dialog;
   95 
   96 static void draw_scsi_scan_devs(GtkCList *clist);
   97 static gint draw_cd_setup_writers(GtkWidget *menu, gint *firstdevnr); 
   98 static gint draw_cd_setup_readers(GtkWidget *menu, gint *firstdevnr); 
   99 static void writer_selected(GtkWidget *item, gpointer devnr);
  100 static void reader_selected(GtkWidget *item, gpointer devnr); 
  101 #if (USER_HOST_MODE == 1)
  102 static void get_entries_from_list(GtkTreeView *clist, GList **outlist);
  103 #endif
  104 
  105  
  106 /*
  107  * main functions of the setup-menu
  108  * called by cancel-button
  109  */
  110 static void menu_setup_cancel(GtkWidget *widget, gpointer data) {
  111 gint i,j;
  112 
  113     dodebug(8, "canceling setup\n");
  114     dolog(2, "Cancel setup\n");
  115  
  116     /* restore the saved data - therefore deletes all changes */
  117     free_glist(&setupdata.image_dirs);
  118     memcpy(&setupdata,&bak_setupdata,sizeof(setup_data_t));
  119     setupdata.image_dirs = NULL;
  120     copy_glist(&setupdata.image_dirs, bak_setupdata.image_dirs);
  121     free_glist(&bak_setupdata.image_dirs);
  122 
  123 #if (USER_HOST_MODE == 1)
  124     if (isroot()) {
  125         setupdata.root_users_lists = NULL;
  126         setupdata.root_hosts_lists = NULL;
  127         free_glist(&setupdata.root_users_lists);
  128         free_glist(&setupdata.root_hosts_lists);
  129         copy_glist(&setupdata.root_users_lists, bak_setupdata.root_users_lists);
  130         free_glist(&bak_setupdata.root_users_lists);
  131         copy_glist(&setupdata.root_hosts_lists, bak_setupdata.root_hosts_lists);
  132         free_glist(&bak_setupdata.root_hosts_lists);
  133     }
  134 #endif
  135 
  136     setupdata.dsp_device = g_strdup(bak_setupdata.dsp_device);
  137     g_free(bak_setupdata.dsp_device);
  138     setupdata.mix_device = g_strdup(bak_setupdata.mix_device);
  139     g_free(bak_setupdata.mix_device);
  140     setupdata.cddb_host = g_strdup(bak_setupdata.cddb_host);
  141     g_free(bak_setupdata.cddb_host);
  142     setupdata.cddb_proxy_host = g_strdup(bak_setupdata.cddb_proxy_host);
  143     g_free(bak_setupdata.cddb_proxy_host);
  144     setupdata.logfile = g_strdup(bak_setupdata.logfile);
  145     g_free(bak_setupdata.logfile);
  146 
  147     /* restore and free also writerreader structure copy */
  148     if (bak_writerreader) {
  149         i = 0;
  150         while(bak_writerreader[i] != NULL) {
  151             /* get matching device for our saved data */
  152             j = get_writerreaderdevs_index(bak_writerreader[i]->devnr);
  153             /* device still valid? */
  154             if (j >= 0) {
  155                 /* revert any possible changed values */
  156                 writerreaderdevs[j]->writer_drvmode = bak_writerreader[i]->values[0];
  157                 writerreaderdevs[j]->writer_mode = bak_writerreader[i]->values[1];
  158                 writerreaderdevs[j]->writer_speed = bak_writerreader[i]->values[2];
  159                 writerreaderdevs[j]->writer_fifo = bak_writerreader[i]->values[3];
  160                 writerreaderdevs[j]->audioread_speed = bak_writerreader[i]->values[4];
  161                 writerreaderdevs[j]->audioread_overlap = bak_writerreader[i]->values[5];
  162                 writerreaderdevs[j]->audioread_paranoiareadahead = bak_writerreader[i]->values[6];
  163                 writerreaderdevs[j]->audioread_paranoiaminoverlap = bak_writerreader[i]->values[7];
  164                 writerreaderdevs[j]->audioread_paranoiaretries = bak_writerreader[i]->values[8];
  165                 writerreaderdevs[j]->audioread_useparanoia = bak_writerreader[i]->values[9];
  166                 writerreaderdevs[j]->audioread_showhiddentrack = bak_writerreader[i]->values[10];
  167             }
  168             g_free(bak_writerreader[i]);
  169             i++;
  170         }
  171         g_free(bak_writerreader);
  172         bak_writerreader = NULL;
  173     } 
  174 
  175  
  176     /* check if cancel and no config file loaded */
  177     if (strcmp(xcdroast_version_loaded, "") == 0) {
  178         /*
  179          * no config file found
  180          * continue to lock duplicate
  181          * and create menu buttons
  182          */
  183             create_main(1);
  184     } else {
  185         create_main(0);
  186     }
  187 }
  188 
  189 
  190 /*
  191  * calculate all setup-data before leaving setup-menu
  192  */
  193 static gint menu_setup_ok_work(GtkWidget *widget, gpointer data) {
  194 gint i;
  195 gchar *rowdata[2];
  196 gchar *locreturn;
  197 gchar tmp[MAXLINE];
  198     dodebug(8, "confirming setup\n");
  199 
  200     /* create glist of image-dirs */
  201     free_glist(&setupdata.image_dirs);
  202     for (i = 0; i < clist_list->rows; i++) {
  203         gtk_clist_get_text(clist_list,i,0,rowdata); 
  204         setupdata.image_dirs = g_list_append(setupdata.image_dirs,
  205             g_strdup(rowdata[0]));
  206     }
  207 
  208     /* no image-dirs? */
  209     if (i == 0) {
  210         show_dialog(ICO_ERROR, _("No image-directories defined. You have to define at\nleast one directory for saving image data in order to continue."), T_CANCEL, NULL, NULL, 0);
  211         return 1;
  212     }
  213 
  214 #if (USER_HOST_MODE == 1)
  215     if (isroot()) {
  216         /* create glist of user-host stuff */
  217         free_glist(&setupdata.root_users_lists);
  218         get_entries_from_list(users_clist, &setupdata.root_users_lists);
  219 
  220         free_glist(&setupdata.root_hosts_lists);
  221         get_entries_from_list(hosts_clist, &setupdata.root_hosts_lists);
  222     }
  223 #endif
  224 
  225     if (strcmp(setupdata.language, "") != 0) {
  226         g_free(language);
  227         language = g_strdup(setupdata.language);
  228         locreturn = setlocale(LC_ALL, language);
  229         if (locreturn == NULL) {
  230             /* locate not supported? */
  231             g_snprintf(tmp,MAXLINE,_("The requested language with the locale\n\"%s\" is not available on this system.\nYour language setting will be ignored."), language);
  232             show_dialog(ICO_WARN, tmp, T_OK, NULL, NULL, 0);
  233         }
  234         setlocale (LC_NUMERIC, "C");
  235         putenv("G_FILENAME_ENCODING=UTF-8");
  236     } else {
  237         /* get language from locale */
  238         setlocale (LC_ALL, "");
  239         setlocale (LC_NUMERIC, "C");
  240     }
  241 
  242     /* now generate mixer-device from dsp-device */
  243     g_free(setupdata.mix_device);
  244     if (setupdata.dsp_device != NULL) {
  245         setupdata.mix_device = g_strdup(
  246             gen_mix_from_dspdev(setupdata.dsp_device,tmp));
  247     }
  248 
  249     /* now get cddb/log-entries */
  250     g_free(setupdata.cddb_host);
  251     strcpy(tmp, gtk_entry_get_text(GTK_ENTRY(cddb_entry1)));
  252     strip_string(tmp);
  253     setupdata.cddb_host = g_strdup(tmp);
  254     if (setupdata.cddb_use_http == 0) {
  255         setupdata.cddb_port = atoi(
  256             gtk_entry_get_text(GTK_ENTRY(cddb_entry2)));
  257     }
  258     g_free(setupdata.cddb_proxy_host);
  259     strcpy(tmp, gtk_entry_get_text(GTK_ENTRY(cddb_entry3)));
  260     strip_string(tmp);
  261     setupdata.cddb_proxy_host = g_strdup(tmp);
  262     setupdata.cddb_proxy_port = atoi(
  263         gtk_entry_get_text(GTK_ENTRY(cddb_entry4)));
  264 
  265     g_free(setupdata.logfile);
  266     strcpy(tmp, gtk_entry_get_text(GTK_ENTRY(log_entry)));
  267     setupdata.logfile = g_strdup(tmp);
  268 
  269     /* save the current window size if we are asked to */
  270     if (setupdata.option_savepos) {
  271         gdk_window_get_root_origin(GTK_WIDGET(toplevel)->window,
  272             &setupdata.mainwindow.x, 
  273             &setupdata.mainwindow.y);
  274                 setupdata.mainwindow.width = gdk_window_get_width(GTK_WIDGET(toplevel)->window);
  275                 setupdata.mainwindow.height = gdk_window_get_height(GTK_WIDGET(toplevel)->window);
  276     }
  277 
  278     return 0;
  279 }
  280 
  281 
  282 /*
  283  * called by ok-button
  284  */
  285 static void menu_setup_ok(GtkWidget *widget, gpointer data) {
  286 gint i, ret;
  287 gchar tmp[MAXLINE];
  288 
  289     /* some lasts checks and warnings */
  290     dolog(2, "Confirm setup\n");
  291 
  292     /* get the writer device string */
  293     if (convert_devnr2busid(setupdata.writer_devnr, tmp) == 0) {
  294 
  295         /* ATAPI device? (only on linux) */
  296         if (strstr(tmp, "ATAPI")) {
  297             ret = show_dialog(ICO_WARN, _("You have selected an ATAPI device as your CD-Writer.\nThis is not a recommended setup - you will experience\nlong delays within X-CD-Roast and bad writing performance.\nSee the FAQ how to properly install scsi-emulation for best results."), T_OK,T_CANCEL, NULL, 0);
  298             if (ret == 1) {
  299                 /* abort */
  300                 return;
  301             }
  302         }
  303     }       
  304 
  305     if (menu_setup_ok_work(widget,data)) 
  306         return;
  307 
  308     /* free memory of backup-config */
  309     g_free(bak_setupdata.logfile);
  310     g_free(bak_setupdata.cddb_host);
  311     g_free(bak_setupdata.cddb_proxy_host);
  312     g_free(bak_setupdata.dsp_device);
  313     g_free(bak_setupdata.mix_device);
  314     free_glist(&bak_setupdata.image_dirs);
  315 #if (USER_HOST_MODE == 1)
  316     if (isroot()) {
  317         free_glist(&bak_setupdata.root_users_lists);
  318         free_glist(&bak_setupdata.root_hosts_lists);
  319     }
  320 #endif
  321 
  322     /* free also writerreader structure copy */
  323     if (bak_writerreader) {
  324         i = 0;
  325         while(bak_writerreader[i] != NULL) {
  326             g_free(bak_writerreader[i]);
  327             i++;
  328         }
  329         g_free(bak_writerreader);
  330         bak_writerreader = NULL;
  331     } 
  332     
  333     strcpy(xcdroast_version_loaded, XCDROAST_VERSION);
  334 
  335         create_main(0);
  336 }
  337 
  338 
  339 /*
  340  * called by save button
  341  */
  342 static void menu_setup_save(GtkWidget *widget, gpointer data) {
  343 gchar tmp2[MAXLINE];
  344 gint stat;
  345 
  346     if (menu_setup_ok_work(widget,data))
  347         return;
  348 
  349     dolog(2, "Save setup configuration\n");
  350 
  351 #if (USER_HOST_MODE == 1)
  352     if (isroot()) {
  353         /* save special root config */
  354         stat = save_setup_config("", rootconfig);   
  355 
  356         /* make sure this config got the right permissions */
  357         chmod(rootconfig, 0644);
  358     } else {
  359 #endif
  360         stat = save_setup_config(configdir, CONFFILE);
  361 
  362 #if (USER_HOST_MODE == 1)
  363     }
  364 #endif
  365 
  366     /* write config file */
  367     if (stat == 1) {
  368         /* save failed */
  369         g_snprintf(tmp2,MAXLINE,_("Failed to save configuration file: %s"), CONFFILE);
  370         show_dialog(ICO_WARN, tmp2, T_OK, NULL, NULL, 0);
  371     } else {
  372         /* save ok */
  373         show_dialog(ICO_INFO,_("Configuration saved"), T_OK, NULL, NULL, 0);
  374     }
  375 }
  376 
  377 
  378 /*
  379  * click on device-list
  380  */
  381 static void device_select_row(GtkWidget *clist, gint row, gint col,
  382                      GdkEventButton *event, gpointer data) {
  383 
  384     /* double click? */
  385     if (event && event->type == GDK_2BUTTON_PRESS) {
  386         show_device_detail(writerreaderdevs[row]->devnr);
  387     }   
  388 }
  389 
  390 
  391 /*
  392  * redraw the device scan glist and the writer/reader lists in setup
  393  * after new devices are scanned
  394  */
  395 static void redraw_writerreader_menus() {
  396 gint firstdevnr;
  397 GtkWidget *menu;
  398 
  399     /* redraw menus */
  400     if (dev_scan_clist) {
  401         gtk_clist_clear(dev_scan_clist);
  402         draw_scsi_scan_devs(dev_scan_clist);
  403     }
  404     if (writer_omenu) {
  405         /* replace current writer list by updated one */
  406         gtk_option_menu_remove_menu(GTK_OPTION_MENU(writer_omenu));
  407         menu = gtk_menu_new();
  408         draw_cd_setup_writers(menu, &firstdevnr);
  409         gtk_option_menu_set_menu(GTK_OPTION_MENU(writer_omenu), menu);
  410 
  411         setupdata.writer_devnr = firstdevnr;
  412 
  413         /* and update corresponding displayed writer data */
  414         writer_selected(NULL, GINT_TO_POINTER(setupdata.writer_devnr));
  415     }
  416     if (reader_omenu) {
  417         /* replace current reader list by updated one */
  418         gtk_option_menu_remove_menu(GTK_OPTION_MENU(reader_omenu));
  419         menu = gtk_menu_new();
  420         draw_cd_setup_readers(menu, &firstdevnr);
  421         gtk_option_menu_set_menu(GTK_OPTION_MENU(reader_omenu), menu);
  422 
  423         setupdata.reader_devnr = firstdevnr;
  424 
  425         /* and update corresponding displayed reader data */
  426         reader_selected(NULL, GINT_TO_POINTER(setupdata.reader_devnr));
  427     }
  428 }
  429 
  430 
  431 static void rescan_clicked(GtkWidget *widget, gpointer altdevscan) {
  432 gint ret;
  433 
  434     ret = show_dialog(ICO_WARN,_("Are you sure you want to rescan for devices?\nThis will remove all manually configured devices and all\nsaved configuration data for the other devices."), 
  435         T_OK,T_CANCEL,NULL,1);
  436 
  437     if (ret == 1) {
  438         /* abort */
  439         return;
  440     }
  441 
  442     /* remove all device information */
  443     free_writerreader_data();
  444 
  445     /* scan */
  446     create_device_scanning(GPOINTER_TO_INT(altdevscan), 0, 0,  NULL); 
  447 
  448     redraw_writerreader_menus();
  449 }
  450 
  451 
  452 static void manual_add_clicked(GtkWidget *widget, gpointer data) {
  453 gint ret, i, found;
  454 gchar tmp[MAXLINE];
  455 
  456     ret = show_add_manual_device(tmp);
  457     if (ret != 0) {
  458         /* cancel */
  459         return;
  460     }
  461 
  462     strip_string(tmp);
  463 
  464     if (strlen(tmp) == 0) {
  465         show_dialog(ICO_ERROR,_("Invalid device specification."), T_OK, NULL, NULL, 0);
  466                 return;
  467     }
  468 
  469     /* special case REMOTE and trailing colon */
  470     if (strstr(tmp,"REMOTE")) {
  471         if (tmp[strlen(tmp)-1] == ':') {
  472             /* strip off last colon */
  473             tmp[strlen(tmp)-1] = '\0';
  474         }
  475     }
  476 
  477     /* check if such a device is already added */
  478     i = 0; found = 0;
  479     while(writerreaderdevs[i] != NULL) {
  480         if (strcmp(writerreaderdevs[i]->devicestr,tmp) == 0) {
  481             found = 1;
  482             break;
  483         }
  484         i++;
  485     }
  486     if (found) {
  487         show_dialog(ICO_ERROR,_("Device already existing."), T_OK, NULL, NULL, 0);
  488         return;
  489     }
  490 
  491     /* scan that single device and add to writerreader list */
  492     create_device_scanning(0, 1, 0, tmp);
  493     
  494     /* redraw menus if new device was found */  
  495     redraw_writerreader_menus();
  496 }
  497 
  498 
  499 /*
  500  * remove a single device from the device list
  501  */
  502 static void remove_single_device(gint devnr) {
  503 gint ret;
  504 gchar tmp[MAXLINE], tmp2[MAXLINE];
  505 
  506     convert_devnr2devstring(devnr, tmp);
  507     g_snprintf(tmp2, MAXLINE, _("Are you sure you want to remove the device\n%s\nfrom this configuration?"), tmp);
  508 
  509     ret = show_dialog(ICO_WARN, tmp2, T_YES,T_NO, NULL, 0);
  510     if (ret == 1) {
  511         /* abort */
  512         return;
  513     }
  514 
  515     /* remove device */
  516     remove_from_writerreader_data(devnr);
  517 
  518     /* redraw menus if new device was found */  
  519     redraw_writerreader_menus();
  520 }
  521 
  522 
  523 /*
  524  * an item was selected on the popup menu
  525  */
  526 static void scan_context_response(gint selected) {
  527 GList *sel;
  528 gint row;
  529 
  530     sel = dev_scan_clist->selection;
  531     if (sel) {
  532         row = GPOINTER_TO_INT(sel->data);
  533         switch (selected) {
  534 
  535         case 0:
  536             show_device_detail(writerreaderdevs[row]->devnr);
  537             break;
  538         
  539         case 1:
  540             remove_single_device(writerreaderdevs[row]->devnr);
  541             break;
  542         default:
  543             break;
  544         }
  545     }
  546 }
  547 
  548 
  549 static gint scan_activate_context(GtkWidget *widget, GdkEvent *event) {
  550 gint click_x, click_y, row, col;
  551 GtkCList *clist;
  552 
  553     /* find out which row was clicked */
  554     clist = dev_scan_clist; 
  555     click_x = (gint)event->button.x;
  556     click_y = (gint)event->button.y;
  557 
  558         if (!gtk_clist_get_selection_info(
  559                 clist, click_x, click_y, &row, &col)) {
  560                 row = -1;
  561                 col = 0;
  562         }
  563 
  564         if (event->button.button == 3) {
  565         /* right button press? select row now */
  566         if (row >= 0) 
  567             gtk_clist_select_row(clist, row, 0);
  568 
  569                 /* show context menu */
  570                 gtk_menu_popup(GTK_MENU(widget), NULL, NULL, 
  571                         NULL, NULL, event->button.button, event->button.time);
  572                 return TRUE;
  573         }
  574         return FALSE;
  575 }
  576 
  577 
  578 static void draw_scsi_scan_devs(GtkCList *clist) {
  579 gint count;
  580 GdkPixmap *pixmap;
  581 GdkBitmap *mask;
  582 gchar **xpm;
  583 gchar *data[5];
  584 gchar tmp[MAXLINE];
  585 GtkStyle *style;
  586 
  587     style = gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(clist)));
  588     count = 0;
  589     while(writerreaderdevs[count] != NULL) {
  590 
  591         g_snprintf(tmp,MAXLINE,"[%s]",
  592             writerreaderdevs[count]->devicestr);
  593 
  594         data[0] = NULL;
  595         data[1] = tmp;
  596         data[2] = writerreaderdevs[count]->vendor;
  597         data[3] = writerreaderdevs[count]->model;
  598         data[4] = writerreaderdevs[count]->rev;
  599         gtk_clist_append(clist,data);
  600 
  601         xpm = ico_cdrom_xpm;
  602         if (writerreaderdevs[count]->is_dvdreader) {
  603             xpm = ico_dvdrom_xpm;
  604         }
  605         if (writerreaderdevs[count]->is_cdrwriter) {
  606             xpm = ico_cdwriter_xpm;
  607         }
  608         if (writerreaderdevs[count]->is_dvdwriter) {
  609             xpm = ico_dvdwriter_xpm;
  610         }
  611 
  612         pixmap = gdk_pixmap_create_from_xpm_d(clist->clist_window, 
  613             &mask, &style->bg[GTK_STATE_NORMAL],(gchar **)xpm);
  614         gtk_clist_set_pixmap(clist,count,0,pixmap,mask);
  615         
  616         count++;
  617     }
  618 }
  619 
  620 
  621 /*
  622  * draw scsi-scan screen
  623  */
  624 static void draw_scsi_scan(GtkWidget *win) {
  625 gchar *titles[5];
  626 GtkWidget *list, *vbox, *l1, *box2, *b1, *b2;
  627 GtkCList *clist;
  628 GtkWidget *scrolled_win;
  629 GtkWidget *context_menu, *context_items;
  630 
  631     dev_scan_clist = NULL;  
  632 
  633         vbox = gtk_vbox_new(FALSE,0);
  634         gtk_container_add(GTK_CONTAINER(win),vbox);
  635         gtk_widget_show(vbox);
  636 
  637     scrolled_win = gtk_scrolled_window_new (NULL, NULL);
  638     gtk_container_set_border_width (GTK_CONTAINER (scrolled_win), 5);
  639     gtk_box_pack_start(GTK_BOX(vbox),scrolled_win, TRUE, TRUE, 0);
  640     gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
  641         GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
  642 
  643     titles[0] = _("Type");
  644     titles[1] = _("Device-Id");
  645     titles[2] = _("Vendor");
  646     titles[3] = _("Model");
  647     titles[4] = _("Rev.");
  648 
  649     list = gtk_clist_new_with_titles(5,titles);
  650     gtk_container_add (GTK_CONTAINER (scrolled_win), list);
  651     gtk_widget_realize(list);
  652 
  653     context_menu = gtk_menu_new();
  654     context_items = gtk_menu_item_new_with_label(_("Show details..."));
  655     gtk_menu_append(GTK_MENU(context_menu), context_items);
  656     g_signal_connect_swapped (context_items, 
  657                         "activate", G_CALLBACK(scan_context_response),
  658             GINT_TO_POINTER(0));
  659     gtk_widget_show(context_items);
  660     context_items = gtk_menu_item_new_with_label(_("Remove device"));
  661     gtk_menu_append(GTK_MENU(context_menu), context_items);
  662     g_signal_connect_swapped (context_items, 
  663                         "activate", G_CALLBACK(scan_context_response),
  664             GINT_TO_POINTER(1));
  665     gtk_widget_show(context_items);
  666 
  667     if (!isroot() && !(setupdata.root_option_change_writer &&
  668         setupdata.root_option_change_reader)) {
  669         gtk_widget_set_sensitive(context_items, FALSE);
  670     }
  671 
  672 
  673     clist = GTK_CLIST(list);
  674     dev_scan_clist = clist;
  675     gtk_clist_set_column_auto_resize(clist, 5, TRUE);
  676 
  677         g_signal_connect_swapped(clist, "button_press_event",
  678             G_CALLBACK(scan_activate_context), GTK_OBJECT(context_menu));
  679 
  680     gtk_clist_set_row_height(clist, 48);
  681     gtk_clist_set_column_width(clist, 0, 48);
  682     gtk_clist_set_column_justification(clist, 0, GTK_JUSTIFY_CENTER);
  683     gtk_clist_set_column_width(clist, 1, tbf(220));
  684     gtk_clist_set_column_justification(clist, 1, GTK_JUSTIFY_CENTER);
  685     gtk_clist_set_column_width(clist, 2, tbf(70));
  686     gtk_clist_set_column_width(clist, 3, tbf(140));
  687     gtk_clist_set_column_width(clist, 4, tbf(35));
  688     g_signal_connect(clist, "select_row",
  689         G_CALLBACK(device_select_row), NULL);
  690     
  691     draw_scsi_scan_devs(clist);
  692 
  693     gtk_widget_show(list);
  694     gtk_widget_show(scrolled_win);
  695 
  696     box2 = gtk_hbox_new(FALSE,0);
  697         gtk_box_pack_start(GTK_BOX(vbox),box2,FALSE,TRUE,5);
  698     b1 = gtk_button_new_with_label(_("Rescan devices"));
  699         g_signal_connect(b1,"clicked",
  700                 G_CALLBACK(rescan_clicked), GINT_TO_POINTER(altdevscan));
  701     gtk_box_pack_start(GTK_BOX(box2),b1,TRUE,TRUE,10);
  702     gtk_widget_show(b1);
  703     define_tooltip(b1,_("Removes the currently configured devices and scans for them again. Useful when you changed something in your hardware configuration."));
  704 
  705     if (!isroot() && !(setupdata.root_option_change_writer &&
  706         setupdata.root_option_change_reader)) {
  707         gtk_widget_set_sensitive(b1, FALSE);
  708     }
  709 
  710     b2 = gtk_button_new_with_label(_("Manually add device"));
  711         g_signal_connect(b2,"clicked",
  712                 G_CALLBACK(manual_add_clicked),NULL);
  713     gtk_box_pack_start(GTK_BOX(box2),b2,TRUE,TRUE,10);
  714     gtk_widget_show(b2);
  715     define_tooltip(b2,_("Add a device that wasn't recognized by the automatic scanning."));
  716 
  717     gtk_widget_show(box2);
  718 
  719     if (!isroot() && !(setupdata.root_option_change_writer &&
  720         setupdata.root_option_change_reader)) {
  721         gtk_widget_set_sensitive(b2, FALSE);
  722     }
  723 
  724     l1 = gtk_label_new(_("Please see http://www.xcdroast.org/faq when you miss a drive this list."));
  725     gtk_box_pack_start(GTK_BOX(vbox),l1, FALSE, TRUE, 0);
  726     gtk_widget_show(l1);
  727 }
  728 
  729 
  730 /*
  731  * all the callbacks for the disc setup: "CD/DVD/BD Settings"
  732  */
  733 static void speed_changed(GtkAdjustment *adj, GtkWidget *label) {
  734 gchar tmp[MAXLINE];
  735 gint i;
  736 
  737     i = get_writerreaderdevs_index(setupdata.writer_devnr);
  738 
  739     g_snprintf(tmp, MAXLINE,"%dx",(gint)adj->value);
  740     gtk_label_set_text(GTK_LABEL(label),tmp);
  741     if (!isroot() && !setupdata.root_option_change_writeparam) {
  742         set_labelcolor(label,DISABLEDCOLOR);
  743     }
  744     writerreaderdevs[i]->writer_speed = (gint)adj->value;
  745 }
  746 
  747 static void fifo_changed(GtkAdjustment *adj, GtkWidget *label) {
  748 gchar tmp[MAXLINE];
  749 gint i;
  750 
  751     i = get_writerreaderdevs_index(setupdata.writer_devnr);
  752 
  753     g_snprintf(tmp, MAXLINE,"%d MiB",(gint)(adj->value) * 2);
  754     gtk_label_set_text(GTK_LABEL(label),tmp);
  755     if (!isroot() && !setupdata.root_option_change_writeparam) {
  756         set_labelcolor(label,DISABLEDCOLOR);
  757     }
  758     writerreaderdevs[i]->writer_fifo = (gint)(adj->value) * 2;
  759 }
  760 
  761 static void audio_speed_changed(GtkAdjustment *adj, GtkWidget *label) {
  762 gchar tmp[MAXLINE];
  763 gint i;
  764 
  765     i = get_writerreaderdevs_index(setupdata.reader_devnr);
  766 
  767     g_snprintf(tmp, MAXLINE,"%dx",(gint)adj->value);
  768     gtk_label_set_text(GTK_LABEL(label),tmp);
  769     if (!isroot() && !setupdata.root_option_change_readparam) {
  770         set_labelcolor(label,DISABLEDCOLOR);
  771     }   
  772     writerreaderdevs[i]->audioread_speed = (gint)adj->value;
  773 }
  774 
  775 static void sectors_changed(GtkAdjustment *adj, GtkWidget *label) {
  776 gchar tmp[MAXLINE];
  777 gint i;
  778 
  779     i = get_writerreaderdevs_index(setupdata.reader_devnr);
  780 
  781     g_snprintf(tmp, MAXLINE,"%d",(gint)adj->value);
  782     gtk_label_set_text(GTK_LABEL(label),tmp);
  783     if (!isroot() && !setupdata.root_option_change_readparam) {
  784         set_labelcolor(label,DISABLEDCOLOR);
  785     }   
  786     writerreaderdevs[i]->audioread_overlap = (gint)adj->value;
  787 }
  788 
  789 static void sectors2_changed(GtkAdjustment *adj, GtkWidget *label) {
  790 gchar tmp[MAXLINE];
  791 gint i;
  792 
  793     i = get_writerreaderdevs_index(setupdata.reader_devnr);
  794 
  795     g_snprintf(tmp, MAXLINE,"%d",(gint)(adj->value) * 100);
  796     gtk_label_set_text(GTK_LABEL(label),tmp);
  797     if (!isroot() && !setupdata.root_option_change_readparam) {
  798         set_labelcolor(label,DISABLEDCOLOR);
  799     }   
  800     writerreaderdevs[i]->audioread_paranoiareadahead = (gint)(adj->value) * 100;
  801 }
  802 
  803 static void sectors3_changed(GtkAdjustment *adj, GtkWidget *label) {
  804 gchar tmp[MAXLINE];
  805 gint i;
  806 
  807     i = get_writerreaderdevs_index(setupdata.reader_devnr);
  808 
  809     g_snprintf(tmp, MAXLINE,"%d",(gint)adj->value);
  810     gtk_label_set_text(GTK_LABEL(label),tmp);
  811     if (!isroot() && !setupdata.root_option_change_readparam) {
  812         set_labelcolor(label,DISABLEDCOLOR);
  813     }   
  814     writerreaderdevs[i]->audioread_paranoiaminoverlap = (gint)adj->value;
  815 }
  816 
  817 static void sectors4_changed(GtkAdjustment *adj, GtkWidget *label) {
  818 gchar tmp[MAXLINE];
  819 gint i;
  820 
  821     i = get_writerreaderdevs_index(setupdata.reader_devnr);
  822 
  823     g_snprintf(tmp, MAXLINE,"%d",(gint)(adj->value) * 5);
  824     gtk_label_set_text(GTK_LABEL(label),tmp);
  825     if (!isroot() && !setupdata.root_option_change_readparam) {
  826         set_labelcolor(label,DISABLEDCOLOR);
  827     }
  828     writerreaderdevs[i]->audioread_paranoiaretries = (gint)(adj->value) * 5;
  829 }
  830 
  831 static void writer_selected(GtkWidget *item, gpointer devnr) {
  832 gint i,j;
  833 GtkMenuShell *menu_shell;
  834 GtkWidget *menuitem;
  835 GList *loop;
  836 
  837     setupdata.writer_devnr = GPOINTER_TO_INT(devnr);
  838 
  839     /* i is the index in our writerreaderdevs structure */
  840     i = get_writerreaderdevs_index(setupdata.writer_devnr);
  841 
  842     /* no device? lock all the dialoges */ 
  843     if (i == -1) {
  844         if (writer_frame)
  845             gtk_widget_set_sensitive(writer_frame, FALSE);
  846         return;
  847     } else {
  848         if (writer_frame)
  849             gtk_widget_set_sensitive(writer_frame, TRUE);
  850     }
  851 
  852     /* update data displayed for this writer */
  853     if (cdr_drv_omenu) {
  854         gtk_option_menu_set_history(GTK_OPTION_MENU (cdr_drv_omenu),
  855             writerreaderdevs[i]->writer_drvmode +1);
  856     }
  857     if (cdr_mode_omenu) {
  858         gtk_option_menu_set_history(GTK_OPTION_MENU (cdr_mode_omenu),
  859             writerreaderdevs[i]->writer_mode);
  860         menu_shell = GTK_MENU_SHELL(GTK_OPTION_MENU (cdr_mode_omenu)->menu);
  861         /* loop through all given menu entries */
  862         j = 0;
  863         loop = g_list_first(menu_shell->children);
  864         while(loop) {
  865             menuitem = loop->data;  
  866             if (!writemode_supported(j, setupdata.writer_devnr)) {
  867                 gtk_widget_set_sensitive(menuitem, FALSE);
  868             } else {
  869                 gtk_widget_set_sensitive(menuitem, TRUE);
  870             }
  871             j++;
  872             loop = loop->next;
  873         }       
  874     }
  875     /* We must add 0.1 because otherwise the lowest value is not displayed. Very strange */
  876     if (cdr_spd_adj) {
  877         gtk_adjustment_set_value(GTK_ADJUSTMENT (cdr_spd_adj), 
  878             (gfloat)writerreaderdevs[i]->writer_speed +0.1);
  879     }
  880     if (cdr_fifo_adj) {
  881         gtk_adjustment_set_value(GTK_ADJUSTMENT (cdr_fifo_adj), 
  882             (gfloat)(writerreaderdevs[i]->writer_fifo) / 2 +0.1);
  883     }
  884 }
  885 
  886 static void writermode_selected(GtkWidget *item, gpointer mode) {
  887 gint i;
  888 static gint showonce = 0;
  889 
  890     i = get_writerreaderdevs_index(setupdata.writer_devnr);
  891 
  892     /* user touched that setting? */
  893     if (writerreaderdevs[i]->writer_drvmode != GPOINTER_TO_INT(mode)) {
  894         if (!showonce) {
  895             showonce = 1;
  896             show_dialog(ICO_WARN,_("Please note that changing this setting to anything other\nthan \"autodetect\" is almost never required.\nDon't touch unless you are a cdrtools expert."),T_OK,NULL,NULL,0);
  897         }
  898     }
  899     writerreaderdevs[i]->writer_drvmode = GPOINTER_TO_INT(mode);
  900     
  901 }
  902 
  903 static void paranoia_selected(GtkWidget *item, gpointer data) {
  904 gint i;
  905 
  906     i = get_writerreaderdevs_index(setupdata.reader_devnr);
  907 
  908     writerreaderdevs[i]->audioread_useparanoia = 
  909         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(item));
  910     /*
  911      * enable/disable sliders for paranoia options
  912      * and vice versa the non-paranoia one
  913      */
  914     if (writerreaderdevs[i]->audioread_useparanoia == 0) {
  915         gtk_widget_set_sensitive(readslider2,FALSE);
  916         set_labelcolor(readspd2,DISABLEDCOLOR);
  917         gtk_widget_set_sensitive(readslider3,FALSE);
  918         set_labelcolor(readspd3,DISABLEDCOLOR);
  919         gtk_widget_set_sensitive(readslider4,FALSE);
  920         set_labelcolor(readspd4,DISABLEDCOLOR);
  921         if (isroot() || setupdata.root_option_change_readparam) {
  922             gtk_widget_set_sensitive(readslider1,TRUE);
  923             set_labelcolor(readspd1,ENABLEDCOLOR);
  924         }
  925     } else {
  926         gtk_widget_set_sensitive(readslider1,FALSE);
  927         set_labelcolor(readspd1,DISABLEDCOLOR);
  928         if (isroot() || setupdata.root_option_change_readparam) {
  929             gtk_widget_set_sensitive(readslider2,TRUE);
  930             set_labelcolor(readspd2,ENABLEDCOLOR);
  931             gtk_widget_set_sensitive(readslider3,TRUE);
  932             set_labelcolor(readspd3,ENABLEDCOLOR);
  933             gtk_widget_set_sensitive(readslider4,TRUE);
  934             set_labelcolor(readspd4,ENABLEDCOLOR);
  935         }
  936     }
  937 }
  938 
  939 static void htoa_selected(GtkWidget *item, gpointer data) {
  940 gint i;
  941 
  942     i = get_writerreaderdevs_index(setupdata.reader_devnr);
  943 
  944     writerreaderdevs[i]->audioread_showhiddentrack = 
  945         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(item));
  946 }
  947 
  948 static void reader_selected(GtkWidget *item, gpointer devnr) {
  949 gint i;
  950 
  951     setupdata.reader_devnr = GPOINTER_TO_INT(devnr);
  952 
  953     /* i is the index in our writerreaderdevs structure */
  954     i = get_writerreaderdevs_index(setupdata.reader_devnr);
  955 
  956     /* no device? lock all the dialoge */ 
  957     if (i == -1) {
  958         if (reader_frame)
  959             gtk_widget_set_sensitive(reader_frame, FALSE);
  960         return;
  961     } else {
  962         if (reader_frame)
  963             gtk_widget_set_sensitive(reader_frame, TRUE);
  964     }
  965 
  966     /*
  967      * update data displayed for this reader;
  968      * we must add 0.1 because otherwise the
  969      * lowest value is not displayed. Very strange!
  970      */
  971     if (rdr_spd_adj) {
  972         gtk_adjustment_set_value(GTK_ADJUSTMENT (rdr_spd_adj), 
  973             (gfloat)writerreaderdevs[i]->audioread_speed +0.1);
  974     }
  975     if (rdr_ovrl_adj) {
  976         gtk_adjustment_set_value(GTK_ADJUSTMENT (rdr_ovrl_adj), 
  977             (gfloat)writerreaderdevs[i]->audioread_overlap +0.1);
  978     }
  979     if (rdr_pararahd_adj) {
  980         gtk_adjustment_set_value(GTK_ADJUSTMENT (rdr_pararahd_adj), 
  981             (gfloat)(writerreaderdevs[i]->audioread_paranoiareadahead) / 100 +0.1);
  982     }
  983     if (rdr_paraovrl_adj) {
  984         gtk_adjustment_set_value(GTK_ADJUSTMENT (rdr_paraovrl_adj), 
  985             (gfloat)writerreaderdevs[i]->audioread_paranoiaminoverlap +0.1);
  986     }
  987     if (rdr_pararetr) {
  988     gtk_adjustment_set_value(GTK_ADJUSTMENT (rdr_pararetr),
  989         (gfloat)(writerreaderdevs[i]->audioread_paranoiaretries) / 5 +0.1);
  990     }
  991     if (rdr_para_check) {
  992         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rdr_para_check),
  993             writerreaderdevs[i]->audioread_useparanoia);
  994         paranoia_selected(rdr_para_check, NULL);
  995     }
  996     if (rdr_htoa_check) {
  997         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rdr_htoa_check),
  998             writerreaderdevs[i]->audioread_showhiddentrack);
  999         htoa_selected(rdr_htoa_check, NULL);
 1000     }
 1001 }
 1002 
 1003 static void defwritemode_selected(GtkWidget *item, gpointer level) {
 1004 gint i;
 1005 
 1006     i = get_writerreaderdevs_index(setupdata.writer_devnr);
 1007     writerreaderdevs[i]->writer_mode = GPOINTER_TO_INT(level);
 1008 }
 1009 /*
 1010  * end of all the callbacks for the disc setup
 1011  */
 1012 
 1013 
 1014 static gint draw_cd_setup_writers(GtkWidget *menu, gint *firstdevnr) {
 1015 GtkWidget *menu_item;
 1016 gint i, menuhistory, menuidx;
 1017 gchar tmp[MAXLINE];
 1018 
 1019     menuidx = 0; menuhistory = -1; *firstdevnr = -1;
 1020     i = 0;
 1021     while(writerreaderdevs[i] != NULL) {
 1022 
 1023         /* only show writers here */
 1024                 if (writerreaderdevs[i]->is_cdrwriter ||
 1025                     writerreaderdevs[i]->is_dvdwriter) {
 1026 
 1027             if (*firstdevnr == -1) {
 1028                 *firstdevnr = writerreaderdevs[i]->devnr;
 1029             }
 1030             if (convert_devnr2devstring(writerreaderdevs[i]->devnr,tmp) == 0) {
 1031                 menu_item = gtk_menu_item_new_with_label(tmp);
 1032                 g_signal_connect(menu_item,
 1033                     "activate", G_CALLBACK(writer_selected),
 1034                     GINT_TO_POINTER(writerreaderdevs[i]->devnr));
 1035                 gtk_menu_append (GTK_MENU (menu), menu_item);
 1036                 /* look if this is the currently selected writer */
 1037                 if (setupdata.writer_devnr == writerreaderdevs[i]->devnr) { menuhistory = menuidx; }
 1038                 menuidx++;
 1039                 gtk_widget_show (menu_item);
 1040             }
 1041         }
 1042         i++;
 1043     }
 1044     
 1045     return menuhistory;
 1046 }
 1047 
 1048 static gint draw_cd_setup_readers(GtkWidget *menu, gint *firstdevnr) {
 1049 GtkWidget *menu_item;
 1050 gint i, menuhistory, menuidx;
 1051 gchar tmp[MAXLINE];
 1052 
 1053     menuidx = 0; menuhistory = -1; *firstdevnr = -1;
 1054     i = 0;
 1055     while(writerreaderdevs[i] != NULL) {
 1056 
 1057         if (*firstdevnr == -1) {
 1058             *firstdevnr = writerreaderdevs[i]->devnr;
 1059         }
 1060         if (convert_devnr2devstring(writerreaderdevs[i]->devnr,tmp) == 0) {
 1061             menu_item = gtk_menu_item_new_with_label(tmp);
 1062             g_signal_connect(menu_item,
 1063                 "activate", G_CALLBACK(reader_selected),
 1064                 GINT_TO_POINTER(writerreaderdevs[i]->devnr));
 1065             gtk_menu_append (GTK_MENU (menu), menu_item);
 1066 
 1067             if (setupdata.reader_devnr == writerreaderdevs[i]->devnr) { menuhistory = menuidx; }
 1068             menuidx++;
 1069             gtk_widget_show (menu_item);
 1070         }
 1071         i++;
 1072     }
 1073 
 1074     return menuhistory;
 1075 }
 1076 
 1077 
 1078 /*
 1079  * draw disc setup screen: CD/DVD/BD Settings"
 1080  */
 1081 static void draw_cd_setup(GtkWidget *win) {
 1082 GtkWidget *omenu;
 1083 GtkWidget *menu_item;
 1084 GtkWidget *menu;
 1085 GtkWidget *l1;
 1086 GtkWidget *f1;
 1087 GtkWidget *vbox, *vbox2, *sep;
 1088 GtkWidget *tbl;
 1089 GtkObject *adj1,*adj2,*adj3,*adj4,*adj5,*adj6,*adj7;
 1090 GtkWidget *scale;
 1091 GtkWidget *spdlabel, *fifolabel, *check;
 1092 gchar tmp[MAXLINE];
 1093 gint i;
 1094 gint menuhistory, firstdevnr;
 1095 static const gchar *writemodes[] = WRITE_MODES;
 1096 static const gchar *helpwritemodes[] = HELP_WRITE_MODES;
 1097 
 1098     writer_omenu = NULL;
 1099     cdr_drv_omenu = NULL;
 1100     cdr_mode_omenu = NULL;
 1101     cdr_spd_adj = NULL;
 1102     cdr_fifo_adj = NULL;
 1103 
 1104     reader_omenu = NULL;
 1105     rdr_spd_adj = NULL;
 1106     rdr_pararahd_adj = NULL;
 1107     rdr_ovrl_adj = NULL;
 1108     rdr_paraovrl_adj = NULL;
 1109     rdr_para_check = NULL;
 1110     rdr_htoa_check = NULL;
 1111 
 1112     writer_frame = NULL;
 1113     reader_frame = NULL;
 1114 
 1115     vbox = gtk_vbox_new(FALSE,0);
 1116     gtk_container_add(GTK_CONTAINER(win),vbox);
 1117     gtk_container_set_border_width(GTK_CONTAINER(vbox),10);
 1118 
 1119     gtk_widget_show(vbox);
 1120 
 1121     /*
 1122      * ---- writer configuration ----
 1123      */
 1124     f1 = gtk_frame_new(_("CD/DVD/BD Writer Configuration"));
 1125     set_font_and_color_frame(f1,PANGO_BOLD,NULL);
 1126     gtk_box_pack_start(GTK_BOX(vbox),f1,FALSE,TRUE,0);
 1127     gtk_widget_show(f1);
 1128     writer_frame = f1;
 1129 
 1130     vbox2 = gtk_vbox_new(FALSE,0);
 1131     gtk_container_add(GTK_CONTAINER(f1),vbox2);
 1132     gtk_widget_show(vbox2);
 1133 
 1134     tbl = gtk_table_new(1,32,TRUE);
 1135     gtk_table_set_col_spacing(GTK_TABLE(tbl),14,5);
 1136     gtk_container_set_border_width(GTK_CONTAINER (tbl),5);
 1137     gtk_box_pack_start(GTK_BOX(vbox2),tbl,FALSE,TRUE,0);
 1138     gtk_widget_show(tbl);
 1139 
 1140     /* write device */
 1141 
 1142     l1 = rightjust_gtk_label_new(_("Write Device:"));
 1143     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,15,0,1);
 1144     gtk_widget_show(l1);
 1145     
 1146     omenu = gtk_option_menu_new ();
 1147     menu = gtk_menu_new();
 1148     writer_omenu = omenu;
 1149 
 1150     menuhistory = draw_cd_setup_writers(menu, &firstdevnr);
 1151 
 1152     gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
 1153     if (menuhistory != -1) {
 1154         /* set the preselected writer */
 1155         gtk_option_menu_set_history(GTK_OPTION_MENU (omenu),menuhistory);
 1156     } else {
 1157         /* nothing valid preselected */
 1158         setupdata.writer_devnr = firstdevnr;
 1159     }
 1160     gtk_table_attach_defaults(GTK_TABLE(tbl),omenu,15,32,0,1);
 1161     gtk_widget_show(omenu);
 1162     define_tooltip(omenu,_("Select the writer device you normally want to use to burn Discs with."));
 1163 
 1164     if (!isroot() && !setupdata.root_option_change_writer) {
 1165         gtk_widget_set_sensitive(omenu,FALSE);
 1166     }
 1167 
 1168         sep = gtk_hseparator_new();
 1169         gtk_box_pack_start(GTK_BOX(vbox2),sep,TRUE,TRUE,0);
 1170         gtk_widget_show(sep);
 1171 
 1172     tbl = gtk_table_new(4,32,TRUE);
 1173     gtk_table_set_col_spacing(GTK_TABLE(tbl),14,5);
 1174     gtk_container_set_border_width(GTK_CONTAINER (tbl),5);
 1175     gtk_box_pack_start(GTK_BOX(vbox2),tbl,FALSE,TRUE,0);
 1176     gtk_widget_show(tbl);
 1177 
 1178 
 1179     /* list of cdrecord drivers */
 1180 
 1181     l1 = rightjust_gtk_label_new(_("Disc Writer Mode:"));
 1182     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,15,0,1);
 1183     gtk_widget_show(l1);
 1184 
 1185     omenu = gtk_option_menu_new();
 1186     menu = gtk_menu_new();
 1187     cdr_drv_omenu = omenu;
 1188 
 1189     menu_item = gtk_menu_item_new_with_label(_("Autodetect"));
 1190     g_signal_connect(menu_item,
 1191         "activate", G_CALLBACK(writermode_selected),
 1192         GINT_TO_POINTER(-1));
 1193     gtk_menu_append (GTK_MENU (menu), menu_item);
 1194     gtk_widget_show (menu_item);
 1195 
 1196     i = 0;
 1197     while(drivers[i] != NULL) {
 1198 
 1199         menu_item = gtk_menu_item_new_with_label(drivers[i]->desc);
 1200         g_signal_connect(menu_item,
 1201             "activate", G_CALLBACK(writermode_selected),
 1202             GINT_TO_POINTER(i));
 1203         gtk_menu_append (GTK_MENU (menu), menu_item);
 1204         gtk_widget_show (menu_item);
 1205         i++;
 1206     }
 1207     gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
 1208     gtk_table_attach_defaults(GTK_TABLE(tbl),omenu,15,32,0,1);
 1209     gtk_widget_show(omenu);
 1210     define_tooltip(omenu,_("The write-mode: Leave that at \"autodetect\" unless you really know what you are doing."));
 1211 
 1212         if (!isroot() && !(setupdata.root_option_change_writeparam &&
 1213         setupdata.root_option_change_writer)) {
 1214         gtk_widget_set_sensitive(omenu,FALSE);
 1215     }
 1216 
 1217     l1 = rightjust_gtk_label_new(_("Default Write Mode:"));
 1218     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,15,1,2);
 1219     gtk_widget_show(l1);
 1220 
 1221         omenu = gtk_option_menu_new ();
 1222         menu = gtk_menu_new();
 1223     cdr_mode_omenu = omenu;
 1224 
 1225         i = 0;
 1226         while (writemodes[i]) {
 1227                 menu_item = gtk_menu_item_new_with_label(_(writemodes[i]));
 1228                 g_signal_connect(menu_item, "activate",
 1229                         G_CALLBACK(defwritemode_selected),
 1230                         GINT_TO_POINTER(i));
 1231                 gtk_menu_append (GTK_MENU (menu), menu_item);
 1232                 gtk_widget_show (menu_item);
 1233                 if (helpwritemodes[i])
 1234                         define_tooltip(menu_item,(gchar *)_(helpwritemodes[i]));
 1235         i++;
 1236         }
 1237         gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
 1238         gtk_table_attach_defaults(GTK_TABLE(tbl),omenu,15,32,1,2);
 1239         gtk_widget_show(omenu);
 1240         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."));
 1241         define_tooltip(omenu, tmp); /* concatenated text */
 1242 
 1243     if (!isroot() && !setupdata.root_option_change_writeparam) {
 1244                 gtk_widget_set_sensitive(omenu,FALSE);
 1245         }
 1246 
 1247     /* speed */
 1248 
 1249     l1 = rightjust_gtk_label_new(_("Disc Writer Speed:"));
 1250     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,15,2,3);
 1251     gtk_widget_show(l1);
 1252 
 1253     f1 = gtk_frame_new(NULL);
 1254     gtk_frame_set_shadow_type(GTK_FRAME(f1),GTK_SHADOW_IN);
 1255     gtk_container_border_width(GTK_CONTAINER(f1),3);
 1256     gtk_table_attach_defaults(GTK_TABLE(tbl),f1,15,19,2,3);
 1257     gtk_widget_show(f1);
 1258 
 1259     spdlabel = gtk_label_new("");
 1260     gtk_container_add(GTK_CONTAINER(f1),spdlabel);
 1261     gtk_widget_show(spdlabel);
 1262 
 1263     adj1 = gtk_adjustment_new(0.0,0.0,65.0,1.0,2.0,1.0);
 1264     cdr_spd_adj = adj1;
 1265     g_signal_connect(adj1, "value_changed",
 1266         G_CALLBACK(speed_changed), spdlabel);
 1267     scale = gtk_hscale_new(GTK_ADJUSTMENT (adj1));
 1268     gtk_scale_set_value_pos (GTK_SCALE(scale), GTK_POS_LEFT);
 1269     gtk_scale_set_digits(GTK_SCALE(scale),0);
 1270     gtk_scale_set_draw_value(GTK_SCALE(scale),FALSE);
 1271     gtk_table_attach_defaults(GTK_TABLE(tbl),scale,19,32,2,3);
 1272 
 1273 
 1274     gtk_widget_show(scale);
 1275     define_tooltip(scale,_("The default speed to be used for writing."));
 1276     
 1277     if (!isroot() && !setupdata.root_option_change_writeparam) {
 1278         gtk_widget_set_sensitive(scale,FALSE);
 1279     }
 1280 
 1281     /* FIFO */
 1282 
 1283     l1 = rightjust_gtk_label_new(_("Disc Writer FIFO-Buffer-Size:"));
 1284     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,15,3,4);
 1285     gtk_widget_show(l1);
 1286 
 1287     f1 = gtk_frame_new(NULL);
 1288     gtk_frame_set_shadow_type(GTK_FRAME(f1),GTK_SHADOW_IN);
 1289     gtk_container_border_width(GTK_CONTAINER(f1),3);
 1290     gtk_table_attach_defaults(GTK_TABLE(tbl),f1,15,19,3,4);
 1291     gtk_widget_show(f1);
 1292 
 1293     fifolabel = gtk_label_new("");
 1294     gtk_container_add(GTK_CONTAINER(f1),fifolabel);
 1295     gtk_widget_show(fifolabel);
 1296 
 1297     adj2 = gtk_adjustment_new(1.0,1.0,65.0,1.0,2.0,1.0);
 1298     cdr_fifo_adj = adj2;
 1299     g_signal_connect(adj2, "value_changed",
 1300         G_CALLBACK(fifo_changed), fifolabel);
 1301     scale = gtk_hscale_new(GTK_ADJUSTMENT (adj2));
 1302     gtk_scale_set_value_pos (GTK_SCALE(scale), GTK_POS_LEFT);
 1303     gtk_scale_set_digits(GTK_SCALE(scale),0);
 1304     gtk_scale_set_draw_value(GTK_SCALE(scale),FALSE);
 1305     gtk_table_attach_defaults(GTK_TABLE(tbl),scale,19,32,3,4);
 1306          
 1307     gtk_widget_show(scale);
 1308     define_tooltip(scale,_("This is the internal memory-buffer cdrecord allocates to prevent buffer-underruns while burning. This should be set higher than the internal hardware buffer of the CD/DVD/BD Writer."));
 1309 
 1310     if (!isroot() && !setupdata.root_option_change_writeparam) {
 1311         gtk_widget_set_sensitive(scale,FALSE);
 1312     }
 1313 
 1314     /* draw current values */
 1315     writer_selected(NULL, GINT_TO_POINTER(setupdata.writer_devnr));
 1316     
 1317     /*
 1318      * ---- reader configuration ----
 1319      */
 1320     f1 = gtk_frame_new(_("CD/DVD/BD Reader Configuration"));
 1321     set_font_and_color_frame(f1,PANGO_BOLD,NULL);
 1322     gtk_box_pack_start(GTK_BOX(vbox),f1,FALSE,TRUE,5);
 1323     gtk_widget_show(f1);
 1324     reader_frame = f1;
 1325 
 1326     vbox2 = gtk_vbox_new(FALSE,0);
 1327     gtk_container_add(GTK_CONTAINER(f1),vbox2);
 1328     gtk_widget_show(vbox2);
 1329 
 1330 
 1331     tbl = gtk_table_new(1,32,TRUE);
 1332     gtk_table_set_col_spacing(GTK_TABLE(tbl),14,5);
 1333     gtk_container_set_border_width(GTK_CONTAINER (tbl),5);
 1334     gtk_box_pack_start(GTK_BOX(vbox2),tbl,FALSE,TRUE,0);
 1335     gtk_widget_show(tbl);
 1336 
 1337     /* read device */
 1338 
 1339     l1 = rightjust_gtk_label_new(_("Read Device:"));
 1340     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,15,0,1);
 1341     gtk_widget_show(l1);
 1342 
 1343     omenu = gtk_option_menu_new ();
 1344     menu = gtk_menu_new();
 1345     reader_omenu = omenu;
 1346 
 1347     menuhistory = draw_cd_setup_readers(menu, &firstdevnr);
 1348 
 1349     gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
 1350     if (menuhistory != -1) {
 1351         gtk_option_menu_set_history(GTK_OPTION_MENU (omenu),menuhistory);
 1352     } else {
 1353         setupdata.reader_devnr = firstdevnr;
 1354     }
 1355     gtk_table_attach_defaults(GTK_TABLE(tbl),omenu,15,32,0,1);
 1356     gtk_widget_show(omenu);
 1357     define_tooltip(omenu,_("The device you normally want to use to read data or audio from Discs."));
 1358 
 1359     if (!isroot() && !setupdata.root_option_change_reader) {
 1360         gtk_widget_set_sensitive(omenu,FALSE);
 1361     }
 1362 
 1363         sep = gtk_hseparator_new();
 1364         gtk_box_pack_start(GTK_BOX(vbox2),sep,TRUE,TRUE,0);
 1365         gtk_widget_show(sep);
 1366 
 1367     tbl = gtk_table_new(5,32,TRUE);
 1368     gtk_table_set_col_spacing(GTK_TABLE(tbl),14,5);
 1369     gtk_container_set_border_width(GTK_CONTAINER (tbl),5);
 1370     gtk_box_pack_start(GTK_BOX(vbox2),tbl,FALSE,TRUE,0);
 1371     gtk_widget_show(tbl);
 1372 
 1373     /* speed */
 1374 
 1375     l1 = rightjust_gtk_label_new(_("Audio Read Speed:"));
 1376     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,15,0,1);
 1377     gtk_widget_show(l1);
 1378 
 1379     f1 = gtk_frame_new(NULL);
 1380     gtk_frame_set_shadow_type(GTK_FRAME(f1),GTK_SHADOW_IN);
 1381     gtk_container_border_width(GTK_CONTAINER(f1),3);
 1382     gtk_table_attach_defaults(GTK_TABLE(tbl),f1,15,19,0,1);
 1383     gtk_widget_show(f1);
 1384 
 1385     spdlabel = gtk_label_new("");
 1386     gtk_container_add(GTK_CONTAINER(f1),spdlabel);
 1387     gtk_widget_show(spdlabel);
 1388 
 1389     adj3 = gtk_adjustment_new(0.0,0.0,65.0,1.0,2.0,1.0);
 1390     rdr_spd_adj = adj3;
 1391     g_signal_connect(adj3, "value_changed",
 1392         G_CALLBACK(audio_speed_changed), spdlabel);
 1393     scale = gtk_hscale_new(GTK_ADJUSTMENT (adj3));
 1394     gtk_scale_set_value_pos (GTK_SCALE(scale), GTK_POS_LEFT);
 1395     gtk_scale_set_digits(GTK_SCALE(scale),0);
 1396     gtk_scale_set_draw_value(GTK_SCALE(scale),FALSE);
 1397     gtk_table_attach_defaults(GTK_TABLE(tbl),scale,19,32,0,1);
 1398     gtk_widget_show(scale);
 1399     define_tooltip(scale,_("The speed X-CD-Roast uses when reading audio tracks. For maximum extraction quality, do set it to a value of 8 or below. Note: The drive will silently ignore this setting if the value is not one of the supported speeds for reading."));
 1400 
 1401     if (!isroot() && !setupdata.root_option_change_readparam) {
 1402         gtk_widget_set_sensitive(scale,FALSE);
 1403     }
 1404     
 1405     /* non-paranoia overlap */
 1406 
 1407     l1 = rightjust_gtk_label_new(_("Sectors for overlap sampling:"));
 1408     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,15,1,2);
 1409     gtk_widget_show(l1);
 1410 
 1411     f1 = gtk_frame_new(NULL);
 1412     gtk_frame_set_shadow_type(GTK_FRAME(f1),GTK_SHADOW_IN);
 1413     gtk_container_border_width(GTK_CONTAINER(f1),3);
 1414     gtk_table_attach_defaults(GTK_TABLE(tbl),f1,15,19,1,2);
 1415     gtk_widget_show(f1);
 1416 
 1417     spdlabel = gtk_label_new("");
 1418     readspd1 = l1;
 1419     gtk_container_add(GTK_CONTAINER(f1),spdlabel);
 1420     gtk_widget_show(spdlabel);
 1421 
 1422     adj4 = gtk_adjustment_new(0.0,0.0,36.0,1.0,2.0,1.0);
 1423     rdr_ovrl_adj = adj4;
 1424     g_signal_connect(adj4, "value_changed",
 1425         G_CALLBACK(sectors_changed), spdlabel);
 1426     scale = gtk_hscale_new(GTK_ADJUSTMENT (adj4));
 1427     readslider1 = scale;
 1428     gtk_scale_set_value_pos (GTK_SCALE(scale), GTK_POS_LEFT);
 1429     gtk_scale_set_digits(GTK_SCALE(scale),0);
 1430     gtk_scale_set_draw_value(GTK_SCALE(scale),FALSE);
 1431     gtk_table_attach_defaults(GTK_TABLE(tbl),scale,19,32,1,2);
 1432     gtk_widget_show(scale);
 1433     define_tooltip(scale,_("Enables jitter-correction for audio tracks. The higher this setting the slower the read process can be."));
 1434 
 1435     if (!isroot() && !setupdata.root_option_change_readparam) {
 1436         gtk_widget_set_sensitive(scale,FALSE);
 1437     }
 1438 
 1439     /* paranoia readahead */
 1440 
 1441     l1 = rightjust_gtk_label_new(_("Size of read ahead buffer:"));
 1442     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,15,2,3);
 1443     gtk_widget_show(l1);
 1444 
 1445     f1 = gtk_frame_new(NULL);
 1446     gtk_frame_set_shadow_type(GTK_FRAME(f1),GTK_SHADOW_IN);
 1447     gtk_container_border_width(GTK_CONTAINER(f1),3);
 1448     gtk_table_attach_defaults(GTK_TABLE(tbl),f1,15,19,2,3);
 1449     gtk_widget_show(f1);
 1450 
 1451     spdlabel = gtk_label_new("");
 1452     readspd2 = l1;
 1453     gtk_container_add(GTK_CONTAINER(f1),spdlabel);
 1454     gtk_widget_show(spdlabel);
 1455 
 1456     adj5 = gtk_adjustment_new(1.0,1.0,41.0,1.0,2.0,1.0);
 1457     rdr_pararahd_adj = adj5;
 1458     g_signal_connect(adj5, "value_changed",
 1459         G_CALLBACK(sectors2_changed), spdlabel);
 1460     scale = gtk_hscale_new(GTK_ADJUSTMENT (adj5));
 1461     readslider2 = scale;
 1462     gtk_scale_set_value_pos (GTK_SCALE(scale), GTK_POS_LEFT);
 1463     gtk_scale_set_digits(GTK_SCALE(scale),0);
 1464     gtk_scale_set_draw_value(GTK_SCALE(scale),FALSE);
 1465     gtk_table_attach_defaults(GTK_TABLE(tbl),scale,19,32,2,3);
 1466     gtk_widget_show(scale);
 1467     define_tooltip(scale,_("This is the number of sectors to use for the read ahead buffer. In some cases a higher value can improve the quality. But use always at least 425 sectors per MiB RAM in the disc reader. X-CD-Roast resets the minimum value for your drive automatically each time you scan for new devices."));
 1468 
 1469     if (!isroot() && !setupdata.root_option_change_readparam) {
 1470         gtk_widget_set_sensitive(scale,FALSE);
 1471     }
 1472 
 1473     /* paranoia minoverlap */
 1474 
 1475     l1 = rightjust_gtk_label_new(_("Minimum overlap of sectors:"));
 1476     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,15,3,4);
 1477     gtk_widget_show(l1);
 1478 
 1479     f1 = gtk_frame_new(NULL);
 1480     gtk_frame_set_shadow_type(GTK_FRAME(f1),GTK_SHADOW_IN);
 1481     gtk_container_border_width(GTK_CONTAINER(f1),3);
 1482     gtk_table_attach_defaults(GTK_TABLE(tbl),f1,15,19,3,4);
 1483     gtk_widget_show(f1);
 1484 
 1485     spdlabel = gtk_label_new("");
 1486     readspd3 = l1;
 1487     gtk_container_add(GTK_CONTAINER(f1),spdlabel);
 1488     gtk_widget_show(spdlabel);
 1489 
 1490     adj6 = gtk_adjustment_new(0.0,0.0,36.0,1.0,2.0,1.0);
 1491     rdr_paraovrl_adj = adj6;
 1492     g_signal_connect(adj6, "value_changed",
 1493         G_CALLBACK(sectors3_changed), spdlabel);
 1494     scale = gtk_hscale_new(GTK_ADJUSTMENT (adj6));
 1495     readslider3 = scale;
 1496     gtk_scale_set_value_pos (GTK_SCALE(scale), GTK_POS_LEFT);
 1497     gtk_scale_set_digits(GTK_SCALE(scale),0);
 1498     gtk_scale_set_draw_value(GTK_SCALE(scale),FALSE);
 1499     gtk_table_attach_defaults(GTK_TABLE(tbl),scale,19,32,3,4);
 1500     gtk_widget_show(scale);
 1501     define_tooltip(scale,_("Sets the minimum number of sectors for the dynamic overlap. The quality varies a lot with this value and it is recommended to run experiments with it. If set to 0 the default minimum overlap of 0.5 is used.")); 
 1502     if (!isroot() && !setupdata.root_option_change_readparam) {
 1503         gtk_widget_set_sensitive(scale,FALSE);
 1504     }
 1505 
 1506     /* paranoia retries */
 1507 
 1508     l1 = rightjust_gtk_label_new(_("Paranoia retries per sector:"));
 1509     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,15,4,5);
 1510     gtk_widget_show(l1);
 1511 
 1512     f1 = gtk_frame_new(NULL);
 1513     gtk_frame_set_shadow_type(GTK_FRAME(f1),GTK_SHADOW_IN);
 1514     gtk_container_border_width(GTK_CONTAINER(f1),3);
 1515     gtk_table_attach_defaults(GTK_TABLE(tbl),f1,15,19,4,5);
 1516     gtk_widget_show(f1);
 1517 
 1518     spdlabel = gtk_label_new("");
 1519     readspd4 = l1;
 1520     gtk_container_add(GTK_CONTAINER(f1),spdlabel);
 1521     gtk_widget_show(spdlabel);
 1522 
 1523     adj7 = gtk_adjustment_new(1.0,1.0,41.0,1.0,2.0,1.0);
 1524     rdr_pararetr = adj7;
 1525     g_signal_connect(adj7, "value_changed",
 1526         G_CALLBACK(sectors4_changed), spdlabel);
 1527     scale = gtk_hscale_new(GTK_ADJUSTMENT (adj7));
 1528     readslider4 = scale;
 1529     gtk_scale_set_value_pos (GTK_SCALE(scale), GTK_POS_LEFT);
 1530     gtk_scale_set_digits(GTK_SCALE(scale),0);
 1531     gtk_scale_set_draw_value(GTK_SCALE(scale),FALSE);
 1532     gtk_table_attach_defaults(GTK_TABLE(tbl),scale,19,32,4,5);
 1533     gtk_widget_show(scale);
 1534     g_snprintf(tmp,MAXLINE,"%s %s",_("How often the paranoia code will try to read a fautly sector before giving up."), _("In case of \"retry/skip errors\" do also try different values for 'read ahead buffer' or 'minimum overlap'."));
 1535     define_tooltip(scale,tmp);  /* concatenated text */
 1536 
 1537     if (!isroot() && !setupdata.root_option_change_readparam) {
 1538         gtk_widget_set_sensitive(scale,FALSE);
 1539     }
 1540 
 1541     /* paranoia mode? */
 1542 
 1543     check = gtk_check_button_new_with_label(_("Use paranoia mode for audio"));
 1544     rdr_para_check = check;
 1545     g_signal_connect(check,"clicked",
 1546         G_CALLBACK(paranoia_selected), NULL);
 1547     gtk_table_attach_defaults(GTK_TABLE(tbl),check,15,32,5,6);
 1548     gtk_widget_show(check);
 1549     define_tooltip(check, _("Read audio CDs with the enhanced error correction paranoia code."));
 1550 
 1551     if (!isroot() && !setupdata.root_option_change_readparam) {
 1552         gtk_widget_set_sensitive(check,FALSE);
 1553     }
 1554 
 1555     /* htoa? */
 1556 
 1557     check = gtk_check_button_new_with_label(_("Show a hidden audio track"));
 1558     rdr_htoa_check = check;
 1559     g_signal_connect(check,"clicked",
 1560         G_CALLBACK(htoa_selected), NULL);
 1561     gtk_table_attach_defaults(GTK_TABLE(tbl),check,15,32,6,7);
 1562     gtk_widget_show(check);
 1563     define_tooltip(check, _("A few audio CDs contain a hidden piece of music before the first track, called \"Hidden Track One Audio (HTOA)\". If the track list shows a '0. audio track' then this audio CD may hold such one. However, if it is shorter than 4 seconds, you cannot write it to a CD-R/RW, as you will get a faulty audio CD then."));
 1564 
 1565     if (!isroot() && !setupdata.root_option_change_readparam) {
 1566         gtk_widget_set_sensitive(check,FALSE);
 1567     }
 1568 
 1569     /* draw current values */
 1570     reader_selected(NULL, GINT_TO_POINTER(setupdata.reader_devnr));
 1571 }
 1572 
 1573 
 1574 /*
 1575  * Check if the partition is already in use by another image path.
 1576  * Return 1 if yes, 0 if not. Returns also the other image path
 1577  * in busypath. (fs = filesystem)
 1578  * Return -1 if no path was updated yet.
 1579  */
 1580 static gint fs_in_use(GtkCList *clist, gchar *fs, gchar *busypath) {
 1581 gint i;
 1582 gchar tmp[MAXLINE];
 1583 gchar *mnt;
 1584 gchar *data[3];
 1585 
 1586     for (i = 0; i < clist->rows; i++) {
 1587         mnt = (gchar *)gtk_clist_get_row_data(clist,i);
 1588         if (mnt == NULL) {
 1589             return -1;
 1590         }
 1591         strcpy(tmp,mnt);
 1592         if (strcmp(tmp,fs) == 0) {
 1593             if (busypath != NULL) {
 1594                 gtk_clist_get_text(clist,i,0,data);
 1595                 strcpy(busypath,data[0]);
 1596             }
 1597             return 1;
 1598         }
 1599     }
 1600     return 0;
 1601 }
 1602 
 1603 
 1604 /*
 1605  * Check if the partition is already in use by another image path.
 1606  * Skip the row "skiprow". (fs = filesystem)
 1607  * Return 1 if a partition is found.
 1608  */
 1609 static gint fs_in_use2(GtkCList *clist, gchar *fs, gint skiprow) {
 1610 gint i;
 1611 gchar *mnt;
 1612 
 1613     for (i = 0; i < clist->rows; i++) {
 1614         mnt = (gchar *)gtk_clist_get_row_data(clist,i);
 1615         if (mnt == NULL) {
 1616             /* ignore not updated lines */
 1617             continue;
 1618         }
 1619         if (i == skiprow) {
 1620             /* ignore the row marked to skip */
 1621             continue;
 1622         }
 1623         if (strcmp(mnt,fs) == 0) {
 1624             /* we found a match */
 1625             return 1;
 1626         }
 1627     }
 1628     return 0;
 1629 }
 1630 
 1631 
 1632 /*
 1633  * callbacks for hd-setup-menu
 1634  */
 1635 static void entry_imagepath_callback(GtkWidget *widget, GtkCList *clist) {
 1636 gchar dir[MAXLINE];
 1637 gchar *data[3];
 1638 gchar tmp[MAXLINE];
 1639 gchar tmp2[MAXLINE];
 1640 gchar fs[MAXLINE];
 1641 gint free;
 1642 gint row;
 1643 gint fsuse;
 1644 
 1645     strcpy(dir,gtk_entry_get_text(GTK_ENTRY(clist_entry)));
 1646     check_tilde(dir);
 1647     gtk_entry_set_text(GTK_ENTRY(clist_entry), dir);
 1648     convert_for_gtk2_filename(dir);
 1649 
 1650     /* valid directory? */
 1651     if (is_directory(dir) == 0) {
 1652         show_dialog(ICO_INFO,_("No valid path specified"),T_OK,NULL,NULL,0);    
 1653         return;
 1654     }
 1655 
 1656     /* now run update to get all partitions */
 1657     gtk_button_clicked(GTK_BUTTON(updatebutton));
 1658 
 1659     /* last character a /? remove */
 1660     if (dir[strlen(dir)-1] == '/') {
 1661         dir[strlen(dir)-1] = '\0';
 1662     }
 1663 
 1664     free = get_free_space(dir,fs);
 1665 
 1666     /*
 1667      * now check if this directory is
 1668      * on a partition (fs = filesystem)
 1669      * which you already added
 1670      */
 1671     fsuse = fs_in_use(clist,fs,tmp);
 1672     if (fsuse == 1) {
 1673         g_snprintf(tmp2,MAXLINE,_("Invalid path to add because it is on the same\npartition as the already added path:\n%s"),tmp);
 1674         show_dialog(ICO_WARN,tmp2,T_OK,NULL,NULL,0);    
 1675         return;
 1676     } else if (fsuse == -1) {
 1677         /* no updated sizes yet - press update first */
 1678         show_dialog(ICO_INFO,_("Please press \"Update\" once before adding new paths."),T_OK,NULL,NULL,0);
 1679         return;
 1680     }
 1681 
 1682     data[0] = convert_for_gtk2(dir);
 1683     data[1] = "N.A.";
 1684 
 1685     if (free != -1) {
 1686         convert_kbytes2mbminstring(free,tmp);
 1687         data[1] = tmp;
 1688     }
 1689 
 1690     if (is_dir_writeable(dir) == 0) {
 1691         data[2] = T_YES;
 1692     } else {
 1693         data[2] = T_NO;
 1694     }
 1695     
 1696     row = gtk_clist_append(clist,data);
 1697 
 1698     /* save the filesystem-device into row-data */
 1699     gtk_clist_set_row_data(clist,row,g_strdup(fs));
 1700 
 1701     gtk_entry_set_text(GTK_ENTRY(clist_entry),"");
 1702 
 1703     /* now update again to have all registered paths updated */
 1704     gtk_button_clicked(GTK_BUTTON(updatebutton));
 1705 
 1706 }
 1707 
 1708 
 1709 /*
 1710  * called when a drag is received on the entry
 1711  */
 1712 static void entry_imagepath_drag_received(GtkWidget *widget, 
 1713     GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data,
 1714     guint info, guint t, gpointer data) {
 1715 gchar *text;
 1716 gchar newdir[MAXLINE];
 1717 
 1718     /* nothing received? ignore */
 1719     if(selection_data == NULL)
 1720         return;
 1721         if(selection_data->length < 0)
 1722                 return;
 1723 
 1724     if ((info == DRAG_TAR_INFO_0) ||
 1725            (info == DRAG_TAR_INFO_1) ||
 1726            (info == DRAG_TAR_INFO_2)) {
 1727         text = (char *) selection_data->data;
 1728         if (extract_single_drag_filename(text, selection_data->length, newdir)) {
 1729             /* extracted the plain filename from drag */
 1730             if (strcmp(newdir,"") != 0) {
 1731                 dodebug(3,"Received from drag: %s\n", newdir);
 1732                 gtk_entry_set_text(GTK_ENTRY(clist_entry),newdir);
 1733                 if (data) {
 1734                     /* now simulate the press to the add button
 1735                        because we dragged directly onto the clist */
 1736                     entry_imagepath_callback(NULL, 
 1737                         GTK_CLIST(data));
 1738                 }
 1739             }
 1740         }
 1741     }
 1742 }
 1743 
 1744 
 1745 static void button_imagepath_callback(GtkWidget *widget, gpointer data) {
 1746 gchar tmp[MAXLINE];
 1747 
 1748     show_dir_tree(tmp);
 1749     if (strcmp(tmp,"") != 0) {
 1750         convert_for_gtk2(tmp);
 1751         gtk_entry_set_text(GTK_ENTRY(clist_entry),tmp);
 1752     }
 1753 }
 1754 
 1755 static void update_imagepath_callback(GtkWidget *widget, GtkCList *clist) {
 1756 gchar *data[3];
 1757 gchar tmp[MAXLINE];
 1758 gchar fs[MAXLINE];
 1759 gint free, sum;
 1760 gint i;
 1761 GdkCursor *cursor;
 1762 gchar *mnt;
 1763 gint marktodelete;
 1764 
 1765     /* set watch-cursor */
 1766     cursor = gdk_cursor_new(GDK_WATCH);
 1767     gdk_window_set_cursor(GTK_WIDGET(toplevel)->window,cursor);
 1768     /* give gtk time to update cursor */
 1769     gtk_main_iteration_do(FALSE);
 1770 
 1771     marktodelete = -1;
 1772     sum = 0;
 1773     /* loop through all rows */
 1774     for (i = 0; i < clist->rows; i++) {
 1775         gtk_clist_get_text(clist,i,0,data);
 1776         mnt = (gchar *)gtk_clist_get_row_data(clist,i);
 1777 
 1778         free = get_free_space(data[0],fs);
 1779 
 1780         convert_kbytes2mbminstring(free,tmp);
 1781 
 1782         gtk_clist_set_text(clist,i,1,tmp);
 1783 
 1784         if (is_dir_writeable(data[0]) == 0) {
 1785             gtk_clist_set_text(clist,i,2,T_YES);
 1786         } else {
 1787             gtk_clist_set_text(clist,i,2,T_NO);
 1788         }
 1789 
 1790         /*
 1791          * not yet a filesystem registred
 1792          * (updated) for this path?
 1793          */
 1794         if (mnt == NULL) {
 1795             /* do it now */
 1796             gtk_clist_set_row_data(clist,i,g_strdup(fs));
 1797         }
 1798         
 1799         /*
 1800          * now check if the new updated filesystem is already
 1801          * in use (should never happen - but may possible if the
 1802          * user repartitioned its drive without telling xcdroast)
 1803          */
 1804         if (fs_in_use2(clist,fs,i) == 1) {
 1805             /* mark the conflicting entry */
 1806             marktodelete = i;
 1807             continue;
 1808         }
 1809 
 1810         /* add sizes up */
 1811         sum+=free;
 1812     }   
 1813     convert_kbytes2mbminstring(sum,tmp);
 1814     gtk_label_set_text(GTK_LABEL(updatesum_label),tmp);
 1815 
 1816     /* normal cursor */
 1817     gdk_window_set_cursor(GTK_WIDGET(toplevel)->window, NULL);
 1818     gdk_cursor_destroy (cursor);
 1819 
 1820     /* if we found a conflicting entry - delete it now */
 1821     if (marktodelete != -1) {   
 1822         g_free(gtk_clist_get_row_data(clist,marktodelete));
 1823         gtk_clist_remove(clist,marktodelete);
 1824         show_dialog(ICO_WARN,_("Removed a conflicting path.\nPlease \"Update\" again."),T_OK,NULL,NULL,0);
 1825     }
 1826 }
 1827 
 1828 static void remove_imagepath_callback(GtkWidget *widget, GtkCList *clist) {
 1829 GList *sel;
 1830 gint row;
 1831 
 1832     sel = clist->selection;
 1833 
 1834     if (sel != NULL) {
 1835         row = GPOINTER_TO_INT(sel->data);
 1836         g_free(gtk_clist_get_row_data(clist,row));
 1837         gtk_clist_remove(clist,row);
 1838     } else {
 1839         show_dialog(ICO_INFO,_("No path selected to remove"),T_OK,NULL,NULL,0); 
 1840     }
 1841 }
 1842 
 1843 
 1844 /*
 1845  * draw hd-setup screen
 1846  */
 1847 static void draw_hd_setup(GtkWidget *win) {
 1848 GtkWidget *vbox;
 1849 GtkWidget *scrolled_win;
 1850 GtkWidget *f1,*l1;
 1851 gchar *titles[3];
 1852 gchar *data[3];
 1853 GtkWidget *list;
 1854 GtkCList  *clist;
 1855 GList *loop;
 1856 GtkWidget *tbl;
 1857 GtkWidget *b1;
 1858 GtkWidget *e1;
 1859 gint row;
 1860 GtkTargetEntry target_entry[3];
 1861 gchar tmp[MAXLINE];
 1862 
 1863     /* required for drag&drop setup */
 1864     target_entry[0].target = DRAG_TAR_NAME_0;
 1865     target_entry[0].flags = 0;
 1866     target_entry[0].info = DRAG_TAR_INFO_0;
 1867         target_entry[1].target = DRAG_TAR_NAME_1;
 1868         target_entry[1].flags = 0;
 1869         target_entry[1].info = DRAG_TAR_INFO_1;
 1870         target_entry[2].target = DRAG_TAR_NAME_2;
 1871         target_entry[2].flags = 0;
 1872         target_entry[2].info = DRAG_TAR_INFO_2;
 1873 
 1874     vbox = gtk_vbox_new(FALSE,0);
 1875     gtk_container_add(GTK_CONTAINER(win),vbox);
 1876     gtk_container_set_border_width(GTK_CONTAINER(vbox),10);
 1877     gtk_widget_show(vbox);
 1878 
 1879     f1 = gtk_frame_new(_("Temporary Image Storage Directories"));
 1880     set_font_and_color_frame(f1,PANGO_BOLD,NULL);
 1881     gtk_box_pack_start(GTK_BOX(vbox),f1,TRUE,TRUE,0);
 1882     gtk_widget_show(f1);
 1883 
 1884     scrolled_win = gtk_scrolled_window_new (NULL, NULL);
 1885     gtk_container_set_border_width (GTK_CONTAINER (scrolled_win), 5);
 1886     gtk_container_add(GTK_CONTAINER(f1),scrolled_win);
 1887     gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
 1888         GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
 1889     gtk_widget_show(scrolled_win);
 1890 
 1891     titles[0] = _("Path");
 1892     titles[1] = _("Available space");
 1893     titles[2] = _("Writeable");
 1894 
 1895     list = gtk_clist_new_with_titles(3,titles);
 1896     gtk_widget_set_size_request(GTK_WIDGET(list), -1, tbf(150));
 1897     gtk_container_add (GTK_CONTAINER (scrolled_win), list);
 1898     
 1899     clist = GTK_CLIST(list);
 1900     gtk_clist_set_column_auto_resize(clist, 2, TRUE);
 1901     clist_list = clist;
 1902 
 1903     gtk_clist_set_column_width(clist,0,tbf(270));
 1904     gtk_clist_set_column_width(clist,1,tbf(160));
 1905     gtk_clist_set_column_justification(clist, 1, GTK_JUSTIFY_CENTER);
 1906     gtk_clist_set_column_justification(clist, 2, GTK_JUSTIFY_CENTER);
 1907 
 1908     /* now fill list with current values */
 1909     loop = g_list_first(setupdata.image_dirs);
 1910     while (loop) {
 1911         strncpy(tmp, (gchar *)loop->data, MAXLINE);
 1912         data[0] = convert_for_gtk2(tmp); 
 1913         data[1] = " -"; 
 1914         if (is_dir_writeable((gchar *)loop->data) == 0) {
 1915             data[2] = T_YES;
 1916         } else {
 1917             data[2] = T_NO;
 1918         }
 1919         row = gtk_clist_append(clist,data);
 1920         gtk_clist_set_row_data(clist,row,NULL);
 1921         loop = loop->next;
 1922     }
 1923 
 1924         gtk_widget_realize(list);
 1925         if(!GTK_WIDGET_NO_WINDOW(list)) {
 1926 
 1927         gtk_drag_dest_set(list, GTK_DEST_DEFAULT_MOTION |
 1928           GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
 1929           target_entry, sizeof(target_entry) / sizeof(GtkTargetEntry),
 1930           GDK_ACTION_MOVE | GDK_ACTION_COPY);
 1931         g_signal_connect(list, "drag_data_received",
 1932           G_CALLBACK(entry_imagepath_drag_received), clist);
 1933     }
 1934     gtk_widget_show(list);
 1935 
 1936     tbl = gtk_table_new(4,8,TRUE);
 1937     gtk_table_set_row_spacings(GTK_TABLE(tbl),5);
 1938     gtk_table_set_col_spacings(GTK_TABLE(tbl),5);
 1939     gtk_table_set_col_spacing(GTK_TABLE(tbl),1,10);
 1940     gtk_table_set_col_spacing(GTK_TABLE(tbl),2,10);
 1941 
 1942     gtk_box_pack_start(GTK_BOX(vbox),tbl,FALSE,TRUE,10);
 1943     gtk_widget_show(tbl);
 1944 
 1945     l1 = rightjust_gtk_label_new(_("Total space available:"));
 1946     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,3,0,1);
 1947     gtk_widget_show(l1);
 1948 
 1949     f1 = gtk_frame_new(NULL);
 1950     gtk_frame_set_shadow_type(GTK_FRAME(f1),GTK_SHADOW_IN);
 1951     gtk_table_attach_defaults(GTK_TABLE(tbl),f1,3,6,0,1);
 1952     gtk_widget_show(f1);
 1953     define_tooltip(f1,_("Data / Audio"));
 1954 
 1955     l1 = gtk_label_new("");
 1956     updatesum_label = l1;
 1957     gtk_container_add(GTK_CONTAINER(f1),l1);
 1958     gtk_widget_show(l1);
 1959 
 1960     b1 = gtk_button_new_with_label(_("Update"));
 1961     updatebutton = b1;
 1962     gtk_table_attach_defaults(GTK_TABLE(tbl),b1,6,8,0,1);
 1963     g_signal_connect (b1, "clicked",
 1964         G_CALLBACK(update_imagepath_callback),clist);
 1965     gtk_widget_show(b1);
 1966     define_tooltip(b1,_("Calculates all currently free space in the image directories."));
 1967 
 1968     l1 = rightjust_gtk_label_new(_("Path:"));
 1969     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,2,2,3);
 1970     gtk_widget_show(l1);
 1971 
 1972     e1 = gtk_entry_new();
 1973     gtk_entry_set_max_length(GTK_ENTRY(e1), MAXLINE);
 1974     clist_entry = e1;
 1975     g_signal_connect(e1, "activate",
 1976         G_CALLBACK(entry_imagepath_callback),clist);
 1977     gtk_table_attach_defaults(GTK_TABLE(tbl),e1,2,6,2,3);
 1978     gtk_widget_show(e1);
 1979     define_tooltip(e1, _("Enter a path or click on the 'Browse' button on the right."));
 1980     gtk_drag_dest_set(e1, GTK_DEST_DEFAULT_MOTION |
 1981         GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
 1982         target_entry, sizeof(target_entry) / sizeof(GtkTargetEntry),
 1983         GDK_ACTION_MOVE | GDK_ACTION_COPY);
 1984     g_signal_connect(e1, "drag_data_received",
 1985         G_CALLBACK(entry_imagepath_drag_received), NULL);
 1986 
 1987     b1 = gtk_button_new_with_label(_("Browse"));
 1988     gtk_table_attach_defaults(GTK_TABLE(tbl),b1,6,8,2,3);
 1989     g_signal_connect (b1, "clicked",
 1990         G_CALLBACK(button_imagepath_callback),NULL);
 1991     gtk_widget_show(b1);
 1992     define_tooltip(b1,_("Displays a directory selector to pick a new image directory."));
 1993 
 1994     if (!isroot() && !setupdata.root_option_change_imagedirs) {
 1995         gtk_widget_set_sensitive(e1,FALSE);
 1996         gtk_widget_set_sensitive(b1,FALSE);
 1997     }
 1998 
 1999     b1 = gtk_button_new_with_label(_("Add"));
 2000     gtk_table_attach_defaults(GTK_TABLE(tbl),b1,2,4,3,4);
 2001     g_signal_connect(b1, "clicked",
 2002         G_CALLBACK(entry_imagepath_callback),clist);
 2003     gtk_widget_show(b1);
 2004     define_tooltip(b1,_("Adds a new image directory."));
 2005 
 2006     if (!isroot() && !setupdata.root_option_change_imagedirs) {
 2007         gtk_widget_set_sensitive(b1,FALSE);
 2008     }
 2009 
 2010     b1 = gtk_button_new_with_label(_("Remove"));
 2011     gtk_table_attach_defaults(GTK_TABLE(tbl),b1,4,6,3,4);
 2012     g_signal_connect(b1, "clicked",
 2013         G_CALLBACK(remove_imagepath_callback),clist);
 2014     gtk_widget_show(b1);
 2015     define_tooltip(b1,_("Removes the selected image directory from the list."));
 2016     if (!isroot() && !setupdata.root_option_change_imagedirs) {
 2017         gtk_widget_set_sensitive(b1,FALSE);
 2018     }
 2019 }
 2020 
 2021 
 2022 /*
 2023  * callbacks for misc-menu
 2024  */
 2025 static void dspdevice_selected(GtkWidget *item, gchar *device) {
 2026 
 2027     g_free(setupdata.dsp_device);
 2028     setupdata.dsp_device = g_strdup(device);
 2029 
 2030     /* set dsp-test-button to active when we set a dsp-device */
 2031     if (strcmp(setupdata.dsp_device,"") != 0) {
 2032         gtk_widget_set_sensitive(btn_testdsp, TRUE);
 2033     } else {
 2034         gtk_widget_set_sensitive(btn_testdsp, FALSE);
 2035     }
 2036 }
 2037 
 2038 static void dsptest_callback(GtkWidget *widget, gpointer data) {
 2039 
 2040     show_setup_dsptest();
 2041 }
 2042 
 2043 static void notifyvia_selected(GtkWidget *item, gpointer data) {
 2044 
 2045     setupdata.notify_via = 
 2046         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(item));
 2047 }
 2048 
 2049 static void notifyat_selected(GtkWidget *item, gpointer data) {
 2050 
 2051     setupdata.notify_at = GPOINTER_TO_INT(data); 
 2052 }
 2053 
 2054 static void cddb_entry1_callback(GtkWidget *widget, gpointer data) {
 2055 gchar tmp[MAXLINE];
 2056     
 2057     g_free(setupdata.cddb_host);
 2058     strcpy(tmp, gtk_entry_get_text(GTK_ENTRY(widget)));
 2059     strip_string(tmp);
 2060 
 2061     setupdata.cddb_host = g_strdup(tmp);
 2062     gtk_entry_set_text(GTK_ENTRY(widget), tmp);
 2063 }
 2064 
 2065 static void cddb_entry2_callback(GtkWidget *widget, gpointer data) {
 2066 gchar tmp[MAXLINE];
 2067     
 2068     setupdata.cddb_port = atoi(gtk_entry_get_text(GTK_ENTRY(widget)));
 2069     g_snprintf(tmp, MAXLINE,"%d",setupdata.cddb_port);
 2070     gtk_entry_set_text(GTK_ENTRY(widget),tmp);
 2071 }
 2072 
 2073 static void cddb_entry3_callback(GtkWidget *widget, gpointer data) {
 2074 gchar tmp[MAXLINE];
 2075     
 2076     g_free(setupdata.cddb_proxy_host);
 2077     strcpy(tmp, gtk_entry_get_text(GTK_ENTRY(widget)));
 2078     strip_string(tmp);
 2079 
 2080     setupdata.cddb_proxy_host = g_strdup(tmp);
 2081     gtk_entry_set_text(GTK_ENTRY(widget), tmp);
 2082 }
 2083 
 2084 static void cddb_entry4_callback(GtkWidget *widget, gpointer data) {
 2085 gchar tmp[MAXLINE];
 2086     
 2087     setupdata.cddb_proxy_port = atoi(gtk_entry_get_text(GTK_ENTRY(widget)));
 2088     g_snprintf(tmp, MAXLINE,"%d",setupdata.cddb_proxy_port);
 2089     gtk_entry_set_text(GTK_ENTRY(widget),tmp);
 2090 }
 2091 
 2092 static void cddb_use_http_selected(GtkWidget *item, gpointer data) {
 2093 gchar tmp[MAXLINE];
 2094     
 2095     setupdata.cddb_use_http = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(item));
 2096 
 2097     if (setupdata.cddb_use_http == 0) {
 2098         gtk_widget_set_sensitive(cddb_entry3, FALSE);
 2099         gtk_widget_set_sensitive(cddb_entry4, FALSE);
 2100         gtk_widget_set_sensitive(cddb_opt2, FALSE);
 2101         gtk_widget_set_sensitive(cddb_entry2, TRUE);    /* no longer http mode - restore original port */
 2102         g_snprintf(tmp, MAXLINE,"%d",setupdata.cddb_port);
 2103         gtk_entry_set_text(GTK_ENTRY(cddb_entry2),tmp);
 2104     } else {
 2105         if (setupdata.cddb_use_proxy == 1) {
 2106             gtk_widget_set_sensitive(cddb_entry3, TRUE);
 2107             gtk_widget_set_sensitive(cddb_entry4, TRUE);
 2108         }
 2109         gtk_widget_set_sensitive(cddb_opt2, TRUE);
 2110         gtk_entry_set_text(GTK_ENTRY(cddb_entry2),"80");    /* http mode uses always port 80 */
 2111         gtk_widget_set_sensitive(cddb_entry2, FALSE);
 2112     }
 2113 }
 2114 
 2115 static void cddb_use_proxy_selected(GtkWidget *item, gpointer data) {
 2116     
 2117     setupdata.cddb_use_proxy = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(item));
 2118     if (setupdata.cddb_use_http == 1 && setupdata.cddb_use_proxy == 0) {
 2119         gtk_widget_set_sensitive(cddb_entry3, FALSE);
 2120         gtk_widget_set_sensitive(cddb_entry4, FALSE);
 2121     }
 2122     if (setupdata.cddb_use_http == 1 && setupdata.cddb_use_proxy == 1) {
 2123         gtk_widget_set_sensitive(cddb_entry3, TRUE);
 2124         gtk_widget_set_sensitive(cddb_entry4, TRUE);
 2125     }
 2126 }
 2127 
 2128 static void logfile_entry_callback(GtkWidget *widget, gpointer data) {
 2129 gchar tmp[MAXLINE];
 2130     
 2131     g_free(setupdata.logfile);
 2132     strcpy(tmp, gtk_entry_get_text(GTK_ENTRY(widget)));
 2133 
 2134     convert_for_gtk2_filename(tmp);
 2135 
 2136     setupdata.logfile = g_strdup(tmp);
 2137     gtk_entry_set_text(GTK_ENTRY(widget), tmp);
 2138 }
 2139 
 2140 
 2141 /*
 2142  * called when a drag is received on the entry
 2143  */
 2144 static void entry_logfile_drag_received(GtkWidget *widget, 
 2145         GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data,
 2146         guint info, guint t, gpointer data) {
 2147 gchar *text;
 2148 gchar newdir[MAXLINE];
 2149 gchar tmp[MAXLINE];
 2150 
 2151         /* nothing received? ignore */
 2152         if(selection_data == NULL)
 2153                 return;
 2154         if(selection_data->length < 0)
 2155                 return;
 2156 
 2157         if ((info == DRAG_TAR_INFO_0) ||
 2158            (info == DRAG_TAR_INFO_1) ||
 2159            (info == DRAG_TAR_INFO_2)) {
 2160                 text = (char *) selection_data->data;
 2161                 if (extract_single_drag_filename(text, selection_data->length, newdir)) {
 2162                         /* extracted the plain filename from drag */
 2163                         if (strcmp(newdir,"") != 0) {
 2164                 dodebug(3,"Received from drag: %s\n", newdir);
 2165                 gtk_entry_set_text(data, newdir);
 2166                 strncpy(tmp, newdir, MAXLINE);
 2167                 convert_for_gtk2_filename(tmp); 
 2168                 g_free(setupdata.logfile);
 2169                 setupdata.logfile = g_strdup(tmp);
 2170                         }
 2171                 }
 2172         }
 2173 }
 2174 
 2175 static void logfile_browse_callback(GtkWidget *widget, GtkEntry *entry) {
 2176 gchar tmp[MAXLINE];
 2177 gchar tmp2[MAXLINE];
 2178 
 2179     show_file_selector(_("Select Logfile"), MODE_SAVE, (gchar *)gtk_entry_get_text(entry),tmp);
 2180     if (strcmp(tmp,"") != 0) {
 2181         gtk_entry_set_text(entry,tmp);
 2182         strncpy(tmp2, tmp, MAXLINE);
 2183         convert_for_gtk2_filename(tmp2);    
 2184         g_free(setupdata.logfile);
 2185         setupdata.logfile = g_strdup(tmp);
 2186     }
 2187 }
 2188 
 2189 static void loglevel_selected(GtkWidget *item, gpointer level) {
 2190 
 2191     setupdata.loglevel = GPOINTER_TO_INT(level);
 2192 }
 2193 
 2194 static void language_selected(GtkWidget *item, gchar *lang) {
 2195 
 2196     g_free(setupdata.language);
 2197     setupdata.language = g_strdup(lang);
 2198 }
 2199 
 2200 
 2201 /*
 2202  * draw misc-setup screen
 2203  */
 2204 static void draw_misc_setup(GtkWidget *win) {
 2205 GtkWidget *vbox;
 2206 GtkWidget *f1,*l1,*b1,*e1;
 2207 GtkWidget *tbl;
 2208 GtkWidget *omenu;
 2209 GtkWidget *menu;
 2210 GtkWidget *menu_item;
 2211 GSList *group;
 2212 GtkWidget *btn, *check;
 2213 GList *dsp;
 2214 gint i;
 2215 gint menuhistory, menuidx, menulang;
 2216 gchar tmp[MAXLINE];
 2217 static const gchar *lang_array[] = AVAIL_LANG;
 2218 GtkTargetEntry target_entry[3];
 2219 
 2220         /* required for drag&drop setup */
 2221         target_entry[0].target = DRAG_TAR_NAME_0;
 2222         target_entry[0].flags = 0;
 2223         target_entry[0].info = DRAG_TAR_INFO_0;
 2224         target_entry[1].target = DRAG_TAR_NAME_1;
 2225         target_entry[1].flags = 0;
 2226         target_entry[1].info = DRAG_TAR_INFO_1;
 2227         target_entry[2].target = DRAG_TAR_NAME_2;
 2228         target_entry[2].flags = 0;
 2229         target_entry[2].info = DRAG_TAR_INFO_2;
 2230 
 2231     vbox = gtk_vbox_new(FALSE,0);
 2232     gtk_container_add(GTK_CONTAINER(win),vbox);
 2233     gtk_container_set_border_width(GTK_CONTAINER(vbox),10);
 2234     gtk_widget_show(vbox);
 2235 
 2236     /* Audio frame */
 2237 
 2238     f1 = gtk_frame_new(_("Audio"));
 2239     set_font_and_color_frame(f1,PANGO_BOLD,NULL);
 2240     gtk_box_pack_start(GTK_BOX(vbox),f1,FALSE,TRUE,0);
 2241     gtk_widget_show(f1);
 2242 
 2243     tbl = gtk_table_new(4,8,TRUE);
 2244     gtk_container_add (GTK_CONTAINER (f1), tbl);
 2245     gtk_table_set_col_spacings(GTK_TABLE(tbl),5);
 2246     gtk_table_set_col_spacing(GTK_TABLE(tbl),2,10);
 2247     gtk_widget_show(tbl);
 2248 
 2249     l1 = rightjust_gtk_label_new(_("Audio-Device:"));
 2250     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,1,3,0,1);
 2251     gtk_widget_show(l1);
 2252 
 2253     /* get a list of all dsp-devices */
 2254     dsp = get_dsp_devices();
 2255 
 2256     omenu = gtk_option_menu_new ();
 2257     menu = gtk_menu_new();
 2258 
 2259     menuidx = 0; menuhistory = 0;
 2260     /* "none"-setting, if no devices are available */
 2261     if (!dsp) {
 2262         menu_item = gtk_menu_item_new_with_label(_("None "));
 2263         g_signal_connect(menu_item,
 2264             "activate", G_CALLBACK(dspdevice_selected),
 2265             "");
 2266         gtk_menu_append (GTK_MENU (menu), menu_item);
 2267         if (strcmp(setupdata.dsp_device,"") == 0) { 
 2268             menuhistory = menuidx; 
 2269         }
 2270         menuidx++;
 2271         gtk_widget_show (menu_item);
 2272     }
 2273 
 2274     while (dsp) {
 2275         menu_item = gtk_menu_item_new_with_label((gchar *)dsp->data);
 2276         g_signal_connect(menu_item,
 2277             "activate", G_CALLBACK(dspdevice_selected),
 2278             (gchar *)dsp->data);
 2279         gtk_menu_append (GTK_MENU (menu), menu_item);
 2280 
 2281         /* if nothing is selected so far, select the first entry */
 2282         if (strcmp(setupdata.dsp_device, "") == 0) {
 2283             setupdata.dsp_device = g_strdup((gchar *)dsp->data);
 2284         }
 2285         if (setupdata.dsp_device != NULL) {
 2286             if (strcmp(setupdata.dsp_device,(gchar *)dsp->data) == 0) {
 2287                 menuhistory = menuidx;
 2288             }
 2289         }
 2290         menuidx++;
 2291         gtk_widget_show (menu_item);
 2292 
 2293         dsp = dsp->next;
 2294     }
 2295     
 2296     gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
 2297     gtk_option_menu_set_history(GTK_OPTION_MENU (omenu),menuhistory);
 2298     gtk_table_attach_defaults(GTK_TABLE(tbl),omenu,3,6,0,1);
 2299     gtk_widget_show(omenu);
 2300     define_tooltip(omenu,_("The soundcard device. Used to play warning sounds or audio tracks."));
 2301 
 2302     b1 = gtk_button_new_with_label(_("Test"));
 2303     btn_testdsp = b1;
 2304     g_signal_connect (b1, "clicked",
 2305         G_CALLBACK(dsptest_callback),NULL);
 2306     gtk_table_attach_defaults(GTK_TABLE(tbl),b1,6,7,0,1);
 2307     gtk_widget_show(b1);
 2308     define_tooltip(b1,_("Plays a demo sample on the soundcard to verify if it's working correctly."));
 2309 
 2310     /* only allow test when device is set */
 2311     if (strcmp(setupdata.dsp_device,"") == 0) {
 2312         gtk_widget_set_sensitive(btn_testdsp, FALSE);
 2313     }
 2314 
 2315     l1 = rightjust_gtk_label_new(_("Notify-Beeps via:"));
 2316     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,0,3,1,2);
 2317     gtk_widget_show(l1);
 2318 
 2319     btn = gtk_radio_button_new_with_label(NULL,_("Audio-Device"));
 2320     gtk_table_attach_defaults(GTK_TABLE(tbl),btn,3,5,1,2);
 2321     gtk_widget_show(btn);
 2322     group = gtk_radio_button_group (GTK_RADIO_BUTTON(btn));
 2323     btn = gtk_radio_button_new_with_label(group,_("internal speaker"));
 2324     g_signal_connect(btn,"clicked",
 2325         G_CALLBACK(notifyvia_selected),NULL);
 2326     gtk_table_attach_defaults(GTK_TABLE(tbl),btn,5,8,1,2);
 2327     gtk_widget_show(btn);
 2328     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(btn),
 2329         setupdata.notify_via);
 2330     
 2331     l1 = rightjust_gtk_label_new(_("at events:"));
 2332     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,1,3,2,3);
 2333     gtk_widget_show(l1);
 2334 
 2335     btn = gtk_radio_button_new_with_label(NULL,_("never"));
 2336     g_signal_connect(btn,"clicked",
 2337         G_CALLBACK(notifyat_selected),GINT_TO_POINTER(0));
 2338     gtk_table_attach_defaults(GTK_TABLE(tbl),btn,3,5,2,3);
 2339     gtk_widget_show(btn);
 2340     if (setupdata.notify_at == 0) 
 2341         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(btn),1);
 2342     group = gtk_radio_button_group (GTK_RADIO_BUTTON(btn));
 2343     btn = gtk_radio_button_new_with_label(group,_("always"));
 2344     g_signal_connect(btn,"clicked",
 2345         G_CALLBACK(notifyat_selected),GINT_TO_POINTER(1));
 2346     gtk_table_attach_defaults(GTK_TABLE(tbl),btn,5,8,2,3);
 2347     gtk_widget_show(btn);
 2348     if (setupdata.notify_at == 1) 
 2349         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(btn),1);
 2350     group = gtk_radio_button_group (GTK_RADIO_BUTTON(btn));
 2351     btn = gtk_radio_button_new_with_label(group,_("on completion"));
 2352     g_signal_connect(btn,"clicked",
 2353         G_CALLBACK(notifyat_selected),GINT_TO_POINTER(2));
 2354     gtk_table_attach_defaults(GTK_TABLE(tbl),btn,3,5,3,4);
 2355     gtk_widget_show(btn);
 2356     if (setupdata.notify_at == 2) 
 2357         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(btn),1);
 2358     group = gtk_radio_button_group (GTK_RADIO_BUTTON(btn));
 2359     btn = gtk_radio_button_new_with_label(group,_("on warnings"));
 2360     gtk_table_attach_defaults(GTK_TABLE(tbl),btn,5,8,3,4);
 2361     g_signal_connect(btn,"clicked",
 2362         G_CALLBACK(notifyat_selected),GINT_TO_POINTER(3));
 2363     gtk_widget_show(btn);
 2364     if (setupdata.notify_at == 3) 
 2365         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(btn),1);
 2366 
 2367     /* Network frame */
 2368     
 2369     f1 = gtk_frame_new(_("Network"));
 2370     set_font_and_color_frame(f1,PANGO_BOLD,NULL);
 2371     gtk_box_pack_start(GTK_BOX(vbox),f1,FALSE,TRUE,10);
 2372     gtk_widget_show(f1);
 2373 
 2374     tbl = gtk_table_new(2,32,TRUE);
 2375     gtk_container_set_border_width(GTK_CONTAINER (tbl),5);
 2376     gtk_container_add (GTK_CONTAINER (f1), tbl);
 2377     gtk_table_set_row_spacings(GTK_TABLE(tbl),5);
 2378     gtk_table_set_col_spacings(GTK_TABLE(tbl),5);
 2379     gtk_table_set_col_spacing(GTK_TABLE(tbl),11,10);
 2380     gtk_widget_show(tbl);
 2381 
 2382     l1 = rightjust_gtk_label_new(_("CDDB-Server:"));
 2383     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,1,12,0,1);
 2384     gtk_widget_show(l1);
 2385 
 2386     e1 = gtk_entry_new();
 2387     gtk_entry_set_max_length(GTK_ENTRY(e1), MAXENTRY);
 2388     cddb_entry1 = e1;
 2389     g_signal_connect(e1, "activate",
 2390         G_CALLBACK(cddb_entry1_callback),NULL);
 2391     gtk_table_attach_defaults(GTK_TABLE(tbl),e1,12,19,0,1);
 2392     if (setupdata.cddb_host != NULL) {
 2393         gtk_entry_set_text(GTK_ENTRY(e1),setupdata.cddb_host);
 2394     }
 2395     gtk_widget_show(e1);
 2396     define_tooltip(e1,_("The CDDB-Server to connect to in order to download track-titles from the internet."));
 2397 
 2398     l1 = rightjust_gtk_label_new(_("Port:"));
 2399     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,19,22,0,1);
 2400     gtk_widget_show(l1);
 2401 
 2402     e1 = gtk_entry_new();
 2403     gtk_entry_set_max_length(GTK_ENTRY(e1), MAXENTRY);
 2404     cddb_entry2 = e1;
 2405     g_signal_connect(e1, "activate",
 2406         G_CALLBACK(cddb_entry2_callback),NULL);
 2407     gtk_table_attach_defaults(GTK_TABLE(tbl),e1,22,25,0,1);
 2408     g_snprintf(tmp, MAXLINE,"%d",setupdata.cddb_port);
 2409     gtk_entry_set_text(GTK_ENTRY(e1),tmp);
 2410     gtk_widget_show(e1);
 2411 
 2412     check = gtk_check_button_new_with_label(_("Use HTTP"));
 2413     cddb_opt1 = check;
 2414     g_signal_connect(check,"clicked",
 2415         G_CALLBACK(cddb_use_http_selected), NULL);
 2416     gtk_table_attach_defaults(GTK_TABLE(tbl),check,25,32,0,1);
 2417     gtk_widget_show(check);
 2418     define_tooltip(check, _("Use the HTTP protocol rather than the CDDB protocol to access the CDDB-Server."));
 2419 
 2420     l1 = rightjust_gtk_label_new(_("via HTTP-Proxy:"));
 2421     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,1,12,1,2);
 2422     gtk_widget_show(l1);
 2423 
 2424     e1 = gtk_entry_new();
 2425     gtk_entry_set_max_length(GTK_ENTRY(e1), MAXENTRY);
 2426     cddb_entry3 = e1;
 2427     g_signal_connect(e1, "activate",
 2428         G_CALLBACK(cddb_entry3_callback),NULL);
 2429     gtk_table_attach_defaults(GTK_TABLE(tbl),e1,12,19,1,2);
 2430     if (setupdata.cddb_proxy_host != NULL) {
 2431         gtk_entry_set_text(GTK_ENTRY(e1),setupdata.cddb_proxy_host);
 2432     }
 2433     gtk_widget_show(e1);
 2434     define_tooltip(e1,_("If you are behind a firewall you may require to use a HTTP-proxy to reach the CDDB-Server. If your proxy requires authentication you can use the following syntax: \"user:password@proxyhost\""));
 2435 
 2436     l1 = rightjust_gtk_label_new(_("Port:"));
 2437     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,19,22,1,2);
 2438     gtk_widget_show(l1);
 2439 
 2440     e1 = gtk_entry_new();
 2441     gtk_entry_set_max_length(GTK_ENTRY(e1), MAXENTRY);
 2442     cddb_entry4 = e1;
 2443     g_signal_connect(e1, "activate",
 2444         G_CALLBACK(cddb_entry4_callback),NULL);
 2445     gtk_table_attach_defaults(GTK_TABLE(tbl),e1,22,25,1,2);
 2446     g_snprintf(tmp, MAXLINE,"%d",setupdata.cddb_proxy_port);
 2447     gtk_entry_set_text(GTK_ENTRY(e1),tmp);
 2448     gtk_widget_show(e1);
 2449 
 2450     check = gtk_check_button_new_with_label(_("Use Proxy"));
 2451     cddb_opt2 = check;
 2452     g_signal_connect(check,"clicked",
 2453         G_CALLBACK(cddb_use_proxy_selected), NULL);
 2454     gtk_table_attach_defaults(GTK_TABLE(tbl),check,25,32,1,2);
 2455     gtk_widget_show(check);
 2456     define_tooltip(check, _("Don't connect directly to the CDDB-Server, but use a HTTP-proxy instead."));
 2457 
 2458     /* set editable fields according to current settings */
 2459     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cddb_opt1),
 2460         setupdata.cddb_use_http);
 2461     cddb_use_http_selected(cddb_opt1, NULL);
 2462     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cddb_opt2),
 2463         setupdata.cddb_use_proxy);
 2464     cddb_use_proxy_selected(cddb_opt2, NULL);
 2465 
 2466     /* Logging frame */
 2467 
 2468     f1 = gtk_frame_new(_("Logging"));
 2469     set_font_and_color_frame(f1,PANGO_BOLD,NULL);
 2470     gtk_box_pack_start(GTK_BOX(vbox),f1,FALSE,TRUE,0);
 2471     gtk_widget_show(f1);
 2472 
 2473     tbl = gtk_table_new(2,8,TRUE);
 2474     gtk_container_set_border_width(GTK_CONTAINER (tbl),5);
 2475     gtk_container_add (GTK_CONTAINER (f1), tbl);
 2476     gtk_table_set_row_spacings(GTK_TABLE(tbl),5);
 2477     gtk_table_set_col_spacings(GTK_TABLE(tbl),5);
 2478     gtk_table_set_col_spacing(GTK_TABLE(tbl),2,10);
 2479     gtk_widget_show(tbl);
 2480 
 2481     l1 = rightjust_gtk_label_new(_("Logfile:"));
 2482     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,1,3,0,1);
 2483     gtk_widget_show(l1);
 2484 
 2485     e1 = gtk_entry_new();
 2486     gtk_entry_set_max_length(GTK_ENTRY(e1), MAXLINE);
 2487     log_entry = e1;
 2488     g_signal_connect(e1, "activate",
 2489         G_CALLBACK(logfile_entry_callback),NULL);
 2490     gtk_table_attach_defaults(GTK_TABLE(tbl),e1,3,6,0,1);
 2491     gtk_widget_show(e1);
 2492         gtk_drag_dest_set(e1, GTK_DEST_DEFAULT_MOTION |
 2493                 GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
 2494                 target_entry, sizeof(target_entry) / sizeof(GtkTargetEntry),
 2495                 GDK_ACTION_MOVE | GDK_ACTION_COPY);
 2496         g_signal_connect(e1, "drag_data_received",
 2497                 G_CALLBACK(entry_logfile_drag_received), GTK_ENTRY(e1));
 2498     if (setupdata.logfile != NULL) {
 2499         gtk_entry_set_text(GTK_ENTRY(e1),setupdata.logfile);
 2500     }
 2501     gtk_widget_show(e1);
 2502     define_tooltip(e1,_("The name of the file that logs all actions of X-CD-Roast."));
 2503 
 2504     b1 = gtk_button_new_with_label(_("Browse"));
 2505     g_signal_connect (b1, "clicked",
 2506         G_CALLBACK(logfile_browse_callback),GTK_ENTRY(e1));
 2507     gtk_table_attach_defaults(GTK_TABLE(tbl),b1,6,8,0,1);
 2508     gtk_widget_show(b1);
 2509 
 2510     if (!isroot() && !setupdata.root_option_change_logoptions) {
 2511         gtk_widget_set_sensitive(e1,FALSE);
 2512         gtk_widget_set_sensitive(b1,FALSE);
 2513     }
 2514 
 2515     l1 = rightjust_gtk_label_new(_("Loglevel:"));
 2516     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,1,3,1,2);
 2517     gtk_widget_show(l1);
 2518 
 2519     omenu = gtk_option_menu_new ();
 2520     menu = gtk_menu_new();
 2521 
 2522     /* loglevels */
 2523     menu_item = gtk_menu_item_new_with_label(_("Off"));
 2524     g_signal_connect(menu_item, "activate",
 2525         G_CALLBACK(loglevel_selected),GINT_TO_POINTER(0));
 2526     gtk_menu_append (GTK_MENU (menu), menu_item);
 2527     gtk_widget_show (menu_item);
 2528     menu_item = gtk_menu_item_new_with_label(_("Sparse"));
 2529     g_signal_connect(menu_item, "activate",
 2530         G_CALLBACK(loglevel_selected),GINT_TO_POINTER(1));
 2531     gtk_menu_append (GTK_MENU (menu), menu_item);
 2532     gtk_widget_show (menu_item);
 2533     menu_item = gtk_menu_item_new_with_label(_("Medium"));
 2534     g_signal_connect(menu_item, "activate",
 2535         G_CALLBACK(loglevel_selected),GINT_TO_POINTER(2));
 2536     gtk_menu_append (GTK_MENU (menu), menu_item);
 2537     gtk_widget_show (menu_item);
 2538     menu_item = gtk_menu_item_new_with_label(_("Verbose"));
 2539     g_signal_connect(menu_item, "activate",
 2540         G_CALLBACK(loglevel_selected),GINT_TO_POINTER(3));
 2541     gtk_menu_append (GTK_MENU (menu), menu_item);
 2542     gtk_widget_show (menu_item);
 2543 
 2544     gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
 2545     gtk_option_menu_set_history(GTK_OPTION_MENU (omenu), 
 2546         setupdata.loglevel);
 2547     gtk_table_attach_defaults(GTK_TABLE(tbl),omenu,3,6,1,2);
 2548     gtk_widget_show(omenu);
 2549     define_tooltip(omenu,_("How much information is logged into the logfile."));
 2550 
 2551     if (!isroot() && !setupdata.root_option_change_logoptions) {
 2552         gtk_widget_set_sensitive(omenu,FALSE);
 2553     }
 2554 
 2555     /* Internationalization frame */
 2556 
 2557     f1 = gtk_frame_new(_("Internationalization"));
 2558     set_font_and_color_frame(f1,PANGO_BOLD,NULL);
 2559     gtk_box_pack_start(GTK_BOX(vbox),f1,FALSE,TRUE,10);
 2560     gtk_widget_show(f1);
 2561 
 2562     tbl = gtk_table_new(1,8,TRUE);
 2563     gtk_container_set_border_width(GTK_CONTAINER (tbl),5);
 2564     gtk_table_set_row_spacings(GTK_TABLE(tbl),5);
 2565     gtk_table_set_col_spacings(GTK_TABLE(tbl),10);
 2566     gtk_container_add (GTK_CONTAINER (f1), tbl);
 2567     gtk_widget_show(tbl);
 2568 
 2569     l1 = rightjust_gtk_label_new(_("Language:"));
 2570     gtk_table_attach_defaults(GTK_TABLE(tbl),l1,1,3,0,1);
 2571     gtk_widget_show(l1);
 2572 
 2573     omenu = gtk_option_menu_new ();
 2574     menu = gtk_menu_new();
 2575 
 2576     i = 0; 
 2577     menulang = 0;
 2578 
 2579     /* add default setting */
 2580 
 2581 #if ENABLE_NLS
 2582 
 2583     menu_item = gtk_menu_item_new_with_label(_("System default"));
 2584     g_signal_connect(menu_item, "activate",
 2585         G_CALLBACK(language_selected),"");
 2586     gtk_menu_append (GTK_MENU (menu), menu_item);
 2587     gtk_widget_show (menu_item);
 2588 
 2589     while(lang_array[i]) {
 2590 
 2591         /* count valid languages */
 2592         if (strcmp(setupdata.language, lang_array[i+1]) == 0) 
 2593             menulang = i/2+1;
 2594 
 2595         menu_item = gtk_menu_item_new_with_label(
 2596             lang_array[i]);
 2597         g_signal_connect(menu_item, "activate",
 2598             G_CALLBACK(language_selected),(gpointer)lang_array[i+1]);
 2599         gtk_menu_append (GTK_MENU (menu), menu_item);
 2600         gtk_widget_show (menu_item);
 2601         i+=2;
 2602     }
 2603 #else
 2604     menu_item = gtk_menu_item_new_with_label(lang_array[0]);
 2605     gtk_menu_append (GTK_MENU (menu), menu_item);
 2606     gtk_widget_show (menu_item);
 2607     gtk_widget_set_sensitive(omenu,FALSE);
 2608 #endif
 2609 
 2610     gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
 2611     gtk_option_menu_set_history(GTK_OPTION_MENU (omenu), menulang);
 2612     gtk_table_attach_defaults(GTK_TABLE(tbl),omenu,3,6,0,1);
 2613     gtk_widget_show(omenu);
 2614     define_tooltip(omenu,_("Set the language: You have to leave setup to activate this setting. Please note that switching directly to languages that require a different font will not work correctly."));
 2615 
 2616 }
 2617 
 2618 
 2619 /*
 2620  * callbacks for misc-setup2 "Options"
 2621  */
 2622 static void options_selected(GtkWidget *item, gpointer nr) {
 2623 gint sel;
 2624 
 2625     sel = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(item));
 2626 
 2627     switch (GPOINTER_TO_INT(nr)) {
 2628         case 0:
 2629             setupdata.option_tooltips = sel;
 2630             break;
 2631         case 1:
 2632             setupdata.option_autoraise = sel;
 2633             break;
 2634         case 2:
 2635             setupdata.option_savepos = sel;
 2636             break;
 2637         case 3:
 2638             setupdata.option_personimage = sel;
 2639             break;
 2640         case 4:
 2641             setupdata.option_overwritewarn = sel;
 2642             break;
 2643         case 5:
 2644             setupdata.option_autodelete = sel;
 2645             break;
 2646         case 6:
 2647             setupdata.option_titleprogress = sel;
 2648             break;
 2649         case 7:
 2650             setupdata.option_displaycdtext = sel;
 2651             break;
 2652     }
 2653 }
 2654 
 2655 
 2656 /*
 2657  * draw misc-setup screen part 2 "Options"
 2658  */
 2659 static void draw_misc2_setup(GtkWidget *win) {
 2660 GtkWidget *vbox;
 2661 GtkWidget *f1;
 2662 GtkWidget *tbl;
 2663 GtkWidget *check;
 2664 /* GtkWidget *scrolled_win; */
 2665 
 2666     vbox = gtk_vbox_new(FALSE,0);
 2667     gtk_container_add(GTK_CONTAINER(win),vbox);
 2668     gtk_container_set_border_width(GTK_CONTAINER(vbox),10);
 2669     gtk_widget_show(vbox);
 2670 
 2671     f1 = gtk_frame_new(_("Options"));
 2672     set_font_and_color_frame(f1,PANGO_BOLD,NULL);
 2673     gtk_box_pack_start(GTK_BOX(vbox),f1,FALSE,TRUE,0);
 2674     gtk_widget_show(f1);
 2675 
 2676     tbl = gtk_table_new(9,8,TRUE);
 2677     gtk_container_set_border_width(GTK_CONTAINER (tbl),5);
 2678     gtk_container_add (GTK_CONTAINER (f1), tbl);
 2679     gtk_widget_show(tbl);
 2680 
 2681     check = gtk_check_button_new_with_label(_("Tooltips help"));
 2682     g_signal_connect(check,"clicked",
 2683         G_CALLBACK(options_selected),GINT_TO_POINTER(0));
 2684     gtk_table_attach_defaults(GTK_TABLE(tbl),check,1,7,0,1);
 2685     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 2686         setupdata.option_tooltips);
 2687     gtk_widget_show(check);
 2688     define_tooltip(check, _("Display help when pausing the mouse pointer over a button."));
 2689 
 2690     check = gtk_check_button_new_with_label(_("Auto-raise/lower windows"));
 2691     g_signal_connect(check,"clicked",
 2692         G_CALLBACK(options_selected),GINT_TO_POINTER(1));
 2693     gtk_table_attach_defaults(GTK_TABLE(tbl),check,1,7,1,2);
 2694     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 2695         setupdata.option_autoraise);
 2696     gtk_widget_show(check);
 2697     gtk_widget_set_sensitive(check, FALSE);
 2698     define_tooltip(check, _("Not implemented yet"));
 2699 
 2700     check = gtk_check_button_new_with_label(_("Save window positions"));
 2701     g_signal_connect(check,"clicked",
 2702         G_CALLBACK(options_selected),GINT_TO_POINTER(2));
 2703     gtk_table_attach_defaults(GTK_TABLE(tbl),check,1,7,2,3);
 2704     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 2705         setupdata.option_savepos);
 2706     gtk_widget_show(check);
 2707     define_tooltip(check, _("When you save your configuration also save the last used window position and size."));
 2708 
 2709     check = gtk_check_button_new_with_label(_("Personalize image filenames"));
 2710     g_signal_connect(check,"clicked",
 2711         G_CALLBACK(options_selected),GINT_TO_POINTER(3));
 2712     gtk_table_attach_defaults(GTK_TABLE(tbl),check,1,7,3,4);
 2713     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 2714         setupdata.option_personimage);
 2715     gtk_widget_show(check);
 2716     gtk_widget_set_sensitive(check, FALSE);
 2717     define_tooltip(check, _("Not implemented yet"));
 2718 
 2719     check = gtk_check_button_new_with_label(_("Warn before overwriting images"));
 2720     g_signal_connect(check,"clicked",
 2721         G_CALLBACK(options_selected),GINT_TO_POINTER(4));
 2722     gtk_table_attach_defaults(GTK_TABLE(tbl),check,1,7,4,5);
 2723     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 2724         setupdata.option_overwritewarn);
 2725     gtk_widget_show(check);
 2726     define_tooltip(check, _("When reading or creating new tracks do warn before overwriting existing tracks on the hard drive."));
 2727 
 2728     check = gtk_check_button_new_with_label(_("Automatically delete images after burn"));
 2729     g_signal_connect(check,"clicked",
 2730         G_CALLBACK(options_selected),GINT_TO_POINTER(5));
 2731     gtk_table_attach_defaults(GTK_TABLE(tbl),check,1,7,5,6);
 2732     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 2733         setupdata.option_autodelete);
 2734     gtk_widget_show(check);
 2735     gtk_widget_set_sensitive(check, FALSE);
 2736     define_tooltip(check, _("Not implemented yet"));
 2737 
 2738     check = gtk_check_button_new_with_label(_("Progress-indicator in window-title"));
 2739     g_signal_connect(check,"clicked",
 2740         G_CALLBACK(options_selected),GINT_TO_POINTER(6));
 2741     gtk_table_attach_defaults(GTK_TABLE(tbl),check,1,7,6,7);
 2742     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 2743         setupdata.option_titleprogress);
 2744     gtk_widget_show(check);
 2745     define_tooltip(check, _("Shows the percentage of the current write/read process in the titlebar. Allows to minimize X-CD-Roast and still see the progress in some window-managers."));
 2746 
 2747     check = gtk_check_button_new_with_label(_("Display CD-Text if available"));
 2748     g_signal_connect(check,"clicked",
 2749         G_CALLBACK(options_selected),GINT_TO_POINTER(7));
 2750     gtk_table_attach_defaults(GTK_TABLE(tbl),check,1,7,7,8);
 2751     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 2752         setupdata.option_displaycdtext);
 2753     gtk_widget_show(check);
 2754     define_tooltip(check, _("Display CD-Text in Info-Screen when available by disc drive and audio CD."));
 2755 }
 2756 
 2757 #if (USER_HOST_MODE == 1)
 2758 
 2759 /*
 2760  * callbacks for usermode "Users"
 2761  */
 2762 static void root_options_selected(GtkWidget *item, gpointer nr) {
 2763 gint sel;
 2764 
 2765     sel = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(item));
 2766 
 2767     switch (GPOINTER_TO_INT(nr)) {
 2768         case 0:
 2769             setupdata.root_option_change_writer = sel;
 2770             break;
 2771         case 1:
 2772             setupdata.root_option_change_writeparam = sel;
 2773             break;
 2774         case 2:
 2775             setupdata.root_option_change_reader = sel;
 2776             break;
 2777         case 3:
 2778             setupdata.root_option_change_readparam = sel;
 2779             break;
 2780         case 4:
 2781             setupdata.root_option_change_imagedirs = sel;
 2782             break;
 2783         case 5:
 2784             setupdata.root_option_change_logoptions = sel;
 2785             break;
 2786     }
 2787 }
 2788 
 2789 gboolean entry_duplicate_foreach_func (GtkTreeModel *model,
 2790                 GtkTreePath  *path,
 2791                 GtkTreeIter  *iter,
 2792                 gchar *newentry)
 2793 {
 2794 gchar *listentry;
 2795 
 2796     gtk_tree_model_get (model, iter, 0, &listentry, -1);
 2797 
 2798     if (strcmp(listentry, newentry) == 0) {
 2799         g_free(listentry);
 2800         /* return empty entry to show it already exists */
 2801         strcpy(newentry, "");
 2802         return (TRUE);
 2803     }
 2804 
 2805     g_free(listentry);
 2806     return (FALSE);
 2807 }
 2808 
 2809 /*
 2810  * read all entries from a treeview list and store into GList
 2811  */
 2812 
 2813 static void get_entries_from_list(GtkTreeView *clist, GList **outlist) {
 2814 GtkTreeModel *model;
 2815 GtkTreeIter  iter;
 2816 gboolean valid;
 2817 gchar *listuser;
 2818 
 2819     /* loop over all entries */
 2820     model = gtk_tree_view_get_model(clist);
 2821     valid = gtk_tree_model_get_iter_first(model, &iter);
 2822 
 2823         while (valid)
 2824         {
 2825         gtk_tree_model_get (model, &iter, 0, &listuser, -1);
 2826         *outlist = g_list_append(*outlist, listuser);
 2827 
 2828         valid = gtk_tree_model_iter_next(model, &iter);
 2829     }   
 2830 }
 2831 
 2832 /* 
 2833  * return the path of the last element in a tree view list, or NULL
 2834  * if empty.
 2835  */
 2836 static GtkTreePath *entry_get_last_path(GtkTreeView *clist) {
 2837 GtkTreeModel *model;
 2838 GtkTreeIter  iter, orgiter;
 2839 gboolean valid;
 2840 
 2841     /* loop over all entries */
 2842     model = gtk_tree_view_get_model(clist);
 2843     valid = gtk_tree_model_get_iter_first(model, &iter);
 2844     if (!valid) 
 2845         return NULL;
 2846 
 2847     while(valid) {
 2848         orgiter = iter;
 2849         valid = gtk_tree_model_iter_next(model, &iter);
 2850     }
 2851 
 2852     /* iter is now on last, convert to path */
 2853     return (gtk_tree_model_get_path(model, &orgiter));
 2854 }
 2855 
 2856  
 2857 static void entry_rootusers_callback(GtkWidget *widget, GtkTreeSelection *selection) {
 2858 gchar user[MAXLINE], userbak[MAXLINE], tmp2[MAXLINE];
 2859 gchar *data[1];
 2860 gint stat;
 2861 GtkTreeModel *model;
 2862 GtkListStore *store;
 2863 GtkTreeIter iter;
 2864 GtkTreePath *path;
 2865 
 2866     strncpy(user,gtk_entry_get_text(GTK_ENTRY(rootusers_entry)), MAXLINE);
 2867     strip_string(user);
 2868     strncpy(userbak, user, MAXLINE);
 2869 
 2870     /* ignore empty entry */
 2871     if (strcmp(user,"") == 0) {
 2872         return;
 2873     }
 2874 
 2875     /* loop over all entries to find if we are a duplicate */
 2876     model = gtk_tree_view_get_model(GTK_TREE_VIEW(users_clist));
 2877     gtk_tree_model_foreach(model, (GtkTreeModelForeachFunc)entry_duplicate_foreach_func, user);
 2878 
 2879     /* ignore duplicate entry */
 2880     if (strcmp(user,"") == 0) {
 2881         g_snprintf(tmp2,MAXLINE,_("User \"%s\" already added"), userbak);
 2882         show_dialog(ICO_WARN,tmp2,T_OK,NULL,NULL,0);    
 2883         return;
 2884     }
 2885 
 2886     /* now check if user does exist */
 2887     if (!check_pw_user(user)) {
 2888         g_snprintf(tmp2,MAXLINE,_("User \"%s\" does not exist.\nAdd anyway?"),user);
 2889         stat = show_dialog(ICO_WARN,tmp2,T_NO,T_YES,NULL,0);    
 2890         if (stat == 0) return;
 2891     }
 2892 
 2893     data[0] = convert_for_gtk2(user);
 2894 
 2895     store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(users_clist)));
 2896     gtk_list_store_append(store, &iter);
 2897     gtk_list_store_set(store, &iter, 0, data[0], -1);
 2898 
 2899     /* scroll to newly added entry */
 2900     path = entry_get_last_path(GTK_TREE_VIEW(users_clist));
 2901     if (path) 
 2902         gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(users_clist),
 2903             path, NULL, TRUE, 1.0, 0.0);
 2904 
 2905     gtk_entry_set_text(GTK_ENTRY(rootusers_entry),"");
 2906 
 2907 }
 2908 
 2909 gboolean remove_selected_foreach_func (GtkTreeModel  *model,
 2910                               GtkTreePath   *path,
 2911                               GtkTreeIter   *iter,
 2912                               GList       **rowref_list)
 2913 {
 2914 GtkTreeRowReference  *rowref;
 2915 
 2916     /* create list to selected entries */
 2917         rowref = gtk_tree_row_reference_new(model, path);
 2918     *rowref_list = g_list_append(*rowref_list, rowref);
 2919 
 2920     return(FALSE);
 2921 }
 2922 
 2923 static void remove_selected_entries(GtkListStore *store, GtkTreeSelection *selection) {
 2924 GtkTreeIter iter;
 2925 GList *rr_list = NULL;    /* list of GtkTreeRowReferences to remove */
 2926 GList *node;
 2927 GtkTreePath *path;
 2928 
 2929     /* collect the tree row references for each selected item */
 2930     gtk_tree_selection_selected_foreach(selection, 
 2931         (GtkTreeSelectionForeachFunc) remove_selected_foreach_func, 
 2932         &rr_list);
 2933 
 2934     /* remove list of entries */
 2935     for (node=rr_list; node != NULL; node=node->next) {
 2936             path = gtk_tree_row_reference_get_path((GtkTreeRowReference*)node->data);
 2937         if (path) {
 2938                 if (gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path))
 2939                 {
 2940                         gtk_list_store_remove(store, &iter);
 2941                 }
 2942         }
 2943     }
 2944     g_list_foreach(rr_list, (GFunc) gtk_tree_row_reference_free, NULL);
 2945     g_list_free(rr_list);
 2946 }
 2947 
 2948 
 2949 static void remove_rootusers_callback(GtkWidget *widget, GtkTreeSelection *selection) {
 2950 GtkListStore *store;
 2951 GtkTreeModel *model;
 2952 GtkTreeIter iter;
 2953 
 2954     store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(users_clist)));
 2955     model = gtk_tree_view_get_model(GTK_TREE_VIEW(users_clist));
 2956 
 2957     if (gtk_tree_model_get_iter_first(model, &iter) == FALSE || 
 2958             gtk_tree_selection_count_selected_rows(selection) == 0) {
 2959         show_dialog(ICO_WARN,_("No user selected to remove"),T_OK,NULL,NULL,0); 
 2960         return;
 2961     }
 2962     remove_selected_entries(store, selection);
 2963 }
 2964 
 2965 
 2966 static void entry_roothosts_callback(GtkWidget *widget, GtkTreeSelection *selection) {
 2967 gchar host[MAXLINE], hostbak[MAXLINE], tmp2[MAXLINE];
 2968 gchar *data[1];
 2969 GtkTreeModel *model;
 2970 GtkListStore *store;
 2971 GtkTreeIter iter;
 2972 GtkTreePath *path;
 2973 
 2974     strncpy(host,gtk_entry_get_text(GTK_ENTRY(roothosts_entry)), MAXLINE);
 2975     strip_string(host);
 2976     strncpy(hostbak, host, MAXLINE);
 2977 
 2978     /* ignore empty entry */
 2979     if (strcmp(host,"") == 0) {
 2980         return;
 2981     }
 2982 
 2983     /* loop over all entries to find if we are a duplicate */
 2984     model = gtk_tree_view_get_model(GTK_TREE_VIEW(hosts_clist));
 2985     gtk_tree_model_foreach(model, (GtkTreeModelForeachFunc)entry_duplicate_foreach_func, host);
 2986 
 2987     /* ignore duplicate entry */
 2988     if (strcmp(host,"") == 0) {
 2989         g_snprintf(tmp2,MAXLINE,_("Host \"%s\" already added"), hostbak);
 2990         show_dialog(ICO_WARN,tmp2,T_OK,NULL,NULL,0);    
 2991         return;
 2992     }
 2993 
 2994     data[0] = convert_for_gtk2(host);
 2995 
 2996     store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(hosts_clist)));
 2997     gtk_list_store_append(store, &iter);
 2998     gtk_list_store_set(store, &iter, 0, data[0], -1);
 2999 
 3000     /* scroll to newly added entry */
 3001     path = entry_get_last_path(GTK_TREE_VIEW(hosts_clist));
 3002     if (path) 
 3003         gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(hosts_clist),
 3004             path, NULL, TRUE, 1.0, 0.0);
 3005 
 3006     gtk_entry_set_text(GTK_ENTRY(roothosts_entry),"");
 3007 }
 3008 
 3009 
 3010 static void remove_roothosts_callback(GtkWidget *widget, GtkTreeSelection *selection) {
 3011 GtkListStore *store;
 3012 GtkTreeModel *model;
 3013 GtkTreeIter iter;
 3014 
 3015     store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(hosts_clist)));
 3016     model = gtk_tree_view_get_model(GTK_TREE_VIEW(hosts_clist));
 3017 
 3018     if (gtk_tree_model_get_iter_first(model, &iter) == FALSE || 
 3019             gtk_tree_selection_count_selected_rows(selection) == 0) {
 3020         show_dialog(ICO_WARN,_("No host selected to remove"),T_OK,NULL,NULL,0); 
 3021         return;
 3022     }
 3023     remove_selected_entries(store, selection);
 3024 }
 3025 
 3026 static void root_users_selected(GtkWidget *item, gpointer data) {
 3027 
 3028         setupdata.root_users_access = GPOINTER_TO_INT(data); 
 3029 }
 3030 
 3031 static void root_hosts_selected(GtkWidget *item, gpointer data) {
 3032 
 3033         setupdata.root_hosts_access = GPOINTER_TO_INT(data); 
 3034 }
 3035 
 3036 
 3037 static void init_entry_list(GtkWidget *list) {
 3038 GtkCellRenderer *renderer;
 3039 GtkTreeViewColumn *column;
 3040 GtkListStore *store;
 3041 
 3042     renderer = gtk_cell_renderer_text_new ();
 3043     column = gtk_tree_view_column_new_with_attributes("List Items",
 3044             renderer, "text", 0, NULL);
 3045     gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
 3046 
 3047     store = gtk_list_store_new(1, G_TYPE_STRING);
 3048 
 3049     gtk_tree_view_set_model(GTK_TREE_VIEW(list), 
 3050             GTK_TREE_MODEL(store));
 3051 
 3052     g_object_unref(store);
 3053 }
 3054 
 3055 
 3056 static void add_to_entry_list(GtkWidget *list, const gchar *str) {
 3057 GtkListStore *store;
 3058 GtkTreeIter iter;
 3059 
 3060     store = GTK_LIST_STORE(gtk_tree_view_get_model
 3061             (GTK_TREE_VIEW(list)));
 3062 
 3063     gtk_list_store_append(store, &iter);
 3064     gtk_list_store_set(store, &iter, 0, str, -1);
 3065 }
 3066 
 3067 
 3068 /*
 3069  * draw user-host menu "Users"
 3070  */
 3071 static void draw_usermode_setup(GtkWidget *win) {
 3072 GtkWidget *vbox, *hbox;
 3073 GtkWidget *tbl, *tbl2;
 3074 GtkWidget *f1, *b1, *e1;
 3075 GtkWidget *scrolled_win;
 3076 GtkWidget *list;
 3077 GtkWidget *btn, *check;
 3078 GSList *group;
 3079 GList *loop;
 3080 gchar *data[1];
 3081 gchar tmp[MAXLINE];
 3082 GtkTreeSelection *selection; 
 3083 
 3084     vbox = gtk_vbox_new(FALSE,0);
 3085     gtk_container_add(GTK_CONTAINER(win),vbox);
 3086     gtk_container_set_border_width(GTK_CONTAINER(vbox),10);
 3087     gtk_widget_show(vbox);
 3088 
 3089     /* left and right frame */
 3090     tbl = gtk_table_new(1,2,TRUE);
 3091     gtk_table_set_col_spacing(GTK_TABLE(tbl),0,5);
 3092     gtk_box_pack_start(GTK_BOX(vbox),tbl,FALSE,TRUE,0);
 3093     gtk_widget_show(tbl);
 3094 
 3095     f1 = gtk_frame_new(_("Access by users:"));
 3096     set_font_and_color_frame(f1,PANGO_BOLD,NULL);
 3097     gtk_table_attach_defaults(GTK_TABLE(tbl),f1,0,1,0,1);
 3098     gtk_widget_show(f1);
 3099 
 3100     tbl2 = gtk_table_new(5,14,TRUE);
 3101     gtk_table_set_col_spacing(GTK_TABLE(tbl2),9,5);
 3102     gtk_container_set_border_width(GTK_CONTAINER (tbl2),5);
 3103     gtk_container_add(GTK_CONTAINER(f1),tbl2);
 3104     gtk_widget_show(tbl2);
 3105 
 3106     scrolled_win = gtk_scrolled_window_new (NULL, NULL);
 3107     gtk_table_attach_defaults(GTK_TABLE(tbl2),scrolled_win,6,14,0,3);
 3108     gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
 3109         GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
 3110     gtk_widget_show(scrolled_win);
 3111 
 3112     list = gtk_tree_view_new();
 3113     gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE);
 3114     users_clist = GTK_TREE_VIEW(list);
 3115 
 3116     gtk_container_add (GTK_CONTAINER (scrolled_win), list);
 3117 
 3118     init_entry_list(list);
 3119 
 3120     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
 3121     gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
 3122 
 3123     gtk_widget_show(list);
 3124 
 3125     /* now add current values */
 3126         loop = g_list_first(setupdata.root_users_lists);
 3127     while (loop) {
 3128                 strncpy(tmp, (gchar *)loop->data, MAXLINE);
 3129                 data[0] = convert_for_gtk2(tmp); 
 3130         add_to_entry_list(list, data[0]);
 3131                 loop = loop->next;
 3132         }
 3133 
 3134     e1 = gtk_entry_new();
 3135     gtk_entry_set_max_length(GTK_ENTRY(e1), MAXENTRY);
 3136     rootusers_entry = e1;
 3137         g_signal_connect(e1, "activate",
 3138                 G_CALLBACK(entry_rootusers_callback),selection);
 3139     gtk_table_attach_defaults(GTK_TABLE(tbl2),e1,6,14,3,4);
 3140     gtk_widget_show(e1);
 3141     define_tooltip(e1, _("Enter here an username which should be allowed or denied access for X-CD-Roast. Press Return or click on the \"Add\"-button to put it on the list."));
 3142 
 3143     /* add button */
 3144     b1 = gtk_button_new_with_label(_("Add"));
 3145         g_signal_connect(b1, "clicked",
 3146                 G_CALLBACK(entry_rootusers_callback),selection);
 3147     gtk_table_attach_defaults(GTK_TABLE(tbl2),b1,6,10,4,5);
 3148     gtk_widget_show(b1);
 3149     define_tooltip(b1, _("Add the username given in the entry-field to the list."));
 3150 
 3151     /* remove button */
 3152     b1 = gtk_button_new_with_label(_("Remove"));
 3153         g_signal_connect(b1, "clicked",
 3154                 G_CALLBACK(remove_rootusers_callback),selection);
 3155     gtk_table_attach_defaults(GTK_TABLE(tbl2),b1,10,14,4,5);
 3156     gtk_widget_show(b1);
 3157     define_tooltip(b1, _("Remove all selected users from the list."));
 3158 
 3159     btn = gtk_radio_button_new_with_label(NULL,_("Allow all"));
 3160     g_signal_connect(btn,"clicked",
 3161         G_CALLBACK(root_users_selected),GINT_TO_POINTER(0));
 3162     gtk_table_attach_defaults(GTK_TABLE(tbl2),btn,0,6,0,1);
 3163     gtk_widget_show(btn);
 3164     define_tooltip(btn, _("All users are allowed to start X-CD-Roast."));
 3165         if (setupdata.root_users_access == 0) 
 3166                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(btn),1);
 3167     group = gtk_radio_button_group (GTK_RADIO_BUTTON(btn));
 3168 
 3169     btn = gtk_radio_button_new_with_label(group,_("None allowed"));
 3170     g_signal_connect(btn,"clicked",
 3171         G_CALLBACK(root_users_selected),GINT_TO_POINTER(1));
 3172     gtk_table_attach_defaults(GTK_TABLE(tbl2),btn,0,6,1,2);
 3173     gtk_widget_show(btn);
 3174     define_tooltip(btn, _("No users are allowed to start X-CD-Roast (except root)."));
 3175         if (setupdata.root_users_access == 1) 
 3176                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(btn),1);
 3177     group = gtk_radio_button_group (GTK_RADIO_BUTTON(btn));
 3178 
 3179     btn = gtk_radio_button_new_with_label(group,_("All in list"));
 3180     g_signal_connect(btn,"clicked",
 3181         G_CALLBACK(root_users_selected),GINT_TO_POINTER(2));
 3182     gtk_table_attach_defaults(GTK_TABLE(tbl2),btn,0,6,2,3);
 3183     gtk_widget_show(btn);
 3184     define_tooltip(btn, _("Only the users which were added to the list are allowed to start X-CD-Roast."));
 3185         if (setupdata.root_users_access == 2) 
 3186                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(btn),1);
 3187     group = gtk_radio_button_group (GTK_RADIO_BUTTON(btn));
 3188 
 3189     btn = gtk_radio_button_new_with_label(group,_("All, but listed"));
 3190     g_signal_connect(btn,"clicked",
 3191         G_CALLBACK(root_users_selected),GINT_TO_POINTER(3));
 3192     gtk_table_attach_defaults(GTK_TABLE(tbl2),btn,0,6,3,4);
 3193     gtk_widget_show(btn);
 3194     define_tooltip(btn, _("All users on the list are not allowed to start X-CD-Roast. All others may use it."));
 3195         if (setupdata.root_users_access == 3) 
 3196                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(btn),1);
 3197 
 3198     /* right frame */
 3199     f1 = gtk_frame_new(_("Access by hosts:"));
 3200     set_font_and_color_frame(f1,PANGO_BOLD,NULL);
 3201     gtk_table_attach_defaults(GTK_TABLE(tbl),f1,1,2,0,1);
 3202     gtk_widget_show(f1);
 3203 
 3204     tbl2 = gtk_table_new(5,14,TRUE);
 3205     gtk_table_set_col_spacing(GTK_TABLE(tbl2),9,5);
 3206     gtk_container_set_border_width(GTK_CONTAINER (tbl2),5);
 3207     gtk_container_add(GTK_CONTAINER(f1),tbl2);
 3208     gtk_widget_show(tbl2);
 3209 
 3210     scrolled_win = gtk_scrolled_window_new (NULL, NULL);
 3211     gtk_table_attach_defaults(GTK_TABLE(tbl2),scrolled_win,6,14,0,3);
 3212     gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
 3213         GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
 3214     gtk_widget_show(scrolled_win);
 3215 
 3216     list = gtk_tree_view_new();
 3217     gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE);
 3218     hosts_clist = GTK_TREE_VIEW(list);
 3219 
 3220     gtk_container_add (GTK_CONTAINER (scrolled_win), list);
 3221 
 3222     init_entry_list(list);
 3223 
 3224     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
 3225     gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
 3226 
 3227     gtk_widget_show(list);
 3228 
 3229     /* now add current values */
 3230         loop = g_list_first(setupdata.root_hosts_lists);
 3231     while (loop) {
 3232                 strncpy(tmp, (gchar *)loop->data, MAXLINE);
 3233                 data[0] = convert_for_gtk2(tmp); 
 3234         add_to_entry_list(list, data[0]);
 3235                 loop = loop->next;
 3236         }
 3237 
 3238     e1 = gtk_entry_new();
 3239     gtk_entry_set_max_length(GTK_ENTRY(e1), MAXENTRY);
 3240     roothosts_entry = e1;
 3241         g_signal_connect(e1, "activate",
 3242                 G_CALLBACK(entry_roothosts_callback), selection);
 3243     gtk_table_attach_defaults(GTK_TABLE(tbl2),e1,6,14,3,4);
 3244     gtk_widget_show(e1);
 3245     define_tooltip(e1, _("Enter here a hostname of a computer which may run X-CD-Roast. This makes sense, when using the same config-file on more than one host (e.g. pool-installations)."));
 3246 
 3247     /* add button */
 3248     b1 = gtk_button_new_with_label(_("Add"));
 3249         g_signal_connect(b1, "clicked",
 3250                 G_CALLBACK(entry_roothosts_callback), selection);
 3251     gtk_table_attach_defaults(GTK_TABLE(tbl2),b1,6,10,4,5);
 3252     gtk_widget_show(b1);
 3253     define_tooltip(b1, _("Add the hostname given in the entry-field to the list."));
 3254 
 3255     /* remove button */
 3256     b1 = gtk_button_new_with_label(_("Remove"));
 3257         g_signal_connect(b1, "clicked",
 3258                 G_CALLBACK(remove_roothosts_callback), selection);
 3259     gtk_table_attach_defaults(GTK_TABLE(tbl2),b1,10,14,4,5);
 3260     gtk_widget_show(b1);
 3261     define_tooltip(b1, _("Remove all selected hosts from the list."));
 3262 
 3263     btn = gtk_radio_button_new_with_label(NULL,_("Allow all"));
 3264     g_signal_connect(btn,"clicked",
 3265         G_CALLBACK(root_hosts_selected),GINT_TO_POINTER(0));
 3266     gtk_table_attach_defaults(GTK_TABLE(tbl2),btn,0,6,0,1);
 3267     gtk_widget_show(btn);
 3268     define_tooltip(btn, _("X-CD-Roast may be started on all hosts."));
 3269         if (setupdata.root_hosts_access == 0) 
 3270                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(btn),1);
 3271     group = gtk_radio_button_group (GTK_RADIO_BUTTON(btn));
 3272 
 3273     btn = gtk_radio_button_new_with_label(group,_("None allowed"));
 3274     g_signal_connect(btn,"clicked",
 3275         G_CALLBACK(root_hosts_selected),GINT_TO_POINTER(1));
 3276     gtk_table_attach_defaults(GTK_TABLE(tbl2),btn,0,6,1,2);
 3277     gtk_widget_show(btn);
 3278     define_tooltip(btn, _("X-CD-Roast won't start on any host (except when run by root)."));
 3279         if (setupdata.root_hosts_access == 1) 
 3280                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(btn),1);
 3281     group = gtk_radio_button_group (GTK_RADIO_BUTTON(btn));
 3282 
 3283     btn = gtk_radio_button_new_with_label(group,_("All in list"));
 3284     g_signal_connect(btn,"clicked",
 3285         G_CALLBACK(root_hosts_selected),GINT_TO_POINTER(2));
 3286     gtk_table_attach_defaults(GTK_TABLE(tbl2),btn,0,6,2,3);
 3287     gtk_widget_show(btn);
 3288     define_tooltip(btn, _("Only the hosts in the list may start X-CD-Roast."));
 3289         if (setupdata.root_hosts_access == 2) 
 3290                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(btn),1);
 3291     group = gtk_radio_button_group (GTK_RADIO_BUTTON(btn));
 3292 
 3293     btn = gtk_radio_button_new_with_label(group,_("All, but listed"));
 3294     g_signal_connect(btn,"clicked",
 3295         G_CALLBACK(root_hosts_selected),GINT_TO_POINTER(3));
 3296     gtk_table_attach_defaults(GTK_TABLE(tbl2),btn,0,6,3,4);
 3297     gtk_widget_show(btn);
 3298     define_tooltip(btn, _("Only hosts which are not listed can start X-CD-Roast."));
 3299         if (setupdata.root_hosts_access == 3) 
 3300                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(btn),1);
 3301 
 3302     /* options */
 3303 
 3304     f1 = gtk_frame_new(_("Users are allowed to:"));
 3305     set_font_and_color_frame(f1,PANGO_BOLD,NULL);
 3306     gtk_box_pack_start(GTK_BOX(vbox),f1,FALSE,TRUE,10);
 3307     gtk_widget_show(f1);
 3308 
 3309     tbl = gtk_table_new(4,16,TRUE);
 3310     gtk_container_set_border_width(GTK_CONTAINER (tbl),5);
 3311     gtk_container_add (GTK_CONTAINER (f1), tbl);
 3312     gtk_widget_show(tbl);
 3313 
 3314     if (!curset.isProDVD) {
 3315         check = gtk_check_button_new_with_label(_("change disc writer"));
 3316     } else {
 3317         check = gtk_check_button_new_with_label(_("change CD/DVD Writer Device"));
 3318     }
 3319     g_signal_connect(check,"clicked",
 3320         G_CALLBACK(root_options_selected),GINT_TO_POINTER(0));
 3321     gtk_table_attach_defaults(GTK_TABLE(tbl),check,1,9,0,1);
 3322     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 3323         setupdata.root_option_change_writer);
 3324     gtk_widget_show(check);
 3325     define_tooltip(check, _("If enabled, then the user is allowed to change the settings for the disc writers. Else the setting given by root must be used."));
 3326 
 3327     check = gtk_check_button_new_with_label(_("change write parameters"));
 3328     g_signal_connect(check,"clicked",
 3329         G_CALLBACK(root_options_selected),GINT_TO_POINTER(1));
 3330     gtk_table_attach_defaults(GTK_TABLE(tbl),check,9,16,0,1);
 3331     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 3332         setupdata.root_option_change_writeparam);
 3333     gtk_widget_show(check);
 3334     define_tooltip(check, _("If enabled, then the user is allowed the change the write parameters for the disc writer (e.g. Speed and FIFO-Buffer-Size)."));
 3335 
 3336     if (!curset.isProDVD) {
 3337         check = gtk_check_button_new_with_label(_("change disc reader"));
 3338     } else {
 3339         check = gtk_check_button_new_with_label(_("change CD/DVD Reader Device"));
 3340     }
 3341     g_signal_connect(check,"clicked",
 3342         G_CALLBACK(root_options_selected),GINT_TO_POINTER(2));
 3343     gtk_table_attach_defaults(GTK_TABLE(tbl),check,1,9,1,2);
 3344     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 3345         setupdata.root_option_change_reader);
 3346     gtk_widget_show(check);
 3347     define_tooltip(check, _("If enabled, then the user is allowed to change the settings for the disc readers. Else the settings given by root must be used."));
 3348 
 3349     check = gtk_check_button_new_with_label(_("change read parameters"));
 3350     g_signal_connect(check,"clicked",
 3351         G_CALLBACK(root_options_selected),GINT_TO_POINTER(3));
 3352     gtk_table_attach_defaults(GTK_TABLE(tbl),check,9,16,1,2);
 3353     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 3354         setupdata.root_option_change_readparam);
 3355     gtk_widget_show(check);
 3356     define_tooltip(check, _("If enabled, then the user is allowed the change the read parameters for the disc reader (e.g. Speed and Paranoia settings)."));
 3357 
 3358     check = gtk_check_button_new_with_label(_("change Image Storage Directories"));
 3359     g_signal_connect(check,"clicked",
 3360         G_CALLBACK(root_options_selected),GINT_TO_POINTER(4));
 3361     gtk_table_attach_defaults(GTK_TABLE(tbl),check,1,9,2,3);
 3362     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 3363         setupdata.root_option_change_imagedirs);
 3364     gtk_widget_show(check);
 3365     define_tooltip(check, _("If enabled, then the user may give his own image-directories (best where he got write permissions). Else the directories specified by root must be used (should be also a directory where any user can write into)."));
 3366 
 3367     check = gtk_check_button_new_with_label(_("change Logging-Options"));
 3368     g_signal_connect(check,"clicked",
 3369         G_CALLBACK(root_options_selected),GINT_TO_POINTER(5));
 3370     gtk_table_attach_defaults(GTK_TABLE(tbl),check,1,9,3,4);
 3371     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
 3372         setupdata.root_option_change_logoptions);
 3373     gtk_widget_show(check);
 3374     define_tooltip(check, _("If enabled, then the user may change the logging parameters (the path of the logfile and the loglevel)."));
 3375 
 3376     hbox = gtk_alignment_new(0.5, 0.5, 0.5, 0);
 3377     gtk_box_pack_start(GTK_BOX(vbox),hbox,TRUE,TRUE,10);
 3378     gtk_widget_show(hbox);
 3379 }
 3380 #endif
 3381 
 3382 /*
 3383  * called by the setup-button
 3384  */
 3385 void create_setup() {
 3386 GtkWidget *side_t;
 3387 GtkWidget *side_t_btn2;
 3388 GtkWidget *side_t_btn3;
 3389 GtkWidget *side_t_btn4;
 3390 GtkWidget *notebook,*f1,*l1,*f2,*l2,*f3,*l3,*f4,*l4,*f5,*l5;
 3391 #if (USER_HOST_MODE == 1)
 3392 GtkWidget *f6, *l6;
 3393 #endif
 3394 GtkWidget *head,*head_l;
 3395 GtkWidget *xcdroast_logo;
 3396 gint i;
 3397 
 3398     /* backup the current setup-data */
 3399     memcpy(&bak_setupdata,&setupdata,sizeof(setup_data_t)); 
 3400     bak_setupdata.image_dirs = NULL;
 3401     copy_glist(&bak_setupdata.image_dirs, setupdata.image_dirs); 
 3402 #if (USER_HOST_MODE == 1)
 3403     if (isroot()) {
 3404         bak_setupdata.root_users_lists = NULL;
 3405         copy_glist(&bak_setupdata.root_users_lists, setupdata.root_users_lists); 
 3406         bak_setupdata.root_hosts_lists = NULL;
 3407         copy_glist(&bak_setupdata.root_hosts_lists, setupdata.root_hosts_lists); 
 3408     }
 3409 #endif
 3410     bak_setupdata.dsp_device = g_strdup(setupdata.dsp_device);
 3411     bak_setupdata.mix_device = g_strdup(setupdata.mix_device);
 3412     bak_setupdata.cddb_host = g_strdup(setupdata.cddb_host);
 3413     bak_setupdata.cddb_proxy_host = g_strdup(setupdata.cddb_proxy_host);
 3414     bak_setupdata.logfile = g_strdup(setupdata.logfile);
 3415 
 3416     /* backup the dynamic part of the readerwriter structure too */
 3417     bak_writerreader = g_new0(writerreader_bak_t *, MAXDEVICES);
 3418     i = 0;
 3419     while(writerreaderdevs[i] != NULL) {
 3420         bak_writerreader[i] = g_new0(writerreader_bak_t, 1);
 3421         bak_writerreader[i]->devnr = writerreaderdevs[i]->devnr;
 3422         bak_writerreader[i]->values[0] = writerreaderdevs[i]->writer_drvmode;
 3423         bak_writerreader[i]->values[1] = writerreaderdevs[i]->writer_mode;
 3424         bak_writerreader[i]->values[2] = writerreaderdevs[i]->writer_speed;
 3425         bak_writerreader[i]->values[3] = writerreaderdevs[i]->writer_fifo;
 3426         bak_writerreader[i]->values[4] = writerreaderdevs[i]->audioread_speed;
 3427         bak_writerreader[i]->values[5] = writerreaderdevs[i]->audioread_overlap;
 3428         bak_writerreader[i]->values[6] = writerreaderdevs[i]->audioread_paranoiareadahead;
 3429         bak_writerreader[i]->values[7] = writerreaderdevs[i]->audioread_paranoiaminoverlap;
 3430         bak_writerreader[i]->values[8] = writerreaderdevs[i]->audioread_paranoiaretries;
 3431         bak_writerreader[i]->values[9] = writerreaderdevs[i]->audioread_useparanoia;
 3432         bak_writerreader[i]->values[10] = writerreaderdevs[i]->audioread_showhiddentrack;
 3433 
 3434         i++;
 3435     }
 3436 
 3437     clear_sidespace();
 3438     clear_workspace();
 3439 
 3440     /* load the small xcdrlogo logo */
 3441     xcdroast_logo = display_logo(img.xcdrlogo_small, "[LOGO]");
 3442 
 3443     /* sidespace */
 3444     side_t = gtk_table_new(10,1, TRUE);
 3445     gtk_table_set_row_spacings(GTK_TABLE(side_t),10);
 3446     gtk_box_pack_start(GTK_BOX(sidespace), side_t,TRUE,TRUE,0);
 3447 
 3448     head = gtk_frame_new(NULL);
 3449     gtk_frame_set_shadow_type(GTK_FRAME(head),GTK_SHADOW_NONE);
 3450     gtk_widget_set_size_request(head,0,45);
 3451     gtk_table_attach_defaults(GTK_TABLE(side_t), head, 0,1,0,1);
 3452     gtk_widget_show(head);
 3453     gtk_container_add(GTK_CONTAINER(head), xcdroast_logo);
 3454 #if DISPLAY_SIDEBAR_LOGO
 3455     gtk_widget_show(xcdroast_logo);
 3456 #endif
 3457 
 3458         side_t_btn2 = gtk_button_new_with_label (_("Save configuration"));
 3459         side_t_btn3 = gtk_button_new_with_label (T_OK);
 3460         side_t_btn4 = gtk_button_new_with_label (T_CANCEL);
 3461 
 3462     g_signal_connect (side_t_btn2, "clicked",
 3463                 G_CALLBACK(menu_setup_save),NULL);
 3464 
 3465     g_signal_connect (side_t_btn3, "clicked",
 3466                 G_CALLBACK(menu_setup_ok),NULL);
 3467 
 3468     g_signal_connect (side_t_btn4, "clicked",
 3469                 G_CALLBACK(menu_setup_cancel),NULL);
 3470 
 3471 
 3472         gtk_table_attach_defaults(GTK_TABLE(side_t), side_t_btn2, 0,1,5,6);
 3473         gtk_widget_show(side_t_btn2);
 3474         define_tooltip(side_t_btn2,_("Saves your current configuration."));
 3475 
 3476         gtk_table_attach_defaults(GTK_TABLE(side_t), side_t_btn3, 0,1,7,8);
 3477         gtk_widget_show(side_t_btn3);
 3478         define_tooltip(side_t_btn3,_("Accept the current configuration and return to main menu."));
 3479 
 3480         gtk_table_attach_defaults(GTK_TABLE(side_t), side_t_btn4, 0,1,8,9);
 3481         gtk_widget_show(side_t_btn4);
 3482         define_tooltip(side_t_btn4,_("Cancel all changes and return to main menu."));
 3483 
 3484         gtk_widget_show(side_t);
 3485     gtk_widget_show(sidespace);
 3486 
 3487     /* draw workspace */
 3488 
 3489     head = gtk_frame_new(NULL);
 3490     gtk_frame_set_shadow_type(GTK_FRAME(head),GTK_SHADOW_IN);
 3491     gtk_widget_set_size_request(head, -1, 45);
 3492     gtk_box_pack_start(GTK_BOX(workspace), head,FALSE,TRUE,0);
 3493     gtk_widget_show(head);
 3494     head_l = gtk_label_new(_("Setup"));
 3495     set_font_and_color(head_l,PANGO_BIG,NULL);
 3496     gtk_container_add(GTK_CONTAINER(head),head_l);
 3497     gtk_widget_show(head_l);
 3498     gtk_widget_show(workspace);
 3499 
 3500     notebook = gtk_notebook_new();
 3501     gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
 3502     gtk_box_pack_start(GTK_BOX(workspace), notebook,TRUE,TRUE,10);
 3503     gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
 3504     gtk_widget_show(notebook);
 3505 
 3506     l1 = gtk_label_new(_("Device-Scan"));
 3507     f1 = gtk_frame_new(NULL);
 3508     gtk_container_set_border_width (GTK_CONTAINER (f1), 10);
 3509     gtk_widget_show_all(f1);
 3510     gtk_notebook_append_page(GTK_NOTEBOOK (notebook),f1,l1);
 3511     draw_scsi_scan(f1);
 3512 
 3513     if (!curset.isProDVD) {
 3514         l2 = gtk_label_new(_("CD/DVD/BD Settings"));
 3515     } else {
 3516         l2 = gtk_label_new(_("CD/DVD Settings"));
 3517     }
 3518     f2 = gtk_frame_new(NULL);
 3519     gtk_container_set_border_width (GTK_CONTAINER (f2), 10);
 3520     gtk_widget_show_all(f2);
 3521     gtk_notebook_append_page(GTK_NOTEBOOK (notebook),f2,l2);
 3522     draw_cd_setup(f2);
 3523 
 3524     l3 = gtk_label_new(_("HD Settings"));
 3525     f3 = gtk_frame_new(NULL);
 3526     gtk_container_set_border_width (GTK_CONTAINER (f3), 10);
 3527     gtk_widget_show_all(f3);
 3528     gtk_notebook_append_page(GTK_NOTEBOOK (notebook),f3,l3);
 3529     draw_hd_setup(f3);
 3530 
 3531     l4 = gtk_label_new(_("Miscellaneous"));
 3532     f4 = gtk_frame_new(NULL);
 3533     gtk_container_set_border_width (GTK_CONTAINER (f4), 10);
 3534     gtk_widget_show_all(f4);
 3535     gtk_notebook_append_page(GTK_NOTEBOOK (notebook),f4,l4);
 3536     draw_misc_setup(f4);
 3537 
 3538     l5 = gtk_label_new(_("Options"));
 3539     f5 = gtk_frame_new(NULL);
 3540     gtk_container_set_border_width (GTK_CONTAINER (f5), 10);
 3541     gtk_widget_show_all(f5);
 3542     gtk_notebook_append_page(GTK_NOTEBOOK (notebook),f5,l5);
 3543     draw_misc2_setup(f5);
 3544 
 3545 #if (USER_HOST_MODE == 1)
 3546     if (isroot()) {
 3547         l6 = gtk_label_new(_("Users"));
 3548         f6 = gtk_frame_new(NULL);
 3549         gtk_container_set_border_width (GTK_CONTAINER (f6), 10);
 3550         gtk_widget_show_all(f6);
 3551         gtk_notebook_append_page(GTK_NOTEBOOK (notebook),f6,l6);
 3552         draw_usermode_setup(f6);
 3553     }
 3554 #endif
 3555 
 3556     /* check if found any optical drive at all */
 3557     if (writerreaderdevs[0] == NULL) {
 3558         /* no devices found */
 3559         show_dialog(ICO_WARN, _("No CD/DVD/BD drive detected.\n\nIf you want to use a remote device over the network,\nplease see the X-CD-Roast manual / FAQ how to do that."), T_OK, NULL, NULL, 0);
 3560     }   
 3561 }
 3562 
 3563 
 3564 /*
 3565  * called on delete event
 3566  */
 3567 static gint nrs_dialog_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) {
 3568 
 3569     if (gtk_main_level() > 0)
 3570             gtk_main_quit();
 3571 
 3572     nrs_dialog_done = -1;
 3573     return (TRUE);
 3574 }
 3575 
 3576 
 3577 static void nrs_dialog_btn_press(GtkWidget *widget, gpointer data) {
 3578 
 3579     if (gtk_main_level() > 0)
 3580             gtk_main_quit();
 3581 
 3582     nrs_dialog_done = GPOINTER_TO_INT(data);
 3583 }
 3584 
 3585 
 3586 /*
 3587  * show dialog for device scanning
 3588  * a big and a small version for manual scanning only
 3589  */
 3590 gint create_device_scanning(gint scanparam, gint manual, gint withlogo, gchar *devicestr) {
 3591 GtkWidget *dialog, *l1, *f1, *vbox, *xcdroast_logo;
 3592 GtkWidget *vbox2, *scrolled_win, *txt, *sep, *hbox, *b1;
 3593 gchar tmp[MAXLINE];
 3594 GdkCursor *cursor;
 3595 PangoFontDescription *font;
 3596 
 3597     dodebug(8, "displaying create_device_scanning\n");
 3598 
 3599     dialog = my_gtk_dialog_new();
 3600     nrs_dialog = dialog;
 3601     set_xcdr_title(dialog, NULL, -1);
 3602     gtk_window_set_policy(GTK_WINDOW(dialog), FALSE, TRUE, FALSE);
 3603     gtk_widget_set_size_request(dialog, tbf(400), -1);
 3604     gtk_widget_realize(dialog);
 3605 
 3606     /* make sure our window is always on top */
 3607     gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(toplevel));
 3608 
 3609         g_signal_connect (dialog, "delete_event",
 3610                 G_CALLBACK (nrs_dialog_delete_event), (gpointer) dialog);
 3611 
 3612     vbox = gtk_vbox_new(FALSE,0);
 3613     gtk_container_add(GTK_CONTAINER(dialog),vbox);
 3614     gtk_widget_show(vbox);
 3615 
 3616     /* load the half scaled logo */
 3617     if (withlogo) {
 3618         xcdroast_logo = display_logo(img.xcdrlogo_middle, "[LOGO]");
 3619             gtk_box_pack_start(GTK_BOX(vbox),xcdroast_logo,FALSE,FALSE,0);
 3620             gtk_widget_show(xcdroast_logo);
 3621 
 3622         g_snprintf(tmp,MAXLINE,_("Version %s"),XCDROAST_VERSION);
 3623         l1 = gtk_label_new(tmp);    
 3624         gtk_label_set_justify(GTK_LABEL(l1),GTK_JUSTIFY_CENTER);
 3625         set_font_and_color(l1,NULL,"red");
 3626         gtk_box_pack_start(GTK_BOX(vbox),l1,FALSE,FALSE,0);
 3627         gtk_widget_show(l1);
 3628     }
 3629 
 3630     if (!manual) { 
 3631         f1 = gtk_frame_new(NULL);
 3632     } else {
 3633         f1 = gtk_frame_new(_("Scanning for new devices"));
 3634         set_font_and_color_frame(f1,PANGO_BOLD,NULL);
 3635     }
 3636     gtk_box_pack_start(GTK_BOX(vbox),f1,TRUE,TRUE,0);
 3637     gtk_container_set_border_width(GTK_CONTAINER (f1),5);
 3638     gtk_widget_show(f1);
 3639 
 3640 
 3641     vbox2 = gtk_vbox_new(FALSE,0);
 3642     gtk_container_set_border_width(GTK_CONTAINER (vbox2),5);
 3643 
 3644     if (!manual) {
 3645         l1 = gtk_label_new(_("Scanning for devices"));
 3646         set_font_and_color(l1,PANGO_BOLD,NULL);
 3647         gtk_label_set_justify(GTK_LABEL(l1),GTK_JUSTIFY_CENTER);
 3648         gtk_box_pack_start(GTK_BOX(vbox2),l1,FALSE,FALSE,0);
 3649         gtk_widget_show(l1);
 3650     }
 3651 
 3652     l1 = gtk_label_new(_("Scanning for CD/DVD/BD-Writers and CD/DVD/BD-Readers.\nOn some configurations this can take a while."));
 3653     gtk_label_set_justify(GTK_LABEL(l1),GTK_JUSTIFY_CENTER);
 3654     gtk_box_pack_start(GTK_BOX(vbox2),l1,FALSE,FALSE,10);
 3655     gtk_widget_show(l1);
 3656 
 3657     scrolled_win = gtk_scrolled_window_new (NULL, NULL);
 3658     gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
 3659         GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
 3660     gtk_box_pack_start(GTK_BOX(vbox2),scrolled_win,TRUE,TRUE,5);
 3661     gtk_widget_show(scrolled_win);
 3662 
 3663     font = pango_font_description_from_string(PANGO_MONOSPACE);
 3664 
 3665     txt = gtk_text_view_new();
 3666     gtk_text_view_set_editable(GTK_TEXT_VIEW(txt), FALSE);
 3667     gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(txt), GTK_WRAP_NONE);
 3668     gtk_container_add(GTK_CONTAINER(scrolled_win), txt);
 3669     gtk_widget_set_size_request(txt, 0, 100);
 3670     gtk_widget_modify_font(txt, font);
 3671     gtk_widget_show(txt);
 3672 
 3673     sep = gtk_hseparator_new();
 3674     gtk_box_pack_start(GTK_BOX(vbox2),sep,FALSE,FALSE,5);
 3675     gtk_widget_show(sep);
 3676 
 3677     hbox = gtk_hbox_new(FALSE,0);
 3678     gtk_box_pack_start(GTK_BOX(vbox2),hbox,FALSE,TRUE,5);
 3679     gtk_widget_show(hbox);
 3680 
 3681     b1 = gtk_button_new_with_label(T_OK);
 3682     g_signal_connect (b1, "clicked",
 3683                 G_CALLBACK(nrs_dialog_btn_press), GINT_TO_POINTER(0));
 3684     gtk_box_pack_start(GTK_BOX(hbox),b1,TRUE,TRUE,5);
 3685     gtk_widget_set_sensitive(b1, FALSE);
 3686     gtk_widget_show(b1);
 3687 
 3688 
 3689     gtk_container_add(GTK_CONTAINER(f1),vbox2);
 3690     gtk_widget_show(vbox2);
 3691 
 3692     if (GTK_WIDGET_MAPPED(toplevel)) {
 3693         gtk_grab_add(dialog);
 3694     }
 3695 
 3696     /* also set watch cursor on scan window itself */
 3697         cursor = gdk_cursor_new(GDK_WATCH);
 3698         gdk_window_set_cursor(GTK_WIDGET(dialog)->window,cursor);
 3699 
 3700     my_center_dialog(dialog);
 3701     gtk_widget_show(dialog);
 3702 
 3703     /* update window */
 3704     gtk_widget_queue_draw(dialog);
 3705         wait_and_process_events();
 3706 
 3707     /* fill textbox and do the actual scanning */
 3708     if (!manual) {
 3709         scanbus_new(txt, scanparam);
 3710     } else {
 3711         /* the syntax used to scan for REMOTE scsi devices */
 3712         if (strncmp(devicestr,"REMOTE:", 7) == 0 && 
 3713             strstr(devicestr+7, ":") == 0) {
 3714             scanbus_rscsi(devicestr, txt);  
 3715         } else {
 3716             scanbus_new_single(devicestr, txt);
 3717         }
 3718     }
 3719 
 3720     /* unlock ok button */
 3721     gtk_widget_set_sensitive(b1, TRUE);
 3722 
 3723         gdk_window_set_cursor(GTK_WIDGET(dialog)->window,NULL);
 3724         if (cursor) 
 3725             gdk_cursor_destroy (cursor);
 3726 
 3727         /* now wait until button is pressed */
 3728         gtk_main();
 3729 
 3730         if (GTK_WIDGET_MAPPED(toplevel)) {
 3731                 gtk_grab_remove(GTK_WIDGET(dialog));
 3732         }
 3733 
 3734         /* remove dialog window */
 3735         gtk_widget_destroy(dialog);
 3736         wait_and_process_events();
 3737 
 3738 
 3739     return (nrs_dialog_done);
 3740 }
 3741