#include #include #include #include #include #include #include #include #include "gmencoder.h" void LimpiaOrigenes () { int activo_mantener; memset (&medio_dvd, 0, sizeof(DATOS_DVD)); /* Limpio la combo de titulos y al hacerlo todas las demás */ strPrincipal.cmbTitulosDVD_items = g_list_append (strPrincipal.cmbTitulosDVD_items, (gpointer) ""); gtk_combo_set_popdown_strings (GTK_COMBO (strPrincipal.cmbTitulosDVD), strPrincipal.cmbTitulosDVD_items); g_list_free(strPrincipal.cmbTitulosDVD_items); strPrincipal.cmbTitulosDVD_items = NULL; memset (&medio_fichero, 0, sizeof(DATOS_FICHERO)); memset (&medio_tele, 0, sizeof(DATOS_FICHERO)); gtk_widget_set_sensitive(strPrincipal.chkCropping, FALSE); gtk_widget_set_sensitive(strPrincipal.chkRedimensionar, FALSE); gtk_widget_set_sensitive(strPrincipal.chkPostProcesar, FALSE); gtk_widget_set_sensitive(strPrincipal.chkSubtitulos, FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(strPrincipal.chkCropping), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(strPrincipal.chkRedimensionar), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(strPrincipal.chkPostProcesar), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(strPrincipal.chkSubtitulos), FALSE); /* Quito el activo para que al actualizar los spins no intente mantener el aspecto */ activo_mantener = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(strPrincipal.rbtMantenerAspecto)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(strPrincipal.rbtMantenerAspecto), FALSE); gtk_spin_button_set_value (GTK_SPIN_BUTTON(strPrincipal.spX), FALSE); gtk_spin_button_set_value (GTK_SPIN_BUTTON(strPrincipal.spY), 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(strPrincipal.rbtMantenerAspecto), activo_mantener); /* Vaciar combo de cropping */ strPrincipal.cmbValoresCropping_items = g_list_append (strPrincipal.cmbValoresCropping_items, (gpointer) ""); gtk_combo_set_popdown_strings (GTK_COMBO (strPrincipal.cmbValoresCropping), strPrincipal.cmbValoresCropping_items); g_list_free(strPrincipal.cmbValoresCropping_items); strPrincipal.cmbValoresCropping_items = NULL; } void SacaEspacioFS (char *Nombre, int *Libre, int *Total) { *Libre = 100; *Total = 500; } int LeeLinea (char *linea, int MaxTam, FILE *fd) { int i = 0; while (!feof (fd)) { if (i < (MaxTam-1)) { if (1 == fread ((void *) &linea[i], sizeof (char), 1, fd)) { if (linea[i] == '\r' || linea[i] == '\n' || linea[i] == '\0') { linea[i] = 0; if (i != 0) break; } } } else { linea[MaxTam-1] = 0; break; } i ++; } #ifdef DEBUG2 fprintf (stderr, "<--[%s]-->\n", linea); #endif if (feof (fd)) return -1; else return 0; } char *AnalizaLinea (char *linea, char *dato, char *id_linea, char *ini, char *fin, int salta) { int i; int j; char *retorno = dato; #ifdef DEBUG1 printf ("Comparing:\n"); printf (" - %s", linea); printf (" - %s\n", id_linea); #endif if (!fnmatch (id_linea, linea, 0)) { #ifdef DEBUG1 printf (" - OK\n", id_linea); #endif for (i = 0; i < (strlen (linea) - salta); i++) { if (!fnmatch (ini, &linea[i], 0)) { for (j = 0; linea[i+salta+j] != '\n' && fnmatch (fin, &linea[i+salta+j], 0) && linea[i+salta+j] != 0; j ++) { dato[j] = linea[i+salta+j]; dato[j+1] = 0; } if (!dato[0]) { retorno = NULL; } break; } } } else { #ifdef DEBUG1 printf (" - NO\n"); #endif retorno = NULL; } return retorno; } void MsgError (const unsigned char * mensaje,...) { char Cadena[512]; va_list ArgsVar; va_start(ArgsVar, mensaje); vsnprintf(Cadena, sizeof(Cadena), mensaje, ArgsVar); fprintf (stderr, _("%s"), Cadena); while (gtk_events_pending()) { gtk_main_iteration (); } va_end(ArgsVar); } int TituloAct () { int retorno = 0; for (retorno = 0; retorno < medio_dvd.Titulos; retorno ++) { if (!strcmp (medio_dvd.TextoTitulos[retorno], (char *) gtk_entry_get_text (GTK_ENTRY(strPrincipal.entCmbTitulosDVD)))) { break; } } if (retorno == medio_dvd.Titulos) { retorno = 0; } else { retorno ++; } return retorno; } int SubtituloAct () { int retorno = 0; int titulo; if (medio_dvd.Titulos) { titulo = TituloAct () - 1; for (retorno = 0; retorno < medio_dvd.NumSubtitulos[titulo]; retorno ++) { if (!strcmp (medio_dvd.TextoSubtitulos[titulo][retorno], (char *) gtk_entry_get_text (GTK_ENTRY(strPrincipal.entCmbIdiomaSubtitulos)))) { break; } } if (retorno == medio_dvd.NumSubtitulos[titulo]) { retorno = 0; } else { retorno = medio_dvd.IdSubtitulos[titulo][retorno]; } } else if (medio_fichero.x) { for (retorno = 0; retorno < medio_fichero.NumSubtitulos; retorno ++) { if (!strcmp (medio_fichero.TextoSubtitulos[retorno], (char *) gtk_entry_get_text (GTK_ENTRY(strPrincipal.entCmbIdiomaSubtitulos)))) { break; } } if (retorno == medio_fichero.NumSubtitulos) { retorno = 0; } else { retorno = medio_fichero.IdSubtitulos[retorno]; } } return retorno; } int AudioAct () { int retorno = 0; int titulo; titulo = TituloAct () - 1; for (retorno = 0; retorno < medio_dvd.NumAudio[titulo]; retorno ++) { if (!strcmp (medio_dvd.TextoAudio[titulo][retorno], (char *) gtk_entry_get_text (GTK_ENTRY(strPrincipal.entCmbIdiomaAudio)))) { break; } } if (retorno == medio_dvd.NumAudio[titulo]) { retorno = 0; } else { retorno = medio_dvd.IdAudio[titulo][retorno]; } return retorno; } char *LeeEtiqueta (char *Principal, char *Secundaria, char *Etiqueta, char *Dato, char *Fichero) { FILE *file; char Tmp[256]; char Linea[1024]; int i = 0; if (NULL == (file = fopen (Fichero, "r"))) { fprintf (stderr, _("Error opening the configuration file [%s].\n"), Fichero); return NULL; } if (Principal) { sprintf (Tmp, "[%s]", Principal); while (!feof (file)) { fgets (Linea, 1024, file); i = 0; while (Linea[i] == ' ' || Linea[i] == '\t') i++; if (!strncmp (&Linea[i], Tmp, strlen (Tmp))) break; } if (strncmp (&Linea[i], Tmp, strlen (Tmp))) { fclose (file); return NULL; } if (Secundaria) { sprintf (Tmp, "<%s>", Secundaria); while (!feof (file)) { fgets (Linea, 1024, file); i = 0; while (Linea[i] == ' ' || Linea[i] == '\t') i++; if (Linea[i] == '[') break; if (!strncmp (&Linea[i], Tmp, strlen (Tmp))) break; } if (strncmp (&Linea[i], Tmp, strlen (Tmp))) { fclose (file); return NULL; } } } if (Etiqueta) { sprintf (Tmp, "%s:", Etiqueta); while (!feof (file)) { fgets (Linea, 1024, file); i = 0; while (Linea[i] == ' ' || Linea[i] == '\t') i++; if (Linea[i] == '[' || Linea[i] == '<') break; if (!strncmp (&Linea[i], Tmp, strlen (Tmp))) break; } if (strncmp (&Linea[i], Tmp, strlen (Tmp))) { fclose (file); return NULL; } /* Busco los ':' tienen que estar seguro sino * no habria llegado aqui */ while (Linea[i] != ':') i++; /* Quito el '\n' */ Linea[strlen(Linea) - 1] = 0; strcpy (Dato, &Linea[i+1]); } fclose (file); return Dato; }