From 701002a149020e89d9023dbe56c6d0ccdb5c3aca Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 6 Sep 2012 11:25:16 +0900 Subject: Fix for 580160 : Deleting a gradient stop using Shape tools deletes the object (bzr r11655) --- src/spray-context.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/spray-context.cpp') diff --git a/src/spray-context.cpp b/src/spray-context.cpp index 8013d9e3a..bcdc69805 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -892,6 +892,12 @@ gint sp_spray_context_root_handler(SPEventContext *event_context, GdkEvent *even case GDK_KEY_Control_L: case GDK_KEY_Control_R: break; + case GDK_KEY_Delete: + case GDK_KEY_KP_Delete: + case GDK_KEY_BackSpace: + ret = event_context->deleteSelectedDrag(MOD__CTRL_ONLY); + break; + default: break; } -- cgit v1.2.3 From 370a3f5cc9e39352a081e5d5dd8c43676547a6e6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 4 Oct 2012 11:45:44 +1000 Subject: code cleanup: add own includes to cpp files or make the functions static if they are not used elsewhere. (bzr r11735) --- src/spray-context.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/spray-context.cpp') diff --git a/src/spray-context.cpp b/src/spray-context.cpp index bcdc69805..fe478583c 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -134,7 +134,7 @@ static void sp_spray_context_class_init(SPSprayContextClass *klass) } /* Method to rotate items */ -void sp_spray_rotate_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Rotate const &rotation) +static void sp_spray_rotate_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Rotate const &rotation) { Geom::Translate const s(c); Geom::Affine affine = Geom::Affine(s).inverse() * Geom::Affine(rotation) * Geom::Affine(s); @@ -150,7 +150,7 @@ void sp_spray_rotate_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Ge } /* Method to scale items */ -void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Scale const &scale) +static void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Scale const &scale) { Geom::Translate const s(c); item->set_i2d_affine(item->i2dt_affine() * s.inverse() * scale * s); @@ -207,7 +207,7 @@ static void sp_spray_context_dispose(GObject *object) G_OBJECT_CLASS(parent_class)->dispose(object); } -bool is_transform_modes(gint mode) +static bool is_transform_modes(gint mode) { return (mode == SPRAY_MODE_COPY || mode == SPRAY_MODE_CLONE || @@ -215,7 +215,7 @@ bool is_transform_modes(gint mode) mode == SPRAY_OPTION); } -void sp_spray_update_cursor(SPSprayContext *tc, bool /*with_shift*/) +static void sp_spray_update_cursor(SPSprayContext *tc, bool /*with_shift*/) { SPEventContext *event_context = SP_EVENT_CONTEXT(tc); SPDesktop *desktop = event_context->desktop; @@ -342,12 +342,12 @@ static void sp_spray_extinput(SPSprayContext *tc, GdkEvent *event) } } -double get_dilate_radius(SPSprayContext *tc) +static double get_dilate_radius(SPSprayContext *tc) { return 250 * tc->width/SP_EVENT_CONTEXT(tc)->desktop->current_zoom(); } -double get_path_force(SPSprayContext *tc) +static double get_path_force(SPSprayContext *tc) { double force = 8 * (tc->usepressure? tc->pressure : TC_DEFAULT_PRESSURE) /sqrt(SP_EVENT_CONTEXT(tc)->desktop->current_zoom()); @@ -357,28 +357,28 @@ double get_path_force(SPSprayContext *tc) return force * tc->force; } -double get_path_mean(SPSprayContext *tc) +static double get_path_mean(SPSprayContext *tc) { return tc->mean; } -double get_path_standard_deviation(SPSprayContext *tc) +static double get_path_standard_deviation(SPSprayContext *tc) { return tc->standard_deviation; } -double get_move_force(SPSprayContext *tc) +static double get_move_force(SPSprayContext *tc) { double force = (tc->usepressure? tc->pressure : TC_DEFAULT_PRESSURE); return force * tc->force; } -double get_move_mean(SPSprayContext *tc) +static double get_move_mean(SPSprayContext *tc) { return tc->mean; } -double get_move_standard_deviation(SPSprayContext *tc) +static double get_move_standard_deviation(SPSprayContext *tc) { return tc->standard_deviation; } @@ -392,7 +392,7 @@ double get_move_standard_deviation(SPSprayContext *tc) * @param[in] choice : */ -void random_position(double &radius, double &angle, double &a, double &s, int /*choice*/) +static void random_position(double &radius, double &angle, double &a, double &s, int /*choice*/) { // angle is taken from an uniform distribution angle = g_random_double_range(0, M_PI*2.0); @@ -411,7 +411,7 @@ void random_position(double &radius, double &angle, double &a, double &s, int /* } -bool sp_spray_recursive(SPDesktop *desktop, +static bool sp_spray_recursive(SPDesktop *desktop, Inkscape::Selection *selection, SPItem *item, Geom::Point p, @@ -572,7 +572,7 @@ bool sp_spray_recursive(SPDesktop *desktop, return did; } -bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::Point p, Geom::Point vector, bool reverse) +static bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::Point p, Geom::Point vector, bool reverse) { Inkscape::Selection *selection = sp_desktop_selection(SP_EVENT_CONTEXT(tc)->desktop); SPDesktop *desktop = SP_EVENT_CONTEXT(tc)->desktop; @@ -617,7 +617,7 @@ bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::Point p, return did; } -void sp_spray_update_area(SPSprayContext *tc) +static void sp_spray_update_area(SPSprayContext *tc) { double radius = get_dilate_radius(tc); Geom::Affine const sm ( Geom::Scale(radius/(1-tc->ratio), radius/(1+tc->ratio)) ); @@ -625,7 +625,7 @@ void sp_spray_update_area(SPSprayContext *tc) sp_canvas_item_show(tc->dilate_area); } -void sp_spray_switch_mode(SPSprayContext *tc, gint mode, bool with_shift) +static void sp_spray_switch_mode(SPSprayContext *tc, gint mode, bool with_shift) { // select the button mode SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue("spray_tool_mode", mode); @@ -634,7 +634,7 @@ void sp_spray_switch_mode(SPSprayContext *tc, gint mode, bool with_shift) sp_spray_update_cursor(tc, with_shift); } -void sp_spray_switch_mode_temporarily(SPSprayContext *tc, gint mode, bool with_shift) +static void sp_spray_switch_mode_temporarily(SPSprayContext *tc, gint mode, bool with_shift) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); // Juggling about so that prefs have the old value but tc->mode and the button show new mode: -- cgit v1.2.3 From 9cffd82661a0aa17fdb4f6333b8a45ee896901b0 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 3 Dec 2012 15:10:10 +0100 Subject: Translations. Removing sp-color-gtkselector.cpp from translatable files. UI. Fix for Bug #836477 (Spray Tool: Descriptions in status bar "... scroll to spray something" need more words). Translations. Translation template update. (bzr r11926) --- src/spray-context.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/spray-context.cpp') diff --git a/src/spray-context.cpp b/src/spray-context.cpp index fe478583c..07539a080 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -232,13 +232,13 @@ static void sp_spray_update_cursor(SPSprayContext *tc, bool /*with_shift*/) switch (tc->mode) { case SPRAY_MODE_COPY: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray copies of the initial selection."), sel_message); + tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray copies of the initial selection."), sel_message); break; case SPRAY_MODE_CLONE: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray clones of the initial selection."), sel_message); + tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray clones of the initial selection."), sel_message); break; case SPRAY_MODE_SINGLE_PATH: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray in a single path of the initial selection."), sel_message); + tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray in a single path of the initial selection."), sel_message); break; default: break; -- cgit v1.2.3 From 4cff9f1b30d110eba814d9adc0689fa073c79157 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 31 Dec 2012 12:20:39 +0000 Subject: Replace C-style pointer casts in event contexts (bzr r12001) --- src/spray-context.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/spray-context.cpp') diff --git a/src/spray-context.cpp b/src/spray-context.cpp index 07539a080..8d74477c3 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -121,10 +121,10 @@ GType sp_spray_context_get_type(void) static void sp_spray_context_class_init(SPSprayContextClass *klass) { - GObjectClass *object_class = (GObjectClass *) klass; - SPEventContextClass *event_context_class = (SPEventContextClass *) klass; + GObjectClass *object_class = G_OBJECT_CLASS(klass); + SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - parent_class = (SPEventContextClass*)g_type_class_peek_parent(klass); + parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass)); object_class->dispose = sp_spray_context_dispose; @@ -223,7 +223,7 @@ static void sp_spray_update_cursor(SPSprayContext *tc, bool /*with_shift*/) guint num = 0; gchar *sel_message = NULL; if (!desktop->selection->isEmpty()) { - num = g_slist_length((GSList *) desktop->selection->itemList()); + num = g_slist_length(const_cast(desktop->selection->itemList())); sel_message = g_strdup_printf(ngettext("%i object selected","%i objects selected",num), num); } else { sel_message = g_strdup_printf(_("Nothing selected")); @@ -251,8 +251,8 @@ static void sp_spray_context_setup(SPEventContext *ec) { SPSprayContext *tc = SP_SPRAY_CONTEXT(ec); - if (((SPEventContextClass *) parent_class)->setup) { - ((SPEventContextClass *) parent_class)->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(parent_class))->setup) { + (SP_EVENT_CONTEXT_CLASS(parent_class))->setup(ec); } { @@ -460,7 +460,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, parent->appendChild(copy); SPObject *new_obj = doc->getObjectByRepr(copy); - item_copied = (SPItem *) new_obj; //convertion object->item + item_copied = SP_ITEM(new_obj); //convertion object->item Geom::Point center=item->getCenter(); sp_spray_scale_rel(center,desktop, item_copied, Geom::Scale(_scale,_scale)); sp_spray_scale_rel(center,desktop, item_copied, Geom::Scale(scale,scale)); @@ -480,11 +480,11 @@ static bool sp_spray_recursive(SPDesktop *desktop, SPItem *son = NULL; //father copy int i=1; - for (GSList *items = g_slist_copy((GSList *) selection->itemList()); + for (GSList *items = g_slist_copy(const_cast(selection->itemList())); items != NULL; items = items->next) { - SPItem *item1 = (SPItem *) items->data; + SPItem *item1 = SP_ITEM(items->data); if (i == 1) { father = item1; } @@ -504,7 +504,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, Inkscape::XML::Node *copy1 = old_repr->duplicate(xml_doc); parent->appendChild(copy1); SPObject *new_obj1 = doc->getObjectByRepr(copy1); - son = (SPItem *) new_obj1; // conversion object->item + son = SP_ITEM(new_obj1); // conversion object->item unionResult = son; Inkscape::GC::release(copy1); } @@ -514,7 +514,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, Inkscape::XML::Node *copy2 = old_repr->duplicate(xml_doc); parent->appendChild(copy2); SPObject *new_obj2 = doc->getObjectByRepr(copy2); - item_copied = (SPItem *) new_obj2; + item_copied = SP_ITEM(new_obj2); // Move around the cursor Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio), -sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint()); @@ -554,7 +554,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, SPObject *clone_object = doc->getObjectByRepr(clone); // conversion object->item - item_copied = (SPItem *) clone_object; + item_copied = SP_ITEM(clone_object); Geom::Point center = item->getCenter(); sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(_scale, _scale)); sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(scale, scale)); @@ -599,11 +599,11 @@ static bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::P double move_mean = get_move_mean(tc); double move_standard_deviation = get_move_standard_deviation(tc); - for (GSList *items = g_slist_copy((GSList *) selection->itemList()); + for (GSList *items = g_slist_copy(const_cast(selection->itemList())); items != NULL; items = items->next) { - SPItem *item = (SPItem *) items->data; + SPItem *item = SP_ITEM(items->data); if (is_transform_modes(tc->mode)) { if (sp_spray_recursive(desktop, selection, item, p, vector, tc->mode, radius, move_force, tc->population, tc->scale, tc->scale_variation, reverse, move_mean, move_standard_deviation, tc->ratio, tc->tilt, tc->rotation_variation, tc->distrib)) @@ -701,7 +701,7 @@ gint sp_spray_context_root_handler(SPEventContext *event_context, GdkEvent *even guint num = 0; if (!desktop->selection->isEmpty()) { - num = g_slist_length((GSList *) desktop->selection->itemList()); + num = g_slist_length(const_cast(desktop->selection->itemList())); } if (num == 0) { tc->_message_context->flash(Inkscape::ERROR_MESSAGE, _("Nothing selected! Select objects to spray.")); @@ -926,8 +926,8 @@ gint sp_spray_context_root_handler(SPEventContext *event_context, GdkEvent *even } if (!ret) { - if (((SPEventContextClass *) parent_class)->root_handler) { - ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event); + if ((SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler) { + ret = (SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler(event_context, event); } } -- cgit v1.2.3 From 4569747878f930a0992a2b089460f3f8cdcb39c5 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 23 Jan 2013 12:22:14 +0000 Subject: Clean up more GObject type definitions (bzr r12055) --- src/spray-context.cpp | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) (limited to 'src/spray-context.cpp') diff --git a/src/spray-context.cpp b/src/spray-context.cpp index 8d74477c3..694e3a500 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -78,16 +78,13 @@ using namespace std; #define DDC_RED_RGBA 0xff0000ff #define DYNA_MIN_WIDTH 1.0e-6 -static void sp_spray_context_class_init(SPSprayContextClass *klass); -static void sp_spray_context_init(SPSprayContext *ddc); static void sp_spray_context_dispose(GObject *object); static void sp_spray_context_setup(SPEventContext *ec); static void sp_spray_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val); static gint sp_spray_context_root_handler(SPEventContext *ec, GdkEvent *event); -static SPEventContextClass *parent_class = 0; - +G_DEFINE_TYPE(SPSprayContext, sp_spray_context, SP_TYPE_EVENT_CONTEXT); /** * This function returns pseudo-random numbers from a normal distribution @@ -100,32 +97,11 @@ inline double NormalDistribution(double mu, double sigma) return mu + sigma * sqrt( -2.0 * log(g_random_double_range(0, 1)) ) * cos( 2.0*M_PI*g_random_double_range(0, 1) ); } -GType sp_spray_context_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPSprayContextClass), - NULL, NULL, - (GClassInitFunc) sp_spray_context_class_init, - NULL, NULL, - sizeof(SPSprayContext), - 4, - (GInstanceInitFunc) sp_spray_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPSprayContext", &info, (GTypeFlags)0); - } - return type; -} - static void sp_spray_context_class_init(SPSprayContextClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass)); - object_class->dispose = sp_spray_context_dispose; event_context_class->setup = sp_spray_context_setup; @@ -204,7 +180,7 @@ static void sp_spray_context_dispose(GObject *object) delete tc->_message_context; } - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_spray_context_parent_class)->dispose(object); } static bool is_transform_modes(gint mode) @@ -251,8 +227,8 @@ static void sp_spray_context_setup(SPEventContext *ec) { SPSprayContext *tc = SP_SPRAY_CONTEXT(ec); - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->setup) { - (SP_EVENT_CONTEXT_CLASS(parent_class))->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_spray_context_parent_class))->setup) { + (SP_EVENT_CONTEXT_CLASS(sp_spray_context_parent_class))->setup(ec); } { @@ -926,8 +902,8 @@ gint sp_spray_context_root_handler(SPEventContext *event_context, GdkEvent *even } if (!ret) { - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler) { - ret = (SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler(event_context, event); + if ((SP_EVENT_CONTEXT_CLASS(sp_spray_context_parent_class))->root_handler) { + ret = (SP_EVENT_CONTEXT_CLASS(sp_spray_context_parent_class))->root_handler(event_context, event); } } -- cgit v1.2.3 From 6753a094002684a8f14232934c9cdeba13e00e8e Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 18 Mar 2013 00:36:01 +0000 Subject: Fix -Wunused-function warnings (bzr r12221) --- src/spray-context.cpp | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'src/spray-context.cpp') diff --git a/src/spray-context.cpp b/src/spray-context.cpp index 694e3a500..6a5684891 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -610,19 +610,6 @@ static void sp_spray_switch_mode(SPSprayContext *tc, gint mode, bool with_shift) sp_spray_update_cursor(tc, with_shift); } -static void sp_spray_switch_mode_temporarily(SPSprayContext *tc, gint mode, bool with_shift) -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - // Juggling about so that prefs have the old value but tc->mode and the button show new mode: - gint now_mode = prefs->getInt("/tools/spray/mode", 0); - SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue("spray_tool_mode", mode); - // button has changed prefs, restore - prefs->setInt("/tools/spray/mode", now_mode); - // changing prefs changed tc->mode, restore back :) - tc->mode = mode; - sp_spray_update_cursor(tc, with_shift); -} - gint sp_spray_context_root_handler(SPEventContext *event_context, GdkEvent *event) { SPSprayContext *tc = SP_SPRAY_CONTEXT(event_context); -- cgit v1.2.3