X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fgtk%2FGuiSelection.C;h=c1193f1ece1736a53ae9326178a5ecdce82c2b9b;hb=063994371eb9d3465ddeda0a41aa450f891043be;hp=350c08ccdd736bf96b99ce006613c472a6cd1b09;hpb=ebaaff58fad6299f19bfd65157b5deabf6925fcf;p=lyx.git diff --git a/src/frontends/gtk/GuiSelection.C b/src/frontends/gtk/GuiSelection.C index 350c08ccdd..c1193f1ece 100644 --- a/src/frontends/gtk/GuiSelection.C +++ b/src/frontends/gtk/GuiSelection.C @@ -21,8 +21,14 @@ #endif #include "GuiSelection.h" + +#include "BufferView.h" #include "debug.h" +#include "frontends/Application.h" +#include "frontends/Gui.h" +#include "frontends/LyXView.h" + #include using std::endl; @@ -50,5 +56,38 @@ void GuiSelection::put(docstring const & str) clipboard->set_text(utf8); } + +void GuiSelection::onClipboardGet(Gtk::SelectionData & /*selection_data*/, + guint /*info*/) +{ + // FIXME: This assumes only one LyXView + lyx::docstring const sel = theApp->gui().view(0).view()->requestSelection(); + if (!sel.empty()) + put(sel); +} + + +void GuiSelection::onClipboardClear() +{ + // FIXME: This assumes only one LyXView + theApp->gui().view(0).view()->clearSelection(); +} + + +void GuiSelection::haveSelection(bool toHave) +{ + if (toHave) { + Glib::RefPtr clipboard = + Gtk::Clipboard::get(GDK_SELECTION_PRIMARY); + std::vector listTargets; + listTargets.push_back(Gtk::TargetEntry("UTF8_STRING")); + clipboard->set(listTargets, + sigc::mem_fun(const_cast(*this), + &GuiSelection::onClipboardGet), + sigc::mem_fun(const_cast(*this), + &GuiSelection::onClipboardClear)); + } +} + } // namespace frontend } // namespace lyx