diff options
| author | Kris De Gussem <kris.degussem@gmail.com> | 2011-12-11 23:18:05 +0000 |
|---|---|---|
| committer | Kris <Kris.De.Gussem@hotmail.com> | 2011-12-11 23:18:05 +0000 |
| commit | 7c124c77c3f5db80e46ad23d74dfc92d8f3aa069 (patch) | |
| tree | bfe0fd1d9b3fe2dc14580eec2ad01a6a12f134f8 /src/widgets | |
| parent | SPAttributeWidget C++ified (diff) | |
| download | inkscape-7c124c77c3f5db80e46ad23d74dfc92d8f3aa069.tar.gz inkscape-7c124c77c3f5db80e46ad23d74dfc92d8f3aa069.zip | |
SPAttributeTable C++ified
(bzr r10766.1.3)
Diffstat (limited to 'src/widgets')
| -rw-r--r-- | src/widgets/sp-attribute-widget.cpp | 551 | ||||
| -rw-r--r-- | src/widgets/sp-attribute-widget.h | 70 |
2 files changed, 246 insertions, 375 deletions
diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index 7d4424cfd..8cc521449 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -1,6 +1,7 @@ /* Authors: * Lauris Kaplinski <lauris@ximian.com> - * Abhishek Sharma + * Abhishek Sharma + * Kris De Gussem <Kris.DeGussem@gmail.com> * * Copyright (C) 2001 Ximian, Inc. * Released under GNU GPL, read the file 'COPYING' for more information @@ -129,9 +130,9 @@ void SPAttributeWidget::on_changed (void) { Glib::ustring text1; const gchar *text; - blocked = TRUE; + blocked = true; text1 = get_text (); - text=text1.c_str(); + text = text1.c_str(); if (!*text) text = NULL; @@ -155,17 +156,18 @@ static void sp_attribute_widget_object_modified ( SPObject */*object*/, if (flags && SP_OBJECT_MODIFIED_FLAG) { - const gchar *val, *text; - val = spaw->src.object->getRepr()->attribute(spaw->get_attribute().c_str()); - text = gtk_entry_get_text (GTK_ENTRY (spaw)); + 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) { + if (val || !text.empty()) { - if (!val || !text || strcmp (val, text)) { + if (!val || text.empty() || (text == val)) { /* We are different */ spaw->set_blocked(true); - gtk_entry_set_text ( GTK_ENTRY (spaw), - val ? val : (const gchar *) ""); + spaw->set_text(val ? val : (const gchar *) ""); spaw->set_blocked(false); } // end of if() @@ -184,374 +186,258 @@ static void sp_attribute_widget_object_release ( SPObject */*object*/, /* SPAttributeTable */ - -static void sp_attribute_table_class_init (SPAttributeTableClass *klass); -static void sp_attribute_table_init (SPAttributeTable *widget); -static void sp_attribute_table_destroy (GtkObject *object); - static void sp_attribute_table_object_modified (SPObject *object, guint flags, SPAttributeTable *spaw); -static void sp_attribute_table_object_release (SPObject *object, SPAttributeTable *spaw); -static void sp_attribute_table_entry_changed (GtkEditable *editable, SPAttributeTable *spat); - -static GtkVBoxClass *table_parent_class; - - +//static void sp_attribute_table_object_release (SPObject *object, SPAttributeTable *spaw); +static void sp_attribute_table_entry_changed (Gtk::Editable *editable, SPAttributeTable *spat); +#define XPAD 4 +#define YPAD 0 -GType sp_attribute_table_get_type(void) +SPAttributeTable::SPAttributeTable () : + blocked(0), + hasobj(0), + table(0), + _attributes(), + _entries(), + modified_connection()/*, + release_connection()*/ { - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPAttributeTableClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_attribute_table_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPAttributeTable), - 0, // n_preallocs - (GInstanceInitFunc)sp_attribute_table_init, - 0 // value_table - }; - type = g_type_register_static(GTK_TYPE_VBOX, "SPAttributeTable", &info, static_cast<GTypeFlags>(0)); - } - return type; -} // end of sp_attribute_table_get_type() - - +g_message("SPAttributeTable"); + src.object = NULL; +} -static void sp_attribute_table_class_init (SPAttributeTableClass *klass) +SPAttributeTable::SPAttributeTable (SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkContainer* parent) : + blocked(0), + hasobj(0), + table(0), + _attributes(), + _entries(), + modified_connection()/*, + release_connection()*/ { - GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); - - table_parent_class = (GtkVBoxClass*)g_type_class_peek_parent (klass); - - object_class->destroy = sp_attribute_table_destroy; - -} // end of sp_attribute_table_class_init() - - +g_message("SPAttributeTable"); + src.object = NULL; + set_object(object, labels, attributes, parent); +} -static void sp_attribute_table_init ( SPAttributeTable *spat ) +SPAttributeTable::~SPAttributeTable () { - spat->blocked = FALSE; - spat->hasobj = FALSE; - spat->table = NULL; - spat->src.object = NULL; - spat->num_attr = 0; - spat->attributes = NULL; - spat->entries = NULL; - - new (&spat->modified_connection) sigc::connection(); - new (&spat->release_connection) sigc::connection(); +g_message("~SPAttributeTable"); + clear(); } -static void sp_attribute_table_destroy ( GtkObject *object ) +void SPAttributeTable::clear(void) { - SPAttributeTable *spat; - - spat = SP_ATTRIBUTE_TABLE (object); - - if (spat->attributes) { - gint i; - for (i = 0; i < spat->num_attr; i++) { - g_free (spat->attributes[i]); +g_message("clear"); + Gtk::Widget *w; + +g_message("destroy 1"); + if (table) + { + std::vector<Widget*> ch = table->get_children(); + +g_message("destroy 2a"); + for (int i = (ch.size())-1; i >=0 ; i--) + { +g_message("destroy 2c"); + w = ch[i]; + ch.pop_back(); +g_message("destroy 2d"); + if (w != NULL) + { + try + { + delete w; + } + catch(...) + { +g_message("destroy 2d catched"); + } +g_message("destroy 2e"); } - g_free (spat->attributes); - spat->attributes = NULL; } + ch.clear(); +g_message("destroy 3"); + _attributes.clear(); + _entries.clear(); - if (spat->hasobj) { + delete table; + table = NULL; + } - if (spat->src.object) { - spat->modified_connection.disconnect(); - spat->release_connection.disconnect(); - spat->src.object = NULL; + if (hasobj) { + if (src.object) { + modified_connection.disconnect(); + //release_connection.disconnect(); + src.object = NULL; } } else { - if (spat->src.repr) { - spat->src.repr = Inkscape::GC::release(spat->src.repr); + if (src.repr) { + src.repr = Inkscape::GC::release(src.repr); } - } // end of if() - - spat->modified_connection.~connection(); - spat->release_connection.~connection(); - - if (spat->entries) { - g_free (spat->entries); - spat->entries = NULL; - } - - spat->table = NULL; - - if (((GtkObjectClass *) table_parent_class)->destroy) { - (* ((GtkObjectClass *) table_parent_class)->destroy) (object); } +g_message("destroy 4"); +} -} // end of sp_attribute_table_destroy() - - -GtkWidget * sp_attribute_table_new ( SPObject *object, - gint num_attr, - const gchar **labels, - const gchar **attributes ) -{ - SPAttributeTable *spat; - - g_return_val_if_fail (!object || SP_IS_OBJECT (object), NULL); - g_return_val_if_fail (!object || (num_attr > 0), NULL); - g_return_val_if_fail (!num_attr || (labels && attributes), NULL); - - spat = (SPAttributeTable*)g_object_new (SP_TYPE_ATTRIBUTE_TABLE, NULL); - - sp_attribute_table_set_object (spat, object, num_attr, labels, attributes); - - return GTK_WIDGET (spat); - -} // end of sp_attribute_table_new() - - - -GtkWidget *sp_attribute_table_new_repr ( Inkscape::XML::Node *repr, - gint num_attr, - const gchar **labels, - const gchar **attributes ) -{ - SPAttributeTable *spat; - - g_return_val_if_fail (!num_attr || (labels && attributes), NULL); - - spat = (SPAttributeTable*)g_object_new (SP_TYPE_ATTRIBUTE_TABLE, NULL); - - sp_attribute_table_set_repr (spat, repr, num_attr, labels, attributes); - - return GTK_WIDGET (spat); - -} // end of sp_attribute_table_new_repr() - - - -#define XPAD 4 -#define YPAD 0 - -void sp_attribute_table_set_object ( SPAttributeTable *spat, - SPObject *object, - gint num_attr, - const gchar **labels, - const gchar **attributes ) +void SPAttributeTable::set_object(SPObject *object, + std::vector<Glib::ustring> &labels, + std::vector<Glib::ustring> &attributes, + GtkContainer* parent) { - - g_return_if_fail (spat != NULL); - g_return_if_fail (SP_IS_ATTRIBUTE_TABLE (spat)); +g_message("set_object"); + g_return_if_fail (parent); g_return_if_fail (!object || SP_IS_OBJECT (object)); - g_return_if_fail (!object || (num_attr > 0)); - g_return_if_fail (!num_attr || (labels && attributes)); - - if (spat->table) { - gtk_widget_destroy (spat->table); - spat->table = NULL; - } + g_return_if_fail (!object || !labels.empty() || !attributes.empty()); + g_return_if_fail (labels.size() == attributes.size()); - if (spat->attributes) { - gint i; - for (i = 0; i < spat->num_attr; i++) { - g_free (spat->attributes[i]); - } - g_free (spat->attributes); - spat->attributes = NULL; - } - - if (spat->entries) { - g_free (spat->entries); - spat->entries = NULL; - } - - if (spat->hasobj) { - if (spat->src.object) { - spat->modified_connection.disconnect(); - spat->release_connection.disconnect(); - spat->src.object = NULL; - } - } else { - if (spat->src.repr) { - spat->src.repr = Inkscape::GC::release(spat->src.repr); - } - } - - spat->hasobj = TRUE; + clear(); + hasobj = true; +g_message("1"); if (object) { - gint i; - - spat->blocked = TRUE; +g_message("2"); + blocked = true; /* Set up object */ - spat->src.object = object; - spat->num_attr = num_attr; + src.object = object; - spat->modified_connection = object->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_attribute_table_object_modified), spat)); - spat->release_connection = object->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_attribute_table_object_release), spat)); + modified_connection = object->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_attribute_table_object_modified), this)); + //release_connection = object->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_attribute_table_object_release), this)); /* Create table */ - spat->table = gtk_table_new (num_attr, 2, FALSE); - gtk_container_add (GTK_CONTAINER (spat), spat->table); - /* Arrays */ - spat->attributes = g_new0 (gchar *, num_attr); - spat->entries = g_new0 (GtkWidget *, num_attr); +g_message("3a"); + table = new Gtk::Table (attributes.size(), 2, false); +g_message("3b"); + gtk_container_add (parent,(GtkWidget*)table->gobj()); +g_message("3c"); + /* Fill rows */ - for (i = 0; i < num_attr; i++) { - GtkWidget *w; + _attributes = attributes; + for (gint i = 0; i < (attributes.size()); i++) { + Gtk::Label *ll; + Gtk::Entry *ee; + Gtk::Widget *w; const gchar *val; - spat->attributes[i] = g_strdup (attributes[i]); - w = gtk_label_new (_(labels[i])); - gtk_widget_show (w); - gtk_misc_set_alignment (GTK_MISC (w), 1.0, 0.5); - gtk_table_attach ( GTK_TABLE (spat->table), w, 0, 1, i, i + 1, - GTK_FILL, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), + ll = new Gtk::Label (_(labels[i].c_str())); + w = (Gtk::Widget *) ll; + ll->show(); + ll->set_alignment (1.0, 0.5); + table->attach (*w, 0, 1, i, i + 1, + Gtk::FILL, + (Gtk::EXPAND | Gtk::FILL), XPAD, YPAD ); - w = gtk_entry_new (); - gtk_widget_show (w); - val = object->getRepr()->attribute(attributes[i]); - gtk_entry_set_text (GTK_ENTRY (w), val ? val : (const gchar *) ""); - gtk_table_attach ( GTK_TABLE (spat->table), w, 1, 2, i, i + 1, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), +g_message("4a"); + ee = new Gtk::Entry(); + w = (Gtk::Widget *) ee; + ee->show(); + val = object->getRepr()->attribute(attributes[i].c_str()); + ee->set_text (val ? val : (const gchar *) ""); + table->attach (*w, 1, 2, i, i + 1, + (Gtk::EXPAND | Gtk::FILL), + (Gtk::EXPAND | Gtk::FILL), XPAD, YPAD ); - spat->entries[i] = w; - g_signal_connect ( G_OBJECT (w), "changed", + _entries.push_back(w); + g_signal_connect ( w->gobj(), "changed", G_CALLBACK (sp_attribute_table_entry_changed), - spat ); + this ); +g_message("4b"); } /* Show table */ - gtk_widget_show (spat->table); - - spat->blocked = FALSE; + table->show (); + blocked = false; } - gtk_widget_set_sensitive ( GTK_WIDGET (spat), - (spat->src.object != NULL) ); - -} // end of sp_attribute_table_set_object() - - + //set_sensitive ((src.object != NULL) ); +g_message("5"); +} -void sp_attribute_table_set_repr ( SPAttributeTable *spat, - Inkscape::XML::Node *repr, - gint num_attr, - const gchar **labels, - const gchar **attributes ) +void SPAttributeTable::set_repr (Inkscape::XML::Node *repr, + std::vector<Glib::ustring> &labels, + std::vector<Glib::ustring> &attributes, + GtkContainer* parent) { - g_return_if_fail (spat != NULL); - g_return_if_fail (SP_IS_ATTRIBUTE_TABLE (spat)); - g_return_if_fail (!num_attr || (labels && attributes)); +g_message("set_repr"); + g_return_if_fail (!labels.empty() || !attributes.empty()); + g_return_if_fail (labels.size() == attributes.size()); - if (spat->table) { - gtk_widget_destroy (spat->table); - spat->table = NULL; - } + clear(); - if (spat->attributes) { - gint i; - for (i = 0; i < spat->num_attr; i++) { - g_free (spat->attributes[i]); - } - g_free (spat->attributes); - spat->attributes = NULL; - } - - if (spat->entries) { - g_free (spat->entries); - spat->entries = NULL; - } - - if (spat->hasobj) { - if (spat->src.object) { - spat->modified_connection.disconnect(); - spat->release_connection.disconnect(); - spat->src.object = NULL; - } - } else { - if (spat->src.repr) { - spat->src.repr = Inkscape::GC::release(spat->src.repr); - } - } - - spat->hasobj = FALSE; + hasobj = false; if (repr) { - gint i; - - spat->blocked = TRUE; - - /* Set up repr */ - spat->src.repr = Inkscape::GC::anchor(repr); - spat->num_attr = num_attr; - /* Create table */ - spat->table = gtk_table_new (num_attr, 2, FALSE); - gtk_container_add (GTK_CONTAINER (spat), spat->table); - /* Arrays */ - spat->attributes = g_new0 (gchar *, num_attr); - spat->entries = g_new0 (GtkWidget *, num_attr); + blocked = true; - /* Fill rows */ - for (i = 0; i < num_attr; i++) { - GtkWidget *w; + // Set up repr + src.repr = Inkscape::GC::anchor(repr); + + // Create table + table = new Gtk::Table (attributes.size(), 2, false); + gtk_container_add (parent,(GtkWidget*)table->gobj()); + + // Fill rows + _attributes = attributes; + for (gint i = 0; i < (attributes.size()); i++) { + Gtk::Label *ll; + Gtk::Entry *ee; + Gtk::Widget *w; const gchar *val; - spat->attributes[i] = g_strdup (attributes[i]); - w = gtk_label_new (labels[i]); - gtk_widget_show (w); - gtk_misc_set_alignment (GTK_MISC (w), 1.0, 0.5); - gtk_table_attach ( GTK_TABLE (spat->table), w, 0, 1, i, i + 1, - GTK_FILL, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), + ll = new Gtk::Label (_(labels[i].c_str())); + w = (Gtk::Widget *) ll; + ll->show (); + ll->set_alignment (1.0, 0.5); + table->attach (*w, 0, 1, i, i + 1, + Gtk::FILL, + (Gtk::EXPAND | Gtk::FILL), XPAD, YPAD ); - w = gtk_entry_new (); - gtk_widget_show (w); - val = repr->attribute(attributes[i]); - gtk_entry_set_text (GTK_ENTRY (w), val ? val : (const gchar *) ""); - gtk_table_attach ( GTK_TABLE (spat->table), w, 1, 2, i, i + 1, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), + ee = new Gtk::Entry(); + w = (Gtk::Widget *) ee; + ee->show(); + val = repr->attribute(attributes[i].c_str()); + ee->set_text (val ? val : (const gchar *) ""); + table->attach (*w, 1, 2, i, i + 1, + (Gtk::EXPAND | Gtk::FILL), + (Gtk::EXPAND | Gtk::FILL), XPAD, YPAD ); - spat->entries[i] = w; - g_signal_connect ( G_OBJECT (w), "changed", + _entries.push_back(w); +//ee->on_change = sp_attribute_table_entry_changed; + g_signal_connect ( w->gobj(), "changed", G_CALLBACK (sp_attribute_table_entry_changed), - spat ); + this ); } /* Show table */ - gtk_widget_show (spat->table); - - spat->blocked = FALSE; + table->show (); + blocked = false; } - gtk_widget_set_sensitive (GTK_WIDGET (spat), (spat->src.repr != NULL)); - -} // end of sp_attribute_table_set_repr() - + //set_sensitive ((src.repr != NULL)); +} static void sp_attribute_table_object_modified ( SPObject */*object*/, guint flags, SPAttributeTable *spat ) { +g_message("sp_attribute_table_object_modified"); if (flags && SP_OBJECT_MODIFIED_FLAG) { gint i; - for (i = 0; i < spat->num_attr; i++) { - const gchar *val, *text; - val = spat->src.object->getRepr()->attribute(spat->attributes[i]); - text = gtk_entry_get_text (GTK_ENTRY (spat->entries[i])); - if (val || text) { - if (!val || !text || strcmp (val, text)) { + std::vector<Glib::ustring> attributes = spat->get_attributes(); + std::vector<Gtk::Widget *> entries = spat->get_entries(); + Gtk::Entry* e; + Glib::ustring text; + for (i = 0; i < (attributes.size()); i++) { + const gchar *val; + e = (Gtk::Entry*) entries[i]; + val = spat->src.object->getRepr()->attribute(attributes[i].c_str()); + text = e->get_text (); + if (val || !text.empty()) { + if (text != val) { /* We are different */ - spat->blocked = TRUE; - gtk_entry_set_text ( GTK_ENTRY (spat->entries[i]), - val ? val : (const gchar *) ""); - spat->blocked = FALSE; + spat->blocked = true; + e->set_text (val ? val : (const gchar *) ""); + spat->blocked = false; } } } @@ -559,42 +445,41 @@ static void sp_attribute_table_object_modified ( SPObject */*object*/, } // end of sp_attribute_table_object_modified() +//static void sp_attribute_table_object_release (SPObject */*object*/, SPAttributeTable *spat) +/*{ +g_message("sp_attribute_table_object_release"); + std::vector<Glib::ustring> labels; + std::vector<Glib::ustring> attributes; + spat->set_object (NULL, labels, attributes, NULL); +}*/ - -static void sp_attribute_table_object_release (SPObject */*object*/, SPAttributeTable *spat) -{ - sp_attribute_table_set_object (spat, NULL, 0, NULL, NULL); -} - - - -static void sp_attribute_table_entry_changed ( GtkEditable *editable, +static void sp_attribute_table_entry_changed ( Gtk::Editable *editable, SPAttributeTable *spat ) { +g_message("sp_attribute_table_entry_changed"); if (!spat->blocked) { gint i; - for (i = 0; i < spat->num_attr; i++) { - - if (GTK_WIDGET (editable) == spat->entries[i]) { - const gchar *text; - spat->blocked = TRUE; - text = gtk_entry_get_text (GTK_ENTRY (spat->entries[i])); - - if (!*text) - text = NULL; + std::vector<Glib::ustring> attributes = spat->get_attributes(); + std::vector<Gtk::Widget *> entries = spat->get_entries(); + Gtk::Entry *e; + for (i = 0; i < (attributes.size()); i++) { + e = (Gtk::Entry *) entries[i]; + if ((GtkWidget*) (editable) == (GtkWidget*) e->gobj()) { + spat->blocked = true; + Glib::ustring text = e->get_text (); if (spat->hasobj && spat->src.object) { - spat->src.object->getRepr()->setAttribute(spat->attributes[i], text, false); + spat->src.object->getRepr()->setAttribute(attributes[i].c_str(), text.c_str(), false); DocumentUndo::done(spat->src.object->document, SP_VERB_NONE, _("Set attribute")); } else if (spat->src.repr) { - spat->src.repr->setAttribute(spat->attributes[i], text, false); + spat->src.repr->setAttribute(attributes[i].c_str(), text.c_str(), false); /* TODO: Warning! Undo will not be flushed in given case */ } - spat->blocked = FALSE; + spat->blocked = false; return; } } diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h index b3437eea7..aac567987 100644 --- a/src/widgets/sp-attribute-widget.h +++ b/src/widgets/sp-attribute-widget.h @@ -4,6 +4,7 @@ */ /* Authors: * Lauris Kaplinski <lauris@kaplinski.com> + * Kris De Gussem <Kris.DeGussem@gmail.com> * * Copyright (C) 2002 authors * Copyright (C) 2001 Ximian, Inc. @@ -14,16 +15,14 @@ #ifndef SEEN_DIALOGS_SP_ATTRIBUTE_WIDGET_H #define SEEN_DIALOGS_SP_ATTRIBUTE_WIDGET_H -#include <gtkmm/entry.h> +#include <gtk/gtk.h> +#include <gtkmm.h> +//#include <gtkmm/entry.h> +//#include <gtkmm/table.h> #include <glib.h> #include <stddef.h> #include <sigc++/connection.h> - -#define SP_TYPE_ATTRIBUTE_TABLE (sp_attribute_table_get_type ()) -#define SP_ATTRIBUTE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_ATTRIBUTE_TABLE, SPAttributeTable)) -#define SP_ATTRIBUTE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_ATTRIBUTE_TABLE, SPAttributeTableClass)) -#define SP_IS_ATTRIBUTE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_ATTRIBUTE_TABLE)) -#define SP_IS_ATTRIBUTE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_ATTRIBUTE_TABLE)) +#include <vector.h> namespace Inkscape { namespace XML { @@ -33,12 +32,9 @@ class Node; struct SPAttributeTable; struct SPAttributeTableClass; +class SPObject; -class SPObject; - -#include <gtk/gtk.h> - -class SPAttributeWidget : Gtk::Entry { +class SPAttributeWidget : public Gtk::Entry { //NOTE: SPAttributeWidget does not seem to be used nowhere in Inkscape, conversion to c++ not tested public: SPAttributeWidget (); @@ -67,44 +63,34 @@ private: /* SPAttributeTable */ -struct SPAttributeTable { - GtkVBox vbox; - guint blocked : 1; - guint hasobj : 1; - GtkWidget *table; +class SPAttributeTable : public Gtk::Widget { +public: + SPAttributeTable (); + SPAttributeTable (SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkContainer* parent); + ~SPAttributeTable (); + void set_object(SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkContainer* parent); + void set_repr(Inkscape::XML::Node *repr, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkContainer* parent); + std::vector<Glib::ustring> get_attributes(void) {return _attributes;}; + std::vector<Gtk::Widget *> get_entries(void) {return _entries;}; union { SPObject *object; Inkscape::XML::Node *repr; } src; - gint num_attr; - gchar **attributes; - GtkWidget **entries; + guint blocked; + guint hasobj; +private: +// GtkVBox vbox; + Gtk::Table *table; +// Gtk::Container *_parent; + std::vector<Glib::ustring> _attributes; + std::vector<Gtk::Widget *> _entries; sigc::connection modified_connection; - sigc::connection release_connection; -}; - -struct SPAttributeTableClass { - GtkEntryClass entry_class; + //sigc::connection release_connection; + + void clear(void); }; -GType sp_attribute_table_get_type (void); - -GtkWidget *sp_attribute_table_new ( SPObject *object, gint num_attr, - const gchar **labels, - const gchar **attributes ); -GtkWidget *sp_attribute_table_new_repr ( Inkscape::XML::Node *repr, gint num_attr, - const gchar **labels, - const gchar **attributes ); -void sp_attribute_table_set_object ( SPAttributeTable *spw, - SPObject *object, gint num_attr, - const gchar **labels, - const gchar **attrs ); -void sp_attribute_table_set_repr ( SPAttributeTable *spw, - Inkscape::XML::Node *repr, gint num_attr, - const gchar **labels, - const gchar **attrs ); - #endif /* |
