From 7391f378420d4ca5fb2a2eb2851fdd4b0682b90d Mon Sep 17 00:00:00 2001 From: nicholasbishop Date: Mon, 8 Oct 2007 03:28:48 +0000 Subject: [PATCH] Filter effects dialog: * Added click-to-edit for labels in the filter list --- src/ui/dialog/filter-effects-dialog.cpp | 48 +++++++++---------------- src/ui/dialog/filter-effects-dialog.h | 3 +- 2 files changed, 18 insertions(+), 33 deletions(-) diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index c6479d48f..d86aea55e 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -907,21 +907,19 @@ FilterEffectsDialog::FilterModifier::FilterModifier(FilterEffectsDialog& d) Gtk::TreeViewColumn* col = _list.get_column(selcol - 1); if(col) col->add_attribute(_cell_toggle.property_active(), _columns.sel); - _list.append_column(_("_Filter"), _columns.label); + _list.append_column_editable(_("_Filter"), _columns.label); + ((Gtk::CellRendererText*)_list.get_column(1)->get_first_cell_renderer())-> + signal_edited().connect(sigc::mem_fun(*this, &FilterEffectsDialog::FilterModifier::on_name_edited)); sw->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); sw->set_shadow_type(Gtk::SHADOW_IN); show_all_children(); _add.signal_clicked().connect(sigc::mem_fun(*this, &FilterModifier::add_filter)); _cell_toggle.signal_toggled().connect(sigc::mem_fun(*this, &FilterModifier::on_selection_toggled)); - //_list.signal_button_press_event().connect_notify( - // sigc::mem_fun(*this, &FilterModifier::filter_list_button_press)); _list.signal_button_release_event().connect_notify( 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); _list.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &FilterModifier::on_filter_selection_changed)); @@ -1006,6 +1004,19 @@ void FilterEffectsDialog::FilterModifier::on_filter_selection_changed() signal_filter_changed()(); } +void FilterEffectsDialog::FilterModifier::on_name_edited(const Glib::ustring& path, const Glib::ustring& text) +{ + Gtk::TreeModel::iterator iter = _model->get_iter(path); + + if(iter) { + SPFilter* filter = (*iter)[_columns.filter]; + filter->setLabel(text.c_str()); + sp_document_done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Rename filter")); + if(iter) + (*iter)[_columns.label] = text; + } +} + void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustring& path) { Gtk::TreeIter iter = _model->get_iter(path); @@ -1143,33 +1154,6 @@ void FilterEffectsDialog::FilterModifier::duplicate_filter() } } -void FilterEffectsDialog::FilterModifier::rename_filter() -{ - SPFilter* filter = get_selected_filter(); - Gtk::Window *window = dynamic_cast(_dialog.get_vbox()->get_ancestor(GTK_TYPE_WINDOW)); - Gtk::Dialog m("", *window, 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() : Glib::ObjectBase(typeid(CellRendererConnection)), _primitive(*this, "primitive", 0) diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index 56a1e2ca1..cb543775b 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -90,6 +90,8 @@ private: void update_selection(Selection *); void on_filter_selection_changed(); + + void on_name_edited(const Glib::ustring&, const Glib::ustring&); void on_selection_toggled(const Glib::ustring&); void update_filters(); @@ -97,7 +99,6 @@ private: void add_filter(); void remove_filter(); void duplicate_filter(); - void rename_filter(); sigc::connection _doc_replaced; sigc::connection _resource_changed; -- 2.30.2