#include "main.h" cfg_struct cfg; gdouble glob_fps; open_fl_struct cur_open_file; struct infobox infobox; GList *lang_list; /* Functions _only_ called from main.c */ void gse_main_reset_fileinfo (); int main(int argc, char *argv[]) { gchar *ftype = NULL, *filename, msg[BUF_LEN]; gint filetype, ret_status; struct poptOption gse_popt_options[] = { { "filetype", 't', POPT_ARG_STRING, &ftype, 1, _("Force which filetype that should be used"), "subrip/microdvd" }, { NULL, '\0', 0, NULL, 0 } }; /* Initialize the i18n stuff */ #ifdef ENABLE_NLS bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR); textdomain (PACKAGE); #endif cur_open_file.filename = NULL; gnome_init_with_popt_table ("gsubedit", VERSION, argc, argv, gse_popt_options, 0, NULL); cfg_read_config_file (); lang_list = gnome_i18n_get_language_list (NULL); gse_main_reset_fileinfo (); gse_create_main_window (); /* Open file if specified on the commandline */ if ((g_strcasecmp (g_basename (argv[argc - 1]), "gsubedit") != 0)) { filename = argv[argc - 1]; if (!ftype) filetype = gse_fl_get_subtitle_format (argv[argc -1], 0); else { if (strstr (ftype, "micr")) filetype = GSE_SUBT_MICRODVD; else if (strstr (ftype, "subr")) filetype = GSE_SUBT_SUBRIPPER; else filetype = gse_fl_get_subtitle_format (argv[argc -1], 0); } ret_status = gse_fl_open_file (argv[argc - 1], filetype, FALSE); switch (ret_status) { case GSE_FILE_NO_ERRORS: break; case GSE_FILE_ERROR_OPEN_R: g_snprintf (msg, BUF_LEN, _("Error opening file '%s'.\n" "Check if you have read permission to it!"), filename); gnome_dialog_run_and_close (GNOME_DIALOG (gnome_message_box_new (msg, GNOME_MESSAGE_BOX_WARNING, GNOME_STOCK_BUTTON_OK, NULL))); break; case GSE_FILE_CORRECTED_VALUES: g_snprintf (msg, BUF_LEN, _("Errors were found in file.\n" "Please check the result!")); gnome_dialog_run_and_close (GNOME_DIALOG (gnome_message_box_new (msg, GNOME_MESSAGE_BOX_INFO, GNOME_STOCK_BUTTON_OK, NULL))); break; case GSE_FILE_UNKNOWN_TYPE: g_snprintf (msg, BUF_LEN, _("Unable to determine file format of '%s'.\n" "You may want to try the '--filetype' option"), filename); gnome_dialog_run_and_close (GNOME_DIALOG (gnome_message_box_new (msg, GNOME_MESSAGE_BOX_WARNING, GNOME_STOCK_BUTTON_OK, NULL))); break; } } else gse_set_menu_toolbar_state (GSE_NO_FILE_OPEN); gnome_appbar_push (GNOME_APPBAR (mwin_statusbar), "Gnome Subtitle Editor version " VERSION); gtk_main(); return 0; } void gse_main_reset_fileinfo () { open_fl_struct fi = cur_open_file; fi.lang = fi.filename = NULL; fi.size = fi.filetype = fi.lines = fi.changed = 0; fi.fps = 0; }