summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKris De Gussem <kris.degussem@gmail.com>2012-01-01 12:18:42 +0000
committerKris <Kris.De.Gussem@hotmail.com>2012-01-01 12:18:42 +0000
commit0b983c4b758727e27347abf67467883f40741aa0 (patch)
treefe991bcf42ea02efda23a77e8c243bc850651285 /src
parentAdded signal for desktop destruction to allow for proper removal of tracked s... (diff)
downloadinkscape-0b983c4b758727e27347abf67467883f40741aa0.tar.gz
inkscape-0b983c4b758727e27347abf67467883f40741aa0.zip
Item and image properties dialog update: restoring correct behaviour in case of deleting an object
(bzr r10815)
Diffstat (limited to 'src')
-rw-r--r--src/dialogs/item-properties.cpp11
-rw-r--r--src/dialogs/object-attributes.cpp26
-rw-r--r--src/widgets/sp-attribute-widget.cpp40
-rw-r--r--src/widgets/sp-attribute-widget.h12
4 files changed, 66 insertions, 23 deletions
diff --git a/src/dialogs/item-properties.cpp b/src/dialogs/item-properties.cpp
index 1101f9eec..16c29a69f 100644
--- a/src/dialogs/item-properties.cpp
+++ b/src/dialogs/item-properties.cpp
@@ -142,7 +142,7 @@ SPItemDialog::SPItemDialog (void) :
wd.stop = 0;
//set callback for the new dialog
- g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), dlg);
+ 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_delete), dlg);
g_signal_connect ( G_OBJECT (dlg), "delete_event", G_CALLBACK (sp_item_dialog_delete), dlg);
@@ -186,6 +186,7 @@ SPItemDialog::~SPItemDialog (void)
prefs->setInt(prefs_path + "h", h);
sp_signal_disconnect_by_data (INKSCAPE, wd.win);
+ sp_signal_disconnect_by_data (INKSCAPE, &wd);
if (window)
{
//should actually always be true, but for safety check
@@ -318,10 +319,14 @@ void SPItemDialog::widget_setup(void)
Inkscape::Selection *selection = sp_desktop_selection (SP_ACTIVE_DESKTOP);
if (!selection->singleItem()) {
- set_sensitive (false);
+ vb.set_sensitive (false);
+ CurrentItem = NULL;
+ //no selection anymore or multiple objects selected, means that we need
+ //to close the connections to the previously selected object
+ attrTable.clear();
return;
} else {
- set_sensitive (true);
+ vb.set_sensitive (true);
}
SPItem *item = selection->singleItem();
diff --git a/src/dialogs/object-attributes.cpp b/src/dialogs/object-attributes.cpp
index b4b2fe256..808e9a16a 100644
--- a/src/dialogs/object-attributes.cpp
+++ b/src/dialogs/object-attributes.cpp
@@ -66,6 +66,19 @@ static const SPAttrDesc image_nohref_desc[] = {
{ NULL, NULL}
};
+static void object_released( SPObject */*object*/, GtkWidget *widget )
+{
+ gtk_widget_destroy (widget);
+}
+
+
+
+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();
+ delete release_connection;
+}
static void sp_object_attr_show_dialog ( SPObject *object,
const SPAttrDesc *desc,
@@ -95,8 +108,17 @@ static void sp_object_attr_show_dialog ( SPObject *object,
}
window = Inkscape::UI::window_new (title.c_str(), true);
- t = new SPAttributeTable (object, labels, attrs, NULL);
- window->show_all();
+ t = new SPAttributeTable (object, labels, attrs, (GtkWidget*)window->gobj());
+
+ g_signal_connect (window->gobj(), "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), (GtkWidget*)window->gobj()));
+ g_object_set_data((GObject*)window->gobj(), "release_connection", release_connection);
+
+ t->show();
+ window->show();
} // end of sp_object_attr_show_dialog()
diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp
index 09548f250..529fccffd 100644
--- a/src/widgets/sp-attribute-widget.cpp
+++ b/src/widgets/sp-attribute-widget.cpp
@@ -22,8 +22,9 @@
using Inkscape::DocumentUndo;
-static void sp_attribute_table_object_modified (SPObject *object, guint flags, SPAttributeTable *spaw);
static void sp_attribute_table_entry_changed (Gtk::Editable *editable, SPAttributeTable *spat);
+static void sp_attribute_table_object_modified (SPObject *object, guint flags, SPAttributeTable *spaw);
+static void sp_attribute_table_object_release (SPObject */*object*/, SPAttributeTable *spat);
#define XPAD 4
#define YPAD 0
@@ -34,22 +35,24 @@ SPAttributeTable::SPAttributeTable () :
table(0),
_attributes(),
_entries(),
- modified_connection()
+ modified_connection(),
+ release_connection()
{
src.object = NULL;
}
-SPAttributeTable::SPAttributeTable (SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkWidget* ExpanderContainer) :
+SPAttributeTable::SPAttributeTable (SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkWidget* parent) :
blocked(0),
hasobj(0),
table(0),
_attributes(),
_entries(),
- modified_connection()
+ modified_connection(),
+ release_connection()
{
src.object = NULL;
src.repr = NULL;
- set_object(object, labels, attributes, ExpanderContainer);
+ set_object(object, labels, attributes, parent);
}
SPAttributeTable::~SPAttributeTable ()
@@ -91,6 +94,7 @@ void SPAttributeTable::clear(void)
if (hasobj) {
if (src.object) {
modified_connection.disconnect();
+ release_connection.disconnect();
src.object = NULL;
}
} else {
@@ -103,7 +107,7 @@ void SPAttributeTable::clear(void)
void SPAttributeTable::set_object(SPObject *object,
std::vector<Glib::ustring> &labels,
std::vector<Glib::ustring> &attributes,
- GtkWidget* ExpanderContainer)
+ GtkWidget* parent)
{
g_return_if_fail (!object || SP_IS_OBJECT (object));
g_return_if_fail (!object || !labels.empty() || !attributes.empty());
@@ -111,19 +115,20 @@ void SPAttributeTable::set_object(SPObject *object,
clear();
hasobj = true;
+ src.object = object;
if (object) {
blocked = true;
// Set up object
- 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
table = new Gtk::Table (attributes.size(), 2, false);
- if (!(ExpanderContainer == NULL))
+ if (!(parent == NULL))
{
- gtk_container_add (GTK_CONTAINER (ExpanderContainer),(GtkWidget*)table->gobj());
+ gtk_container_add (GTK_CONTAINER (parent),(GtkWidget*)table->gobj());
}
// Fill rows
@@ -167,6 +172,7 @@ void SPAttributeTable::change_object(SPObject *object)
if (hasobj) {
if (src.object) {
modified_connection.disconnect();
+ release_connection.disconnect();
src.object = NULL;
}
} else {
@@ -176,13 +182,14 @@ void SPAttributeTable::change_object(SPObject *object)
}
hasobj = true;
+ src.object = object;
if (object) {
blocked = true;
// Set up object
- 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));
Gtk::Entry *ee;
Gtk::Widget *w;
const gchar *val;
@@ -199,7 +206,7 @@ void SPAttributeTable::change_object(SPObject *object)
/*void SPAttributeTable::set_repr (Inkscape::XML::Node *repr,
std::vector<Glib::ustring> &labels,
std::vector<Glib::ustring> &attributes,
- GtkWidget* ExpanderContainer)
+ GtkWidget* parent)
{
g_return_if_fail (!labels.empty() || !attributes.empty());
g_return_if_fail (labels.size() == attributes.size());
@@ -216,9 +223,9 @@ void SPAttributeTable::change_object(SPObject *object)
// Create table
table = new Gtk::Table (attributes.size(), 2, false);
- if (!(ExpanderContainer == NULL))
+ if (!(parent == NULL))
{
- gtk_container_add (GTK_CONTAINER (ExpanderContainer),(GtkWidget*)table->gobj());
+ gtk_container_add (GTK_CONTAINER (parent),(GtkWidget*)table->gobj());
}
// Fill rows
@@ -320,6 +327,13 @@ static void sp_attribute_table_entry_changed ( Gtk::Editable *editable,
} // end of sp_attribute_table_entry_changed()
+static void sp_attribute_table_object_release (SPObject */*object*/, SPAttributeTable *spat)
+{
+ std::vector<Glib::ustring> labels;
+ std::vector<Glib::ustring> attributes;
+ spat->set_object (NULL, labels, attributes, NULL);
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h
index bfa26e4f2..58be48fbd 100644
--- a/src/widgets/sp-attribute-widget.h
+++ b/src/widgets/sp-attribute-widget.h
@@ -34,11 +34,14 @@ class SPObject;
class SPAttributeTable : public Gtk::Widget {
public:
SPAttributeTable ();
- SPAttributeTable (SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkWidget* ExpanderContainer);
+ SPAttributeTable (SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkWidget* parent);
~SPAttributeTable ();
- void set_object(SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkWidget* ExpanderContainer);
+
+ void set_object(SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkWidget* parent);
void change_object(SPObject *object);
- // void set_repr(Inkscape::XML::Node *repr, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkWidget* ExpanderContainer);
+ // void set_repr(Inkscape::XML::Node *repr, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkWidget* parent);
+ void clear(void);
+
std::vector<Glib::ustring> get_attributes(void) {return _attributes;};
std::vector<Gtk::Entry *> get_entries(void) {return _entries;};
union {
@@ -53,8 +56,7 @@ private:
std::vector<Glib::ustring> _attributes;
std::vector<Gtk::Entry *> _entries;
sigc::connection modified_connection;
-
- void clear(void);
+ sigc::connection release_connection;
};
#endif