summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/app.c13
-rw-r--r--src/app.h1
-rw-r--r--src/ui/window.c7
3 files changed, 18 insertions, 3 deletions
diff --git a/src/app.c b/src/app.c
index c6b9a548..c33664f9 100644
--- a/src/app.c
+++ b/src/app.c
@@ -73,8 +73,9 @@ static const char *dataDir_App_ = "~/AppData/Roaming/fi.skyjake.Lagrange";
73static const char *dataDir_App_ = "~/.config/lagrange"; 73static const char *dataDir_App_ = "~/.config/lagrange";
74#endif 74#endif
75#define EMB_BIN2 "../resources.binary" /* fallback from build/executable dir */ 75#define EMB_BIN2 "../resources.binary" /* fallback from build/executable dir */
76static const char *prefsFileName_App_ = "prefs.cfg"; 76static const char *prefsFileName_App_ = "prefs.cfg";
77static const char *stateFileName_App_ = "state.binary"; 77static const char *stateFileName_App_ = "state.binary";
78static const char *downloadDir_App_ = "~/Downloads";
78 79
79struct Impl_App { 80struct Impl_App {
80 iCommandLine args; 81 iCommandLine args;
@@ -103,6 +104,7 @@ struct Impl_App {
103 iBool useSystemTheme; 104 iBool useSystemTheme;
104 iString gopherProxy; 105 iString gopherProxy;
105 iString httpProxy; 106 iString httpProxy;
107 iString downloadDir;
106}; 108};
107 109
108static iApp app_; 110static iApp app_;
@@ -161,6 +163,7 @@ static iString *serializePrefs_App_(const iApp *d) {
161 appendFormat_String(str, "ostheme arg:%d\n", d->useSystemTheme); 163 appendFormat_String(str, "ostheme arg:%d\n", d->useSystemTheme);
162 appendFormat_String(str, "proxy.gopher address:%s\n", cstr_String(&d->gopherProxy)); 164 appendFormat_String(str, "proxy.gopher address:%s\n", cstr_String(&d->gopherProxy));
163 appendFormat_String(str, "proxy.http address:%s\n", cstr_String(&d->httpProxy)); 165 appendFormat_String(str, "proxy.http address:%s\n", cstr_String(&d->httpProxy));
166 appendFormat_String(str, "downloads path:%s\n", cstr_String(&d->downloadDir));
164 return str; 167 return str;
165} 168}
166 169
@@ -312,6 +315,7 @@ static void init_App_(iApp *d, int argc, char **argv) {
312 d->tabEnum = 0; /* generates unique IDs for tab pages */ 315 d->tabEnum = 0; /* generates unique IDs for tab pages */
313 init_String(&d->gopherProxy); 316 init_String(&d->gopherProxy);
314 init_String(&d->httpProxy); 317 init_String(&d->httpProxy);
318 initCStr_String(&d->downloadDir, downloadDir_App_);
315 setThemePalette_Color(d->theme); 319 setThemePalette_Color(d->theme);
316#if defined (iPlatformApple) 320#if defined (iPlatformApple)
317 setupApplication_MacOS(); 321 setupApplication_MacOS();
@@ -386,6 +390,7 @@ static void init_App_(iApp *d, int argc, char **argv) {
386static void deinit_App(iApp *d) { 390static void deinit_App(iApp *d) {
387 saveState_App_(d); 391 saveState_App_(d);
388 savePrefs_App_(d); 392 savePrefs_App_(d);
393 deinit_String(&d->downloadDir);
389 deinit_String(&d->httpProxy); 394 deinit_String(&d->httpProxy);
390 deinit_String(&d->gopherProxy); 395 deinit_String(&d->gopherProxy);
391 save_Bookmarks(d->bookmarks, dataDir_App_); 396 save_Bookmarks(d->bookmarks, dataDir_App_);
@@ -783,6 +788,10 @@ iBool handleCommand_App(const char *cmd) {
783 d->retainWindowSize = arg_Command(cmd); 788 d->retainWindowSize = arg_Command(cmd);
784 return iTrue; 789 return iTrue;
785 } 790 }
791 else if (equal_Command(cmd, "downloads")) {
792 setCStr_String(&d->downloadDir, suffixPtr_Command(cmd, "path"));
793 return iTrue;
794 }
786 else if (equal_Command(cmd, "open")) { 795 else if (equal_Command(cmd, "open")) {
787 const iString *url = collectNewCStr_String(suffixPtr_Command(cmd, "url")); 796 const iString *url = collectNewCStr_String(suffixPtr_Command(cmd, "url"));
788 iUrl parts; 797 iUrl parts;
diff --git a/src/app.h b/src/app.h
index a5b1266d..acc3e952 100644
--- a/src/app.h
+++ b/src/app.h
@@ -48,6 +48,7 @@ enum iUserEventCode {
48 48
49const iString *execPath_App (void); 49const iString *execPath_App (void);
50const iString *dataDir_App (void); 50const iString *dataDir_App (void);
51const iString *downloadDir_App (void);
51const iString *debugInfo_App (void); 52const iString *debugInfo_App (void);
52 53
53int run_App (int argc, char **argv); 54int run_App (int argc, char **argv);
diff --git a/src/ui/window.c b/src/ui/window.c
index 38df42e0..fbcf42fe 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -91,10 +91,13 @@ static iBool handleRootCommands_(iWidget *root, const char *cmd) {
91#endif 91#endif
92 92
93#if !defined (iHaveNativeMenus) 93#if !defined (iHaveNativeMenus)
94/* TODO: Submenus wouldn't hurt here. */
94static const iMenuItem navMenuItems[] = { 95static const iMenuItem navMenuItems[] = {
95 { "New Tab", 't', KMOD_PRIMARY, "tabs.new" }, 96 { "New Tab", 't', KMOD_PRIMARY, "tabs.new" },
96 { "Open Location...", SDLK_l, KMOD_PRIMARY, "focus.set id:url" }, 97 { "Open Location...", SDLK_l, KMOD_PRIMARY, "focus.set id:url" },
97 { "---", 0, 0, NULL }, 98 { "---", 0, 0, NULL },
99 { "Save Page", SDLK_s, KMOD_PRIMARY, "document.save" },
100 { "---", 0, 0, NULL },
98 { "Copy Source Text", SDLK_c, KMOD_PRIMARY, "copy" }, 101 { "Copy Source Text", SDLK_c, KMOD_PRIMARY, "copy" },
99 { "Bookmark This Page", SDLK_d, KMOD_PRIMARY, "bookmark.add" }, 102 { "Bookmark This Page", SDLK_d, KMOD_PRIMARY, "bookmark.add" },
100 { "---", 0, 0, NULL }, 103 { "---", 0, 0, NULL },
@@ -104,7 +107,7 @@ static const iMenuItem navMenuItems[] = {
104 { "Reset Zoom", SDLK_0, KMOD_PRIMARY, "zoom.set arg:100" }, 107 { "Reset Zoom", SDLK_0, KMOD_PRIMARY, "zoom.set arg:100" },
105 { "---", 0, 0, NULL }, 108 { "---", 0, 0, NULL },
106 { "Preferences...", SDLK_COMMA, KMOD_PRIMARY, "preferences" }, 109 { "Preferences...", SDLK_COMMA, KMOD_PRIMARY, "preferences" },
107 { "Help", 0, 0, "!open url:about:help" }, 110 { "Help", SDLK_F1, 0, "!open url:about:help" },
108 { "Release Notes", 0, 0, "!open url:about:version" }, 111 { "Release Notes", 0, 0, "!open url:about:version" },
109 { "---", 0, 0, NULL }, 112 { "---", 0, 0, NULL },
110 { "Quit Lagrange", 'q', KMOD_PRIMARY, "quit" } 113 { "Quit Lagrange", 'q', KMOD_PRIMARY, "quit" }
@@ -116,6 +119,8 @@ static const iMenuItem navMenuItems[] = {
116static const iMenuItem fileMenuItems[] = { 119static const iMenuItem fileMenuItems[] = {
117 { "New Tab", SDLK_t, KMOD_PRIMARY, "tabs.new" }, 120 { "New Tab", SDLK_t, KMOD_PRIMARY, "tabs.new" },
118 { "Open Location...", SDLK_l, KMOD_PRIMARY, "focus.set id:url" }, 121 { "Open Location...", SDLK_l, KMOD_PRIMARY, "focus.set id:url" },
122 { "---", 0, 0, NULL },
123 { "Save Page", SDLK_s, KMOD_PRIMARY, "document.save" },
119}; 124};
120 125
121static const iMenuItem editMenuItems[] = { 126static const iMenuItem editMenuItems[] = {