summaryrefslogtreecommitdiffstats
path: root/src/ui/clipboard.cpp
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2008-08-28 15:56:26 +0000
committerjoncruz <joncruz@users.sourceforge.net>2008-08-28 15:56:26 +0000
commit871681a9f7760bbcd8905adf312cfdb54a66a5b7 (patch)
treeaf9098fdb0b3d76003d7636660146ff265e66492 /src/ui/clipboard.cpp
parentFixed crash due to use of uninitialized pointer (diff)
downloadinkscape-871681a9f7760bbcd8905adf312cfdb54a66a5b7.tar.gz
inkscape-871681a9f7760bbcd8905adf312cfdb54a66a5b7.zip
Fixed clipboard code to properly load needed extensions. Fixes bug #171662
(bzr r6719)
Diffstat (limited to 'src/ui/clipboard.cpp')
-rw-r--r--src/ui/clipboard.cpp23
1 files 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<char *>(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<Gtk::TargetEntry> 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...