Strange IconView Behaviour



Hello,

Currently I have an IconView that contains two PixBufs which are build from raw data. These images are OK (thoroughly checked this).

The problem is that the Pixbufs are drawn into the IconView as many times as we add them into the Model. So, we get X columns with X versions of each ColumnRecord. This picture shows the behaviour. That was after updating the IconView twice. Pardon the ugly colours.

The IconView contains a custom TreeModel::ColumnRecord shown below.

    class IconColumns : public Gtk::TreeModel::ColumnRecord
    {
    public:
        Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > thumbnail1;
        Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > thumbnail2;

        IconColumns() {
            add(thumbnail1);
            add(thumbnail2);
        }
    };

The IconView is build in Glade without a model. Everything in Glade is default except that the orientation is horizontal rather than vertical. The model is then set using the following code:

    IconColumns cols;
    previewListStore = Gtk::ListStore::create(cols);
    previewIconView->set_model(previewListStore);

I have spent my day attempting to figure this out, but since porting this project over to GTK3 (mm), I have not been able figure this out.

We update the IconView is updated in the following method:

    IconColumns mColumns;
    Glib::RefPtr<Gtk::ListStore> m_list = Gtk::ListStore::create(mColumns);
    size_t imageCount = calIconImages[0].size();

    printf("num cols: c:%d, n:%d :: imgCount %d\n", previewListStore->get_n_columns(), m_list->get_n_columns(), imageCount);

    for(size_t i = 0; i < imageCount; i++) {
        Gtk::ListStore::iterator it = m_list->prepend();
        Gtk::ListStore::Row row = *it;
        Glib::RefPtr<Gdk::Pixbuf> pixbuf1 = Gdk::Pixbuf::create_from_data((const guint8*)calIconImages[0][i]->imageData, Gdk::COLORSPACE_RGB, false, 8, 100, 80, 3*100);
        Glib::RefPtr<Gdk::Pixbuf> pixbuf2 = Gdk::Pixbuf::create_from_data((const guint8*)calIconImages[1][i]->imageData, Gdk::COLORSPACE_RGB, false, 8, 100, 80, 3*100);
        row.set_value(mColumns.thumbnail1, pixbuf1);
        row.set_value(mColumns.thumbnail2, pixbuf2);
        printf("\t\t1: %d 2: %d\n", mColumns.thumbnail1.index(), mColumns.thumbnail2.index());
    }

    printf("\tbefore clear: c:%d, n:%d\n", previewListStore->get_n_columns(), m_list->get_n_columns());
    if (previewListStore)
        previewListStore->clear();

    printf("\tafter clear: c:%d, n:%d\n", previewListStore->get_n_columns(), m_list->get_n_columns());

    previewIconView->unset_model();
    previewIconView->set_columns(100);
    previewIconView->set_model(m_list);

    previewListStore = m_list;
    ((Gtk::CellLayout*)previewIconView)->pack_start(mColumns.thumbnail1, false);
    ((Gtk::CellLayout*)previewIconView)->pack_start(mColumns.thumbnail2, false);

The calIconImages is an array of vectors (size 2) which is filled in another thread with IplImages. The image data is irrelevant, it is valid and the information placed into the pixbuf::create method is correct, as well.

We have tried changing all of the methods in the loading of the model but have come to a standstill and are very confused. Any and all insight into what might be the problem is highly appreciated.

Kind regards,

Kevin Brightwell

P.S. if this is the wrong mailing list, I apologize and would appreciate a pointer to the correct list!

--
Kevin Brightwell
Year 4 Bachelor of Computer Engineering (BESc.)
Year 3 Bachelor of Computer Science (BSc.)

Residence Don - Saugeen-Maitland Hall
Western University www.westernu.ca
e. kevin brightwell2 gmail com c. 226.678.4927



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