2 #include <libchimara/chimara-glk.h>
4 /* This is a test program for CSS styling of the Glk program, which is not
7 /* Style the GUI funky */
9 style1(GtkButton *button, GtkStyleProvider *funky_provider)
11 gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), funky_provider, GTK_STYLE_PROVIDER_PRIORITY_USER);
14 /* Style the GUI nicely */
16 style2(GtkButton *button, GtkStyleProvider *funky_provider)
18 gtk_style_context_remove_provider_for_screen(gdk_screen_get_default(), funky_provider);
22 main(int argc, char **argv)
25 gtk_init(&argc, &argv);
28 GtkWidget *win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
29 GtkWidget *grid = gtk_grid_new();
30 GtkWidget *glk = chimara_glk_new();
31 GtkWidget *stylebutton1 = gtk_button_new_with_label("Style 1");
32 GtkWidget *stylebutton2 = gtk_button_new_with_label("Style 2");
33 GtkCssProvider *funky_provider = gtk_css_provider_new();
35 /* Set properties on widgets */
36 gtk_widget_set_size_request(win, 400, 400);
37 g_object_set(glk, "expand", TRUE, NULL);
39 gboolean res = gtk_css_provider_load_from_data(funky_provider,
43 " font-family: \"Andale Mono\";"
48 " margin-bottom: 5px;"
49 " font-family: \"Book Antiqua\";"
51 ".glk buffer.header { font-weight: bold; }\n"
60 ".glk buffer.block-quote {"
61 " /*text-align: center;*/"
62 " font-style: italic;"
66 " font-style: italic;"
68 ".glk blank { background-color: #4e702a; }\n"
70 " background-image: -gtk-gradient(linear, 0 0, 0 1,"
71 " color-stop(0, @yellow),"
72 " color-stop(0.2, @blue),"
73 " color-stop(1, #0f0));"
77 g_printerr("Error: %s\n", error->message);
79 /* Put widgets together */
80 gtk_grid_attach(GTK_GRID(grid), stylebutton1, 0, 0, 1, 1);
81 gtk_grid_attach_next_to(GTK_GRID(grid), stylebutton2, NULL, GTK_POS_RIGHT, 1, 1);
82 gtk_grid_attach(GTK_GRID(grid), glk, 0, 1, 2, 1);
83 gtk_container_add(GTK_CONTAINER(win), grid);
86 g_signal_connect(win, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
87 g_signal_connect(stylebutton1, "clicked", G_CALLBACK(style1), funky_provider);
88 g_signal_connect(stylebutton2, "clicked", G_CALLBACK(style2), funky_provider);
91 gtk_widget_show_all(win);
93 char *plugin_argv[] = { "styletest" };
94 chimara_glk_run(CHIMARA_GLK(glk), ".libs/styletest.so", 1, plugin_argv, NULL);
100 chimara_glk_stop(CHIMARA_GLK(glk));
101 chimara_glk_wait(CHIMARA_GLK(glk));
103 g_object_unref(funky_provider);