summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Smith <john.smith7545@yahoo.com>2012-11-18 12:33:53 +0000
committerJohn Smith <john.smith7545@yahoo.com>2012-11-18 12:33:53 +0000
commitf1a9fc07d9f4cfa94da390247c25ce4ba693a34e (patch)
treee2086e2b37c097ab210558c879c16c3a59e9ec67 /src
parentFix for 177931 : Layer dialog toggle solo mode with Shift/Alt click (diff)
downloadinkscape-f1a9fc07d9f4cfa94da390247c25ce4ba693a34e.tar.gz
inkscape-f1a9fc07d9f4cfa94da390247c25ce4ba693a34e.zip
Fix for 1079971 : Symbol dialog : Drag & Drop to the canvas
(bzr r11880)
Diffstat (limited to 'src')
-rw-r--r--src/desktop.cpp1
-rw-r--r--src/interface.cpp12
-rw-r--r--src/ui/dialog/symbols.cpp27
-rw-r--r--src/ui/dialog/symbols.h1
4 files changed, 40 insertions, 1 deletions
diff --git a/src/desktop.cpp b/src/desktop.cpp
index f10174119..2f8f3e4b6 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -1903,6 +1903,7 @@ SPDesktop::show_dialogs()
mapVerbPreference.insert(std::make_pair ((int)SP_VERB_DIALOG_CLONETILER, "/dialogs/clonetiler") );
mapVerbPreference.insert(std::make_pair ((int)SP_VERB_DIALOG_ITEM, "/dialogs/object") );
mapVerbPreference.insert(std::make_pair ((int)SP_VERB_DIALOG_SPELLCHECK, "/dialogs/spellcheck") );
+ mapVerbPreference.insert(std::make_pair ((int)SP_VERB_DIALOG_SYMBOLS, "/dialogs/symbols") );
for (iter = mapVerbPreference.begin(); iter != mapVerbPreference.end(); iter++) {
int verbId = iter->first;
diff --git a/src/interface.cpp b/src/interface.cpp
index bad95adc6..823119953 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -59,6 +59,7 @@
#include "dialogs/dialog-events.h"
#include "message-context.h"
#include "ui/uxmanager.h"
+#include "ui/clipboard.h"
#include "display/sp-canvas.h"
#include "color.h"
@@ -97,6 +98,7 @@ typedef enum {
APP_X_INKY_COLOR,
APP_X_COLOR,
APP_OSWB_COLOR,
+ APP_X_INK_PASTE
} ui_drop_target_info;
static GtkTargetEntry ui_drop_target_entries [] = {
@@ -109,7 +111,8 @@ static GtkTargetEntry ui_drop_target_entries [] = {
{(gchar *)"application/x-inkscape-color", 0, APP_X_INKY_COLOR},
#endif // ENABLE_MAGIC_COLORS
{(gchar *)"application/x-oswb-color", 0, APP_OSWB_COLOR },
- {(gchar *)"application/x-color", 0, APP_X_COLOR }
+ {(gchar *)"application/x-color", 0, APP_X_COLOR },
+ {(gchar *)"application/x-inkscape-paste", 0, APP_X_INK_PASTE }
};
static GtkTargetEntry *completeDropTargets = 0;
@@ -1430,6 +1433,13 @@ sp_ui_drag_data_received(GtkWidget *widget,
break;
}
+ case APP_X_INK_PASTE: {
+ Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
+ cm->paste(desktop);
+ DocumentUndo::done( doc, SP_VERB_NONE, _("Drop Symbol") );
+ break;
+ }
+
case PNG_DATA:
case JPEG_DATA:
case IMAGE_DATA: {
diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp
index 4e1b82ebe..8cf48f827 100644
--- a/src/ui/dialog/symbols.cpp
+++ b/src/ui/dialog/symbols.cpp
@@ -123,6 +123,12 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) :
iconView->set_tooltip_column( 1 );
iconView->set_pixbuf_column( columns->symbol_image );
+ std::vector< Gtk::TargetEntry > targets;
+ targets.push_back(Gtk::TargetEntry( "application/x-inkscape-paste"));
+
+ iconView->enable_model_drag_source (targets, Gdk::BUTTON1_MASK, Gdk::ACTION_COPY);
+ iconView->signal_drag_data_get().connect(sigc::mem_fun(*this, &SymbolsDialog::iconDragDataGet));
+
sigc::connection connIconChanged;
connIconChanged =
iconView->signal_selection_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::iconChanged));
@@ -228,6 +234,27 @@ void SymbolsDialog::rebuild() {
draw_symbols( symbolDocument );
}
+void SymbolsDialog::iconDragDataGet(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& data, guint info, guint time) {
+
+#if WITH_GTKMM_3_0
+ std::vector<Gtk::TreePath> iconArray = iconView->get_selected_items();
+#else
+ Gtk::IconView::ArrayHandle_TreePaths iconArray = iconView->get_selected_items();
+#endif
+
+ if( iconArray.empty() ) {
+ //std::cout << " iconArray empty: huh? " << std::endl;
+ } else {
+ Gtk::TreeModel::Path const & path = *iconArray.begin();
+ Gtk::ListStore::iterator row = store->get_iter(path);
+ Glib::ustring symbol_id = (*row)[getColumns()->symbol_id];
+
+ GdkAtom dataAtom = gdk_atom_intern( "application/x-inkscape-paste", FALSE );
+ gtk_selection_data_set( data.gobj(), dataAtom, 9, (guchar*)symbol_id.c_str(), symbol_id.length() );
+ }
+
+}
+
void SymbolsDialog::iconChanged() {
#if WITH_GTKMM_3_0
std::vector<Gtk::TreePath> iconArray = iconView->get_selected_items();
diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h
index c2bb4448e..5486ff546 100644
--- a/src/ui/dialog/symbols.h
+++ b/src/ui/dialog/symbols.h
@@ -54,6 +54,7 @@ private:
void rebuild();
void iconChanged();
+ void iconDragDataGet(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection_data, guint info, guint time);
void get_symbols();
void draw_symbols( SPDocument* symbol_document );