The branch, trivial, has been updated.

- Log -----------------------------------------------------------------

commit b7d3dcb538f091b24b574f14b0d74da5eab187b3
Author: Jean-Marc Lasgouttes <[email protected]>
Date:   Tue Apr 19 21:48:31 2016 +0200

    Move handling of set-graphics-group to InsetGraphics
    
    It does not make sense to do this kind of handling in Text. Normally, the 
AtPoint property is enough to handle that.

diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp
index 1e83905..cc716a4 100644
--- a/src/LyXAction.cpp
+++ b/src/LyXAction.cpp
@@ -2578,7 +2578,7 @@ void LyXAction::init()
  * \li Origin: sanda, 6 May 2008
  * \endvar
  */
-               { LFUN_SET_GRAPHICS_GROUP, "set-graphics-group", Noop, Edit },
+               { LFUN_SET_GRAPHICS_GROUP, "set-graphics-group", AtPoint, Edit 
},
 
 /*!
  * \var lyx::FuncCode lyx::LFUN_FINISHED_FORWARD
diff --git a/src/Text3.cpp b/src/Text3.cpp
index 2eba1af..72b33d4 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -58,8 +58,6 @@
 #include "insets/InsetExternal.h"
 #include "insets/InsetFloat.h"
 #include "insets/InsetFloatList.h"
-#include "insets/InsetGraphics.h"
-#include "insets/InsetGraphicsParams.h"
 #include "insets/InsetIPAMacro.h"
 #include "insets/InsetNewline.h"
 #include "insets/InsetQuotes.h"
@@ -1216,28 +1214,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                break;
        }
 
-       case LFUN_SET_GRAPHICS_GROUP: {
-               InsetGraphics * ins = graphics::getCurrentGraphicsInset(cur);
-               if (!ins)
-                       break;
-
-               cur.recordUndo();
-
-               string id = to_utf8(cmd.argument());
-               string grp = graphics::getGroupParams(bv->buffer(), id);
-               InsetGraphicsParams tmp, inspar = ins->getParams();
-
-               if (id.empty())
-                       inspar.groupId = to_utf8(cmd.argument());
-               else {
-                       InsetGraphics::string2params(grp, bv->buffer(), tmp);
-                       tmp.filename = inspar.filename;
-                       inspar = tmp;
-               }
-
-               ins->setParams(inspar);
-       }
-
        case LFUN_SPACE_INSERT:
                if (cur.paragraph().layout().free_spacing)
                        insertChar(cur, ' ');
@@ -3055,15 +3031,6 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & 
cmd,
                enable = cur.paragraph().isPassThru();
                break;
 
-       case LFUN_SET_GRAPHICS_GROUP: {
-               InsetGraphics * ins = graphics::getCurrentGraphicsInset(cur);
-               if (!ins)
-                       enable = false;
-               else
-                       flag.setOnOff(to_utf8(cmd.argument()) == 
ins->getParams().groupId);
-               break;
-       }
-
        case LFUN_NEWPAGE_INSERT:
                // not allowed in description items
                code = NEWPAGE_CODE;
diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp
index 323eaac..5e7fa62 100644
--- a/src/insets/InsetGraphics.cpp
+++ b/src/insets/InsetGraphics.cpp
@@ -235,6 +235,24 @@ void InsetGraphics::doDispatch(Cursor & cur, FuncRequest & 
cmd)
                cur.bv().updateDialog("graphics", params2string(params(), 
buffer()));
                break;
 
+       case LFUN_SET_GRAPHICS_GROUP: {
+               cur.recordUndo();
+
+               string id = to_utf8(cmd.argument());
+               string grp = graphics::getGroupParams(cur.bv().buffer(), id);
+               InsetGraphicsParams tmp, inspar = getParams();
+
+               if (id.empty())
+                       inspar.groupId = to_utf8(cmd.argument());
+               else {
+                       InsetGraphics::string2params(grp, cur.bv().buffer(), 
tmp);
+                       tmp.filename = inspar.filename;
+                       inspar = tmp;
+               }
+
+               setParams(inspar);
+       }
+
        case LFUN_GRAPHICS_RELOAD:
                params_.filename.refresh();
                graphic_->reload();
@@ -261,6 +279,11 @@ bool InsetGraphics::getStatus(Cursor & cur, FuncRequest 
const & cmd,
                flag.setEnabled(true);
                return true;
 
+       case LFUN_SET_GRAPHICS_GROUP: {
+               flag.setOnOff(to_utf8(cmd.argument()) == getParams().groupId);
+               return true;
+       }
+
        default:
                return Inset::getStatus(cur, cmd, flag);
        }
@@ -1153,18 +1176,6 @@ void unifyGraphicsGroups(Buffer & b, string const & 
argument)
        b.undo().endUndoGroup();
 }
 
-
-InsetGraphics * getCurrentGraphicsInset(Cursor const & cur)
-{
-       Inset * instmp = &cur.inset();
-       if (instmp->lyxCode() != GRAPHICS_CODE)
-               instmp = cur.nextInset();
-       if (!instmp || instmp->lyxCode() != GRAPHICS_CODE)
-               return 0;
-
-       return static_cast<InsetGraphics *>(instmp);
-}
-
 } // namespace graphics
 
 } // namespace lyx
diff --git a/src/insets/InsetGraphics.h b/src/insets/InsetGraphics.h
index 3cf296f..f7fa573 100644
--- a/src/insets/InsetGraphics.h
+++ b/src/insets/InsetGraphics.h
@@ -151,7 +151,6 @@ namespace graphics {
            Both groupId and params are taken from argument.
        */
        void unifyGraphicsGroups(Buffer &, std::string const &);
-       InsetGraphics * getCurrentGraphicsInset(Cursor const &);
 
 }
 

-----------------------------------------------------------------------

Summary of changes:
 src/LyXAction.cpp            |    2 +-
 src/Text3.cpp                |   33 ---------------------------------
 src/insets/InsetGraphics.cpp |   35 +++++++++++++++++++++++------------
 src/insets/InsetGraphics.h   |    1 -
 4 files changed, 24 insertions(+), 47 deletions(-)


hooks/post-receive
-- 
Repository for new features

Reply via email to