GtkSourceView-CRITICAL : I am wrong or a SourceView bug ?



Hello,

I get this message when I play with my following minimal example.

(minimal:14414): GtkSourceView-CRITICAL **:
gtk_source_undo_manager_undo: assertion `undo_action != NULL' failed

Anybody can help me ?

Thanks a lot,
-- 
François

#include <string>
#include <gtkmm.h>
#include <gtksourceviewmm.h>

using namespace std ;
using namespace Glib ;
#define Gsv gtksourceview

class OverriddenSourceView ;

class App {
	private :
		Gtk::Window * m_ptr_window ;
		OverriddenSourceView * m_ptr_source_view ;
	public:
		App() ;
		~App() ;
		Gtk::Window & get_window() const { return *m_ptr_window ; }
		bool on_key_press_event(GdkEventKey* event) ;
		bool on_key_release_event(GdkEventKey* event) ;
} ;

// This class exists only to intercept the "on_key_press_event" events
adressed to the
// source_view et to redirect the events to the member functions
// "App::on_key_press_event".
class OverriddenSourceView : public Gsv::SourceView {
	private :
		App * m_ptr_App ;
		typedef bool (App::*tmp_t)(GdkEventKey *) ;
		tmp_t m_ptr_key_press ;
	public :
		OverriddenSourceView (App & App ,tmp_t ptr_key_press) :
			SourceView(),
			m_ptr_App(&App),
			m_ptr_key_press(ptr_key_press) {}
	protected :
		// If the member function return "true", then return "true" to stop
the key process;
		// else call the process of the SourceView class.
		virtual bool on_key_press_event(GdkEventKey* event) {
			return (m_ptr_App->*m_ptr_key_press)(event) ? true :
				Gsv::SourceView::on_key_press_event(event) ;
		}
} ;
App::App() {
	m_ptr_window = new(Gtk::Window) ;
	m_ptr_source_view = manage(new OverriddenSourceView(*this,
		&App::on_key_press_event)) ;
	m_ptr_window->add(*m_ptr_source_view) ;
	RefPtr<Gsv::SourceBuffer> ptr_sb = m_ptr_source_view->get_source_buffer() ;
	ptr_sb->begin_not_undoable_action() ;
	ptr_sb->insert(ptr_sb->begin(), "First line\nSecond line") ;
	ptr_sb->end_not_undoable_action() ;
	ptr_sb->set_modified(false) ;
}
App::~App() {
	if (m_ptr_window) {
		delete m_ptr_window ;
		m_ptr_window = 0 ;
	}
}
bool App::on_key_press_event(GdkEventKey* event) {
	if ( event->keyval == GDK_Tab ) {
		m_ptr_source_view->get_source_buffer()->insert_at_cursor("##TAB##") ;
		return true ; // Stop the SourceView process of key pressed.
	}
	return false ;
}
int main(int argc, char **argv) {
	Gtk::Main kit(argc, argv) ;
	gtksourceview::init() ;

	App App ;
	App.get_window().set_size_request(500, 400) ;
	App.get_window().show_all() ;
	kit.run(App.get_window()) ;

	return 0 ;
}


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