Style cleanup. No functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41150 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,11 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006, Haiku.
|
* Copyright 2006, 2011, Stephan Aßmus <superstippi@gmx.de>.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Stephan Aßmus <superstippi@gmx.de>
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "IconEditorApp.h"
|
#include "IconEditorApp.h"
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
@@ -60,7 +58,7 @@ using std::nothrow;
|
|||||||
|
|
||||||
static const char* kAppSig = "application/x-vnd.haiku-icon_o_matic";
|
static const char* kAppSig = "application/x-vnd.haiku-icon_o_matic";
|
||||||
|
|
||||||
// constructor
|
|
||||||
IconEditorApp::IconEditorApp()
|
IconEditorApp::IconEditorApp()
|
||||||
: BApplication(kAppSig),
|
: BApplication(kAppSig),
|
||||||
fMainWindow(NULL),
|
fMainWindow(NULL),
|
||||||
@@ -77,7 +75,7 @@ IconEditorApp::IconEditorApp()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// destructor
|
|
||||||
IconEditorApp::~IconEditorApp()
|
IconEditorApp::~IconEditorApp()
|
||||||
{
|
{
|
||||||
// NOTE: it is important that the GUI has been deleted
|
// NOTE: it is important that the GUI has been deleted
|
||||||
@@ -91,9 +89,10 @@ IconEditorApp::~IconEditorApp()
|
|||||||
delete fMessageAfterSave;
|
delete fMessageAfterSave;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
// QuitRequested
|
|
||||||
bool
|
bool
|
||||||
IconEditorApp::QuitRequested()
|
IconEditorApp::QuitRequested()
|
||||||
{
|
{
|
||||||
@@ -109,7 +108,7 @@ IconEditorApp::QuitRequested()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MessageReceived
|
|
||||||
void
|
void
|
||||||
IconEditorApp::MessageReceived(BMessage* message)
|
IconEditorApp::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
@@ -219,29 +218,19 @@ IconEditorApp::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadyToRun
|
|
||||||
void
|
void
|
||||||
IconEditorApp::ReadyToRun()
|
IconEditorApp::ReadyToRun()
|
||||||
{
|
{
|
||||||
// create file panels
|
// create file panels
|
||||||
BMessenger messenger(this, this);
|
BMessenger messenger(this, this);
|
||||||
BMessage message(B_REFS_RECEIVED);
|
BMessage message(B_REFS_RECEIVED);
|
||||||
fOpenPanel = new BFilePanel(B_OPEN_PANEL,
|
fOpenPanel = new BFilePanel(B_OPEN_PANEL, &messenger, NULL, B_FILE_NODE,
|
||||||
&messenger,
|
true, &message);
|
||||||
NULL,
|
|
||||||
B_FILE_NODE,
|
|
||||||
true,
|
|
||||||
&message);
|
|
||||||
|
|
||||||
message.what = MSG_SAVE_AS;
|
message.what = MSG_SAVE_AS;
|
||||||
fSavePanel = new SavePanel("save panel",
|
fSavePanel = new SavePanel("save panel", &messenger, NULL,
|
||||||
&messenger,
|
B_FILE_NODE | B_DIRECTORY_NODE | B_SYMLINK_NODE, false, &message);
|
||||||
NULL,
|
|
||||||
B_FILE_NODE
|
|
||||||
| B_DIRECTORY_NODE
|
|
||||||
| B_SYMLINK_NODE,
|
|
||||||
false,
|
|
||||||
&message);
|
|
||||||
|
|
||||||
// create main window
|
// create main window
|
||||||
BMessage settings('stns');
|
BMessage settings('stns');
|
||||||
@@ -253,7 +242,7 @@ IconEditorApp::ReadyToRun()
|
|||||||
_InstallDocumentMimeType();
|
_InstallDocumentMimeType();
|
||||||
}
|
}
|
||||||
|
|
||||||
// RefsReceived
|
|
||||||
void
|
void
|
||||||
IconEditorApp::RefsReceived(BMessage* message)
|
IconEditorApp::RefsReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
@@ -269,7 +258,7 @@ IconEditorApp::RefsReceived(BMessage* message)
|
|||||||
_SyncPanels(fOpenPanel, fSavePanel);
|
_SyncPanels(fOpenPanel, fSavePanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ArgvReceived
|
|
||||||
void
|
void
|
||||||
IconEditorApp::ArgvReceived(int32 argc, char** argv)
|
IconEditorApp::ArgvReceived(int32 argc, char** argv)
|
||||||
{
|
{
|
||||||
@@ -282,9 +271,10 @@ IconEditorApp::ArgvReceived(int32 argc, char** argv)
|
|||||||
_Open(ref);
|
_Open(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
// _CheckSaveIcon
|
|
||||||
bool
|
bool
|
||||||
IconEditorApp::_CheckSaveIcon(const BMessage* currentMessage)
|
IconEditorApp::_CheckSaveIcon(const BMessage* currentMessage)
|
||||||
{
|
{
|
||||||
@@ -314,7 +304,7 @@ IconEditorApp::_CheckSaveIcon(const BMessage* currentMessage)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// _PickUpActionBeforeSave
|
|
||||||
void
|
void
|
||||||
IconEditorApp::_PickUpActionBeforeSave()
|
IconEditorApp::_PickUpActionBeforeSave()
|
||||||
{
|
{
|
||||||
@@ -323,7 +313,7 @@ IconEditorApp::_PickUpActionBeforeSave()
|
|||||||
fDocument->WriteUnlock();
|
fDocument->WriteUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fMessageAfterSave)
|
if (fMessageAfterSave == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PostMessage(fMessageAfterSave);
|
PostMessage(fMessageAfterSave);
|
||||||
@@ -331,9 +321,10 @@ IconEditorApp::_PickUpActionBeforeSave()
|
|||||||
fMessageAfterSave = NULL;
|
fMessageAfterSave = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
// _MakeIconEmpty
|
|
||||||
void
|
void
|
||||||
IconEditorApp::_MakeIconEmpty()
|
IconEditorApp::_MakeIconEmpty()
|
||||||
{
|
{
|
||||||
@@ -355,7 +346,7 @@ IconEditorApp::_MakeIconEmpty()
|
|||||||
fMainWindow->Unlock();
|
fMainWindow->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
// _Open
|
|
||||||
void
|
void
|
||||||
IconEditorApp::_Open(const entry_ref& ref, bool append)
|
IconEditorApp::_Open(const entry_ref& ref, bool append)
|
||||||
{
|
{
|
||||||
@@ -506,7 +497,7 @@ IconEditorApp::_Open(const entry_ref& ref, bool append)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// _Open
|
|
||||||
void
|
void
|
||||||
IconEditorApp::_Open(const BMessenger& externalObserver, const uint8* data,
|
IconEditorApp::_Open(const BMessenger& externalObserver, const uint8* data,
|
||||||
size_t size)
|
size_t size)
|
||||||
@@ -524,7 +515,8 @@ IconEditorApp::_Open(const BMessenger& externalObserver, const uint8* data,
|
|||||||
if (data && size > 0) {
|
if (data && size > 0) {
|
||||||
// try to open the icon from the provided data
|
// try to open the icon from the provided data
|
||||||
FlatIconImporter flatImporter;
|
FlatIconImporter flatImporter;
|
||||||
status_t ret = flatImporter.Import(icon, const_cast<uint8*>(data), size);
|
status_t ret = flatImporter.Import(icon, const_cast<uint8*>(data),
|
||||||
|
size);
|
||||||
// NOTE: the const_cast is a bit ugly, but no harm is done
|
// NOTE: the const_cast is a bit ugly, but no harm is done
|
||||||
// the reason is that the LittleEndianBuffer knows read and write
|
// the reason is that the LittleEndianBuffer knows read and write
|
||||||
// mode, in this case it is used read-only, and it does not assume
|
// mode, in this case it is used read-only, and it does not assume
|
||||||
@@ -573,7 +565,7 @@ IconEditorApp::_Open(const BMessenger& externalObserver, const uint8* data,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// _CreateSaver
|
|
||||||
DocumentSaver*
|
DocumentSaver*
|
||||||
IconEditorApp::_CreateSaver(const entry_ref& ref, uint32 exportMode)
|
IconEditorApp::_CreateSaver(const entry_ref& ref, uint32 exportMode)
|
||||||
{
|
{
|
||||||
@@ -621,7 +613,7 @@ IconEditorApp::_CreateSaver(const entry_ref& ref, uint32 exportMode)
|
|||||||
return saver;
|
return saver;
|
||||||
}
|
}
|
||||||
|
|
||||||
// _SyncPanels
|
|
||||||
void
|
void
|
||||||
IconEditorApp::_SyncPanels(BFilePanel* from, BFilePanel* to)
|
IconEditorApp::_SyncPanels(BFilePanel* from, BFilePanel* to)
|
||||||
{
|
{
|
||||||
@@ -641,7 +633,7 @@ IconEditorApp::_SyncPanels(BFilePanel* from, BFilePanel* to)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// _LastFilePath
|
|
||||||
const char*
|
const char*
|
||||||
IconEditorApp::_LastFilePath(path_kind which)
|
IconEditorApp::_LastFilePath(path_kind which)
|
||||||
{
|
{
|
||||||
@@ -679,9 +671,10 @@ IconEditorApp::_LastFilePath(path_kind which)
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
// _StoreSettings
|
|
||||||
void
|
void
|
||||||
IconEditorApp::_StoreSettings()
|
IconEditorApp::_StoreSettings()
|
||||||
{
|
{
|
||||||
@@ -695,7 +688,7 @@ IconEditorApp::_StoreSettings()
|
|||||||
save_settings(&settings, "Icon-O-Matic");
|
save_settings(&settings, "Icon-O-Matic");
|
||||||
}
|
}
|
||||||
|
|
||||||
// _RestoreSettings
|
|
||||||
void
|
void
|
||||||
IconEditorApp::_RestoreSettings(BMessage& settings)
|
IconEditorApp::_RestoreSettings(BMessage& settings)
|
||||||
{
|
{
|
||||||
@@ -706,7 +699,7 @@ IconEditorApp::_RestoreSettings(BMessage& settings)
|
|||||||
fSavePanel->SetExportMode(mode);
|
fSavePanel->SetExportMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// _InstallDocumentMimeType
|
|
||||||
void
|
void
|
||||||
IconEditorApp::_InstallDocumentMimeType()
|
IconEditorApp::_InstallDocumentMimeType()
|
||||||
{
|
{
|
||||||
@@ -727,8 +720,8 @@ IconEditorApp::_InstallDocumentMimeType()
|
|||||||
|
|
||||||
ret = mime.Install();
|
ret = mime.Install();
|
||||||
if (ret < B_OK) {
|
if (ret < B_OK) {
|
||||||
fprintf(stderr, "Could not install native document mime type (%s): %s.\n",
|
fprintf(stderr, "Could not install native document mime type (%s): "
|
||||||
kNativeIconMimeType, strerror(ret));
|
"%s.\n", kNativeIconMimeType, strerror(ret));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// set preferred app
|
// set preferred app
|
||||||
@@ -765,7 +758,7 @@ IconEditorApp::_InstallDocumentMimeType()
|
|||||||
parseError.String());
|
parseError.String());
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Icon-O-Matic writes the icon being saved as icon of the file anyways
|
// NOTE: Icon-O-Matic writes the icon being saved as icon of the file anyway
|
||||||
// therefor, the following code is not needed, it is also not tested and I am
|
// therefor, the following code is not needed, it is also not tested and I am
|
||||||
// spotting an error with SetIcon()
|
// spotting an error with SetIcon()
|
||||||
// // set document icon
|
// // set document icon
|
||||||
@@ -773,13 +766,16 @@ IconEditorApp::_InstallDocumentMimeType()
|
|||||||
// // does not need to be freed (belongs to BApplication base)
|
// // does not need to be freed (belongs to BApplication base)
|
||||||
// if (resources) {
|
// if (resources) {
|
||||||
// size_t size;
|
// size_t size;
|
||||||
// const void* iconData = resources->LoadResource('VICN', "IOM:DOC_ICON", &size);
|
// const void* iconData = resources->LoadResource('VICN', "IOM:DOC_ICON",
|
||||||
|
// &size);
|
||||||
// if (iconData && size > 0) {
|
// if (iconData && size > 0) {
|
||||||
// memcpy(largeIcon.Bits(), iconData, size);
|
// memcpy(largeIcon.Bits(), iconData, size);
|
||||||
// if (mime.SetIcon(&largeIcon, B_LARGE_ICON) < B_OK)
|
// if (mime.SetIcon(&largeIcon, B_LARGE_ICON) < B_OK)
|
||||||
// fprintf(stderr, "Could not set large icon of mime type.\n");
|
// fprintf(stderr, "Could not set large icon of mime type.\n");
|
||||||
// } else
|
// } else {
|
||||||
// fprintf(stderr, "Could not find icon in app resources (data: %p, size: %ld).\n", iconData, size);
|
// fprintf(stderr, "Could not find icon in app resources (data: %p,
|
||||||
|
// "size: %ld).\n", iconData, size);
|
||||||
|
// }
|
||||||
// } else
|
// } else
|
||||||
// fprintf(stderr, "Could not find app resources.\n");
|
// fprintf(stderr, "Could not find app resources.\n");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006, Haiku.
|
* Copyright 2006, 2011, Stephan Aßmus <superstippi@gmx.de>.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Stephan Aßmus <superstippi@gmx.de>
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ICON_EDITOR_APP_H
|
#ifndef ICON_EDITOR_APP_H
|
||||||
#define ICON_EDITOR_APP_H
|
#define ICON_EDITOR_APP_H
|
||||||
|
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
class BFilePanel;
|
class BFilePanel;
|
||||||
class Document;
|
class Document;
|
||||||
class DocumentSaver;
|
class DocumentSaver;
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
class SavePanel;
|
class SavePanel;
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MSG_NEW = 'newi',
|
MSG_NEW = 'newi',
|
||||||
|
|
||||||
@@ -31,6 +30,7 @@ enum {
|
|||||||
MSG_EXPORT_AS = 'xpas',
|
MSG_EXPORT_AS = 'xpas',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
EXPORT_MODE_MESSAGE = 0,
|
EXPORT_MODE_MESSAGE = 0,
|
||||||
EXPORT_MODE_FLAT_ICON,
|
EXPORT_MODE_FLAT_ICON,
|
||||||
@@ -43,14 +43,16 @@ enum {
|
|||||||
EXPORT_MODE_ICON_SOURCE,
|
EXPORT_MODE_ICON_SOURCE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
LAST_PATH_OPEN = 0,
|
LAST_PATH_OPEN = 0,
|
||||||
LAST_PATH_SAVE,
|
LAST_PATH_SAVE,
|
||||||
LAST_PATH_EXPORT,
|
LAST_PATH_EXPORT,
|
||||||
} path_kind;
|
} path_kind;
|
||||||
|
|
||||||
|
|
||||||
class IconEditorApp : public BApplication {
|
class IconEditorApp : public BApplication {
|
||||||
public:
|
public:
|
||||||
IconEditorApp();
|
IconEditorApp();
|
||||||
virtual ~IconEditorApp();
|
virtual ~IconEditorApp();
|
||||||
|
|
||||||
@@ -63,7 +65,7 @@ class IconEditorApp : public BApplication {
|
|||||||
|
|
||||||
// IconEditorApp
|
// IconEditorApp
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _CheckSaveIcon(const BMessage* currentMessage);
|
bool _CheckSaveIcon(const BMessage* currentMessage);
|
||||||
void _PickUpActionBeforeSave();
|
void _PickUpActionBeforeSave();
|
||||||
|
|
||||||
@@ -84,6 +86,7 @@ class IconEditorApp : public BApplication {
|
|||||||
void _RestoreSettings(BMessage& settings);
|
void _RestoreSettings(BMessage& settings);
|
||||||
void _InstallDocumentMimeType();
|
void _InstallDocumentMimeType();
|
||||||
|
|
||||||
|
private:
|
||||||
MainWindow* fMainWindow;
|
MainWindow* fMainWindow;
|
||||||
Document* fDocument;
|
Document* fDocument;
|
||||||
|
|
||||||
@@ -97,4 +100,5 @@ class IconEditorApp : public BApplication {
|
|||||||
BMessage* fMessageAfterSave;
|
BMessage* fMessageAfterSave;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // ICON_EDITOR_APP_H
|
#endif // ICON_EDITOR_APP_H
|
||||||
|
|||||||
Reference in New Issue
Block a user