List Info

Thread: Themes and colours




Themes and colours
user name
2006-10-16 00:03:38
Hi all.

I use colours to highlight data - usually in treeviews. I
realise that
this is somewhat frowned upon with themable toolkits, but on
the other hand this is a requirement from our users, and
does
make data a lot easier to interpret with a quick glance.

For example, I use $treeview_column->set_cell_data_func
to highlight
negative values in red:

if ( $value < 0 ) {
   $renderer->set( foreground  => "red" );
} else {
   $renderer->set( foreground  => "black" );
}

With most themes, this is OK, but with some of the darker
themes
( which are my favourite ), the black text is unreadable. I
need to be
able to find out what colours a theme is using - mainly in
treeviews.

I've been reading a bit on
Gtk2::Widget->get_default_style and
Gtk2::Style, but I'm not sure if I can do what I want to do.
Here's
what I want to do ...

- find out what default colour a cell's text will be,
according to the
current Gtk2 theme ( most important )

- find out what colour a cell's text will be when the row is
selected
( helps me to decide what text colours might be appropriate
)

- find out what colours a cell's background alternates
between when
'rules hinting' is on ( less important )

Is this stuff possible?

Dan

_______________________________________________
gtk-perl-list mailing list
gtk-perl-listgnome.org

http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Themes and colours
user name
2006-10-16 00:35:31
On Oct 15, 2006, at 8:03 PM, Daniel Kasak wrote:

> I've been reading a bit on
Gtk2::Widget->get_default_style and
> Gtk2::Style, but I'm not sure if I can do what I want
to do. Here's
> what I want to do ...
>
> - find out what default colour a cell's text will be,
according to the
> current Gtk2 theme ( most important )
>
> - find out what colour a cell's text will be when the
row is selected
> ( helps me to decide what text colours might be
appropriate )
>
> - find out what colours a cell's background alternates
between when
> 'rules hinting' is on ( less important )
>
> Is this stuff possible?

You can read the gtk+ source and find the answers, but
they're  
probably not guaranteed.

In general:

- the text color will come from the TreeView's style's
"text" color;  
the state is determined by mapping the cell renderer's state
into the  
GtkWidgetState enumeration values.

- the background color is from the TreeView's style's
"base" color.   
again, the state is determined by mapping the renderer's
state.   
"selected" is most important here.

- the treeview sets up the "cell_odd_ruled" etc
detail for GtkStyle  
when drawing a ruled view.  the default implementation uses
a custom  
function to "darken" the base color (using a
trivial scaling of  
luminance and saturation in the HLS colorspace) by some
initially non- 
obvious rules.  the upshot is that i think this is entirely
theme- 
dependent, and there appears to be no way to query it.  if
you  
*really* need the color, you may have to resort to
screen-scraping.

--
"Ghostbusters" is the best movie of this decade.
   -- Neal, circa 1996, referring to a movie released in
1984.

_______________________________________________
gtk-perl-list mailing list
gtk-perl-listgnome.org

http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Themes and colours
user name
2006-10-17 21:00:22
Thanks for the response muppet 


muppet wrote:

> - the text color will come from the TreeView's style's
"text"
> color; the state is determined by mapping the cell
renderer's state

How do I get to the state? I've found plenty of
documentation that
*uses* this state, but none about getting it. Sorry. I'm
having a slow
couple of days ...

Dan

_______________________________________________
gtk-perl-list mailing list
gtk-perl-listgnome.org

http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Themes and colours
user name
2006-10-17 22:01:51
On Wed, 2006-10-18 at 07:00 +1000, Daniel Kasak wrote:

> > - the text color will come from the TreeView's
style's "text"
> > color; the state is determined by mapping the cell
renderer's state
> 
> How do I get to the state? I've found plenty of
documentation that
> *uses* this state, but none about getting it. Sorry.
I'm having a slow
> couple of days ...

I'm not sure what state you're referring to here.  I can
think of a few
things, all of which are accessible:

* Is the Gtk2::TreeView insensitive?  Look at
$view->state.

* Does the view itself have focus?  $view->has_focus.

* Is a certain row in the view selected?
$view->get_selection->iter_is_selected ($iter) or
$view->get_selection->path_is_selected ($path).

* Which cell has keyboard focus?  $view->get_cursor.

-- 
Bye,
-Torsten

_______________________________________________
gtk-perl-list mailing list
gtk-perl-listgnome.org

http://mail.gnome.org/mailman/listinfo/gtk-perl-list
[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )