From: gouldtj Date: Tue, 2 May 2006 05:29:03 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9913b9cb8fe557ed68c814af16a1f3455dcc8bb4;p=inkscape.git --- diff --git a/ChangeLog b/ChangeLog index e98b0264e..a44b9d39c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,83 +1,3 @@ -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 6155568a2..1f6bcefab 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -166,6 +166,10 @@ 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) \ @@ -194,6 +198,10 @@ 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 531882f8d..18f6b7b03 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -319,6 +319,18 @@ 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) @@ -330,9 +342,4 @@ 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 7be2545f0..6fab6c1c6 100644 --- a/src/dialogs/guidelinedialog.cpp +++ b/src/dialogs/guidelinedialog.cpp @@ -39,35 +39,43 @@ namespace Dialogs { GuidelinePropertiesDialog::GuidelinePropertiesDialog(SPGuide *guide, SPDesktop *desktop) : _desktop(desktop), _guide(guide), - _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), + _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(guide, desktop); - dialog._setup(); - dialog.run(); + GuidelinePropertiesDialog *dialog = new GuidelinePropertiesDialog(guide, desktop); + dialog->_setup(); + dialog->run(); + delete dialog; } void GuidelinePropertiesDialog::_modeChanged() { - _mode = !_relative_toggle.get_active(); - if (!_mode) { - _label_move.set_label(_("Move by:")); + 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; } else { - _label_move.set_label(_("Move to:")); + // 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; } } void GuidelinePropertiesDialog::_onApply() { gdouble const raw_dist = _spin_button.get_value(); - SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(_unit_selector->gobj())); + SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(_unit_selector)); gdouble const points = sp_units_get_pixels(raw_dist, unit); gdouble const newpos = ( _mode ? points @@ -118,48 +126,54 @@ void GuidelinePropertiesDialog::_setup() { Gtk::VBox *mainVBox = get_vbox(); - _layout_table.set_spacings(4); - _layout_table.resize (3, 4); + _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); - mainVBox->pack_start(_layout_table, false, false, 0); + //labels + _b3.set_homogeneous(false); + _b3.set_spacing(4); + _b2.pack_start(_b3, true, true, 0); - _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.set_label("foo1"); + _b3.pack_start(_label, true, true, 0); + _label.set_alignment(1.0, 0.5); - _layout_table.attach(_label_move, - 0, 2, 1, 2, Gtk::FILL, Gtk::FILL); - _label_move.set_alignment(0, 0.5); - _modeChanged(); + _label_id.set_label("foo2"); + _b3.pack_start(_label_id, true, true, 0); + _label_id.set_alignment(0.0, 0.5); - // indent - _layout_table.attach(*manage(new Gtk::Label(" ")), - 0, 1, 2, 3, Gtk::FILL, Gtk::FILL, 10); + _b4.set_homogeneous(false); + _b4.set_spacing(4); + _b2.pack_start(_b4, false, false, 0); - // 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)); + // 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); // unitmenu /* fixme: We should allow percents here too, as percents of the canvas size */ - 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)); + _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); // 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); - _layout_table.attach(_spin_button, - 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + _b4.pack_start(_spin_button, true, true, 0); gtk_signal_connect_object(GTK_OBJECT(_spin_button.gobj()), "activate", GTK_SIGNAL_FUNC(gtk_window_activate_default), gobj()); - _layout_table.attach(*_unit_selector, - 2, 3, 2, 3, Gtk::FILL, Gtk::FILL); + gtk_box_pack_start(GTK_BOX(_b4.gobj()), _unit_selector, FALSE, FALSE, 0); // dialog @@ -170,15 +184,17 @@ void GuidelinePropertiesDialog::_setup() { _oldpos = _guide->position; { gchar *guide_description = sp_guide_description(_guide); - Inkscape::XML::Node *repr = SP_OBJECT_REPR (_guide); - const gchar *guide_id = repr->attribute("id"); - gchar *label = g_strdup_printf(_("Moving %s %s"), guide_description, guide_id); + gchar *label = g_strdup_printf(_("Move %s"), guide_description); g_free(guide_description); - _label_descr.set_label(label); + _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); } - 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 d12e34042..d68ca4044 100644 --- a/src/dialogs/guidelinedialog.h +++ b/src/dialogs/guidelinedialog.h @@ -14,12 +14,10 @@ #define INKSCAPE_DIALOG_GUIDELINE_H #include -#include #include #include #include #include -#include "ui/widget/button.h" namespace Inkscape { namespace UI { @@ -50,14 +48,18 @@ private: SPDesktop *_desktop; SPGuide *_guide; - Gtk::Table _layout_table; - Gtk::Label _label_descr; - Gtk::Label _label_move; - Inkscape::UI::Widget::CheckButton _relative_toggle; + 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::Adjustment _adjustment; Gtk::SpinButton _spin_button; - Gtk::Widget *_unit_selector; + GtkWidget *_unit_selector; bool _mode; gdouble _oldpos; }; diff --git a/src/dom/domimpl.cpp b/src/dom/domimpl.cpp index ecbfd123d..026dc37c6 100644 --- a/src/dom/domimpl.cpp +++ b/src/dom/domimpl.cpp @@ -936,7 +936,7 @@ NodeImpl::NodeImpl() : Node() /** * */ -NodeImpl::NodeImpl(const NodeImpl &other) : Node() +NodeImpl::NodeImpl(const NodeImpl &other) { init(); assign(other); diff --git a/src/dom/xpathtoken.cpp b/src/dom/xpathtoken.cpp index c9d4898d7..2d5dfc1d7 100644 --- a/src/dom/xpathtoken.cpp +++ b/src/dom/xpathtoken.cpp @@ -131,12 +131,12 @@ static TokenStringPair tokenStrings[] = /** - * Return the string TokenType of this token + * Return the enumerated TokenType of this token * (in the .cpp file) */ DOMString Token::getTypeString() { - DOMString ret = "unknown"; + DOMString ret; for (TokenStringPair *pair = tokenStrings ; pair->sval ; pair++) { if (pair->ival == type) @@ -148,8 +148,6 @@ DOMString Token::getTypeString() return ret; } - - //######################################################################## //# X P A T H A X I S //######################################################################## @@ -168,8 +166,7 @@ Axis::Axis() */ Axis::Axis(int tokPos) { - init(); - tokenPosition = tokPos; + assign(other); } @@ -186,15 +183,7 @@ Axis::Axis(const Axis &other) /** * */ -Axis::~Axis() -{ -} - - -/** - * - */ -Axis &Axis::operator=(const Axis &other) +StackItem &StackItem::operator=(const StackItem &other) { assign(other); return *this; @@ -203,82 +192,72 @@ Axis &Axis::operator=(const Axis &other) /** * */ -void Axis::init() +void StackItem::assign(const StackItem &other) { - tokenPosition = 0; + sval = other.sval; + ival = other.ival; + dval = other.dval; } -/** - * - */ -void Axis::assign(const Axis &other) -{ - tokenPosition = other.tokenPosition; -} -/** - * - */ -void Axis::setPosition(unsigned int val) -{ - tokenPosition = val; -} +//######################################################################## +//# X P A T H S T A C K I T E M +//######################################################################## /** * */ -unsigned int Axis::getPosition() +StackItem::StackItem() { - return tokenPosition; + ival = 0L; + dval = 0.0; } -/** - * - */ -void Axis::setNode(const Node *val) -{ - node = (Node *)val; -} /** * */ -Node *Axis::getNode() +StackItem::StackItem(const StackItem &other) { - return node; + assign(other); } -//######################################################################## -//# X P A T H S T A C K I T E M -//######################################################################## /** * */ -StackItem::StackItem() +Stack::~Stack() { - ival = 0L; - dval = 0.0; } /** * */ -StackItem::StackItem(const StackItem &other) +void Stack::assign(const Stack &other) { - assign(other); + 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->dump(); + tok->execute(stack); } } + list = stack.getNodeList(); -//######################################################################## -//# X P A T H E X E C U T O R -//######################################################################## - -/** - * - */ -TokenExecutor::TokenExecutor() -{ - reset(); + return list; } diff --git a/src/dom/xpathtoken.h b/src/dom/xpathtoken.h index d595ad43c..03175efb1 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 TokenExecutor &other); + virtual void assign(const Stack &other); /** * Reset the stack to its original settings @@ -217,38 +217,23 @@ public: virtual StackItem pop(); /** - * Execute a token list on the stack + * Set the root node */ - NodeList execute(const TokenList &list, const Node *node); + virtual void setRootNode(const Node *node); /** - * + * Get the current node list; */ - Axis axis; + virtual NodeList &getNodeList(); - /** - * - */ - std::vector axisStack; private: - /** - * 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 - */ + Node *root; NodeList nodeList; - + StackItem items[STACK_SIZE]; + int size; }; @@ -387,7 +372,8 @@ public: virtual int getType() { return type; } /** - * Return the string TokenType of this token + * Return the enumerated TokenType of this token + * (in the .cpp file) */ virtual DOMString getTypeString(); @@ -395,7 +381,7 @@ public: * Let this token execute itself on the given stack, * possibly adding Nodes to the node list. */ - virtual bool execute(TokenExecutor &stack) + virtual bool execute(Stack &stack) { return true; } /** @@ -456,7 +442,7 @@ public: type = TOK_STR; sval = val; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { StackItem item; item.sval = sval; @@ -473,7 +459,7 @@ public: type = TOK_FLOAT; dval = val; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { StackItem item; item.dval = dval; @@ -490,7 +476,7 @@ public: type = TOK_INT; ival = val; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { StackItem item; item.ival = ival; @@ -506,7 +492,7 @@ public: { type = TOK_AND; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -523,7 +509,7 @@ public: { type = TOK_OR; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -540,7 +526,7 @@ public: { type = TOK_MOD; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -557,7 +543,7 @@ public: { type = TOK_DIV; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -574,7 +560,7 @@ public: { type = TOK_MULTIPLY; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -591,7 +577,7 @@ public: { type = TOK_PLUS; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -608,7 +594,7 @@ public: { type = TOK_MINUS; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -625,7 +611,7 @@ public: { type = TOK_NEG; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { StackItem item = exec.pop(); item.dval = -item.dval; @@ -642,7 +628,7 @@ public: { type = TOK_EQUALS; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -659,7 +645,7 @@ public: { type = TOK_NOT_EQUALS; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -676,7 +662,7 @@ public: { type = TOK_LESS_THAN_EQUALS; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -693,7 +679,7 @@ public: { type = TOK_LESS_THAN; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -710,7 +696,7 @@ public: { type = TOK_GREATER_THAN_EQUALS; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -727,7 +713,7 @@ public: { type = TOK_GREATER_THAN; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { StackItem item1 = exec.pop(); StackItem item2 = exec.pop(); @@ -749,7 +735,7 @@ public: { type = TOK_ABSOLUTE; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { Node *n = exec.axis.getNode(); while (n->getParentNode()) @@ -766,7 +752,7 @@ public: { type = TOK_RELATIVE; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { ///exec.axis.currentNode = stack.rootNode; return true; @@ -780,7 +766,7 @@ public: { type = TOK_STEP; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -794,7 +780,7 @@ public: type = TOK_NAME_TEST; sval = name; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -807,7 +793,7 @@ public: { type = TOK_EXPR; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -820,7 +806,7 @@ public: { type = TOK_UNION; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -841,7 +827,7 @@ public: { type = TOK_AXIS_ANCESTOR_OR_SELF; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -854,7 +840,7 @@ public: { type = TOK_AXIS_ANCESTOR; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -867,7 +853,7 @@ public: { type = TOK_AXIS_ATTRIBUTE; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -880,7 +866,7 @@ public: { type = TOK_AXIS_CHILD; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -893,7 +879,7 @@ public: { type = TOK_AXIS_DESCENDANT_OR_SELF; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -906,7 +892,7 @@ public: { type = TOK_AXIS_DESCENDANT; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -919,7 +905,7 @@ public: { type = TOK_AXIS_FOLLOWING_SIBLING; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -932,7 +918,7 @@ public: { type = TOK_AXIS_FOLLOWING; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -945,7 +931,7 @@ public: { type = TOK_AXIS_NAMESPACE; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -958,7 +944,7 @@ public: { type = TOK_AXIS_PARENT; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -971,7 +957,7 @@ public: { type = TOK_AXIS_PRECEDING_SIBLING; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -984,7 +970,7 @@ public: { type = TOK_AXIS_PRECEDING; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -997,7 +983,7 @@ public: { type = TOK_AXIS_SELF; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1016,7 +1002,7 @@ public: { type = TOK_FUNC_LAST; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1029,7 +1015,7 @@ public: { type = TOK_FUNC_POSITION; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1042,7 +1028,7 @@ public: { type = TOK_FUNC_COUNT; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1055,7 +1041,7 @@ public: { type = TOK_FUNC_ID; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1068,7 +1054,7 @@ public: { type = TOK_FUNC_LOCAL_NAME; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1081,7 +1067,7 @@ public: { type = TOK_FUNC_NAMESPACE_URI; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1094,7 +1080,7 @@ public: { type = TOK_FUNC_NAME; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1107,7 +1093,7 @@ public: { type = TOK_FUNC_STRING; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1120,7 +1106,7 @@ public: { type = TOK_FUNC_CONCAT; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1133,7 +1119,7 @@ public: { type = TOK_FUNC_STARTS_WITH; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1146,7 +1132,7 @@ public: { type = TOK_FUNC_CONTAINS; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1159,7 +1145,7 @@ public: { type = TOK_FUNC_SUBSTRING_BEFORE; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1172,7 +1158,7 @@ public: { type = TOK_FUNC_SUBSTRING_AFTER; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1185,7 +1171,7 @@ public: { type = TOK_FUNC_SUBSTRING; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1198,7 +1184,7 @@ public: { type = TOK_FUNC_STRING_LENGTH; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1211,7 +1197,7 @@ public: { type = TOK_FUNC_NORMALIZE_SPACE; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1224,7 +1210,7 @@ public: { type = TOK_FUNC_TRANSLATE; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1237,7 +1223,7 @@ public: { type = TOK_FUNC_BOOLEAN; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1250,7 +1236,7 @@ public: { type = TOK_FUNC_NOT; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1263,7 +1249,7 @@ public: { type = TOK_FUNC_TRUE; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1276,7 +1262,7 @@ public: { type = TOK_FUNC_FALSE; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1289,7 +1275,7 @@ public: { type = TOK_FUNC_LANG; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1302,7 +1288,7 @@ public: { type = TOK_FUNC_NUMBER; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1315,7 +1301,7 @@ public: { type = TOK_FUNC_SUM; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1328,7 +1314,7 @@ public: { type = TOK_FUNC_FLOOR; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1341,7 +1327,7 @@ public: { type = TOK_FUNC_CEILING; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } @@ -1354,7 +1340,7 @@ public: { type = TOK_FUNC_ROUND; } - virtual bool execute(TokenExecutor &exec) + virtual bool execute(Stack &stack) { return true; } diff --git a/src/gc-anchored.cpp b/src/gc-anchored.cpp index baf36c0c9..285efd69d 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/simple-event.h" +#include "debug/event.h" #include "util/share.h" #include "util/format.h" @@ -20,39 +20,51 @@ namespace Inkscape { namespace GC { -namespace { +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) + {} -typedef Debug::SimpleEvent RefCountEvent; + static Category category() { return REFCOUNT; } -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)); + 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 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")) - {} +private: + Util::ptr_shared _base; + Util::ptr_shared _object; + Util::ptr_shared _class_name; + Util::ptr_shared _refcount; + Type _type; }; -} - Anchored::Anchor *Anchored::_new_anchor() const { return new Anchor(this); } @@ -62,7 +74,7 @@ void Anchored::_free_anchor(Anchored::Anchor *anchor) const { } void Anchored::anchor() const { - Debug::EventTracker tracker(this); + Debug::EventTracker tracker(this, AnchorEvent::ANCHOR); if (!_anchor) { _anchor = _new_anchor(); } @@ -70,7 +82,7 @@ void Anchored::anchor() const { } void Anchored::release() const { - Debug::EventTracker tracker(this); + Debug::EventTracker tracker(this, AnchorEvent::RELEASE); if (!--_anchor->refcount) { _free_anchor(_anchor); _anchor = NULL; diff --git a/src/sp-object.cpp b/src/sp-object.cpp index fbe16e957..68865fb0e 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -246,18 +246,42 @@ public: } }; -class RefEvent : public RefCountEvent { -public: - RefEvent(SPObject *object) - : RefCountEvent(object, 1, Util::share_static_string("sp-object-ref")) + 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 UnrefEvent : public RefCountEvent { -public: - UnrefEvent(SPObject *object) - : RefCountEvent(object, -1, Util::share_static_string("sp-object-unref")) - {} + 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; }; } @@ -276,7 +300,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); + Inkscape::Debug::EventTracker tracker(object, RefEvent::REF); g_object_ref(G_OBJECT(object)); return object; } @@ -296,7 +320,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); + Inkscape::Debug::EventTracker tracker(object, RefEvent::UNREF); 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 4fb77bbdd..1f3749bda 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 204833aa5..492da2833 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"), inkscape_get_repr(INKSCAPE, ss->_tool_path)); + ss->setWatched (inkscape_get_repr(INKSCAPE, "desktop")); } else { - ss->setWatched (inkscape_get_repr(INKSCAPE, ss->_tool_path), NULL); + ss->setWatched (inkscape_get_repr(INKSCAPE, ss->_tool_path)); } // 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,6 +161,7 @@ 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; @@ -169,7 +170,7 @@ StyleSwatch::~StyleSwatch() } void -StyleSwatch::setWatched(Inkscape::XML::Node *watched, Inkscape::XML::Node *secondary) +StyleSwatch::setWatched(Inkscape::XML::Node *watched) { if (_watched) { sp_repr_remove_listener_by_data(_watched, this); @@ -182,18 +183,6 @@ StyleSwatch::setWatched(Inkscape::XML::Node *watched, Inkscape::XML::Node *secon 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 1f7dd2e37..a21d6202f 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, Inkscape::XML::Node *secondary); + void setWatched (Inkscape::XML::Node *watched); void setWatchedTool (const char *path, bool synthesize); char *_tool_path; diff --git a/src/util/format.h b/src/util/format.h index 3066173e1..1b8e9e2e2 100644 --- a/src/util/format.h +++ b/src/util/format.h @@ -4,7 +4,7 @@ * Authors: * MenTaLguY * - * Copyright (C) 2006 MenTaLguY + * Copyright (C) 2004 MenTaLguY * * Released under GNU GPL, read the file 'COPYING' for more information */