Hi Jeff

you were right, I got a segmetation error. But the reason was, I deleted
1 linr too many,

but I still got the problem, my backgroundcolour is still black, and I
would like to change it to different colours

Here is the new code :
           
        gint MaleDrehscheibe(gpointer data)
        {
                GtkWidget* drawing_area = (GtkWidget *) data;
                GdkDrawable *drawable;
                GdkGC *gc;
                GdkFont *font;
                GdkColormap *colormap;
                GdkColor color = { 0xffff,0xffff,0xffff,0xffff};

                gc = gdk_gc_new (drawing_area->window);
                colormap = gtk_widget_get_colormap (drawing_area);
                if (!gdk_colormap_alloc_color (colormap, &color, FALSE,
TRUE))
                        g_warning ("Failed to allocate color");

                drawable = drawing_area->window;

                gdk_gc_set_background(gc, &color) ;

                gdk_draw_arc(drawable, gc, 1, 0, 0, 127, 127, 0, 360
*64);

                font =
gdk_font_load("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*");
                gdk_draw_text (drawable, font,
drawing_area->style->black_gc, 30, 70, "Drehscheibe",11);
                return 1;       
                
        }


Elisabeth Hibberd
email:[EMAIL PROTECTED]
Vossloh System-Technik
24145 Kiel
Edisonstraße 3
Tel: (49) 431 7109 354
Fax: (49) 431 7109 502 

> -----Ursprüngliche Nachricht-----
> Von:  Jeff Gunter [SMTP:[EMAIL PROTECTED]]
> Gesendet am:  Keines
> An:   [EMAIL PROTECTED]
> Betreff:      Re: AW: Drawing circle
> 
> > 
> > Hi Chaplin,
> > 
> > here is the code for drawing the circle
> > 
> >
> /*------------DrawDrehscheibe-----------------------------------------
> --
> > ---------------------*/
> > gint MaleDrehscheibe(gpointer data)
> > {
> >     GtkWidget* drawing_area = (GtkWidget *) data;
> >     GdkDrawable *drawable;
> >     GdkGC *gc;
> >     GdkFont *font;
> > 
> >     GdkColor color = { 0xffff,0xffff,0xffff,0xffff};
> >     drawable = drawing_area->window;
> >     
> >     gdk_gc_set_background(gc, &color) ;
> >     gdk_draw_arc(drawable, gc, 1, 0, 0, 127, 127, 0, 360 *64);
> > 
> >     font =
> >
> gdk_font_load("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*");
> >     gdk_draw_text (drawable, font, drawing_area->style->black_gc,
> > 30, 70, "Drehscheibe",11);
> >     return 1;       
> > }
> > 
> 
> 
> 
> Don't you get a SEGFAULT when this runs?  You have defined gc as a
> pointer to 
> a graphics context but never allocated that graphics context or set gc
> to 
> point to a known graphics context. I would suggest adding something
> like this:
> 
> 
> static GdkGC *gc=NULL;        
> 
> . 
> . 
> . 
> if(!gc)
> {
>  GdkColor color= {0xffff,0xffff,0xffff,0xffff};
>  gc=gdk_gc_new(drawable);
>  gdk_gc_set_background(gc, &color) ;
> }     
>  
> The idea is to create a basically valid gc from your drawing area and
> modify
> it.  Since this involve shipping things back and forth to the X-server
> do it
> once and remember the pointer.
> 
>  
>       
> 
> +---------------------------------------------------------------------
> +
> To unsubscribe from this list, send a message to [EMAIL PROTECTED]
> with the line "unsubscribe glade-devel" in the body of the message.

+---------------------------------------------------------------------+
To unsubscribe from this list, send a message to [EMAIL PROTECTED]
with the line "unsubscribe glade-devel" in the body of the message.

Reply via email to