Re: [gtk-list] Re: style usage + memory leak

Eric Harlow wrote:
> Nope nope nope.  Ran a little test to see what the ref count was and
> when the style was created, the ref count was 1.  Adding it to a
> button makes the ref count be 3.   I suspect this is because it's
> adding the style to the button and the contained label, but I haven't
> verified this.

No, setting a style to the widget doesn't change the
label's color e.g. Proof atttached.


Robert Roebling              "Write once, compile, run everywhere"


#include <gtk/gtk.h>

int main (int argc, char *argv[])
    GtkWidget     *window;
    GtkWidget     *menu;
    GtkWidget     *button;
    GdkColor       color;
    GdkColormap   *colormap;
    GtkStyle      *style;

    gtk_init (&argc, &argv);
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title (GTK_WINDOW (window), "Style usage?");

    gtk_container_border_width (GTK_CONTAINER (window), 10);

       create simple button
    button = gtk_button_new_with_label( "Hallo" );
    gtk_container_add (GTK_CONTAINER (window), button );
    gtk_widget_realize( button );
    gtk_widget_show( button );
      create style by copying an existing one
    style = gtk_style_copy( gtk_widget_get_style( button ) );

      create color and assign it to style's background
      = 40000; = 40000;  = 40000;
    colormap = gdk_window_get_colormap( button->window );
    gdk_color_alloc( colormap, &color );
    style->fg[GTK_STATE_NORMAL] = color;
      assign style to button
      color will not affect label unless uncommented
    gtk_widget_set_style( button, style );
//    gtk_widget_set_style( GTK_BUTTON(button)->child, style );
    gtk_style_unref( style );
    gtk_widget_show (window);
    return 0;

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