#include <gtk/gtk.h>

#define N_LEVELS 4

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

  GtkCssProvider *css_provider = gtk_css_provider_new ();
  gtk_css_provider_load_from_data (css_provider,
    /*
    "frame.level0 > border { background-color: rgba(0, 0, 0, 0.2); }\n"
    "frame.level1 > border { background-color: rgba(0, 0, 0, 0.2); }\n"
    "frame.level2 > border { background-color: rgba(0, 0, 0, 0.2); }\n"
    "frame.level3 > border { background-color: rgba(0, 0, 0, 0.2); }\n"
    */
    "frame.level0 > border { background-color: rgba(0, 0, 0, 0.2); }\n"
    "frame.level1 > border { background-color: rgba(1, 0, 0, 0.2); }\n"
    "frame.level2 > border { background-color: rgba(0, 2, 0, 0.2); }\n"
    "frame.level3 > border { background-color: rgba(0, 0, 3, 0.2); }\n"
    /*
    "frame.level0 > border { background-color: rgba(0, 0, 0, 0.2); }\n"
    "frame.level1 > border { background-color: rgba(1, 1, 1, 0.2); }\n"
    "frame.level2 > border { background-color: rgba(2, 2, 2, 0.2); }\n"
    "frame.level3 > border { background-color: rgba(3, 3, 3, 0.2); }\n"
    */
    /*
    "frame.level0 > border { background-color: rgba(  0,   0,   0, 0.2); }\n"
    "frame.level1 > border { background-color: rgba(255,   0,   0, 0.2); }\n"
    "frame.level2 > border { background-color: rgba(  0, 255,   0, 0.2); }\n"
    "frame.level3 > border { background-color: rgba(  0,   0, 255, 0.2); }\n"
    */
                                   , -1, NULL);

  gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
                                             GTK_STYLE_PROVIDER (css_provider),
                                             GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

  GtkWidget *containers[N_LEVELS];
  for (unsigned i = 0; i < N_LEVELS; ++i)
  {
    containers[i] = gtk_frame_new (g_strdup_printf ("%i", i));
    char *cssclass = g_strdup_printf ("level%u", i);
    gtk_style_context_add_class (gtk_widget_get_style_context (containers[i]),
                                 cssclass);
    g_free (cssclass);
    gtk_container_set_border_width (GTK_CONTAINER (containers[i]), 6);

    if (i > 0)
      gtk_container_add (GTK_CONTAINER (containers[i - 1]), containers[i]);
  }

  GtkWidget *scale = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL,
                                               0, 100, 1);
  gtk_widget_set_size_request (scale, 42, 127);

  GtkWidget *check_button = gtk_check_button_new_with_label ("GtkCheckButton");

  GtkWidget *box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_container_add (GTK_CONTAINER (box), scale);
  gtk_container_add (GTK_CONTAINER (box), check_button);
  gtk_container_add (GTK_CONTAINER (containers[N_LEVELS - 1]), box);

  GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_container_add (GTK_CONTAINER (window), containers[0]);
  g_signal_connect (G_OBJECT (window), "delete-event",
                    G_CALLBACK (&gtk_main_quit), NULL);
  gtk_widget_show_all (window);

  gtk_main ();
}
