From a1f7f2d01e284a7208b21d441ceb84532aaf6a95 Mon Sep 17 00:00:00 2001 From: joncruz Date: Thu, 28 Aug 2008 15:56:26 +0000 Subject: [PATCH] Fixed clipboard code to properly load needed extensions. Fixes bug #171662 --- src/ui/clipboard.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 36ceac0d1..a3f1b9c0d 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -902,6 +902,7 @@ bool ClipboardManagerImpl::_pasteText() */ SPCSSAttr *ClipboardManagerImpl::_parseColor(const Glib::ustring &text) { +// TODO reuse existing code instead of replicating here. Glib::ustring::size_type len = text.bytes(); char *str = const_cast(text.data()); bool attempt_alpha = false; @@ -1060,9 +1061,13 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/) { g_assert( _clipboardSPDoc != NULL ); - const Glib::ustring target = sel.get_target(); + Glib::ustring target = sel.get_target(); if(target == "") return; // this shouldn't happen + if (target == CLIPBOARD_TEXT_TARGET) { + target = "image/x-inkscape-svg"; + } + Inkscape::Extension::DB::OutputList outlist; Inkscape::Extension::db.get_output_list(outlist); Inkscape::Extension::DB::OutputList::const_iterator out = outlist.begin(); @@ -1100,6 +1105,10 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/) } else { + if (!(*out)->loaded()) { + // Need to load the extension. + (*out)->set_state(Inkscape::Extension::Extension::STATE_LOADED); + } (*out)->save(_clipboardSPDoc, filename); } g_file_get_contents(filename, &data, &len, NULL); @@ -1245,8 +1254,18 @@ void ClipboardManagerImpl::_setClipboardTargets() Inkscape::Extension::DB::OutputList outlist; Inkscape::Extension::db.get_output_list(outlist); std::list target_list; + bool plaintextSet = false; for (Inkscape::Extension::DB::OutputList::const_iterator out = outlist.begin() ; out != outlist.end() ; ++out) { - target_list.push_back(Gtk::TargetEntry( (*out)->get_mimetype() )); + if ( !(*out)->deactivated() ) { + Glib::ustring mime = (*out)->get_mimetype(); + if (mime != CLIPBOARD_TEXT_TARGET) { + if ( !plaintextSet && (mime.find("svg") == Glib::ustring::npos) ) { + target_list.push_back(Gtk::TargetEntry(CLIPBOARD_TEXT_TARGET)); + plaintextSet = true; + } + target_list.push_back(Gtk::TargetEntry(mime)); + } + } } // Add PNG export explicitly since there is no extension for this... -- 2.30.2