From: gouldtj Date: Tue, 2 May 2006 05:49:17 +0000 (+0000) Subject: r11667@tres: ted | 2006-05-01 22:48:49 -0700 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=29c54358e58809867ecea08ad077d54cf7208e8a;p=inkscape.git r11667@tres: ted | 2006-05-01 22:48:49 -0700 Backing out version 11530. SVK is so liberating and so frustrating all at the same time. --- diff --git a/ChangeLog b/ChangeLog index a44b9d39c..e98b0264e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,83 @@ +2006-05-01 Jon A. Cruz + + * src/Makefile.am, src/Makefile_insert, src/attributes-test.h, + src/color-profile-test.h, src/mod360-test.cpp, src/mod360-test.h, + src/round-test.cpp, src/round-test.h, src/sp-gradient-test.cpp, + src/sp-gradient-test.h, src/sp-style-elem-test.cpp, + src/sp-style-elem-test.h, src/style-test.h, src/test-helpers.h: + Replaced four more tests with CxxTest versions. + +2006-05-01 MenTaLguY + + * src/display/nr-arena-item.cpp: + + use GC allocator for bitmap cache and transform + +2006-05-01 Marco Scholten + + * src/dialogs/inkscape-preferences.cpp: Moved 'compass like + display of angles' from 'windows' to 'steps'. + +2006-04-30 MenTaLguY + + * src/libnr/nr-object.cpp: + + log finalization of NRObjects + +2006-04-29 Jon Phillips + + * src/dialogs/rdf.cpp: Updated cc licenses to 2.5 by default. + + * src/ui/dialog/document-metadata.cpp: Made metadata window + resizable so that one can see the licenses and enter long entries. + +2006-04-29 MenTaLguY + + * src/display/nr-arena-group.cpp, src/display/nr-arena-item.cpp, + src/display/nr-arena-item.h, src/display/nr-arena-shape.cpp: + + rationalize function names and remove spurious soft_ptr + +2006-04-29 MenTaLguY + + * src/document.cpp: + + use proper unref function on SPRoot to avoid appearance of leak + +2006-04-29 MenTaLguY + + * src/gc-anchored.cpp, src/xml/simple-node.cpp, src/sp-object.cpp: + + switch everyone to simpler debug event API + +2006-04-29 MenTaLguY + + * src/Makefile_insert, src/gc-finalized.cpp, src/gc-finalized.h: + + add finalizer logging + +2006-04-29 MenTaLguY + + * src/debug/simple-event.h: simplify the SimpleEvent API more + +2006-04-29 MenTaLguY + + * src/debug/simple-event.h: make Debug::SimpleEvent more convenient + + * src/debug/event.h, src/debug/logger.cpp: add FINALIZERS category + +2006-04-29 MenTaLguY + + * src/debug/logger.cpp: + + finish interrupted refactoring of log filter configuration + +2006-04-29 MenTaLguY + + * src/doc/Makefile.am, src/doc/refcounting.txt: + + some developer documentation about refcounting + 2006-04-29 MenTaLguY * src/ui/view/view.cpp: diff --git a/src/Makefile.am b/src/Makefile.am index 1f6bcefab..6155568a2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -166,10 +166,6 @@ EXTRA_PROGRAMS = \ TESTS = \ test-all$(EXEEXT) \ - mod360-test$(EXEEXT) \ - round-test$(EXEEXT) \ - sp-gradient-test$(EXEEXT) \ - sp-style-elem-test$(EXEEXT) \ style-test$(EXEEXT) \ display/bezier-utils-test$(EXEEXT) \ helper/units-test$(EXEEXT) \ @@ -198,10 +194,6 @@ TESTS = \ check_PROGRAMS = \ test-all \ - mod360-test \ - round-test \ - sp-gradient-test \ - sp-style-elem-test \ style-test \ display/bezier-utils-test \ helper/units-test \ diff --git a/src/Makefile_insert b/src/Makefile_insert index 18f6b7b03..531882f8d 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -319,18 +319,6 @@ inkscape_LDFLAGS = --export-dynamic $(kdeldflags) inkview_SOURCES = inkview.cpp $(win32_sources) inkview_LDADD = $(all_libs) -mod360_test_SOURCES = mod360-test.cpp -mod360_test_LDADD = libinkpre.a -lglib-2.0 - -round_test_SOURCES = round-test.cpp -round_test_LDADD = libinkpost.a - -sp_gradient_test_SOURCES = sp-gradient-test.cpp -sp_gradient_test_LDADD = $(all_libs) - -sp_style_elem_test_SOURCES = sp-style-elem-test.cpp -sp_style_elem_test_LDADD = $(all_libs) - style_test_SOURCES = style-test.cpp style_test_LDADD = $(all_libs) @@ -342,4 +330,9 @@ test_all_includes = \ color-profile-test.h \ dir-util-test.h \ extract-uri-test.h \ + mod360-test.h \ + round-test.h \ + sp-gradient-test.h \ + sp-style-elem-test.h \ + style-test.h \ verbs-test.h diff --git a/src/dialogs/guidelinedialog.cpp b/src/dialogs/guidelinedialog.cpp index 6fab6c1c6..7be2545f0 100644 --- a/src/dialogs/guidelinedialog.cpp +++ b/src/dialogs/guidelinedialog.cpp @@ -39,43 +39,35 @@ namespace Dialogs { GuidelinePropertiesDialog::GuidelinePropertiesDialog(SPGuide *guide, SPDesktop *desktop) : _desktop(desktop), _guide(guide), - _adjustment(0.0, -SP_DESKTOP_SCROLL_LIMIT, SP_DESKTOP_SCROLL_LIMIT, 1.0, 10.0, 10.0), + _relative_toggle(_("Rela_tive move"), _("Move guide relative to current position")), + _adjustment(0.0, -SP_DESKTOP_SCROLL_LIMIT, SP_DESKTOP_SCROLL_LIMIT, 1.0, 10.0, 10.0), _unit_selector(NULL), _mode(true), _oldpos(0.0) { } GuidelinePropertiesDialog::~GuidelinePropertiesDialog() { - if ( NULL != _unit_selector) { - //g_free(_unit_selector); - } } void GuidelinePropertiesDialog::showDialog(SPGuide *guide, SPDesktop *desktop) { - GuidelinePropertiesDialog *dialog = new GuidelinePropertiesDialog(guide, desktop); - dialog->_setup(); - dialog->run(); - delete dialog; + GuidelinePropertiesDialog dialog(guide, desktop); + dialog._setup(); + dialog.run(); } void GuidelinePropertiesDialog::_modeChanged() { - if (_mode) { - // TRANSLATORS: This string appears when double-clicking on a guide. - // This is the distance by which the guide is to be moved. - _m.set_label(_(" relative by ")); - _mode = false; + _mode = !_relative_toggle.get_active(); + if (!_mode) { + _label_move.set_label(_("Move by:")); } else { - // TRANSLATORS: This string appears when double-clicking on a guide. - // This is the target location where the guide is to be moved. - _m.set_label(_(" absolute to ")); - _mode = true; + _label_move.set_label(_("Move to:")); } } void GuidelinePropertiesDialog::_onApply() { gdouble const raw_dist = _spin_button.get_value(); - SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(_unit_selector)); + SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(_unit_selector->gobj())); gdouble const points = sp_units_get_pixels(raw_dist, unit); gdouble const newpos = ( _mode ? points @@ -126,54 +118,48 @@ void GuidelinePropertiesDialog::_setup() { Gtk::VBox *mainVBox = get_vbox(); - _b1.set_homogeneous(false); - _b1.set_spacing(4); - mainVBox->pack_start(_b1, false, false, 0); - _b1.set_border_width(4); - - _b2.set_homogeneous(false); - _b2.set_spacing(4); - _b1.pack_start(_b2, true, true, 0); + _layout_table.set_spacings(4); + _layout_table.resize (3, 4); - //labels - _b3.set_homogeneous(false); - _b3.set_spacing(4); - _b2.pack_start(_b3, true, true, 0); + mainVBox->pack_start(_layout_table, false, false, 0); - _label.set_label("foo1"); - _b3.pack_start(_label, true, true, 0); - _label.set_alignment(1.0, 0.5); + _label_descr.set_label("foo1"); + _layout_table.attach(_label_descr, + 0, 3, 0, 1, Gtk::FILL, Gtk::FILL); + _label_descr.set_alignment(0, 0.5); - _label_id.set_label("foo2"); - _b3.pack_start(_label_id, true, true, 0); - _label_id.set_alignment(0.0, 0.5); + _layout_table.attach(_label_move, + 0, 2, 1, 2, Gtk::FILL, Gtk::FILL); + _label_move.set_alignment(0, 0.5); + _modeChanged(); - _b4.set_homogeneous(false); - _b4.set_spacing(4); - _b2.pack_start(_b4, false, false, 0); + // indent + _layout_table.attach(*manage(new Gtk::Label(" ")), + 0, 1, 2, 3, Gtk::FILL, Gtk::FILL, 10); - // mode button - _but.set_relief(Gtk::RELIEF_NONE); - _b4.pack_start(_but, false, true, 0); - _but.signal_clicked().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_modeChanged)); - _m.set_label(_(" absolute to ")); - _but.add(_m); + // mode radio button + _layout_table.attach(_relative_toggle, + 1, 3, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + _relative_toggle.signal_toggled().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_modeChanged)); // unitmenu /* fixme: We should allow percents here too, as percents of the canvas size */ - _unit_selector = sp_unit_selector_new(SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE); - sp_unit_selector_set_unit(SP_UNIT_SELECTOR(_unit_selector), _desktop->namedview->doc_units); + GtkWidget *unit_selector = sp_unit_selector_new(SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE); + sp_unit_selector_set_unit(SP_UNIT_SELECTOR(unit_selector), _desktop->namedview->doc_units); + _unit_selector = Gtk::manage(Glib::wrap(unit_selector)); // spinbutton - sp_unit_selector_add_adjustment(SP_UNIT_SELECTOR(_unit_selector), GTK_ADJUSTMENT(_adjustment.gobj())); + sp_unit_selector_add_adjustment(SP_UNIT_SELECTOR(unit_selector), GTK_ADJUSTMENT(_adjustment.gobj())); _spin_button.configure(_adjustment, 1.0 , 2); _spin_button.set_numeric(TRUE); - _b4.pack_start(_spin_button, true, true, 0); + _layout_table.attach(_spin_button, + 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); gtk_signal_connect_object(GTK_OBJECT(_spin_button.gobj()), "activate", GTK_SIGNAL_FUNC(gtk_window_activate_default), gobj()); - gtk_box_pack_start(GTK_BOX(_b4.gobj()), _unit_selector, FALSE, FALSE, 0); + _layout_table.attach(*_unit_selector, + 2, 3, 2, 3, Gtk::FILL, Gtk::FILL); // dialog @@ -184,17 +170,15 @@ void GuidelinePropertiesDialog::_setup() { _oldpos = _guide->position; { gchar *guide_description = sp_guide_description(_guide); - gchar *label = g_strdup_printf(_("Move %s"), guide_description); - g_free(guide_description); - _label.set_label(label); - g_free(label); - Inkscape::XML::Node *repr = SP_OBJECT_REPR (_guide); const gchar *guide_id = repr->attribute("id"); - _label_id.set_label(guide_id); + gchar *label = g_strdup_printf(_("Moving %s %s"), guide_description, guide_id); + g_free(guide_description); + _label_descr.set_label(label); + g_free(label); } - SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(_unit_selector)); + SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(unit_selector)); gdouble const val = sp_pixels_get_units(_oldpos, unit); _spin_button.set_value(val); _spin_button.grab_focus(); diff --git a/src/dialogs/guidelinedialog.h b/src/dialogs/guidelinedialog.h index d68ca4044..d12e34042 100644 --- a/src/dialogs/guidelinedialog.h +++ b/src/dialogs/guidelinedialog.h @@ -14,10 +14,12 @@ #define INKSCAPE_DIALOG_GUIDELINE_H #include +#include #include #include #include #include +#include "ui/widget/button.h" namespace Inkscape { namespace UI { @@ -48,18 +50,14 @@ private: SPDesktop *_desktop; SPGuide *_guide; - Gtk::HBox _b1; - Gtk::VBox _b2; - Gtk::HBox _b3; - Gtk::HBox _b4; - Gtk::Label _label; - Gtk::Label _label_id; - Gtk::Button _but; - Gtk::Label _m; + Gtk::Table _layout_table; + Gtk::Label _label_descr; + Gtk::Label _label_move; + Inkscape::UI::Widget::CheckButton _relative_toggle; Gtk::Adjustment _adjustment; Gtk::SpinButton _spin_button; - GtkWidget *_unit_selector; + Gtk::Widget *_unit_selector; bool _mode; gdouble _oldpos; }; diff --git a/src/dom/domimpl.cpp b/src/dom/domimpl.cpp index 026dc37c6..ecbfd123d 100644 --- a/src/dom/domimpl.cpp +++ b/src/dom/domimpl.cpp @@ -936,7 +936,7 @@ NodeImpl::NodeImpl() : Node() /** * */ -NodeImpl::NodeImpl(const NodeImpl &other) +NodeImpl::NodeImpl(const NodeImpl &other) : Node() { init(); assign(other); diff --git a/src/dom/xpathtoken.cpp b/src/dom/xpathtoken.cpp index 2d5dfc1d7..c9d4898d7 100644 --- a/src/dom/xpathtoken.cpp +++ b/src/dom/xpathtoken.cpp @@ -131,12 +131,12 @@ static TokenStringPair tokenStrings[] = /** - * Return the enumerated TokenType of this token + * Return the string TokenType of this token * (in the .cpp file) */ DOMString Token::getTypeString() { - DOMString ret; + DOMString ret = "unknown"; for (TokenStringPair *pair = tokenStrings ; pair->sval ; pair++) { if (pair->ival == type) @@ -148,6 +148,8 @@ DOMString Token::getTypeString() return ret; } + + //######################################################################## //# X P A T H A X I S //######################################################################## @@ -166,7 +168,8 @@ Axis::Axis() */ Axis::Axis(int tokPos) { - assign(other); + init(); + tokenPosition = tokPos; } @@ -183,7 +186,15 @@ Axis::Axis(const Axis &other) /** * */ -StackItem &StackItem::operator=(const StackItem &other) +Axis::~Axis() +{ +} + + +/** + * + */ +Axis &Axis::operator=(const Axis &other) { assign(other); return *this; @@ -192,105 +203,99 @@ StackItem &StackItem::operator=(const StackItem &other) /** * */ -void StackItem::assign(const StackItem &other) +void Axis::init() { - sval = other.sval; - ival = other.ival; - dval = other.dval; + tokenPosition = 0; } - -//######################################################################## -//# X P A T H S T A C K I T E M -//######################################################################## - /** * */ -StackItem::StackItem() +void Axis::assign(const Axis &other) { - ival = 0L; - dval = 0.0; + tokenPosition = other.tokenPosition; } - /** * */ -StackItem::StackItem(const StackItem &other) +void Axis::setPosition(unsigned int val) { - assign(other); + tokenPosition = val; } - /** * */ -Stack::~Stack() +unsigned int Axis::getPosition() { + return tokenPosition; } - /** * */ -void Stack::assign(const Stack &other) +void Axis::setNode(const Node *val) { - root = other.root; - nodeList = other.nodeList; - size = other.size; - for (int i=0 ; i::iterator iter; printf("############# TOKENS\n"); for (iter = tokens.begin() ; iter != tokens.end() ; iter++) { Token *tok = *iter; - tok->execute(stack); + tok->dump(); } } - list = stack.getNodeList(); - return list; +//######################################################################## +//# X P A T H E X E C U T O R +//######################################################################## + +/** + * + */ +TokenExecutor::TokenExecutor() +{ + reset(); } diff --git a/src/dom/xpathtoken.h b/src/dom/xpathtoken.h index 03175efb1..d595ad43c 100644 --- a/src/dom/xpathtoken.h +++ b/src/dom/xpathtoken.h @@ -199,7 +199,7 @@ public: /** * Assign our values to those of the other */ - virtual void assign(const Stack &other); + virtual void assign(const TokenExecutor &other); /** * Reset the stack to its original settings @@ -217,23 +217,38 @@ public: virtual StackItem pop(); /** - * Set the root node + * Execute a token list on the stack */ - virtual void setRootNode(const Node *node); + NodeList execute(const TokenList &list, const Node *node); /** - * Get the current node list; + * */ - virtual NodeList &getNodeList(); + Axis axis; + /** + * + */ + std::vector axisStack; private: - Node *root; + /** + * Contains the StackItem stack; + */ + StackItem stack[STACK_SIZE]; + + /** + * Marks the head of the stack, for push() and pop() + */ + int stackSize; + + /** + * Current list of nodes found by the expression + */ NodeList nodeList; - StackItem items[STACK_SIZE]; - int size; + }; @@ -372,8 +387,7 @@ public: virtual int getType() { return type; } /** - * Return the enumerated TokenType of this token - * (in the .cpp file) + * Return the string TokenType of this token */ virtual DOMString getTypeString(); @@ -381,7 +395,7 @@ public: * Let this token execute itself on the given stack, * possibly adding Nodes to the node list. */ - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &stack) { return true; } /** @@ -442,7 +456,7 @@ public: type = TOK_STR; sval = val; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { StackItem item; item.sval = sval; @@ -459,7 +473,7 @@ public: type = TOK_FLOAT; dval = val; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { StackItem item; item.dval = dval; @@ -476,7 +490,7 @@ public: type = TOK_INT; ival = val; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { StackItem item; item.ival = ival; @@ -492,7 +506,7 @@ public: { type = TOK_AND; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -509,7 +523,7 @@ public: { type = TOK_OR; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -526,7 +540,7 @@ public: { type = TOK_MOD; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -543,7 +557,7 @@ public: { type = TOK_DIV; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -560,7 +574,7 @@ public: { type = TOK_MULTIPLY; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -577,7 +591,7 @@ public: { type = TOK_PLUS; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -594,7 +608,7 @@ public: { type = TOK_MINUS; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -611,7 +625,7 @@ public: { type = TOK_NEG; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { StackItem item = exec.pop(); item.dval = -item.dval; @@ -628,7 +642,7 @@ public: { type = TOK_EQUALS; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -645,7 +659,7 @@ public: { type = TOK_NOT_EQUALS; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -662,7 +676,7 @@ public: { type = TOK_LESS_THAN_EQUALS; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -679,7 +693,7 @@ public: { type = TOK_LESS_THAN; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -696,7 +710,7 @@ public: { type = TOK_GREATER_THAN_EQUALS; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -713,7 +727,7 @@ public: { type = TOK_GREATER_THAN; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -735,7 +749,7 @@ public: { type = TOK_ABSOLUTE; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { Node *n = exec.axis.getNode(); while (n->getParentNode()) @@ -752,7 +766,7 @@ public: { type = TOK_RELATIVE; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { ///exec.axis.currentNode = stack.rootNode; return true; @@ -766,7 +780,7 @@ public: { type = TOK_STEP; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -780,7 +794,7 @@ public: type = TOK_NAME_TEST; sval = name; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -793,7 +807,7 @@ public: { type = TOK_EXPR; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -806,7 +820,7 @@ public: { type = TOK_UNION; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -827,7 +841,7 @@ public: { type = TOK_AXIS_ANCESTOR_OR_SELF; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -840,7 +854,7 @@ public: { type = TOK_AXIS_ANCESTOR; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -853,7 +867,7 @@ public: { type = TOK_AXIS_ATTRIBUTE; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -866,7 +880,7 @@ public: { type = TOK_AXIS_CHILD; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -879,7 +893,7 @@ public: { type = TOK_AXIS_DESCENDANT_OR_SELF; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -892,7 +906,7 @@ public: { type = TOK_AXIS_DESCENDANT; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -905,7 +919,7 @@ public: { type = TOK_AXIS_FOLLOWING_SIBLING; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -918,7 +932,7 @@ public: { type = TOK_AXIS_FOLLOWING; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -931,7 +945,7 @@ public: { type = TOK_AXIS_NAMESPACE; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -944,7 +958,7 @@ public: { type = TOK_AXIS_PARENT; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -957,7 +971,7 @@ public: { type = TOK_AXIS_PRECEDING_SIBLING; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -970,7 +984,7 @@ public: { type = TOK_AXIS_PRECEDING; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -983,7 +997,7 @@ public: { type = TOK_AXIS_SELF; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1002,7 +1016,7 @@ public: { type = TOK_FUNC_LAST; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1015,7 +1029,7 @@ public: { type = TOK_FUNC_POSITION; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1028,7 +1042,7 @@ public: { type = TOK_FUNC_COUNT; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1041,7 +1055,7 @@ public: { type = TOK_FUNC_ID; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1054,7 +1068,7 @@ public: { type = TOK_FUNC_LOCAL_NAME; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1067,7 +1081,7 @@ public: { type = TOK_FUNC_NAMESPACE_URI; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1080,7 +1094,7 @@ public: { type = TOK_FUNC_NAME; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1093,7 +1107,7 @@ public: { type = TOK_FUNC_STRING; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1106,7 +1120,7 @@ public: { type = TOK_FUNC_CONCAT; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1119,7 +1133,7 @@ public: { type = TOK_FUNC_STARTS_WITH; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1132,7 +1146,7 @@ public: { type = TOK_FUNC_CONTAINS; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1145,7 +1159,7 @@ public: { type = TOK_FUNC_SUBSTRING_BEFORE; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1158,7 +1172,7 @@ public: { type = TOK_FUNC_SUBSTRING_AFTER; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1171,7 +1185,7 @@ public: { type = TOK_FUNC_SUBSTRING; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1184,7 +1198,7 @@ public: { type = TOK_FUNC_STRING_LENGTH; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1197,7 +1211,7 @@ public: { type = TOK_FUNC_NORMALIZE_SPACE; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1210,7 +1224,7 @@ public: { type = TOK_FUNC_TRANSLATE; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1223,7 +1237,7 @@ public: { type = TOK_FUNC_BOOLEAN; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1236,7 +1250,7 @@ public: { type = TOK_FUNC_NOT; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1249,7 +1263,7 @@ public: { type = TOK_FUNC_TRUE; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1262,7 +1276,7 @@ public: { type = TOK_FUNC_FALSE; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1275,7 +1289,7 @@ public: { type = TOK_FUNC_LANG; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1288,7 +1302,7 @@ public: { type = TOK_FUNC_NUMBER; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1301,7 +1315,7 @@ public: { type = TOK_FUNC_SUM; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1314,7 +1328,7 @@ public: { type = TOK_FUNC_FLOOR; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1327,7 +1341,7 @@ public: { type = TOK_FUNC_CEILING; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } @@ -1340,7 +1354,7 @@ public: { type = TOK_FUNC_ROUND; } - virtual bool execute(Stack &stack) + virtual bool execute(TokenExecutor &exec) { return true; } diff --git a/src/gc-anchored.cpp b/src/gc-anchored.cpp index 285efd69d..baf36c0c9 100644 --- a/src/gc-anchored.cpp +++ b/src/gc-anchored.cpp @@ -12,7 +12,7 @@ #include #include "gc-anchored.h" #include "debug/event-tracker.h" -#include "debug/event.h" +#include "debug/simple-event.h" #include "util/share.h" #include "util/format.h" @@ -20,51 +20,39 @@ namespace Inkscape { namespace GC { -class AnchorEvent : public Debug::Event { -public: - enum Type { ANCHOR, RELEASE }; - - AnchorEvent(GC::Anchored const *object, Type type) - : _base(Util::format("%p", Core::base(const_cast(object)))), - _object(Util::format("%p", object)), - _class_name(Util::share_static_string(typeid(*object).name())), - _refcount(Util::format("%d", ( type == ANCHOR ? object->_anchored_refcount() + 1 : object->_anchored_refcount() - 1 ))), - _type(type) - {} +namespace { - static Category category() { return REFCOUNT; } +typedef Debug::SimpleEvent RefCountEvent; - Util::ptr_shared name() const { - if ( _type == ANCHOR ) { - return Util::share_static_string("gc-anchor"); - } else { - return Util::share_static_string("gc-release"); - } - } - unsigned propertyCount() const { return 4; } - PropertyPair property(unsigned index) const { - switch (index) { - case 0: - return PropertyPair("base", _base); - case 1: - return PropertyPair("pointer", _object); - case 2: - return PropertyPair("class", _class_name); - case 3: - return PropertyPair("new-refcount", _refcount); - default: - return PropertyPair(); - } +class BaseAnchorEvent : public RefCountEvent { +public: + BaseAnchorEvent(Anchored const *object, int bias, + Util::ptr_shared name) + : RefCountEvent(name) + { + _addProperty("base", Util::format("%p", Core::base(const_cast(object)))); + _addProperty("pointer", Util::format("%p", object)); + _addProperty("class", Util::share_static_string(typeid(*object).name())); + _addProperty("new-refcount", Util::format("%d", object->_anchored_refcount() + bias)); } +}; -private: - Util::ptr_shared _base; - Util::ptr_shared _object; - Util::ptr_shared _class_name; - Util::ptr_shared _refcount; - Type _type; +class AnchorEvent : public BaseAnchorEvent { +public: + AnchorEvent(Anchored const *object) + : BaseAnchorEvent(object, 1, Util::share_static_string("gc-anchor")) + {} }; +class ReleaseEvent : public BaseAnchorEvent { +public: + ReleaseEvent(Anchored const *object) + : BaseAnchorEvent(object, -1, Util::share_static_string("gc-release")) + {} +}; + +} + Anchored::Anchor *Anchored::_new_anchor() const { return new Anchor(this); } @@ -74,7 +62,7 @@ void Anchored::_free_anchor(Anchored::Anchor *anchor) const { } void Anchored::anchor() const { - Debug::EventTracker tracker(this, AnchorEvent::ANCHOR); + Debug::EventTracker tracker(this); if (!_anchor) { _anchor = _new_anchor(); } @@ -82,7 +70,7 @@ void Anchored::anchor() const { } void Anchored::release() const { - Debug::EventTracker tracker(this, AnchorEvent::RELEASE); + Debug::EventTracker tracker(this); if (!--_anchor->refcount) { _free_anchor(_anchor); _anchor = NULL; diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 68865fb0e..fbe16e957 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -246,42 +246,18 @@ public: } }; - RefEvent(SPObject *object, Type type) - : _object(stringify(object)), - _class_name(Inkscape::Util::share_static_string(g_type_name(G_TYPE_FROM_INSTANCE(object)))), - _refcount(G_OBJECT(object)->ref_count), - _type(type) +class RefEvent : public RefCountEvent { +public: + RefEvent(SPObject *object) + : RefCountEvent(object, 1, Util::share_static_string("sp-object-ref")) {} }; - static Category category() { return REFCOUNT; } - - Inkscape::Util::ptr_shared name() const { - if ( _type == REF) { - return Inkscape::Util::share_static_string("sp-object-ref"); - } else { - return Inkscape::Util::share_static_string("sp-object-unref"); - } - } - unsigned propertyCount() const { return 3; } - PropertyPair property(unsigned index) const { - switch (index) { - case 0: - return PropertyPair("object", _object); - case 1: - return PropertyPair("class", _class_name); - case 2: - return PropertyPair("new-refcount", stringify( _type == REF ? _refcount + 1 : _refcount - 1 )); - default: - return PropertyPair(); - } - } - -private: - Inkscape::Util::ptr_shared _object; - Inkscape::Util::ptr_shared _class_name; - unsigned _refcount; - Type _type; +class UnrefEvent : public RefCountEvent { +public: + UnrefEvent(SPObject *object) + : RefCountEvent(object, -1, Util::share_static_string("sp-object-unref")) + {} }; } @@ -300,7 +276,7 @@ sp_object_ref(SPObject *object, SPObject *owner) g_return_val_if_fail(SP_IS_OBJECT(object), NULL); g_return_val_if_fail(!owner || SP_IS_OBJECT(owner), NULL); - Inkscape::Debug::EventTracker tracker(object, RefEvent::REF); + Inkscape::Debug::EventTracker tracker(object); g_object_ref(G_OBJECT(object)); return object; } @@ -320,7 +296,7 @@ sp_object_unref(SPObject *object, SPObject *owner) g_return_val_if_fail(SP_IS_OBJECT(object), NULL); g_return_val_if_fail(!owner || SP_IS_OBJECT(owner), NULL); - Inkscape::Debug::EventTracker tracker(object, RefEvent::UNREF); + Inkscape::Debug::EventTracker tracker(object); g_object_unref(G_OBJECT(object)); return NULL; } diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 1f3749bda..4fb77bbdd 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -243,7 +243,7 @@ PageSizer::init (Registry& reg) table->set_row_spacings (4); table->set_col_spacings (4); - Inkscape::UI::Widget::Button* fit_canv = manage(new Inkscape::UI::Widget::Button(_("Fit page to selection"), + Inkscape::UI::Widget::Button* fit_canv = manage(new Inkscape::UI::Widget::Button(_("_Fit page to selection"), _("Resize the page to fit the current selection, or the entire drawing if there is no selection"))); // prevent fit_canv from expanding Gtk::Alignment *fit_canv_cont = manage(new Gtk::Alignment(1.0,0.5,0.0,0.0)); diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp index 492da2833..204833aa5 100644 --- a/src/ui/widget/style-swatch.cpp +++ b/src/ui/widget/style-swatch.cpp @@ -61,12 +61,12 @@ static void style_swatch_tool_attr_changed(Inkscape::XML::Node *repr, gchar cons bool is_interactive, gpointer data) { Inkscape::UI::Widget::StyleSwatch *ss = (Inkscape::UI::Widget::StyleSwatch *) data; - + if (!strcmp (name, "usecurrent")) { // FIXME: watching only for the style attr, no CSS attrs if (!strcmp (new_value, "1")) { - ss->setWatched (inkscape_get_repr(INKSCAPE, "desktop")); + ss->setWatched (inkscape_get_repr(INKSCAPE, "desktop"), inkscape_get_repr(INKSCAPE, ss->_tool_path)); } else { - ss->setWatched (inkscape_get_repr(INKSCAPE, ss->_tool_path)); + ss->setWatched (inkscape_get_repr(INKSCAPE, ss->_tool_path), NULL); } // UGLY HACK: we have to reconnect to the watched tool repr again, retrieving it from the stored // tool_path, because the actual repr keeps shifting with each change, no idea why @@ -161,7 +161,6 @@ StyleSwatch::~StyleSwatch() } if (_watched_tool) { - std::cout << " =============remove\n"; sp_repr_remove_listener_by_data(_watched_tool, this); Inkscape::GC::release(_watched_tool); _watched_tool = NULL; @@ -170,7 +169,7 @@ StyleSwatch::~StyleSwatch() } void -StyleSwatch::setWatched(Inkscape::XML::Node *watched) +StyleSwatch::setWatched(Inkscape::XML::Node *watched, Inkscape::XML::Node *secondary) { if (_watched) { sp_repr_remove_listener_by_data(_watched, this); @@ -183,6 +182,18 @@ StyleSwatch::setWatched(Inkscape::XML::Node *watched) Inkscape::GC::anchor(_watched); sp_repr_add_listener(_watched, &style_swatch_repr_events, this); sp_repr_synthesize_events(_watched, &style_swatch_repr_events, this); + + // If desktop's last-set style is empty, a tool uses its own fixed style even if set to use + // last-set (so long as it's empty). To correctly show this, we're passed the second repr, + // that of the tool prefs node, from which we now setStyle if the watched repr's style is + // empty. + if (secondary) { + SPCSSAttr *css = sp_repr_css_attr_inherited(watched, "style"); + if (sp_repr_children((Inkscape::XML::Node *) css) == NULL) { // is css empty? + SPCSSAttr *css_secondary = sp_repr_css_attr_inherited(secondary, "style"); + this->setStyle (css_secondary); + } + } } } diff --git a/src/ui/widget/style-swatch.h b/src/ui/widget/style-swatch.h index a21d6202f..1f7dd2e37 100644 --- a/src/ui/widget/style-swatch.h +++ b/src/ui/widget/style-swatch.h @@ -49,7 +49,7 @@ public: void setStyle(SPCSSAttr *attr); SPCSSAttr *getStyle(); - void setWatched (Inkscape::XML::Node *watched); + void setWatched (Inkscape::XML::Node *watched, Inkscape::XML::Node *secondary); void setWatchedTool (const char *path, bool synthesize); char *_tool_path; diff --git a/src/util/format.h b/src/util/format.h index 1b8e9e2e2..3066173e1 100644 --- a/src/util/format.h +++ b/src/util/format.h @@ -4,7 +4,7 @@ * Authors: * MenTaLguY * - * Copyright (C) 2004 MenTaLguY + * Copyright (C) 2006 MenTaLguY * * Released under GNU GPL, read the file 'COPYING' for more information */