From 0f8dffd779f8f324c013f727ea3bb2aec6bb47e2 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Fri, 15 Feb 2019 00:54:19 +0100 Subject: Add missing icons and add double languaje --- src/live_effects/effect-enum.h | 11 ++++ src/live_effects/effect.cpp | 103 ++++++++++++++++++++++++++-------- src/ui/dialog/livepatheffect-add.cpp | 105 +++++++++++++++++++---------------- 3 files changed, 146 insertions(+), 73 deletions(-) (limited to 'src') diff --git a/src/live_effects/effect-enum.h b/src/live_effects/effect-enum.h index 6a50cffce..c82471439 100644 --- a/src/live_effects/effect-enum.h +++ b/src/live_effects/effect-enum.h @@ -81,6 +81,7 @@ struct EnumEffectData { const Glib::ustring label; const Glib::ustring key; const Glib::ustring icon; + const Glib::ustring untranslated_label; const Glib::ustring description; const bool on_path; const bool on_shape; @@ -178,6 +179,16 @@ class EnumEffectDataConverter { return empty_string; } + const Glib::ustring &get_untranslated_label(const E id) const + { + for (unsigned int i = 0; i < _length; ++i) { + if (_data[i].id == id) + return _data[i].untranslated_label; + } + + return empty_string; + } + const Glib::ustring &get_description(const E id) const { for (unsigned int i = 0; i < _length; ++i) { diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 613eef9e6..960831a5e 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -102,7 +102,8 @@ const EnumEffectData LPETypeData[] = { , N_("Bend") //label , "bend_path" //key , "bend-path" //icon - , N_("Curve a item based on skeleton path") //description + , "Bend" //untranslated name + , N_("Bend an object along the curvature of another path.") //description , true //on_path , true //on_shape , true //on_group @@ -115,7 +116,8 @@ const EnumEffectData LPETypeData[] = { , N_("Gears") //label , "gears" //key , "gears" //icon - , N_("Create configurable gears based on points in path") //description + , "Gears" //untranslated name + , N_("Create interlocking, configurable gears based on the nodes of a path.") //description , true //on_path , true //on_shape , true //on_group @@ -128,7 +130,8 @@ const EnumEffectData LPETypeData[] = { , N_("Pattern Along Path") //label , "skeletal" //key , "skeletal" //icon - , N_("Transform a element along path with optional repeating") //description + , "Pattern Along Path" //untranslated name + , N_("Place one or more copies of another path along the path.") //description , true //on_path , true //on_shape , true //on_group @@ -141,7 +144,8 @@ const EnumEffectData LPETypeData[] = { , N_("Stitch Sub-Paths") //label , "curvestitching" //key , "curvestitching" //icon - , N_("Create a stich between sup-paths") //description + , "Stitch Sub-Paths" //untranslated name + , N_("Draw perpendicular lines between subpaths of a path, like rungs of a ladder.") //description , true //on_path , false //on_shape , true //on_group @@ -155,6 +159,7 @@ const EnumEffectData LPETypeData[] = { , N_("VonKoch") //label , "vonkoch" //key , "vonkoch" //icon + , "VonKoch" //untranslated name , N_("Create VonKoch fractal") //description , true //on_path , true //on_shape @@ -168,7 +173,8 @@ const EnumEffectData LPETypeData[] = { , N_("Knot") //label , "knot" //key , "knot" //icon - , N_("Create holes in self-intersecions like Celtic knots") //description + , "Knot" //untranslated name + , N_("Create gaps in self-intersections, as in Celtic knots") //description , true //on_path , true //on_shape , true //on_group @@ -181,7 +187,8 @@ const EnumEffectData LPETypeData[] = { , N_("Construct grid") //label , "construct_grid" //key , "construct-grid" //icon - , N_("Create a (perspective) grid using points of item") //description + , "Construct grid" //untranslated name + , N_("Create a (perspective) grid from a 3-node path.") //description , true //on_path , true //on_shape , true //on_group @@ -194,7 +201,8 @@ const EnumEffectData LPETypeData[] = { , N_("Spiro spline") //label , "spiro" //key , "spiro" //icon - , N_("Add Spiro bsplie to a path, this usualy is added on path creation and not directly from here") //description + , "Spiro spline" //untranslated name + , N_("Make the path curl like wire, using Spiro B-Splines. This effect is usually used directly on the canvas with the Spiro mode of the drawing tools.") //description , true //on_path , false //on_shape , false //on_group @@ -207,7 +215,8 @@ const EnumEffectData LPETypeData[] = { , N_("Envelope Deformation") //label , "envelope" //key , "envelope" //icon - , N_("Deform a item changing his contourn bounds") //description + , "Envelope Deformation" //untranslated name + , N_("Adjust the shape of an object by transforming paths on its four sides.") //description , true //on_path , true //on_shape , true //on_group @@ -220,7 +229,8 @@ const EnumEffectData LPETypeData[] = { , N_("Interpolate Sub-Paths") //label , "interpolate" //key , "interpolate" //icon - , N_("Add to a path with multiple subpats and interpolate inbetween") //description + , "Interpolate Sub-Paths" //untranslated name + , N_("Create a stepwise transition between the 2 subpaths of a path.") //description , true //on_path , false //on_shape , false //on_group @@ -233,7 +243,8 @@ const EnumEffectData LPETypeData[] = { , N_("Hatches (rough)") //label , "rough_hatches" //key , "rough-hatches" //icon - , N_("Create a weaby line rough hatches in the fill of item") //description + , "Hatches (rough)" //untranslated name + , N_("Fill the object with adjustable hatching.") //description , true //on_path , true //on_shape , true //on_group @@ -246,7 +257,8 @@ const EnumEffectData LPETypeData[] = { , N_("Sketch") //label , "sketch" //key , "sketch" //icon - , N_("Sketch item strokes in a flexible way") //description + , "Sketch" //untranslated name + , N_("Draw multiple short strokes along the path, as in a pencil sketch.") //description , true //on_path , true //on_shape , true //on_group @@ -259,7 +271,8 @@ const EnumEffectData LPETypeData[] = { , N_("Ruler") //label , "ruler" //key , "ruler" //icon - , N_("Create a ruler trought the borders with the stroke style") //description + , "Ruler" //untranslated name + , N_("Add ruler marks to the path in adjustable intervals, using the path's stroke style.") //description , true //on_path , true //on_shape , true //on_group @@ -273,7 +286,8 @@ const EnumEffectData LPETypeData[] = { , N_("Power stroke") //label , "powerstroke" //key , "powerstroke" //icon - , N_("Add variable width to paths with power stroke") //description + , "Power stroke" //untranslated name + , N_("Create calligraphic strokes and control their variable width and curvature. This effect can also be used directly on the canvas with a pressure sensitive stylus and the Pencil tool.") //description , true //on_path , false //on_shape , false //on_group @@ -286,7 +300,8 @@ const EnumEffectData LPETypeData[] = { , N_("Clone original") //label , "clone_original" //key , "clone-original" //icon - , N_("Make the selected item a clone of other, allowin cloning particular attributes and styles") //description + , "Clone original" //untranslated name + , N_("Let a path take on the shape, fill, stroke and/or other attributes of another path.") //description , true //on_path , true //on_shape , true //on_group @@ -300,7 +315,8 @@ const EnumEffectData LPETypeData[] = { , N_("Simplify") //label , "simplify" //key , "simplify" //icon - , N_("Simplify the path, and show the improvements") //description + , "Simplify" //untranslated name + , N_("Smoothen and simplify a path. This effect is also available in the Pencil tool's tool controls.") //description , true //on_path , true //on_shape , true //on_group @@ -313,7 +329,8 @@ const EnumEffectData LPETypeData[] = { , N_("Lattice Deformation 2") //label , "lattice2" //key , "lattice2" //icon - , N_("Deform a item based on a grid") //description + , "Lattice Deformation 2" //untranslated name + , N_("Warp an object's shape based on a 5x5 grid") //description , true //on_path , true //on_shape , true //on_group @@ -326,6 +343,7 @@ const EnumEffectData LPETypeData[] = { , N_("Perspective/Envelope") //label , "perspective-envelope" //key wrong key with "-" retain because historic , "perspective-envelope" //icon + , "Perspective/Envelope" //untranslated name , N_("Perspective or envelope a item by 4 corner ponts") //description , true //on_path , true //on_shape @@ -339,6 +357,7 @@ const EnumEffectData LPETypeData[] = { , N_("Interpolate points") //label , "interpolate_points" //key , "interpolate-points" //icon + , "Interpolate points" //untranslated name , N_("Interpolate points creating diferent conxions between: straight, smooth...") //description , true //on_path , true //on_shape @@ -352,7 +371,8 @@ const EnumEffectData LPETypeData[] = { , N_("Transform by 2 points") //label , "transform_2pts" //key , "transform-2pts" //icon - , N_("Transform a item based in two points, perfect to fit a path between 2 separated paths.") //description + , "Transform by 2 points" //untranslated name + , N_("Scale, stretch and rotate an object by two handles.") //description , true //on_path , true //on_shape , true //on_group @@ -365,6 +385,7 @@ const EnumEffectData LPETypeData[] = { , N_("Show handles") //label , "show_handles" //key , "show-handles" //icon + , "Show handles" //untranslated name , N_("Show handles of element, perfect to temporsty show path handles and nodes") //description , true //on_path , true //on_shape @@ -378,6 +399,7 @@ const EnumEffectData LPETypeData[] = { , N_("Roughen") //label , "roughen" //key , "roughen" //icon + , "Roughen" //untranslated name , N_("Roughen a item so looks a slight more natural or handcrafted or totaly deformed.") //description , true //on_path , true //on_shape @@ -391,6 +413,7 @@ const EnumEffectData LPETypeData[] = { , N_("BSpline") //label , "bspline" //key , "bspline" //icon + , "BSpline" //untranslated name , N_("Add BSpline bsplie to a path, this usualy is added on path creation and not directly from here") //description , true //on_path , false //on_shape @@ -404,6 +427,7 @@ const EnumEffectData LPETypeData[] = { , N_("Join type") //label , "join_type" //key , "join-type" //icon + , "Join type" //untranslated name , N_("Join type convert a path stroke to a real fill path, act lice conbert stroke to path but non destructive. Also have the extrapolated arc option for line joins") //description , true //on_path , true //on_shape @@ -417,7 +441,8 @@ const EnumEffectData LPETypeData[] = { , N_("Taper stroke") //label , "taper_stroke" //key , "taper-stroke" //icon - , N_("Thin starting and/or ending of paths") //description + , "Taper stroke" //untranslated name + , N_("Let the path's ends narrow down to a tip.") //description , true //on_path , true //on_shape , true //on_group @@ -430,7 +455,8 @@ const EnumEffectData LPETypeData[] = { , N_("Mirror symmetry") //label , "mirror_symmetry" //key , "mirror-symmetry" //icon - , N_("Mirror symmetry items, optionaly fussing this and spliting to handle diferent propertyes") //description + , "Mirror symmetry" //untranslated name + , N_("Mirror an object along a movable axis, or around the page center. The mirrored copy can be styled independently.") //description , true //on_path , true //on_shape , true //on_group @@ -443,7 +469,8 @@ const EnumEffectData LPETypeData[] = { , N_("Rotate copies") //label , "copy_rotate" //key , "copy-rotate" //icon - , N_("Rotate copies, optionaly fussing this and spliting to handle diferent propertyes") //description + , "Rotate copies" //untranslated name + , N_("Create multiple rotated copies of an object, as in a kaleidoscope. The copies can be styled independently.") //description , true //on_path , true //on_shape , true //on_group @@ -457,6 +484,7 @@ const EnumEffectData LPETypeData[] = { , N_("Attach path") //label , "attach_path" //key , "attach-path" //icon + , "Attach path" //untranslated name , N_("Join starting and/or ending paths to current path") //description , true //on_path , true //on_shape @@ -470,6 +498,7 @@ const EnumEffectData LPETypeData[] = { , N_("Fill between strokes") //label , "fill_between_strokes" //key , "fill-between-strokes" //icon + , "Fill between strokes" //untranslated name , N_("Create a updateable fill between 2 diferent paths") //description , true //on_path , true //on_shape @@ -483,6 +512,7 @@ const EnumEffectData LPETypeData[] = { , N_("Fill between many") //label , "fill_between_many" //key , "fill-between-many" //icon + , "Fill between many" //untranslated name , N_("Create a updateable fill between many diferent paths") //description , true //on_path , true //on_shape @@ -496,6 +526,7 @@ const EnumEffectData LPETypeData[] = { , N_("Ellipse by 5 points") //label , "ellipse_5pts" //key , "ellipse-5pts" //icon + , "Ellipse by 5 points" //untranslated name , N_("Create a ellipse by a path with 5 points") //description , true //on_path , true //on_shape @@ -509,7 +540,8 @@ const EnumEffectData LPETypeData[] = { , N_("Bounding Box") //label , "bounding_box" //key , "bounding-box" //icon - , N_("Create a bounding box item to apply to another linked element") //description + , "Bounding Box" //untranslated name + , N_("Turn the path into a bounding box that entirely encompasses another path.") //description , true //on_path , true //on_shape , true //on_group @@ -523,6 +555,7 @@ const EnumEffectData LPETypeData[] = { , N_("Measure Segments") //label , "measure_segments" //key , "measure-segments" //icon + , "Measure Segments" //untranslated name , N_("Measure segments, add lines, units, projections...") //description , true //on_path , true //on_shape @@ -536,7 +569,8 @@ const EnumEffectData LPETypeData[] = { , N_("Fillet/Chamfer") //label , "fillet_chamfer" //key , "fillet-chamfer" //icon - , N_("Fillet or chamfer the corners of your path or shape") //description + , "Fillet/Chamfer" //untranslated name + , N_("Adjust the shape of a path's corners, rounding them to a specified radius, or cutting them off.") //description , true //on_path , true //on_shape , false //on_group @@ -549,7 +583,8 @@ const EnumEffectData LPETypeData[] = { , N_("Boolean operation") //label , "bool_op" //key , "bool-op" //icon - , N_("Non destructive boolean operations") //description + , "Boolean operation" //untranslated name + , N_("Cut, union, subtract, intersect and divide a path non-destructively with another path.") //description , true //on_path , true //on_shape , true //on_group @@ -562,6 +597,7 @@ const EnumEffectData LPETypeData[] = { , N_("Embroidery stitch") //label , "embrodery_stitch" //key , "embrodery-stitch" //icon + , "Embroidery stitch" //untranslated name , N_("Embroidery stitch") //description , true //on_path , true //on_shape @@ -575,6 +611,7 @@ const EnumEffectData LPETypeData[] = { , N_("Power clip") //label , "powerclip" //key , "powerclip" //icon + , "Power clip" //untranslated name , N_("Power clip alows to reverse a clip, fatten it...") //description , true //on_path , true //on_shape @@ -588,6 +625,7 @@ const EnumEffectData LPETypeData[] = { , N_("Power mask") //label , "powermask" //key , "powermask" //icon + , "Power mask" //untranslated name , N_("Power mask allow to inverse the mask, make negative..") //description , true //on_path , true //on_shape @@ -601,7 +639,8 @@ const EnumEffectData LPETypeData[] = { , N_("Ellipse from points") //label , "pts2ellipse" //key , "pts2ellipse" //icon - , N_("Ellipse from points in the item") //description + , "Ellipse from points" //untranslated name + , N_("Draw a circle, ellipse, arc or slice based on the nodes of a path.") //description , true //on_path , true //on_shape , true //on_group @@ -614,6 +653,7 @@ const EnumEffectData LPETypeData[] = { , N_("Offset") //label , "offset" //key , "offset" //icon + , "Offset" //untranslated name , N_("Offset a item also with line joins cusp") //description , true //on_path , true //on_shape @@ -627,6 +667,7 @@ const EnumEffectData LPETypeData[] = { , N_("Dash Stroke") //label , "dash_stroke" //key , "dash-stroke" //icon + , "Dash Stroke" //untranslated name , N_("Dash Stroke that fit exatly") //description , true //on_path , true //on_shape @@ -641,6 +682,7 @@ const EnumEffectData LPETypeData[] = { , N_("doEffect stack test") //label , "doeffectstacktest" //key , "experimental" //icon + , "doEffect stack test" //untranslated name , N_("doEffect stack test") //description , true //on_path , true //on_shape @@ -654,6 +696,7 @@ const EnumEffectData LPETypeData[] = { , N_("Angle bisector") //label , "angle_bisector" //key , "experimental" //icon + , "Angle bisector" //untranslated name , N_("Angle bisector") //description , true //on_path , true //on_shape @@ -667,6 +710,7 @@ const EnumEffectData LPETypeData[] = { , N_("Circle (by center and radius)") //label , "circle_with_radius" //key , "experimental" //icon + , "Circle (by center and radius)" //untranslated name , N_("Circle (by center and radius)") //description , true //on_path , true //on_shape @@ -680,6 +724,7 @@ const EnumEffectData LPETypeData[] = { , N_("Circle by 3 points") //label , "circle_3pts" //key , "experimental" //icon + , "Circle by 3 points" //untranslated name , N_("Circle by 3 points") //description , true //on_path , true //on_shape @@ -693,6 +738,7 @@ const EnumEffectData LPETypeData[] = { , N_("Dynamic stroke") //label , "dynastroke" //key , "experimental" //icon + , "Dynamic stroke" //untranslated name , N_("Dynamic stroke") //description , true //on_path , true //on_shape @@ -706,6 +752,7 @@ const EnumEffectData LPETypeData[] = { , N_("Extrude") //label , "extrude" //key , "experimental" //icon + , "Extrude" //untranslated name , N_("Extrude") //description , true //on_path , true //on_shape @@ -719,6 +766,7 @@ const EnumEffectData LPETypeData[] = { , N_("Lattice Deformation") //label , "lattice" //key , "experimental" //icon + , "Lattice Deformation" //untranslated name , N_("Lattice Deformation") //description , true //on_path , true //on_shape @@ -732,6 +780,7 @@ const EnumEffectData LPETypeData[] = { , N_("Line Segment") //label , "line_segment" //key , "experimental" //icon + , "Line Segment" //untranslated name , N_("Line Segment") //description , true //on_path , true //on_shape @@ -745,6 +794,7 @@ const EnumEffectData LPETypeData[] = { , N_("Parallel") //label , "parallel" //key , "experimental" //icon + , "Parallel" //untranslated name , N_("Parallel") //description , true //on_path , true //on_shape @@ -758,6 +808,7 @@ const EnumEffectData LPETypeData[] = { , N_("Path length") //label , "path_length" //key , "experimental" //icon + , "Path length" //untranslated name , N_("Path length") //description , true //on_path , true //on_shape @@ -771,6 +822,7 @@ const EnumEffectData LPETypeData[] = { , N_("Perpendicular bisector") //label , "perp_bisector" //key , "experimental" //icon + , "Perpendicular bisector" //untranslated name , N_("Perpendicular bisector") //description , true //on_path , true //on_shape @@ -784,6 +836,7 @@ const EnumEffectData LPETypeData[] = { , N_("Recursive skeleton") //label , "recursive_skeleton" //key , "experimental" //icon + , "Recursive skeleton" //untranslated name , N_("Recursive skeleton") //description , true //on_path , true //on_shape @@ -797,6 +850,7 @@ const EnumEffectData LPETypeData[] = { , N_("Tangent to curve") //label , "tangent_to_curve" //key , "experimental" //icon + , "Tangent to curve" //untranslated name , N_("Tangent to curve") //description , true //on_path , true //on_shape @@ -810,6 +864,7 @@ const EnumEffectData LPETypeData[] = { , N_("Text label") //label , "text_label" //key , "experimental" //icon + , "Text label" //untranslated name , N_("Text label") //description , true //on_path , true //on_shape diff --git a/src/ui/dialog/livepatheffect-add.cpp b/src/ui/dialog/livepatheffect-add.cpp index 5edcb691f..3cd2ae4ee 100644 --- a/src/ui/dialog/livepatheffect-add.cpp +++ b/src/ui/dialog/livepatheffect-add.cpp @@ -90,28 +90,6 @@ LivePathEffectAdd::LivePathEffectAdd() return; } _builder->get_widget("LPEDialogSelector", _LPEDialogSelector); - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - Inkscape::Selection *sel = desktop->getSelection(); - if ( sel && !sel->isEmpty() ) { - SPItem *item = sel->singleItem(); - if (item) { - SPShape *shape = dynamic_cast(item); - SPPath *path = dynamic_cast(item); - SPGroup *group = dynamic_cast(item); - _item_type = ""; - if (group) { - _item_type = "group"; - } else if (shape) { - _item_type = "shape"; - } else if (path){ - _item_type = "path"; - } else { - _LPEDialogSelector->hide(); - return; - } - } - } - _builder->get_widget("LPESelectorFlowBox", _LPESelectorFlowBox); _builder->get_widget("LPESelectorEffectInfoPop", _LPESelectorEffectInfoPop); _builder->get_widget("LPEFilter", _LPEFilter); @@ -133,20 +111,18 @@ LivePathEffectAdd::LivePathEffectAdd() return; } const LivePathEffect::EnumEffectData *data = &converter.data(i); - bool disable = false; - if (_item_type == "group" && !converter.get_on_group(data->id)) { - disable = true; - } else if (_item_type == "shape" && !converter.get_on_shape(data->id)) { - disable = true; - } else if (_item_type == "path" && !converter.get_on_path(data->id)) { - disable = true; - } Gtk::EventBox *LPESelectorEffect; builder_effect->get_widget("LPESelectorEffect", LPESelectorEffect); LPESelectorEffect->signal_button_press_event().connect(sigc::bind, const LivePathEffect::EnumEffectData * >(sigc::mem_fun(*this, &LivePathEffectAdd::apply), builder_effect, &converter.data(i))); Gtk::Label *LPEName; builder_effect->get_widget("LPEName", LPEName); - LPEName->set_text(converter.get_label(data->id).c_str()); + const Glib::ustring label = converter.get_label(data->id); + const Glib::ustring untranslated_label = converter.get_untranslated_label(data->id); + if (untranslated_label == label) { + LPEName->set_text(label); + } else { + LPEName->set_markup((label + "\n" + untranslated_label + "").c_str()); + } Gtk::Label *LPEDescription; builder_effect->get_widget("LPEDescription", LPEDescription); LPEDescription->set_text(converter.get_description(data->id)); @@ -183,11 +159,6 @@ LivePathEffectAdd::LivePathEffectAdd() LPESelectorEffect->signal_enter_notify_event().connect(sigc::bind(sigc::mem_fun(*this, &LivePathEffectAdd::mouseover), GTK_WIDGET(LPESelectorEffect->gobj()))); LPESelectorEffect->signal_leave_notify_event().connect(sigc::bind(sigc::mem_fun(*this, &LivePathEffectAdd::mouseout), GTK_WIDGET(LPESelectorEffect->gobj()))); _LPESelectorFlowBox->insert(*LPESelectorEffect, i); - if (disable) { - LPESelectorEffect->get_parent()->get_style_context()->add_class("lpedisabled"); - } else { - LPESelectorEffect->get_parent()->get_style_context()->remove_class("lpedisabled"); - } } _visiblelpe = _LPESelectorFlowBox->get_children().size(); _LPEInfo->set_visible(false); @@ -197,21 +168,9 @@ LivePathEffectAdd::LivePathEffectAdd() _LPESelectorEffectInfoEventBox->signal_button_press_event().connect(sigc::mem_fun(*this, &LivePathEffectAdd::hide_pop_description)); _LPESelectorEffectInfoEventBox->signal_enter_notify_event().connect(sigc::bind(sigc::mem_fun(*this, &LivePathEffectAdd::mouseover), GTK_WIDGET(_LPESelectorEffectInfoEventBox->gobj()))); _LPESelectorEffectInfoEventBox->signal_leave_notify_event().connect(sigc::bind(sigc::mem_fun(*this, &LivePathEffectAdd::mouseout), GTK_WIDGET(_LPESelectorEffectInfoEventBox->gobj()))); - _LPESelectorFlowBox->set_sort_func(sigc::mem_fun(*this, &LivePathEffectAdd::on_sort)); _LPESelectorFlowBox->set_filter_func(sigc::mem_fun(*this, &LivePathEffectAdd::on_filter)); _LPEExperimental->property_active().signal_changed().connect(sigc::mem_fun(*this, &LivePathEffectAdd::reload_effect_list)); _LPEDialogSelector->show_all_children(); - int width; - int height; - int width_2; - int height_2; - _LPEDialogSelector->get_default_size (width_2, height_2); - _LPEDialogSelector->get_size (width, height); - if( width == width_2 && height == height_2 ){ - Gtk::Window *window = desktop->getToplevel(); - window->get_size (width, height); - _LPEDialogSelector->resize(std::min( width - 300, 1440), std::min( height - 300, 900)); - } } const LivePathEffect::EnumEffectData* LivePathEffectAdd::getActiveData() @@ -345,8 +304,24 @@ bool LivePathEffectAdd::apply(GdkEventButton* evt, Glib::RefPtr bu return true; } + + bool LivePathEffectAdd::on_filter(Gtk::FlowBoxChild *child) { + const LivePathEffect::EnumEffectData *data = &converter.data(child->get_index()); + bool disable = false; + if (_item_type == "group" && !converter.get_on_group(data->id)) { + disable = true; + } else if (_item_type == "shape" && !converter.get_on_shape(data->id)) { + disable = true; + } else if (_item_type == "path" && !converter.get_on_path(data->id)) { + disable = true; + } + if (disable) { + child->get_style_context()->add_class("lpedisabled"); + } else { + child->get_style_context()->remove_class("lpedisabled"); + } child->set_valign(Gtk::ALIGN_START); Gtk::EventBox *eventbox = dynamic_cast(child->get_child()); if (eventbox) { @@ -511,9 +486,41 @@ void LivePathEffectAdd::onKeyEvent(GdkEventKey* evt) void LivePathEffectAdd::show(SPDesktop *desktop) { LivePathEffectAdd &dial = instance(); + Inkscape::Selection *sel = desktop->getSelection(); + if ( sel && !sel->isEmpty() ) { + SPItem *item = sel->singleItem(); + if (item) { + SPShape *shape = dynamic_cast(item); + SPPath *path = dynamic_cast(item); + SPGroup *group = dynamic_cast(item); + dial._item_type = ""; + if (group) { + dial._item_type = "group"; + } else if (path) { + dial._item_type = "path"; + } else if (shape){ + dial._item_type = "shape"; + } else { + dial._LPEDialogSelector->hide(); + return; + } + } + } + int width; + int height; + int width_2; + int height_2; + dial._LPEDialogSelector->get_default_size (width_2, height_2); + dial._LPEDialogSelector->get_size (width, height); + if( width == width_2 && height == height_2 ){ + Gtk::Window *window = desktop->getToplevel(); + window->get_size (width, height); + dial._LPEDialogSelector->resize(std::min( width - 300, 1440), std::min( height - 300, 900)); + } dial._applied=false; + dial._LPESelectorFlowBox->unset_sort_func(); dial._LPESelectorFlowBox->invalidate_filter(); - dial._LPESelectorFlowBox->invalidate_sort(); + dial._LPESelectorFlowBox->set_sort_func(sigc::mem_fun(dial, &LivePathEffectAdd::on_sort)); Glib::RefPtr< Gtk::Adjustment > vadjust = dial._LPEScrolled->get_vadjustment(); vadjust->set_value(vadjust->get_lower()); dial._LPEDialogSelector->run(); -- cgit v1.2.3