diff --git a/mkvinfo.cpp b/mkvinfo.cpp index b9ce6bfa4..16f428ef8 100644 --- a/mkvinfo.cpp +++ b/mkvinfo.cpp @@ -12,7 +12,7 @@ /*! \file - \version \$Id: mkvinfo.cpp,v 1.58 2003/06/08 18:59:43 mosu Exp $ + \version \$Id: mkvinfo.cpp,v 1.59 2003/06/10 21:57:15 mosu Exp $ \brief retrieves and displays information about a Matroska file \author Moritz Bunkus */ @@ -122,7 +122,7 @@ void usage() { "Usage: mkvinfo [options] inname\n\n" " options:\n" #ifdef HAVE_WXWINDOWS - " -g, --gui Start the GUI. All other options are ignored.\n" + " -g, --gui Start the GUI (and open inname if it was given).\n" #endif " inname Use 'inname' as the source.\n" " -v, --verbose Increase verbosity. See the man page for a detailed\n" @@ -1075,10 +1075,8 @@ int console_main(int argc, char **argv) { return 1; } -int main(int argc, char **argv) { - char *initial_file; - int res; - +void setup() { +#if !defined(WIN32) && !defined(__CYGWIN__) if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL) { fprintf(stderr, "Error: Could not set the locale 'en_US.UTF-8'. Make sure " "that your system supports this locale.\n"); @@ -1089,22 +1087,46 @@ int main(int argc, char **argv) { "LANG, LC_ALL and LC_CTYPE environment variables.\n"); exit(1); } +#endif cc_local_utf8 = utf8_init(NULL); +} +void cleanup() { + utf8_done(); +} + +#if !defined HAVE_WXWINDOWS +int main(int argc, char **argv) { + char *initial_file; + int res; + + setup(); + parse_args(argc, argv, initial_file, use_gui); + + res = console_main(argc, argv); + cleanup(); + + return res; +} + +#elif !defined(WIN32) && !defined(__CYGWIN__) + +int main(int argc, char **argv) { + char *initial_file; + int res; + + setup(); parse_args(argc, argv, initial_file, use_gui); -#ifdef HAVE_WXWINDOWS if (use_gui) { wxEntry(argc, argv); return 0; } else res = console_main(argc, argv); -#else - res = console_main(argc, argv); -#endif - utf8_done(); + cleanup(); return res; } +#endif // HAVE_WXWINDOWS diff --git a/mkvinfo.h b/mkvinfo.h index e5e45e059..040a34719 100644 --- a/mkvinfo.h +++ b/mkvinfo.h @@ -13,7 +13,7 @@ /*! \file - \version \$Id: mkvinfo.h,v 1.4 2003/05/31 09:08:02 mosu Exp $ + \version \$Id: mkvinfo.h,v 1.5 2003/06/10 21:57:15 mosu Exp $ \brief definition of global variables and functions \author Moritz Bunkus */ @@ -35,6 +35,8 @@ void parse_args(int argc, char **argv, char *&file_name, bool &use_gui); int console_main(int argc, char **argv); bool process_file(const char *file_name); +void setup(); +void cleanup(); extern bool use_gui; diff --git a/mkvinfo_gui.cpp b/mkvinfo_gui.cpp index 9c00846fb..0b52f445d 100644 --- a/mkvinfo_gui.cpp +++ b/mkvinfo_gui.cpp @@ -29,10 +29,14 @@ enum { bool mi_app::OnInit() { char *initial_file; - bool use_gui; parse_args(argc, argv, initial_file, use_gui); + if (!use_gui) { + console_main(argc, argv); + return false; + } + frame = new mi_frame(_T("mkvinfo"), wxPoint(50, 50), wxSize(600, 400)); frame->Show(true); frame->Refresh(true); @@ -323,6 +327,10 @@ BEGIN_EVENT_TABLE(mi_frame, wxFrame) EVT_MENU(mi_help_about, mi_frame::on_help_about) END_EVENT_TABLE() +#if defined(__CYGWIN__) || defined(WIN32) +IMPLEMENT_APP(mi_app) +#else IMPLEMENT_APP_NO_MAIN(mi_app) +#endif #endif // HAVE_WXWINDOWS