diff --git a/src/apps/webpositive/BrowserWindow.cpp b/src/apps/webpositive/BrowserWindow.cpp index b797a9c57e..8f7347ed18 100644 --- a/src/apps/webpositive/BrowserWindow.cpp +++ b/src/apps/webpositive/BrowserWindow.cpp @@ -650,20 +650,7 @@ printf(" file ok\n"); int32 index; if (message->FindInt32("tab index", &index) != B_OK) index = -1; - BWebView* webView = dynamic_cast(fTabManager->ViewForTab(index)); - if (webView == CurrentWebView()) - break; - SetCurrentWebView(webView); - if (webView) - _UpdateTitle(webView->MainFrameTitle()); - else - _UpdateTitle(""); - if (webView) { - fURLTextControl->SetText(webView->MainFrameURL()); - // Trigger update of the interface to the new page, by requesting - // to resend all notifications. - webView->WebPage()->ResendNotifications(); - } + _TabChanged(index); break; } @@ -876,6 +863,20 @@ BrowserWindow::NewPageCreated(BWebView* view) } +void +BrowserWindow::CloseWindowRequested(BWebView* view) +{ + int32 index = fTabManager->TabForView(view); + if (index < 0) { + // Tab is already gone. + return; + } + BMessage message(CLOSE_TAB); + message.AddInt32("tab index", index); + PostMessage(&message, this); +} + + void BrowserWindow::LoadNegotiating(const BString& url, BWebView* view) { @@ -1122,7 +1123,7 @@ void BrowserWindow::_UpdateTabGroupVisibility() { if (Lock()) { - //fTabGroup->SetVisible(fTabManager->CountTabs() > 1); +// fTabGroup->SetVisible(fTabManager->CountTabs() > 1); fTabManager->SetCloseButtonsAvailable(fTabManager->CountTabs() > 1); Unlock(); } @@ -1141,6 +1142,26 @@ BrowserWindow::_ShutdownTab(int32 index) } +void +BrowserWindow::_TabChanged(int32 index) +{ + BWebView* webView = dynamic_cast(fTabManager->ViewForTab(index)); + if (webView == CurrentWebView()) + return; + SetCurrentWebView(webView); + if (webView) + _UpdateTitle(webView->MainFrameTitle()); + else + _UpdateTitle(""); + if (webView) { + fURLTextControl->SetText(webView->MainFrameURL()); + // Trigger update of the interface to the new page, by requesting + // to resend all notifications. + webView->WebPage()->ResendNotifications(); + } +} + + status_t BrowserWindow::_BookmarkPath(BPath& path) const { diff --git a/src/apps/webpositive/BrowserWindow.h b/src/apps/webpositive/BrowserWindow.h index 4e6cac811c..823db49adb 100644 --- a/src/apps/webpositive/BrowserWindow.h +++ b/src/apps/webpositive/BrowserWindow.h @@ -87,6 +87,7 @@ private: BWebView* view); virtual void NewWindowRequested(const BString& url, bool primaryAction); + virtual void CloseWindowRequested(BWebView* view); virtual void NewPageCreated(BWebView* view); virtual void LoadNegotiating(const BString& url, BWebView* view); @@ -121,6 +122,7 @@ private: void _UpdateTitle(const BString &title); void _UpdateTabGroupVisibility(); void _ShutdownTab(int32 index); + void _TabChanged(int32 index); status_t _BookmarkPath(BPath& path) const; void _CreateBookmark();