From: gouldtj Date: Wed, 27 Jun 2007 06:26:13 +0000 (+0000) Subject: r15506@tres: ted | 2007-05-24 22:30:55 -0700 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6a4cf574d0308833eeda63ff2f2fd50a80abc676;p=inkscape.git r15506@tres: ted | 2007-05-24 22:30:55 -0700 Wow, the basics are kinda working. Only for ints and floats, and it seems to not like repeadative entry. But, it really is seeming very feasible. --- diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp index 80dc776e3..6ae9eae50 100644 --- a/src/extension/effect.cpp +++ b/src/extension/effect.cpp @@ -9,6 +9,10 @@ #include "inkscape-private.h" #include "helper/action.h" +#include "ui/view/view.h" +#include "desktop-handles.h" +#include "selection.h" +#include "sp-namedview.h" #include "document.h" #include "prefdialog.h" #include "implementation/implementation.h" @@ -17,6 +21,8 @@ #include "gtkmm/messagedialog.h" +#include "util/glib-list-iterators.h" + /* Inkscape::Extension::Effect */ namespace Inkscape { @@ -209,6 +215,7 @@ private: bool _canceled; Glib::RefPtr _mainloop; Inkscape::UI::View::View * _doc; + std::list _selected; public: void run (void); @@ -222,6 +229,21 @@ public: _canceled(false), _doc(doc) { + SPDesktop *desktop = (SPDesktop *)_doc; + sp_namedview_document_from_window(desktop); + + if (desktop != NULL) { + Inkscape::Util::GSListConstIterator selected = + sp_desktop_selection(desktop)->itemList(); + while ( selected != NULL ) { + Glib::ustring selected_id; + selected_id = SP_OBJECT_ID(*selected); + _selected.insert(_selected.end(), selected_id); + std::cout << "Selected: " << selected_id << std::endl; + ++selected; + } + } + _mainloop = Glib::MainLoop::create(false); if (controls != NULL) { @@ -241,6 +263,7 @@ public: } void preferencesChange (void) { + std::cout << "Preferences are a changin'" << std::endl; if (_humanWait) { _mainloop->quit(); documentCancel(); @@ -338,6 +361,23 @@ private: Effect::set_last_effect(_effect); return; } + + void reselect (void) { + SPDocument * doc = _doc->doc(); + + SPDesktop *desktop = (SPDesktop *)_doc; + sp_namedview_document_from_window(desktop); + + if (desktop == NULL) { return; } + + Inkscape::Selection * selection = sp_desktop_selection(desktop); + + for (std::list::iterator i = _selected.begin(); i != _selected.end(); i++) { + selection->add(doc->getObjectById(i->c_str())); + } + + return; + } }; void @@ -352,6 +392,7 @@ ExecutionEnv::run (void) { } if (_canceled) { sp_document_cancel(_doc->doc()); + reselect(); } } return; diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp index 20aff9c03..5082ba08e 100644 --- a/src/extension/extension.cpp +++ b/src/extension/extension.cpp @@ -631,7 +631,7 @@ Extension::autogui (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal(list->data); - Gtk::Widget * widg = param->get_widget(doc, node); + Gtk::Widget * widg = param->get_widget(doc, node, changeSignal); gchar const * tip = param->get_tooltip(); agui->addWidget(widg, tip); } diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 96c436dfd..85b2addcb 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -563,7 +563,7 @@ Script::prefs_effect(Inkscape::Extension::Effect *module, first_select = SP_OBJECT_REPR(item); } - return module->autogui(current_document, first_select); + return module->autogui(current_document, first_select, changeSignal); } diff --git a/src/extension/paramenum.cpp b/src/extension/paramenum.cpp index 283ef8f5c..b9dab676f 100644 --- a/src/extension/paramenum.cpp +++ b/src/extension/paramenum.cpp @@ -209,7 +209,7 @@ ParamComboBoxEntry::changed (void) \brief Creates a combobox widget for an enumeration parameter */ Gtk::Widget * -ParamComboBox::get_widget (SPDocument * doc, Inkscape::XML::Node * node) +ParamComboBox::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); diff --git a/src/extension/paramenum.h b/src/extension/paramenum.h index 4ad448549..b5eaeded7 100644 --- a/src/extension/paramenum.h +++ b/src/extension/paramenum.h @@ -39,7 +39,7 @@ private: public: ParamComboBox(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); ~ParamComboBox(void); - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node); + Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal); Glib::ustring * string (void); const gchar * get (const SPDocument * doc, const Inkscape::XML::Node * node) { return _value; } diff --git a/src/extension/parameter.cpp b/src/extension/parameter.cpp index 50b90f71c..4d6619236 100644 --- a/src/extension/parameter.cpp +++ b/src/extension/parameter.cpp @@ -52,7 +52,7 @@ private: gchar * _value; public: ParamDescription(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node); + Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal); }; /** \brief A boolean parameter */ @@ -65,7 +65,7 @@ public: /** \brief Returns \c _value */ bool get (const SPDocument * doc, const Inkscape::XML::Node * node) { return _value; } bool set (bool in, SPDocument * doc, Inkscape::XML::Node * node); - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node); + Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal); Glib::ustring * string (void); }; @@ -103,7 +103,7 @@ public: int set (int in, SPDocument * doc, Inkscape::XML::Node * node); int max (void) { return _max; } int min (void) { return _min; } - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node); + Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal); Glib::ustring * string (void); }; @@ -157,7 +157,7 @@ public: float set (float in, SPDocument * doc, Inkscape::XML::Node * node); float max (void) { return _max; } float min (void) { return _min; } - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node); + Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal); Glib::ustring * string (void); }; @@ -209,7 +209,7 @@ public: /** \brief Returns \c _value, with a \i const to protect it. */ const gchar * get (const SPDocument * doc, const Inkscape::XML::Node * node) { return _value; } const gchar * set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node); - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node); + Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal); Glib::ustring * string (void); }; @@ -242,7 +242,7 @@ public: /** \brief Returns \c _value, with a \i const to protect it. */ const gchar * get (const SPDocument * doc, const Inkscape::XML::Node * node) { return _current_choice != NULL ? _current_choice->_value : NULL; } const gchar * set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node); - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node); + Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal); Glib::ustring * string (void); }; /* class ParamEnum */ @@ -620,7 +620,7 @@ Parameter::document_param_node (SPDocument * doc) /** \brief Basically, if there is no widget pass a NULL. */ Gtk::Widget * -Parameter::get_widget (SPDocument * doc, Inkscape::XML::Node * node) +Parameter::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { return NULL; } @@ -639,11 +639,12 @@ class ParamFloatAdjustment : public Gtk::Adjustment { ParamFloat * _pref; SPDocument * _doc; Inkscape::XML::Node * _node; + sigc::signal * _changeSignal; public: /** \brief Make the adjustment using an extension and the string describing the parameter. */ - ParamFloatAdjustment (ParamFloat * param, SPDocument * doc, Inkscape::XML::Node * node) : - Gtk::Adjustment(0.0, param->min(), param->max(), 0.1), _pref(param), _doc(doc), _node(node) { + ParamFloatAdjustment (ParamFloat * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) : + Gtk::Adjustment(0.0, param->min(), param->max(), 0.1), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { this->set_value(_pref->get(NULL, NULL) /* \todo fix */); this->signal_value_changed().connect(sigc::mem_fun(this, &ParamFloatAdjustment::val_changed)); return; @@ -661,8 +662,13 @@ public: void ParamFloatAdjustment::val_changed (void) { - // std::cout << "Value Changed to: " << this->get_value() << std::endl; + std::cout << "Value Changed to: " << this->get_value() << std::endl; _pref->set(this->get_value(), _doc, _node); + if (_changeSignal != NULL) { + _changeSignal->emit(); + } else { + std::cout << "_changeSignal is NULL" << std::endl; + } return; } @@ -672,11 +678,12 @@ class ParamIntAdjustment : public Gtk::Adjustment { ParamInt * _pref; SPDocument * _doc; Inkscape::XML::Node * _node; + sigc::signal * _changeSignal; public: /** \brief Make the adjustment using an extension and the string describing the parameter. */ - ParamIntAdjustment (ParamInt * param, SPDocument * doc, Inkscape::XML::Node * node) : - Gtk::Adjustment(0.0, param->min(), param->max(), 1.0), _pref(param), _doc(doc), _node(node) { + ParamIntAdjustment (ParamInt * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) : + Gtk::Adjustment(0.0, param->min(), param->max(), 1.0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { this->set_value(_pref->get(NULL, NULL) /* \todo fix */); this->signal_value_changed().connect(sigc::mem_fun(this, &ParamIntAdjustment::val_changed)); return; @@ -694,8 +701,13 @@ public: void ParamIntAdjustment::val_changed (void) { - // std::cout << "Value Changed to: " << this->get_value() << std::endl; + std::cout << "Value Changed to: " << this->get_value() << std::endl; _pref->set((int)this->get_value(), _doc, _node); + if (_changeSignal != NULL) { + _changeSignal->emit(); + } else { + std::cout << "_changeSignal is NULL" << std::endl; + } return; } @@ -705,7 +717,7 @@ ParamIntAdjustment::val_changed (void) Builds a hbox with a label and a float adjustment in it. */ Gtk::Widget * -ParamFloat::get_widget (SPDocument * doc, Inkscape::XML::Node * node) +ParamFloat::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); @@ -713,7 +725,7 @@ ParamFloat::get_widget (SPDocument * doc, Inkscape::XML::Node * node) label->show(); hbox->pack_start(*label, true, true); - ParamFloatAdjustment * fadjust = Gtk::manage(new ParamFloatAdjustment(this, doc, node)); + ParamFloatAdjustment * fadjust = Gtk::manage(new ParamFloatAdjustment(this, doc, node, changeSignal)); Gtk::SpinButton * spin = Gtk::manage(new Gtk::SpinButton(*fadjust, 0.1, 1)); spin->show(); hbox->pack_start(*spin, false, false); @@ -729,7 +741,7 @@ ParamFloat::get_widget (SPDocument * doc, Inkscape::XML::Node * node) Builds a hbox with a label and a int adjustment in it. */ Gtk::Widget * -ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node) +ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); @@ -737,7 +749,7 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node) label->show(); hbox->pack_start(*label, true, true); - ParamIntAdjustment * fadjust = Gtk::manage(new ParamIntAdjustment(this, doc, node)); + ParamIntAdjustment * fadjust = Gtk::manage(new ParamIntAdjustment(this, doc, node, changeSignal)); Gtk::SpinButton * spin = Gtk::manage(new Gtk::SpinButton(*fadjust, 1.0, 0)); spin->show(); hbox->pack_start(*spin, false, false); @@ -790,7 +802,7 @@ ParamBoolCheckButton::on_toggle (void) Builds a hbox with a label and a check button in it. */ Gtk::Widget * -ParamBool::get_widget (SPDocument * doc, Inkscape::XML::Node * node) +ParamBool::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); @@ -846,7 +858,7 @@ ParamStringEntry::changed_text (void) Builds a hbox with a label and a text box in it. */ Gtk::Widget * -ParamString::get_widget (SPDocument * doc, Inkscape::XML::Node * node) +ParamString::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); @@ -927,7 +939,7 @@ ParamString::string (void) /** \brief Create a label for the description */ Gtk::Widget * -ParamDescription::get_widget (SPDocument * doc, Inkscape::XML::Node * node) +ParamDescription::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_value))); label->set_line_wrap(); @@ -978,7 +990,7 @@ ParamEnum::string (void) } Gtk::Widget * -ParamEnum::get_widget (SPDocument * doc, Inkscape::XML::Node * node) +ParamEnum::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { return NULL; } diff --git a/src/extension/parameter.h b/src/extension/parameter.h index e1e27302c..5ac1c9f5c 100644 --- a/src/extension/parameter.h +++ b/src/extension/parameter.h @@ -85,7 +85,7 @@ public: const gchar * name (void) {return _name;} static Parameter * make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext); - virtual Gtk::Widget * get_widget (SPDocument * doc, Inkscape::XML::Node * node); + virtual Gtk::Widget * get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal); virtual Glib::ustring * string (void); gchar const * get_tooltip (void) { return _desc; } }; diff --git a/src/extension/paramnotebook.cpp b/src/extension/paramnotebook.cpp index e8bd1e902..80a17b95b 100644 --- a/src/extension/paramnotebook.cpp +++ b/src/extension/paramnotebook.cpp @@ -54,7 +54,7 @@ public: ParamNotebookPage(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); ~ParamNotebookPage(void); - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node); + Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal); Glib::ustring * paramString (void); gchar * get_guitext (void) {return _text;}; @@ -187,7 +187,7 @@ ParamNotebookPage::makepage (Inkscape::XML::Node * in_repr, Inkscape::Extension: Builds a notebook page (a vbox) and puts parameters on it. */ Gtk::Widget * -ParamNotebookPage::get_widget (SPDocument * doc, Inkscape::XML::Node * node) +ParamNotebookPage::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { if (!_tooltips) _tooltips = new Gtk::Tooltips(); @@ -197,7 +197,7 @@ ParamNotebookPage::get_widget (SPDocument * doc, Inkscape::XML::Node * node) // add parameters onto page (if any) for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) { Parameter * param = reinterpret_cast(list->data); - Gtk::Widget * widg = param->get_widget(doc, node); + Gtk::Widget * widg = param->get_widget(doc, node, changeSignal); gchar const * tip = param->get_tooltip(); vbox->pack_start(*widg, true, true, 2); @@ -387,7 +387,7 @@ ParamNotebookWdg::changed_page(GtkNotebookPage *page, Builds a notebook and puts pages in it. */ Gtk::Widget * -ParamNotebook::get_widget (SPDocument * doc, Inkscape::XML::Node * node) +ParamNotebook::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { ParamNotebookWdg * nb = Gtk::manage(new ParamNotebookWdg(this, doc, node)); @@ -397,7 +397,7 @@ ParamNotebook::get_widget (SPDocument * doc, Inkscape::XML::Node * node) for (GSList * list = pages; list != NULL; list = g_slist_next(list)) { i++; ParamNotebookPage * page = reinterpret_cast(list->data); - Gtk::Widget * widg = page->get_widget(doc, node); + Gtk::Widget * widg = page->get_widget(doc, node, changeSignal); nb->append_page(*widg, _(page->get_guitext())); if (!strcmp(_value, page->name())) { pagenr = i; // this is the page to be displayed? diff --git a/src/extension/paramnotebook.h b/src/extension/paramnotebook.h index f0ab15f57..d0603003e 100644 --- a/src/extension/paramnotebook.h +++ b/src/extension/paramnotebook.h @@ -40,7 +40,7 @@ private: public: ParamNotebook(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); ~ParamNotebook(void); - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node); + Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal); Glib::ustring * string (void); const gchar * get (const SPDocument * doc, const Inkscape::XML::Node * node) { return _value; } diff --git a/src/extension/paramradiobutton.cpp b/src/extension/paramradiobutton.cpp index 94270af84..e88232932 100644 --- a/src/extension/paramradiobutton.cpp +++ b/src/extension/paramradiobutton.cpp @@ -224,7 +224,7 @@ ParamRadioButtonWdg::changed (void) \brief Creates a combobox widget for an enumeration parameter */ Gtk::Widget * -ParamRadioButton::get_widget (SPDocument * doc, Inkscape::XML::Node * node) +ParamRadioButton::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); Gtk::VBox * vbox = Gtk::manage(new Gtk::VBox(false, 0)); diff --git a/src/extension/paramradiobutton.h b/src/extension/paramradiobutton.h index 8e1edf5b8..6a5fd7d0d 100644 --- a/src/extension/paramradiobutton.h +++ b/src/extension/paramradiobutton.h @@ -39,7 +39,7 @@ private: public: ParamRadioButton(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); ~ParamRadioButton(void); - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node); + Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal); Glib::ustring * string (void); const gchar * get (const SPDocument * doc, const Inkscape::XML::Node * node) { return _value; }