* Cleanup, no functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35189 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
03734edfef
commit
887d9b8b43
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2006 Haiku, Inc. All rights reserved.
|
* Copyright 2002-2010, Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@ -8,10 +8,7 @@
|
|||||||
* Michael Wilber
|
* Michael Wilber
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "DataTranslations.h"
|
#include "DataTranslations.h"
|
||||||
#include "DataTranslationsWindow.h"
|
|
||||||
#include "DataTranslationsSettings.h"
|
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
@ -20,9 +17,8 @@
|
|||||||
#include <TranslatorRoster.h>
|
#include <TranslatorRoster.h>
|
||||||
#include <TextView.h>
|
#include <TextView.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "DataTranslationsSettings.h"
|
||||||
#include <stdlib.h>
|
#include "DataTranslationsWindow.h"
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
const char* kApplicationSignature = "application/x-vnd.Haiku-DataTranslations";
|
const char* kApplicationSignature = "application/x-vnd.Haiku-DataTranslations";
|
||||||
@ -31,35 +27,33 @@ const char* kApplicationSignature = "application/x-vnd.Haiku-DataTranslations";
|
|||||||
DataTranslationsApplication::DataTranslationsApplication()
|
DataTranslationsApplication::DataTranslationsApplication()
|
||||||
: BApplication(kApplicationSignature)
|
: BApplication(kApplicationSignature)
|
||||||
{
|
{
|
||||||
fSettings = new DataTranslationsSettings();
|
|
||||||
new DataTranslationsWindow();
|
new DataTranslationsWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DataTranslationsApplication::~DataTranslationsApplication()
|
DataTranslationsApplication::~DataTranslationsApplication()
|
||||||
{
|
{
|
||||||
delete fSettings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DataTranslationsApplication::SetWindowCorner(BPoint corner)
|
DataTranslationsApplication::SetWindowCorner(const BPoint& leftTop)
|
||||||
{
|
{
|
||||||
fSettings->SetWindowCorner(corner);
|
fSettings.SetWindowCorner(leftTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DataTranslationsApplication::AboutRequested()
|
DataTranslationsApplication::AboutRequested()
|
||||||
{
|
{
|
||||||
BAlert *alert = new BAlert("about", "DataTranslations\n"
|
BAlert* alert = new BAlert("about", "DataTranslations\n\twritten by Oliver "
|
||||||
"\twritten by Oliver Siebenmarck and others\n"
|
"Siebenmarck and others\n\tCopyright 2002-2010, Haiku Inc. All rights "
|
||||||
"\tCopyright 2002-2006, Haiku.\n", "OK");
|
"reserved.\n", "OK");
|
||||||
BTextView *view = alert->TextView();
|
|
||||||
BFont font;
|
|
||||||
|
|
||||||
|
BTextView* view = alert->TextView();
|
||||||
view->SetStylable(true);
|
view->SetStylable(true);
|
||||||
|
|
||||||
|
BFont font;
|
||||||
view->GetFont(&font);
|
view->GetFont(&font);
|
||||||
font.SetSize(18);
|
font.SetSize(18);
|
||||||
font.SetFace(B_BOLD_FACE);
|
font.SetFace(B_BOLD_FACE);
|
||||||
@ -72,9 +66,10 @@ DataTranslationsApplication::AboutRequested()
|
|||||||
void
|
void
|
||||||
DataTranslationsApplication::_InstallError(const char* name, status_t status)
|
DataTranslationsApplication::_InstallError(const char* name, status_t status)
|
||||||
{
|
{
|
||||||
BString text;
|
BString text("Could not install ");
|
||||||
text << "Could not install " << name << ":\n" << strerror(status);
|
text << name << ":\n" << strerror(status);
|
||||||
(new BAlert("DataTranslations - Error", text.String(), "Stop"))->Go();
|
BAlert* alert = new BAlert("DataTranslations - Error", text.String(), "Ok");
|
||||||
|
alert->Go();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -87,7 +82,6 @@ DataTranslationsApplication::_Install(BDirectory& target, BEntry& entry)
|
|||||||
{
|
{
|
||||||
// Find out wether we need to copy it
|
// Find out wether we need to copy it
|
||||||
status_t status = entry.MoveTo(&target, NULL, true);
|
status_t status = entry.MoveTo(&target, NULL, true);
|
||||||
|
|
||||||
if (status == B_OK)
|
if (status == B_OK)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
@ -101,10 +95,11 @@ DataTranslationsApplication::_Install(BDirectory& target, BEntry& entry)
|
|||||||
void
|
void
|
||||||
DataTranslationsApplication::_NoTranslatorError(const char* name)
|
DataTranslationsApplication::_NoTranslatorError(const char* name)
|
||||||
{
|
{
|
||||||
BString text;
|
BString text("The item '");
|
||||||
text.SetTo("The item '");
|
text << name << "' does not appear to be a Translator and will not be "
|
||||||
text << name << "' does not appear to be a Translator and will not be installed.";
|
"installed.";
|
||||||
(new BAlert("", text.String(), "Stop"))->Go();
|
BAlert* alert = new BAlert("", text.String(), "Ok");
|
||||||
|
alert->Go();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -133,8 +128,8 @@ DataTranslationsApplication::RefsReceived(BMessage* message)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry_ref ref;
|
|
||||||
int32 i = 0;
|
int32 i = 0;
|
||||||
|
entry_ref ref;
|
||||||
while (message->FindRef("refs", i++, &ref) == B_OK) {
|
while (message->FindRef("refs", i++, &ref) == B_OK) {
|
||||||
if (!roster->IsTranslator(&ref))
|
if (!roster->IsTranslator(&ref))
|
||||||
_NoTranslatorError(ref.name);
|
_NoTranslatorError(ref.name);
|
||||||
@ -147,14 +142,14 @@ DataTranslationsApplication::RefsReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (target.Contains(ref.name)) {
|
if (target.Contains(ref.name)) {
|
||||||
BString string;
|
BString string("An item named '");
|
||||||
string << "An item named '" << ref.name
|
string << ref.name << "' already exists in the Translators folder! "
|
||||||
<< "' already exists in the Translators folder";
|
"Shall the existing translator be overwritten?";
|
||||||
|
|
||||||
BAlert* alert = new BAlert("DataTranslations - Note", string.String(),
|
BAlert* alert = new BAlert("DataTranslations - Note", string.String(),
|
||||||
"Overwrite", "Stop");
|
"Cancel", "Overwrite");
|
||||||
alert->SetShortcut(1, B_ESCAPE);
|
alert->SetShortcut(0, B_ESCAPE);
|
||||||
if (alert->Go() != 0)
|
if (alert->Go() != 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// the original file will be replaced
|
// the original file will be replaced
|
||||||
@ -164,9 +159,9 @@ DataTranslationsApplication::RefsReceived(BMessage* message)
|
|||||||
|
|
||||||
status = _Install(target, entry);
|
status = _Install(target, entry);
|
||||||
if (status == B_OK) {
|
if (status == B_OK) {
|
||||||
(new BAlert("DataTranslations - Note",
|
BAlert* alert = new BAlert("DataTranslations - Note", "The new "
|
||||||
"The new translator has been installed successfully",
|
"translator has been installed successfully.", "OK");
|
||||||
"OK"))->Go(NULL);
|
alert->Go(NULL);
|
||||||
} else
|
} else
|
||||||
_InstallError(ref.name, status);
|
_InstallError(ref.name, status);
|
||||||
}
|
}
|
||||||
@ -184,4 +179,3 @@ main(int, char**)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2006, Haiku, Inc.
|
* Copyright 2002-2010, Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@ -11,11 +11,12 @@
|
|||||||
#define DATA_TRANSLATIONS_H
|
#define DATA_TRANSLATIONS_H
|
||||||
|
|
||||||
|
|
||||||
#include "DataTranslationsWindow.h"
|
|
||||||
#include "DataTranslationsSettings.h"
|
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
|
|
||||||
|
#include "DataTranslationsSettings.h"
|
||||||
|
|
||||||
|
class BDirectory;
|
||||||
|
class BEntry;
|
||||||
|
|
||||||
class DataTranslationsApplication : public BApplication {
|
class DataTranslationsApplication : public BApplication {
|
||||||
public:
|
public:
|
||||||
@ -23,17 +24,20 @@ class DataTranslationsApplication : public BApplication {
|
|||||||
virtual ~DataTranslationsApplication();
|
virtual ~DataTranslationsApplication();
|
||||||
|
|
||||||
virtual void RefsReceived(BMessage* message);
|
virtual void RefsReceived(BMessage* message);
|
||||||
virtual void AboutRequested(void);
|
virtual void AboutRequested();
|
||||||
|
|
||||||
BPoint WindowCorner() const {return fSettings->WindowCorner(); }
|
BPoint WindowCorner() const {
|
||||||
void SetWindowCorner(BPoint corner);
|
return fSettings.WindowCorner();
|
||||||
|
}
|
||||||
|
void SetWindowCorner(const BPoint& leftTop);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _InstallError(const char* name, status_t status);
|
void _InstallError(const char* name, status_t status);
|
||||||
status_t _Install(BDirectory& target, BEntry& entry);
|
status_t _Install(BDirectory& target, BEntry& entry);
|
||||||
void _NoTranslatorError(const char* name);
|
void _NoTranslatorError(const char* name);
|
||||||
|
|
||||||
DataTranslationsSettings* fSettings;
|
private:
|
||||||
|
DataTranslationsSettings fSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DATA_TRANSLATIONS_H
|
#endif // DATA_TRANSLATIONS_H
|
||||||
|
Loading…
Reference in New Issue
Block a user