Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Fix file:// url shim. Implement GetCurrentLanguage(), thanks Rado
Browse files Browse the repository at this point in the history
  • Loading branch information
pritambaral committed Nov 11, 2012
1 parent 9e28fe7 commit 3870093
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
10 changes: 3 additions & 7 deletions appshell/cefclient_gtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ int GetInitialUrl() {

if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{
szInitialUrl = "file://";
szInitialUrl.append(gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)));
gtk_widget_destroy (dialog);
return 0;
Expand All @@ -75,7 +74,6 @@ std::string AppGetRunningDirectory() {
if(szRunningDir.length() > 0)
return szRunningDir;

szRunningDir = "file://";
char buf[512];
int len = readlink("/proc/self/exe", buf, 512);

Expand All @@ -92,9 +90,7 @@ std::string AppGetRunningDirectory() {
}

CefString AppGetCachePath() {
std::string cachePath = "file://"; //To avoid Unix paths being interpreted as http:// URLs
cachePath.append(ClientApp::AppGetSupportDirectory());
cachePath.append("/cef_data");
std::string cachePath = std::string(ClientApp::AppGetSupportDirectory()) + "/cef_data";

return CefString(cachePath);
}
Expand Down Expand Up @@ -138,7 +134,7 @@ int main(int argc, char* argv[]) {

{
struct stat buf;
if(!(stat(szInitialUrl.c_str()+7, &buf) >= 0) || !(S_ISREG(buf.st_mode)))
if(!(stat(szInitialUrl.c_str(), &buf) >= 0) || !(S_ISREG(buf.st_mode)))
if(GetInitialUrl() < 0)
return 0;
}
Expand Down Expand Up @@ -188,7 +184,7 @@ int main(int argc, char* argv[]) {
CefBrowserHost::CreateBrowser(
window_info,
static_cast<CefRefPtr<CefClient> >(g_handler),
szInitialUrl, browserSettings);
"file://"+szInitialUrl, browserSettings);

gtk_container_add(GTK_CONTAINER(window), vbox);
gtk_widget_show_all(GTK_WIDGET(window));
Expand Down
12 changes: 9 additions & 3 deletions appshell/client_app_gtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,15 @@ extern char _binary_appshell_appshell_extensions_js_start;

CefString ClientApp::GetCurrentLanguage()
{
//TODO proper locale in GTK
printf("in GetCurrentLanguage\n");
return CefString("en");
const char* locconst = pango_language_to_string( gtk_get_default_language() );
//Rado: for me it prints "en-us", so I have to strip everything after the "-"
char loc[10] = {0};
strncpy(loc, locconst, 9);
for(int i=0; i<8; i++)
if ( (loc[i] == '-') || (loc[i] == '_') ) { loc[i] = 0; break; }

//TODO Explore possibility of using locale as-is, without stripping
return CefString(loc);
}

std::string ClientApp::GetExtensionJSSource()
Expand Down

0 comments on commit 3870093

Please sign in to comment.