diff options
-rw-r--r-- | src/app.c | 24 | ||||
-rw-r--r-- | src/app.h | 2 |
2 files changed, 26 insertions, 0 deletions
@@ -1,6 +1,7 @@ | |||
1 | #include "app.h" | 1 | #include "app.h" |
2 | #include "embedded.h" | 2 | #include "embedded.h" |
3 | #include "gmcerts.h" | 3 | #include "gmcerts.h" |
4 | #include "gmutil.h" | ||
4 | #include "history.h" | 5 | #include "history.h" |
5 | #include "ui/command.h" | 6 | #include "ui/command.h" |
6 | #include "ui/window.h" | 7 | #include "ui/window.h" |
@@ -337,6 +338,13 @@ iBool handleCommand_App(const char *cmd) { | |||
337 | iWidget *root = d->window->root; | 338 | iWidget *root = d->window->root; |
338 | if (equal_Command(cmd, "open")) { | 339 | if (equal_Command(cmd, "open")) { |
339 | const iString *url = collect_String(newCStr_String(suffixPtr_Command(cmd, "url"))); | 340 | const iString *url = collect_String(newCStr_String(suffixPtr_Command(cmd, "url"))); |
341 | iUrl parts; | ||
342 | init_Url(&parts, url); | ||
343 | if (equalCase_Rangecc(&parts.protocol, "http") || | ||
344 | equalCase_Rangecc(&parts.protocol, "https")) { | ||
345 | openInDefaultBrowser_App(url); | ||
346 | return iTrue; | ||
347 | } | ||
340 | if (!argLabel_Command(cmd, "history")) { | 348 | if (!argLabel_Command(cmd, "history")) { |
341 | if (argLabel_Command(cmd, "redirect")) { | 349 | if (argLabel_Command(cmd, "redirect")) { |
342 | replace_History(d->history, url); | 350 | replace_History(d->history, url); |
@@ -416,3 +424,19 @@ iBool handleCommand_App(const char *cmd) { | |||
416 | } | 424 | } |
417 | return iTrue; | 425 | return iTrue; |
418 | } | 426 | } |
427 | |||
428 | void openInDefaultBrowser_App(const iString *url) { | ||
429 | iProcess *proc = new_Process(); | ||
430 | #if defined (iPlatformApple) | ||
431 | setArguments_Process(proc, | ||
432 | iClob(newStringsCStr_StringList("/usr/bin/open", cstr_String(url), NULL))); | ||
433 | start_Process(proc); | ||
434 | #elif defined(iPlatformLinux) | ||
435 | setArguments_Process(proc, | ||
436 | iClob(newStringsCStr_StringList("/usr/bin/x-www-browser", cstr_String(url), NULL))); | ||
437 | start_Process(proc); | ||
438 | #else | ||
439 | iAssert(iFalse); | ||
440 | #endif | ||
441 | iRelease(proc); | ||
442 | } | ||
@@ -38,3 +38,5 @@ void postCommandf_App (const char *command, ...); | |||
38 | iLocalDef void postCommandString_App(const iString *command) { | 38 | iLocalDef void postCommandString_App(const iString *command) { |
39 | postCommand_App(cstr_String(command)); | 39 | postCommand_App(cstr_String(command)); |
40 | } | 40 | } |
41 | |||
42 | void openInDefaultBrowser_App (const iString *url); | ||