#include <gtk/gtk.h>
#include <gtksourceview/gtksourceview.h>
#include <gtksourceview/gtksourcebuffer.h>
#include <gtksourceview/gtksourcelanguagemanager.h>

int
main(int argc, char **argv)
{
	gtk_init(&argc, &argv);
	
	/* Construct the widgets */
	GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size(GTK_WINDOW(window), 300, 300);
	g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
	GtkWidget *scr = gtk_scrolled_window_new(NULL, NULL);
	gtk_container_add(GTK_CONTAINER(window), scr);
	
	/* Uncomment the following line and comment the one after it to get the
	expected behavior */
	/* GtkWidget *sourceview = gtk_source_view_new(); */
	GtkWidget *sourceview = GTK_WIDGET(g_object_new(GTK_TYPE_SOURCE_VIEW, NULL));
	
	gtk_container_add(GTK_CONTAINER(scr), sourceview);
	
	/* Get the buffer */
	GtkSourceBuffer *sourcebuffer = GTK_SOURCE_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(sourceview)));
	
	/* Do stuff to the buffer, to prove we've really got the GtkSourceBuffer */
	gtk_text_buffer_set_text(GTK_TEXT_BUFFER(sourcebuffer),
		"def hello():\n\tprint 'This should be highlighted as Python'\n", -1);
	GtkSourceLanguageManager *manager = gtk_source_language_manager_get_default();
	GtkSourceLanguage *python = gtk_source_language_manager_get_language(manager, "python");
	gtk_source_buffer_set_language(sourcebuffer, python);
	
	/* Okay, that should prove it, now run the program */
	gtk_widget_show_all(window);
	gtk_main();

	return 0;
}
