summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Smith <john.smith7545@yahoo.com>2012-08-07 08:45:50 +0000
committerJohn Smith <john.smith7545@yahoo.com>2012-08-07 08:45:50 +0000
commitd2e06a8ebec38b7819efc7dacccd720b477aaadc (patch)
tree26f27a72083fcc5bd619be07e7f466b0c078d48c
parentUse Gtk::StyleContext in OCAL dialog (diff)
downloadinkscape-d2e06a8ebec38b7819efc7dacccd720b477aaadc.tar.gz
inkscape-d2e06a8ebec38b7819efc7dacccd720b477aaadc.zip
Fix for 427514 : Filter effects dialog data mirroring
(bzr r11596)
-rw-r--r--src/ui/dialog/filter-effects-dialog.cpp74
-rw-r--r--src/ui/dialog/filter-effects-dialog.h24
-rw-r--r--src/ui/dialog/livepatheffect-editor.cpp4
-rw-r--r--src/ui/dialog/livepatheffect-editor.h12
4 files changed, 80 insertions, 34 deletions
diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp
index fe68feca8..317cb2773 100644
--- a/src/ui/dialog/filter-effects-dialog.cpp
+++ b/src/ui/dialog/filter-effects-dialog.cpp
@@ -1108,7 +1108,11 @@ Glib::RefPtr<Gtk::Menu> create_popup_menu(Gtk::Widget& parent, sigc::slot<void>
/*** FilterModifier ***/
FilterEffectsDialog::FilterModifier::FilterModifier(FilterEffectsDialog& d)
- : _dialog(d), _add(Gtk::Stock::NEW), _observer(new Inkscape::XML::SignalObserver)
+ : _desktop(NULL),
+ _deskTrack(),
+ _dialog(d),
+ _add(Gtk::Stock::NEW),
+ _observer(new Inkscape::XML::SignalObserver)
{
Gtk::ScrolledWindow* sw = Gtk::manage(new Gtk::ScrolledWindow);
pack_start(*sw);
@@ -1149,54 +1153,60 @@ FilterEffectsDialog::FilterModifier::FilterModifier(FilterEffectsDialog& d)
_list.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &FilterModifier::on_filter_selection_changed));
_observer->signal_changed().connect(signal_filter_changed().make_slot());
- g_signal_connect(G_OBJECT(INKSCAPE), "change_selection",
- G_CALLBACK(&FilterModifier::on_inkscape_change_selection), this);
- g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop",
- G_CALLBACK(&FilterModifier::on_activate_desktop), this);
- g_signal_connect(G_OBJECT(INKSCAPE), "deactivate_desktop",
- G_CALLBACK(&FilterModifier::on_deactivate_desktop), this);
+ desktopChangeConn = _deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &FilterModifier::setTargetDesktop) );
+ _deskTrack.connect(GTK_WIDGET(gobj()));
- on_activate_desktop(INKSCAPE, d.getDesktop(), this);
update_filters();
}
FilterEffectsDialog::FilterModifier::~FilterModifier()
{
+ _selectChangedConn.disconnect();
+ _selectModifiedConn.disconnect();
_resource_changed.disconnect();
_doc_replaced.disconnect();
}
-void FilterEffectsDialog::FilterModifier::on_activate_desktop(Application*, SPDesktop* desktop, FilterModifier* me)
+void FilterEffectsDialog::FilterModifier::setTargetDesktop(SPDesktop *desktop)
{
- me->_doc_replaced.disconnect();
- me->_doc_replaced = desktop->connectDocumentReplaced(
- sigc::mem_fun(me, &FilterModifier::on_document_replaced));
-
- me->_resource_changed.disconnect();
- me->_resource_changed =
- sp_desktop_document(desktop)->connectResourcesChanged("filter",sigc::mem_fun(me, &FilterModifier::update_filters));
-
- me->_dialog.setDesktop(desktop);
+ if (_desktop != desktop) {
+ if (_desktop) {
+ _selectChangedConn.disconnect();
+ _selectModifiedConn.disconnect();
+ _doc_replaced.disconnect();
+ _resource_changed.disconnect();
+ _dialog.setDesktop(NULL);
+ }
+ _desktop = desktop;
+ if (desktop) {
+ if (desktop->selection) {
+ _selectChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &FilterModifier::on_change_selection)));
+ _selectModifiedConn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &FilterModifier::on_modified_selection)));
+ }
+ _doc_replaced = desktop->connectDocumentReplaced( sigc::mem_fun(*this, &FilterModifier::on_document_replaced));
+ _resource_changed = sp_desktop_document(desktop)->connectResourcesChanged("filter",sigc::mem_fun(*this, &FilterModifier::update_filters));
+ _dialog.setDesktop(desktop);
- me->update_filters();
+ update_filters();
+ }
+ }
}
-void FilterEffectsDialog::FilterModifier::on_deactivate_desktop(Application*, SPDesktop* /*desktop*/, FilterModifier* me)
+// When the selection changes, show the active filter(s) in the dialog
+void FilterEffectsDialog::FilterModifier::on_change_selection()
{
- me->_doc_replaced.disconnect();
- me->_resource_changed.disconnect();
- me->_dialog.setDesktop(NULL);
+ Inkscape::Selection *selection = sp_desktop_selection (SP_ACTIVE_DESKTOP);
+ update_selection(selection);
}
-
-// When the selection changes, show the active filter(s) in the dialog
-void FilterEffectsDialog::FilterModifier::on_inkscape_change_selection(Application */*inkscape*/,
- Selection *sel,
- FilterModifier* fm)
+void FilterEffectsDialog::FilterModifier::on_modified_selection( guint flags )
{
- if(fm && sel)
- fm->update_selection(sel);
+ if (flags & ( SP_OBJECT_MODIFIED_FLAG |
+ SP_OBJECT_PARENT_MODIFIED_FLAG |
+ SP_OBJECT_STYLE_MODIFIED_FLAG) ) {
+ on_change_selection();
+ }
}
// Update each filter's sel property based on the current object selection;
@@ -1205,6 +1215,10 @@ void FilterEffectsDialog::FilterModifier::on_inkscape_change_selection(Applicati
// If only one filter is in use, it is selected
void FilterEffectsDialog::FilterModifier::update_selection(Selection *sel)
{
+ if (!sel) {
+ return;
+ }
+
std::set<SPObject*> used;
for (GSList const *i = sel->itemList(); i != NULL; i = i->next) {
diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h
index 4e75860a5..38811354e 100644
--- a/src/ui/dialog/filter-effects-dialog.h
+++ b/src/ui/dialog/filter-effects-dialog.h
@@ -21,6 +21,7 @@
#include "ui/widget/combo-enums.h"
#include "ui/widget/spin-slider.h"
#include "xml/helper-observer.h"
+#include "ui/dialog/desktop-tracker.h"
#include <gtkmm/notebook.h>
#include <gtkmm/sizegroup.h>
@@ -74,14 +75,15 @@ private:
Gtk::TreeModelColumn<int> sel;
};
- static void on_activate_desktop(Application*, SPDesktop*, FilterModifier*);
- static void on_deactivate_desktop(Application*, SPDesktop*, FilterModifier*);
+ void setTargetDesktop(SPDesktop *desktop);
+
void on_document_replaced(SPDesktop*, SPDocument*)
{
update_filters();
}
- static void on_inkscape_change_selection(Application *, Selection *, FilterModifier*);
+ void on_change_selection();
+ void on_modified_selection( guint flags );
void update_selection(Selection *);
void on_filter_selection_changed();
@@ -96,6 +98,22 @@ private:
void duplicate_filter();
void rename_filter();
+ /**
+ * Stores the current desktop.
+ */
+ SPDesktop *_desktop;
+
+ /**
+ * Auxiliary widget to keep track of desktop changes for the floating dialog.
+ */
+ DesktopTracker _deskTrack;
+
+ /**
+ * Link to callback function for a change in desktop (window).
+ */
+ sigc::connection desktopChangeConn;
+ sigc::connection _selectChangedConn;
+ sigc::connection _selectModifiedConn;
sigc::connection _doc_replaced;
sigc::connection _resource_changed;
diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp
index ba7ece901..7ecb6d5cd 100644
--- a/src/ui/dialog/livepatheffect-editor.cpp
+++ b/src/ui/dialog/livepatheffect-editor.cpp
@@ -80,6 +80,7 @@ static void lpeeditor_selection_modified (Inkscape::Selection * selection, guint
LivePathEffectEditor::LivePathEffectEditor()
: UI::Widget::Panel("", "/dialogs/livepatheffect", SP_VERB_DIALOG_LIVE_PATH_EFFECT),
+ deskTrack(),
lpe_list_locked(false),
effectwidget(NULL),
status_label("", Gtk::ALIGN_CENTER),
@@ -174,6 +175,9 @@ LivePathEffectEditor::LivePathEffectEditor()
button_up.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onUp));
button_down.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onDown));
+ desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &LivePathEffectEditor::setDesktop) );
+ deskTrack.connect(GTK_WIDGET(gobj()));
+
show_all_children();
}
diff --git a/src/ui/dialog/livepatheffect-editor.h b/src/ui/dialog/livepatheffect-editor.h
index 20b0a673d..4aac25eaa 100644
--- a/src/ui/dialog/livepatheffect-editor.h
+++ b/src/ui/dialog/livepatheffect-editor.h
@@ -23,7 +23,7 @@
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/toolbar.h>
#include <gtkmm/buttonbox.h>
-
+#include "ui/dialog/desktop-tracker.h"
class SPDesktop;
class SPLPEItem;
@@ -50,6 +50,16 @@ public:
void setDesktop(SPDesktop *desktop);
private:
+
+ /**
+ * Auxiliary widget to keep track of desktop changes for the floating dialog.
+ */
+ DesktopTracker deskTrack;
+
+ /**
+ * Link to callback function for a change in desktop (window).
+ */
+ sigc::connection desktopChangeConn;
sigc::connection selection_changed_connection;
sigc::connection selection_modified_connection;