}
+void InsetGraphics::setBuffer(Buffer & buffer)
+{
+ if (buffer_) {
+ try {
+ // a file may not be copied successfully when, e.g. buffer_
+ // has already been closed.
+ params_.filename = params_.filename.copyTo(&buffer);
+ } catch (ExceptionMessage const & message) {
+ Alert::error(message.title_, message.details_);
+ // failed to embed
+ params_.filename.setEmbed(false);
+ }
+ }
+ Inset::setBuffer(buffer);
+}
+
+
void InsetGraphics::doDispatch(Cursor & cur, FuncRequest & cmd)
{
switch (cmd.action) {
case LFUN_GRAPHICS_EDIT: {
- InsetGraphicsParams p;
- InsetGraphicsMailer::string2params(to_utf8(cmd.argument()), buffer(), p);
+ InsetGraphicsParams p = params();
+ if (!cmd.argument().empty())
+ InsetGraphicsMailer::string2params(to_utf8(cmd.argument()), buffer(), p);
editGraphics(p, buffer());
break;
}
break;
case LFUN_MOUSE_RELEASE:
- if (!cur.selection())
+ if (!cur.selection() && cmd.button() == mouse_button::button1)
InsetGraphicsMailer(*this).showDialog(&cur.bv());
break;
}
+docstring InsetGraphics::contextMenu(BufferView const &, int, int) const
+{
+ return from_ascii("context-graphics");
+}
+
+
string const InsetGraphicsMailer::name_("graphics");
InsetGraphicsMailer::InsetGraphicsMailer(InsetGraphics & inset)