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

Commit 3870093

Browse files
committed
Fix file:// url shim. Implement GetCurrentLanguage(), thanks Rado
1 parent 9e28fe7 commit 3870093

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

appshell/cefclient_gtk.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ int GetInitialUrl() {
5757

5858
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
5959
{
60-
szInitialUrl = "file://";
6160
szInitialUrl.append(gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)));
6261
gtk_widget_destroy (dialog);
6362
return 0;
@@ -75,7 +74,6 @@ std::string AppGetRunningDirectory() {
7574
if(szRunningDir.length() > 0)
7675
return szRunningDir;
7776

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

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

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

9995
return CefString(cachePath);
10096
}
@@ -138,7 +134,7 @@ int main(int argc, char* argv[]) {
138134

139135
{
140136
struct stat buf;
141-
if(!(stat(szInitialUrl.c_str()+7, &buf) >= 0) || !(S_ISREG(buf.st_mode)))
137+
if(!(stat(szInitialUrl.c_str(), &buf) >= 0) || !(S_ISREG(buf.st_mode)))
142138
if(GetInitialUrl() < 0)
143139
return 0;
144140
}
@@ -188,7 +184,7 @@ int main(int argc, char* argv[]) {
188184
CefBrowserHost::CreateBrowser(
189185
window_info,
190186
static_cast<CefRefPtr<CefClient> >(g_handler),
191-
szInitialUrl, browserSettings);
187+
"file://"+szInitialUrl, browserSettings);
192188

193189
gtk_container_add(GTK_CONTAINER(window), vbox);
194190
gtk_widget_show_all(GTK_WIDGET(window));

appshell/client_app_gtk.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,15 @@ extern char _binary_appshell_appshell_extensions_js_start;
3737

3838
CefString ClientApp::GetCurrentLanguage()
3939
{
40-
//TODO proper locale in GTK
41-
printf("in GetCurrentLanguage\n");
42-
return CefString("en");
40+
const char* locconst = pango_language_to_string( gtk_get_default_language() );
41+
//Rado: for me it prints "en-us", so I have to strip everything after the "-"
42+
char loc[10] = {0};
43+
strncpy(loc, locconst, 9);
44+
for(int i=0; i<8; i++)
45+
if ( (loc[i] == '-') || (loc[i] == '_') ) { loc[i] = 0; break; }
46+
47+
//TODO Explore possibility of using locale as-is, without stripping
48+
return CefString(loc);
4349
}
4450

4551
std::string ClientApp::GetExtensionJSSource()

0 commit comments

Comments
 (0)