#!/usr/bin/perl use strict; use diagnostics; use warnings; #use Glib qw(TRUE FALSE); use Gtk3 '-init'; # Set up CSS style my $provider = Gtk3::CssProvider->new(); # Why are these lines necessary? What function do they serve? my $display = Gtk3::Gdk::Display::get_default; my $screen = Gtk3::Gdk::Display::get_default_screen($display); Gtk3::StyleContext::add_provider_for_screen($screen, $provider, 600); # This applies the style to the whole window #my $theming = "* {\nbackground-color: #000000;\ncolor: #FF0000;\n}"; #$provider->load_from_data($theming, -1, undef); # But this doesn't apply the style (just) to the textview my $theming = "GtkTextView {\nbackground-color: #000000;\ncolor: #FF0000;\n}"; $provider->load_from_data($theming, -1, undef); # Open a Gtk3 window containing a Gtk3::TextView my $window = Gtk3::Window->new('toplevel'); $window->set_title('Hello world'); $window->set_position('center'); $window->set_default_size(600, 400); $window->signal_connect('delete-event' => sub { Gtk3->main_quit(); exit; }); my $scrollWin = Gtk3::ScrolledWindow->new(undef, undef); $window->add($scrollWin); my $textView = Gtk3::TextView->new; $scrollWin->add_with_viewport($textView); $textView->get_buffer()->set_text("Hello, world!"); $window->show_all(); # Start Gtk3's main loop Gtk3->main();