Re: custom widget theme change problem



Hello again,

Seems to be a habit of mine here, I ask a question, don't get an
immediate response and then look further into it and find some sort of
solution...

On 21 June 2012 10:42, James Morris <jwm art net gmail com> wrote:
Hi,

I have a custom GTK widget which renders using Cairo. In the expose
callback gtk_widget_get_style is called to obtain colours to render
the widget with some theme consistency.

When a theme is changed (ie using gtk-chtheme) any of my custom
widgets that are visible are not updated. However, after switching to
a different notebook tab, I can see previously hidden instances of the
custom widget have been updated (switching notebook tabs back again
does not trigger update).

Can anyone give any pointers as to what might be happening?

I've found the culprit, or put another way, I've found what to comment
out to fix the problem.

In my custom_widget_realize callback it has the following code which
if I comment out the last three lines of, the problem resolves:

    window = gtk_widget_get_parent_window (widget);
    gtk_widget_set_window(widget, window);
    g_object_ref (window);

    style = gtk_widget_get_style(widget);
    style = gtk_style_attach(style, window);
    gtk_widget_set_style(widget, style);

It is code I updated from this old code (which won't compile with
GTK_DISABLE_DEPRECATED etc):

    widget->window = gtk_widget_get_parent_window (widget);
    g_object_ref (widget->window);
    widget->style = gtk_style_attach (widget->style, widget->window);

This old code (which uses GDK rather than Cairo) doesn't have any
problem with theme changes... but without it the widgets aren't
updated after theme changes.

Scratching head..
James.


Thanks,
James.

GTK 2.24.10



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