Added a method to PrefHandler to save the default settings, and used it

in TermWindow and PrefWindow. Added patch by adparadox which implements
menuitem and shortcut to close the active tab (slightly modified by me).
I went with COMMAND-SHIFT-W instead of COMMAND-W.
This fixes bug #3898.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34176 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2009-11-21 17:18:28 +00:00
parent 92d7fb19f1
commit 411d718eec
4 changed files with 26 additions and 16 deletions

View File

@ -163,6 +163,15 @@ PrefHandler::Save(const char *path)
} }
void
PrefHandler::SaveDefaultAsText()
{
BPath path;
if (GetDefaultPath(path) == B_OK)
SaveAsText(path.Path(), PREFFILE_MIMETYPE);
}
void void
PrefHandler::SaveAsText(const char *path, const char *mimetype, PrefHandler::SaveAsText(const char *path, const char *mimetype,
const char *signature) const char *signature)

View File

@ -68,6 +68,7 @@ class PrefHandler {
status_t Open(const char *name); status_t Open(const char *name);
status_t OpenText(const char *path); status_t OpenText(const char *path);
status_t Save(const char *name); status_t Save(const char *name);
void SaveDefaultAsText();
void SaveAsText(const char *path, const char *minmtype = NULL, void SaveAsText(const char *path, const char *minmtype = NULL,
const char *signature = NULL); const char *signature = NULL);

View File

@ -132,11 +132,8 @@ PrefWindow::_Save()
delete fPreviousPref; delete fPreviousPref;
fPreviousPref = new PrefHandler(PrefHandler::Default()); fPreviousPref = new PrefHandler(PrefHandler::Default());
BPath path; PrefHandler::Default()->SaveDefaultAsText();
if (PrefHandler::GetDefaultPath(path) == B_OK) { fDirty = false;
PrefHandler::Default()->SaveAsText(path.Path(), PREFFILE_MIMETYPE);
fDirty = false;
}
} }

View File

@ -166,11 +166,9 @@ TermWindow::~TermWindow()
// TODO: Code duplication. Exterminate // TODO: Code duplication. Exterminate
if (fPrefWindow) if (fPrefWindow)
fPrefWindow->PostMessage(B_QUIT_REQUESTED); fPrefWindow->PostMessage(B_QUIT_REQUESTED);
else { else
BPath path; PrefHandler::Default()->SaveDefaultAsText();
if (PrefHandler::GetDefaultPath(path) == B_OK)
PrefHandler::Default()->SaveAsText(path.Path(), PREFFILE_MIMETYPE);
}
if (fFindPanel && fFindPanel->Lock()) { if (fFindPanel && fFindPanel->Lock()) {
fFindPanel->Quit(); fFindPanel->Quit();
@ -297,6 +295,8 @@ TermWindow::_SetupMenu()
fFilemenu->AddItem(new BMenuItem("About Terminal" B_UTF8_ELLIPSIS, fFilemenu->AddItem(new BMenuItem("About Terminal" B_UTF8_ELLIPSIS,
new BMessage(B_ABOUT_REQUESTED))); new BMessage(B_ABOUT_REQUESTED)));
fFilemenu->AddSeparatorItem(); fFilemenu->AddSeparatorItem();
fFilemenu->AddItem(new BMenuItem("Close Active Tab",
new BMessage(kCloseView), 'W', B_SHIFT_KEY));
fFilemenu->AddItem(new BMenuItem("Quit", fFilemenu->AddItem(new BMenuItem("Quit",
new BMessage(B_QUIT_REQUESTED), 'Q')); new BMessage(B_QUIT_REQUESTED), 'Q'));
fMenubar->AddItem(fFilemenu); fMenubar->AddItem(fFilemenu);
@ -631,12 +631,15 @@ TermWindow::MessageReceived(BMessage *message)
case kCloseView: case kCloseView:
{ {
TermView* termView; TermView* termView;
if (message->FindPointer("termView", (void**)&termView) == B_OK) { int32 index = -1;
int32 index = _IndexOfTermView(termView); if (message->FindPointer("termView", (void**)&termView) == B_OK)
if (index >= 0) { index = _IndexOfTermView(termView);
_RemoveTab(index); else
} index = _IndexOfTermView(_ActiveTermView());
}
if (index >= 0)
_RemoveTab(index);
break; break;
} }