Toolbar problem



Good day,

There is small test case.
It shows problem with toolbar button - if disabled/enabled it loses state that pointer is still over the button.
Steps:
1. run application
2. move mouse pointer over toolbar item
3. wait 2 seconds (timeout callback)
4. you will notice that you can't activate item pressing MB1
5. move pointer out toolbar item and back again
6. press MB1
7. after handler done you can't use MB1 to actiave toolbar item

Versions: Gtk+ 2.4.14, Gtkmm 2.4.11

Questions:
1. Is it known issue?
2. Was it fixed in latest Gtk+?
3. How could I reactivate toolitem without moving mouse pointer out/to toolbutton?

Regards,
-andrew

If needed I could submit a bug and make GTK+ test case also.

#include <gtkmm/main.h>
#include <gtkmm/window.h>
#include <gtkmm/toolbar.h>
#include <gtkmm/actiongroup.h>
#include <gtkmm/stock.h>

#include <iostream>
using namespace std;

class MyApp : public Gtk::Window
{
    Glib::RefPtr< Gtk::ActionGroup > m_refMainGroup;
    Gtk::ToolItem* item;
public:
    MyApp()
    {
	m_refMainGroup = Gtk::ActionGroup::create( "MainGroup" );

	Glib::RefPtr<Gtk::Action> action = Gtk::Action::create( "test", Gtk::Stock::REFRESH,
								"", "Test tool button" );
	m_refMainGroup->add( action,
			     Gtk::AccelKey( "F5" ),
			     sigc::mem_fun( *this, &MyApp::action_handler ) );

	Gtk::Toolbar* toolbar = manage( new Gtk::Toolbar );
	add( *toolbar );

	item = action->create_tool_item();
	item->set_expand( false );
	item->set_homogeneous( false );
	toolbar->append( *item );
	action->set_accel_group( get_accel_group() );
	action->connect_accelerator();

	Glib::signal_timeout().connect( sigc::mem_fun( *this, &MyApp::timeout_handler ), 2000 );

	resize( 200, 100 );
	show_all_children();
    }
    ~MyApp()
    {
    }

    void action_handler()
    {
	cerr << "tool button pressed" << endl;
	m_refMainGroup->get_action( "test" )->set_sensitive( false );
	Glib::usleep( 1000000 );
	m_refMainGroup->get_action( "test" )->set_sensitive( true );
	cerr << "done" << endl;
	item->grab_focus();
    }

    bool timeout_handler()
    {
	cerr << "timeout tick" << endl;
	m_refMainGroup->get_action( "test" )->set_sensitive( false );
	Glib::usleep( 1000000 );
	m_refMainGroup->get_action( "test" )->set_sensitive( true );
	cerr << "done" << endl;
	item->grab_focus();

	return false;
    }
};

int main( int argc, char* argv[] )
{
    Gtk::Main kit( &argc, &argv );
    MyApp app;
    kit.run( app );
    return 0;
}


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