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

Commit f6edb99

Browse files
committed
Brackets runs! HAHAHAHA Still need to implement platform code though
1 parent d3477af commit f6edb99

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

appshell/cefclient_gtk.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
//#include "string_util.h"
1616

1717
char szWorkingDir[512]; // The current working directory
18+
std:: string szInitialUrl;
1819

1920
// The global ClientHandler reference.
2021
extern CefRefPtr<ClientHandler> g_handler;
@@ -250,8 +251,12 @@ int main(int argc, char* argv[]) {
250251
// Check cache_path setting
251252
if (CefString(&settings.cache_path).length() == 0) {
252253
CefString(&settings.cache_path) = AppGetCachePath();
254+
printf("No cache_path supplied by default\n");
253255
}
254256

257+
szInitialUrl = CefString(&settings.cache_path);
258+
szInitialUrl.append("/www/index.html");
259+
255260
// Initialize CEF.
256261
CefInitialize(main_args, settings, app.get());
257262

@@ -320,12 +325,15 @@ int main(int argc, char* argv[]) {
320325
// Populate the settings based on command line arguments.
321326
AppGetBrowserSettings(browserSettings);
322327

328+
browserSettings.file_access_from_file_urls_allowed = true;
329+
browserSettings.universal_access_from_file_urls_allowed = true;
330+
323331
window_info.SetAsChild(vbox);
324332

325-
CefBrowserHost::CreateBrowserSync(
333+
CefBrowserHost::CreateBrowser(
326334
window_info,
327335
static_cast<CefRefPtr<CefClient> >(g_handler),
328-
"http://www.google.com", browserSettings);
336+
szInitialUrl, browserSettings);
329337

330338
gtk_container_add(GTK_CONTAINER(window), vbox);
331339
gtk_widget_show_all(GTK_WIDGET(window));
@@ -348,7 +356,8 @@ std::string AppGetWorkingDirectory() {
348356
}
349357

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

354363
return CefString(cachePath);

appshell/client_app_gtk.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "include/cef_base.h"
2727
#include "config.h"
2828

29+
#include <pwd.h>
2930
#include <algorithm>
3031
//#include <MMSystem.h>
3132
//#include <ShlObj.h>
@@ -68,6 +69,16 @@ double ClientApp::GetElapsedMilliseconds()
6869

6970
CefString ClientApp::AppGetSupportDirectory()
7071
{
71-
return CefString("/");
72+
//Check environment variables first
73+
char* home_dir = getenv("HOME");
74+
if(home_dir == NULL)
75+
{
76+
//If no environment variable, use the system provided home directory
77+
struct passwd *pw = getpwuid(getuid());
78+
home_dir = pw->pw_dir;
79+
}
80+
81+
// ~/.config/Brackets? ~/.Brackets ?? We'll see, later.
82+
return strcat(home_dir,"/.Brackets");
7283
}
7384

0 commit comments

Comments
 (0)