Re: [gtkmm] how do I know when a row has been edited?



"Andreas B. Thun" <abt gmx de> writes:

> How can I call a callback when a value in my list has been changed?
> signal_changed() only calls my callback after selection but not when
> I edit the row.
>
> I read about signal_row_changed() but I don't have a TreeModel...

If you have an editable cell:

  treeview->set_model(tree_store);
  int view_column = treeview->append_column("Name", list_columns.m_col_name);
  Gtk::CellRenderer *renderer =
    treeview->get_column_cell_renderer(view_column - 1);
  Gtk::CellRendererText *text_renderer =
    dynamic_cast<Gtk::CellRendererText *>(renderer);
  if (text_renderer)
    {
      text_renderer->property_editable() = true;
      text_renderer->signal_edited().connect
        ( SigC::slot(*this, &MyDialog::on_edited) );
    }


void
MyDialog::on_edited(const Glib::ustring& path,
                    const Glib::ustring& text)
{
  // Check if the value has changed from its previous value...
  {
    Gtk::TreeModel::iterator cur =
      m_tree_store->get_iter(Gtk::TreePath(path));
    Gtk::TreeModel::Row row = *cur;
    if (row[list_columns.m_col_name] == text) // value is unchanged
      return;
  }

  // Do other stuff here...
}


HTH,
Roger

-- 
Roger Leigh

                Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
                GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]