index 0e30acf1bd002581a4d8c9ea950aee3082bc4284..5415fdc80fb050af4193d3c11cab77911811b5b9 100644 (file)
--- a/src/dropper-context.cpp
+++ b/src/dropper-context.cpp
#include "color.h"
#include "color-rgba.h"
#include "desktop-style.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "sp-namedview.h"
#include "desktop.h"
#include "desktop-handles.h"
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(dc->area), 0x0000007f, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_item_hide(dc->area);
- if (prefs_get_int_attribute("tools.dropper", "selcue", 0) != 0) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/dropper/selcue")) {
ec->enableSelectionCue();
}
- if (prefs_get_int_attribute("tools.dropper", "gradientdrag", 0) != 0) {
+ if (prefs->getBool("/tools/dropper/gradientdrag")) {
ec->enableGrDrag();
}
}
SPDropperContext *dc = SP_DROPPER_CONTEXT(ec);
ec->enableGrDrag(false);
+
+ if (dc->grabbed) {
+ sp_canvas_item_ungrab(dc->grabbed, GDK_CURRENT_TIME);
+ dc->grabbed = NULL;
+ }
if (dc->area) {
gtk_object_destroy(GTK_OBJECT(dc->area));
}
+/**
+ * Returns the current dropper context icc-color.
+ */
+SPColor* sp_dropper_context_get_icc_color(SPEventContext */*ec*/)
+{
+ //TODO: implement-me!
+
+ return 0; // At least we will cause a clean crash, instead of random corruption.
+}
+
/**
* Returns the current dropper context color.
*/
guint32 sp_dropper_context_get_color(SPEventContext *ec)
{
SPDropperContext *dc = SP_DROPPER_CONTEXT(ec);
-
- int pick = prefs_get_int_attribute("tools.dropper", "pick",
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+ int pick = prefs->getInt("/tools/dropper/pick",
SP_DROPPER_PICK_VISIBLE);
- int setalpha = prefs_get_int_attribute("tools.dropper", "setalpha", 1);
-
+ bool setalpha = prefs->getBool("/tools/dropper/setalpha", true);
+
return SP_RGBA32_F_COMPOSE(dc->R, dc->G, dc->B,
(pick == SP_DROPPER_PICK_ACTUAL && setalpha) ? dc->alpha : 1.0);
}
@@ -157,9 +174,10 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv
SPDropperContext *dc = (SPDropperContext *) event_context;
int ret = FALSE;
SPDesktop *desktop = event_context->desktop;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- int pick = prefs_get_int_attribute("tools.dropper", "pick", SP_DROPPER_PICK_VISIBLE);
- int setalpha = prefs_get_int_attribute("tools.dropper", "setalpha", 1);
+ int pick = prefs->getInt("/tools/dropper/pick", SP_DROPPER_PICK_VISIBLE);
+ bool setalpha = prefs->getBool("/tools/dropper/setalpha", true);
switch (event->type) {
case GDK_BUTTON_PRESS:
@@ -168,6 +186,12 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv
dc->dragging = TRUE;
ret = TRUE;
}
+
+ sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
+ GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK,
+ NULL, event->button.time);
+ dc->grabbed = SP_CANVAS_ITEM(desktop->acetate);
+
break;
case GDK_MOTION_NOTIFY:
if (event->motion.state & GDK_BUTTON2_MASK) {
@@ -308,6 +332,11 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv
{
sp_canvas_item_hide(dc->area);
dc->dragging = FALSE;
+
+ if (dc->grabbed) {
+ sp_canvas_item_ungrab(dc->grabbed, event->button.time);
+ dc->grabbed = NULL;
+ }
double alpha_to_set = setalpha? dc->alpha : 1.0;
@@ -321,7 +350,7 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv
if (!(sp_desktop_selection(desktop)->isEmpty())) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_DROPPER,
+ sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_DROPPER,
_("Set picked color"));
}