Line
Link Here
|
0 |
-- a/src/ui/drag-and-drop.cpp |
0 |
++ b/src/ui/drag-and-drop.cpp |
Lines 14-19
Link Here
|
14 |
|
14 |
|
15 |
#include "drag-and-drop.h" |
15 |
#include "drag-and-drop.h" |
16 |
|
16 |
|
|
|
17 |
#include <array> |
17 |
#include <glibmm/i18n.h> // Internationalization |
18 |
#include <glibmm/i18n.h> // Internationalization |
18 |
|
19 |
|
19 |
#include "desktop-style.h" |
20 |
#include "desktop-style.h" |
Lines 60-82
enum ui_drop_target_info {
Link Here
|
60 |
APP_X_INK_PASTE |
61 |
APP_X_INK_PASTE |
61 |
}; |
62 |
}; |
62 |
|
63 |
|
63 |
static GtkTargetEntry ui_drop_target_entries [] = { |
64 |
static const std::array<Gtk::TargetEntry, 8> ui_drop_target_entries = { |
64 |
// clang-format off |
65 |
Gtk::TargetEntry("text/uri-list", Gtk::TargetFlags(0), URI_LIST ), |
65 |
{(gchar *)"text/uri-list", 0, URI_LIST }, |
66 |
Gtk::TargetEntry("image/svg+xml", Gtk::TargetFlags(0), SVG_XML_DATA ), |
66 |
{(gchar *)"image/svg+xml", 0, SVG_XML_DATA }, |
67 |
Gtk::TargetEntry("image/svg", Gtk::TargetFlags(0), SVG_DATA ), |
67 |
{(gchar *)"image/svg", 0, SVG_DATA }, |
68 |
Gtk::TargetEntry("image/png", Gtk::TargetFlags(0), PNG_DATA ), |
68 |
{(gchar *)"image/png", 0, PNG_DATA }, |
69 |
Gtk::TargetEntry("image/jpeg", Gtk::TargetFlags(0), JPEG_DATA ), |
69 |
{(gchar *)"image/jpeg", 0, JPEG_DATA }, |
70 |
Gtk::TargetEntry("application/x-oswb-color", Gtk::TargetFlags(0), APP_OSWB_COLOR ), |
70 |
{(gchar *)"application/x-oswb-color", 0, APP_OSWB_COLOR }, |
71 |
Gtk::TargetEntry("application/x-color", Gtk::TargetFlags(0), APP_X_COLOR ), |
71 |
{(gchar *)"application/x-color", 0, APP_X_COLOR }, |
72 |
Gtk::TargetEntry("application/x-inkscape-paste", Gtk::TargetFlags(0), APP_X_INK_PASTE) |
72 |
{(gchar *)"application/x-inkscape-paste", 0, APP_X_INK_PASTE } |
|
|
73 |
// clang-format on |
74 |
}; |
73 |
}; |
75 |
|
74 |
|
76 |
static GtkTargetEntry *completeDropTargets = nullptr; |
75 |
static std::vector<Gtk::TargetEntry> completeDropTargets; |
77 |
static int completeDropTargetsCount = 0; |
|
|
78 |
|
79 |
static guint nui_drop_target_entries = G_N_ELEMENTS(ui_drop_target_entries); |
80 |
|
76 |
|
81 |
/** Convert screen (x, y) coordinates to desktop coordinates. */ |
77 |
/** Convert screen (x, y) coordinates to desktop coordinates. */ |
82 |
inline Geom::Point world2desktop(SPDesktop *desktop, int x, int y) |
78 |
inline Geom::Point world2desktop(SPDesktop *desktop, int x, int y) |
Lines 74-83
inline Geom::Point world2desktop(SPDesktop *desktop, int x, int y)
Link Here
|
74 |
return (Geom::Point(x, y) + desktop->canvas->get_area_world().min()) * desktop->w2d(); |
74 |
return (Geom::Point(x, y) + desktop->canvas->get_area_world().min()) * desktop->w2d(); |
75 |
} |
75 |
} |
76 |
|
76 |
|
77 |
/* Drag and Drop */ |
77 |
// Drag and Drop |
78 |
static |
78 |
static void ink_drag_data_received(GtkWidget *widget, |
79 |
void |
|
|
80 |
ink_drag_data_received(GtkWidget *widget, |
81 |
GdkDragContext *drag_context, |
79 |
GdkDragContext *drag_context, |
82 |
gint x, gint y, |
80 |
gint x, gint y, |
83 |
GtkSelectionData *data, |
81 |
GtkSelectionData *data, |
Lines 398-459
static void ink_drag_leave( GtkWidget */*widget*/,
Link Here
|
398 |
} |
392 |
} |
399 |
#endif |
393 |
#endif |
400 |
|
394 |
|
401 |
void |
395 |
void ink_drag_setup(SPDesktopWidget *dtw) |
402 |
ink_drag_setup(SPDesktopWidget* dtw) |
|
|
403 |
{ |
396 |
{ |
404 |
if ( completeDropTargets == nullptr || completeDropTargetsCount == 0 ) |
397 |
if (completeDropTargets.empty()) { |
405 |
{ |
398 |
for (auto const &entry : ui_drop_target_entries) { |
406 |
std::vector<Glib::ustring> types; |
399 |
completeDropTargets.emplace_back(entry); |
407 |
|
|
|
408 |
std::vector<Gdk::PixbufFormat> list = Gdk::Pixbuf::get_formats(); |
409 |
for (auto one:list) { |
410 |
std::vector<Glib::ustring> typesXX = one.get_mime_types(); |
411 |
for (auto i:typesXX) { |
412 |
types.push_back(i); |
413 |
} |
414 |
} |
415 |
completeDropTargetsCount = nui_drop_target_entries + types.size(); |
416 |
completeDropTargets = new GtkTargetEntry[completeDropTargetsCount]; |
417 |
for ( int i = 0; i < (int)nui_drop_target_entries; i++ ) { |
418 |
completeDropTargets[i] = ui_drop_target_entries[i]; |
419 |
} |
400 |
} |
420 |
int pos = nui_drop_target_entries; |
401 |
for (auto const &fmt : Gdk::Pixbuf::get_formats()) { |
421 |
|
402 |
for (auto &type : fmt.get_mime_types()) { |
422 |
for (auto & type : types) { |
403 |
completeDropTargets.emplace_back(std::move(type), Gtk::TargetFlags(0), IMAGE_DATA); |
423 |
completeDropTargets[pos].target = g_strdup(type.c_str()); |
404 |
} |
424 |
completeDropTargets[pos].flags = 0; |
|
|
425 |
completeDropTargets[pos].info = IMAGE_DATA; |
426 |
pos++; |
427 |
} |
405 |
} |
428 |
} |
406 |
} |
429 |
|
407 |
|
430 |
auto canvas = dtw->get_canvas(); |
408 |
auto canvas = dtw->get_canvas(); |
431 |
|
409 |
|
432 |
gtk_drag_dest_set(GTK_WIDGET(canvas->gobj()), |
410 |
canvas->drag_dest_set(completeDropTargets, |
433 |
GTK_DEST_DEFAULT_ALL, |
411 |
Gtk::DestDefaults::DEST_DEFAULT_ALL, |
434 |
completeDropTargets, |
412 |
Gdk::DragAction::ACTION_COPY | Gdk::DragAction::ACTION_MOVE); |
435 |
completeDropTargetsCount, |
|
|
436 |
GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE)); |
437 |
|
413 |
|
438 |
g_signal_connect(G_OBJECT(canvas->gobj()), |
414 |
g_signal_connect(G_OBJECT(canvas->gobj()), |
439 |
"drag_data_received", |
415 |
"drag_data_received", |
440 |
G_CALLBACK(ink_drag_data_received), |
416 |
G_CALLBACK(ink_drag_data_received), |
441 |
dtw); |
417 |
dtw); |
442 |
|
|
|
443 |
#if 0 |
444 |
g_signal_connect(G_OBJECT(win->gobj()), |
445 |
"drag_motion", |
446 |
G_CALLBACK(ink_drag_motion), |
447 |
NULL); |
448 |
|
449 |
g_signal_connect(G_OBJECT(win->gobj()), |
450 |
"drag_leave", |
451 |
G_CALLBACK(ink_drag_leave), |
452 |
NULL); |
453 |
#endif |
454 |
} |
418 |
} |
455 |
|
419 |
|
456 |
|
|
|
457 |
/* |
420 |
/* |
458 |
Local Variables: |
421 |
Local Variables: |
459 |
mode:c++ |
422 |
mode:c++ |
460 |
-- a/src/ui/widget/selected-style.cpp |
423 |
++ b/src/ui/widget/selected-style.cpp |
Lines 100-117
enum ui_drop_target_info {
Link Here
|
100 |
APP_OSWB_COLOR |
100 |
APP_OSWB_COLOR |
101 |
}; |
101 |
}; |
102 |
|
102 |
|
103 |
//TODO: warning: deprecated conversion from string constant to ‘gchar*’ |
103 |
static const std::vector<Gtk::TargetEntry> ui_drop_target_entries = { |
104 |
// |
104 |
Gtk::TargetEntry("application/x-oswb-color", Gtk::TargetFlags(0), APP_OSWB_COLOR) |
105 |
//Turn out to be warnings that we should probably leave in place. The |
|
|
106 |
// pointers/types used need to be read-only. So until we correct the using |
107 |
// code, those warnings are actually desired. They say "Hey! Fix this". We |
108 |
// definitely don't want to hide/ignore them. --JonCruz |
109 |
static const GtkTargetEntry ui_drop_target_entries [] = { |
110 |
{g_strdup("application/x-oswb-color"), 0, APP_OSWB_COLOR} |
111 |
}; |
105 |
}; |
112 |
|
106 |
|
113 |
static guint nui_drop_target_entries = G_N_ELEMENTS(ui_drop_target_entries); |
|
|
114 |
|
115 |
/* convenience function */ |
107 |
/* convenience function */ |
116 |
static Dialog::FillAndStroke *get_fill_and_stroke_panel(SPDesktop *desktop); |
108 |
static Dialog::FillAndStroke *get_fill_and_stroke_panel(SPDesktop *desktop); |
117 |
|
109 |
|
Lines 906-933
SelectedStyle::update()
Link Here
|
906 |
place->add(_na[i]); |
898 |
place->add(_na[i]); |
907 |
place->set_tooltip_text(__na[i]); |
899 |
place->set_tooltip_text(__na[i]); |
908 |
_mode[i] = SS_NA; |
900 |
_mode[i] = SS_NA; |
909 |
if ( _dropEnabled[i] ) { |
901 |
if (_dropEnabled[i]) { |
910 |
gtk_drag_dest_unset( GTK_WIDGET((i==SS_FILL) ? _fill_place.gobj():_stroke_place.gobj()) ); |
902 |
auto widget = i == SS_FILL ? &_fill_place : &_stroke_place; |
|
|
903 |
widget->drag_dest_unset(); |
911 |
_dropEnabled[i] = false; |
904 |
_dropEnabled[i] = false; |
912 |
} |
905 |
} |
913 |
break; |
906 |
break; |
914 |
case QUERY_STYLE_SINGLE: |
907 |
case QUERY_STYLE_SINGLE: |
915 |
case QUERY_STYLE_MULTIPLE_AVERAGED: |
908 |
case QUERY_STYLE_MULTIPLE_AVERAGED: |
916 |
case QUERY_STYLE_MULTIPLE_SAME: |
909 |
case QUERY_STYLE_MULTIPLE_SAME: { |
917 |
if ( !_dropEnabled[i] ) { |
910 |
if (!_dropEnabled[i]) { |
918 |
gtk_drag_dest_set( GTK_WIDGET( (i==SS_FILL) ? _fill_place.gobj():_stroke_place.gobj()), |
911 |
auto widget = i == SS_FILL ? &_fill_place : &_stroke_place; |
919 |
GTK_DEST_DEFAULT_ALL, |
912 |
widget->drag_dest_set(ui_drop_target_entries, |
920 |
ui_drop_target_entries, |
913 |
Gtk::DestDefaults::DEST_DEFAULT_ALL, |
921 |
nui_drop_target_entries, |
914 |
Gdk::DragAction::ACTION_COPY | Gdk::DragAction::ACTION_MOVE); |
922 |
GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE) ); |
|
|
923 |
_dropEnabled[i] = true; |
915 |
_dropEnabled[i] = true; |
924 |
} |
916 |
} |
925 |
SPIPaint *paint; |
917 |
auto paint = i == SS_FILL ? query.fill.upcast() : query.stroke.upcast(); |
926 |
if (i == SS_FILL) { |
|
|
927 |
paint = &(query.fill); |
928 |
} else { |
929 |
paint = &(query.stroke); |
930 |
} |
931 |
if (paint->set && paint->isPaintserver()) { |
918 |
if (paint->set && paint->isPaintserver()) { |
932 |
SPPaintServer *server = (i == SS_FILL)? SP_STYLE_FILL_SERVER (&query) : SP_STYLE_STROKE_SERVER (&query); |
919 |
SPPaintServer *server = (i == SS_FILL)? SP_STYLE_FILL_SERVER (&query) : SP_STYLE_STROKE_SERVER (&query); |
933 |
if ( server ) { |
920 |
if ( server ) { |
Lines 999-1004
SelectedStyle::update()
Link Here
|
999 |
flag_place->set_tooltip_text(__multiple[i]); |
986 |
flag_place->set_tooltip_text(__multiple[i]); |
1000 |
} |
987 |
} |
1001 |
break; |
988 |
break; |
|
|
989 |
} |
1002 |
case QUERY_STYLE_MULTIPLE_DIFFERENT: |
990 |
case QUERY_STYLE_MULTIPLE_DIFFERENT: |
1003 |
place->add(_many[i]); |
991 |
place->add(_many[i]); |
1004 |
place->set_tooltip_text(__many[i]); |
992 |
place->set_tooltip_text(__many[i]); |