diff options
Diffstat (limited to 'src/widgets/sp-attribute-widget.cpp')
| -rw-r--r-- | src/widgets/sp-attribute-widget.cpp | 152 |
1 files changed, 0 insertions, 152 deletions
diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index 1c7d36b4d..d2c52e2ae 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -22,158 +22,6 @@ using Inkscape::DocumentUndo; -static void sp_attribute_widget_object_modified ( SPObject *object, - guint flags, - SPAttributeWidget *spaw ); - - -SPAttributeWidget::SPAttributeWidget () : - blocked(0), - hasobj(0), - _attribute(), - modified_connection() -{ - src.object = NULL; -} - -SPAttributeWidget::~SPAttributeWidget () -{ - if (hasobj) - { - if (src.object) - { - modified_connection.disconnect(); - src.object = NULL; - } - } - else - { - if (src.repr) - { - src.repr = Inkscape::GC::release(src.repr); - } - } -} - -void SPAttributeWidget::set_object(SPObject *object, const gchar *attribute) -{ - if (hasobj) { - if (src.object) { - modified_connection.disconnect(); - src.object = NULL; - } - } else { - - if (src.repr) { - src.repr = Inkscape::GC::release(src.repr); - } - } - - hasobj = true; - - if (object) { - const gchar *val; - - blocked = true; - src.object = object; - - modified_connection = object->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_attribute_widget_object_modified), this)); - - _attribute = attribute; - - val = object->getRepr()->attribute(attribute); - set_text (val ? val : (const gchar *) ""); - blocked = false; - } - gtk_widget_set_sensitive (GTK_WIDGET(this), (src.object != NULL)); -} - -void SPAttributeWidget::set_repr(Inkscape::XML::Node *repr, const gchar *attribute) -{ - if (hasobj) { - if (src.object) { - modified_connection.disconnect(); - src.object = NULL; - } - } else { - - if (src.repr) { - src.repr = Inkscape::GC::release(src.repr); - } - } - - hasobj = false; - - if (repr) { - const gchar *val; - - blocked = true; - src.repr = Inkscape::GC::anchor(repr); - attribute = g_strdup (attribute); - - val = repr->attribute(attribute); - set_text (val ? val : (const gchar *) ""); - blocked = false; - } - gtk_widget_set_sensitive (GTK_WIDGET (this), (src.repr != NULL)); -} - -void SPAttributeWidget::on_changed (void) -{ - if (!blocked) - { - Glib::ustring text1; - const gchar *text; - blocked = true; - text1 = get_text (); - text = text1.c_str(); - if (!*text) - text = NULL; - - if (hasobj && src.object) { - src.object->getRepr()->setAttribute(_attribute.c_str(), text, false); - DocumentUndo::done(src.object->document, SP_VERB_NONE, - _("Set attribute")); - - } else if (src.repr) { - src.repr->setAttribute(_attribute.c_str(), text, false); - /* TODO: Warning! Undo will not be flushed in given case */ - } - blocked = false; - } -} - -static void sp_attribute_widget_object_modified ( SPObject */*object*/, - guint flags, - SPAttributeWidget *spaw ) -{ - - if (flags && SP_OBJECT_MODIFIED_FLAG) { - - const gchar *val; - Glib::ustring text; - Glib::ustring attr = spaw->get_attribute(); - val = spaw->src.object->getRepr()->attribute(attr.c_str()); - text = spaw->get_text(); - - if (val || !text.empty()) { - - if (!val || text.empty() || (text == val)) { - /* We are different */ - spaw->set_blocked(true); - spaw->set_text(val ? val : (const gchar *) ""); - spaw->set_blocked(false); - } // end of if() - - } // end of if() - - } //end of if() - -} // end of sp_attribute_widget_object_modified() - - - -/* SPAttributeTable */ static void sp_attribute_table_object_modified (SPObject *object, guint flags, SPAttributeTable *spaw); static void sp_attribute_table_entry_changed (Gtk::Editable *editable, SPAttributeTable *spat); |
