(Partially) solved issue 663 : UTF-8 support at Windows for stable branch_3.0

This commit is contained in:
Hombre
2011-05-22 10:39:26 +02:00
parent 9ae1bdc443
commit 33c8254b87
4 changed files with 34 additions and 250 deletions

View File

@@ -48,48 +48,42 @@ Glib::ustring argv0;
Glib::ustring argv1;
int main(int argc, char **argv)
{
{
Glib::ustring argv0_, argv1_;
std::string argv0_, argv1_;
#ifdef WIN32
char exname[512];
GetModuleFileName (NULL, exname, 512);
WCHAR exnameU[512] = {0};
char exname[512] = {0};
GetModuleFileNameW (NULL, exnameU, 512);
WideCharToMultiByte(CP_UTF8,0,exnameU,-1,exname,512,0,0 );
argv0_ = exname;
// get the path where the rawtherapee is stored
int i;
for (i=argv0_.size()-1; (argv0_[i]!='/' && argv0_[i]!='\\') && i>0; i--);
if (argv0_[i]=='/' || argv0_[i]=='\\')
argv0_ = argv0_.substr(0,i);
// get the path where the rawtherapee executable is stored
argv0 = Glib::path_get_dirname(argv0_);
#else
// get the path to data (defined in config.h which is generated by cmake)
argv0_ = DATA_SEARCH_PATH;
argv0 = DATA_SEARCH_PATH;
// check if path exists, otherwise revert back to behavior similar to windows
try {
Glib::Dir dir(DATA_SEARCH_PATH);
} catch (Glib::FileError) {
argv0_ = argv[0];
int i;
for (i=argv0_.size()-1; (argv0_[i]!='/' && argv0_[i]!='\\') && i>0; i--);
if (argv0_[i]=='/' || argv0_[i]=='\\')
argv0_ = argv0_.substr(0,i);
argv0 = Glib::path_get_dirname(argv0_);
}
#endif
if (argc>1)
argv1_ = argv[1];
else
argv1_ = "";
#ifdef GLIBMM_EXCEPTIONS_ENABLED
argv0 = Glib::filename_to_utf8 (argv0_);
argv1 = Glib::filename_to_utf8 (argv1_);
#else
std::auto_ptr<Glib::Error> error;
argv0 = Glib::filename_to_utf8 (argv0_, error);
argv1 = Glib::filename_to_utf8 (argv1_, error);
#endif //GLIBMM_EXCEPTIONS_ENABLED
argv1 = safe_locale_to_utf8 (argv1_);
Glib::thread_init();
gdk_threads_init();
@@ -106,7 +100,7 @@ int main(int argc, char **argv)
// Gtk::RC::add_default_file (argv0+"/themes/"+options.theme);
if (!options.useSystemTheme)
{
std::vector<std::string> rcfiles;
std::vector<Glib::ustring> rcfiles;
rcfiles.push_back (argv0+"/themes/"+options.theme);
// Set the font face and size
Gtk::RC::parse_string (Glib::ustring::compose(