#!/usr/bin/perl -w

use strict;
use warnings;

use Gtk3		'-init';
use Glib		qw (TRUE FALSE );




#$p->load_from_data ([map ord, split //, "GtkTextView { color: blue; font: Serif 38; background-color: yellow; -GtkWidget-cursor-color: red; }\n
#GtkTextView:selected { background-color: black; color: green  } " ]);
#print $p->to_string,"\n";


#$p->load_from_file ( '/common/home/harms/gtk3/test/Style.css' );


#Gtk3::StyleContext::add_provider_for_screen ( $s, $p, Gtk3::STYLE_PROVIDER_PRIORITY_USER);

    my $f_main = Gtk3::Window->new ();

    my $f_outer = Gtk3::VBox->new ( FALSE, 0 );
    $f_main->add ( $f_outer );

    my $f_top = Gtk3::HBox->new ();
    $f_top->set_size_request ( 300, 100 );
    $f_outer->pack_start ( $f_top, FALSE, FALSE, 0 );


    my $css_provider = Gtk3::CssProvider->new ();

if (0) {
   my $x_error;
   $css_provider->load_from_file ( '/common/home/harms/gtk3/test/Style.css',
								\$x_error );
# fails with
# Gtk-CRITICAL **:gtk_css_provider_load_from_file: assertion `G_IS_FILE (file)'
} else {


   $css_provider->load_from_data ( [map ord, split //, "
		GtkEventBox {	background-color: blue }
		GtkWindow {	background-color: green }
		GtkViewport {	background-color: pink }	" ]);

    my $css_display = Gtk3::Gdk::Display::get_default ();
    my $css_screen = $css_display->get_default_screen;

    Gtk3::StyleContext::add_provider_for_screen ( $css_screen, $css_provider,
					Gtk3::STYLE_PROVIDER_PRIORITY_USER);
}


    my $f_middle = Gtk3::ScrolledWindow->new ();
    $f_outer->pack_start ( $f_middle, FALSE, FALSE, 0 );
    $f_middle->set_size_request ( -1, 100 );
    $f_middle->set_policy ( 'never', 'always' );

    my $view_port = Gtk3::Viewport->new ( 0.0, 0.0 );
    $f_middle->add ( $view_port );

    my $e_box2 = Gtk3::EventBox->new ( FALSE, 0 );
    $view_port->add ( $e_box2 );


    my $e_box2 = Gtk3::EventBox->new();
    $view_port->add ( $e_box2 );

    $e_box2 = Gtk3::EventBox->new();
    $e_box2->set_size_request ( -1, 100 );
    $f_outer->pack_start ( $e_box2, FALSE, FALSE, 0 );

    $f_main->show_all;

Gtk3->main;
