diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/extension/param/description.cpp | 5 | ||||
| -rw-r--r-- | src/helper/action.cpp | 71 | ||||
| -rw-r--r-- | src/seltrans.cpp | 7 | ||||
| -rw-r--r-- | src/sp-item-transform.cpp | 15 | ||||
| -rw-r--r-- | src/sp-item-transform.h | 2 | ||||
| -rw-r--r-- | src/ui/dialog/new-from-template.cpp | 2 | ||||
| -rw-r--r-- | src/ui/dialog/pixelartdialog.cpp | 4 | ||||
| -rw-r--r-- | src/ui/dialog/swatches.cpp | 4 | ||||
| -rw-r--r-- | src/ui/dialog/template-load-tab.cpp | 10 | ||||
| -rw-r--r-- | src/ui/dialog/template-load-tab.h | 2 | ||||
| -rw-r--r-- | src/ui/dialog/template-widget.cpp | 2 | ||||
| -rw-r--r-- | src/widgets/select-toolbar.cpp | 2 | ||||
| -rw-r--r-- | src/xml/quote.cpp | 16 |
13 files changed, 81 insertions, 61 deletions
diff --git a/src/extension/param/description.cpp b/src/extension/param/description.cpp index c9cea73d4..95ed04afc 100644 --- a/src/extension/param/description.cpp +++ b/src/extension/param/description.cpp @@ -66,7 +66,10 @@ ParamDescription::ParamDescription (const gchar * name, Gtk::Widget * ParamDescription::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * /*changeSignal*/) { - if (_gui_hidden) { + if (_gui_hidden) { + return NULL; + } + if (_value == NULL) { return NULL; } diff --git a/src/helper/action.cpp b/src/helper/action.cpp index 28cb40334..060bf317c 100644 --- a/src/helper/action.cpp +++ b/src/helper/action.cpp @@ -40,16 +40,16 @@ sp_action_class_init (SPActionClass *klass) static void sp_action_init (SPAction *action) { - action->sensitive = 0; - action->active = 0; - action->context = Inkscape::ActionContext(); - action->id = action->name = action->tip = NULL; - action->image = NULL; - - new (&action->signal_perform) sigc::signal<void>(); - new (&action->signal_set_sensitive) sigc::signal<void, bool>(); - new (&action->signal_set_active) sigc::signal<void, bool>(); - new (&action->signal_set_name) sigc::signal<void, Glib::ustring const &>(); + action->sensitive = 0; + action->active = 0; + action->context = Inkscape::ActionContext(); + action->id = action->name = action->tip = NULL; + action->image = NULL; + + new (&action->signal_perform) sigc::signal<void>(); + new (&action->signal_set_sensitive) sigc::signal<void, bool>(); + new (&action->signal_set_active) sigc::signal<void, bool>(); + new (&action->signal_set_name) sigc::signal<void, Glib::ustring const &>(); } /** @@ -84,17 +84,17 @@ sp_action_new(Inkscape::ActionContext const &context, const gchar *image, Inkscape::Verb * verb) { - SPAction *action = (SPAction *)g_object_new(SP_TYPE_ACTION, NULL); + SPAction *action = (SPAction *)g_object_new(SP_TYPE_ACTION, NULL); - action->context = context; - action->sensitive = TRUE; - action->id = g_strdup (id); - action->name = g_strdup (name); - action->tip = g_strdup (tip); - action->image = g_strdup (image); - action->verb = verb; + action->context = context; + action->sensitive = TRUE; + action->id = g_strdup (id); + action->name = g_strdup (name); + action->tip = g_strdup (tip); + action->image = g_strdup (image); + action->verb = verb; - return action; + return action; } namespace { @@ -129,11 +129,11 @@ public: */ void sp_action_perform(SPAction *action, void * /*data*/) { - g_return_if_fail (action != NULL); - g_return_if_fail (SP_IS_ACTION (action)); + g_return_if_fail (action != NULL); + g_return_if_fail (SP_IS_ACTION (action)); - Inkscape::Debug::EventTracker<ActionEvent> tracker(action); - action->signal_perform.emit(); + Inkscape::Debug::EventTracker<ActionEvent> tracker(action); + action->signal_perform.emit(); } /** @@ -142,10 +142,10 @@ void sp_action_perform(SPAction *action, void * /*data*/) void sp_action_set_active (SPAction *action, unsigned int active) { - g_return_if_fail (action != NULL); - g_return_if_fail (SP_IS_ACTION (action)); + g_return_if_fail (action != NULL); + g_return_if_fail (SP_IS_ACTION (action)); - action->signal_set_active.emit(active); + action->signal_set_active.emit(active); } /** @@ -154,15 +154,18 @@ sp_action_set_active (SPAction *action, unsigned int active) void sp_action_set_sensitive (SPAction *action, unsigned int sensitive) { - g_return_if_fail (action != NULL); - g_return_if_fail (SP_IS_ACTION (action)); + g_return_if_fail (action != NULL); + g_return_if_fail (SP_IS_ACTION (action)); - action->signal_set_sensitive.emit(sensitive); + action->signal_set_sensitive.emit(sensitive); } void sp_action_set_name (SPAction *action, Glib::ustring const &name) { + g_return_if_fail (action != NULL); + g_return_if_fail (SP_IS_ACTION (action)); + g_free(action->name); action->name = g_strdup(name.data()); action->signal_set_name.emit(name); @@ -174,8 +177,8 @@ sp_action_set_name (SPAction *action, Glib::ustring const &name) SPDocument * sp_action_get_document (SPAction *action) { - g_return_val_if_fail (SP_IS_ACTION (action), NULL); - return action->context.getDocument(); + g_return_val_if_fail (SP_IS_ACTION (action), NULL); + return action->context.getDocument(); } /** @@ -194,8 +197,8 @@ sp_action_get_selection (SPAction *action) Inkscape::UI::View::View * sp_action_get_view (SPAction *action) { - g_return_val_if_fail (SP_IS_ACTION (action), NULL); - return action->context.getView(); + g_return_val_if_fail (SP_IS_ACTION (action), NULL); + return action->context.getView(); } /** @@ -209,7 +212,7 @@ sp_action_get_desktop (SPAction *action) // already the norm in the Inkscape codebase. This seems wrong. Surely // we should store an SPDesktop* in the first place? Is there a case // of actions being carried out on a View that is not an SPDesktop? - return static_cast<SPDesktop *>(sp_action_get_view(action)); + return static_cast<SPDesktop *>(sp_action_get_view(action)); } /* diff --git a/src/seltrans.cpp b/src/seltrans.cpp index f961e309d..d1d39532c 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -1460,7 +1460,8 @@ Geom::Point Inkscape::SelTrans::_getGeomHandlePos(Geom::Point const &visual_hand // Calculate the absolute affine while taking into account the scaling of the stroke width Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool transform_stroke = prefs->getBool("/options/transform/stroke", true); - Geom::Affine abs_affine = get_scale_transform_for_uniform_stroke (*_bbox, _strokewidth, transform_stroke, + bool preserve = prefs->getBool("/options/preservetransform/value", false); + Geom::Affine abs_affine = get_scale_transform_for_uniform_stroke (*_bbox, _strokewidth, transform_stroke, preserve, new_bbox.min()[Geom::X], new_bbox.min()[Geom::Y], new_bbox.max()[Geom::X], new_bbox.max()[Geom::Y]); // Calculate the scaled geometrical bbox @@ -1499,15 +1500,17 @@ Geom::Point Inkscape::SelTrans::_calcAbsAffineDefault(Geom::Scale const default_ Geom::Point new_bbox_max = _visual_bbox->max() * abs_affine; bool transform_stroke = false; + bool preserve = false; gdouble strokewidth = 0; if ( _snap_bbox_type != SPItem::GEOMETRIC_BBOX) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); transform_stroke = prefs->getBool("/options/transform/stroke", true); + preserve = prefs->getBool("/options/preservetransform/value", false); strokewidth = _strokewidth; } - _absolute_affine = get_scale_transform_for_uniform_stroke (*_visual_bbox, strokewidth, transform_stroke, + _absolute_affine = get_scale_transform_for_uniform_stroke (*_visual_bbox, strokewidth, transform_stroke, preserve, new_bbox_min[Geom::X], new_bbox_min[Geom::Y], new_bbox_max[Geom::X], new_bbox_max[Geom::Y]); // return the new handle position diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index a27a1bc78..70cb74940 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -94,7 +94,7 @@ void sp_item_move_rel(SPItem *item, Geom::Translate const &tr) * not possible here because it will only allow for a positive width and height, and therefore cannot mirror * @return */ -Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visual, gdouble strokewidth, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1) +Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visual, gdouble strokewidth, bool transform_stroke, bool preserve, gdouble x0, gdouble y0, gdouble x1, gdouble y1) { Geom::Affine p2o = Geom::Translate (-bbox_visual.min()); Geom::Affine o2n = Geom::Translate (x0, y0); @@ -147,13 +147,13 @@ Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visua ratio_y = (h1 - r0) / (h0 - r0); r1 = transform_stroke ? r0 * sqrt(h1/h0) : r0; scale_x = 1; - scale_y = (h1 - r1)/(h0 - r0); + scale_y = preserve ? h1/h0 : (h1 - r1)/(h0 - r0); } else if (fabs(h0 - r0) < 1e-6) { // We have a horizontal line at hand direct = Geom::Scale(flip_x * w1 / w0, flip_y); ratio_x = (w1 - r0) / (w0 - r0); ratio_y = 1; r1 = transform_stroke ? r0 * sqrt(w1/w0) : r0; - scale_x = (w1 - r1)/(w0 - r0); + scale_x = preserve ? w1/w0 : (w1 - r1)/(w0 - r0); scale_y = 1; } else { // We have a true 2D object at hand direct = Geom::Scale(flip_x * w1 / w0, flip_y* h1 / h0); // Scaling of the visual bounding box @@ -164,21 +164,21 @@ Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visua * This is how the stroke should scale: r1^2 / A1 = r0^2 / A0 * So therefore we will need to solve this equation: * - * r1^2 * (w0-r0) * (h1-r1) = r0^2 * (w1-r1) * (h0-r0) + * r1^2 * (w0-r0) * (h0-r0) = r0^2 * (w1-r1) * (h1-r1) * * This is a quadratic equation in r1, of which the roots can be found using the ABC formula * */ gdouble A = -w0*h0 + r0*(w0 + h0); gdouble B = -(w1 + h1) * r0*r0; gdouble C = w1 * h1 * r0*r0; - if (B*B - 4*A*C > 0) { + if ((B*B - 4*A*C > 0) && !preserve) { // Of the two roots, I verified experimentally that this is the one we need r1 = fabs((-B - sqrt(B*B - 4*A*C))/(2*A)); // If w1 < 0 then the scale will be wrong if we just assume that scale_x = (w1 - r1)/(w0 - r0); // Therefore we here need the absolute values of w0, w1, h0, h1, and r0, as taken care of earlier scale_x = (w1 - r1)/(w0 - r0); scale_y = (h1 - r1)/(h0 - r0); - } else { // Can't find the roots of the quadratic equation. Likely the input parameters are invalid? + } else { // roots are complex. Or 'Preserve Transforms' was chosen. r1 = r0; scale_x = w1 / w0; scale_y = h1 / h0; @@ -190,7 +190,8 @@ Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visua // Now we account for mirroring by flipping if needed scale *= Geom::Scale(flip_x * scale_x, flip_y * scale_y); // Make sure that the lower-left corner of the visual bounding box stays where it is, even though the stroke width has changed - unbudge *= Geom::Translate (-flip_x * 0.5 * (r0 * scale_x - r1), -flip_y * 0.5 * (r0 * scale_y - r1)); + if (!preserve) + unbudge *= Geom::Translate (-flip_x * 0.5 * (r0 * scale_x - r1), -flip_y * 0.5 * (r0 * scale_y - r1)); } else { // The stroke should not be scaled, or is zero if (r0 == 0 || r0 == Geom::infinity() ) { // Strokewidth is zero or infinite scale *= direct; diff --git a/src/sp-item-transform.h b/src/sp-item-transform.h index 5e67dd276..0cfb42027 100644 --- a/src/sp-item-transform.h +++ b/src/sp-item-transform.h @@ -11,7 +11,7 @@ void sp_item_scale_rel (SPItem *item, Geom::Scale const &scale); void sp_item_skew_rel (SPItem *item, double skewX, double skewY); void sp_item_move_rel(SPItem *item, Geom::Translate const &tr); -Geom::Affine get_scale_transform_for_uniform_stroke (Geom::Rect const &bbox_visual, gdouble strokewidth, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1); +Geom::Affine get_scale_transform_for_uniform_stroke (Geom::Rect const &bbox_visual, gdouble strokewidth, bool transform_stroke, bool preserve, gdouble x0, gdouble y0, gdouble x1, gdouble y1); Geom::Affine get_scale_transform_for_variable_stroke (Geom::Rect const &bbox_visual, Geom::Rect const &bbox_geom, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1); Geom::Rect get_visual_bbox (Geom::OptRect const &initial_geom_bbox, Geom::Affine const &abs_affine, gdouble const initial_strokewidth, bool const transform_stroke); diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp index 2595e2cf5..177f15195 100644 --- a/src/ui/dialog/new-from-template.cpp +++ b/src/ui/dialog/new-from-template.cpp @@ -34,7 +34,7 @@ NewFromTemplate::NewFromTemplate() align->set_padding(0, 0, 0, 15); align->add(_create_template_button); - _create_template_button.signal_pressed().connect( + _create_template_button.signal_clicked().connect( sigc::mem_fun(*this, &NewFromTemplate::_createFromTemplate)); show_all(); diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index cc7bbb277..ec2bfb822 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -373,8 +373,8 @@ void PixelArtDialogImpl::processLibdepixelize(SPImage *img) = Glib::wrap(img->pixbuf->getPixbufRaw(), true); if ( pixbuf->get_width() > 256 || pixbuf->get_height() > 256 ) { - char *msg = _("Image looks too big. Process may take a while and is" - " wise to save your document before continue." + char *msg = _("Image looks too big. Process may take a while and it is" + " wise to save your document before continuing." "\n\nContinue the procedure (without saving)?"); Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK_CANCEL, true); diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 1e5baffd2..3f161ad28 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -309,8 +309,8 @@ gboolean colorItemHandleButtonPress( GtkWidget* widget, GdkEventButton* event, g gtk_widget_show_all(popupMenu); } - ColorItem* item = reinterpret_cast<ColorItem*>(user_data); - if ( item ) { + if ( user_data ) { + ColorItem* item = reinterpret_cast<ColorItem*>(user_data); bool show = swp && (swp->getSelectedIndex() == 0); for ( std::vector<GtkWidget*>::iterator it = popupExtras.begin(); it != popupExtras.end(); ++ it) { gtk_widget_set_sensitive(*it, show); diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 8e33cf503..057eff337 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -9,7 +9,6 @@ */ #include "template-widget.h" - #include "template-load-tab.h" #include <gtkmm/messagedialog.h> @@ -83,6 +82,11 @@ void TemplateLoadTab::createTemplate() } +void TemplateLoadTab::_onRowActivated(const Gtk::TreeModel::Path &, Gtk::TreeViewColumn*) +{ + _info_widget->create(); +} + void TemplateLoadTab::_displayTemplateInfo() { Glib::RefPtr<Gtk::TreeSelection> templateSelectionRef = _tlist_view.get_selection(); @@ -119,9 +123,11 @@ void TemplateLoadTab::_initLists() _tlist_view.get_selection(); templateSelectionRef->signal_changed().connect( sigc::mem_fun(*this, &TemplateLoadTab::_displayTemplateInfo)); + + _tlist_view.signal_row_activated().connect( + sigc::mem_fun(*this, &TemplateLoadTab::_onRowActivated)); } - void TemplateLoadTab::_keywordSelected() { _current_keyword = _keywords_combo.get_active_text(); diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index 744a2a9fb..920ae6ca2 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -101,6 +101,8 @@ private: void _getTemplatesFromDir(const std::string &); void _keywordSelected(); TemplateData _processTemplateFile(const std::string &); + + void _onRowActivated(const Gtk::TreeModel::Path &, Gtk::TreeViewColumn*); }; } diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 898903f2b..d1697244e 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -53,7 +53,7 @@ TemplateWidget::TemplateWidget() pack_end(_short_description_label, Gtk::PACK_SHRINK, 5); - _more_info_button.signal_pressed().connect( + _more_info_button.signal_clicked().connect( sigc::mem_fun(*this, &TemplateWidget::_displayTemplateDetails)); } diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 58d7134b3..542f6f115 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -259,7 +259,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) // we'll just use the old get_scale_transform_for_uniform_stroke() for now. // 2) get_scale_transform_for_uniform_stroke() is intended for visual bounding boxes, not geometrical ones! // we'll trick it into using a geometric bounding box though, by setting the stroke width to zero - scaler = get_scale_transform_for_uniform_stroke (*bbox_geom, 0, false, x0, y0, x1, y1); + scaler = get_scale_transform_for_uniform_stroke (*bbox_geom, 0, false, false, x0, y0, x1, y1); } sp_selection_apply_affine(selection, scaler); diff --git a/src/xml/quote.cpp b/src/xml/quote.cpp index c9e001d05..02c12dfb0 100644 --- a/src/xml/quote.cpp +++ b/src/xml/quote.cpp @@ -23,13 +23,15 @@ size_t xml_quoted_strlen(char const *val) { size_t ret = 0; - for (; *val != '\0'; val++) { - switch (*val) { - case '"': ret += sizeof(""") - 1; break; - case '&': ret += sizeof("&") - 1; break; - case '<': ret += sizeof("<") - 1; break; - case '>': ret += sizeof(">") - 1; break; - default: ++ret; break; + if (val != NULL) { + for (; *val != '\0'; val++) { + switch (*val) { + case '"': ret += sizeof(""") - 1; break; + case '&': ret += sizeof("&") - 1; break; + case '<': ret += sizeof("<") - 1; break; + case '>': ret += sizeof(">") - 1; break; + default: ++ret; break; + } } } return ret; |
