summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKris De Gussem <kris.degussem@gmail.com>2011-12-15 23:39:15 +0000
committerKris <Kris.De.Gussem@hotmail.com>2011-12-15 23:39:15 +0000
commit75145ce1349a9508b1d3688b215ec334abaefdda (patch)
treee6c31142d0318979d0c666a3a47adc7656c1f5ee /src
parentcredits update (diff)
downloadinkscape-75145ce1349a9508b1d3688b215ec334abaefdda.tar.gz
inkscape-75145ce1349a9508b1d3688b215ec334abaefdda.zip
- Dropped deprecated sp_window_new
- quick and dirty memory leak fix for item properties window (bzr r10766.1.5)
Diffstat (limited to 'src')
-rw-r--r--src/dialogs/item-properties.cpp68
-rw-r--r--src/widgets/sp-attribute-widget.cpp49
-rw-r--r--src/widgets/sp-attribute-widget.h11
3 files changed, 54 insertions, 74 deletions
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<Glib::ustring> int_labels;
- std::vector<Glib::ustring> 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<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkContainer* parent) :
+SPAttributeTable::SPAttributeTable (SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &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<Glib::ustring> &labels,
std::vector<Glib::ustring> &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 <gtk/gtk.h>
#include <gtkmm.h>
-//#include <gtkmm/entry.h>
-//#include <gtkmm/table.h>
#include <glib.h>
#include <stddef.h>
#include <sigc++/connection.h>
@@ -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<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkContainer* parent);
+ SPAttributeTable (SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, Gtk::Container* parent);
~SPAttributeTable ();
- void set_object(SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkContainer* parent);
+ void set_object(SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, Gtk::Container* 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;};
@@ -80,13 +78,10 @@ public:
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;
void clear(void);
};