Code

Filter effects dialog:
authornicholasbishop <nicholasbishop@users.sourceforge.net>
Wed, 8 Aug 2007 06:53:46 +0000 (06:53 +0000)
committernicholasbishop <nicholasbishop@users.sourceforge.net>
Wed, 8 Aug 2007 06:53:46 +0000 (06:53 +0000)
* Removed the FilterEffectChooser base class, no longer used

src/ui/dialog/filter-effects-dialog.cpp
src/ui/dialog/filter-effects-dialog.h
src/ui/widget/filter-effect-chooser.cpp
src/ui/widget/filter-effect-chooser.h

index 903701cf59ca8cbd6759c80db9802f803f8f4cea..af413bc0ebfd9197f01af3e731052e594c51fb1d 100644 (file)
@@ -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<int> 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<void>& 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()
index 4fdd6f957a1d121f43c516756097a5d8d8c917c8..95dafaff244ae24df79ce3abc69cbf4cdf8933dc 100644 (file)
@@ -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<void>& signal_filter_changed();
+        SPFilter* get_selected_filter();
+        void select_filter(const SPFilter*);
+
+        sigc::signal<void>& signal_filter_changed()
+        {
+            return _signal_filter_changed;
+        }
     private:
+        class Columns : public Gtk::TreeModel::ColumnRecord
+        {
+        public:
+            Columns()
+            {
+                add(filter);
+                add(label);
+                add(sel);
+            }
+
+            Gtk::TreeModelColumn<SPFilter*> filter;
+            Gtk::TreeModelColumn<Glib::ustring> label;
+            Gtk::TreeModelColumn<int> sel;
+        };
+
         class CellRendererSel : public Gtk::CellRenderer
         {
         public:
             CellRendererSel();
-            Glib::PropertyProxy<int> property_sel();
+
+            Glib::PropertyProxy<int> 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<int> _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<Gtk::ListStore> _model;
+        Columns _columns;
         CellRendererSel _cell_sel;
         Gtk::Button _add;
         Glib::RefPtr<Gtk::Menu> _menu;
index bf71c33d158263c96d00c6bdf656d8c6f12a3506..f8aee43f0f0640fd05809c43e49c9d270d30924a 100644 (file)
 #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),
index 673118ac3e24349862e6513e068ece9c5e8096d9..f0d6f324db7fccc7cd0a2b5d51773aaa9992c429 100644 (file)
@@ -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<SPFilter*> filter;
-        Gtk::TreeModelColumn<Glib::ustring> label;
-        Gtk::TreeModelColumn<int> sel;
-    };
-
-    virtual void update_filters();
-
-    Glib::RefPtr<Gtk::ListStore> _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