I'm very sorry but the attachment didn't pass through... here is the 
snippet:


#include <gtkmm.h>
#include <iostream>

class Columns : public Gtk::TreeModelColumnRecord {
public:
    Columns() {
        add(col);
    }
    Gtk::TreeModelColumn<Glib::ustring> col;
};

Gtk::TreeView *list_view;

bool on_list_key_press_event(GdkEventKey* event) {
    Glib::ustring ch(event->string);
    if (ch == "a") {
        // scroll up
        Glib::RefPtr<Gtk::TreeSelection>selection = 
list_view->get_selection();
        Gtk::TreeModel::iterator it= selection->get_selected();
        Gtk::TreeModel::Children children = 
list_view->get_model()->children();
        if (it && it!=children.begin()) {
            selection->select(--it);
        }
        return true;
    }
    if (ch == "z") {
        // scroll down
        Glib::RefPtr<Gtk::TreeSelection>selection = 
list_view->get_selection();
        Gtk::TreeModel::iterator it= selection->get_selected();
        Gtk::TreeModel::Children children = 
list_view->get_model()->children();
        if (it && it!=children.end()) {
            selection->select(++it);
        }
        return true;
    }
    return false;
}

int mainn(int argc, char *argv[]) {
    Gtk::Main kit(argc, argv);
    Gtk::Window window;

    Columns cols;
    Glib::RefPtr<Gtk::ListStore> model = Gtk::ListStore::create(cols);
    (*model->append())[cols.col]="foo bar row 1";
    (*model->append())[cols.col]="foo bar row 2";
    (*model->append())[cols.col]="foo bar row 3";

    list_view = manage(new Gtk::TreeView());
    list_view->set_model(model);
    list_view->append_column("a list", cols.col);
    list_view->set_enable_search(false);

    
list_view->signal_key_press_event().connect(sigc::ptr_fun(&on_list_key_press_event));

    window.add(*list_view);
    window.show_all_children(true);

    Gtk::Main::run(window);

    return 0;
}

// end


Michael Baranov wrote:
> Hello!
> I'm new to the list and new to gtkmm...
>
> Here is a very simple standalone snippet that looks OK to me but 
> produces warnings:
>
> Gtk-CRITICAL **: gtk_list_store_get_path: assertion `iter->stamp == 
> GTK_LIST_STORE (tree_model)->stamp' failed
>
> In the snippet keys A/Z move selection up/down; Hit key Z several 
> times to see the warnings.
> Am I missing something?
>
> Thanks for the help and a superb lib!
>

-- 
Michael Baranov

_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to