From: nicholasbishop Date: Wed, 8 Aug 2007 06:53:46 +0000 (+0000) Subject: Filter effects dialog: X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9496d940d814b037c16b03e111bd238e57684125;p=inkscape.git Filter effects dialog: * Removed the FilterEffectChooser base class, no longer used --- diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 903701cf5..af413bc0e 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -32,6 +32,7 @@ #include "document.h" #include "filter-chemistry.h" #include "filter-effects-dialog.h" +#include "filter-enums.h" #include "inkscape.h" #include "selection.h" #include "sp-feblend.h" @@ -798,6 +799,7 @@ FilterEffectsDialog::FilterModifier::FilterModifier(FilterEffectsDialog& d) pack_start(_add, false, false); sw->add(_list); + _model = Gtk::ListStore::create(_columns); _list.set_model(_model); const int selcol = _list.append_column("", _cell_sel); Gtk::TreeViewColumn* col = _list.get_column(selcol - 1); @@ -824,20 +826,25 @@ FilterEffectsDialog::FilterModifier::FilterModifier(FilterEffectsDialog& d) 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); + + on_activate_desktop(INKSCAPE, SP_ACTIVE_DESKTOP, this); update_filters(); } +FilterEffectsDialog::FilterModifier::~FilterModifier() +{ + _resource_changed.disconnect(); + _doc_replaced.disconnect(); +} + FilterEffectsDialog::FilterModifier::CellRendererSel::CellRendererSel() : Glib::ObjectBase(typeid(CellRendererSel)), _size(10), _sel(*this, "sel", 0) {} -Glib::PropertyProxy FilterEffectsDialog::FilterModifier::CellRendererSel::property_sel() -{ - return _sel.get_proxy(); -} - void FilterEffectsDialog::FilterModifier::CellRendererSel::get_size_vfunc( Gtk::Widget&, const Gdk::Rectangle*, int* x, int* y, int* w, int* h) const { @@ -868,6 +875,21 @@ void FilterEffectsDialog::FilterModifier::CellRendererSel::render_vfunc( } } +void FilterEffectsDialog::FilterModifier::on_activate_desktop(Application*, SPDesktop* desktop, FilterModifier* me) +{ + me->update_filters(); + + 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_document_resources_changed_connect(sp_desktop_document(desktop), "filter", + sigc::mem_fun(me, &FilterModifier::update_filters)); +} + + // When the selection changes, show the active filter(s) in the dialog void FilterEffectsDialog::FilterModifier::on_inkscape_change_selection(Application *inkscape, Selection *sel, @@ -913,9 +935,24 @@ void FilterEffectsDialog::FilterModifier::on_filter_selection_changed() signal_filter_changed()(); } -sigc::signal& FilterEffectsDialog::FilterModifier::signal_filter_changed() +/* Add all filters in the document to the combobox. + Keeps the same selection if possible, otherwise selects the first element */ +void FilterEffectsDialog::FilterModifier::update_filters() { - return _signal_filter_changed; + SPDesktop* desktop = SP_ACTIVE_DESKTOP; + SPDocument* document = sp_desktop_document(desktop); + const GSList* filters = sp_document_get_resource_list(document, "filter"); + + _model->clear(); + + for(const GSList *l = filters; l; l = l->next) { + Gtk::TreeModel::Row row = *_model->append(); + SPFilter* f = (SPFilter*)l->data; + row[_columns.filter] = f; + const gchar* lbl = f->label(); + const gchar* id = SP_OBJECT_ID(f); + row[_columns.label] = lbl ? lbl : (id ? id : "filter"); + } } SPFilter* FilterEffectsDialog::FilterModifier::get_selected_filter() diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index 4fdd6f957..95dafaff2 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -27,7 +27,7 @@ #include "attributes.h" #include "dialog.h" #include "sp-filter.h" -#include "ui/widget/filter-effect-chooser.h" +#include "ui/widget/combo-enums.h" #include "ui/widget/spin-slider.h" using namespace Inkscape::UI::Widget; @@ -48,20 +48,44 @@ public: private: class SignalObserver; - class FilterModifier : public Gtk::VBox, public FilterEffectChooser + class FilterModifier : public Gtk::VBox { public: FilterModifier(FilterEffectsDialog&); + ~FilterModifier(); - virtual SPFilter* get_selected_filter(); - virtual void select_filter(const SPFilter*); - sigc::signal& signal_filter_changed(); + SPFilter* get_selected_filter(); + void select_filter(const SPFilter*); + + sigc::signal& signal_filter_changed() + { + return _signal_filter_changed; + } private: + class Columns : public Gtk::TreeModel::ColumnRecord + { + public: + Columns() + { + add(filter); + add(label); + add(sel); + } + + Gtk::TreeModelColumn filter; + Gtk::TreeModelColumn label; + Gtk::TreeModelColumn sel; + }; + class CellRendererSel : public Gtk::CellRenderer { public: CellRendererSel(); - Glib::PropertyProxy property_sel(); + + Glib::PropertyProxy property_sel() + { + return _sel.get_proxy(); + } protected: virtual void get_size_vfunc(Gtk::Widget&, const Gdk::Rectangle*, int*, int*, int*, int*) const; @@ -72,11 +96,19 @@ private: const int _size; Glib::Property _sel; }; - + + static void on_activate_desktop(Application*, SPDesktop*, FilterModifier*); + void on_document_replaced(SPDesktop*, SPDocument*) + { + update_filters(); + } + static void on_inkscape_change_selection(Application *, Selection *, FilterModifier*); + void update_selection(Selection *); void on_filter_selection_changed(); + void update_filters(); void filter_list_button_press(GdkEventButton*); void filter_list_button_release(GdkEventButton*); void add_filter(); @@ -84,8 +116,13 @@ private: void duplicate_filter(); void rename_filter(); + sigc::connection _doc_replaced; + sigc::connection _resource_changed; + FilterEffectsDialog& _dialog; Gtk::TreeView _list; + Glib::RefPtr _model; + Columns _columns; CellRendererSel _cell_sel; Gtk::Button _add; Glib::RefPtr _menu; diff --git a/src/ui/widget/filter-effect-chooser.cpp b/src/ui/widget/filter-effect-chooser.cpp index bf71c33d1..f8aee43f0 100644 --- a/src/ui/widget/filter-effect-chooser.cpp +++ b/src/ui/widget/filter-effect-chooser.cpp @@ -16,68 +16,11 @@ #include "document.h" #include "filter-effect-chooser.h" #include "inkscape.h" -#include "ui/dialog/dialog-manager.h" namespace Inkscape { namespace UI { namespace Widget { -FilterEffectChooser::FilterEffectChooser() -{ - _model = Gtk::ListStore::create(_columns); - - g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", - G_CALLBACK(&FilterEffectChooser::on_activate_desktop), this); - - - on_activate_desktop(INKSCAPE, SP_ACTIVE_DESKTOP, this); -} - -FilterEffectChooser::~FilterEffectChooser() -{ - _resource_changed.disconnect(); - _doc_replaced.disconnect(); -} - -void FilterEffectChooser::on_activate_desktop(Inkscape::Application*, SPDesktop* desktop, FilterEffectChooser* fec) -{ - fec->update_filters(); - - fec->_doc_replaced.disconnect(); - fec->_doc_replaced = desktop->connectDocumentReplaced( - sigc::mem_fun(fec, &FilterEffectChooser::on_document_replaced)); - - fec->_resource_changed.disconnect(); - fec->_resource_changed = - sp_document_resources_changed_connect(sp_desktop_document(desktop), "filter", - sigc::mem_fun(fec, &FilterEffectChooser::update_filters)); -} - -void FilterEffectChooser::on_document_replaced(SPDesktop* desktop, SPDocument* document) -{ - update_filters(); -} - -/* Add all filters in the document to the combobox. - Keeps the same selection if possible, otherwise selects the first element */ -void FilterEffectChooser::update_filters() -{ - SPDesktop* desktop = SP_ACTIVE_DESKTOP; - SPDocument* document = sp_desktop_document(desktop); - const GSList* filters = sp_document_get_resource_list(document, "filter"); - - _model->clear(); - - for(const GSList *l = filters; l; l = l->next) { - Gtk::TreeModel::Row row = *_model->append(); - SPFilter* f = (SPFilter*)l->data; - row[_columns.filter] = f; - const gchar* lbl = f->label(); - const gchar* id = SP_OBJECT_ID(f); - row[_columns.label] = lbl ? lbl : (id ? id : "filter"); - } -} - SimpleFilterModifier::SimpleFilterModifier() : _lb_blend(_("_Blend mode:")), _lb_blur(_("B_lur:"), Gtk::ALIGN_LEFT), diff --git a/src/ui/widget/filter-effect-chooser.h b/src/ui/widget/filter-effect-chooser.h index 673118ac3..f0d6f324d 100644 --- a/src/ui/widget/filter-effect-chooser.h +++ b/src/ui/widget/filter-effect-chooser.h @@ -27,43 +27,6 @@ namespace Inkscape { namespace UI { namespace Widget { -class FilterEffectChooser -{ -public: - virtual ~FilterEffectChooser(); - -protected: - FilterEffectChooser(); - - class Columns : public Gtk::TreeModel::ColumnRecord - { - public: - Columns() - { - add(filter); - add(label); - add(sel); - } - - Gtk::TreeModelColumn filter; - Gtk::TreeModelColumn label; - Gtk::TreeModelColumn sel; - }; - - virtual void update_filters(); - - Glib::RefPtr _model; - Columns _columns; -private: - static void on_activate_desktop(Inkscape::Application*, SPDesktop*, FilterEffectChooser*); - void on_document_replaced(SPDesktop*, SPDocument*); - - sigc::connection _doc_replaced; - sigc::connection _resource_changed; - - Gtk::TreeView::Column _filter_column; -}; - /* Allows basic control over feBlend and feGaussianBlur effects, with an option to use the full filter effect controls. */ class SimpleFilterModifier : public Gtk::VBox