Re: [gtk-list] Re: style usage + memory leak
- From: Robert Roebling <roebling sun2 ruf uni-freiburg de>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: style usage + memory leak
- Date: Thu, 29 Oct 1998 21:36:57 +0100
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
--
------------------------------------------------------------------
Robert Roebling "Write once, compile, run everywhere"
wxWindows/GTK http://wesley.informatik.uni-freiburg.de/~wxxt
#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);
gtk_widget_realize(window);
/*
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
*/
color.red = 40000;
color.green = 40000;
color.blue = 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);
gtk_main();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]