problems setting bgcolor of a window



hi,

I'm having some trouble setting the background colour of a window.  I've
tried lots of different methods, and have gone through the docs and the
list's archives looking for a solution, but nothing seems to work.  The code
below does change the colour of my window, but it then crashes my
application.  Does anyone know what I'm doing wrong?

Stella

typedef struct {
    /* answer window widget, and properties */
    GtkWidget *answer_window;
 } ballData;

void
give_answer(AppletWidget *applet, gpointer data)
{
    ballData *mb = data;
    GdkColor *bg_color;

    if (mb->answer_window != NULL) {
    /* raise the window */
        gdk_window_show(mb->answer_window->window);
        gdk_window_raise(mb->answer_window->window);
    } else {
        mb->answer_window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
        signal_connect( GTK_OBJECT (mb->answer_window), "destroy",
                        GTK_SIGNAL_FUNC (close_answer_window), mb );
        container_set_border_width( GTK_CONTAINER (mb->answer_window), 10 );
        widget_realize(mb->answer_window);
    }

    /* set up the background colour */
    bg_color->red = 0;
    bg_color->green = 0;
    bg_color->blue = 0;
    gdk_colormap_alloc_color(gtk_widget_get_colormap(mb->answer_window),bg_color,FALSE,TRUE);
    gdk_window_set_background(mb->answer_window->window, bg_color);
    
    gtk_widget_show(mb->answer_window);
 }



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