* added "NativeSaver" which combines the MessageExporter and AttributeSaver

to save the document also as icon attribute to a native Icon-O-Matic
  document file
* added cmd-Y short cut to main window (on a German keyboard, Y and Z
  are swapped, but the Undo/Redo shortcuts are still "Z" while Z is much
  harder to reach than Y)
* fixed warning in SetColorCommand.cpp
* FlatIconExporter needs to save the attribute using B_VECTOR_ICON_TYPE
  (of course)



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21235 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2007-05-25 07:53:54 +00:00
parent 68fd0cb964
commit a8745d98e9
7 changed files with 72 additions and 4 deletions

View File

@ -35,6 +35,7 @@
#include "MessageExporter.h"
#include "MessageImporter.h"
#include "MessengerSaver.h"
#include "NativeSaver.h"
#include "PathContainer.h"
#include "RDefExporter.h"
#include "SavePanel.h"
@ -354,7 +355,7 @@ IconEditorApp::_Open(const entry_ref& ref, bool append)
switch (refMode) {
case REF_MESSAGE:
fDocument->SetNativeSaver(
new SimpleFileSaver(new MessageExporter(), ref));
new NativeSaver(ref));
break;
case REF_FLAT:
fDocument->SetExportSaver(
@ -475,7 +476,7 @@ IconEditorApp::_CreateSaver(const entry_ref& ref, uint32 exportMode)
case EXPORT_MODE_MESSAGE:
default:
saver = new SimpleFileSaver(new MessageExporter(), ref);
saver = new NativeSaver(ref);
break;
}

View File

@ -116,6 +116,7 @@ Application Icon-O-Matic :
DocumentSaver.cpp
FileSaver.cpp
MessengerSaver.cpp
NativeSaver.cpp
SimpleFileSaver.cpp
# generic/command

View File

@ -480,6 +480,9 @@ MainWindow::_Init()
fSwatchGroup->SetCurrentColor(CurrentColor::Default());
SetIcon(fDocument->Icon());
AddShortcut('Y', 0, new BMessage(MSG_UNDO));
AddShortcut('Y', B_SHIFT_KEY, new BMessage(MSG_REDO));
}
// _CreateGUI

View File

@ -0,0 +1,35 @@
/*
* Copyright 2007, Haiku. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Stephan Aßmus <superstippi@gmx.de>
*/
#include "NativeSaver.h"
#include "FlatIconFormat.h"
#include "MessageExporter.h"
// constructor
NativeSaver::NativeSaver(const entry_ref& ref)
: fAttrSaver(ref, kVectorAttrNodeName),
fFileSaver(new MessageExporter(), ref)
{
}
// destructor
NativeSaver::~NativeSaver()
{
}
// Save
status_t
NativeSaver::Save(Document* document)
{
status_t ret = fFileSaver.Save(document);
if (ret < B_OK)
return ret;
return fAttrSaver.Save(document);
}

View File

@ -0,0 +1,27 @@
/*
* Copyright 2007, Haiku. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Stephan Aßmus <superstippi@gmx.de>
*/
#ifndef NATIVE_SAVER_H
#define NATIVE_SAVER_H
#include "AttributeSaver.h"
#include "SimpleFileSaver.h"
class NativeSaver : public DocumentSaver {
public:
NativeSaver(const entry_ref& ref);
virtual ~NativeSaver();
virtual status_t Save(Document* document);
protected:
AttributeSaver fAttrSaver;
SimpleFileSaver fFileSaver;
};
#endif // NATIVE_SAVER_H

View File

@ -109,7 +109,7 @@ FlatIconExporter::Export(const Icon* icon, BNode* node,
return ret;
// write buffer to attribute
ssize_t written = node->WriteAttr(attrName, B_RAW_TYPE, 0,
ssize_t written = node->WriteAttr(attrName, B_VECTOR_ICON_TYPE, 0,
buffer.Buffer(), buffer.SizeUsed());
if (written != (ssize_t)buffer.SizeUsed()) {
if (written < 0)

View File

@ -37,7 +37,8 @@ SetColorCommand::InitCheck()
#ifdef __HAIKU__
return fStyle && fStyle->Color() != fColor ? B_OK : B_NO_INIT;
#else
return fStyle && *(uint32*)&fStyle->Color() != *(uint32*)&fColor ?
rgb_color color = fStyle->Color();
return fStyle && *(uint32*)&color != *(uint32*)&fColor ?
B_OK : B_NO_INIT;
#endif
}