
/* gcc $(pkg-config --cflags --libs gtk+-2.0) -o test gnome-438114-test.c
 * && ./test
 *
 * vim:set fdm=marker:
 */

#include <gtk/gtk.h>

typedef struct _SwTest SwTest;
typedef struct _SwTestClass SwTestClass;

struct _SwTest
{
    GtkScrolledWindow parent;
};

struct _SwTestClass
{
    GtkScrolledWindowClass parent;
};

static void
sw_test_init(SwTest *self)
{
#ifdef WORKAROUND
    g_object_set(self, "hadjustment", NULL, "vadjustment", NULL, NULL);
#endif

    GtkWidget *tv = gtk_text_view_new();
    gtk_container_add(GTK_CONTAINER(self), tv);
    gtk_widget_show(tv);
}

GType sw_test_get_type(void)
{
    static GType type = 0;
    if (!type)
    {
	type = g_type_register_static_simple(
		GTK_TYPE_SCROLLED_WINDOW,
		"SwTest",
		sizeof(SwTestClass),
		NULL,
		sizeof(SwTest),
		(GInstanceInitFunc)sw_test_init,
		0
	    );
    }
    return type;
}

int main(int argc, char **argv)
{
    gtk_init(&argc, &argv);

    GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
    gtk_widget_show(window);

    /* This is not a plausible scenario, of course.  Normally one would use
     * _new()... */
    GtkWidget *sw = g_object_new(sw_test_get_type(), NULL);
    gtk_container_add(GTK_CONTAINER(window), sw);
    gtk_widget_show(sw);

    gtk_window_present(GTK_WINDOW(window));

    gtk_main();

    return 0;
}

