Re: How can I retrieve gtk style context information from textview widget class without a textview widget?
- From: Colomban Wendling <lists ban herbesfolles org>
- To: gtk-app-devel-list gnome org
- Subject: Re: How can I retrieve gtk style context information from textview widget class without a textview widget?
- Date: Sat, 13 Jun 2015 00:39:11 +0200
Hi,
Le 12/06/2015 14:04, Friedrich Beckmann wrote:
I would like to use the style information from the textview widget in
another context. I want to retrieve the text foreground color and the
background color as it would be used in a textview widget and use
this style information for rendering inside a drawing area. […]
[…]
Is there a way to retrieve this information of the background-color
similar to the class mechanism? I would need the same style context
as if I was in a textview widget.
Don't take my words as gospel, but there's something:
First, realize that you can't reliably achieve the same look as the
theme by simply picking background and foreground colors: the theme
might be using gradients, images and whatnot.
If you want to paint it like a text view, you should probably use the
GTK rendering functions, like gtk_render_background() and
gtk_render_layout().
Then, if you don't have an actual GtkTextView to get the style context
from, you'll need to create it yourself faking the one a true text view
would have. You can probably do that relatively easily with
gtk_style_context_new() and then setting an appropriate widget path with
gtk_style_context_set_path() -- and possibly appropriate classes, as you
already figured out.
Regards,
Colomban
https://developer.gnome.org/gtk3/stable/GtkStyleContext.html#gtk-render-background
https://developer.gnome.org/gtk3/stable/GtkStyleContext.html#gtk-render-layout
https://developer.gnome.org/gtk3/stable/GtkStyleContext.html#gtk-style-context-new
https://developer.gnome.org/gtk3/stable/GtkStyleContext.html#gtk-style-context-set-path
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]