From: nicholasbishop Date: Wed, 1 Aug 2007 20:33:00 +0000 (+0000) Subject: Filter effects dialog: X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=75d2a56fc2c5b0d39e545d42909d64c3847cd68d;p=inkscape.git Filter effects dialog: Removed unused header file. --- diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 755b1fba4..d848b6b32 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -617,20 +618,9 @@ Glib::RefPtr create_popup_menu(Gtk::Widget& parent, sigc::slot return menu; } -static void try_id_change(SPObject* ob, const Glib::ustring& text) -{ - // FIXME: this needs more serious error checking... - if(ob && !SP_ACTIVE_DOCUMENT->getObjectById(text.c_str())) { - SPException ex; - SP_EXCEPTION_INIT(&ex); - sp_object_setAttribute(ob, "id", text.c_str(), &ex); - sp_document_done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_FILTER_EFFECTS, _("Set object ID")); - } -} - /*** FilterModifier ***/ -FilterEffectsDialog::FilterModifier::FilterModifier() - : _add(Gtk::Stock::ADD) +FilterEffectsDialog::FilterModifier::FilterModifier(FilterEffectsDialog& d) + : _dialog(d), _add(Gtk::Stock::ADD) { Gtk::ScrolledWindow* sw = Gtk::manage(new Gtk::ScrolledWindow); pack_start(*sw); @@ -642,7 +632,7 @@ FilterEffectsDialog::FilterModifier::FilterModifier() Gtk::TreeViewColumn* col = _list.get_column(selcol - 1); if(col) col->add_attribute(_cell_sel.property_sel(), _columns.sel); - _list.append_column(_("_Filter"), _columns.id); + _list.append_column(_("_Filter"), _columns.label); sw->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); sw->set_shadow_type(Gtk::SHADOW_IN); @@ -654,6 +644,9 @@ FilterEffectsDialog::FilterModifier::FilterModifier() sigc::mem_fun(*this, &FilterModifier::filter_list_button_release)); _menu = create_popup_menu(*this, sigc::mem_fun(*this, &FilterModifier::duplicate_filter), sigc::mem_fun(*this, &FilterModifier::remove_filter)); + _menu->items().push_back(Gtk::Menu_Helpers::MenuElem( + _("R_ename"), sigc::mem_fun(*this, &FilterModifier::rename_filter))); + _menu->accelerate(*this); g_signal_connect(G_OBJECT(INKSCAPE), "change_selection", G_CALLBACK(&FilterModifier::on_inkscape_change_selection), this); @@ -811,6 +804,11 @@ void FilterEffectsDialog::FilterModifier::add_filter() SPDocument* doc = sp_desktop_document(SP_ACTIVE_DESKTOP); SPFilter* filter = new_filter(doc); + const int count = _model->children().size(); + std::ostringstream os; + os << "filter" << count; + filter->setLabel(os.str().c_str()); + update_filters(); select_filter(filter); @@ -847,12 +845,30 @@ void FilterEffectsDialog::FilterModifier::duplicate_filter() } } -void FilterEffectsDialog::FilterModifier::filter_name_edited(const Glib::ustring& path, const Glib::ustring& text) +void FilterEffectsDialog::FilterModifier::rename_filter() { - Gtk::TreeModel::iterator i = _model->get_iter(path); - - if(i) - try_id_change((SPObject*)(*i)[_columns.filter], text); + SPFilter* filter = get_selected_filter(); + Gtk::Dialog m("", _dialog, true); + m.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + m.add_button(_("_Rename"), Gtk::RESPONSE_OK); + m.set_default_response(Gtk::RESPONSE_OK); + Gtk::Label lbl(_("Filter name:")); + Gtk::Entry entry; + entry.set_text(filter->label() ? filter->label() : ""); + Gtk::HBox hb; + hb.add(lbl); + hb.add(entry); + hb.set_spacing(12); + hb.show_all(); + m.get_vbox()->add(hb); + const int res = m.run(); + if(res == Gtk::RESPONSE_OK) { + filter->setLabel(entry.get_text().c_str()); + sp_document_done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Rename filter")); + Gtk::TreeIter iter = _list.get_selection()->get_selected(); + if(iter) + (*iter)[_columns.label] = entry.get_text(); + } } FilterEffectsDialog::CellRendererConnection::CellRendererConnection() @@ -1443,6 +1459,7 @@ int FilterEffectsDialog::PrimitiveList::primitive_count() const FilterEffectsDialog::FilterEffectsDialog() : Dialog ("dialogs.filtereffects", SP_VERB_DIALOG_FILTER_EFFECTS), + _filter_modifier(*this), _primitive_list(*this), _add_primitive_type(FPConverter), _add_primitive(Gtk::Stock::ADD), diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index 3d834c4b2..2dacd4860 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -51,7 +50,7 @@ private: class FilterModifier : public Gtk::VBox, public FilterEffectChooser { public: - FilterModifier(); + FilterModifier(FilterEffectsDialog&); virtual SPFilter* get_selected_filter(); virtual void select_filter(const SPFilter*); @@ -81,8 +80,9 @@ private: void add_filter(); void remove_filter(); void duplicate_filter(); - void filter_name_edited(const Glib::ustring& path, const Glib::ustring& text); + void rename_filter(); + FilterEffectsDialog& _dialog; Gtk::TreeView _list; CellRendererSel _cell_sel; Gtk::Button _add; diff --git a/src/ui/widget/filter-effect-chooser.cpp b/src/ui/widget/filter-effect-chooser.cpp index 9cc235895..0820a2f28 100644 --- a/src/ui/widget/filter-effect-chooser.cpp +++ b/src/ui/widget/filter-effect-chooser.cpp @@ -72,8 +72,9 @@ void FilterEffectChooser::update_filters() 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.id] = id ? id : ""; + row[_columns.label] = lbl ? lbl : (id ? id : "filter"); } } @@ -113,7 +114,7 @@ SimpleFilterModifier::SimpleFilterModifier() _blend.signal_changed().connect(signal_blend_blur_changed()); _blur.signal_value_changed().connect(signal_blend_blur_changed()); _filter.set_model(_model); - _filter.pack_start(_columns.id); + _filter.pack_start(_columns.label); _edit_filters.signal_clicked().connect(sigc::mem_fun(*this, &SimpleFilterModifier::show_filter_dialog)); _edit_filters.set_use_underline(); @@ -188,7 +189,7 @@ void SimpleFilterModifier::update_filters() // Set state if no filters exist Gtk::TreeModel::Row row = *_model->prepend(); row[_columns.filter] = 0; - row[_columns.id] = "None"; + row[_columns.label] = "None"; _filter.set_sensitive(false); _filter.set_active(0); } diff --git a/src/ui/widget/filter-effect-chooser.h b/src/ui/widget/filter-effect-chooser.h index 9a49f523b..5d1d16efd 100644 --- a/src/ui/widget/filter-effect-chooser.h +++ b/src/ui/widget/filter-effect-chooser.h @@ -44,12 +44,12 @@ protected: Columns() { add(filter); - add(id); + add(label); add(sel); } Gtk::TreeModelColumn filter; - Gtk::TreeModelColumn id; + Gtk::TreeModelColumn label; Gtk::TreeModelColumn sel; };