From 3f85163d6c6ce18cebab214ad86cc06956e1866e Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Fri, 30 Dec 2011 11:59:19 +0100 Subject: C++ification of item properties dialog (bzr r10805) --- src/widgets/sp-attribute-widget.cpp | 79 +++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 38 deletions(-) (limited to 'src/widgets/sp-attribute-widget.cpp') diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index d2c52e2ae..239879130 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -39,7 +39,7 @@ SPAttributeTable::SPAttributeTable () : src.object = NULL; } -SPAttributeTable::SPAttributeTable (SPObject *object, std::vector &labels, std::vector &attributes, GtkWidget* parent) : +SPAttributeTable::SPAttributeTable (SPObject *object, std::vector &labels, std::vector &attributes, GtkWidget* ExpanderContainer) : blocked(0), hasobj(0), table(0), @@ -48,7 +48,7 @@ SPAttributeTable::SPAttributeTable (SPObject *object, std::vector modified_connection() { src.object = NULL; - set_object(object, labels, attributes, parent); + set_object(object, labels, attributes, ExpanderContainer); } SPAttributeTable::~SPAttributeTable () @@ -62,27 +62,27 @@ void SPAttributeTable::clear(void) if (table) { - std::vector ch = table->get_children(); - - for (int i = (ch.size())-1; i >=0 ; i--) - { - w = ch[i]; - ch.pop_back(); - if (w != NULL) + std::vector ch = table->get_children(); + + for (int i = (ch.size())-1; i >=0 ; i--) { - try - { - delete w; - } - catch(...) + w = ch[i]; + ch.pop_back(); + if (w != NULL) { + try + { + delete w; + } + catch(...) + { + } } } - } - ch.clear(); - _attributes.clear(); - _entries.clear(); - + ch.clear(); + _attributes.clear(); + _entries.clear(); + delete table; table = NULL; } @@ -102,9 +102,8 @@ void SPAttributeTable::clear(void) void SPAttributeTable::set_object(SPObject *object, std::vector &labels, std::vector &attributes, - GtkWidget* parent) + GtkWidget* ExpanderContainer) { - g_return_if_fail (parent); g_return_if_fail (!object || SP_IS_OBJECT (object)); g_return_if_fail (!object || !labels.empty() || !attributes.empty()); g_return_if_fail (labels.size() == attributes.size()); @@ -120,17 +119,19 @@ void SPAttributeTable::set_object(SPObject *object, modified_connection = object->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_attribute_table_object_modified), this)); // Create table - table = Gtk::manage(new Gtk::Table (attributes.size(), 2, false)); - gtk_container_add (GTK_CONTAINER (parent),(GtkWidget*)table->gobj()); + table = new Gtk::Table (attributes.size(), 2, false); + if (!(ExpanderContainer == NULL)) + { + gtk_container_add (GTK_CONTAINER (ExpanderContainer),(GtkWidget*)table->gobj()); + } // Fill rows - _attributes = attributes; + _attributes = attributes; + Gtk::Label *ll; + Gtk::Entry *ee; + Gtk::Widget *w; + const gchar *val; for (guint i = 0; i < (attributes.size()); i++) { - Gtk::Label *ll; - Gtk::Entry *ee; - Gtk::Widget *w; - const gchar *val; - ll = new Gtk::Label (_(labels[i].c_str())); w = (Gtk::Widget *) ll; ll->show(); @@ -162,7 +163,7 @@ void SPAttributeTable::set_object(SPObject *object, void SPAttributeTable::set_repr (Inkscape::XML::Node *repr, std::vector &labels, std::vector &attributes, - GtkWidget* parent) + GtkWidget* ExpanderContainer) { g_return_if_fail (!labels.empty() || !attributes.empty()); g_return_if_fail (labels.size() == attributes.size()); @@ -179,16 +180,18 @@ void SPAttributeTable::set_repr (Inkscape::XML::Node *repr, // Create table table = new Gtk::Table (attributes.size(), 2, false); - gtk_container_add (GTK_CONTAINER (parent),(GtkWidget*)table->gobj()); + if (!(ExpanderContainer == NULL)) + { + gtk_container_add (GTK_CONTAINER (ExpanderContainer),(GtkWidget*)table->gobj()); + } // Fill rows _attributes = attributes; + Gtk::Label *ll; + Gtk::Entry *ee; + Gtk::Widget *w; + const gchar *val; for (guint i = 0; i < (attributes.size()); i++) { - Gtk::Label *ll; - Gtk::Entry *ee; - Gtk::Widget *w; - const gchar *val; - ll = new Gtk::Label (_(labels[i].c_str())); w = (Gtk::Widget *) ll; ll->show (); @@ -243,7 +246,7 @@ static void sp_attribute_table_object_modified ( SPObject */*object*/, } } } - } // end of if() + } } // end of sp_attribute_table_object_modified() @@ -277,7 +280,7 @@ static void sp_attribute_table_entry_changed ( Gtk::Editable *editable, } } g_warning ("file %s: line %d: Entry signalled change, but there is no such entry", __FILE__, __LINE__); - } // end of if() + } } // end of sp_attribute_table_entry_changed() -- cgit v1.2.3