Re: [gtk-list] Re: gtk_rc_get_style_by_name()?

"Michael K. Johnson" writes:
>I wrote:
>>Doh!  I've found gtk_rc_style_find(), which appears to do what I want.

But gtk_rc_style_find returns a GtkRcStyle, not a GtkStyle. The
GtkRcStyle contains a GtkStyle which may need to be initialized. I
guess I can add a gtk_rc_style_by_name if its desired. 

>If it were exported, it might.  There are several rc functions that are
>static that would be useful.  Is there a reason for that, or can we make
>some of them available?

Name 'em, explain why they might be useful and I'll see about
exporting them. 

>I'd really like to keep those style definitions out of the executable,
>in the configuration file.  Is it possible?  Is it supposed to be

As mentioned by someone else on the list, gtk_widget_set_name does
weird things with changing the style. Why did I do it that way? I
can't remember. Probably because gtk_widget_set_style wasn't
implemented for a long time. Anyways, changing gtk_widget_set_name to
the following worked for me in a small little test:

gtk_widget_set_name (GtkWidget *widget,
		     gchar     *name)
  GtkStyle *new_style;

  g_return_if_fail (widget != NULL);

  if (widget->name)
    g_free (widget->name);
  widget->name = g_strdup (name);

  new_style = gtk_rc_get_style (widget);
  gtk_widget_set_style (widget, new_style);

My test basically involved creating a resource file that contained: 

style "foo"
  bg[PRELIGHT] = { 0, 0, 65535 } # blue

widget "*.foo.*" style "foo"

Which means any widget named "foo" (and all its children) will have
the style "foo". I then used a simple hello world program with a
single push button, ran it in gdb. Initially it has the default
style. Using gdb I changed the buttons name to "foo" and now it has
style "foo" and its prelight color has changed. 

For some reason, I had gtk_widget_set_name not change the style if the
widget was already realized (visible on the screen). This was
undoubtedly causing the problem for you.


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