Re: is it possible to have a widget act as insensitive but look as it is sensitive?
- From: Yiannis <odysseus lost gmail com>
- To: Tristan Van Berkom <tristan van berkom gmail com>
- Cc: gtk-app-devel-list gnome org, gtk-list gnome org
- Subject: Re: is it possible to have a widget act as insensitive but look as it is sensitive?
- Date: Fri, 30 Dec 2005 21:28:47 +0200
Sorry for posting back but my code failed.... :)
On 28/12/05, Tristan Van Berkom <tristan van berkom gmail com
> wrote:
Heh,
I was just jotting it down from memory; I didn't actually
expect it to compile out of the box ;-)
I don't expect answers out of the box.... :). I do check with the
documentation and the source code.... :) So here we go..... Firstly let
me paste Tristan's previous reply to this email too:
Tristan said:
you can:
o Create a sample GtkToggleButton
o Make copies of the GdkColor structs on widget->style.bg[GTK_STATE_NORMAL]
(or is it ACTIVE ?), you might also want the .fg, .base & .text members.
you'd want to do this post gtk_rc_parse().
o Use gtk_widget_modify_bg (widget, GTK_STATE_INSENSITIVE, sensitive_bg)
(and friends) to set the sensitive graphic state onto the insensitive state.
o gtk_widget_set_sensitive (widget, FASLE);
Now, what I tried so far has failed. Here we go:
Modifying directly the values of widget->style:
widget->style->bg[GTK_STATE_INSENSITIVE] = widget->style->bg[GTK_STATE_NORMAL];
widget->style->fg[GTK_STATE_INSENSITIVE] = widget->style->fg[GTK_STATE_NORMAL];
widget->style->base[GTK_STATE_INSENSITIVE] = widget->style->base[GTK_STATE_NORMAL];
widget->style->fg_rc[GTK_STATE_INSENSITIVE] = widget->style->fg_rc[GTK_STATE_NORMAL];
using the gtk_widget_modify_xx functions:
gtk_widget_modify_bg(widget, GTK_STATE_INSENSITIVE, &(widget->style->bg[GTK_STATE_NORMAL]));
gtk_widget_modify_fg(widget, GTK_STATE_INSENSITIVE, &(widget->style->fg[GTK_STATE_NORMAL]));
gtk_widget_modify_base(widget, GTK_STATE_INSENSITIVE, &(widget->style->base[GTK_STATE_NORMAL]));
gtk_widget_modify_text(widget, GTK_STATE_INSENSITIVE, &(widget->style->text[GTK_STATE_NORMAL]));
Copying firstly the GtkStyle, modifying the new one and passing it back
to the widget (using gtk_widget_set_style...) even if this method is
not recommended in the API:
GtkStyle *style = gtk_style_copy(widget->style);
style->fg[GTK_STATE_INSENSITIVE] = style->fg[GTK_STATE_NORMAL];
style->bg[GTK_STATE_INSENSITIVE] = style->bg[GTK_STATE_NORMAL];
style->base[GTK_STATE_INSENSITIVE] = style->base[GTK_STATE_NORMAL];
gtk_widget_set_style(widget, style);
Copying the GtkRcStyle and then using gtk_widget_modify_style to pass
it back... according to the API this is the "recommended" method as
subsequent calls to gtk_widget_modify_XX are cummulative leaving the
rest of the attributes unchanged.
GtkRcStyle *rcstyle = gtk_widget_get_modifier_style(widget);
rcstyle->bg[GTK_STATE_INSENSITIVE] = rcstyle->bg[GTK_STATE_NORMAL];
rcstyle->fg[GTK_STATE_INSENSITIVE] = rcstyle->fg[GTK_STATE_NORMAL];
rcstyle->base[GTK_STATE_INSENSITIVE] = rcstyle->base[GTK_STATE_NORMAL];
gtk_widget_modify_style(widget, rcstyle);
In all cases I call thereafter
gtk_widget_set_sensitive(widget, FALSE);
to make the widget insensitive.
However, none of the above works.... the colours of the insensitive widget are still the ones of an insensitive widget....
Any clues?
The only thing I can think of is that I am not using the right
attributes.... bg, fg, base.... however, I cannot find any
documentation explaining each one of the members in the GtkStyle
structure.... but the names are self-explanatory so they should be the
correct ones.... One more thing I am not fully sure about is the
RcStyle.... This is supposed some kind of file that is used to define a
theme.... Does this affect the GtkStyle? Ie when I call
GtkRcStyle *rcstyle = gtk_widget_get_modifier_style(widget);
what I am copying is the widget->style data structure or something
else??? Because the function return GtkRcStyle* but I cannot find any
GtkRcStyle structure in the gtkwidget.h definition.
--
-- Yiannis
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]