/[graveman]/graveman/current/src/matos.c
ViewVC logotype

Diff of /graveman/current/src/matos.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18 by scresto, Mon Feb 28 01:28:09 2005 UTC revision 1.19 by scresto, Wed Mar 2 00:19:58 2005 UTC
# Line 551  _DEB("ici LDST => %s\n", Ldst); Line 551  _DEB("ici LDST => %s\n", Ldst);
551    return Lstatus;    return Lstatus;
552  }  }
553    
554    void set_waitwindow_title(gboolean Ainsert, gint Atypecd, gint Anum, Tgrave *Awaitg)
555    {
556      gchar Lcd[_BUF_SIZE];
557      gchar Ltitle[_BUF_SIZE];
558      gchar *Ldrivelib = sc_grave_get_datav(Awaitg, "devicetitle%d", Anum);
559      GtkLabel *Llabel = GTK_LABEL(sc_grave_get_widgetv(Awaitg, "label%d", Anum));
560    
561      *Ltitle=0;
562      *Lcd = 0;
563      if (Atypecd & _MEDIA_CDR) {
564        g_snprintf(Lcd, sizeof(Lcd)-1, _("a CDR"));
565      } else if (Atypecd & _MEDIA_CDRW) {
566        g_snprintf(Lcd, sizeof(Lcd)-1, _("a CDRW"));
567      } else if (Atypecd & _MEDIA_CD) {
568        g_snprintf(Lcd, sizeof(Lcd)-1, _("a CD"));
569      }
570      if (*Lcd && (Atypecd & _MEDIA_IS_DVD)) {
571        strncat(Lcd, _(" or "), sizeof(Lcd)-1);
572      }
573      if (Atypecd & _MEDIA_DVDR) {
574        g_snprintf(Lcd, sizeof(Lcd)-1, _("a DVDR"));
575      } else if ((Atypecd & _MEDIA_DVDPRW) || (Atypecd & _MEDIA_DVDMRW)) {
576        g_snprintf(Lcd, sizeof(Lcd)-1, _("a DVDRW"));
577      } else if (Atypecd & _MEDIA_DVD) {
578        g_snprintf(Lcd, sizeof(Lcd)-1, _("a DVD"));
579      }
580    
581      if (Ainsert) {
582        g_snprintf(Ltitle, sizeof(Ltitle)-1, _("Please insert %s in drive %s to continue..."), Lcd, Ldrivelib);
583      } else {
584        g_snprintf(Ltitle, sizeof(Ltitle)-1, _("Ok there is a %s in drive %s."), Lcd, Ldrivelib);
585      }
586      gtk_label_set_text(Llabel, Ltitle);
587    }
588    
589    
590  /* attente que l'utilisateur ai inseré le/les cd qui va bien */  /* attente que l'utilisateur ai inseré le/les cd qui va bien */
591  gboolean callback_waiting_for_user(gpointer Adata)  gboolean callback_waiting_for_user(gpointer Adata)
592  {  {
593    Tgrave *Lg = (Tgrave *)Adata;    Tgrave *Lg = (Tgrave *)Adata;
594    gint *Lcont = (gint *)sc_grave_get_data(Lg, "cont");    gint *Lcont = (gint *)sc_grave_get_data(Lg, "cont");
595      gint *Ldetect = NULL;
596    gchar *Ldrive;    gchar *Ldrive;
597    gint *Lrequis;    gint *Lrequis;
598    gint Lmedia;    gint Lmedialu;
599      gboolean Lstatusmedia;
600    gint i;    gint i;
601      gboolean LnewCont = FALSE;
602        
603    for (i=1; 1; i++) {    for (i=1; 1; i++) {
604      Ldrive = sc_grave_get_datav(Lg, "device%d", i);      Ldrive = sc_grave_get_datav(Lg, "device%d", i);
605      if (!Ldrive) break;      if (!Ldrive) break;
606                
607      Lrequis = (gint *) sc_grave_get_datav(Lg, "devicesrequis%d", i);      Lrequis = (gint *) sc_grave_get_datav(Lg, "devicerequis%d", i);
608        Ldetect = (gint *) sc_grave_get_datav(Lg, "detect%d", i);
609      if (*Lrequis | _MEDIA_IS_CD) {      Lmedialu = 0;
610     printf("oui on interroge le lecteur dvd\n");      
611        Lmedia = get_dvdinfo(Ldrive, NULL);      if (*Lrequis & _MEDIA_IS_DVD) {
612    printf("===%d\n", Lmedia);  printf("test DVD!\n");
613          Lmedialu += get_dvdinfo(Ldrive, NULL);
614    printf("fin => %d\n", Lmedialu);      
615      }      }
616    
617      if (*Lrequis | _MEDIA_IS_DVD) {      if (*Lrequis & _MEDIA_IS_CD) {
618     printf("oui on interroge le lecteur cd\n");  printf("test CD!\n");
619        Lmedia = get_cdinfo(Ldrive, NULL);        Lmedialu += get_cdinfo(Ldrive, NULL);
620    printf("===%d\n", Lmedia);  printf("fin => %d\n", Lmedialu);      
621          
622      }      }
623    printf("cdoudvd => %d\n", (!(_MEDIA_CMP_CD(*Lrequis, Lmedialu) || _MEDIA_CMP_DVD(*Lrequis, Lmedialu))));
624    printf("blank = >%d\n", ((*Lrequis & _MEDIA_BLANK) && (Lmedialu & _MEDIA_NOBLANK)));
625    printf("nobliank => %d\n", ((*Lrequis & _MEDIA_NOBLANK) && (Lmedialu & _MEDIA_BLANK)));
626    printf("apprend => %d\n", ((*Lrequis & _MEDIA_APPENDABLE) && (!(Lmedialu & _MEDIA_APPENDABLE))));
627    
628        if (Ldetect) *Ldetect = Lmedialu;
629        Lstatusmedia = (!(_MEDIA_CMP_CD(*Lrequis, Lmedialu) || _MEDIA_CMP_DVD(*Lrequis, Lmedialu))) ||
630                         ((*Lrequis & _MEDIA_BLANK) && (Lmedialu & _MEDIA_NOBLANK)) ||
631                         ((*Lrequis & _MEDIA_NOBLANK) && (Lmedialu & _MEDIA_BLANK)) ||
632                         ((*Lrequis & _MEDIA_APPENDABLE) && (!(Lmedialu & _MEDIA_APPENDABLE)));
633        if (Lstatusmedia) LnewCont = TRUE;
634            
635        set_waitwindow_title(Lstatusmedia, *Lrequis, i, Lg);
636    }    }
637    
638      if (LnewCont == FALSE) *Lcont = 0;
639            
640    return TRUE;    return TRUE;
641  }  }
642    
643  gboolean waiting_for_user(Tgrave *Ag, gint Atypecd1, gchar *Ldriveident1, gint Atypecd2, gchar *Ldriveident2)  
644    gboolean waiting_for_user(Tgrave *Ag, gint Atypecd1, gint *Adetectcd1, gchar *Ldriveident1,
645                                          gint Atypecd2, gint *Adetectcd2, gchar *Ldriveident2)
646  {  {
647    Tgrave *Lwaitg = sc_grave_load("window_waiting_cd.glade");    Tgrave *Lwaitg = sc_grave_load("window_waiting_cd.glade");
648    GtkWidget *Lparent = sc_grave_get_widget(Ag, "topwindow");    GtkWidget *Lparent = sc_grave_get_widget(Ag, "topwindow");
649    GtkWidget *Lwindow;    GtkWidget *Lwindow;
650    gchar *Lident;    gchar *Lident1 = NULL, *Ldevicetitle1 = NULL;
651    gboolean Lcont = TRUE;    gchar *Lident2 = NULL, *Ldevicetitle2 = NULL;
652    guint Ltimeout;    gint Lcont = 2;
653  printf("toto deb\n");    gboolean Labort = FALSE;
654      guint Ltimeout = 0;
655      GtkTreeIter Liter;
656      gchar Ltitle[_BUF_SIZE] = "";
657      
658    g_assert(Lwaitg);    g_assert(Lwaitg);
659        
660    Lwindow = GTK_WIDGET(sc_grave_get_widget(Lwaitg, "window_waiting_cd"));    Lwindow = GTK_WIDGET(sc_grave_get_widget(Lwaitg, "window_waiting_cd"));
661      g_signal_connect(G_OBJECT(sc_grave_get_widget(Lwaitg, "cancelbutton")), "clicked", G_CALLBACK(abort_encours), Lwaitg);
662    
663    sc_grave_set_data(Lwaitg, Lwindow, "window");    sc_grave_set_data(Lwaitg, Lwindow, "window");
664    sc_grave_set_data(Lwaitg, &Lcont, "cont");    sc_grave_set_data(Lwaitg, &Lcont, "cont");
665      sc_grave_set_data(Lwaitg, &Labort, "gabort");
666      
667    if (Ldriveident1) {    if (Ldriveident1) {
668      Lident = get_combo_value(sc_grave_get_widget(Ag, Ldriveident1));      GtkComboBox *Lcombob1 = GTK_COMBO_BOX(sc_grave_get_widget(Ag, Ldriveident1));
669      sc_grave_set_data(Lwaitg, Lident, "device1");      GtkTreeModel *Lmodelb1 = gtk_combo_box_get_model(Lcombob1);
670      sc_grave_set_data(Lwaitg, &Atypecd1, "devicesrequis1");      if (gtk_combo_box_get_active_iter(Lcombob1, &Liter)) {
671          gtk_tree_model_get(Lmodelb1, &Liter, 0, &Lident1, 2, &Ldevicetitle1, -1);
672    
673          sc_grave_set_data(Lwaitg, Lident1, "device1");
674          sc_grave_set_data(Lwaitg, Adetectcd1, "detect1");
675          sc_grave_set_data(Lwaitg, Ldevicetitle1, "devicetitle1");
676          sc_grave_set_data(Lwaitg, &Atypecd1, "devicerequis1");
677    
678          set_waitwindow_title(TRUE, Atypecd1, 1, Lwaitg);
679        }
680    }    }
681    if (Ldriveident2) {    if (Ldriveident2) {
682      Lident = get_combo_value(sc_grave_get_widget(Ag, Ldriveident2));      GtkComboBox *Lcombob2 = GTK_COMBO_BOX(sc_grave_get_widget(Ag, Ldriveident2));
683      sc_grave_set_data(Lwaitg, Lident, "device2");      GtkTreeModel *Lmodelb2 = gtk_combo_box_get_model(Lcombob2);
684      sc_grave_set_data(Lwaitg, &Atypecd2, "devicesrequis2");      if (gtk_combo_box_get_active_iter(Lcombob2, &Liter)) {
685          gtk_tree_model_get(Lmodelb2, &Liter, 0, &Lident2, 2, &Ldevicetitle2, -1);
686    
687          sc_grave_set_data(Lwaitg, Lident2, "device2");
688          sc_grave_set_data(Lwaitg, Adetectcd2, "detect2");
689          sc_grave_set_data(Lwaitg, Ldevicetitle1, "devicetitle2");
690          sc_grave_set_data(Lwaitg, &Atypecd2, "devicerequis2");
691    
692          set_waitwindow_title(TRUE, Atypecd2, 2, Lwaitg); //Atypecd2, Ldevicetitle2);
693          gtk_label_set_text(GTK_LABEL(sc_grave_get_widget(Lwaitg, "label2")), Ltitle);
694        }
695    }    }
696  printf("yopla = 1\n");  
697    gtk_window_set_transient_for(GTK_WINDOW(Lwindow), GTK_WINDOW(Lparent));    gtk_window_set_transient_for(GTK_WINDOW(Lwindow), GTK_WINDOW(Lparent));
698      gtk_window_set_position(GTK_WINDOW(Lwindow), GTK_WIN_POS_CENTER_ALWAYS);
699    
 printf("yopla = 2\n");  
700    gtk_widget_show(Lwindow);    gtk_widget_show(Lwindow);
701    
702  printf("yopla = 3\n");    /* on appele une fois le callback pour verifier que l'utilisateur n'ai pas
703    Ltimeout = g_timeout_add(1500, callback_waiting_for_user, Lwaitg);     * deja inseré le bon cd qui va bien */
704    while (Lcont == TRUE) {    callback_waiting_for_user(Lwaitg);
705      gtk_main_iteration();  
706      if (Lcont == 2 && Labort == FALSE) {
707        /* apparement non, on affiche la fenetre d'attente */
708        Ltimeout = g_timeout_add(1500, callback_waiting_for_user, Lwaitg);
709        do {
710          gtk_main_iteration();
711        } while (Lcont == 2 && Labort == FALSE);
712    }    }
713    
714    /* attente de la fin du timeout */    /* fin du timeout */
715    g_source_remove(Ltimeout);    if (Ltimeout) g_source_remove(Ltimeout);
716    
717    gtk_widget_destroy(Lwindow);    gtk_widget_destroy(Lwindow);
718    
719      g_free(Lident1); g_free(Lident2);
720      g_free(Ldevicetitle1); g_free(Ldevicetitle2);
721    
722    sc_grave_destroy(Lwaitg);    sc_grave_destroy(Lwaitg);
723    
724      return (Lcont == 0 && Labort == FALSE);
725  }  }
726    
727  /*  /*

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26