Re: CSS



On 30/11/2018 21:16, Damon Chaplin wrote:
On Sun, 2018-11-25 at 17:12 +0100, Jeffrey Ratcliffe via goocanvas-list 
wrote:
gscan2pdf uses goocanvas to display the OCR output.

A user has asked how to change the colours of the fore- and
background
of the canvas and I haven't managed to work out what CSS is needed to
do so (without changing the everything else).

Obviously the CSS would then end up in

~/.config/gtk-3.0/gtk.css


I'm not sure you can do it with CSS, but you could use a preferences
dialog and set the colors directly in the code.

After some more investigation, I've found that you can extract the
foreground colour with:

   my $style        = $self->get_style_context;
   my $color_string = $style->get_color('normal')->to_string;

Convert it to hex with:

   if ( $color_string =~ /^rgb[(](\d+),(\d+),(\d+)[)]$/smx ) {
        $color_hex = sprintf '#%02x%02x%02x', ( $1, $2, $3 );
   }

Which you can use as the "stroke-color" or "fill-color", etc.

If you name the canvas widget with something like:

   $self->set_name('my-canvas-widget-name');

Adding something like the following to ~/.config/gtk-3.0/gtk.css will
allow you to theme just your widget:

#my-canvas-widget-name {
  color: red;
}

Regards

Jeff

Attachment: signature.asc
Description: OpenPGP digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]