From e36c534d5676a2a36fef713b4eac230f5129282e Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Mon, 12 Dec 2011 00:10:01 +0100 Subject: mixed usage of class and struct for same object (bzr r10766.1.1) --- src/conn-avoid-ref.h | 6 +++--- src/context-fns.h | 4 ++-- src/desktop-events.h | 6 +++--- src/desktop-style.h | 4 ++-- src/desktop.h | 4 ++-- src/display/canvas-axonomgrid.h | 2 +- src/display/canvas-grid.h | 4 ++-- src/display/canvas-text.h | 4 ++-- src/display/sp-ctrlline.h | 2 +- src/display/sp-ctrlpoint.h | 2 +- src/document.h | 4 ++-- src/event-context.h | 6 +++--- src/gradient-drag.h | 2 +- src/knot-holder-entity.h | 2 +- src/live_effects/effect.h | 12 ++++++------ src/live_effects/parameter/parameter.h | 4 ++-- src/object-snapper.h | 4 ++-- src/rubberband.h | 8 ++++---- src/selcue.h | 4 ++-- src/seltrans.h | 6 +++--- src/snap-candidate.h | 2 +- src/snapper.h | 2 +- src/sp-shape.h | 2 +- src/splivarot.h | 2 +- src/svg-view.h | 2 +- src/text-editing.h | 6 +++--- src/trace/trace.h | 2 +- src/ui/dialog/calligraphic-profile-rename.h | 2 +- src/ui/dialog/icon-preview.h | 2 +- src/ui/widget/ruler.h | 2 +- src/widgets/select-toolbar.h | 2 +- 31 files changed, 58 insertions(+), 58 deletions(-) (limited to 'src') diff --git a/src/conn-avoid-ref.h b/src/conn-avoid-ref.h index f99d1f0cb..89e86ded7 100644 --- a/src/conn-avoid-ref.h +++ b/src/conn-avoid-ref.h @@ -13,12 +13,12 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#include #include #include -struct SPDesktop; -struct SPItem; +class SPDesktop; +class SPItem; struct ConnectionPoint; typedef std::map IdConnectionPointMap; namespace Avoid { class ShapeRef; } diff --git a/src/context-fns.h b/src/context-fns.h index c56c67a27..12d6e6194 100644 --- a/src/context-fns.h +++ b/src/context-fns.h @@ -14,8 +14,8 @@ #include #include <2geom/forward.h> -struct SPDesktop; -struct SPItem; +class SPDesktop; +class SPItem; struct SPEventContext; const double goldenratio = 1.61803398874989484820; // golden ratio diff --git a/src/desktop-events.h b/src/desktop-events.h index e573fc878..cac7e089f 100644 --- a/src/desktop-events.h +++ b/src/desktop-events.h @@ -16,9 +16,9 @@ #include #include -class SPDesktop; -class SPDesktopWidget; -class SPCanvasItem; +class SPDesktop; +class SPDesktopWidget; +struct SPCanvasItem; /* Item handlers */ diff --git a/src/desktop-style.h b/src/desktop-style.h index 3719c2a9e..81485420b 100644 --- a/src/desktop-style.h +++ b/src/desktop-style.h @@ -17,8 +17,8 @@ class ColorRGBA; struct SPCSSAttr; -struct SPDesktop; -struct SPObject; +class SPDesktop; +class SPObject; struct SPStyle; namespace Inkscape { namespace XML { diff --git a/src/desktop.h b/src/desktop.h index 8921f45b8..b466fff15 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -44,9 +44,9 @@ struct SPCanvas; struct SPCanvasItem; struct SPCanvasGroup; struct SPEventContext; -struct SPItem; +class SPItem; struct SPNamedView; -struct SPObject; +class SPObject; struct SPStyle; typedef struct _DocumentInterface DocumentInterface;//struct DocumentInterface; diff --git a/src/display/canvas-axonomgrid.h b/src/display/canvas-axonomgrid.h index e63d660fe..1f8bad51d 100644 --- a/src/display/canvas-axonomgrid.h +++ b/src/display/canvas-axonomgrid.h @@ -24,7 +24,7 @@ #include "canvas-grid.h" -struct SPDesktop; +class SPDesktop; struct SPNamedView; namespace Inkscape { diff --git a/src/display/canvas-grid.h b/src/display/canvas-grid.h index 10feeca0e..f7cc3c032 100644 --- a/src/display/canvas-grid.h +++ b/src/display/canvas-grid.h @@ -24,10 +24,10 @@ #include "snapper.h" #include "line-snapper.h" -struct SPDesktop; +class SPDesktop; struct SPNamedView; struct SPCanvasBuf; -class SPDocument; +class SPDocument; namespace Inkscape { diff --git a/src/display/canvas-text.h b/src/display/canvas-text.h index 85333d84e..90c02717c 100644 --- a/src/display/canvas-text.h +++ b/src/display/canvas-text.h @@ -16,8 +16,8 @@ #include "sp-canvas-item.h" -struct SPItem; -struct SPDesktop; +class SPItem; +class SPDesktop; #define SP_TYPE_CANVASTEXT (sp_canvastext_get_type ()) #define SP_CANVASTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CANVASTEXT, SPCanvasText)) diff --git a/src/display/sp-ctrlline.h b/src/display/sp-ctrlline.h index eeed7e75d..4bfe50a77 100644 --- a/src/display/sp-ctrlline.h +++ b/src/display/sp-ctrlline.h @@ -16,7 +16,7 @@ #include "sp-canvas-item.h" -struct SPItem; +class SPItem; #define SP_TYPE_CTRLLINE (sp_ctrlline_get_type ()) #define SP_CTRLLINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CTRLLINE, SPCtrlLine)) diff --git a/src/display/sp-ctrlpoint.h b/src/display/sp-ctrlpoint.h index 907f74bf8..a7a5475b7 100644 --- a/src/display/sp-ctrlpoint.h +++ b/src/display/sp-ctrlpoint.h @@ -14,7 +14,7 @@ #include "sp-canvas-item.h" -struct SPItem; +class SPItem; #define SP_TYPE_CTRLPOINT (sp_ctrlpoint_get_type ()) #define SP_CTRLPOINT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CTRLPOINT, SPCtrlPoint)) diff --git a/src/document.h b/src/document.h index efb14123a..b799cb832 100644 --- a/src/document.h +++ b/src/document.h @@ -39,8 +39,8 @@ class Router; } struct SPDesktop; -struct SPItem; -struct SPObject; +class SPItem; +class SPObject; struct SPGroup; struct SPRoot; struct SPUnit; diff --git a/src/event-context.h b/src/event-context.h index 1c9f46a46..1e641e6ef 100644 --- a/src/event-context.h +++ b/src/event-context.h @@ -20,9 +20,9 @@ #include "preferences.h" struct GrDrag; -struct SPDesktop; -struct SPItem; -class ShapeEditor; +class SPDesktop; +class SPItem; +class ShapeEditor; struct SPEventContext; namespace Inkscape { diff --git a/src/gradient-drag.h b/src/gradient-drag.h index cb3f13e71..8aa9a6550 100644 --- a/src/gradient-drag.h +++ b/src/gradient-drag.h @@ -24,12 +24,12 @@ #include "knot-enums.h" -struct SPItem; struct SPKnot; class SPDesktop; class SPCSSAttr; class SPLinearGradient; +class SPItem; class SPObject; class SPRadialGradient; class SPStop; diff --git a/src/knot-holder-entity.h b/src/knot-holder-entity.h index e708486ca..5422e6d1b 100644 --- a/src/knot-holder-entity.h +++ b/src/knot-holder-entity.h @@ -19,7 +19,7 @@ #include <2geom/forward.h> #include "snapper.h" -struct SPItem; +class SPItem; struct SPKnot; class SPDesktop; diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index 91d09fef6..48577c225 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -21,13 +21,13 @@ struct SPDocument; struct SPDesktop; -struct SPItem; -class SPNodeContext; +class SPItem; +class SPNodeContext; struct LivePathEffectObject; -class SPLPEItem; -class KnotHolder; -class KnotHolderEntity; -class SPPath; +class SPLPEItem; +class KnotHolder; +class KnotHolderEntity; +class SPPath; struct SPCurve; namespace Gtk { diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index fe93e8dca..92c2c8b41 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -15,8 +15,8 @@ class KnotHolder; class SPLPEItem; -struct SPDesktop; -struct SPItem; +class SPDesktop; +class SPItem; namespace Gtk { class Widget; diff --git a/src/object-snapper.h b/src/object-snapper.h index d51cade93..59e2f10ce 100644 --- a/src/object-snapper.h +++ b/src/object-snapper.h @@ -16,8 +16,8 @@ #include "snap-candidate.h" struct SPNamedView; -struct SPItem; -struct SPObject; +class SPItem; +class SPObject; namespace Inkscape { diff --git a/src/rubberband.h b/src/rubberband.h index 1b71f9ae2..fbebe2b08 100644 --- a/src/rubberband.h +++ b/src/rubberband.h @@ -17,10 +17,10 @@ /* fixme: do multidocument safe */ -class CtrlRect; -class SPCanvasItem; -class SPCurve; -class SPDesktop; +class CtrlRect; +struct SPCanvasItem; +class SPCurve; +class SPDesktop; enum { RUBBERBAND_MODE_RECT, diff --git a/src/selcue.h b/src/selcue.h index 0869a597d..f62ef768a 100644 --- a/src/selcue.h +++ b/src/selcue.h @@ -17,8 +17,8 @@ #include #include -class SPDesktop; -class SPCanvasItem; +class SPDesktop; +struct SPCanvasItem; namespace Inkscape { diff --git a/src/seltrans.h b/src/seltrans.h index 3804caef3..122e7a522 100644 --- a/src/seltrans.h +++ b/src/seltrans.h @@ -27,9 +27,9 @@ #include "sp-item.h" struct SPKnot; -class SPDesktop; -class SPCanvasItem; -class SPSelTransHandle; +class SPDesktop; +struct SPCanvasItem; +class SPSelTransHandle; namespace Inkscape { diff --git a/src/snap-candidate.h b/src/snap-candidate.h index 1c5cf3234..5f17c8572 100644 --- a/src/snap-candidate.h +++ b/src/snap-candidate.h @@ -17,7 +17,7 @@ //#include "snapped-point.h" #include "snap-enums.h" -struct SPItem; // forward declaration +class SPItem; // forward declaration namespace Inkscape { diff --git a/src/snapper.h b/src/snapper.h index f5fbd4fdc..78d32c12c 100644 --- a/src/snapper.h +++ b/src/snapper.h @@ -31,7 +31,7 @@ struct IntermSnapResults { }; class SnapManager; -struct SPItem; +class SPItem; namespace Inkscape { diff --git a/src/sp-shape.h b/src/sp-shape.h index 014158b21..c5e9588b3 100644 --- a/src/sp-shape.h +++ b/src/sp-shape.h @@ -31,7 +31,7 @@ #define SP_SHAPE_WRITE_PATH (1 << 2) -struct SPDesktop; +class SPDesktop; namespace Inkscape { diff --git a/src/splivarot.h b/src/splivarot.h index 40089ad71..9dc596888 100644 --- a/src/splivarot.h +++ b/src/splivarot.h @@ -11,7 +11,7 @@ #include <2geom/forward.h> #include <2geom/path.h> class SPCurve; -struct SPItem; +class SPItem; // boolean operations // work on the current selection diff --git a/src/svg-view.h b/src/svg-view.h index 33a9b569a..aaaa8a9a5 100644 --- a/src/svg-view.h +++ b/src/svg-view.h @@ -14,7 +14,7 @@ #include "ui/view/view.h" class SPCanvasGroup; -class SPCanvasItem; +struct SPCanvasItem; /** diff --git a/src/text-editing.h b/src/text-editing.h index c0f104dec..37527d385 100644 --- a/src/text-editing.h +++ b/src/text-editing.h @@ -18,9 +18,9 @@ #include "libnrtype/Layout-TNG.h" #include "text-tag-attributes.h" -class SPCSSAttr; -struct SPItem; -struct SPObject; +class SPCSSAttr; +class SPItem; +class SPObject; struct SPStyle; typedef std::pair iterator_pair; diff --git a/src/trace/trace.h b/src/trace/trace.h index 29b8716ee..a7fbe0cc8 100644 --- a/src/trace/trace.h +++ b/src/trace/trace.h @@ -27,7 +27,7 @@ #include struct SPImage; -struct SPItem; +class SPItem; namespace Inkscape { diff --git a/src/ui/dialog/calligraphic-profile-rename.h b/src/ui/dialog/calligraphic-profile-rename.h index e9f6a8b95..f0eb0b491 100644 --- a/src/ui/dialog/calligraphic-profile-rename.h +++ b/src/ui/dialog/calligraphic-profile-rename.h @@ -15,7 +15,7 @@ #include #include #include -struct SPDesktop; +class SPDesktop; namespace Inkscape { namespace UI { diff --git a/src/ui/dialog/icon-preview.h b/src/ui/dialog/icon-preview.h index 9c10eb89b..ec4b3cac4 100644 --- a/src/ui/dialog/icon-preview.h +++ b/src/ui/dialog/icon-preview.h @@ -26,7 +26,7 @@ #include "ui/widget/panel.h" #include "desktop-tracker.h" -struct SPObject; +class SPObject; namespace Glib { class Timer; } diff --git a/src/ui/widget/ruler.h b/src/ui/widget/ruler.h index 319624709..1a455a325 100644 --- a/src/ui/widget/ruler.h +++ b/src/ui/widget/ruler.h @@ -14,7 +14,7 @@ #include <2geom/point.h> struct SPCanvasItem; -struct SPDesktop; +class SPDesktop; namespace Glib { class ustring; } diff --git a/src/widgets/select-toolbar.h b/src/widgets/select-toolbar.h index a4c42880f..e3573da66 100644 --- a/src/widgets/select-toolbar.h +++ b/src/widgets/select-toolbar.h @@ -15,7 +15,7 @@ */ #include -struct SPDesktop; +class SPDesktop; void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder); -- cgit v1.2.3 From 48a43f957441a3b86ff12c15052789865e422e64 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Mon, 12 Dec 2011 00:13:51 +0100 Subject: SPAttributeWidget C++ified (bzr r10766.1.2) --- src/display/gnome-canvas-acetate.cpp | 18 +- src/widgets/sp-attribute-widget.cpp | 317 ++++++++++------------------------- src/widgets/sp-attribute-widget.h | 48 ++---- 3 files changed, 109 insertions(+), 274 deletions(-) (limited to 'src') diff --git a/src/display/gnome-canvas-acetate.cpp b/src/display/gnome-canvas-acetate.cpp index bdda3a120..544efe61f 100644 --- a/src/display/gnome-canvas-acetate.cpp +++ b/src/display/gnome-canvas-acetate.cpp @@ -25,8 +25,7 @@ static double sp_canvas_acetate_point (SPCanvasItem *item, Geom::Point p, SPCanv static SPCanvasItemClass *parent_class; -GType -sp_canvas_acetate_get_type (void) +GType sp_canvas_acetate_get_type (void) { static GType acetate_type = 0; if (!acetate_type) { @@ -45,8 +44,7 @@ sp_canvas_acetate_get_type (void) return acetate_type; } -static void -sp_canvas_acetate_class_init (SPCanvasAcetateClass *klass) +static void sp_canvas_acetate_class_init (SPCanvasAcetateClass *klass) { GtkObjectClass *object_class; SPCanvasItemClass *item_class; @@ -62,14 +60,12 @@ sp_canvas_acetate_class_init (SPCanvasAcetateClass *klass) item_class->point = sp_canvas_acetate_point; } -static void -sp_canvas_acetate_init (SPCanvasAcetate */*acetate*/) +static void sp_canvas_acetate_init (SPCanvasAcetate */*acetate*/) { /* Nothing here */ } -static void -sp_canvas_acetate_destroy (GtkObject *object) +static void sp_canvas_acetate_destroy (GtkObject *object) { SPCanvasAcetate *acetate; @@ -82,8 +78,7 @@ sp_canvas_acetate_destroy (GtkObject *object) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } -static void -sp_canvas_acetate_update( SPCanvasItem *item, Geom::Affine const &/*affine*/, unsigned int /*flags*/ ) +static void sp_canvas_acetate_update( SPCanvasItem *item, Geom::Affine const &/*affine*/, unsigned int /*flags*/ ) { item->x1 = -G_MAXINT; item->y1 = -G_MAXINT; @@ -91,8 +86,7 @@ sp_canvas_acetate_update( SPCanvasItem *item, Geom::Affine const &/*affine*/, un item->y2 = G_MAXINT; } -static double -sp_canvas_acetate_point( SPCanvasItem *item, Geom::Point /*p*/, SPCanvasItem **actual_item ) +static double sp_canvas_acetate_point( SPCanvasItem *item, Geom::Point /*p*/, SPCanvasItem **actual_item ) { *actual_item = item; diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index f3bdc062d..7d4424cfd 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -20,277 +20,133 @@ using Inkscape::DocumentUndo; -static void sp_attribute_widget_class_init (SPAttributeWidgetClass *klass); -static void sp_attribute_widget_init (SPAttributeWidget *widget); -static void sp_attribute_widget_destroy (GtkObject *object); - -static void sp_attribute_widget_changed (GtkEditable *editable); - static void sp_attribute_widget_object_modified ( SPObject *object, guint flags, SPAttributeWidget *spaw ); static void sp_attribute_widget_object_release ( SPObject *object, SPAttributeWidget *spaw ); -static GtkEntryClass *parent_class; - - - -GType sp_attribute_widget_get_type(void) +SPAttributeWidget::SPAttributeWidget () : + blocked(0), + hasobj(0), + _attribute(), + modified_connection(), + release_connection() { - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPAttributeWidgetClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_attribute_widget_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPAttributeWidget), - 0, // n_preallocs - (GInstanceInitFunc)sp_attribute_widget_init, - 0 // value_table - }; - type = g_type_register_static(GTK_TYPE_ENTRY, "SPAttributeWidget", &info, static_cast(0)); - } - return type; -} // end of sp_attribute_widget_get_type() - - - -static void sp_attribute_widget_class_init (SPAttributeWidgetClass *klass) -{ - GtkObjectClass *object_class; - GtkEditableClass *editable_class; - - object_class = GTK_OBJECT_CLASS (klass); - editable_class = GTK_EDITABLE_CLASS (klass); - - parent_class = (GtkEntryClass*)g_type_class_peek_parent (klass); - - object_class->destroy = sp_attribute_widget_destroy; - - editable_class->changed = sp_attribute_widget_changed; - -} // end of sp_attribute_widget_class_init() - - - -static void sp_attribute_widget_init (SPAttributeWidget *spaw) -{ - spaw->blocked = FALSE; - spaw->hasobj = FALSE; - - spaw->src.object = NULL; - - spaw->attribute = NULL; - - new (&spaw->modified_connection) sigc::connection(); - new (&spaw->release_connection) sigc::connection(); + src.object = NULL; } - - -static void sp_attribute_widget_destroy (GtkObject *object) +SPAttributeWidget::~SPAttributeWidget () { - - SPAttributeWidget *spaw; - - spaw = SP_ATTRIBUTE_WIDGET (object); - - if (spaw->attribute) { - g_free (spaw->attribute); - spaw->attribute = NULL; - } - - - if (spaw->hasobj) { - - if (spaw->src.object) { - spaw->modified_connection.disconnect(); - spaw->release_connection.disconnect(); - spaw->src.object = NULL; - } - } else { - - if (spaw->src.repr) { - spaw->src.repr = Inkscape::GC::release(spaw->src.repr); + if (hasobj) + { + if (src.object) + { + modified_connection.disconnect(); + release_connection.disconnect(); + src.object = NULL; } - } // end of if() - - spaw->modified_connection.~connection(); - spaw->release_connection.~connection(); - - ((GtkObjectClass *) parent_class)->destroy (object); - -} - - - -static void sp_attribute_widget_changed (GtkEditable *editable) -{ - - SPAttributeWidget *spaw; - - spaw = SP_ATTRIBUTE_WIDGET (editable); - - if (!spaw->blocked) { - - const gchar *text; - spaw->blocked = TRUE; - text = gtk_entry_get_text (GTK_ENTRY (spaw)); - if (!*text) - text = NULL; - - if (spaw->hasobj && spaw->src.object) { - spaw->src.object->getRepr()->setAttribute(spaw->attribute, text, false); - DocumentUndo::done(spaw->src.object->document, SP_VERB_NONE, - _("Set attribute")); - - } else if (spaw->src.repr) { - spaw->src.repr->setAttribute(spaw->attribute, text, false); - /* TODO: Warning! Undo will not be flushed in given case */ + } + else + { + if (src.repr) + { + src.repr = Inkscape::GC::release(src.repr); } - spaw->blocked = FALSE; } - -} // end of sp_attribute_widget_changed() - - - -GtkWidget *sp_attribute_widget_new ( SPObject *object, const gchar *attribute ) -{ - SPAttributeWidget *spaw; - - g_return_val_if_fail (!object || SP_IS_OBJECT (object), NULL); - g_return_val_if_fail (!object || attribute, NULL); - - spaw = (SPAttributeWidget*)g_object_new (SP_TYPE_ATTRIBUTE_WIDGET, NULL); - - sp_attribute_widget_set_object (spaw, object, attribute); - - return GTK_WIDGET (spaw); - -} // end of sp_attribute_widget_new() - - - -GtkWidget *sp_attribute_widget_new_repr ( Inkscape::XML::Node *repr, const gchar *attribute ) -{ - SPAttributeWidget *spaw; - - spaw = (SPAttributeWidget*)g_object_new (SP_TYPE_ATTRIBUTE_WIDGET, NULL); - - sp_attribute_widget_set_repr (spaw, repr, attribute); - - return GTK_WIDGET (spaw); } - - -void sp_attribute_widget_set_object ( SPAttributeWidget *spaw, - SPObject *object, - const gchar *attribute ) +void SPAttributeWidget::set_object(SPObject *object, const gchar *attribute) { - - g_return_if_fail (spaw != NULL); - g_return_if_fail (SP_IS_ATTRIBUTE_WIDGET (spaw)); - g_return_if_fail (!object || SP_IS_OBJECT (object)); - g_return_if_fail (!object || attribute); - g_return_if_fail (attribute != NULL); - - if (spaw->attribute) { - g_free (spaw->attribute); - spaw->attribute = NULL; - } - - if (spaw->hasobj) { - - if (spaw->src.object) { - spaw->modified_connection.disconnect(); - spaw->release_connection.disconnect(); - spaw->src.object = NULL; + if (hasobj) { + if (src.object) { + modified_connection.disconnect(); + release_connection.disconnect(); + src.object = NULL; } } else { - if (spaw->src.repr) { - spaw->src.repr = Inkscape::GC::release(spaw->src.repr); + if (src.repr) { + src.repr = Inkscape::GC::release(src.repr); } } - spaw->hasobj = TRUE; - + hasobj = true; + if (object) { const gchar *val; - spaw->blocked = TRUE; - spaw->src.object = object; + blocked = true; + src.object = object; - spaw->modified_connection = object->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_attribute_widget_object_modified), spaw)); - spaw->release_connection = object->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_attribute_widget_object_release), spaw)); + modified_connection = object->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_attribute_widget_object_modified), this)); + release_connection = object->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_attribute_widget_object_release), this)); - spaw->attribute = g_strdup (attribute); + _attribute = attribute; val = object->getRepr()->attribute(attribute); - gtk_entry_set_text (GTK_ENTRY (spaw), val ? val : (const gchar *) ""); - spaw->blocked = FALSE; + set_text (val ? val : (const gchar *) ""); + blocked = false; } + gtk_widget_set_sensitive (GTK_WIDGET(this), (src.object != NULL)); +} - gtk_widget_set_sensitive (GTK_WIDGET (spaw), (spaw->src.object != NULL)); - -} // end of sp_attribute_widget_set_object() - - - -void sp_attribute_widget_set_repr ( SPAttributeWidget *spaw, - Inkscape::XML::Node *repr, - const gchar *attribute ) +void SPAttributeWidget::set_repr(Inkscape::XML::Node *repr, const gchar *attribute) { - - g_return_if_fail (spaw != NULL); - g_return_if_fail (SP_IS_ATTRIBUTE_WIDGET (spaw)); - g_return_if_fail (attribute != NULL); - - if (spaw->attribute) { - g_free (spaw->attribute); - spaw->attribute = NULL; - } - - if (spaw->hasobj) { - - if (spaw->src.object) { - spaw->modified_connection.disconnect(); - spaw->release_connection.disconnect(); - spaw->src.object = NULL; + if (hasobj) { + if (src.object) { + modified_connection.disconnect(); + release_connection.disconnect(); + src.object = NULL; } } else { - if (spaw->src.repr) { - spaw->src.repr = Inkscape::GC::release(spaw->src.repr); + if (src.repr) { + src.repr = Inkscape::GC::release(src.repr); } } - spaw->hasobj = FALSE; - + hasobj = false; + if (repr) { const gchar *val; - spaw->blocked = TRUE; - spaw->src.repr = Inkscape::GC::anchor(repr); - spaw->attribute = g_strdup (attribute); + blocked = true; + src.repr = Inkscape::GC::anchor(repr); + attribute = g_strdup (attribute); val = repr->attribute(attribute); - gtk_entry_set_text (GTK_ENTRY (spaw), val ? val : (const gchar *) ""); - spaw->blocked = FALSE; + set_text (val ? val : (const gchar *) ""); + blocked = false; } + gtk_widget_set_sensitive (GTK_WIDGET (this), (src.repr != NULL)); +} - gtk_widget_set_sensitive (GTK_WIDGET (spaw), (spaw->src.repr != NULL)); - -} // end of sp_attribute_widget_set_repr() +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, @@ -300,17 +156,17 @@ 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->attribute); + val = spaw->src.object->getRepr()->attribute(spaw->get_attribute().c_str()); text = gtk_entry_get_text (GTK_ENTRY (spaw)); if (val || text) { if (!val || !text || strcmp (val, text)) { /* We are different */ - spaw->blocked = TRUE; + spaw->set_blocked(true); gtk_entry_set_text ( GTK_ENTRY (spaw), val ? val : (const gchar *) ""); - spaw->blocked = FALSE; + spaw->set_blocked(false); } // end of if() } // end of if() @@ -319,13 +175,10 @@ static void sp_attribute_widget_object_modified ( SPObject */*object*/, } // end of sp_attribute_widget_object_modified() - - -static void -sp_attribute_widget_object_release ( SPObject */*object*/, - SPAttributeWidget *spaw ) +static void sp_attribute_widget_object_release ( SPObject */*object*/, + SPAttributeWidget * spaw ) { - sp_attribute_widget_set_object (spaw, NULL, NULL); + spaw->set_object (NULL, NULL); } diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h index a4acf9504..b3437eea7 100644 --- a/src/widgets/sp-attribute-widget.h +++ b/src/widgets/sp-attribute-widget.h @@ -14,16 +14,11 @@ #ifndef SEEN_DIALOGS_SP_ATTRIBUTE_WIDGET_H #define SEEN_DIALOGS_SP_ATTRIBUTE_WIDGET_H +#include #include #include #include -#define SP_TYPE_ATTRIBUTE_WIDGET (sp_attribute_widget_get_type ()) -#define SP_ATTRIBUTE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_ATTRIBUTE_WIDGET, SPAttributeWidget)) -#define SP_ATTRIBUTE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_ATTRIBUTE_WIDGET, SPAttributeWidgetClass)) -#define SP_IS_ATTRIBUTE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_ATTRIBUTE_WIDGET)) -#define SP_IS_ATTRIBUTE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_ATTRIBUTE_WIDGET)) - #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)) @@ -36,10 +31,6 @@ class Node; } } - -struct SPAttributeWidget; -struct SPAttributeWidgetClass; - struct SPAttributeTable; struct SPAttributeTableClass; @@ -47,35 +38,32 @@ class SPObject; #include -struct SPAttributeWidget { - GtkEntry entry; - guint blocked : 1; - guint hasobj : 1; +class SPAttributeWidget : Gtk::Entry { +//NOTE: SPAttributeWidget does not seem to be used nowhere in Inkscape, conversion to c++ not tested +public: + SPAttributeWidget (); + ~SPAttributeWidget (); + void set_object(SPObject *object, const gchar *attribute); + void set_repr(Inkscape::XML::Node *repr, const gchar *attribute); + Glib::ustring get_attribute(void) {return _attribute;}; + void set_blocked(guint b) {blocked = b;}; + union { SPObject *object; Inkscape::XML::Node *repr; } src; - gchar *attribute; +protected: + void on_changed (void); + +private: + guint blocked; + guint hasobj; + Glib::ustring _attribute; sigc::connection modified_connection; sigc::connection release_connection; }; -struct SPAttributeWidgetClass { - GtkEntryClass entry_class; -}; - -GType sp_attribute_widget_get_type (void); - -GtkWidget *sp_attribute_widget_new (SPObject *object, const gchar *attribute); -GtkWidget *sp_attribute_widget_new_repr (Inkscape::XML::Node *repr, const gchar *attribute); - -void sp_attribute_widget_set_object ( SPAttributeWidget *spw, - SPObject *object, - const gchar *attribute ); -void sp_attribute_widget_set_repr ( SPAttributeWidget *spw, - Inkscape::XML::Node *repr, - const gchar *attribute ); /* SPAttributeTable */ -- cgit v1.2.3 From 7c124c77c3f5db80e46ad23d74dfc92d8f3aa069 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Mon, 12 Dec 2011 00:18:05 +0100 Subject: SPAttributeTable C++ified (bzr r10766.1.3) --- src/dialogs/item-properties.cpp | 20 +- src/dialogs/object-attributes.cpp | 40 ++- src/widgets/sp-attribute-widget.cpp | 551 ++++++++++++++---------------------- src/widgets/sp-attribute-widget.h | 70 ++--- 4 files changed, 278 insertions(+), 403 deletions(-) (limited to 'src') diff --git a/src/dialogs/item-properties.cpp b/src/dialogs/item-properties.cpp index 4ca2b2753..ce8d4e362 100644 --- a/src/dialogs/item-properties.cpp +++ b/src/dialogs/item-properties.cpp @@ -356,13 +356,25 @@ static void sp_item_widget_setup( SPWidget *spw, Inkscape::Selection *selection gtk_container_remove(GTK_CONTAINER(w), int_table); } - const gchar* int_labels[10] = {"onclick", "onmouseover", "onmouseout", "onmousedown", "onmouseup", "onmousemove","onfocusin", "onfocusout", "onactivate", "onload"}; - - int_table = sp_attribute_table_new (obj, 10, int_labels, int_labels); + std::vector int_labels; + std::vector int_attributes; + int_labels.push_back("onclick"); + int_labels.push_back("onmouseover"); + int_labels.push_back("onmouseout"); + int_labels.push_back("onmousedown"); + int_labels.push_back("onmouseup"); + int_labels.push_back("onmousemove"); + int_labels.push_back("onfocusin"); + int_labels.push_back("onfocusout"); + int_labels.push_back("onfocusout"); + int_labels.push_back("onload"); +int_attributes=int_labels; + SPAttributeTable* t = new SPAttributeTable (obj, int_labels, int_attributes, GTK_CONTAINER (w)); + int_table = (GtkWidget*) t->gobj(); gtk_widget_show_all (int_table); g_object_set_data(G_OBJECT(spw), "interactivity_table", int_table); - gtk_container_add (GTK_CONTAINER (w), int_table); +// gtk_container_add (GTK_CONTAINER (w), int_table); } diff --git a/src/dialogs/object-attributes.cpp b/src/dialogs/object-attributes.cpp index f83d3ef1f..bdb292622 100644 --- a/src/dialogs/object-attributes.cpp +++ b/src/dialogs/object-attributes.cpp @@ -72,7 +72,6 @@ static void object_released( SPObject */*object*/, GtkWidget *widget ) } - static void window_destroyed( GtkObject *window, GtkObject */*object*/ ) { sigc::connection *release_connection = (sigc::connection *)g_object_get_data(G_OBJECT(window), "release_connection"); @@ -81,26 +80,16 @@ static void window_destroyed( GtkObject *window, GtkObject */*object*/ ) } - static void sp_object_attr_show_dialog ( SPObject *object, const SPAttrDesc *desc, const gchar *tag ) { - const gchar **labels, **attrs; - gint len, i; + int len; + GtkWidget *w; + SPAttributeTable* t; Glib::ustring title; - GtkWidget *w, *t; - - len = 0; - while (desc[len].label) len += 1; - - labels = (const gchar **) new gchar* [len]; - attrs = (const gchar **) new gchar* [len]; - - for (i = 0; i < len; i++) { - labels[i] = desc[i].label; - attrs[i] = desc[i].attribute; - } + std::vector labels; + std::vector attrs; if (!strcmp (tag, "Link")) { title = _("Link Properties"); @@ -110,17 +99,21 @@ static void sp_object_attr_show_dialog ( SPObject *object, title = Glib::ustring::compose(_("%1 Properties"), tag); } + len = 0; + while (desc[len].label) + { + labels.push_back(desc[len].label); + attrs.push_back (desc[len].attribute); + len += 1; + } + w = sp_window_new (title.c_str(), TRUE); - - t = sp_attribute_table_new (object, len, labels, attrs); - gtk_widget_show (t); - gtk_container_add (GTK_CONTAINER (w), t); - delete labels; - delete attrs; + t = new SPAttributeTable (object, labels, attrs, GTK_CONTAINER (w)); + t->show(); + //gtk_container_add (GTK_CONTAINER (w), (GtkWidget*)t->gobj()); g_signal_connect ( G_OBJECT (w), "destroy", G_CALLBACK (window_destroyed), object ); - sigc::connection *release_connection = new sigc::connection(); *release_connection = object->connectRelease(sigc::bind<1>(sigc::ptr_fun(&object_released), w)); g_object_set_data(G_OBJECT(w), "release_connection", release_connection); @@ -129,7 +122,6 @@ static void sp_object_attr_show_dialog ( SPObject *object, } // end of sp_object_attr_show_dialog() - void sp_object_attributes_dialog (SPObject *object, const gchar *tag) { g_return_if_fail (object != NULL); 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 - * Abhishek Sharma + * Abhishek Sharma + * Kris De Gussem * * 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(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 &labels, std::vector &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 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 &labels, + std::vector &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 &labels, + std::vector &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 attributes = spat->get_attributes(); + std::vector 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 labels; + std::vector 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 attributes = spat->get_attributes(); + std::vector 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 + * Kris De Gussem * * 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 +#include +#include +//#include +//#include #include #include #include - -#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 namespace Inkscape { namespace XML { @@ -33,12 +32,9 @@ class Node; struct SPAttributeTable; struct SPAttributeTableClass; +class SPObject; -class SPObject; - -#include - -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 &labels, std::vector &attributes, GtkContainer* parent); + ~SPAttributeTable (); + void set_object(SPObject *object, std::vector &labels, std::vector &attributes, GtkContainer* parent); + void set_repr(Inkscape::XML::Node *repr, std::vector &labels, std::vector &attributes, GtkContainer* parent); + std::vector get_attributes(void) {return _attributes;}; + std::vector 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 _attributes; + std::vector _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 /* -- cgit v1.2.3 From 75145ce1349a9508b1d3688b215ec334abaefdda Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Fri, 16 Dec 2011 00:39:15 +0100 Subject: - Dropped deprecated sp_window_new - quick and dirty memory leak fix for item properties window (bzr r10766.1.5) --- src/dialogs/item-properties.cpp | 68 +++++++++++++++++-------------------- src/widgets/sp-attribute-widget.cpp | 49 +++++++++++--------------- src/widgets/sp-attribute-widget.h | 11 ++---- 3 files changed, 54 insertions(+), 74 deletions(-) (limited to 'src') diff --git a/src/dialogs/item-properties.cpp b/src/dialogs/item-properties.cpp index ce8d4e362..eec8cce16 100644 --- a/src/dialogs/item-properties.cpp +++ b/src/dialogs/item-properties.cpp @@ -39,6 +39,7 @@ using Inkscape::DocumentUndo; #define MIN_ONSCREEN_DISTANCE 50 static GtkWidget *dlg = NULL; +static SPAttributeTable* attrTable = NULL; static win_data wd; // impossible original values to make sure they are read from prefs @@ -52,16 +53,18 @@ static void sp_item_widget_sensitivity_toggled (GtkWidget *widget, SPWidget *spw static void sp_item_widget_hidden_toggled (GtkWidget *widget, SPWidget *spw); static void sp_item_widget_label_changed (GtkWidget *widget, SPWidget *spw); -static void -sp_item_dialog_destroy( GtkObject */*object*/, gpointer /*data*/ ) +static void sp_item_dialog_destroy( GtkObject */*object*/, gpointer /*data*/ ) { + if (attrTable) + { + delete attrTable; + } sp_signal_disconnect_by_data (INKSCAPE, dlg); wd.win = dlg = NULL; wd.stop = 0; } -static gboolean -sp_item_dialog_delete( GtkObject */*object*/, GdkEvent */*event*/, gpointer /*data*/ ) +static gboolean sp_item_dialog_delete( GtkObject */*object*/, GdkEvent */*event*/, gpointer /*data*/ ) { gtk_window_get_position ((GtkWindow *) dlg, &x, &y); gtk_window_get_size ((GtkWindow *) dlg, &w, &h); @@ -246,8 +249,7 @@ GtkWidget *sp_item_widget_new(void) -static void -sp_item_widget_modify_selection( SPWidget *spw, +static void sp_item_widget_modify_selection( SPWidget *spw, Inkscape::Selection *selection, guint /*flags*/, GtkWidget */*itemw*/ ) @@ -257,8 +259,7 @@ sp_item_widget_modify_selection( SPWidget *spw, -static void -sp_item_widget_change_selection ( SPWidget *spw, +static void sp_item_widget_change_selection ( SPWidget *spw, Inkscape::Selection *selection, GtkWidget */*itemw*/ ) { @@ -352,12 +353,11 @@ static void sp_item_widget_setup( SPWidget *spw, Inkscape::Selection *selection w = GTK_WIDGET(g_object_get_data(G_OBJECT(spw), "interactivity")); GtkWidget* int_table = GTK_WIDGET(g_object_get_data(G_OBJECT(spw), "interactivity_table")); - if (int_table){ - gtk_container_remove(GTK_CONTAINER(w), int_table); - } + //if (int_table){ + // gtk_container_remove(GTK_CONTAINER(w), int_table); + //} std::vector int_labels; - std::vector int_attributes; int_labels.push_back("onclick"); int_labels.push_back("onmouseover"); int_labels.push_back("onmouseout"); @@ -368,14 +368,15 @@ static void sp_item_widget_setup( SPWidget *spw, Inkscape::Selection *selection int_labels.push_back("onfocusout"); int_labels.push_back("onfocusout"); int_labels.push_back("onload"); -int_attributes=int_labels; - SPAttributeTable* t = new SPAttributeTable (obj, int_labels, int_attributes, GTK_CONTAINER (w)); - int_table = (GtkWidget*) t->gobj(); - gtk_widget_show_all (int_table); - g_object_set_data(G_OBJECT(spw), "interactivity_table", int_table); - -// gtk_container_add (GTK_CONTAINER (w), int_table); - + + if (attrTable) + { + delete(attrTable); + } + attrTable = new SPAttributeTable (obj, int_labels, int_labels, (Gtk::Container*) w); + attrTable->show_all(); + g_object_set_data(G_OBJECT(spw), "interactivity_table", (GtkWidget*) attrTable->gobj()); + //gtk_container_add (GTK_CONTAINER (w), int_table); } g_object_set_data (G_OBJECT (spw), "blocked", GUINT_TO_POINTER (FALSE)); @@ -385,8 +386,7 @@ int_attributes=int_labels; -static void -sp_item_widget_sensitivity_toggled (GtkWidget *widget, SPWidget *spw) +static void sp_item_widget_sensitivity_toggled (GtkWidget *widget, SPWidget *spw) { if (g_object_get_data(G_OBJECT (spw), "blocked")) return; @@ -404,8 +404,7 @@ sp_item_widget_sensitivity_toggled (GtkWidget *widget, SPWidget *spw) g_object_set_data (G_OBJECT (spw), "blocked", GUINT_TO_POINTER (FALSE)); } -void -sp_item_widget_hidden_toggled(GtkWidget *widget, SPWidget *spw) +void sp_item_widget_hidden_toggled(GtkWidget *widget, SPWidget *spw) { if (g_object_get_data(G_OBJECT (spw), "blocked")) return; @@ -423,8 +422,7 @@ sp_item_widget_hidden_toggled(GtkWidget *widget, SPWidget *spw) g_object_set_data (G_OBJECT (spw), "blocked", GUINT_TO_POINTER (FALSE)); } -static void -sp_item_widget_label_changed( GtkWidget */*widget*/, SPWidget *spw ) +static void sp_item_widget_label_changed( GtkWidget */*widget*/, SPWidget *spw ) { if (g_object_get_data(G_OBJECT (spw), "blocked")) return; @@ -502,8 +500,9 @@ void sp_item_dialog(void) gchar title[500]; sp_ui_dialog_title_string (Inkscape::Verb::get(SP_VERB_DIALOG_ITEM), title); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - - dlg = sp_window_new (title, TRUE); + + Gtk::Window* window = Inkscape::UI::window_new (title, true); + dlg = (GtkWidget*)window->gobj(); if (x == -1000 || y == -1000) { x = prefs->getInt(prefs_path + "x", -1000); y = prefs->getInt(prefs_path + "y", -1000); @@ -513,9 +512,6 @@ void sp_item_dialog(void) h = prefs->getInt(prefs_path + "h", 0); } -// if (x<0) x=0; -// if (y<0) y=0; - if (w && h) { gtk_window_resize ((GtkWindow *) dlg, w, h); } @@ -525,24 +521,22 @@ void sp_item_dialog(void) gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER); } - sp_transientize (dlg); wd.win = dlg; wd.stop = 0; - g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd); + g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd); g_signal_connect ( G_OBJECT (dlg), "event", G_CALLBACK (sp_dialog_event_handler), dlg); g_signal_connect ( G_OBJECT (dlg), "destroy", G_CALLBACK (sp_item_dialog_destroy), dlg); g_signal_connect ( G_OBJECT (dlg), "delete_event", G_CALLBACK (sp_item_dialog_delete), dlg); - g_signal_connect ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (sp_item_dialog_delete), dlg); - g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg); - g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg); + g_signal_connect ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (sp_item_dialog_delete), dlg); + g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg); + g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg); // Dialog-specific stuff GtkWidget *itemw = sp_item_widget_new (); gtk_widget_show (itemw); gtk_container_add (GTK_CONTAINER (dlg), itemw); - } gtk_window_present ((GtkWindow *) dlg); diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index 8cc521449..1943eef86 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -24,16 +24,16 @@ using Inkscape::DocumentUndo; static void sp_attribute_widget_object_modified ( SPObject *object, guint flags, SPAttributeWidget *spaw ); -static void sp_attribute_widget_object_release ( SPObject *object, - SPAttributeWidget *spaw ); +// static void sp_attribute_widget_object_release ( SPObject *object, + // SPAttributeWidget *spaw ); SPAttributeWidget::SPAttributeWidget () : blocked(0), hasobj(0), _attribute(), - modified_connection(), - release_connection() + modified_connection()//, + // release_connection() { src.object = NULL; } @@ -45,7 +45,7 @@ SPAttributeWidget::~SPAttributeWidget () if (src.object) { modified_connection.disconnect(); - release_connection.disconnect(); + // release_connection.disconnect(); src.object = NULL; } } @@ -63,7 +63,7 @@ void SPAttributeWidget::set_object(SPObject *object, const gchar *attribute) if (hasobj) { if (src.object) { modified_connection.disconnect(); - release_connection.disconnect(); + // release_connection.disconnect(); src.object = NULL; } } else { @@ -82,7 +82,7 @@ void SPAttributeWidget::set_object(SPObject *object, const gchar *attribute) src.object = object; modified_connection = object->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_attribute_widget_object_modified), this)); - release_connection = object->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_attribute_widget_object_release), this)); + // release_connection = object->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_attribute_widget_object_release), this)); _attribute = attribute; @@ -98,7 +98,7 @@ void SPAttributeWidget::set_repr(Inkscape::XML::Node *repr, const gchar *attribu if (hasobj) { if (src.object) { modified_connection.disconnect(); - release_connection.disconnect(); + // release_connection.disconnect(); src.object = NULL; } } else { @@ -177,17 +177,16 @@ static void sp_attribute_widget_object_modified ( SPObject */*object*/, } // end of sp_attribute_widget_object_modified() -static void sp_attribute_widget_object_release ( SPObject */*object*/, - SPAttributeWidget * spaw ) -{ - spaw->set_object (NULL, NULL); -} +//static void sp_attribute_widget_object_release ( SPObject */*object*/, +// SPAttributeWidget * spaw ) +//{ +// spaw->set_object (NULL, NULL); +//} /* SPAttributeTable */ 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 (Gtk::Editable *editable, SPAttributeTable *spat); #define XPAD 4 @@ -199,21 +198,19 @@ SPAttributeTable::SPAttributeTable () : table(0), _attributes(), _entries(), - modified_connection()/*, - release_connection()*/ + modified_connection() { g_message("SPAttributeTable"); src.object = NULL; } -SPAttributeTable::SPAttributeTable (SPObject *object, std::vector &labels, std::vector &attributes, GtkContainer* parent) : +SPAttributeTable::SPAttributeTable (SPObject *object, std::vector &labels, std::vector &attributes, Gtk::Container *parent) : blocked(0), hasobj(0), table(0), _attributes(), _entries(), - modified_connection()/*, - release_connection()*/ + modified_connection() { g_message("SPAttributeTable"); src.object = NULL; @@ -268,7 +265,6 @@ g_message("destroy 3"); if (hasobj) { if (src.object) { modified_connection.disconnect(); - //release_connection.disconnect(); src.object = NULL; } } else { @@ -282,10 +278,10 @@ g_message("destroy 4"); void SPAttributeTable::set_object(SPObject *object, std::vector &labels, std::vector &attributes, - GtkContainer* parent) + Gtk::Container* parent) { g_message("set_object"); - g_return_if_fail (parent); + // 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()); @@ -302,13 +298,12 @@ g_message("2"); src.object = object; 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 */ g_message("3a"); - table = new Gtk::Table (attributes.size(), 2, false); + table = Gtk::manage(new Gtk::Table (attributes.size(), 2, false)); g_message("3b"); - gtk_container_add (parent,(GtkWidget*)table->gobj()); + gtk_container_add (GTK_CONTAINER ((GtkWidget*) parent),(GtkWidget*)table->gobj());// g_message("3c"); /* Fill rows */ @@ -347,8 +342,6 @@ g_message("4b"); table->show (); blocked = false; } - - //set_sensitive ((src.object != NULL) ); g_message("5"); } @@ -410,8 +403,6 @@ g_message("set_repr"); table->show (); blocked = false; } - - //set_sensitive ((src.repr != NULL)); } diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h index aac567987..d108aa827 100644 --- a/src/widgets/sp-attribute-widget.h +++ b/src/widgets/sp-attribute-widget.h @@ -17,8 +17,6 @@ #include #include -//#include -//#include #include #include #include @@ -57,7 +55,7 @@ private: guint hasobj; Glib::ustring _attribute; sigc::connection modified_connection; - sigc::connection release_connection; + //sigc::connection release_connection; }; @@ -66,9 +64,9 @@ private: class SPAttributeTable : public Gtk::Widget { public: SPAttributeTable (); - SPAttributeTable (SPObject *object, std::vector &labels, std::vector &attributes, GtkContainer* parent); + SPAttributeTable (SPObject *object, std::vector &labels, std::vector &attributes, Gtk::Container* parent); ~SPAttributeTable (); - void set_object(SPObject *object, std::vector &labels, std::vector &attributes, GtkContainer* parent); + void set_object(SPObject *object, std::vector &labels, std::vector &attributes, Gtk::Container* parent); void set_repr(Inkscape::XML::Node *repr, std::vector &labels, std::vector &attributes, GtkContainer* parent); std::vector get_attributes(void) {return _attributes;}; std::vector get_entries(void) {return _entries;}; @@ -80,13 +78,10 @@ public: guint hasobj; private: -// GtkVBox vbox; Gtk::Table *table; -// Gtk::Container *_parent; std::vector _attributes; std::vector _entries; sigc::connection modified_connection; - //sigc::connection release_connection; void clear(void); }; -- cgit v1.2.3