Program aborts when setting a Gtk::TreeView as the custom widget via Gtk::Tooltip::set_custom()


I am having some problems when I try to add a Gtk::TreeView as the
custom widget in a tooltip via Gtk::Tooltip::set_custom(), I have
isolated the problem and written a very small test program which shows
the problem.

The program works when I use a Gtk::ComboBox instead of the Gtk::TreeView.

I can actually get the Gtk::TreeView to work, but only if I call

So here are my observations:

1) using Gtk::ComboBox always works without any warnings

2) using Gtk::TreeView with headers hidden works partially
2.1) the first time the tooltip is to be shown the following warnings
are printed:
  Gdk-CRITICAL **: gdk_window_show: assertion `GDK_IS_WINDOW (window)' failed
  Gdk-CRITICAL **: gdk_window_show: assertion `GDK_IS_WINDOW (window)' failed

these warnings first reappear after I leave the window with the mouse
and reenter again; the first time after reentering the widget with the
mouse the tooltip is not shown these warnings appear and then the
second time the tooltip is to be shown it works as expected

3) using Gtk::TreeView with headers visible never works but instead
aborts with the following messages:
Gdk-CRITICAL **: gdk_window_show: assertion `GDK_IS_WINDOW (window)' failed
Gtk-CRITICAL **: gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED
(widget) || GTK_IS_INVISIBLE (widget)' failed
Gtk-CRITICAL **: gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED
(widget) || GTK_IS_INVISIBLE (widget)' failed
Gtk-CRITICAL **: gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED
(widget) || GTK_IS_INVISIBLE (widget)' failed
Gtk-CRITICAL **: gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED
(widget) || GTK_IS_INVISIBLE (widget)' failed
Gtk-ERROR **: file /build/buildd/gtk+2.0-2.12.0/gtk/gtkwidget.c: line
7922 (gtk_widget_real_map): assertion failed: (GTK_WIDGET_REALIZED

Thanks in advance for any pointers for how this can be solved!

With kind regards,

Mikael Olenfalk

Here for your reference is the sourcecode, compile as usual with g++
`pkg-config --libs --cflags gtkmm-2.4` customtooltiptest.cpp

If you undefine USE_TREEVIEW_IN_TOOLTIP a combobox is added instead
(empty), redefining SHOW_TREEVIEW_HEADERS from true to false
hides the headers and makes the example work as explained in point 2) above.

// ---- SNIP ----
#include <gtkmm.h>
#include <sstream>


bool on_query_tooltip (int x, int y, bool keyboard_tooltip,
		const Glib::RefPtr< Gtk::Tooltip >& tooltip, Gtk::Widget& widget)
	tooltip->set_custom (widget);
	return true;

class ModelColumns : public Gtk::TreeModel::ColumnRecord
	ModelColumns ()
	{ add(text); }
	Gtk::TreeModelColumn<Glib::ustring> text;

int main(int argc, char *argv[])
    Gtk::Main kit(argc, argv);

    Gtk::Window window;
    Gtk::Button button("A button with a tooltip");

    // create treeview and add some dummy data
    ModelColumns model;
    Glib::RefPtr< Gtk::TreeStore > refmodel = Gtk::TreeStore::create (model);

    Gtk::TreeView view;

    view.set_model (refmodel);
    view.append_column ("Text", model.text);

    for (int i = 0; i < 5; ++i) {
        Gtk::TreeModel::Row row = *(refmodel->append());

        std::ostringstream ossi;
        ossi << i;
        row[model.text] = ossi.str ();

    	for (int j = 0; j < 2; ++j) {
    		Gtk::TreeModel::Row child_row = *(refmodel->append(row.children()));
    		std::ostringstream ossc;
    		ossc << i << " : " << j;
    		child_row[model.text] = ossc.str ();	
    Gtk::ComboBox view;

    // setup tooltip
    button.signal_query_tooltip().connect ( sigc::bind (sigc::ptr_fun
(&on_query_tooltip), sigc::ref(view)) );

    window.add (button);


    return 0;
// ---- END SNIP ----

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