From 6343a24c5cd0a998e00ae05fc6abe2081be21c71 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Mon, 3 Oct 2011 00:24:15 -0700 Subject: Doxygen cleanup. (bzr r10660) --- src/dialogs/object-attributes.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/dialogs/object-attributes.cpp') diff --git a/src/dialogs/object-attributes.cpp b/src/dialogs/object-attributes.cpp index 57b295e4e..043454dc8 100644 --- a/src/dialogs/object-attributes.cpp +++ b/src/dialogs/object-attributes.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Generic properties editor +/** + * @file + * Generic properties editor. */ /* Authors: * Lauris Kaplinski -- cgit v1.2.3 From 2608034f3607bfacf354151097c28be36b6c0a8c Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sun, 4 Dec 2011 22:03:12 +0100 Subject: cppcheck - dropped unused variable - changed use of obsolute function 'alloca' (see http://stackoverflow.com/questions/1018853/why-is-alloca-not-considered-good-practice and http://linux.die.net/man/3/alloca). (bzr r10760) --- src/dialogs/object-attributes.cpp | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'src/dialogs/object-attributes.cpp') diff --git a/src/dialogs/object-attributes.cpp b/src/dialogs/object-attributes.cpp index 043454dc8..f83d3ef1f 100644 --- a/src/dialogs/object-attributes.cpp +++ b/src/dialogs/object-attributes.cpp @@ -66,16 +66,14 @@ static const SPAttrDesc image_nohref_desc[] = { }; -static void -object_released( SPObject */*object*/, GtkWidget *widget ) +static void object_released( SPObject */*object*/, GtkWidget *widget ) { gtk_widget_destroy (widget); } -static void -window_destroyed( GtkObject *window, GtkObject */*object*/ ) +static void window_destroyed( GtkObject *window, GtkObject */*object*/ ) { sigc::connection *release_connection = (sigc::connection *)g_object_get_data(G_OBJECT(window), "release_connection"); release_connection->disconnect(); @@ -84,21 +82,20 @@ window_destroyed( GtkObject *window, GtkObject */*object*/ ) -static void -sp_object_attr_show_dialog ( SPObject *object, +static void sp_object_attr_show_dialog ( SPObject *object, const SPAttrDesc *desc, const gchar *tag ) { const gchar **labels, **attrs; gint len, i; - gchar *title; + Glib::ustring title; GtkWidget *w, *t; len = 0; while (desc[len].label) len += 1; - labels = (const gchar **)alloca (len * sizeof (char *)); - attrs = (const gchar **)alloca (len * sizeof (char *)); + labels = (const gchar **) new gchar* [len]; + attrs = (const gchar **) new gchar* [len]; for (i = 0; i < len; i++) { labels[i] = desc[i].label; @@ -106,19 +103,20 @@ sp_object_attr_show_dialog ( SPObject *object, } if (!strcmp (tag, "Link")) { - title = g_strdup_printf (_("Link Properties")); + title = _("Link Properties"); } else if (!strcmp (tag, "Image")) { - title = g_strdup_printf (_("Image Properties")); + title = _("Image Properties"); } else { - title = g_strdup_printf (_("%s Properties"), tag); + title = Glib::ustring::compose(_("%1 Properties"), tag); } - w = sp_window_new (title, TRUE); - g_free (title); + 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; g_signal_connect ( G_OBJECT (w), "destroy", G_CALLBACK (window_destroyed), object ); @@ -128,13 +126,11 @@ sp_object_attr_show_dialog ( SPObject *object, g_object_set_data(G_OBJECT(w), "release_connection", release_connection); gtk_widget_show (w); - } // end of sp_object_attr_show_dialog() -void -sp_object_attributes_dialog (SPObject *object, const gchar *tag) +void sp_object_attributes_dialog (SPObject *object, const gchar *tag) { g_return_if_fail (object != NULL); g_return_if_fail (SP_IS_OBJECT (object)); -- 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/object-attributes.cpp | 40 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 24 deletions(-) (limited to 'src/dialogs/object-attributes.cpp') 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); -- cgit v1.2.3