setting background color of eventbox ... how?



Hi there,
trying to create a composite widget, I'd like to arrange the individual widgets in a table. I also want to have the space between the individual widgets painted black.

I've gotten as far as finding out that I need an eventbox to do that because a table doesn't have its own background. So I added one ... but I still fail to find the right
method for setting the background:

I've tried:
1)
       colormap = gtk_widget_get_colormap(GTK_WIDGET(ebox));
          if (gdk_color_parse("black", &g_col)){
             if (gdk_colormap_alloc_color(colormap, &g_col, FALSE, TRUE)) {
gtk_widget_modify_bg (GTK_WIDGET(ebox), GTK_STATE_NORMAL, &g_col);
       }
   }

No effect ..

2)
   g_object_get((gpointer) w, (gchar*) "style", (GtkStyle) style);

          if (gdk_color_parse("black", &g_col)){
             if (gdk_colormap_alloc_color(colormap, &g_col, FALSE, TRUE)) {
                   for ( i=0 ; i<5 ;i++ ) style.bg[i] = g_col;
gtk_style_set_background (&style, w->window, GTK_STATE_NORMAL);
       }
   }

fails with "(gtk_style_set_background): assertion `GTK_IS_STYLE (style)' failed" .... Huh?

3)
in a "state-changed" and "realize" event handler:

   colormap = NULL;
   colormap = gdk_drawable_get_colormap (w->window);

          if (gdk_color_parse("black", &g_col)){
             if (gdk_colormap_alloc_color(colormap, &g_col, FALSE, TRUE)) {
           gdk_window_set_background (GDK_WINDOW(w->window), &g_col);
       }
   }

this flashes up the black colour for a split second, then gets repainted in the parent
window's default bg.

If somebody could point me to what I'm doing wrong here, that would be much
appreciated.

TIA,

Karl.





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