[gtkmm] Gtk::Button.set_flags() && GTK_WIDGET_SET_FLAGS ( widget , GTK_CAN_DEFAULT)



Maybe I'm just a newbie.... but can anybody tell me why this

#include <gtkmm.h>
#include <gtkmm/main.h>

using namespace Gtk;

class BuggyWindow : public Window
{
	public:
	BuggyWindow();
	virtual ~BuggyWindow(){}	
	
	protected:
	
	VBox m_VBox;
	TextView m_TextView;
	Entry m_Entry;
	Button m_Button;
	
	virtual void on_m_Button_clicked();
};

BuggyWindow::BuggyWindow() : m_Button("Don't click me !")
{
	set_title("My Buggy Window");
	
	m_VBox.pack_start(m_TextView);
	m_VBox.pack_start(m_Entry);
	m_VBox.pack_start(m_Button);
	
	/*GTK_WIDGET_SET_FLAGS (m_Button , GTK_CAN_DEFAULT);    		
compile-time error: cannot convert
          `this->BuggyWindow::m_Button' from type `
      	Gtk::Button' to type `GTypeInstance*' */

	m_Button.set_flags(CAN_DEFAULT);  /*-> runtime error:  			 	
Gtk-WARNING **: gtkwidget.c:3571: widget not within a 				GtkWindow &&
doesn't work */
	
	m_Button.grab_default();
	
	m_Entry.set_activates_default();
	
	m_Button.signal_clicked().connect(SigC::slot(*this, 						
&BuggyWindow::on_m_Button_clicked));
	
	add(m_VBox);
	m_VBox.show_all();
}

void BuggyWindow::on_m_Button_clicked()
{
	Glib::RefPtr<TextBuffer> m_TextBuffer = m_TextView.get_buffer();
	m_TextBuffer->insert_at_cursor("Outch - did you like that ? 										\n");
	m_Entry.grab_focus();
}

int main(int argc, char* argv[])
{
	Main kit(argc, argv);
	
	BuggyWindow m_BuggyWindow;	
	Main::run(m_BuggyWindow);
	
	return 0;
}

doesn't work ? I'm using gcc 3.2.2, gtkmm 2.20, gtk+ libary 2.2.1 ....
it means the latest versions available in the gentoo-portage-tree.
Thanks for your help !






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