/* * Initial main.c file generated by Glade. Edit as required. * Glade will not overwrite this file. */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include "interface.h" #include "support.h" #include "gmencoder.h" OPTS_PP *opts_pp = NULL; OPTS_SWS *opts_sws = NULL; CFGGEN CfgGen; extern DATOS_RIPPEO datos_rippeo[MAX_COLA]; void CargaOpciones (unsigned char *fichero) { unsigned char dato[512]; unsigned char dato1[512]; unsigned char tmp[512]; int num_pp; int num_sws; int i; memset (datos_rippeo, 0, sizeof (DATOS_RIPPEO) * MAX_COLA); if (NULL != LeeEtiqueta ("General", NULL, "PATH_MP", dato, fichero)) { fprintf (stderr, _("Mplayer/Mencoder was not in the Path. I read it for the config file [%s]\n"), dato); strcpy (CfgGen.Path_mp, dato); } /* Opciones de postprocesado */ if (NULL != LeeEtiqueta ("Postprocess", NULL, "NumPP", dato, fichero)) { num_pp = atoi (dato); fprintf (stderr, _("Number of Postprocess options [%d].\n"), num_pp); opts_pp = (OPTS_PP *) calloc (num_pp + 1, sizeof (OPTS_PP)); for (i = 0; i < num_pp; i ++) { sprintf (tmp, "PP%d", i); if (NULL != LeeEtiqueta ("Postprocess", tmp, "Text", dato, fichero)) { if (NULL != LeeEtiqueta ("Postprocess", tmp, "Value", dato1, fichero)) { strcpy (opts_pp[i].Text, dato); strcpy (opts_pp[i].Value, dato1); fprintf (stderr, _("Postprocess option [%s] [%s].\n"), opts_pp[i].Text, opts_pp[i].Value); } else { fprintf (stderr, _("Text [%s] without Value Label.\n"), dato); break; } } else { fprintf (stderr, _("Section [%s] without Text Label.\n"), tmp); break; } } for (i = 0; opts_pp[i].Text[0]; i ++) { strPrincipal.cmbPostProcesar_items = g_list_append (strPrincipal.cmbPostProcesar_items, (gpointer) opts_pp[i].Text); } gtk_combo_set_popdown_strings (GTK_COMBO (strPrincipal.cmbPostProcesar), strPrincipal.cmbPostProcesar_items); g_list_free(strPrincipal.cmbPostProcesar_items); } /* Algoritmos de redimensionamiento */ if (NULL != LeeEtiqueta ("SWScale", NULL, "NumSWS", dato, fichero)) { num_sws = atoi (dato); fprintf (stderr, "Number of Software scale types [%d].\n", num_sws); opts_sws = (OPTS_SWS *) calloc (num_sws + 1, sizeof (OPTS_SWS)); for (i = 0; i < num_sws; i ++) { sprintf (tmp, "SWS%d", i); if (NULL != LeeEtiqueta ("SWScale", tmp, "Text", dato, fichero)) { if (NULL != LeeEtiqueta ("SWScale", tmp, "Value", dato1, fichero)) { strcpy (opts_sws[i].Text, dato); strcpy (opts_sws[i].Value, dato1); fprintf (stderr, _("Postprocess option [%s] [%s].\n"), opts_sws[i].Text, opts_sws[i].Value); } else { fprintf (stderr, _("Text [%s] without Value Label.\n"), dato); break; } } else { fprintf (stderr, _("Section [%s] without Text Label.\n"), tmp); break; } } for (i = 0; opts_sws[i].Text[0]; i ++) { strPrincipal.cmbAlgoritmoRedimensionar_items = g_list_append (strPrincipal.cmbAlgoritmoRedimensionar_items, (gpointer) opts_sws[i].Text); } gtk_combo_set_popdown_strings (GTK_COMBO (strPrincipal.cmbAlgoritmoRedimensionar), strPrincipal.cmbAlgoritmoRedimensionar_items); g_list_free(strPrincipal.cmbAlgoritmoRedimensionar_items); } } void CargaConfiguracion (unsigned char *fichero) { unsigned char dato[512]; char *ptr_tmp; char path[512]; char *path_ptr = NULL; char tmp[512]; struct stat buf; fprintf (stderr, "Loading configuration from [%s]\n", fichero); if (NULL != LeeEtiqueta (NULL, NULL, "DeviceDVD", dato, fichero)) { fprintf (stderr, "Device DVD: [%s].\n", dato); strcpy (CfgGen.DeviceDVD, dato); } else { fprintf (stderr, "Device DVD: Not Found. Default Value [/dev/dvd].\n"); strcpy (CfgGen.DeviceDVD, "/dev/dvd"); } if (NULL != LeeEtiqueta (NULL, NULL, "UseAspectRatioPreviews", dato, fichero)) { fprintf (stderr, "UseAspectRatioPreviews DVD: [%s].\n", dato); CfgGen.UsarAspectoPreviews = atoi (dato); } else { fprintf (stderr, "UseAspectRatioPreviews: Not Found. Default Value [0].\n"); CfgGen.UsarAspectoPreviews = 0; } if (NULL != LeeEtiqueta (NULL, NULL, "AutoDetectPathMP", dato, fichero)) { fprintf (stderr, "AutoDetectPathMP: [%s].\n", dato); CfgGen.AutoDetectarPathMP = atoi (dato); } else { fprintf (stderr, "AutoDetectPathMP: Not Found. Default Value [1].\n"); CfgGen.AutoDetectarPathMP = 1; } if (NULL != LeeEtiqueta (NULL, NULL, "DeleteTemporalFiles", dato, fichero)) { fprintf (stderr, "DeleteTemporalFiles: [%s].\n", dato); CfgGen.DeleteTemporalFiles = atoi (dato); } else { fprintf (stderr, "DeleteTemporalFiles: Not Found. Default Value [1].\n"); CfgGen.DeleteTemporalFiles = 1; } if (NULL != LeeEtiqueta (NULL, NULL, "DeleteCopylFiles", dato, fichero)) { fprintf (stderr, "DeleteCopyToDiskFile: [%s].\n", dato); CfgGen.DeleteCopyFile = atoi (dato); } else { fprintf (stderr, "DeleteCopyToDiskFile: Not Found. Default Value [1].\n"); CfgGen.DeleteCopyFile = 1; } if (CfgGen.AutoDetectarPathMP) { CfgGen.Path_mp[0] = 0; ptr_tmp = getenv ("PATH"); if (ptr_tmp) { strcpy (path, ptr_tmp); for (path_ptr = strtok (path, ":"); path_ptr; path_ptr = strtok (NULL, ":")) { sprintf (tmp, "%s/mplayer", path_ptr); if (!stat (tmp, &buf)) { sprintf (tmp, "%s/mencoder", path_ptr); if (!stat (tmp, &buf)) { fprintf (stderr, _("Detected Mplayer/Mencoder Path [%s]\n"), path_ptr); strcpy (CfgGen.Path_mp, path_ptr); break; } } } } } else { if (NULL != LeeEtiqueta (NULL, NULL, "PathMP", dato, fichero)) { fprintf (stderr, "Path MP: [%s].\n", dato); strcpy (CfgGen.Path_mp, dato); } else { fprintf (stderr, "Path MP: Not Found. Default Value [/usr/local/bin].\n"); strcpy (CfgGen.Path_mp, "/usr/local/bin"); } } CfgGen.Guardado = 1; } void CargaConfiguracionTv (unsigned char *fichero) { unsigned char dato[512]; char *ptr_tmp; char path[512]; char *path_ptr = NULL; char tmp[512]; struct stat buf; fprintf (stderr, "Loading TV configuration from [%s]\n", fichero); if (NULL != LeeEtiqueta (NULL, NULL, "Result", dato, fichero)) { fprintf (stderr, "Resultado TV: [%s].\n", dato); strcpy (CfgGen.ResultadoTV, dato); } else { fprintf (stderr, "Resutlado: Not Found. Default Value [-tv on].\n"); strcpy (CfgGen.ResultadoTV, "-tv on"); } gtk_entry_set_text (GTK_ENTRY (strPrincipal.entParametrosTele), CfgGen.ResultadoTV); if (NULL != LeeEtiqueta (NULL, NULL, "UseAspectRatioPreviews", dato, fichero)) { fprintf (stderr, "UseAspectRatioPreviews DVD: [%s].\n", dato); CfgGen.UsarAspectoPreviews = atoi (dato); } else { fprintf (stderr, "UseAspectRatioPreviews: Not Found. Default Value [0].\n"); CfgGen.UsarAspectoPreviews = 0; } if (NULL != LeeEtiqueta (NULL, NULL, "AutoDetectPathMP", dato, fichero)) { fprintf (stderr, "AutoDetectPathMP: [%s].\n", dato); CfgGen.AutoDetectarPathMP = atoi (dato); } else { fprintf (stderr, "AutoDetectPathMP: Not Found. Default Value [1].\n"); CfgGen.AutoDetectarPathMP = 1; } if (NULL != LeeEtiqueta (NULL, NULL, "DeleteTemporalFiles", dato, fichero)) { fprintf (stderr, "DeleteTemporalFiles: [%s].\n", dato); CfgGen.DeleteTemporalFiles = atoi (dato); } else { fprintf (stderr, "DeleteTemporalFiles: Not Found. Default Value [1].\n"); CfgGen.DeleteTemporalFiles = 1; } if (NULL != LeeEtiqueta (NULL, NULL, "DeleteCopylFiles", dato, fichero)) { fprintf (stderr, "DeleteCopyToDiskFile: [%s].\n", dato); CfgGen.DeleteCopyFile = atoi (dato); } else { fprintf (stderr, "DeleteCopyToDiskFile: Not Found. Default Value [1].\n"); CfgGen.DeleteCopyFile = 1; } if (CfgGen.AutoDetectarPathMP) { CfgGen.Path_mp[0] = 0; ptr_tmp = getenv ("PATH"); if (ptr_tmp) { strcpy (path, ptr_tmp); for (path_ptr = strtok (path, ":"); path_ptr; path_ptr = strtok (NULL, ":")) { sprintf (tmp, "%s/mplayer", path_ptr); if (!stat (tmp, &buf)) { sprintf (tmp, "%s/mencoder", path_ptr); if (!stat (tmp, &buf)) { fprintf (stderr, _("Detected Mplayer/Mencoder Path [%s]\n"), path_ptr); strcpy (CfgGen.Path_mp, path_ptr); break; } } } } } else { if (NULL != LeeEtiqueta (NULL, NULL, "PathMP", dato, fichero)) { fprintf (stderr, "Path MP: [%s].\n", dato); strcpy (CfgGen.Path_mp, dato); } else { fprintf (stderr, "Path MP: Not Found. Default Value [/usr/local/bin].\n"); strcpy (CfgGen.Path_mp, "/usr/local/bin"); } } CfgGen.GuardadoTV = 1; } void Configura () { unsigned char fichero_opts[512]; unsigned char fichero_conf[512]; unsigned char *home; int fd; int i; char *ptr_tmp; unsigned char tmp[512]; if (NULL != (home = getenv ("HOME"))) { sprintf (fichero_opts, "%s/.gmencoder_opts", home); if (-1 != (fd = open (fichero_opts, O_RDONLY))) { close (fd); } else { fichero_opts[0] = 0; } } if (!strlen (fichero_opts)) { sprintf (fichero_opts, "/etc/gmencoder_opts", home); if (-1 != (fd = open (fichero_opts, O_RDONLY))) { close (fd); } else { fichero_opts[0] = 0; } } if (strlen (fichero_opts)) { CargaOpciones (fichero_opts); } else { fprintf (stderr, _("Options file missing ($HOME/.gmencoder_opts or /etc/gmencoder_opts).\n")); } if (NULL != (home = getenv ("HOME"))) { sprintf (fichero_conf, "%s/.gmencoderrc", home); if (-1 != (fd = open (fichero_conf, O_RDONLY))) { close (fd); } else { fichero_conf[0] = 0; } } if (!strlen (fichero_conf)) { sprintf (fichero_conf, "/etc/gmencoderrc", home); if (-1 != (fd = open (fichero_conf, O_RDONLY))) { close (fd); } else { fichero_conf[0] = 0; } } CargaConfiguracion (fichero_conf); if (NULL != (home = getenv ("HOME"))) { sprintf (fichero_conf, "%s/.gmencodertvrc", home); if (-1 != (fd = open (fichero_conf, O_RDONLY))) { close (fd); } else { fichero_conf[0] = 0; } } if (!strlen (fichero_conf)) { sprintf (fichero_conf, "/etc/gmencodertvrc", home); if (-1 != (fd = open (fichero_conf, O_RDONLY))) { close (fd); } else { fichero_conf[0] = 0; } } CargaConfiguracionTv (fichero_conf); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (strPrincipal.chkPostProcesar), 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.chkTodoTitulo), TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (strPrincipal.chkCopiarADisco), FALSE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (strPrincipal.chkBitrateAutoLav), TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (strPrincipal.chkSubtitulos), FALSE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (strPrincipal.rbt3PasadasLav), TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (strPrincipal.rbt1CD), TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (strPrincipal.rbt700), TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (strPrincipal.chkTiemposDe), TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (strPrincipal.chkTiemposA), TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (strPrincipal.chkTiemposDe), FALSE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (strPrincipal.chkTiemposA), FALSE); gtk_widget_set_sensitive(strPrincipal.chkCropping, FALSE); gtk_widget_set_sensitive(strPrincipal.chkRedimensionar, FALSE); gtk_widget_set_sensitive(strPrincipal.lblOFPS, FALSE); gtk_widget_set_sensitive(strPrincipal.lblOAR, FALSE); gtk_widget_set_sensitive(strPrincipal.spOutFrames, FALSE); gtk_widget_set_sensitive(strPrincipal.spOutAspect, FALSE); gtk_widget_set_sensitive(strPrincipal.chkPostProcesar, FALSE); gtk_widget_set_sensitive(strPrincipal.chkTiemposDe, FALSE); gtk_widget_set_sensitive(strPrincipal.chkTiemposA, FALSE); gtk_widget_set_sensitive(strPrincipal.fileFicheroCopiarDisco, FALSE); gtk_widget_set_sensitive(strPrincipal.spTamanioDVD, FALSE); gtk_widget_set_sensitive(strPrincipal.spAspectoDVD, FALSE); gtk_widget_set_sensitive(strPrincipal.lblTamanioDVD, FALSE); gtk_widget_set_sensitive(strPrincipal.lblAspectoDVD, FALSE); } int main (int argc, char *argv[]) { GtkWidget *winProgreso; GtkWidget *winPrincipal; GtkWidget *winOperacionEnCurso; GtkWidget *winFicheros; GtkWidget *winFaltanDatos; GtkWidget *winSobreescribir; GtkWidget *winConfig; GtkWidget *winEditTV; #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif g_thread_init(NULL); gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE, argc, argv, GNOME_PARAM_APP_DATADIR, PACKAGE_DATA_DIR, NULL); /* * The following code was added by Glade to create one of each component * (except popup menus), just so that you see something after building * the project. Delete any components that you don't want shown initially. */ winPrincipal = create_winPrincipal (); winProgreso = create_winProgreso (); winOperacionEnCurso = create_winOperacionEnCurso (); winFicheros = create_winFicheros (); winFaltanDatos = create_winFaltanDatos (); winSobreescribir = create_winSobreescribir (); winConfig = create_winConfig (); winEditTV = create_winEditTV (); Configura(); gtk_widget_show (winPrincipal); gdk_threads_enter(); gtk_main (); gdk_threads_leave(); if (opts_pp) free (opts_pp); if (opts_sws) free (opts_sws); return 0; }