X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fcontrollers%2FControlGraphics.C;h=6c13079749ced608abd41be664518a1e3c4139b5;hb=96e9048c24b7ec1b4cbdf9f470fcea8bf900b8d0;hp=41a60e9a81a8601c8ac603419a591288ec8eaaab;hpb=cda84cbcdfa4e4b0881c7dda6d91862b4356ac0e;p=lyx.git diff --git a/src/frontends/controllers/ControlGraphics.C b/src/frontends/controllers/ControlGraphics.C index 41a60e9a81..6c13079749 100644 --- a/src/frontends/controllers/ControlGraphics.C +++ b/src/frontends/controllers/ControlGraphics.C @@ -17,13 +17,24 @@ #pragma implementation #endif +#include "ViewBase.h" +#include "ButtonControllerBase.h" #include "ControlGraphics.h" #include "buffer.h" #include "Dialogs.h" -#include "lyxfunc.h" #include "LyXView.h" +#include "gettext.h" #include "insets/insetgraphics.h" +#include "insets/insetgraphicsParams.h" // need operator!=() + +#include "support/FileInfo.h" // for FileInfo +#include "helper_funcs.h" // for browseFile +#include "support/filetools.h" // for AddName +#include "BufferView.h" + +using std::pair; +using std::make_pair; ControlGraphics::ControlGraphics(LyXView & lv, Dialogs & d) : ControlInset(lv, d) @@ -32,12 +43,6 @@ ControlGraphics::ControlGraphics(LyXView & lv, Dialogs & d) } -LyXView * ControlGraphics::lv() const -{ - return &lv_; -} - - InsetGraphicsParams const ControlGraphics::getParams(string const &) { return InsetGraphicsParams(); @@ -64,3 +69,26 @@ void ControlGraphics::applyParamsToInset() void ControlGraphics::applyParamsNoInset() {} + + +// We need these in the file browser. +extern string system_lyxdir; +extern string user_lyxdir; + +string const ControlGraphics::Browse(string const & in_name) +{ + string const title = N_("Graphics|#G#g"); + // FIXME: currently we need the second '|' to prevent mis-interpretation + string const pattern = "*.(eps|png|jpeg|jpg|gif)|"; + + // Does user clipart directory exist? + string clipdir = AddName (user_lyxdir, "clipart"); + FileInfo fileInfo(clipdir); + if (!(fileInfo.isOK() && fileInfo.isDir())) + // No - bail out to system clipart directory + clipdir = AddName (system_lyxdir, "clipart"); + pair dir1(N_("Clipart|#C#c"), clipdir); + + // Show the file browser dialog + return browseFile(&lv_, in_name, title, pattern, dir1); +}