From 1cc8be7b772d1609b85e57c4dc378c0c00368823 Mon Sep 17 00:00:00 2001 From: Adib Taraben Date: Thu, 30 Dec 2010 04:01:03 +0100 Subject: check for element modification before filling undo stack Fixed bugs: - https://launchpad.net/bugs/510618 (bzr r9991) --- src/widgets/toolbox.cpp | 108 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 72 insertions(+), 36 deletions(-) (limited to 'src/widgets/toolbox.cpp') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 8a616d002..f72b0d907 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -6185,7 +6185,7 @@ static void sp_print_font( SPStyle *query ) { << (query->text->font_specification.value ? query->text->font_specification.value : "No value") << std::endl; } - + static void sp_print_fontweight( SPStyle *query ) { const gchar* names[] = {"100", "200", "300", "400", "500", "600", "700", "800", "900", "NORMAL", "BOLD", "LIGHTER", "BOLDER", "Out of range"}; @@ -6385,8 +6385,10 @@ static void sp_text_fontfamily_value_changed( Ink_ComboBoxEntry_Action *act, GOb g_free (family); // Save for undo - DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, + if (result_fontspec != QUERY_STYLE_NOTHING) { + DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, _("Text: Change font family")); + } sp_repr_css_attr_unref (css); // unfreeze @@ -6431,10 +6433,6 @@ static void sp_text_fontsize_value_changed( Ink_ComboBoxEntry_Action *act, GObje SPDesktop *desktop = SP_ACTIVE_DESKTOP; sp_desktop_set_style (desktop, css, true, true); - // Save for undo - DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:size", SP_VERB_NONE, - _("Text: Change font size")); - // If no selected objects, set default. SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT); int result_numbers = @@ -6443,7 +6441,12 @@ static void sp_text_fontsize_value_changed( Ink_ComboBoxEntry_Action *act, GObje { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->mergeStyle("/tools/text/style", css); + } else { + // Save for undo + DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:size", SP_VERB_NONE, + _("Text: Change font size")); } + sp_style_unref(query); sp_repr_css_attr_unref (css); @@ -6578,8 +6581,10 @@ static void sp_text_style_changed( InkToggleAction* act, GObject *tbl ) // Do we need to update other CSS values? SPDesktop *desktop = SP_ACTIVE_DESKTOP; sp_desktop_set_style (desktop, css, true, true); - DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, + if (result_fontspec != QUERY_STYLE_NOTHING) { + DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, _("Text: Change font style")); + } sp_repr_css_attr_unref (css); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); @@ -6655,9 +6660,10 @@ static void sp_text_script_changed( InkToggleAction* act, GObject *tbl ) sp_desktop_set_style (desktop, css, true, false); // Save for undo - DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:script", SP_VERB_NONE, + if(result_baseline != QUERY_STYLE_NOTHING) { + DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:script", SP_VERB_NONE, _("Text: Change superscript or subscript")); - + } g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); } @@ -6799,8 +6805,11 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl ) sp_style_unref(query); sp_desktop_set_style (desktop, css, true, true); - DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, + if (result_numbers != QUERY_STYLE_NOTHING) + { + DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, _("Text: Change alignment")); + } sp_repr_css_attr_unref (css); gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas)); @@ -6831,15 +6840,19 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl ) // Until deprecated sodipodi:linespacing purged: Inkscape::Selection *selection = sp_desktop_selection(desktop); GSList const *items = selection->itemList(); + bool modmade = false; for (; items != NULL; items = items->next) { if (SP_IS_TEXT (items->data)) { SP_OBJECT_REPR(items->data)->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); + modmade = true; } } // Save for undo - DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:line-height", SP_VERB_NONE, + if(modmade) { + DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:line-height", SP_VERB_NONE, _("Text: Change line-height")); + } // If no selected objects, set default. SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT); @@ -6876,10 +6889,6 @@ static void sp_text_wordspacing_value_changed( GtkAdjustment *adj, GObject *tbl SPDesktop *desktop = SP_ACTIVE_DESKTOP; sp_desktop_set_style (desktop, css, true, false); - // Save for undo - DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:word-spacing", SP_VERB_NONE, - _("Text: Change word-spacing")); - // If no selected objects, set default. SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT); int result_numbers = @@ -6888,6 +6897,10 @@ static void sp_text_wordspacing_value_changed( GtkAdjustment *adj, GObject *tbl { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->mergeStyle("/tools/text/style", css); + } else { + // Save for undo + DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:word-spacing", SP_VERB_NONE, + _("Text: Change word-spacing")); } sp_style_unref(query); @@ -6915,9 +6928,6 @@ static void sp_text_letterspacing_value_changed( GtkAdjustment *adj, GObject *tb SPDesktop *desktop = SP_ACTIVE_DESKTOP; sp_desktop_set_style (desktop, css, true, false); - // Save for undo - DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:letter-spacing", SP_VERB_NONE, - _("Text: Change letter-spacing")); // If no selected objects, set default. SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT); @@ -6928,8 +6938,16 @@ static void sp_text_letterspacing_value_changed( GtkAdjustment *adj, GObject *tb Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->mergeStyle("/tools/text/style", css); } + else + { + // Save for undo + DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:letter-spacing", SP_VERB_NONE, + _("Text: Change letter-spacing")); + } + sp_style_unref(query); + sp_repr_css_attr_unref (css); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); @@ -6945,6 +6963,7 @@ static void sp_text_dx_value_changed( GtkAdjustment *adj, GObject *tbl ) g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) ); gdouble new_dx = adj->value; + bool modmade = false; if( SP_IS_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context) ) { SPTextContext *const tc = SP_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context); @@ -6956,14 +6975,16 @@ static void sp_text_dx_value_changed( GtkAdjustment *adj, GObject *tbl ) double old_dx = attributes->getDx( char_index ); double delta_dx = new_dx - old_dx; sp_te_adjust_dx( tc->text, tc->text_sel_start, tc->text_sel_end, SP_ACTIVE_DESKTOP, delta_dx ); + modmade = true; } } } - // Save for undo - DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:dx", SP_VERB_NONE, + if(modmade) { + // Save for undo + DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:dx", SP_VERB_NONE, _("Text: Change dx (kern)")); - + } g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); } @@ -6976,6 +6997,7 @@ static void sp_text_dy_value_changed( GtkAdjustment *adj, GObject *tbl ) g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) ); gdouble new_dy = adj->value; + bool modmade = false; if( SP_IS_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context) ) { SPTextContext *const tc = SP_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context); @@ -6987,13 +7009,16 @@ static void sp_text_dy_value_changed( GtkAdjustment *adj, GObject *tbl ) double old_dy = attributes->getDy( char_index ); double delta_dy = new_dy - old_dy; sp_te_adjust_dy( tc->text, tc->text_sel_start, tc->text_sel_end, SP_ACTIVE_DESKTOP, delta_dy ); + modmade = true; } } } - // Save for undo - DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:dy", SP_VERB_NONE, + if(modmade) { + // Save for undo + DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:dy", SP_VERB_NONE, _("Text: Change dy")); + } g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); } @@ -7008,6 +7033,7 @@ static void sp_text_rotation_value_changed( GtkAdjustment *adj, GObject *tbl ) gdouble new_degrees = adj->value; + bool modmade = false; if( SP_IS_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context) ) { SPTextContext *const tc = SP_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context); if( tc ) { @@ -7018,13 +7044,16 @@ static void sp_text_rotation_value_changed( GtkAdjustment *adj, GObject *tbl ) double old_degrees = attributes->getRotate( char_index ); double delta_deg = new_degrees - old_degrees; sp_te_adjust_rotation( tc->text, tc->text_sel_start, tc->text_sel_end, SP_ACTIVE_DESKTOP, delta_deg ); - } + modmade = true; + } } } // Save for undo - DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:rotate", SP_VERB_NONE, + if(modmade) { + DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:rotate", SP_VERB_NONE, _("Text: Change rotate")); + } g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); } @@ -7068,8 +7097,11 @@ static void sp_text_orientation_mode_changed( EgeSelectOneAction *act, GObject * } sp_desktop_set_style (SP_ACTIVE_DESKTOP, css, true, true); - DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, + if(result_numbers != QUERY_STYLE_NOTHING) + { + DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, _("Text: Change orientation")); + } sp_repr_css_attr_unref (css); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); @@ -7217,7 +7249,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ // Superscript gboolean superscriptSet = - ((result_baseline == QUERY_STYLE_SINGLE || result_baseline == QUERY_STYLE_MULTIPLE_SAME ) && + ((result_baseline == QUERY_STYLE_SINGLE || result_baseline == QUERY_STYLE_MULTIPLE_SAME ) && query->baseline_shift.set && query->baseline_shift.type == SP_BASELINE_SHIFT_LITERAL && query->baseline_shift.literal == SP_CSS_BASELINE_SHIFT_SUPER ); @@ -7228,7 +7260,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ // Subscript gboolean subscriptSet = - ((result_baseline == QUERY_STYLE_SINGLE || result_baseline == QUERY_STYLE_MULTIPLE_SAME ) && + ((result_baseline == QUERY_STYLE_SINGLE || result_baseline == QUERY_STYLE_MULTIPLE_SAME ) && query->baseline_shift.set && query->baseline_shift.type == SP_BASELINE_SHIFT_LITERAL && query->baseline_shift.literal == SP_CSS_BASELINE_SHIFT_SUB ); @@ -7302,7 +7334,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ double letterSpacing; if (query->letter_spacing.normal) letterSpacing = 0.0; else letterSpacing = query->letter_spacing.computed; // Assume no units (change in desktop-style.cpp) - + GtkAction* letterSpacingAction = GTK_ACTION( g_object_get_data( tbl, "TextLetterSpacingAction" ) ); GtkAdjustment *letterSpacingAdjustment = ege_adjustment_action_get_adjustment(EGE_ADJUSTMENT_ACTION( letterSpacingAction )); @@ -7913,10 +7945,11 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl if (!modmade) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool("/tools/connector/orthogonal", is_orthog); - } + } else { - DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, + DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, is_orthog ? _("Set connector type: orthogonal"): _("Set connector type: polyline")); + } g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); } @@ -7962,9 +7995,10 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble(Glib::ustring("/tools/connector/curvature"), newValue); } - - DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, + else { + DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, _("Change connector curvature")); + } g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); } @@ -7999,21 +8033,23 @@ static void connector_spacing_changed(GtkAdjustment *adj, GObject* tbl) sp_repr_set_css_double(repr, "inkscape:connector-spacing", adj->value); SP_OBJECT(desktop->namedview)->updateRepr(); + bool modmade = false; GSList *items = get_avoided_items(NULL, desktop->currentRoot(), desktop); for ( GSList const *iter = items ; iter != NULL ; iter = iter->next ) { SPItem *item = reinterpret_cast(iter->data); Geom::Matrix m = Geom::identity(); avoid_item_move(&m, item); + modmade = true; } if (items) { g_slist_free(items); } - - DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, + if(modmade) { + DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, _("Change connector spacing")); - + } g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); } -- cgit v1.2.3 From 53933f5fea9d07d1ba6304b88439fba257ee8c34 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Wed, 2 Feb 2011 22:24:36 +0100 Subject: update to latest 2geom ! (bzr r10025) --- src/widgets/toolbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets/toolbox.cpp') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index f72b0d907..d9e72fe50 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -8038,7 +8038,7 @@ static void connector_spacing_changed(GtkAdjustment *adj, GObject* tbl) GSList *items = get_avoided_items(NULL, desktop->currentRoot(), desktop); for ( GSList const *iter = items ; iter != NULL ; iter = iter->next ) { SPItem *item = reinterpret_cast(iter->data); - Geom::Matrix m = Geom::identity(); + Geom::Affine m = Geom::identity(); avoid_item_move(&m, item); modmade = true; } -- cgit v1.2.3 From 5aae9964808fa5447f7574c592b7049012575cca Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 3 Feb 2011 19:40:17 +0100 Subject: Translations. Context removed in filter-enums (context support too complex to be added here) and replaced with context in input and toolbox where needed. inkscape.pot and fr.po updated accordingly. (bzr r10030) --- src/widgets/toolbox.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/widgets/toolbox.cpp') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index d9e72fe50..da919e42e 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -7671,7 +7671,7 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions /* Line height */ { // Drop down menu - gchar const* labels[] = {_("Smaller spacing"), 0, 0, 0, 0, _("Normal"), 0, 0, 0, 0, 0, _("Larger spacing")}; + gchar const* labels[] = {_("Smaller spacing"), 0, 0, 0, 0, C_("Text tool", "Normal"), 0, 0, 0, 0, 0, _("Larger spacing")}; gdouble values[] = { 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1,2, 1.3, 1.4, 1.5, 2.0}; EgeAdjustmentAction *eact = create_adjustment_action( @@ -7702,7 +7702,7 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions /* Word spacing */ { // Drop down menu - gchar const* labels[] = {_("Negative spacing"), 0, 0, 0, _("Normal"), 0, 0, 0, 0, 0, 0, 0, _("Positive spacing")}; + gchar const* labels[] = {_("Negative spacing"), 0, 0, 0, C_("Text tool", "Normal"), 0, 0, 0, 0, 0, 0, 0, _("Positive spacing")}; gdouble values[] = {-2.0, -1.5, -1.0, -0.5, 0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0}; EgeAdjustmentAction *eact = create_adjustment_action( @@ -7733,7 +7733,7 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions /* Letter spacing */ { // Drop down menu - gchar const* labels[] = {_("Negative spacing"), 0, 0, 0, _("Normal"), 0, 0, 0, 0, 0, 0, 0, _("Positive spacing")}; + gchar const* labels[] = {_("Negative spacing"), 0, 0, 0, C_("Text tool", "Normal"), 0, 0, 0, 0, 0, 0, 0, _("Positive spacing")}; gdouble values[] = {-2.0, -1.5, -1.0, -0.5, 0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0}; EgeAdjustmentAction *eact = create_adjustment_action( -- cgit v1.2.3 From 4adb50d2573ca55d83551222799e43acdc440dc2 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 18 Feb 2011 20:03:23 +0100 Subject: Bucket. Lowering the maximum shrink value (see Bug #587769, Paint Bucket: Upper/lower value in context menu of Grow/shrink are unrealistic). (bzr r10057) --- src/widgets/toolbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets/toolbox.cpp') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index da919e42e..b488a0280 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -8447,7 +8447,7 @@ static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main _("Grow/shrink by"), _("Grow/shrink by:"), _("The amount to grow (positive) or shrink (negative) the created fill path"), "/tools/paintbucket/offset", 0, GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, TRUE, - "inkscape:paintbucket-offset", -1e6, 1e6, 0.1, 0.5, + "inkscape:paintbucket-offset", -1e4, 1e4, 0.1, 0.5, 0, 0, 0, paintbucket_offset_changed, 1, 2); tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); -- cgit v1.2.3 From ccba415bc620a21239f11361078c8c30006106c7 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 20 Feb 2011 23:59:34 -0800 Subject: Finished cleanup of outated SP_OBJECT_DOCUMENT C macro. (bzr r10060) --- src/widgets/toolbox.cpp | 103 +++++++++++++++++++++++++++--------------------- 1 file changed, 57 insertions(+), 46 deletions(-) (limited to 'src/widgets/toolbox.cpp') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index b488a0280..7ef864383 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -2041,14 +2041,14 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi SPDesktop *dt = reinterpret_cast(ptr); SPNamedView *nv = sp_desktop_namedview(dt); - SPDocument *doc = SP_OBJECT_DOCUMENT(nv); + SPDocument *doc = nv->document; if (dt == NULL || nv == NULL) { g_warning("No desktop or namedview specified (in toggle_snap_callback)!"); return; } - Inkscape::XML::Node *repr = SP_OBJECT_REPR(nv); + Inkscape::XML::Node *repr = nv->getRepr(); if (repr == NULL) { g_warning("This namedview doesn't have a xml representation attached!"); @@ -2520,13 +2520,14 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu Inkscape::Selection *selection = sp_desktop_selection(desktop); GSList const *items = selection->itemList(); for (; items != NULL; items = items->next) { - if (SP_IS_STAR((SPItem *) items->data)) { - Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) items->data); + SPItem *item = reinterpret_cast(items->data); + if (SP_IS_STAR(item)) { + Inkscape::XML::Node *repr = item->getRepr(); sp_repr_set_int(repr,"sodipodi:sides",(gint)adj->value); sp_repr_set_svg_double(repr, "sodipodi:arg2", (sp_repr_get_double_attribute(repr, "sodipodi:arg1", 0.5) + M_PI / (gint)adj->value)); - SP_OBJECT((SPItem *) items->data)->updateRepr(); + item->updateRepr(); modmade = true; } } @@ -2561,8 +2562,9 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl Inkscape::Selection *selection = sp_desktop_selection(desktop); GSList const *items = selection->itemList(); for (; items != NULL; items = items->next) { - if (SP_IS_STAR((SPItem *) items->data)) { - Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) items->data); + SPItem *item = reinterpret_cast(items->data); + if (SP_IS_STAR(item)) { + Inkscape::XML::Node *repr = item->getRepr(); gdouble r1 = sp_repr_get_double_attribute(repr, "sodipodi:r1", 1.0); gdouble r2 = sp_repr_get_double_attribute(repr, "sodipodi:r2", 1.0); @@ -2572,7 +2574,7 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl sp_repr_set_svg_double(repr, "sodipodi:r1", r2*adj->value); } - SP_OBJECT((SPItem *) items->data)->updateRepr(); + item->updateRepr(); modmade = true; } } @@ -2613,10 +2615,11 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d } for (; items != NULL; items = items->next) { - if (SP_IS_STAR((SPItem *) items->data)) { - Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) items->data); + SPItem *item = reinterpret_cast(items->data); + if (SP_IS_STAR(item)) { + Inkscape::XML::Node *repr = item->getRepr(); repr->setAttribute("inkscape:flatsided", flat ? "true" : "false" ); - SP_OBJECT((SPItem *) items->data)->updateRepr(); + item->updateRepr(); modmade = true; } } @@ -2651,10 +2654,11 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg Inkscape::Selection *selection = sp_desktop_selection(desktop); GSList const *items = selection->itemList(); for (; items != NULL; items = items->next) { - if (SP_IS_STAR((SPItem *) items->data)) { - Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) items->data); + SPItem *item = reinterpret_cast(items->data); + if (SP_IS_STAR(item)) { + Inkscape::XML::Node *repr = item->getRepr(); sp_repr_set_svg_double(repr, "inkscape:rounded", (gdouble) adj->value); - SP_OBJECT(items->data)->updateRepr(); + item->updateRepr(); modmade = true; } } @@ -2688,10 +2692,11 @@ static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKl Inkscape::Selection *selection = sp_desktop_selection(desktop); GSList const *items = selection->itemList(); for (; items != NULL; items = items->next) { - if (SP_IS_STAR((SPItem *) items->data)) { - Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) items->data); + SPItem *item = reinterpret_cast(items->data); + if (SP_IS_STAR(item)) { + Inkscape::XML::Node *repr = item->getRepr(); sp_repr_set_svg_double(repr, "inkscape:randomized", (gdouble) adj->value); - SP_OBJECT(items->data)->updateRepr(); + item->updateRepr(); modmade = true; } } @@ -2783,9 +2788,10 @@ sp_star_toolbox_selection_changed(Inkscape::Selection *selection, GObject *tbl) items != NULL; items = items->next) { - if (SP_IS_STAR((SPItem *) items->data)) { + SPItem* item = reinterpret_cast(items->data); + if (SP_IS_STAR(item)) { n_selected++; - repr = SP_OBJECT_REPR((SPItem *) items->data); + repr = item->getRepr(); } } @@ -3055,7 +3061,7 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const * if (adj->value != 0) { setter(SP_RECT(items->data), sp_units_get_pixels(adj->value, *unit)); } else { - SP_OBJECT_REPR(items->data)->setAttribute(value_name, NULL); + SP_OBJECT(items->data)->getRepr()->setAttribute(value_name, NULL); } modmade = true; } @@ -3184,10 +3190,10 @@ static void sp_rect_toolbox_selection_changed(Inkscape::Selection *selection, GO for (GSList const *items = selection->itemList(); items != NULL; items = items->next) { - if (SP_IS_RECT((SPItem *) items->data)) { + if (SP_IS_RECT(reinterpret_cast(items->data))) { n_selected++; - item = (SPItem *) items->data; - repr = SP_OBJECT_REPR(item); + item = reinterpret_cast(items->data); + repr = item->getRepr(); } } @@ -3474,7 +3480,7 @@ static void box3d_toolbox_selection_changed(Inkscape::Selection *selection, GObj // FIXME: Also deal with multiple selected boxes SPBox3D *box = SP_BOX3D(item); Persp3D *persp = box3d_get_perspective(box); - persp_repr = SP_OBJECT_REPR(persp); + persp_repr = persp->getRepr(); if (persp_repr) { g_object_set_data(tbl, "repr", persp_repr); Inkscape::GC::anchor(persp_repr); @@ -3513,7 +3519,7 @@ static void box3d_angle_value_changed(GtkAdjustment *adj, GObject *dataKludge, P Persp3D *persp = sel_persps.front(); persp->perspective_impl->tmat.set_infinite_direction (axis, adj->value); - SP_OBJECT(persp)->updateRepr(); + persp->updateRepr(); // TODO: use the correct axis here, too DocumentUndo::maybeDone(document, "perspangle", SP_VERB_CONTEXT_3DBOX, _("3D Box: Change perspective (angle of infinite axis)")); @@ -3731,10 +3737,11 @@ static void sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustr items != NULL; items = items->next) { - if (SP_IS_SPIRAL((SPItem *) items->data)) { - Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) items->data); + SPItem *item = reinterpret_cast(items->data); + if (SP_IS_SPIRAL(item)) { + Inkscape::XML::Node *repr = item->getRepr(); sp_repr_set_svg_double( repr, namespaced_name, adj->value ); - SP_OBJECT((SPItem *) items->data)->updateRepr(); + item->updateRepr(); modmade = true; } } @@ -3841,9 +3848,10 @@ static void sp_spiral_toolbox_selection_changed(Inkscape::Selection *selection, items != NULL; items = items->next) { - if (SP_IS_SPIRAL((SPItem *) items->data)) { + SPItem *item = reinterpret_cast(items->data); + if (SP_IS_SPIRAL(item)) { n_selected++; - repr = SP_OBJECT_REPR((SPItem *) items->data); + repr = item->getRepr(); } } @@ -5395,10 +5403,11 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) items != NULL; items = items->next) { - if (SP_IS_ARC((SPItem *) items->data)) { - Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) items->data); + SPItem *item = reinterpret_cast(items->data); + if (SP_IS_ARC(item)) { + Inkscape::XML::Node *repr = item->getRepr(); repr->setAttribute("sodipodi:open", "true"); - SP_OBJECT((SPItem *) items->data)->updateRepr(); + item->updateRepr(); modmade = true; } } @@ -5407,10 +5416,11 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) items != NULL; items = items->next) { - if (SP_IS_ARC((SPItem *) items->data)) { - Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) items->data); + SPItem *item = reinterpret_cast(items->data); + if (SP_IS_ARC(item)) { + Inkscape::XML::Node *repr = item->getRepr(); repr->setAttribute("sodipodi:open", NULL); - SP_OBJECT((SPItem *) items->data)->updateRepr(); + item->updateRepr(); modmade = true; } } @@ -5496,9 +5506,10 @@ static void sp_arc_toolbox_selection_changed(Inkscape::Selection *selection, GOb items != NULL; items = items->next) { - if (SP_IS_ARC((SPItem *) items->data)) { + SPItem *item = reinterpret_cast(items->data); + if (SP_IS_ARC(item)) { n_selected++; - repr = SP_OBJECT_REPR((SPItem *) items->data); + repr = item->getRepr(); } } @@ -6688,7 +6699,7 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl ) if (SP_IS_TEXT((SPItem *) items->data)) { SPItem *item = SP_ITEM(items->data); - unsigned writing_mode = SP_OBJECT_STYLE(item)->writing_mode.value; + unsigned writing_mode = item->style->writing_mode.value; // below, variable names suggest horizontal move, but we check the writing direction // and move in the corresponding axis int axis; @@ -6708,7 +6719,7 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl ) // frame (currently unused) double left_slack = 0; double right_slack = 0; - unsigned old_align = SP_OBJECT_STYLE(item)->text_align.value; + unsigned old_align = item->style->text_align.value; double move = 0; if (old_align == SP_CSS_TEXT_ALIGN_START || old_align == SP_CSS_TEXT_ALIGN_LEFT) { switch (mode) { @@ -6754,8 +6765,8 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl ) XY = XY + Geom::Point (0, move); } SP_TEXT(item)->attributes.setFirstXY(XY); - SP_OBJECT(item)->updateRepr(); - SP_OBJECT(item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + item->updateRepr(); + item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } } @@ -6843,7 +6854,7 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl ) bool modmade = false; for (; items != NULL; items = items->next) { if (SP_IS_TEXT (items->data)) { - SP_OBJECT_REPR(items->data)->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); + SP_OBJECT(items->data)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); modmade = true; } } @@ -8013,7 +8024,7 @@ static void connector_spacing_changed(GtkAdjustment *adj, GObject* tbl) return; } - Inkscape::XML::Node *repr = SP_OBJECT_REPR(desktop->namedview); + Inkscape::XML::Node *repr = desktop->namedview->getRepr(); if ( !repr->attribute("inkscape:connector-spacing") && ( adj->value == defaultConnSpacing )) { @@ -8032,7 +8043,7 @@ static void connector_spacing_changed(GtkAdjustment *adj, GObject* tbl) g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE)); sp_repr_set_css_double(repr, "inkscape:connector-spacing", adj->value); - SP_OBJECT(desktop->namedview)->updateRepr(); + desktop->namedview->updateRepr(); bool modmade = false; GSList *items = get_avoided_items(NULL, desktop->currentRoot(), desktop); @@ -8314,7 +8325,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA // Code to watch for changes to the connector-spacing attribute in // the XML. - Inkscape::XML::Node *repr = SP_OBJECT_REPR(desktop->namedview); + Inkscape::XML::Node *repr = desktop->namedview->getRepr(); g_assert(repr != NULL); purge_repr_listener( holder, holder ); -- cgit v1.2.3 From 4e9fcca4f83f765ab147790d04e251a2bdbd9879 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 29 Mar 2011 19:30:25 +0200 Subject: Spray: * Spray context code clean-up (coding style and unused code removal). * Shift+k and Shift+l shortcuts inverted to reflect the mode order on azerty and qwerty keyboards. * Up and down keys now modify the population parameter. * Tooltips and status messages consistency fixes. * Old Q_() context replaced with C_() context macro. * Fix default values error in the parameters sliders. * Initial fix for duplicate window parameters update (the pressure button now updates as expected). * Fix a bug when spraying with GDK_SCROLL_DOWN (population value was reset to 100). * Default selcue set to 1, default gradient drag set to 0. Eraser: * Reodering the eraser tool parameters for UI consistency. * Default mode set to Cut out a path, default width set to 10. (bzr r10132) --- src/widgets/toolbox.cpp | 87 +++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 46 deletions(-) (limited to 'src/widgets/toolbox.cpp') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 7ef864383..fe87bc4e2 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -332,7 +332,6 @@ static gchar const * ui_descr = " " " " " " - " " " " " " " " @@ -469,9 +468,9 @@ static gchar const * ui_descr = " " " " - " " - " " " " + " " + " " " " " " @@ -4609,10 +4608,10 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction { /* Mean */ - gchar const* labels[] = {_("(minimum mean)"), 0, 0, _("(default)"), 0, 0, 0, _("(maximum mean)")}; - gdouble values[] = {1, 5, 10, 20, 30, 50, 70, 100}; + gchar const* labels[] = {_("(default)"), 0, 0, 0, 0, 0, 0, _("(maximum mean)")}; + gdouble values[] = {0, 5, 10, 20, 30, 50, 70, 100}; EgeAdjustmentAction *eact = create_adjustment_action( "SprayMeanAction", - _("Focus"), _("Focus:"), _("0 to spray a spot. Increase to enlarge the ring radius."), + _("Focus"), _("Focus:"), _("0 to spray a spot; increase to enlarge the ring radius"), "/tools/spray/mean", 0, GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-mean", 0, 100, 1.0, 10.0, @@ -4625,13 +4624,10 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction { /* Standard_deviation */ - gchar const* labels[] = {_("(minimum scatter)"), 0, 0, _("(default)"), 0, 0, 0, _("(maximum scatter)")}; + gchar const* labels[] = {_("(minimum scatter)"), 0, 0, 0, 0, 0, _("(default)"), _("(maximum scatter)")}; gdouble values[] = {1, 5, 10, 20, 30, 50, 70, 100}; - - //TRANSLATORS: only translate "string" in "context|string". - // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS EgeAdjustmentAction *eact = create_adjustment_action( "SprayStandard_deviationAction", - Q_("Toolbox|Scatter"), Q_("Toolbox|Scatter:"), _("Increase to scatter sprayed objects."), + C_("Spray tool", "Scatter"), C_("Spray tool", "Scatter:"), _("Increase to scatter sprayed objects"), "/tools/spray/standard_deviation", 70, GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-standard_deviation", 1, 100, 1.0, 10.0, @@ -4688,11 +4684,11 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction } { /* Population */ - gchar const* labels[] = {_("(low population)"), 0, 0, _("(default)"), 0, 0, _("(high population)")}; - gdouble values[] = {10, 25, 35, 50, 60, 80, 100}; + gchar const* labels[] = {_("(low population)"), 0, 0, 0, _("(default)"), 0, _("(high population)")}; + gdouble values[] = {5, 20, 35, 50, 70, 85, 100}; EgeAdjustmentAction *eact = create_adjustment_action( "SprayPopulationAction", _("Amount"), _("Amount:"), - _("Adjusts the number of items sprayed per clic."), + _("Adjusts the number of items sprayed per clic"), "/tools/spray/population", 70, GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-population", 1, 100, 1.0, 10.0, @@ -4708,21 +4704,22 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction { InkToggleAction* act = ink_toggle_action_new( "SprayPressureAction", _("Pressure"), - _("Use the pressure of the input device to alter the amount of sprayed objects."), + _("Use the pressure of the input device to alter the amount of sprayed objects"), "use_pressure", Inkscape::ICON_SIZE_DECORATION ); - gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); - g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_spray_pressure_state_changed), NULL); - gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/usepressure", true) ); + gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); + PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/spray/usepressure"); + g_signal_connect(holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); + } { /* Rotation */ - gchar const* labels[] = {_("(low rotation variation)"), 0, 0, _("(default)"), 0, 0, _("(high rotation variation)")}; - gdouble values[] = {10, 25, 35, 50, 60, 80, 100}; + gchar const* labels[] = {_("(default)"), 0, 0, 0, 0, 0, 0, _("(high rotation variation)")}; + gdouble values[] = {0, 10, 25, 35, 50, 60, 80, 100}; EgeAdjustmentAction *eact = create_adjustment_action( "SprayRotationAction", _("Rotation"), _("Rotation:"), // xgettext:no-c-format - _("Variation of the rotation of the sprayed objects. 0% for the same rotation than the original object."), + _("Variation of the rotation of the sprayed objects; 0% for the same rotation than the original object"), "/tools/spray/rotation_variation", 0, GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-rotation", 0, 100, 1.0, 10.0, @@ -4735,15 +4732,12 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction } { /* Scale */ - gchar const* labels[] = {_("(low scale variation)"), 0, 0, _("(default)"), 0, 0, _("(high scale variation)")}; - gdouble values[] = {10, 25, 35, 50, 60, 80, 100}; - - //TRANSLATORS: only translate "string" in "context|string". - // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS + gchar const* labels[] = {_("(default)"), 0, 0, 0, 0, 0, 0, _("(high scale variation)")}; + gdouble values[] = {0, 10, 25, 35, 50, 60, 80, 100}; EgeAdjustmentAction *eact = create_adjustment_action( "SprayScaleAction", - Q_("Toolbox|Scale"), Q_("Toolbox|Scale:"), + C_("Spray tool", "Scale"), C_("Spray tool", "Scale:"), // xgettext:no-c-format - _("Variation in the scale of the sprayed objects. 0% for the same scale than the original object."), + _("Variation in the scale of the sprayed objects; 0% for the same scale than the original object"), "/tools/spray/scale_variation", 0, GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-scale", 0, 100, 1.0, 10.0, @@ -6117,23 +6111,6 @@ static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl ) static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder) { - { - /* Width */ - gchar const* labels[] = {_("(hairline)"), 0, 0, 0, _("(default)"), 0, 0, 0, 0, _("(broad stroke)")}; - gdouble values[] = {1, 3, 5, 10, 15, 20, 30, 50, 75, 100}; - EgeAdjustmentAction *eact = create_adjustment_action( "EraserWidthAction", - _("Pen Width"), _("Width:"), - _("The width of the eraser pen (relative to the visible canvas area)"), - "/tools/eraser/width", 15, - GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-eraser", - 1, 100, 1.0, 10.0, - labels, values, G_N_ELEMENTS(labels), - sp_erc_width_value_changed, 1, 0); - ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT ); - gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); - gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); - } - { GtkListStore* model = gtk_list_store_new( 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING ); @@ -6153,9 +6130,10 @@ static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio -1 ); EgeSelectOneAction* act = ege_select_one_action_new( "EraserModeAction", (""), (""), NULL, GTK_TREE_MODEL(model) ); + g_object_set( act, "short_label", _("Mode:"), NULL ); gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); g_object_set_data( holder, "eraser_mode_action", act ); - + ege_select_one_action_set_appearance( act, "full" ); ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE ); g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL ); @@ -6169,6 +6147,23 @@ static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_erasertb_mode_changed), holder ); } + { + /* Width */ + gchar const* labels[] = {_("(hairline)"), 0, 0, 0, _("(default)"), 0, 0, 0, 0, _("(broad stroke)")}; + gdouble values[] = {1, 3, 5, 10, 15, 20, 30, 50, 75, 100}; + EgeAdjustmentAction *eact = create_adjustment_action( "EraserWidthAction", + _("Pen Width"), _("Width:"), + _("The width of the eraser pen (relative to the visible canvas area)"), + "/tools/eraser/width", 15, + GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-eraser", + 1, 100, 1.0, 10.0, + labels, values, G_N_ELEMENTS(labels), + sp_erc_width_value_changed, 1, 0); + ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT ); + gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); + gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); + } + } //######################## -- cgit v1.2.3