2007-08-31 15:42:35 +00:00
|
|
|
/**
|
|
|
|
* \file ControlEmbeddedFiles.cpp
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Bo Peng
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "ControlEmbeddedFiles.h"
|
|
|
|
|
|
|
|
#include "Buffer.h"
|
|
|
|
|
|
|
|
#include "FuncRequest.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "debug.h"
|
2007-08-31 22:02:34 +00:00
|
|
|
#include "Format.h"
|
2007-09-01 04:20:34 +00:00
|
|
|
#include "LyXRC.h"
|
2007-08-31 15:42:35 +00:00
|
|
|
|
2007-09-01 04:20:34 +00:00
|
|
|
#include "frontend_helpers.h"
|
2007-08-31 22:02:34 +00:00
|
|
|
#include "frontends/LyXView.h"
|
2007-09-01 04:20:34 +00:00
|
|
|
|
|
|
|
#include "support/FileFilterList.h"
|
2007-08-31 22:02:34 +00:00
|
|
|
#include "support/convert.h"
|
2007-08-31 15:42:35 +00:00
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
namespace lyx {
|
2007-09-01 04:20:34 +00:00
|
|
|
|
|
|
|
using support::FileFilterList;
|
|
|
|
|
2007-08-31 15:42:35 +00:00
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
ControlEmbeddedFiles::ControlEmbeddedFiles(Dialog & parent)
|
|
|
|
: Dialog::Controller(parent), embedded_files(NULL)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
bool ControlEmbeddedFiles::initialiseParams(string const &)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlEmbeddedFiles::updateEmbeddedFiles()
|
|
|
|
{
|
|
|
|
// copy buffer embeddedFiles to a local copy
|
|
|
|
kernel().buffer().embeddedFiles().update();
|
|
|
|
embedded_files = &kernel().buffer().embeddedFiles();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlEmbeddedFiles::dispatchParams()
|
|
|
|
{
|
|
|
|
// lyx view will only be updated if we do something to the main window. :-)
|
|
|
|
kernel().dispatch(FuncRequest(LFUN_MESSAGE, message_));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 22:02:34 +00:00
|
|
|
void ControlEmbeddedFiles::goTo(EmbeddedFile const & item)
|
|
|
|
{
|
2007-09-01 04:20:34 +00:00
|
|
|
int id = item.parID();
|
|
|
|
if (id != 0) {
|
|
|
|
string const tmp = convert<string>(item.parID());
|
|
|
|
kernel().lyxview().dispatch(FuncRequest(LFUN_PARAGRAPH_GOTO, tmp));
|
|
|
|
}
|
2007-08-31 22:02:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlEmbeddedFiles::view(EmbeddedFile const & item)
|
|
|
|
{
|
|
|
|
formats.view(kernel().buffer(), item, formats.getFormatFromFile(item));
|
|
|
|
}
|
|
|
|
|
2007-09-01 04:20:34 +00:00
|
|
|
|
|
|
|
docstring const ControlEmbeddedFiles::browseFile()
|
|
|
|
{
|
|
|
|
std::pair<docstring, docstring> dir1(_("Documents|#o#O"),
|
|
|
|
lyx::from_utf8(lyxrc.document_path));
|
|
|
|
FileFilterList const filter(_("All file (*.*)"));
|
|
|
|
return browseRelFile(docstring(), lyx::from_utf8(kernel().bufferFilepath()),
|
|
|
|
_("Select a file to embed"),
|
|
|
|
filter, false, dir1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 15:42:35 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|