Hi! I am trying to write a simple code to let the user change the accelerators associated to actions during the execution. I set up a Gtk::TreeView with Gtk::CellRendererAccel to edit and render the accelerators. I am able to receive the emitted signals however I got strange results on modification like being unable to modify the accels for compile time associated actions or multiple slots associated to a single accel. In my application I use a Gtk::ActionGroup (I put it together with the TreeView related thing in a single class) and a Gtk::UIManager to which I add the Gtk::ActionGroup and from which the AccelGroup is extracted and passed to the main window.
I saw in action some things i could undo for instance disconnecting for a signalproxy but there seem not to be a disconnect() function. I do not really know about all that signal/slot proxys. I send you a copy of the code i use. Thanks a lot for your comments/ideas/... -- Émilien TLAPALE class AccelPrefs : public Gtk::TreeView { [...] // CmpGlibUstring may not be necessary std::map<Glib::ustring, Gtk::Action::SlotActivate, CmpGlibUstring> m_slots; [...] void add(const Glib::RefPtr<Gtk::Action> action, const Gtk::Action::SlotActivate& slot) { m_ref_action_group->add(action, slot); Gtk::TreeModel::Row row = *(m_ref_list_store->append()); row[m_columns.action_name] = action->get_name(); m_slots[action->get_name()] = slot; } void add(const Glib::RefPtr<Gtk::Action> action, const Gtk::AccelKey& accel, const Gtk::Action::SlotActivate& slot) { m_ref_action_group->add(action, accel, slot); Gtk::TreeModel::Row row = *(m_ref_list_store->append()); row[m_columns.action_name] = action->get_name(); row[m_columns.accel_key] = accel.get_key(); row[m_columns.accel_mods] = accel.get_mod(); m_slots[action->get_name()] = slot; } void AccelPrefs::on_accel_edited(const Glib::ustring& path, guint key, Gdk::ModifierType mods, guint hardware) { guint old_key; Gdk::ModifierType old_mods; // Update the displayed accelerator Gtk::TreeModel::Row row = *(m_ref_list_store->get_iter(path)); row[m_columns.accel_key] = key; row[m_columns.accel_mods] = mods; // Modify the action's accel Glib::RefPtr<Gtk::Action> action = m_ref_action_group->get_action( row[m_columns.action_name]); Glib::ustring action_name = action->get_name(); Gtk::Action::SlotActivate slot = m_slots[action_name]; m_ref_action_group->remove(action); Gtk::AccelKey new_accel_key = Gtk::AccelKey(key, mods); m_ref_action_group->add(action, new_accel_key, slot); } [...] }; _______________________________________________ gtkmm-list mailing list gtkmm-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtkmm-list