graveman-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Graveman-cvs] Changes to graveman/current/src/matos.c


From: sylvain cresto
Subject: [Graveman-cvs] Changes to graveman/current/src/matos.c
Date: Tue, 01 Mar 2005 19:19:59 -0500

Index: graveman/current/src/matos.c
diff -u graveman/current/src/matos.c:1.18 graveman/current/src/matos.c:1.19
--- graveman/current/src/matos.c:1.18   Mon Feb 28 01:28:09 2005
+++ graveman/current/src/matos.c        Wed Mar  2 00:19:58 2005
@@ -551,83 +551,177 @@
   return Lstatus;
 }
 
+void set_waitwindow_title(gboolean Ainsert, gint Atypecd, gint Anum, Tgrave 
*Awaitg)
+{
+  gchar Lcd[_BUF_SIZE];
+  gchar Ltitle[_BUF_SIZE];
+  gchar *Ldrivelib = sc_grave_get_datav(Awaitg, "devicetitle%d", Anum);
+  GtkLabel *Llabel = GTK_LABEL(sc_grave_get_widgetv(Awaitg, "label%d", Anum));
+
+  *Ltitle=0;
+  *Lcd = 0;
+  if (Atypecd & _MEDIA_CDR) {
+    g_snprintf(Lcd, sizeof(Lcd)-1, _("a CDR"));
+  } else if (Atypecd & _MEDIA_CDRW) {
+    g_snprintf(Lcd, sizeof(Lcd)-1, _("a CDRW"));
+  } else if (Atypecd & _MEDIA_CD) {
+    g_snprintf(Lcd, sizeof(Lcd)-1, _("a CD"));
+  }
+  if (*Lcd && (Atypecd & _MEDIA_IS_DVD)) {
+    strncat(Lcd, _(" or "), sizeof(Lcd)-1);
+  }
+  if (Atypecd & _MEDIA_DVDR) {
+    g_snprintf(Lcd, sizeof(Lcd)-1, _("a DVDR"));
+  } else if ((Atypecd & _MEDIA_DVDPRW) || (Atypecd & _MEDIA_DVDMRW)) {
+    g_snprintf(Lcd, sizeof(Lcd)-1, _("a DVDRW"));
+  } else if (Atypecd & _MEDIA_DVD) {
+    g_snprintf(Lcd, sizeof(Lcd)-1, _("a DVD"));
+  }
+
+  if (Ainsert) {
+    g_snprintf(Ltitle, sizeof(Ltitle)-1, _("Please insert %s in drive %s to 
continue..."), Lcd, Ldrivelib);
+  } else {
+    g_snprintf(Ltitle, sizeof(Ltitle)-1, _("Ok there is a %s in drive %s."), 
Lcd, Ldrivelib);
+  }
+  gtk_label_set_text(Llabel, Ltitle);
+}
+
+
 /* attente que l'utilisateur ai inseré le/les cd qui va bien */
 gboolean callback_waiting_for_user(gpointer Adata)
 {
   Tgrave *Lg = (Tgrave *)Adata;
   gint *Lcont = (gint *)sc_grave_get_data(Lg, "cont");
+  gint *Ldetect = NULL;
   gchar *Ldrive;
   gint *Lrequis;
-  gint Lmedia;
+  gint Lmedialu;
+  gboolean Lstatusmedia;
   gint i;
+  gboolean LnewCont = FALSE;
   
   for (i=1; 1; i++) {
     Ldrive = sc_grave_get_datav(Lg, "device%d", i);
     if (!Ldrive) break;
       
-    Lrequis = (gint *) sc_grave_get_datav(Lg, "devicesrequis%d", i);
-
-    if (*Lrequis | _MEDIA_IS_CD) {
-   printf("oui on interroge le lecteur dvd\n");
-      Lmedia = get_dvdinfo(Ldrive, NULL);
-  printf("===%d\n", Lmedia);
-
+    Lrequis = (gint *) sc_grave_get_datav(Lg, "devicerequis%d", i);
+    Ldetect = (gint *) sc_grave_get_datav(Lg, "detect%d", i);
+    Lmedialu = 0;
+    
+    if (*Lrequis & _MEDIA_IS_DVD) {
+printf("test DVD!\n"); 
+      Lmedialu += get_dvdinfo(Ldrive, NULL);
+printf("fin => %d\n", Lmedialu);      
     }
 
-    if (*Lrequis | _MEDIA_IS_DVD) {
-   printf("oui on interroge le lecteur cd\n");
-      Lmedia = get_cdinfo(Ldrive, NULL);
-  printf("===%d\n", Lmedia);
+    if (*Lrequis & _MEDIA_IS_CD) {
+printf("test CD!\n"); 
+      Lmedialu += get_cdinfo(Ldrive, NULL);
+printf("fin => %d\n", Lmedialu);      
+      
     }
+printf("cdoudvd => %d\n", (!(_MEDIA_CMP_CD(*Lrequis, Lmedialu) || 
_MEDIA_CMP_DVD(*Lrequis, Lmedialu))));
+printf("blank = >%d\n", ((*Lrequis & _MEDIA_BLANK) && (Lmedialu & 
_MEDIA_NOBLANK)));
+printf("nobliank => %d\n", ((*Lrequis & _MEDIA_NOBLANK) && (Lmedialu & 
_MEDIA_BLANK)));
+printf("apprend => %d\n", ((*Lrequis & _MEDIA_APPENDABLE) && (!(Lmedialu & 
_MEDIA_APPENDABLE))));
+
+    if (Ldetect) *Ldetect = Lmedialu;
+    Lstatusmedia = (!(_MEDIA_CMP_CD(*Lrequis, Lmedialu) || 
_MEDIA_CMP_DVD(*Lrequis, Lmedialu))) ||
+                     ((*Lrequis & _MEDIA_BLANK) && (Lmedialu & 
_MEDIA_NOBLANK)) ||
+                     ((*Lrequis & _MEDIA_NOBLANK) && (Lmedialu & 
_MEDIA_BLANK)) ||
+                     ((*Lrequis & _MEDIA_APPENDABLE) && (!(Lmedialu & 
_MEDIA_APPENDABLE)));
+    if (Lstatusmedia) LnewCont = TRUE;
     
+    set_waitwindow_title(Lstatusmedia, *Lrequis, i, Lg);
   }
+
+  if (LnewCont == FALSE) *Lcont = 0;
     
   return TRUE;
 }
 
-gboolean waiting_for_user(Tgrave *Ag, gint Atypecd1, gchar *Ldriveident1, gint 
Atypecd2, gchar *Ldriveident2)
+
+gboolean waiting_for_user(Tgrave *Ag, gint Atypecd1, gint *Adetectcd1, gchar 
*Ldriveident1,
+                                      gint Atypecd2, gint *Adetectcd2, gchar 
*Ldriveident2)
 {
   Tgrave *Lwaitg = sc_grave_load("window_waiting_cd.glade");
   GtkWidget *Lparent = sc_grave_get_widget(Ag, "topwindow");
   GtkWidget *Lwindow;
-  gchar *Lident;
-  gboolean Lcont = TRUE;
-  guint Ltimeout;
-printf("toto deb\n");
+  gchar *Lident1 = NULL, *Ldevicetitle1 = NULL;
+  gchar *Lident2 = NULL, *Ldevicetitle2 = NULL;
+  gint Lcont = 2;
+  gboolean Labort = FALSE;
+  guint Ltimeout = 0;
+  GtkTreeIter Liter;
+  gchar Ltitle[_BUF_SIZE] = "";
+  
   g_assert(Lwaitg);
   
   Lwindow = GTK_WIDGET(sc_grave_get_widget(Lwaitg, "window_waiting_cd"));
+  g_signal_connect(G_OBJECT(sc_grave_get_widget(Lwaitg, "cancelbutton")), 
"clicked", G_CALLBACK(abort_encours), Lwaitg);
 
   sc_grave_set_data(Lwaitg, Lwindow, "window");
   sc_grave_set_data(Lwaitg, &Lcont, "cont");
-
+  sc_grave_set_data(Lwaitg, &Labort, "gabort");
+  
   if (Ldriveident1) {
-    Lident = get_combo_value(sc_grave_get_widget(Ag, Ldriveident1));
-    sc_grave_set_data(Lwaitg, Lident, "device1");
-    sc_grave_set_data(Lwaitg, &Atypecd1, "devicesrequis1");
+    GtkComboBox *Lcombob1 = GTK_COMBO_BOX(sc_grave_get_widget(Ag, 
Ldriveident1));
+    GtkTreeModel *Lmodelb1 = gtk_combo_box_get_model(Lcombob1);
+    if (gtk_combo_box_get_active_iter(Lcombob1, &Liter)) {
+      gtk_tree_model_get(Lmodelb1, &Liter, 0, &Lident1, 2, &Ldevicetitle1, -1);
+
+      sc_grave_set_data(Lwaitg, Lident1, "device1");
+      sc_grave_set_data(Lwaitg, Adetectcd1, "detect1");
+      sc_grave_set_data(Lwaitg, Ldevicetitle1, "devicetitle1");
+      sc_grave_set_data(Lwaitg, &Atypecd1, "devicerequis1");
+
+      set_waitwindow_title(TRUE, Atypecd1, 1, Lwaitg);
+    }
   }
   if (Ldriveident2) {
-    Lident = get_combo_value(sc_grave_get_widget(Ag, Ldriveident2));
-    sc_grave_set_data(Lwaitg, Lident, "device2");
-    sc_grave_set_data(Lwaitg, &Atypecd2, "devicesrequis2");
+    GtkComboBox *Lcombob2 = GTK_COMBO_BOX(sc_grave_get_widget(Ag, 
Ldriveident2));
+    GtkTreeModel *Lmodelb2 = gtk_combo_box_get_model(Lcombob2);
+    if (gtk_combo_box_get_active_iter(Lcombob2, &Liter)) {
+      gtk_tree_model_get(Lmodelb2, &Liter, 0, &Lident2, 2, &Ldevicetitle2, -1);
+
+      sc_grave_set_data(Lwaitg, Lident2, "device2");
+      sc_grave_set_data(Lwaitg, Adetectcd2, "detect2");
+      sc_grave_set_data(Lwaitg, Ldevicetitle1, "devicetitle2");
+      sc_grave_set_data(Lwaitg, &Atypecd2, "devicerequis2");
+
+      set_waitwindow_title(TRUE, Atypecd2, 2, Lwaitg); //Atypecd2, 
Ldevicetitle2);
+      gtk_label_set_text(GTK_LABEL(sc_grave_get_widget(Lwaitg, "label2")), 
Ltitle);
+    }
   }
-printf("yopla = 1\n");
+
   gtk_window_set_transient_for(GTK_WINDOW(Lwindow), GTK_WINDOW(Lparent));
+  gtk_window_set_position(GTK_WINDOW(Lwindow), GTK_WIN_POS_CENTER_ALWAYS);
 
-printf("yopla = 2\n");
   gtk_widget_show(Lwindow);
 
-printf("yopla = 3\n");
-  Ltimeout = g_timeout_add(1500, callback_waiting_for_user, Lwaitg);
-  while (Lcont == TRUE) {
-    gtk_main_iteration(); 
+  /* on appele une fois le callback pour verifier que l'utilisateur n'ai pas
+   * deja inseré le bon cd qui va bien */
+  callback_waiting_for_user(Lwaitg);
+
+  if (Lcont == 2 && Labort == FALSE) {
+    /* apparement non, on affiche la fenetre d'attente */
+    Ltimeout = g_timeout_add(1500, callback_waiting_for_user, Lwaitg);
+    do {
+      gtk_main_iteration(); 
+    } while (Lcont == 2 && Labort == FALSE);
   }
 
-  /* attente de la fin du timeout */ 
-  g_source_remove(Ltimeout);
+  /* fin du timeout */ 
+  if (Ltimeout) g_source_remove(Ltimeout);
 
   gtk_widget_destroy(Lwindow);
+
+  g_free(Lident1); g_free(Lident2);
+  g_free(Ldevicetitle1); g_free(Ldevicetitle2);
+
   sc_grave_destroy(Lwaitg);
+
+  return (Lcont == 0 && Labort == FALSE);
 }
 
 /*




reply via email to

[Prev in Thread] Current Thread [Next in Thread]