diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-08 14:13:37 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-08 14:13:37 +0300 |
commit | 6bdceb9f1f05ac41d253d95e54d9f9f4594c2f98 (patch) | |
tree | ce1014fc17efa5e6d8d1b55b8f8e4274086ba603 /src/ui/window.c | |
parent | d6875fba63cc674d2d9cac64a66c3b4c9f3eaba1 (diff) |
Creating new tabs; cleaned up DocumentWidget
Diffstat (limited to 'src/ui/window.c')
-rw-r--r-- | src/ui/window.c | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/src/ui/window.c b/src/ui/window.c index defe998f..1f05b80d 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -107,29 +107,34 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { | |||
107 | return iTrue; | 107 | return iTrue; |
108 | } | 108 | } |
109 | } | 109 | } |
110 | else if (equal_Command(cmd, "document.changed")) { | 110 | else if (startsWith_CStr(cmd, "document.")) { |
111 | iInputWidget *url = findWidget_App("url"); | 111 | /* React to the current document only. */ |
112 | const iString *urlStr = collect_String(suffix_Command(cmd, "url")); | 112 | if (document_Command(cmd) == document_App()) { |
113 | visitUrl_Visited(visited_App(), urlStr); | 113 | iLabelWidget *reloadButton = findChild_Widget(navBar, "reload"); |
114 | setText_InputWidget(url, urlStr); | 114 | if (equal_Command(cmd, "document.changed")) { |
115 | updateTextCStr_LabelWidget(findChild_Widget(navBar, "reload"), reloadCStr_); | 115 | iInputWidget *url = findWidget_App("url"); |
116 | return iFalse; | 116 | const iString *urlStr = collect_String(suffix_Command(cmd, "url")); |
117 | } | 117 | setText_InputWidget(url, urlStr); |
118 | else if (equal_Command(cmd, "document.request.cancelled")) { | 118 | updateTextCStr_LabelWidget(reloadButton, reloadCStr_); |
119 | updateTextCStr_LabelWidget(findChild_Widget(navBar, "reload"), reloadCStr_); | 119 | return iFalse; |
120 | return iFalse; | 120 | } |
121 | } | 121 | else if (equal_Command(cmd, "document.request.cancelled")) { |
122 | else if (equal_Command(cmd, "document.request.started")) { | 122 | updateTextCStr_LabelWidget(reloadButton, reloadCStr_); |
123 | iInputWidget *url = findChild_Widget(navBar, "url"); | 123 | return iFalse; |
124 | if (isFocused_Widget(as_Widget(url))) { | 124 | } |
125 | setFocus_Widget(NULL); | 125 | else if (equal_Command(cmd, "document.request.started")) { |
126 | iInputWidget *url = findChild_Widget(navBar, "url"); | ||
127 | if (isFocused_Widget(as_Widget(url))) { | ||
128 | setFocus_Widget(NULL); | ||
129 | } | ||
130 | setTextCStr_InputWidget(url, suffixPtr_Command(cmd, "url")); | ||
131 | updateTextCStr_LabelWidget(reloadButton, stopCStr_); | ||
132 | return iFalse; | ||
133 | } | ||
126 | } | 134 | } |
127 | setTextCStr_InputWidget(url, suffixPtr_Command(cmd, "url")); | ||
128 | updateTextCStr_LabelWidget(findChild_Widget(navBar, "reload"), stopCStr_); | ||
129 | return iFalse; | ||
130 | } | 135 | } |
131 | else if (equal_Command(cmd, "navigate.reload")) { | 136 | else if (equal_Command(cmd, "navigate.reload")) { |
132 | iDocumentWidget *doc = findWidget_App("document"); | 137 | iDocumentWidget *doc = document_Command(cmd); |
133 | if (isRequestOngoing_DocumentWidget(doc)) { | 138 | if (isRequestOngoing_DocumentWidget(doc)) { |
134 | postCommand_App("document.stop"); | 139 | postCommand_App("document.stop"); |
135 | } | 140 | } |
@@ -224,15 +229,16 @@ static void setupUserInterface_Window(iWindow *d) { | |||
224 | setAlignVisually_LabelWidget(fileMenu, iTrue); | 229 | setAlignVisually_LabelWidget(fileMenu, iTrue); |
225 | addChild_Widget(navBar, iClob(fileMenu)); | 230 | addChild_Widget(navBar, iClob(fileMenu)); |
226 | } | 231 | } |
227 | |||
228 | /* Tab bar. */ { | 232 | /* Tab bar. */ { |
229 | iWidget *tabBar = makeTabs_Widget(div); | 233 | iWidget *tabBar = makeTabs_Widget(div); |
230 | setId_Widget(tabBar, "doctabs"); | 234 | setId_Widget(tabBar, "doctabs"); |
231 | setFlags_Widget(tabBar, expand_WidgetFlag, iTrue); | 235 | setFlags_Widget(tabBar, expand_WidgetFlag, iTrue); |
232 | setBackgroundColor_Widget(tabBar, gray25_ColorId); | 236 | setBackgroundColor_Widget(tabBar, gray25_ColorId); |
233 | appendTabPage_Widget(tabBar, iClob(new_DocumentWidget()), "Document", '1', KMOD_PRIMARY); | 237 | appendTabPage_Widget(tabBar, iClob(new_DocumentWidget()), "Document", '1', KMOD_PRIMARY); |
234 | addChild_Widget(findChild_Widget(tabBar, "tabs.buttons"), | 238 | setId_Widget( |
235 | iClob(newIcon_LabelWidget("\u2795", 't', KMOD_PRIMARY, "tabs.new"))); | 239 | addChild_Widget(findChild_Widget(tabBar, "tabs.buttons"), |
240 | iClob(newIcon_LabelWidget("\u2795", 't', KMOD_PRIMARY, "tabs.new"))), | ||
241 | "newtab"); | ||
236 | } | 242 | } |
237 | /* Search bar. */ { | 243 | /* Search bar. */ { |
238 | iWidget *searchBar = new_Widget(); | 244 | iWidget *searchBar = new_Widget(); |