summaryrefslogtreecommitdiff
path: root/src/app.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/src/app.c b/src/app.c
index 010c6d74..543467ef 100644
--- a/src/app.c
+++ b/src/app.c
@@ -1878,7 +1878,7 @@ void postCommand_Root(iRoot *d, const char *command) {
1878 ev.user.data2 = d; /* all events are root-specific */ 1878 ev.user.data2 = d; /* all events are root-specific */
1879 ev.user.windowID = d ? id_Window(d->window) : 0; /* root-specific means window-specific */ 1879 ev.user.windowID = d ? id_Window(d->window) : 0; /* root-specific means window-specific */
1880 SDL_PushEvent(&ev); 1880 SDL_PushEvent(&ev);
1881 iWindow *win = get_Window(); 1881 iWindow *win = d ? d->window : NULL;
1882#if defined (iPlatformAndroid) 1882#if defined (iPlatformAndroid)
1883 SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "%s[command] {%d} %s", 1883 SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "%s[command] {%d} %s",
1884 app_.isLoadingPrefs ? "[Prefs] " : "", 1884 app_.isLoadingPrefs ? "[Prefs] " : "",
@@ -1979,6 +1979,13 @@ size_t windowIndex_App(const iMainWindow *win) {
1979 return indexOf_PtrArray(&app_.mainWindows, win); 1979 return indexOf_PtrArray(&app_.mainWindows, win);
1980} 1980}
1981 1981
1982iMainWindow *newMainWindow_App(void) {
1983 iApp *d = &app_;
1984 iMainWindow *win = new_MainWindow(initialWindowRect_App_(d, size_PtrArray(&d->mainWindows)));
1985 addWindow_App(win);
1986 return win;
1987}
1988
1982const iPtrArray *mainWindows_App(void) { 1989const iPtrArray *mainWindows_App(void) {
1983 return &app_.mainWindows; 1990 return &app_.mainWindows;
1984} 1991}
@@ -3038,7 +3045,18 @@ iBool handleCommand_App(const char *cmd) {
3038 return iTrue; /* invalid command */ 3045 return iTrue; /* invalid command */
3039 } 3046 }
3040 if (findWidget_App("prefs")) { 3047 if (findWidget_App("prefs")) {
3041 postCommand_App("prefs.dismiss"); 3048 postCommand_App("prefs.dismiss");
3049 }
3050 if (argLabel_Command(cmd, "newwindow")) {
3051 const iRangecc gotoheading = range_Command(cmd, "gotoheading");
3052 const iRangecc gotourlheading = range_Command(cmd, "gotourlheading");
3053 postCommandf_Root(get_Root(), "window.new%s%s%s%s url:%s",
3054 isEmpty_Range(&gotoheading) ? "" : " gotoheading:",
3055 isEmpty_Range(&gotoheading) ? "" : cstr_Rangecc(gotoheading),
3056 isEmpty_Range(&gotourlheading) ? "" : " gotourlheading:",
3057 isEmpty_Range(&gotourlheading) ? "" : cstr_Rangecc(gotourlheading),
3058 urlArg);
3059 return iTrue;
3042 } 3060 }
3043 iString *url = collectNewCStr_String(urlArg); 3061 iString *url = collectNewCStr_String(urlArg);
3044 const iBool noProxy = argLabel_Command(cmd, "noproxy") != 0; 3062 const iBool noProxy = argLabel_Command(cmd, "noproxy") != 0;
@@ -3187,7 +3205,12 @@ iBool handleCommand_App(const char *cmd) {
3187 addWindow_App(newWin); /* takes ownership */ 3205 addWindow_App(newWin); /* takes ownership */
3188 SDL_ShowWindow(newWin->base.win); 3206 SDL_ShowWindow(newWin->base.win);
3189 setCurrent_Window(newWin); 3207 setCurrent_Window(newWin);
3190 postCommand_Root(newWin->base.roots[0], "~navigate.home"); 3208 if (hasLabel_Command(cmd, "url")) {
3209 postCommandf_Root(newWin->base.roots[0], "~open %s", cmd + 11 /* all arguments passed on */);
3210 }
3211 else {
3212 postCommand_Root(newWin->base.roots[0], "~navigate.home");
3213 }
3191 postCommand_Root(newWin->base.roots[0], "~window.unfreeze"); 3214 postCommand_Root(newWin->base.roots[0], "~window.unfreeze");
3192 return iTrue; 3215 return iTrue;
3193 } 3216 }
@@ -3745,21 +3768,7 @@ void revealPath_App(const iString *path) {
3745} 3768}
3746 3769
3747iObjectList *listDocuments_App(const iRoot *rootOrNull) { 3770iObjectList *listDocuments_App(const iRoot *rootOrNull) {
3748 iWindow *win = get_Window(); 3771 return listDocuments_MainWindow(get_MainWindow(), rootOrNull);
3749 iObjectList *docs = new_ObjectList();
3750 iForIndices(i, win->roots) {
3751 iRoot *root = win->roots[i];
3752 if (!root) continue;
3753 if (!rootOrNull || root == rootOrNull) {
3754 const iWidget *tabs = findChild_Widget(root->widget, "doctabs");
3755 iForEach(ObjectList, i, children_Widget(findChild_Widget(tabs, "tabs.pages"))) {
3756 if (isInstance_Object(i.object, &Class_DocumentWidget)) {
3757 pushBack_ObjectList(docs, i.object);
3758 }
3759 }
3760 }
3761 }
3762 return docs;
3763} 3772}
3764 3773
3765iStringSet *listOpenURLs_App(void) { 3774iStringSet *listOpenURLs_App(void) {