Editable TreeView Cells



Hi,

I'm trying to connect only one column signal from my tree View . The
Signal is the edited, changed something that tells me that the value of
that column has changed.

My code is something like this:

class MyList : public Gtk::TreeView
 {
    public:
       ...
    protected:
       ...
    private:  
        ....

    //inline class
    class ListColumnsModel : public Gtk::TreeModel::ColumnRecord
    {
    public:
        ListColumnsModel ()
        {
            add (Name);
            add (Owner);
            add (Description);
        }

        Gtk::TreeModelColumn<Glib::ustring> Name;

        int NameColumnID;

        Gtk::TreeModelColumn<Glib::ustring> Owner;

        int OwnerColumnID;

        Gtk::TreeModelColumn<Glib::ustring> Description;

        int DescriptionColumnID;
    };

    ListColumnsModel mListColumnsModel;

    Glib::RefPtr<Gtk::ListStore> mModelRef;
}

Then in constructor :

mModelRef = Gtk::ListStore::create (mListColumnsModel);
    set_model (mModelRef);
 
  mListColumnsModel NameColumnID =
        append_column ("Name", mListColumnsModel.Name);
  
 mListColumnsModel.OwnerColumnID =
        append_column ("Owner", mListColumnsModel.Owner);
  
 mListColumnsModel.DescriptionColumnID =
        append_column_editable ("Description",
mListColumnsModel.Description);

Here every thing goes good, I run the program I insert all information I
can retrieve all information from the cells, and when I've changed
append_column to append_column_editable to append The description column
I can edit and cahnge the value of that column.

Now the problem is to catch a signal noticing me that that value has
changed, for internal purposes, so i tried the following.

Gtk::CellRenderer* pCellRenderer = get_column_cell_renderer
(mListColumnsModel.DescriptionColumnID);

Gtk::CellRendererText* pCellRenderText =
dynamic_cast<Gtk::CellRendererText*>(pCellRenderer);

    if(pCellRendererText)
    {   
        std::cout << "Obtained Cell render connecting the signal: " ;
       
        pCellRenderText->signal_edited().connect (sigc::mem_fun
(*this,   &List::DescriptionTextChanged));
    }
    else
    {
        std::cout << "NOT Obtained Cell render for connecting the
signal: " ;
    }

Here the output is allways : "NOT Obtained Cell render for connecting
the signal: ".

Then I tried a second aproach:

Gtk::TreeView::Column* pViewColumn = Gtk::manage(new
Gtk::TreeView::Column("Description", mListColumnsModel.Description));

Gtk::CellRenderer* pCellRenderer = pViewColumn->get_first_cell_renderer();

Gtk::CellRendererText* pCellRenderText =
dynamic_cast<Gtk::CellRendererText*>(pCellRenderer);

if(pCellRenderer)
    {   
        std::cout << "Obtained Cell render connecting the signal: " ;

        pCellRenderText->property_editable_set() = true;
        pCellRenderText->signal_edited().connect (sigc::mem_fun (*this,
&List::DescriptionTextChanged));
    }
    else
    {
        std::cout << "NOT Obtained Cell render for connecting the
signal: " ;
    }

Here it passes trough the if test condition and connects the signal, BUT
when I edit the column text it does not call the handler function. It's
like the cell renderer that I obtained does not refer to the one I need.

I heave no clues about what I'm doing wrong, and I don't now what to try
now.

I hope someone can tell me what I'm doing wrong, and what escaped-me
from the documentation.

Thanks in advance,

Filipe Apóstolo


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